@pubnio/cli 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ ${t}}`;return n},Mg="~effect/Fiber",P2={_A:Ee,_E:Ee},R2=0,xC=(()=>{try{return gl
32
32
  `)===-1&&e.indexOf("\r")===-1?e:e.replace(/[\n\r]/g,"");var rm=(e)=>Xz(typeof e==="string"?LR.encode(e):e),nm=(e)=>{let t=UR(e),r=t.length;if(r%4!==0)return Nt(new pc({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(n!==-1&&(n<r-2||n===r-2&&t[r-1]!=="="))return Nt(new pc({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));let o=t.endsWith("==")?2:t.endsWith("=")?1:0,i=3*(r/4)-o,s=PR(t,i,void 0);if(s)return Zt(s);if(s===null){let c=nj.exec(t);if(c!==null)return Nt(new pc({kind:"Decode",module:"Base64",input:t,message:`Invalid character ${c[0]}`}))}try{let c=new Uint8Array(i);for(let l=0,S=0;l<r;l+=4,S+=3){let m=tm(t.charCodeAt(l))<<18|tm(t.charCodeAt(l+1))<<12|tm(t.charCodeAt(l+2))<<6|tm(t.charCodeAt(l+3));c[S]=m>>16,c[S+1]=m>>8&255,c[S+2]=m&255}return Zt(c)}catch(c){return Nt(new pc({kind:"Decode",module:"Base64",input:t,message:c instanceof Error?c.message:"Invalid input"}))}};var Xz=(e)=>{let t=e.length,r=Uint8Array.prototype.toBase64;if(t>=32){if(typeof r==="function")return r.call(e);let n=_R(e,"base64");if(n!==void 0)return n}return t<128?ej(e):tj(e)},ej=(e)=>{let t=e.length,r="",n;for(n=2;n<t;n+=3)r+=Mn[e[n-2]>>2],r+=Mn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Mn[(e[n-1]&15)<<2|e[n]>>6],r+=Mn[e[n]&63];if(n===t+1)r+=Mn[e[n-2]>>2],r+=Mn[(e[n-2]&3)<<4],r+="==";if(n===t)r+=Mn[e[n-2]>>2],r+=Mn[(e[n-2]&3)<<4|e[n-1]>>4],r+=Mn[(e[n-1]&15)<<2],r+="=";return r},tj=(e)=>{let t=e.length,r=new Uint8Array(Math.ceil(t/3)*4),n,o=0;for(n=2;n<t;n+=3,o+=4)r[o]=pi[e[n-2]>>2],r[o+1]=pi[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=pi[(e[n-1]&15)<<2|e[n]>>6],r[o+3]=pi[e[n]&63];if(n===t+1)r[o]=pi[e[n-2]>>2],r[o+1]=pi[(e[n-2]&3)<<4],r[o+2]=sS,r[o+3]=sS;if(n===t)r[o]=pi[e[n-2]>>2],r[o+1]=pi[(e[n-2]&3)<<4|e[n-1]>>4],r[o+2]=pi[(e[n-1]&15)<<2],r[o+3]=sS;return rj.decode(r)},LR=new TextEncoder,rj=new TextDecoder("utf-8",{ignoreBOM:!0}),Mn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pi=LR.encode(Mn),sS=61,nj=/[^A-Za-z0-9+/=]/,Kd=new Uint8Array(123).fill(255);for(let e=0;e<Mn.length;e++)Kd[Mn.charCodeAt(e)]=e;Kd[61]=0;var tm=(e)=>{if(e>=Kd.length||Kd[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Kd[e]};var qd=(e)=>Object.assign(Object.create(Ay),e);var oj=qd({_tag:"Passthrough"});function Ro(){return oj}function Bt(e){return qd({_tag:"Transform",transform:e})}function ra(e){return qd({_tag:"TransformEffect",transform:e})}function aS(e){return qd({_tag:"TransformOptional",transform:e})}function ij(e){return qd({_tag:"TransformOptionalEffect",transform:e})}function NR(){return aS(()=>ge())}function BR(e){return ij((t)=>{let r=_v(t,Jt);return O(r)?z(r):Mf(e,Ue)})}function om(){return Bt(globalThis.String)}function im(){return Bt(globalThis.Number)}function KR(){return Bt(SO)}function qR(){return Bt(xO)}function sj(e){return ra((t,r)=>typeof t==="string"&&!bO(t)?he(new Hr({expected:"a well-formed Unicode string"},t,r)):z(e(t)))}function $R(){return sj(rm)}function WR(){return ra((e,t)=>Ff(mx(nm(e)),()=>new Hr({expected:"a valid Base64 string"},e,t)))}var cS=class extends qa{_tag="Middleware";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new cS(this.encode,this.decode)}},Wd="~effect/SchemaTransformation/Transformation",ar=class extends qa{[Wd]=Wd;_tag="Transformation";decode;encode;constructor(e,t){super();this.decode=e,this.encode=t}flip(){return new ar(this.encode,this.decode)}};function pj(e){return He(e,Wd)&&e[Wd]===Wd}var pS=(e)=>{if(pj(e))return e;return new ar(e.decode,e.encode)};function sm(e){return new ar(ra(e.decode),ra(e.encode))}function am(e){return new ar(Bt(e.decode),Bt(e.encode))}function GR(){return new ar(KR(),Ro())}function dj(){return new ar(qR(),Ro())}var uj=new ar(Ro(),Ro());function cm(){return uj}var Gd=new ar(im(),Bt((e)=>Object.is(e,-0)?"-0":globalThis.String(e)));var lj=(e)=>HA(e)&&typeof e.message==="string",fj=(e)=>{let r=Object.hasOwn(e,"cause")?Error(e.message,{cause:zR(e.cause)}):Error(e.message);if(typeof e.name==="string"&&e.name!=="Error")r.name=e.name;if(typeof e.stack==="string")r.stack=e.stack;return r},mj=(e)=>{try{let t=Rs(e);return t===void 0?rt(e):JSON.parse(t)}catch{return rt(e)}},hj=(e,t,r)=>{let n={name:e.name,message:typeof e.message==="string"?e.message:""};if(t?.includeStack&&typeof e.stack==="string")n.stack=e.stack;if(!t?.excludeCause&&e.cause!==void 0)n.cause=r(e.cause);return n},yj=(e)=>{let t=new WeakSet,r=(n)=>{if(VA(n)){if(t.has(n))return"[Circular]";t.add(n);let o=hj(n,e,r);return t.delete(n),o}return mj(n)};return r},zR=(e)=>lj(e)?fj(e):e;var jR=(e)=>am({decode:zR,encode:yj(e)});var QR=sm({decode:(e,t)=>URL.canParse(e)?z(new URL(e)):he(new Hr({expected:"a valid URL string"},e,t)),encode:(e)=>z(e.href)});var HR=new ar(WR(),$R());function oa(e){return(t)=>t._tag===e}var xS=oa("Declaration");var Sj=oa("Never");var Lc=oa("Literal"),uS=oa("UniqueSymbol");var i0=oa("Arrays"),s0=oa("Objects");var ia=oa("Suspend"),Lr=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},sa={},SS=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,r=void 0,n=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=r,this.annotations=n}},VR="~effect/Schema";class Fn{[VR]=VR;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,r=void 0,n=void 0){this.annotations=e,this.checks=t,this.encoding=r,this.context=n}toString(){return`<${this._tag}>`}}function fm(e){return e.checks===e.encodingChecks?e:yn(e,{checks:e.encodingChecks,encodingChecks:e.checks,encoding:void 0})}var Vd=class extends Fn{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,r,n,o,i,s,c){super(r,n,o,i);this.typeParameters=e,this.run=t,this.encodingChecks=s,this.encodingRun=c}getParser(){let e;return(t,r)=>{if(t===We)return Ln;e??=this.run(this.typeParameters);try{return e(t,this,r)}catch(n){return Or(n)}}}recur(e){let t=Mc(this.typeParameters,e);return t===this.typeParameters?this:yn(this,{typeParameters:t,encoding:void 0})}flip(e){let t=fm(this.recur(e));return this.run===this.encodingRun?t:yn(t,{run:this.encodingRun??this.run,encodingRun:this.run,encoding:void 0})}getExpected(){let e=this.annotations?.expected;if(typeof e==="string")return e;return"<Declaration>"}},bj=class extends Fn{_tag="Null";getParser(){return US(this,null)}getExpected(){return"null"}},mm=new bj;var Ij=class extends Fn{_tag="Undefined";getParser(){return US(this,void 0)}toCodecJson(){return Dr(this,[wj])}getExpected(){return"undefined"}},wj=new Lr(mm,new ar(Bt(()=>{return}),Bt(()=>null))),bS=new Ij;var Ej=class extends Fn{_tag="Unknown";getParser(){return Zd(this,QA)}getExpected(){return"unknown"}},Qd=new Ej;var _o=class extends Fn{_tag="Literal";literal;constructor(e,t,r,n,o){super(t,r,n,o);if(typeof e==="number"&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${rt(e)}`);this.literal=e}getParser(){return US(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==="bigint"?JR(this):this}toCodecStringTree(){return typeof this.literal==="string"?this:JR(this)}getExpected(){return typeof this.literal==="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function JR(e){let t=globalThis.String(e.literal);return Dr(e,[new Lr(new _o(t),new ar(Bt(()=>e.literal),Bt(()=>t)))])}var kj=class extends Fn{_tag="String";getParser(){return Zd(this,zo)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&ts(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},Xi=new kj,Aj=class extends Fn{_tag="Number";getParser(){return Zd(this,Op)}matchKey(e,t){return this._match(Vj,e,t)}matchPart(e,t){return this._match(gS,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);if(r.disableChecks||!this.checks)return n;return ts(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){if(this.checks&&(lS(this.checks,"effect/schema/isFinite")||lS(this.checks,"effect/schema/isInt")))return this;return Dr(this,[Fj])}toCodecStringTree(){if(this.toCodecJson()===this)return Dr(this,[Jj]);return Dr(this,[Yj])}getExpected(){return"number"}};function lS(e,t){return e.some((r)=>r.annotations?.representation?.id===t||r._tag==="FilterGroup"&&lS(r.checks,t))}var IS=new Aj,vj=class extends Fn{_tag="Boolean";getParser(){return Zd(this,Sl)}getExpected(){return"boolean"}},a0=new vj;var hm=class extends Fn{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,o,i,s,c){super(n,o,i,s);this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=c;let l=!1;for(let S=0;S<t.length;S++)if(Uo(t[S]))l=!0;else if(l)throw Error("A required element cannot follow an optional element. ts(1257)");if(l&&r.length>1)throw Error("A required element cannot follow an optional element. ts(1257)");for(let S=1;S<r.length;S++)if(Uo(r[S]))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let r=this,n,o,i=r.elements.length,s=Math.max(0,r.rest.length-1);function c(m,g){if(g<i)return n[g];else if(g>=m)return o[g-m+1];return o[0]}let l=(m)=>{let{input:g,len:w,options:k}=m;if(r.rest.length===0&&w>i)for(let A=i;A<w;A++){let y=new oS(r,g[A],k),h=new ai([A],y);if(k.errors==="all")if(m.issues)m.issues.push(h);else m.issues=[h];else return he(new Ur(r,[h],g,k))}if(m.issues)return he(new Ur(r,m.issues,g,k));return vr(m.output)},S=(m,g)=>{let w=m.length,k={ast:r,getParser:c,input:m,len:w,tailThreshold:Math.max(i,w-s),output:[],issues:void 0,options:g},A=r.rest.length===0?i:Math.max(w,i+s),y=g.concurrency===void 0?1:od(g.concurrency),h=y===1?Tj(k,m,0,A):Oj(k,m,{concurrency:y,end:A});if(!h)return l(k);if(ft(h))return Qr(h,()=>l(k));let x=!0;return Ve(()=>{if(!x)return S(m,g);return x=!1,Ae(h,()=>l(k))})};return(m,g)=>{if(m===We)return Ln;try{if(!Array.isArray(m))return he(new ro(r,m,g));if(!n)n=r.elements.map((w)=>({ast:w,parser:t(w)})),o=r.rest.map((w)=>({ast:w,parser:t(w)}));return S(m,g)}catch(w){return Or(w)}}}recur(e){let t=Mc(this.elements,e),r=Mc(this.rest,e);return t===this.elements&&r===this.rest?this:new hm(this.isMutable,t,r,this.annotations,this.checks,void 0,this.context,this.encodingChecks)}flip(e){return fm(this.recur(e))}getExpected(){return"array"}};function Cj(e,t,r,n){if(r._tag==="Failure")return um(e,e.ast,n,r);let o=Xt(r)?t:r[Me];if(o!==We)e.output[n]=o;else{let i=e.getParser(e.tailThreshold,n);if(Uo(i.ast))return;let s=new ai([n],new Fd(i.ast.context?.annotations));if(e.options.errors==="all")if(e.issues)e.issues.push(s);else e.issues=[s];else return _n(new Ur(e.ast,[s],e.input,e.options))}}var c0={onItem(e,t,r){let n=r<e.len?t:We;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:Cj},Tj=mf()(c0),Oj=hf()(c0),um=(e,t,r,n)=>{if(n.cause.reasons.length===0)return n;let o=Bd(n.cause);if(o===void 0)return Wi(Gi(n.cause,(s)=>new Ur(t,[new ai([r],s)],e.input,e.options)));let i=new ai([r],o);if(e.options.errors==="all")if(e.issues)e.issues.push(i);else e.issues=[i];else return _n(new Ur(t,[i],e.input,e.options))},p0="[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?";function dS(e,t,r=sa){let n,o;function i(s){switch(s._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter((c)=>s.matchPart(c,r)!==void 0);case"Number":return(n??=Object.keys(e)).filter((c)=>s.matchKey(c,r)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter((c)=>Object.prototype.propertyIsEnumerable.call(e,c)&&s.matchKey(c,r)!==void 0);case"Union":return[...new Set(s.types.flatMap(i))];default:return[]}}return i(DS(ui(t)))}var wS=class{name;type;constructor(e,t){this.name=e,this.type=t}};function d0(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(d0);default:return!1}}function u0(e){let t=CS(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(u0);default:return!1}}function Pj(e){return d0(e)&&u0(e)}var l0=class{parameter;type;constructor(e,t){if(!Pj(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Uo(t)||t.encoding!==void 0&&Uo(ui(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},ES=class extends Fn{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,o,i,s){super(r,n,o,i);this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=s}getParser(e,t=e){let r=this,n=r.propertySignatures.length,o=r.indexSignatures.length;if(!n&&!o)return Zd(r,My);let i,s,c=()=>{if(!i)i=r.propertySignatures.map((g)=>({parser:t(g.type),name:g.name,type:g.type,ownOnly:y0(g.name)})),s=o?r.indexSignatures.map((g)=>({is:g,parserKey:e(DS(g.parameter)),parserValue:t(g.type)})):void 0;return i},l=()=>{let g=new Set(r.propertySignatures.map((h)=>typeof h.name==="number"?globalThis.String(h.name):h.name)),w=(h,x,G,X,I)=>{if(I._tag==="Failure")return um(h,r,x,I)??Jn;let me=Xt(I)?X:I[Me];if(G!==We&&me!==We){if(n&&(g.has(x)||g.has(typeof G==="number"?globalThis.String(G):G)))return Jn;Zr(h.out,G,me)}return Jn},k=(h,x,G,X)=>{if(!X){let K=G.parserKey(x,h.options);if(!ft(K))return Ae(Ac(K),(ee)=>k(h,x,G,ee));X=K}if(X._tag==="Failure")return um(h,r,x,X)??Jn;let I=Xt(X)?x:X[Me],me=h.input[x],pe=G.parserValue(me,h.options);return ft(pe)?w(h,x,I,me,pe):Ae(Ac(pe),(K)=>w(h,x,I,me,K))},A=(h,x,G)=>{let X=h.input[x],I=G.parserValue(X,h.options);return ft(I)?w(h,x,x,X,I):Ae(Ac(I),(me)=>w(h,x,x,X,me))},y=o?hf()({onItem:(h,[x,G])=>G.is.parameter===Xi?A(h,x,G):k(h,x,G),step:(h,x,G)=>G._tag==="Failure"?G:void 0}):void 0;return UO(function*(h,x){if(h===We)return We;if(!(typeof h==="object"&&h!==null&&!Array.isArray(h)))return yield*he(new ro(r,h,x));c();let G=h,X={},I={ast:r,input:G,out:X,issues:void 0,options:x},me=x.errors==="all",pe=x.onExcessProperty==="error",K=x.concurrency===void 0?1:od(x.concurrency),ee=o&&pe?r.indexSignatures.map((Q)=>dS(G,Q.parameter,x)):void 0;if(pe){let Q=ee?new Set(g):g;if(ee)for(let re of ee)for(let ae of re)Q.add(ae);let te=Yr(G);for(let re=0;re<te.length;re++){let ae=te[re];if(!Q.has(ae)){let se=new oS(r,G[ae],x),le=new ai([ae],se);if(me){if(I.issues)I.issues.push(le);else I.issues=[le];continue}else return yield*he(new Ur(r,[le],h,x))}}}if(n){let Q=K===1?YR(I,i):Rj(I,i,{concurrency:K});if(Q)yield*Q}if(o&&K===1)for(let Q=0;Q<o;Q++){let te=s[Q],re=te.is.parameter===Xi?A:k,ae=ee?.[Q]??(te.is.parameter===Xi?Object.keys(G):dS(G,te.is.parameter,x));for(let se=0;se<ae.length;se++){let le=re(I,ae[se],te);if(!ft(le))yield*le;else if(le._tag==="Failure")return yield*le}}else if(y){let Q=Ks();for(let re=0;re<o;re++){let ae=s[re],se=ee?.[re]??(ae.is.parameter===Xi?Object.keys(G):dS(G,ae.is.parameter,x));for(let le=0;le<se.length;le++)Q.push([se[le],ae])}let te=y(I,Q,{concurrency:K});if(te)yield*te}if(I.issues)return yield*he(new Ur(r,I.issues,h,x));return X})};if(o)return l();let S,m=(g,w,k)=>{let A=i[w];return Ae(Ac(k),(y)=>{let h={...g,out:{...g.out}},x=fS(h,A,y);if(x)return x;let G=()=>vr(h.out),X=YR(h,i.slice(w+1));return X?Qr(X,G):G()})};return(g,w)=>{if(g===We)return Ln;if(w.errors==="all"||w.onExcessProperty!==void 0||w.concurrency!==void 0&&od(w.concurrency)!==1)return(S??=l())(g,w);if(!(typeof g==="object"&&g!==null&&!Array.isArray(g)))return he(new ro(r,g,w));let k=c(),A=g,y={},h={ast:r,input:A,out:y,issues:void 0,options:w};try{for(let x=0;x<k.length;x++){let G=k[x],X=G.name,I=G.ownOnly?Object.hasOwn(A,X):(X in A),me=I?A[X]:We,pe=G.parser(me,w);if(!ft(pe))return m(h,x,pe);if(Xt(pe)){if(I)Zr(y,X,me);continue}let K=fS(h,G,pe);if(K)return K}}catch(x){return Or(x)}return vr(y)}}recur(e,t=e){let r=Mc(this.propertySignatures,(o)=>{let i=e(o.type);return i===o.type?o:new wS(o.name,i)}),n=Mc(this.indexSignatures,(o)=>{let i=t(o.parameter),s=e(o.type);return i===o.parameter&&s===o.type?o:new l0(i,s)});return r===this.propertySignatures&&n===this.indexSignatures?this:yn(this,{propertySignatures:r,indexSignatures:n,encoding:void 0})}flip(e){return fm(this.recur(e))}getExpected(){if(this.propertySignatures.length===0&&this.indexSignatures.length===0)return"object | array";return"object"}};function fS(e,t,r){if(r._tag==="Failure")return um(e,e.ast,t.name,r);if(Xt(r))return;let n=r[Me];if(n!==We){Zr(e.out,t.name,n);return}if(delete e.out[t.name],!Uo(t.type)){let o=new ai([t.name],new Fd(t.type.context?.annotations));if(e.options.errors==="all"){if(e.issues)e.issues.push(o);else e.issues=[o];return}else return _n(new Ur(e.ast,[o],e.input,e.options))}}var f0={onItem(e,t){if(!(t.ownOnly?Object.hasOwn(e.input,t.name):(t.name in e.input)))return t.parser(We,e.options);let r=e.input[t.name];return Zr(e.out,t.name,r),t.parser(r,e.options)},step:fS},YR=mf()(f0),Rj=hf()(f0);function kS(e,t){if(!e)return t;if(!t)return e;return[...e,...t]}function ym(e,t,r){return new ES(Yr(e).map((n)=>new wS(n,e[n].ast)),[],r,t)}function gm(e){return e.ast}function xm(e,t,r){return new es(e.map(gm),t,void 0,r)}function m0(e,t){if(e.encoding||t.some((i)=>i.encoding))throw Error("StructWithRest does not support encodings");let{propertySignatures:r,indexSignatures:n,checks:o}=e;for(let i of t){for(let s of i.propertySignatures)if(r.some((c)=>c.name===s.name))throw Error(`Duplicate identifier: ${JSON.stringify(s.name)}. ts(2300)`);r=r.concat(i.propertySignatures),n=n.concat(i.indexSignatures),o=kS(o,i.checks)}return new ES(r,n,void 0,o)}var AS=wp((e)=>{while(!0){if(ia(e))return Qd;let t=e.encoding;if(!t)return e.recur?.(AS,Ee)??e;if(t.some((r)=>r.transformation._tag==="Middleware"&&r.transformation.decode!==Ee))return Qd;e=t[t.length-1].to}});function h0(e){switch(e._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return e.propertySignatures.length||e.indexSignatures.length?["object"]:["string","number","boolean","symbol","bigint","object","array","function"];case"Enum":return Array.from(new Set(e.enums.map(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(h0)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function Hd(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[Zf];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap((t)=>{let r=t.type;if(!Uo(r)){if(Lc(r))return[{key:t.name,literal:r.literal}];if(uS(r))return[{key:t.name,literal:r.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,r)=>{if(!Uo(t)){if(Lc(t))return[{key:r,literal:t.literal}];if(uS(t))return[{key:r,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map((r)=>Hd(AS(r)));return t[0].filter((r)=>t.every((n)=>n.some((o)=>o.key===r.key&&o.literal===r.literal)))}case"Suspend":return Hd(e.thunk())}}var ZR=new WeakMap,pm=Object.freeze([]),XR=(e)=>e===null?"null":Array.isArray(e)?"array":typeof e,_j=new Set(Reflect.ownKeys(Object.prototype)).add("__proto__"),y0=(e)=>_j.has(typeof e==="number"?globalThis.String(e):e),dm=(e,t)=>Object.hasOwn(e,t)||(t in e)&&!y0(t);function Uj(e){let t=ZR.get(e);if(t)return t;let r,n=0,o,i,s=!0,c=[];for(let m=0;m<e.length;m++){let g=e[m],w=AS(g);if(Sj(w))continue;if(Lc(w)||uS(w)){i??=new Map;let A=Lc(w)?w.literal:w.symbol;c[m]=A;let y=i.get(A);if(!y)i.set(A,y=[]);y.push(m)}else s=!1;let k=Hd(w);if(k.length){r??=new Map,n++;for(let{key:A,literal:y}of k){let h=r.get(A);if(!h)r.set(A,h=[new Map,new Set]);h[1].add(m);let x=h[0].get(y);if(!x)h[0].set(y,x=new Set);x.add(m)}}else{o??={};let A=h0(w);for(let y of A)(o[y]??=[]).push(m)}}let l={},S=(m)=>l[m]??=Object.freeze(o?.[m]??pm);if(s&&i)i.forEach(Object.freeze),t=(m)=>i.get(m)??pm;else if(r?.size===1&&!o){let[m,[g]]=r.entries().next().value,w=new Map;for(let[A,y]of g)w.set(A,Object.freeze(Array.from(y)));let k=Object.freeze(e.map((A,y)=>y));t=(A,y)=>{if(Pp(A)){let h=dm(A,m)?A[m]:void 0;if(h!==void 0)return w.get(h)??pm;if(y)return k}return pm}}else if(r){let m;for(let g of r)if((!m||g[1][0].size>m[1][0].size)&&g[1][1].size===n)m=g;t=(g,w)=>{let k=XR(g);if(!Pp(g))return S(k);let A=new Set(o?.[k]),y;if(m){let[h,[x]]=m,G=dm(g,h),X=G?g[h]:void 0;if(G&&(!w||X!==void 0)){let I=x.get(X);if(!I)return S(k);for(let me of I)A.add(me);y=h}}if(y===void 0)for(let[h,[x,G]]of r){let X=dm(g,h),I=X?g[h]:void 0;if(X&&(!w||I!==void 0)){let me=x.get(I);if(me)for(let pe of me)A.add(pe)}else if(w)for(let me of G)A.add(me)}for(let[h,[x,G]]of r){if(h===y)continue;let X=dm(g,h),I=X?g[h]:void 0;if(X&&(!w||I!==void 0)){let me=x.get(I);for(let pe of A)if(G.has(pe)&&!me?.has(pe))A.delete(pe)}}return Array.from(A).sort((h,x)=>h-x)}}else t=(m)=>{let g=S(XR(m));return i?g.filter((w)=>c[w]===void 0||c[w]===m):g};return ZR.set(e,t),t}var es=class extends Fn{_tag="Union";types;options;encodingChecks;constructor(e,t,r,n,o,i,s){super(r,n,o,i);this.types=e,this.options=t,this.encodingChecks=s}getParser(e,t){let r=this,n=t!==void 0,o=[],i=(c)=>o[c]??=e(r.types[c]),s;return(c,l)=>{if(c===We)return Ln;let S=(s??=Uj(r.types))(c,n);if(S.length===0)return he(new Nd(r,[],c,l));if(S.length===1){let m=i(S[0])(c,l);if(m._tag==="Success")return m;return ft(m)?g0(r,m.cause,c,l):Dj(r,m,c,l)}return x0(r,i,S,c,l)}}recur(e){let t=Mc(this.types,e);return t===this.types?this:yn(this,{types:t,encoding:void 0})}flip(e){return fm(this.recur(e))}matchPart(e,t){for(let r of this.types){let n=r.matchPart(e,t);if(n!==void 0)return n}return}getExpected(e){let t=this.annotations?.expected;if(typeof t==="string")return t;if(this.types.length===0)return"never";let r=this.types.map((n)=>{let o=ui(n);switch(o._tag){case"Arrays":{let i=o.elements.filter(Lc);if(i.length>0)return`${t0(o.isMutable)}[ ${i.map((s)=>e(s)+r0(s.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let i=o.propertySignatures.filter((s)=>Lc(s.type));if(i.length>0)return`{ ${i.map((s)=>`${t0(s.type.context?.isMutable)}${Ha(s.name)}${r0(s.type.context?.isOptional)}: ${e(s.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(r)).join(" | ")}};function g0(e,t,r,n){let o=Bd(t);if(!o)return Wi(t);return _n(new Nd(e,[o],r,n))}function Dj(e,t,r,n){return jr(t,(o)=>g0(e,o,r,n))}function x0(e,t,r,n,o){let i={ast:e,parser:t,input:n,out:void 0,successes:e.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:o},s=Lj(i,r);if(!s){if(i.out)return i.out;return he(new Nd(e,i.issues??[],n,o))}if(ft(s))return e0(s,i);let c=!0;return Ve(()=>{if(!c)return x0(e,t,r,n,o);return c=!1,e0(s,i)})}function e0(e,t){return Qr(e,(r)=>{if(t.out)return Xt(t.out)?z(t.input):t.out;return he(new Nd(t.ast,t.issues??[],t.input,t.options))})}var Lj=mf()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,r){if(r._tag==="Failure"){let n=Bd(r.cause);if(n===void 0)return r;if(e.issues)e.issues.push(n);else e.issues=[n]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),_n(new bR(e.ast,e.successes,e.input,e.options));if(e.out=r,e.successes)e.successes.push(e.ast.types[t]);else return Jn}}}),S0=new es([new _o("Infinity"),new _o("-Infinity"),new _o("NaN")]);function t0(e){return e?"":"readonly "}function r0(e){return e?"?":""}function Mj(e){let t;return()=>t??=e()}var mS=class extends qa{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,r=!1){super();this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new mS(this.run,{...this.annotations,...e},this.aborted)}abort(){return new mS(this.run,this.annotations,!0)}and(e,t){return new lm([this,e],t)}},lm=class extends qa{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super();this.checks=e,this.annotations=t}annotate(e){return new lm(this.checks,{...this.annotations,...e})}and(e,t){return new lm([this,e],t)}};function Sm(e,t,r=!1){return new mS((n,o,i)=>wR(o,e(n,o,i),n,i),t,r)}function b0(e){return Sm((t)=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),arbitraryConstraint:{number:"finite"},...e})}var I0=aa(IS,[b0()]),Fj=new Lr(new es([I0,S0]),new ar(im(),Bt((e)=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function vS(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return Sm((o)=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n.source}`,representation:{id:"effect/schema/isPattern",payload:n},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[n]},...t})}var hS=new WeakMap;function yn(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function w0(e,t){let r=yn(e,t);return hS.set(r,Jd(e)),r}function Jd(e){let t=hS.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let r=yn(e,{encoding:void 0});return hS.set(e,r),r}function Dr(e,t){return e.encoding===t?e:w0(e,{encoding:t})}function Fc(e,t){if(e.context===t)return e;let r=Jd(e);if(r.context===t&&r.encoding===e.encoding)return r;return w0(e,{context:t})}function CS(e){return e.encoding?CS(e.encoding[e.encoding.length-1].to):e}function bm(e,t){if(e.checks)return TS(e,E0(e.checks,(r)=>r.annotate(t)));return yn(e,{annotations:{...e.annotations,...t}})}function TS(e,t){if(e._tag==="Suspend"&&t)throw Error("Cannot add checks to Suspend");if(e.checks===t)return e;return yn(e,{checks:t})}function aa(e,t){return TS(e,kS(e.checks,t))}function Im(e,t){let r=t(e.to);return r===e.to?e:new Lr(r,e.transformation)}function E0(e,t){let r=e[e.length-1],n=t(r);if(r===n)return e;let o=[...e];return o[o.length-1]=n,o}function k0(e,t){return E0(e,(r)=>Im(r,t))}function A0(e){return(t)=>t.encoding?Dr(t,k0(t.encoding,e)):t}function v0(e,t){return A0((r)=>Fc(r,t))(e)}function wm(e,t){function r(n){if(n.encoding){let o=n.encoding[n.encoding.length-1];return t?.stopAt?.(o)?n:Dr(n,k0(n.encoding,r))}return e(n)}return wp(r)}function C0(e,t){return T0(e,t,di(e))}function T0(e,t,r){let n=new Lr(e,t);return Dr(r,r.encoding?[...r.encoding,n]:[n])}function Mc(e,t){let r;for(let n=0;n<e.length;n++){let o=e[n],i=t(o);if(r)r[n]=i;else if(i!==o){r=Array(e.length);for(let s=0;s<n;s++)r[s]=e[s];r[n]=i}}return r??e}function OS(e,t=Uo(e),r=Kj(e),n=e.context?.constructorDefault,o=e.context?.annotations){return Fc(e,new SS(t,r,n,o))}function Nj(e){let t=e==="isOptional"?!0:void 0,r=e==="isMutable"?!0:void 0,n=wp((i)=>o(i.context?.[e]?i:OS(i,t,r))),o=A0(n);return n}function Em(e,t){return OS(e,void 0,void 0,void 0,e.context?{...e.context.annotations,...t}:t)}var km=Nj("isOptional"),O0=Pi((e)=>km(new es([e,bS])));function P0(e,t){return OS(e,void 0,void 0,t)}function PS(e,t,r){return T0(e,r,t)}function Bj(e){let t=[],r=[];function n(i){if(!t.includes(i))t.push(i)}function o(i){switch(i._tag){case"Literal":if(Ly(i.literal))n(i.literal);return;case"UniqueSymbol":n(i.symbol);return;case"Enum":for(let[,s]of i.enums)n(s);return;case"Never":return;case"Union":for(let s=0;s<i.types.length;s++)o(i.types[s]);return;default:r.push(i)}}return o(e),{literals:t,parameters:r}}function RS(e,t){let{literals:r,parameters:n}=Bj(e);return new ES(r.map((o)=>new wS(o,t)),n.map((o)=>new l0(o,t)))}function Uo(e){return e.context?.isOptional??!1}function Kj(e){return e.context?.isMutable??!1}function _S(e){return e.annotations?.[Pd]===!0||e._tag==="FilterGroup"&&e.checks.every(_S)}function qj(e){function t(n){if(_S(n))return[n];return n._tag==="FilterGroup"?n.checks.flatMap(t):[]}let r=e.flatMap(t);return Kl(r)?r:void 0}function R0(e,t,r){let n=new Set([e]);for(let i of n){if(r?.has(i))continue;if(!t(i))return!1;if(!ia(i)&&"recur"in i)i.recur(o)}if(r)for(let i of n)r.add(i);return!0;function o(i){return n.add(i),i}}var $j=new WeakSet;function _0(e,t){let r=i0(e)||s0(e)||xS(e)&&e.typeParameters.length>0;if(r&&t.every(_S)||R0(e,(n)=>!n.encoding&&!ia(n),$j))return t;if(r)return qj(t)}function U0(e){return xS(e)&&e.encodingRun!==void 0&&e.encodingRun!==e.run}function Wj(e,t){function r(n){if(ia(n))return n.thunk===t;return!U0(n)&&!(("encodingChecks"in n)&&n.checks&&_0(n,n.checks)!==n.checks)}return R0(e,r)}var jd=new WeakMap,Dc=new WeakMap,n0=new WeakSet,o0=new WeakSet,Yd=new WeakMap,yS=new WeakMap,di=(e)=>Yd.has(e)?Gj(e):na(e),Gj=Pi((e)=>{let t=Yd.get(e);if(t&&n0.has(t))return t;let r=na(e);if(t)n0.add(r);return r});function na(e){let t=jd.get(e);if(t)return t;let r=Yd.get(e),n=r&&jd.get(r)===r,o=r&&Dc.get(r)||zj(e);if(n)Dc.set(r,o);if(jd.set(e,o),o!==e)jd.set(o,o);return o}function D0(e,t){let r=Jd(e);if(r!==e){let n=t(r);return n===r&&!e.encoding?e:Fc(n,e.context)}}function zj(e){let t=D0(e,na);if(t)return t;if(ia(e))return yS.get(e.thunk)?.project(e)??e.recur(na);let r="recur"in e?e.recur(na):e;if("encodingChecks"in r&&r.encodingChecks)return yn(r,{encodingChecks:void 0,checks:kS(_0(e,r.encodingChecks),r.checks)});return r===e&&U0(r)&&Yd.has(e)?yn(r,{}):r}var ui=(e)=>di(hn(e));function jj(e,t){let r=Dr(e,void 0),n=t.map((i)=>{let s=new Lr(hn(r),i.transformation.flip());return r=i.to,s}).reverse(),o=hn(r);return Dr(o,o.encoding?[...o.encoding,...n]:n)}var hn=Pi((e)=>{let t=Qj(e);if(t!==e)Yd.set(t,e);return t});function Qj(e){if(e.encoding)return jj(e,e.encoding);let t=D0(e,hn);if(t)return t;if(ia(e)){let r=yS.get(e.thunk);if(r)return yn(e,{thunk:r.source.thunk});let n=e.recur(hn);return yS.set(n.thunk,{source:e,project(o){let i=Mj(()=>Hj(e.thunk(),i));return yn(o,{thunk:i})}}),n}return"flip"in e?e.flip(hn):e}function Hj(e,t){if(jd.get(e)!==e)return na(hn(e));let r=Dc.get(e);if(r)return r;if(Wj(e,t))return Dc.set(e,e),e;let n=na(hn(e));if(o0.has(e)&&!Dc.has(n))Dc.set(n,e);return o0.add(n),n}function US(e,t){let r=t===0?si:vr(t);return(n,o)=>{if(n===We)return Ln;if(n===t)return r;return he(new ro(e,n,o))}}function Zd(e,t){return(r,n)=>{if(r===We)return Ln;if(t(r))return si;return he(new ro(e,r,n))}}var DS=wm((e)=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(DS)}}),LS=wm((e)=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(LS)}});var gS=new globalThis.RegExp(`^${p0}$`),Vj=new globalThis.RegExp(`^(?:${p0}|Infinity|-Infinity|NaN)$`);function L0(e){return vS(gS,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:gS.source}),...e})}var M0=aa(Xi,[L0()]),Jj=new Lr(M0,Gd),Yj=new Lr(new es([M0,S0]),Gd),Zj="-?\\d+",Zie=new globalThis.RegExp(`^${Zj}$`);var Xj="Symbol\\(([\\s\\S]*)\\)",Xie=new globalThis.RegExp(`^${Xj}$`);function ts(e,t,r,n,o){for(let i=0;i<e.length;i++){let s=e[i];if(s._tag==="FilterGroup"){if(r=ts(s.checks,t,r,n,o),r&&(o.errors!=="all"||r[r.length-1].filter.aborted))return r}else{let c=s.run(t,n,o);if(c){let l=new xR(s,c,t,o);if(r)r.push(l);else r=[l];if(o.errors!=="all"||s.aborted)return r}}}return r}function Am(e){if(!xS(e))return;let t=e.annotations?.[Xf];return xo(t)?t(e.typeParameters):void 0}function eQ(e){return e===null||typeof e==="string"||typeof e==="boolean"||typeof e==="number"&&globalThis.Number.isFinite(e)}function tQ(e){return e===void 0||typeof e==="string"}function F0(e,t){let r=new WeakMap,n=[];e:while(!0){if(typeof e!=="object"||e===null){if(!t(e))return!1}else{let o=e,i=r.get(o);if(i===!1)return!1;if(i===void 0){let s=Array.isArray(o);if(!s){let c=Object.getPrototypeOf(o);if(c!==null&&c!==Object.prototype&&Object.getPrototypeOf(c)!==null)return!1}r.set(o,!1),n.push({value:o,keys:s?o.length:Object.keys(o),index:0})}}while(n.length>0){let o=n[n.length-1],i=o.keys;if(typeof i==="number"){if(o.index<i){e=o.value[o.index++];continue e}}else if(o.index<i.length){e=o.value[i[o.index++]];continue e}r.set(o.value,!0),n.pop()}return!0}}function rQ(e){return F0(e,eQ)}var N0=new Vd([],()=>(e,t,r)=>rQ(e)?si:he(new ro(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{return},toCodecStringTree:()=>MS});function nQ(e){return F0(e,tQ)}var oQ=new Vd([],()=>(e,t,r)=>nQ(e)?si:he(new ro(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>{return}}),MS=new Lr(oQ,cm());function FS(){return Object.assign((e)=>e,{option:(e)=>Ue(e),result:(e)=>Zt(e),is:(e)=>!0})}var q0=FS(),$0=FS(),K0="~effect/process/ChildProcessSpawner/ChildProcessHandle",iQ={[K0]:K0,..._i,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},NS=(e)=>Object.setPrototypeOf({...e},iQ),W0=(e)=>{let t=(n,o)=>e(n).pipe(De((i)=>pR(o?.includeStderr===!0?i.all:sR(i.stdout,i.stderr))),Po),r=(n,o)=>dR(t(n,o));return Bc.of({spawn:e,exitCode:(n)=>Hs(Ae(e(n),(o)=>Un(o.exitCode,Zn(Yx(o.all),hd)))),streamString:t,streamLines:r,lines:(n,o)=>lR(r(n,o)),string:(n,o)=>fR(t(n,o))})};class Bc extends Ht()("effect/process/ChildProcessSpawner"){}var ca=new WeakMap,G0=(e)=>{if(ca.has(e))return ca.get(e);else throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var z0="~effect/Redacted",no=(e)=>He(e,z0),pa=(e,t)=>{let r=Object.create(aQ);if(t?.label)r.label=t.label;return ca.set(r,e),r},aQ={[z0]:{_A:(e)=>e},label:void 0,...qr,toJSON(){return this.toString()},toString(){return`<redacted${zo(this.label)?":"+this.label:""}>`},[kt](){return je(ca.get(this))},[At](e){return no(e)&&nr(ca.get(this),ca.get(e))}},Kc=G0;class da extends Jo("CommandLineError"){}var Q0=(e,t)=>{if(e.length===0)return"";let r=t?.format??"posix";return uQ(r,e.map((n,o)=>no(n)?"<redacted>":bQ(dQ(r,n,o===0))))},H0=(e,...t)=>{let r=e.findIndex((n)=>n===void 0);if(r!==-1)return Nt(new da({reason:"InvalidEscape",message:`Template part ${r} contains an invalid escape sequence`}));return CQ(e,t)},cQ=(e)=>no(e)?Kc(e):String(e),j0=(e)=>no(e)?e:String(e);var pQ=new Set(["!","{","}","and","begin","case","coproc","do","done","elif","else","end","esac","fi","for","foreach","function","if","in","nocorrect","not","or","repeat","select","switch","then","time","until","while"]),dQ=(e,t,r)=>{switch(e){case"posix":return r&&pQ.has(t)?`'${t}'`:fQ(t);case"powershell":return mQ(t);case"windows":return r&&!t.includes('"')?gQ(t):yQ(t)}},uQ=(e,t)=>e==="powershell"?`& ${t.join(" ")}`:t.join(" "),lQ=/^[A-Za-z0-9_@+:,./-]+$/,fQ=(e)=>lQ.test(e)?e:`'${e.replace(/['\\]/g,(t)=>`'\\${t}'`)}'`,mQ=(e)=>`'${e.replace(/['\u2018\u2019\u201A\u201B]/g,"$&$&")}'`,hQ=/[ \t\n\v"]/,yQ=(e)=>{if(e.length>0&&!hQ.test(e))return e;let t='"',r=0;for(let n of e)if(n==="\\")r++;else if(n==='"')t+="\\".repeat(r*2+1)+'"',r=0;else t+="\\".repeat(r)+n,r=0;return t+"\\".repeat(r*2)+'"'},gQ=(e)=>e.length>0&&!/[ \t]/.test(e)?e:`"${e}"`,xQ=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g,SQ={"\n":"\\n","\r":"\\r","\t":"\\t"},bQ=(e)=>e.replace(xQ,(t)=>SQ[t]??`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`),IQ="|&;<>()",wQ="*?[",EQ=/[A-Za-z_0-9{(@*#?$!'"-]/,kQ=/[A-Za-z_0-9{(@*#?$!-]/,AQ=/^[A-Za-z_][A-Za-z0-9_]*\+?$/,BS=(e)=>e===" "||e==="\t"||e===`
33
33
  `,vQ=(e,t,r)=>{if(IQ.includes(e))return`The operator "${e}" needs a shell`;if(e==="`")return"Command substitution needs a shell";if(e==="$"&&t!==void 0&&EQ.test(t))return`The expansion "$${t}" needs a shell`;if(wQ.includes(e))return`The glob character "${e}" needs a shell`;if(!r)return;if(e==="#")return"A comment needs a shell";if(e==="~")return"Tilde expansion needs a shell";if(e==="="&&t!==void 0&&!BS(t))return'A leading "=" is expanded by zsh';return},CQ=(e,t)=>{let r=[],n=[],o=!0,i=0,s=void 0,c=0,l=0,S=(w,k,A=l)=>Nt(new da({reason:w,message:`${k} in template part ${A}`})),m=()=>{if(n.length===0)return;let w=n.map(cQ).join("");r.push(n.length===1&&no(n[0])?n[0]:n.some(no)?pa(w):w),n=[],o=!0,i=0},g=(w)=>{for(let k=0;k<w.length;k++){let A=w[k],y=w[k+1];if(s==="'")if(A==="'")s=void 0;else n.push(A);else if(s==='"')if(A==='"')s=void 0;else if(A==="\\"&&y!==void 0&&'$`"\\\n'.includes(y)){if(y!==`
34
34
  `)n.push(y);k++}else if(A==="`")return S("UnsupportedSyntax","Command substitution needs a shell");else if(A==="$"&&y!==void 0&&kQ.test(y))return S("UnsupportedSyntax",`The expansion "$${y}" needs a shell`);else n.push(A);else if(BS(A))m();else if(A==="\\"){if(y===void 0)return S("InvalidEscape","A trailing backslash escapes nothing");if(y!==`
35
- `)n.push(y),o=!1;k++}else if(A==="'"||A==='"')s=A,c=l,n.push(""),o=!1;else{let h=vQ(A,y,n.length===0);if(h!==void 0)return S("UnsupportedSyntax",h);if(A==="{")i++;else if(A==="}"){if(i>0)i--}else if(i>0&&(A===","||A==="."&&y==="."))return S("UnsupportedSyntax","Brace expansion needs a shell");else if(A==="="&&r.length===0&&o&&AQ.test(n.join("")))return S("UnsupportedSyntax","A variable assignment needs a shell");n.push(A)}}return};for(;l<e.length;l++){let w=g(e[l]);if(w!==void 0)return w;if(l===t.length)break;let k=t[l];if(Array.isArray(k)){let A=e[l+1][0];if(n.length>0||(A===void 0?l+1<t.length:!BS(A)))return S("UnsupportedSyntax","An interpolated array must be a separate argument");for(let y of k)r.push(j0(y))}else n.push(j0(k)),o=!1}if(s!==void 0)return S("UnterminatedQuote","The quote is not closed",c);return m(),Zt(r)};var J0="~effect/process/ChildProcess",TQ={...Ui({label:"Command",evaluate(e){return Wp(e.context,Bc).spawn(this)}}),[J0]:J0};var Xd=(e,t,r)=>Object.assign(Object.create(TQ),{_tag:"StandardCommand",command:e,args:t,options:r});var vm=function(...t){if(Y0(t[0])){let[i,...s]=t,[c,l]=Z0(i,s);return Xd(c,l,{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!Y0(t[0])){let i=t[0];return function(s,...c){if(i.shell!==void 0&&i.shell!==!1)return Xd(OQ(s,c),[],i);let[l,S]=Z0(s,c);return Xd(l,S,i)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[i,s={}]=t;return Xd(i,[],s)}let[r,n=[],o={}]=t;return Xd(r,n,o)};var Y0=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),Cm=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let r=parseInt(t[1],10);return r>=3?r:void 0},X0=(e)=>`fd${e}`,Z0=(e,t)=>{let[r="",...n]=mg(H0(e,...t));if(typeof r!=="string")throw new da({reason:"InvalidArgument",message:"The program name of a command cannot be Redacted"});return[r,n]},OQ=(e,t)=>{if(t.length>0)throw new da({reason:"UnsupportedSyntax",message:"A shell template cannot interpolate values; build the script with CommandLine.quote"});let r=e[0];if(r===void 0)throw new da({reason:"InvalidEscape",message:"Template part 0 contains an invalid escape sequence"});return r};import*as Rm from"child_process";import{PassThrough as KS}from"stream";var e_=(e,t,r)=>{let n=e.detached??r!=="win32";return{...t,detached:n,shell:e.shell,windowsHide:e.windowsHide??!n}};var ct=(e,t)=>(r,[n])=>{let o="Unknown";switch(r.code){case"ENOENT":o="NotFound";break;case"EACCES":case"EPERM":o="PermissionDenied";break;case"EEXIST":o="AlreadyExists";break;case"EISDIR":o="BadResource";break;case"ENOTDIR":o="BadResource";break;case"EBUSY":o="Busy";break;case"ELOOP":o="BadResource";break}return Xn({_tag:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})};import{finished as t_}from"stream";var Tm=(e,t,r)=>{if(!("closed"in e)){t(),r?.();return}let n=()=>{clearImmediate(i),e.off("error",n),e.off("close",n),r?.()},o=()=>{if(e.closed)n();else if(i=setImmediate(o),!r)i.unref()},i=setImmediate(o);if(!r)i.unref();if(e.once("error",n),e.once("close",n),t(),!e.closed)e.destroy()};var $c=(e)=>jx(qx(RQ(e),(t)=>[t])),RQ=(e)=>Ar((t)=>{let r=e.evaluate(),n=UQ({...e,writable:r,pull:t});return z(e.endOnDone===!1?n:oi(n,(o)=>ri(o)?Je:_Q(r)))}),_Q=(e)=>nn((t)=>{let r=()=>t(Je);if(e.closed){let n=t_(e,{readable:!1},()=>{n(),r()})}else Tm(e,Wo,r)}),UQ=(e)=>kc((t)=>{let r=t.currentDispatcher,n=Eo(),o=Eo(),i=(S)=>Vn(o,vf(()=>e.onError(S))),s=!1,c=(S)=>{s=!0,i(S)};e.writable.on("error",c);let l=t_(e.writable,{readable:!1},(S)=>{if(S)i(S);else Vn(n,Je)});return e.pull.pipe(Ae((S)=>{let m=0;return nn((g)=>{let w=!1,k=()=>r.scheduleTask(A,0),A=()=>{e.writable.off("drain",A),e.writable.off("finish",k);for(;m<S.length;){if(w)return;if(!e.writable.write(S[m++],e.encoding,(h)=>{if(!h)return;if(e.writable.closed)i(h);else r.scheduleTask(()=>i(h),0)})){if(!w)e.writable.once("drain",A),e.writable.once("finish",k);return}}if(!w)g(Je)};return A(),Be(()=>{w=!0,e.writable.off("drain",A),e.writable.off("finish",k)})})}),Co({disableYield:!0}),e.endOnDone!==!1?Yn((S)=>(e.writable.end(),Zn(zr(n),hr(S)))):Ee,Un(zr(o)),vo(Be(()=>{l();let S=()=>{e.writable.off("error",c),e.writable.off("error",S),e.writable.off("close",S)};if(e.writable.errored&&!e.writable.closed&&!s)e.writable.once("error",S),e.writable.once("close",S);else S()})))});import{finished as LQ,Readable as Rse}from"stream";var Wc=(e)=>on(MQ(e)),MQ=(e)=>Ar((t,r)=>FQ({scope:r,readable:e.evaluate(),onError:e.onError??NQ,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone}));var FQ=(e)=>{let t=e.readable,r=e.chunkSize??4096,n=e.closeOnDone??!0,o=e.exit??cP(void 0),i=e.latch??iP(!1);function s(){i.openUnsafe()}t.on("readable",s);let c=LQ(t,{readable:!0,writable:!1},(S)=>{o.current??=_n(S?e.onError(S):ld()),i.openUnsafe()}),l=Ve(function S(){let m=e.readable.read(e.readSize);if(m===null){if(o.current)return o.current;if(t.readableEnded)return he(ld());return i.closeUnsafe(),Ae(i.await,S)}let g=Li(m);while(g.length<r){if(m=e.readable.read(e.readSize),m===null)break;g.push(m)}return z(g)});return sr(cd(e.scope,Be(()=>{if(t.off("readable",s),n)Tm(t,c);else c()})),l)};var NQ=(e)=>new hO(e);var ua=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),oo=(e,t,r)=>{let{commands:n}=WS(r),o=globalThis.process.platform==="win32"?"windows":"posix",i=n.map((s)=>Q0([s.command,...s.args],{format:o})).join(" | ");return ct("ChildProcess",e)(t,[i])},Pm=(e)=>no(e)?Kc(e):e,KQ=(e)=>{if(e.command.includes("\x00"))return"The command contains a NUL character";let t=e.args.findIndex((r)=>Pm(r).includes("\x00"));if(t!==-1)return`Argument ${t+1} contains a NUL character`;for(let[r,n]of Object.entries(e.options.env??{}))if(n!==void 0&&Pm(n).includes("\x00"))return`The environment variable ${r} contains a NUL character`;return},r_=1000,qQ=10,n_=(e)=>{let t=()=>{};e.on("error",t),e.once("close",()=>e.off("error",t))},qS=(e)=>e.exitCode!==null||e.signalCode!==null,Om=(e)=>globalThis.process.platform!=="win32"&&e.options.detached!==!1,i_=(e)=>e?.code==="EPERM",o_=(e,t)=>{if(t.lost===!0)return!1;if(!qS(t))return!0;if(!Om(e))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(r){return i_(r)}},$Q=(e,t=()=>{})=>{if(qS(e)){t(null);return}Rm.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t)},WQ=(e,t,r,n)=>{let o=Rm.spawn(e,t,r);for(let i of n){let s=o.stdio[i];if(s&&"allowHalfOpen"in s)s.allowHalfOpen=!0}return o},GQ=Ie(function*(e){let t=yield*Od,r=yield*ea,n=Ie(function*(K){if(ja(K.cwd))return;return yield*t.access(K.cwd),r.resolve(K.cwd)}),o=(K)=>{if(K.env===void 0)return;let ee=K.extendEnv===!0?{...globalThis.process.env}:{};for(let[Q,te]of Object.entries(K.env))if(te===void 0)delete ee[Q];else ee[Q]=Pm(te);return ee},i=(K)=>Zs(K)?"pipe":K,s=(K)=>vd(K)?"pipe":K,c=(K)=>{let ee={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(ja(K.stdin))return ee;if(typeof K.stdin==="string")return{...ee,stream:K.stdin};if(Zs(K.stdin))return{...ee,stream:K.stdin};return{stream:K.stdin.stream,encoding:K.stdin.encoding??ee.encoding,endOnDone:K.stdin.endOnDone??ee.endOnDone}},l=(K,ee)=>{let Q=K[ee];if(ja(Q))return{stream:"pipe"};if(typeof Q==="string")return{stream:Q};if(vd(Q))return{stream:Q};return{stream:Q.stream}},S=(K)=>{if(ja(K.additionalFds))return[];let ee=[];for(let[Q,te]of Object.entries(K.additionalFds)){let re=Cm(Q);if(Jt(re))ee.push({fd:re,config:te})}return ee.sort((Q,te)=>Q.fd-te.fd)},m=(K,ee,Q,te)=>{let re=[i(K.stream),s(ee.stream),s(Q.stream)];if(te.length===0)return re;let ae=te.reduce((se,{fd:le})=>Math.max(se,le),2);for(let se=3;se<=ae;se++)re[se]="ignore";for(let{fd:se}of te)re[se]="pipe";return re},g=(K,ee,Q)=>Uf(uR(cR(K,(te)=>rO(Q,te)),ee)),w=Ie(function*(K,ee,Q,te){if(Q.length===0)return{getInputFd:()=>Cd,getOutputFd:()=>Rc};let re=new Map,ae=new Map,se=(Se,ve,ye)=>Ve(()=>{let $e=Cd;if(ve&&"write"in ve)n_(ve),$e=$c({evaluate:()=>ve,onError:(_e)=>oo(`fromWritable(fd${Se})`,ua(_e),K)});if(ye)return De(g(ye,$e,te),()=>{re.set(Se,$e)});return re.set(Se,$e),Je}),le=(Se,ve,ye)=>{let $e=Rc;if(ve&&"read"in ve){let _e=new KS,rr=void 0;_e.on("error",(Nr)=>{rr??=Nr}),ve.on("error",(Nr)=>_e.destroy(Nr)),ve.pipe(_e);let lr=(Nr)=>oo(`fromReadable(fd${Se})`,ua(Nr),K);$e=iR(()=>rr===void 0?Wc({evaluate:()=>_e,onError:lr}):Jx(lr(rr)))}if(ye)$e=Hf($e,ye);ae.set(Se,$e)};for(let{config:Se,fd:ve}of Q){let ye=ee.stdio[ve];switch(Se.type){case"input":{yield*se(ve,ye,Se.stream);break}case"output":{le(ve,ye,Se.sink);break}case"duplex":{le(ve,ye,Se.sink),yield*se(ve,ye,Se.stream);break}}}return{getInputFd:(Se)=>re.get(Se)??Cd,getOutputFd:(Se)=>ae.get(Se)??Rc}}),k=(K,ee,Q,te)=>Ve(()=>{let re=Cd;if(bl(ee.stdin))n_(ee.stdin),re=$c({evaluate:()=>ee.stdin,onError:(ae)=>oo("fromWritable(stdin)",ua(ae),K),endOnDone:Q.endOnDone,encoding:Q.encoding});if(Zs(Q.stream))return sr(g(Q.stream,re,te),re);return z(re)}),A=(K,ee,Q,te)=>{let re=ee.stdout?(()=>{let le=new KS;return ee.stdout.on("error",(Se)=>le.destroy(Se)),ee.stdout.pipe(le),Wc({evaluate:()=>le,onError:(Se)=>oo("fromReadable(stdout)",ua(Se),K)})})():Rc,ae=ee.stderr?(()=>{let le=new KS;return ee.stderr.on("error",(Se)=>le.destroy(Se)),ee.stderr.pipe(le),Wc({evaluate:()=>le,onError:(Se)=>oo("fromReadable(stderr)",ua(Se),K)})})():Rc;if(vd(Q.stream))re=Hf(re,Q.stream);if(vd(te.stream))ae=Hf(ae,te.stream);let se=aR(re,ae);return{stdout:re,stderr:ae,all:se}},y=(K,ee,Q,te)=>nn((re)=>{let ae=Eo(),se=K(ee.command,ee.args.map(Pm),Q,te);return se.on("error",(le)=>{if(ee.args.some(no))Object.assign(le,{spawnargs:[ee.command,...ee.args.map((Se)=>no(Se)?"<redacted>":Se)]});re(he(oo("spawn",le,ee)))}),se.on("exit",(...le)=>{Vn(ae,Gs(le))}),se.on("lost",(le)=>{Vn(ae,_n(oo("exitCode",le,ee)))}),se.on("spawn",()=>{re(z([se,ae]))}),Be(()=>{se.kill("SIGTERM")})}),h=(K,ee,Q)=>{if(globalThis.process.platform==="win32")return nn((te)=>{$Q(ee,(re)=>{if(re)te(he(oo("kill",ua(re),K)));else te(Je)})});return Pr({try:()=>{globalThis.process.kill(-ee.pid,Q)},catch:(te)=>oo("kill",ua(te),K)})},x=(K,ee)=>{try{globalThis.process.kill(-K.pid,ee)}catch{}},G=(K,ee,Q)=>Ve(()=>{if(!ee.kill(Q)){let re=new globalThis.Error("Failed to kill child process");return he(oo("kill",re,K))}return Je}),X=(K,ee,Q)=>nn((te)=>{let re=Date.now()+Q,ae,se=()=>{clearTimeout(ae),ee.removeListener("exit",le),ee.removeListener("lost",le)},le=()=>{if(clearTimeout(ae),Date.now()>=re||!o_(K,ee)){se(),te(Je);return}ae=setTimeout(le,qQ)};return ee.on("exit",le),ee.on("lost",le),le(),Be(se)}),I=Ie(function*(K,ee,Q,te){let re=(ae)=>globalThis.process.platform==="win32"||Om(K)?h(K,ee,ae).pipe(Qs((se)=>qS(ee)&&i_(se.cause)?Je:G(K,ee,ae))):G(K,ee,ae);if(yield*re(te?.killSignal??"SIGTERM"),ja(te?.forceKillAfter))yield*zr(Q),yield*X(K,ee,r_);else if(yield*X(K,ee,Gl(te.forceKillAfter)),o_(K,ee))yield*re("SIGKILL"),yield*X(K,ee,r_);yield*zr(Q)}),me=(K,ee)=>{let Q=ee??"stdout";switch(Q){case"stdout":return K.stdout;case"stderr":return K.stderr;case"all":return K.all;default:{let te=Cm(Q);if(Jt(te))return K.getOutputFd(te);return K.stdout}}},pe=Ie(function*(K){switch(K._tag){case"StandardCommand":{if(K.options.shell!==void 0&&K.options.shell!==!1&&K.args.length>0)return yield*he(mn({module:"ChildProcess",method:"spawn",description:"The shell option cannot be combined with arguments; pass the whole script as the command"}));let ee=KQ(K);if(ee!==void 0)return yield*he(mn({module:"ChildProcess",method:"spawn",description:ee}));let Q=c(K.options),te=l(K.options,"stdout"),re=l(K.options,"stderr"),ae=S(K.options),se=!0,le=yield*n(K.options),Se=o(K.options),ve=m(Q,te,re,ae),ye=ae.flatMap(({config:wr,fd:An})=>wr.type==="duplex"?[An]:[]),$e=Ie(function*(wr,An){if(wr.lost===!0||!se)return;if(xf(An)){let[Ko]=yield*Ao(zr(An));if((Ko===0||zA(Ko))&&!Om(K))return}yield*gx(I(K,wr,An,K.options))}),_e=yield*e,rr=Bi(),[lr,Nr]=yield*Dn(y(_e,K,e_(K.options,{cwd:le,env:Se,stdio:ve},process.platform),ye),([wr,An],Ko)=>Ec([en(rr,Ko),$e(wr,An)],{concurrency:"unbounded",discard:!0})),ws=$0(lr.pid);if(Om(K))lr.on("exit",(wr)=>{if(se&&wr!==0&&bl(wr))x(lr,K.options.killSignal??"SIGTERM")});let Es=Be(()=>{if(!se)lr.ref(),se=!0}),ks=Be(()=>{if(se)lr.unref(),se=!1;return Es}),yo=Eo(),al=yield*Ki(rr)(k(K,lr,Q,yo)),{all:cl,stderr:pl,stdout:dl}=A(K,lr,te,re),{getInputFd:ul,getOutputFd:ll}=yield*Ki(rr)(w(K,lr,ae,yo)),fl=Ve(()=>xf(Nr)?sr(zr(Nr),!1):z(!0)),ml=Ae(Un(zr(Nr),zr(yo)),([wr,An])=>{if(xf(yo))return zr(yo);if(bl(wr))return z(q0(wr));let Ko=new globalThis.Error(`Process interrupted due to receipt of signal: '${An}'`);return he(oo("exitCode",Ko,K))});return NS({pid:ws,exitCode:ml,isRunning:fl,kill:(wr)=>I(K,lr,Nr,wr),stdin:al,stdout:dl,stderr:pl,all:cl,getInputFd:ul,getOutputFd:ll,unref:ks})}case"PipedCommand":{let{commands:ee,pipeOptions:Q}=WS(K),[te,...re]=ee,ae=[yield*pe(te)];for(let ve=0;ve<re.length;ve++){let ye=re[ve],$e=Q[ve]??{},_e=c(ye.options),rr=Po(z(me(ae[ae.length-1],$e.from))),lr=$e.to??"stdin";if(lr==="stdin")ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,stdin:{..._e,stream:rr}})));else{let Nr=Cm(lr);if(Jt(Nr)){let ws=X0(Nr),Es=ye.options.additionalFds??{},ks=Es[ws],yo=ks?.type==="duplex"?{...ks,stream:rr}:{type:"input",stream:rr};ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,additionalFds:{...Es,[ws]:yo}})))}else ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,stdin:{..._e,stream:rr}})))}}let se=ae[ae.length-1],le=(ve)=>zi([...ae].reverse(),(ye)=>gx(ye.kill(ve)),{discard:!0}),Se=kr(function*(){let ve=[];for(let ye of ae)ve.push(yield*ye.unref);return zi([...ve].reverse(),(ye)=>ye,{discard:!0})});return NS({pid:se.pid,exitCode:se.exitCode,isRunning:se.isRunning,kill:le,stdin:ae[0].stdin,stdout:se.stdout,stderr:se.stderr,all:se.all,getInputFd:se.getInputFd,getOutputFd:se.getOutputFd,unref:Se})}}});return W0(pe)}),$S=Ic(Bc,GQ(z(WQ)));var WS=(e)=>{let t=[],r=[],n=(c)=>{switch(c._tag){case"StandardCommand":{t.push(c);break}case"PipedCommand":{n(c.left),r.push(c.options),n(c.right);break}}};if(n(e),t.length===0)throw Error("flattenCommand produced empty commands array");let[o,...i]=t;return{commands:[o,...i],pipeOptions:r}};import*as c_ from"crypto";import*as we from"fs";import*as p_ from"os";import*as li from"path";var gt=(e)=>(t)=>mn({module:"FileSystem",method:e,description:t.message??String(t)}),d_=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},s_=(e)=>ig(Ns(e),LO),u_=(e)=>BigInt.asUintN(64,e),GS=(e)=>Dl(Ns(e),u_),jQ=(e,t)=>Pr({try:()=>d_(e,"position"),catch:gt(t)}),QQ=(()=>{let e=Rt(we.access,ct("FileSystem","access"),gt("access"));return(t,r)=>{let n=we.constants.F_OK;if(r?.readable)n|=we.constants.R_OK;if(r?.writable)n|=we.constants.W_OK;return e(t,n)}})(),HQ=(()=>{let e=Rt(we.cp,ct("FileSystem","copy"),gt("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),VQ=(()=>{let e=Rt(we.copyFile,ct("FileSystem","copyFile"),gt("copyFile"));return(t,r)=>e(t,r)})(),JQ=(()=>{let e=Rt(we.chmod,ct("FileSystem","chmod"),gt("chmod"));return(t,r)=>e(t,r)})(),YQ=(()=>{let e=Rt(we.chown,ct("FileSystem","chown"),gt("chown"));return(t,r,n)=>e(t,r,n)})(),ZQ=(()=>{let e=Rt(we.link,ct("FileSystem","link"),gt("link"));return(t,r)=>e(t,r)})(),XQ=(()=>{let e=Rt(we.mkdir,ct("FileSystem","makeDirectory"),gt("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),zS=(e)=>{let t=Rt(we.mkdtemp,ct("FileSystem",e),gt(e));return(r)=>Ve(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?li.join(r.directory,"."):p_.tmpdir();return t(n?li.join(o,n):o+"/")})},eH=zS("makeTempDirectory"),jS=(e)=>{let t=Rt(we.rm,ct("FileSystem",e),gt(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},tH=jS("remove"),rH=(()=>{let e=zS("makeTempDirectoryScoped"),t=jS("makeTempDirectoryScoped");return(r)=>Dn(e(r),(n)=>Ao(t(n,{recursive:!0,force:!0})))})(),nH=(e)=>{let{O_APPEND:t,O_CREAT:r,O_EXCL:n,O_RDONLY:o,O_RDWR:i,O_TRUNC:s,O_WRONLY:c}=we.constants;switch(e){case"r":return o;case"r+":return i;case"w":return s|r|c;case"wx":return s|r|c|n;case"w+":return s|r|i;case"wx+":return s|r|i|n;case"a":return t|r|c;case"ax":return t|r|c|n;case"a+":return t|r|i;case"ax+":return t|r|i|n}},oH=(e,t)=>Ve(()=>{let{O_NOFOLLOW:r}=we.constants;if(process.platform==="win32"||typeof r!=="number"||r===0)return he(mn({module:"FileSystem",method:e,description:"noFollow is not supported on this platform"}));return z(nH(t)|r)}),iH=(e)=>{let t=Rt(we.open,ct("FileSystem",e),gt(e)),r=Rt(we.close,ct("FileSystem",e),gt(e));return(n,o)=>Oi(Dn(o?.noFollow===!0?Ae(oH(e,o.flag??"r"),(i)=>t(n,i,o.mode)):t(n,o?.flag??"r",o?.mode),(i)=>Ao(r(i))),De((i)=>cH(i,o?.flag?.startsWith("a")??!1)))},sH=iH("open"),aH=(e)=>e.reason.cause?.code==="ESPIPE",a_=(e)=>mn({module:"FileSystem",method:e,description:"Cannot read before the start of the file"}),cH=(()=>{let e=(m)=>Rt(we.read,ct("FileSystem",m),gt(m)),t=e("read"),r=e("readAlloc"),n=Rt(we.fstat,ct("FileSystem","stat"),gt("stat")),o=Rt(we.ftruncate,ct("FileSystem","truncate"),gt("truncate")),i=Rt(we.fsync,ct("FileSystem","sync"),gt("sync")),s=(m)=>{let g=Rt(we.write,ct("FileSystem",m),gt(m));return(w,k,A)=>g(w,k,0,k.length,A)},c=s("write"),l=s("writeAll");class S{[Vf];fd;append;position=BigInt(0);sequential=!1;constructor(m,g){this[Vf]=Vf,this.fd=m,this.append=g}get stat(){return Ae(n(this.fd,{bigint:!0}),m_)}get sync(){return i(this.fd)}atCursor(m){return Ve(()=>{if(this.sequential)return m(null);let g=this.position;return Qi(De(m(g),(w)=>(this.position=g+BigInt(w),w)),aH,()=>(this.sequential=!0,m(null)))})}writeOnce(m,g,w){return this.append?Ve(()=>g(this.fd,w,void 0)):this.atCursor((k)=>k===null?g(this.fd,w,void 0):Ae(jQ(k,m),(A)=>g(this.fd,w,A)))}seek(m,g){return Ve(()=>{let w=g==="start"?m:this.position+m;if(w<BigInt(0))return he(mn({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"}));return this.position=w,z(w)})}read(m,g){return Ve(()=>{let w=g?.position;if(w===void 0)return this.atCursor((k)=>t(this.fd,{buffer:m,position:k}));return w<BigInt(0)?he(a_("read")):t(this.fd,{buffer:m,position:w})})}readAlloc(m,g){return Ve(()=>{try{if(!Number.isInteger(m)||m<0)throw RangeError("size must be a non-negative integer");let w=g?.position;if(w!==void 0&&w<BigInt(0))return he(a_("readAlloc"));let k=Buffer.allocUnsafeSlow(m),A=(y)=>r(this.fd,{buffer:k,position:y});return De(w===void 0?this.atCursor(A):A(w),(y)=>{if(y===0)return ge();if(y===m)return Ue(k);let h=Buffer.allocUnsafeSlow(y);return k.copy(h,0,0,y),Ue(h)})}catch(w){return he(gt("readAlloc")(w))}})}truncate(m){return De(o(this.fd,m||void 0),()=>{if(!this.append){let g=BigInt(m??0);if(this.position>g)this.position=g}})}write(m){return this.writeOnce("write",c,m)}writeAllChunk(m){return Ae(this.writeOnce("writeAll",l,m),(g)=>{if(g===0)return he(Xn({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));return g<m.length?this.writeAllChunk(m.subarray(g)):Je})}writeAll(m){return m.length===0?Je:this.writeAllChunk(m)}}return(m,g)=>new S(m,g)})(),l_=(e)=>{let t=zS(e);return Ie(function*(r){let n=yield*t(r),o=c_.randomBytes(6).toString("hex"),i=li.join(n,r?.suffix?`${o}${r.suffix}`:o);return yield*y_(i,new Uint8Array(0)),i})},pH=l_("makeTempFile"),dH=(()=>{let e=l_("makeTempFileScoped"),t=jS("makeTempFileScoped");return(r)=>Dn(e(r),(n)=>Ao(t(li.dirname(n),{recursive:!0,force:!0})))})(),uH=(e,t)=>zs({try:()=>we.promises.readdir(e,t),catch:(r)=>ct("FileSystem","readDirectory")(r,[e])}),lH=(e)=>zs({try:()=>we.promises.readdir(e,{withFileTypes:!0}),catch:(t)=>ct("FileSystem","readDirectoryEntries")(t,[e])}).pipe(De((t)=>t.map((r)=>({name:r.name,type:f_(r)})))),fH=(e)=>nn((t,r)=>{try{we.readFile(e,{signal:r},(n,o)=>{if(n)t(he(ct("FileSystem","readFile")(n,[e])));else t(z(o))})}catch(n){t(he(gt("readFile")(n)))}}),mH=(()=>{let e=Rt(we.readlink,ct("FileSystem","readLink"),gt("readLink"));return(t)=>e(t)})(),hH=(()=>{let e=Rt(process.platform==="win32"?we.realpath.native:we.realpath,ct("FileSystem","realPath"),gt("realPath"));return(t)=>e(t)})(),yH=(()=>{let e=Rt(we.rename,ct("FileSystem","rename"),gt("rename"));return(t,r)=>e(t,r)})(),f_=(e)=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",m_=(e,t="stat")=>Pr({try:()=>({type:f_(e),mtime:Ns(e.mtime),atime:Ns(e.atime),birthtime:Ns(e.birthtime),dev:u_(e.dev),rdev:GS(e.rdev),ino:GS(e.ino),mode:d_(e.mode,"mode"),nlink:GS(e.nlink),uid:s_(e.uid),gid:s_(e.gid),size:Ax(e.size),blksize:e.blksize!==void 0?Ue(Ax(e.blksize)):ge(),blocks:Ns(e.blocks)}),catch:gt(t)}),h_=(e,t)=>{let r=Rt(t,ct("FileSystem",e),gt(e));return(n)=>Ae(r(n,{bigint:!0}),(o)=>m_(o,e))},QS=h_("stat",we.stat),gH=h_("lstat",we.lstat),xH=(()=>{let e=Rt(we.symlink,ct("FileSystem","symlink"),gt("symlink"));return(t,r)=>e(t,r)})(),SH=(()=>{let e=Rt(we.truncate,ct("FileSystem","truncate"),gt("truncate"));return(t,r)=>e(t,r)})(),bH=(()=>{let e=Rt(we.utimes,ct("FileSystem","utime"),gt("utime"));return(t,r,n)=>e(t,r,n)})(),IH=(e,t,r)=>oR((n)=>Dn(Be(()=>{let o=t.type==="Directory"?e:li.dirname(e),i=we.watch(e,{recursive:r?.recursive??!1},(s,c)=>{if(!c)return;switch(s){case"rename":{Df(CO(QS(li.resolve(o,c)),{onSuccess:(l)=>wd(n,{_tag:"Create",path:c}),onFailure:(l)=>wd(n,{_tag:"Remove",path:c})}));return}case"change":{Zi(n,{_tag:"Update",path:c});return}}});return i.on("error",(s)=>{Ed(n,mO(Xn({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:s})))}),i.on("close",()=>{Oo(n)}),i}),(o)=>Be(()=>o.close())).pipe(ji(()=>Be(()=>r?.onReady?.())))),wH=(e,t,r)=>Ec([QS(t),Tf(Jf)]).pipe(De(([n,o])=>Rv(o,()=>e).pipe(ig((i)=>i.register(t,n,r)),fr(()=>IH(t,n,r)))),Po),y_=(e,t,r)=>nn((n,o)=>{try{we.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(i)=>{if(i)n(he(ct("FileSystem","writeFile")(i,[e])));else n(Je)})}catch(i){n(he(gt("writeFile")(i)))}}),EH=De(Tf(Jf),(e)=>hR({access:QQ,chmod:JQ,chown:YQ,copy:HQ,copyFile:VQ,link:ZQ,lstat:gH,makeDirectory:XQ,makeTempDirectory:eH,makeTempDirectoryScoped:rH,makeTempFile:pH,makeTempFileScoped:dH,open:sH,readDirectory:uH,readDirectoryEntries:lH,readFile:fH,readLink:mH,realPath:hH,remove:tH,rename:yH,stat:QS,symlink:xH,truncate:SH,utimes:bH,watch(t,r){return wH(e,t,r)},writeFile:y_})),g_=Ic(Od)(EH);var x_=g_;import*as eu from"path";import*as _m from"url";var HS=(e)=>({fromFileUrl:(t)=>Pr({try:()=>_m.fileURLToPath(t,{windows:e}),catch:(r)=>new Id({module:"Path",method:"fromFileUrl",cause:r})}),toFileUrl:(t)=>Pr({try:()=>_m.pathToFileURL(t,{windows:e}),catch:(r)=>new Id({module:"Path",method:"toFileUrl",cause:r})})}),vH=bc(ea)(Yf({...eu.posix,...HS(!1)})),CH=bc(ea)(Yf({...eu.win32,...HS(!0)})),S_=bc(ea)(Yf({...eu,...HS(void 0)}));var b_=S_;var VS="~effect/Stdio",I_=Ht(VS),w_=(e)=>({[VS]:VS,stdinIsTerminal:z(!1),stdoutIsTerminal:z(!1),stderrIsTerminal:z(!1),...e});var PH=Be(()=>{process.nextTick(()=>{if(process.stdin.readableFlowing===null)process.stdin.pause()})}),k_=bc(I_,w_({args:Be(()=>process.argv.slice(2)),stdinIsTerminal:Be(()=>process.stdin.isTTY===!0),stdoutIsTerminal:Be(()=>process.stdout.isTTY===!0),stderrIsTerminal:Be(()=>process.stderr.isTTY===!0),stdout:(e)=>$c({evaluate:()=>process.stdout,onError:(t)=>Xn({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>$c({evaluate:()=>process.stderr,onError:(t)=>Xn({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:Po(sr(vc(()=>PH),Wc({evaluate:()=>process.stdin,onError:(e)=>Xn({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})))}));var A_=k_;var v_="~effect/http/Cookies";var C_="~effect/http/Cookies/Cookie";var UH={[v_]:v_,..._i,toJSON(){return{_id:"effect/Cookies",cookies:Gv(this.cookies,(e)=>e.toJSON())}},pipe(){return et(this,arguments)}},DH=(e)=>{let t=Object.create(UH);return t.cookies=e,t},LH=(e)=>{let t={};for(let r of e)Zr(t,r.name,r);return DH(t)};var T_=LH([]);var Yse={[C_]:C_,..._i,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var P_=Symbol.for("~effect/http/Headers");var Um=Object.defineProperties(Object.create(null),{[P_]:{value:P_},[Ps]:{value(e){return FH(this,dn(e,NH))}},toJSON:{value(){return zn(this)}},[At]:{value(e){return MH(this,e)}},[kt]:{value(){return Cp(this)}},toString:{value:_i.toString},[Xr]:{value:_i[Xr]}});var MH=jv(yv()),la=Object.create(Um),R_=(e)=>{if(e===void 0)return la;else if(Symbol.iterator in e){let r=Object.create(Um);for(let[n,o]of e){let i=n.toLowerCase();r[i]=i in r?`${r[i]}, ${o}`:o}return r}let t=Object.create(Um);for(let[r,n]of Object.entries(e))if(Array.isArray(n))t[r.toLowerCase()]=n.join(", ");else if(n!==void 0)t[r.toLowerCase()]=n;return t},__=(e)=>Object.setPrototypeOf(e,Um);var FH=q(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=pa(e[i])}else for(let i in e)if(i.search(o)!==-1)r[i]=pa(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r});var NH=Vt("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var Dm=(e,t,r)=>Xt(e)?r(t):Qr(e,r);function D_(e){let t=BH(e);return(r,n,o)=>{try{return t(r,n,o)}catch(i){return Or(i)}}}function BH(e){if(e._tag==="Middleware")return(r,n,o)=>{let i=Xt(r)?e.decode(vr(_d(n)),o):e.decode(Mf(r,_d),o);return U_(i)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>Xt(r)?vr(n):r;case"Transform":{let r=(n)=>n===We?Ln:vr(t.transform(n));return(n,o)=>Dm(n,o,r)}case"TransformOptional":{let r=(n)=>tS(t.transform(_d(n)));return(n,o)=>Dm(n,o,r)}case"TransformEffect":return(r,n,o)=>Dm(r,n,(i)=>i===We?Ln:t.transform(i,o));case"TransformOptionalEffect":return(r,n,o)=>Dm(r,n,(i)=>U_(t.transform(_d(i),o)))}}var U_=(e)=>Qr(e,tS),L_=(e,t,r,n)=>jr(n,(o)=>js(()=>Gi(o,(i)=>new SR(e,i,t,r))));function KH(e,t){let r=D_(e.link.transformation),n;return(o,i)=>{if(o===We)return Ln;if(e.isConstructed(o))return si;let s=(n??=t(e.link.to))(o,i);return r(s,o,i)}}function qH(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==We&&n!==void 0)return t(n,o);let i=r;if(ft(i)&&i._tag==="Success"){let s=t(i[Me],o);return Xt(s)?i:s}return Qr(L_(e,n,o,i),(s)=>{let c=t(s,o);return Xt(c)?vr(s):c})}}function YS(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:qH(e,r)}function tu(e,t,r,n,o){if(e._tag==="Declaration")for(let A of e.typeParameters)t(A);let i=r?Am(e):void 0,s=i?KH(i,t):n??e.getParser(t,r),{checks:c,encoding:l}=e,S=l?.map((A)=>D_(A.transformation)),m=e.encodingChecks;if(!l&&!c&&!m)return s;let g,w=(A,y)=>{let h=s(A,y);try{if(m&&!y.disableChecks)if(ft(h)){if(h._tag==="Success"){let x=Xt(h)?A:h[Me];if(A!==We&&x!==We){let G=ts(m,A,void 0,e,y);if(G)h=he(new Ur(e,G,A,y))}}}else h=Ae(h,(x)=>{if(A!==We&&x!==We){let G=ts(m,A,void 0,e,y);if(G)return he(new Ur(e,G,A,y))}return z(x)});if(c&&!y.disableChecks)if(ft(h)){if(h._tag==="Success"){let x=Xt(h)?A:h[Me];if(x===We)return h;let G=ts(c,x,void 0,e,y);if(G)h=he(new Ur(e,G,x,y))}}else h=Ae(h,(x)=>{if(x!==We){let G=ts(c,x,void 0,e,y);if(G)return he(new Ur(e,G,x,y))}return z(x)});return h}catch(x){return Or(x)}},k=o===void 0?w:o(w);if(!l)return k;return(A,y)=>{let h=g??=l.map((X)=>t(X.to)),x=A,G=h[h.length-1](A,y);for(let X=l.length-1;X>=0;X--)if(G=S[X](G,x,y),X!==0){let I=h[X-1];if(G._tag==="Success")x=G[Me],G=I(x,y);else G=Qr(G,(me)=>{let pe=I(me,y);return Xt(pe)?vr(me):pe})}if(G._tag==="Success"){let X=G[Me],I=k(X,y);return Xt(I)?G:I}return G=L_(e,A,y,G),Qr(G,(X)=>{let I=k(X,y);return Xt(I)?vr(X):I})}}var ZS=Symbol(),M_=new WeakMap,F_,ru=!1;var WH=(e)=>ru?Lm(gn,e,"parser"):gn(e).parser,N_=(e)=>ru?Lm(gn,e,"makeEffect"):gn(e).makeEffect,GH=(e)=>YS(e,N_);class XS{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=tu(this.ast,WH)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=tu(this.ast,N_,GH)}}class B_ extends XS{compiled;resolve;constructor(e,t,r){super(e);this.compiled=t,this.resolve=r}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==="function"?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get compiledMakeEffect(){return this.save("compiledMakeEffect",this.operation("makeEffect"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??tu(this.ast,(e)=>Lm(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",zH(e,()=>this.decodeEffect))}get makeEffect(){let e=this.compiledMakeEffect;if(e!==void 0)return this.save("makeEffect",e);let t=(r)=>Lm(this.resolve,r,"makeEffect");return this.save("makeEffect",tu(this.ast,t,(r)=>YS(r,t)))}}function zH(e,t){let r;return(n,o)=>{if(n!==We)try{let i=e(n,o);if(i!==ZS)return i===n?si:vr(i)}catch(i){return Or(i)}return(r??=t())(n,o)}}function Lm(e,t,r){let n=e(t);if(n.compiled===void 0||Object.hasOwn(n,r))return n[r];let o;return(i,s)=>(o??=n[r])(i,s)}function gn(e){let t=M_.get(e);if(t!==void 0)return t;let r=F_===void 0?new XS(e):new B_(e,F_(e,gn),gn);return M_.set(e,r),r}function tb(e){let t=e.ast,r;return(n,o)=>J_(r??=gn(di(t)),n,V_(o))}function Mm(e){let t=tb(e);return(r,n)=>YH(Js(t(r,n)))}function q_(e){return XH(di(e.ast))}function $_(e){return HH(e.ast)}function QH(e){if(!ru){let o=j_(nb(e));return(i)=>{let s=o(i,sa);if(tn(s))return!0;return ta(s.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=gn(e),r=t.is;if(r!==void 0)return(o)=>{try{return r(o,sa)}catch(i){return ta(Ef(i),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return(o)=>{let i=Js(ob(n(o,sa),o));if(tn(i))return!0;return ta(i.cause,"Type guard adapter can only return false for schema issues"),!1}}function HH(e){let t=di(e),r=(n)=>(r=QH(t),r(n));return(n)=>r(n)}function rb(e,t){let r=nb(e.ast);return z_(r,t)}function W_(e,t){return JH(rb(e,t))}function G_(e,t){let r=nb(hn(e.ast));return z_(r,t)}function z_(e,t){return t===void 0?e:(r,n)=>e(r,n?{...t,...n}:t)}var K_=(e)=>{if(e===We)return he(new Hr);return z(e)};function nb(e){return VH(eV,e)}function ob(e,t){if(Xt(e))return z(t);if(!ft(e))return Qr(e,K_);return e[Me]===We?K_(We):e}function VH(e,t){let r;return(n,o)=>ob((r??=e(t))(n,o??sa),n)}function j_(e){return(t,r)=>Js(e(t,r))}function JH(e){let t=j_(e);return(r,n)=>{let o=t(r,n);if(tn(o))return Ue(o.value);return ta(o.cause,"Option adapter can only return none for schema issues"),ge()}}function YH(e){if(tn(e))return Ue(e.value);return ta(e.cause,"Option adapter can only return none for schema issues"),ge()}function ZH(e,t){let r=Js(e);if(tn(r))return r.value;let n=ta(r.cause,t);throw Error("Schema validation failed",{cause:n})}var Q_="Constructor adapter can only throw schema issues";function H_(e){throw Error(Q_,{cause:Ef(e)})}function XH(e){let t;return(r,n)=>eb(t??=gn(e),r,n)}function V_(e){return e?.disableChecks?{...e.parseOptions,disableChecks:!0}:e?.parseOptions??sa}function J_(e,t,r){return ob(e.makeEffect(t,r),t)}function eb(e,t,r){let n=V_(r),o=ru?e.make:void 0;if(o!==void 0&&t!==We){let i;try{i=o(t,n)}catch(s){H_(s)}if(i!==ZS&&i!==We)return i}return ZH(J_(e,t,n),Q_)}function Y_(e,t,r,n){let o=gn(e),i=Am(e);if(i===void 0||o.make!==void 0||o.compiledMakeEffect!==void 0)return eb(o,t,r);if(i.isConstructed(t))return t;let s=eb((o.resolve??gn)(i.link.to),t,r);try{return n(s)}catch(c){H_(c)}}var eV=(e)=>gn(e).parser;var Fm="~effect/Schema/Schema",Z_=Symbol(),tV={[Fm]:Fm,get make(){let e=q_(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=tb(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Mm(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return et(this,arguments)},annotate(e){return this.rebuild(bm(this.ast,e))},annotateKey(e){return this.rebuild(Em(this.ast,e))},check(...e){return this.rebuild(aa(this.ast,e))},rebuild(e){return Gc(e,this[Z_])}};function Gc(e,t){function r(){}let n=Object.setPrototypeOf(r,tV);if(t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__")))Object.defineProperties(n,Object.getOwnPropertyDescriptors({...t}));else Object.assign(n,t);return n[Z_]=t,n.ast=e,n}function iV(e,t){let r=Pi((o)=>{let i=Fc(o,void 0),s=e(i,n);return s===i?null:s}),n=wm((o)=>{let i=r(Jd(o));if(i===null)return o;let s=Fc(i,o.context);return o.context===void 0?s:v0(s,sV(o.context))},t);return n}function sV(e){return e.constructorDefault===void 0?e:new SS(e.isOptional,e.isMutable,void 0,e.annotations)}function aV(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function cV(e){return(t)=>{let r=[...t].sort((o,i)=>e(ui(o))-e(ui(i)));if(!r.some((o,i)=>o!==t[i]))return t;return r}}function eU(e){return Gc(hV(e.ast),{schema:e})}var pV=cV((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function dV(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map((S)=>Gc(t(ui(S)))),o=e.annotations?.toCodecStringTree;if(xo(o)){let S=o(n);if(S===void 0)return e;return Dr(e,[Im(S,t)])}let i=e.annotations?.toCodecJson,s=xo(i)?i(n):void 0,c=s===void 0?e.annotations?.toCodec:void 0,l=s??(xo(c)?c(n):void 0);return l===void 0?r(e):Dr(e,[Im(l,t)])}case"Null":return Dr(e,[uV]);case"Boolean":return Dr(e,[lV]);case"Unknown":case"ObjectKeyword":return Dr(e,[MS]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return aV(e),e.recur(t,LS);case"Union":{let n=pV(e.types);if(n!==e.types)return new es(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var uV=new Lr(new _o("null"),new ar(Bt(()=>null),Bt(()=>"null"))),lV=new Lr(new es([new _o("true"),new _o("false")]),new ar(Bt((e)=>e==="true"),om())),fV=new ar(Bt((e)=>typeof e==="string"?[e]:e),Ro()),mV=(e)=>e.transformation===fV,hV=iV((e,t)=>dV(e,t,(r)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})}),{stopAt:mV});var fa=(e)=>e;var zc="~effect/Schema/SchemaError";function rU(e){return He(e,zc)&&e[zc]===zc}var nu=Fm;function gV(){return(e,t,r)=>Tt(new Vd(e.map(gm),(n)=>t(n.map((o)=>Tt(o))),r))}function xV(e,t){return gV()([],()=>(r,n,o)=>e(r)?z(r):he(new ro(n,r,o)),t)}function SV(e){return(t)=>nU(nU(t).annotate(e))}class ab extends Jo("SchemaError"){[zc]=zc;constructor(e){let t=_s();jn(0);try{super({issue:e})}finally{jn(t)}}get message(){return TR(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Xr](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}}function bV(e){return rU(e)}function sU(e){if(ft(e))return IV(e);return jr(e,(t)=>js(()=>Gi(t,(r)=>new ab(r))))}function IV(e){return tn(e)?e:Wi(Gi(e.cause,(t)=>new ab(t)))}function aU(e,t){let r;for(let n of e.reasons){if(!wf(n)||!bV(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(r===void 0)throw new globalThis.Error(t,{cause:e});return r}function wV(e){return Ex(e).then((t)=>{if(tn(t))return t.value;throw aU(t.cause,"Promise adapter can only reject schema errors")})}function EV(e){let t=Js(e);if(tn(t))return t.value;throw aU(t.cause,"Sync adapter can only throw schema errors")}var cb=$_;function rs(e,t){let r=rb(e,t);return(n,o)=>sU(r(n,o))}var ns=W_;function io(e,t){let r=rs(e,t);return(n,o)=>wV(r(n,o))}function kV(e,t){let r=rs(e,t);return(n,o)=>EV(r(n,o))}function cU(e,t){let r=G_(e,t);return(n,o)=>sU(r(n,o))}var Tt=Gc;function AV(e){return He(e,nu)&&e[nu]===nu}var u=fa((e)=>Tt(km(e.ast),{schema:e}));var pb=fa((e)=>{let t=OV(e);return Tt(O0(e.ast),{schema:t})});var vV=fa((e)=>Tt(ui(e.ast),{schema:e})),ou="~effect/Schema/flip";function CV(e){return He(e,ou)&&e[ou]===ou}function nU(e){if(CV(e))return e.schema.rebuild(hn(e.ast));return Tt(hn(e.ast),{[ou]:ou,schema:e})}function v(e){let t=Tt(new _o(e),{literal:e,transform(r){return t.pipe(os(v(r),{decode:Bt(()=>r),encode:Bt(()=>e)}))}});return t}var H=Tt(Qd),pU=Tt(mm),TV=Tt(bS),a=Tt(Xi);var yr=Tt(IS),Y=Tt(a0);function db(e,t){return Tt(e,{fields:t,mapFields(r,n){let o=r(this.fields);return db(ym(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function p(e){return db(ym(e,void 0),e)}function Wt(e,t){return Tt(RS(e.ast,t.ast),{key:e,value:t})}function dU(e,t){return Tt(m0(e.ast,t.map(gm)),{schema:e,records:t})}var U=fa((e)=>Tt(new hm(!1,[],[e.ast]),{value:e}));function uU(e,t){return Tt(e,{members:t,mapMembers(r,n){let o=r(this.members);return uU(xm(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function mt(e,t){return uU(xm(e,t,void 0),e)}function j(e){let t=e.map(v);return Tt(xm(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return mt(r(this.members))},pick(r){return j(r)},transform(r){return mt(t.map((n,o)=>n.transform(r[o])))}})}var D=fa((e)=>mt([e,pU])),OV=fa((e)=>mt([e,TV]));function pt(e){return(t)=>Tt(t.ast,{schema:t,identifier:e})}function PV(e){return(t)=>Tt(C0(t.ast,new cS(e,Ee)),{schema:t})}function ub(e){return RV(e)}function RV(e){return(t)=>PV(_O(e))(t)}function os(e,t){return(r)=>Tt(PS(r.ast,e.ast,t?pS(t):cm()),{from:r,to:e})}var lb=j(["true","yes","on","1","y"]),fb=j(["false","no","off","0","n"]),lU=j([...lb.literals,...fb.literals]).pipe(os(Y,am({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function _V(e){return(t)=>Tt(P0(t.ast,e),{schema:t})}function UV(e){if(ft(e)&&e._tag==="Success")return e;return jr(e,(t)=>js(()=>Gi(t,(r)=>r.issue)))}function fU(e,t){let r=t?.encodingStrategy==="omit"?NR():Ro();return(n)=>u(vV(n)).pipe(os(n,{decode:BR(UV(e)),encode:r}))}function is(e){return v(e).pipe(_V(z(e)))}function DV(e,t){return p({_tag:is(e),...t})}function ma(e,t){return xV((r)=>r instanceof e,t)}function su(){return(e,t)=>new Lr(e.ast,pS(t))}var Gt=Sm;var oU="^\\S[\\s\\S]*\\S$|^\\S$|^$";function LV(e){let t=new globalThis.RegExp(oU);return Gt((r)=>r.trim()===r,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),arbitraryConstraint:{patterns:[{source:oU,flags:""}]},...e})}function Ge(e,t){let{source:r,flags:n}=e,o=/^[dg]*uy?$/.test(n);return vS(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],...t})}var MV=(e)=>{if(e)return new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);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|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/};function L(e,t){let r=MV(e);return Ge(r,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:r.source,format:"uuid"}),...t})}function FV(e){let r=/^[0-9a-zA-Z+/]*={0,2}$/;return Gt((n)=>n.length%4===0&&r.test(n),{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$"}),arbitraryConstraint:{patterns:[{source:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$",flags:""}]},...e})}function NV(e){let t=qp(e.order),r=e.formatter??rt;return(n,o)=>Gt((i)=>t(i,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function BV(e){let t=og(e.order),r=e.formatter??rt;return(n,o)=>Gt((i)=>t(i,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...o})}function KV(e){let t=ng(e.order),r=e.formatter??rt;return(n,o)=>Gt((i)=>t(i,n),{expected:`a value less than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n},...e.annotate?.(n),...o})}function qV(e){let t=og(e.order),r=qp(e.order),n=ng(e.order),o=Pv(e.order),i=e.formatter??rt;return(s,c)=>{let l=s.exclusiveMinimum?r:t,S=s.exclusiveMaximum?o:n;return Gt((m)=>l(m,s.minimum)&&S(m,s.maximum),{expected:`a value between ${i(s.minimum)}${s.exclusiveMinimum?" (excluded)":""} and ${i(s.maximum)}${s.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:s.minimum,maximum:s.maximum,...s.exclusiveMinimum&&{exclusiveMinimum:!0},...s.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(s),...c})}}function iu(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${rt(e)}`);return e}var Do=NV({order:Fs,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:iu(e)}},toJsonSchema:()=>({exclusiveMinimum:e})})}),Pe=BV({order:Fs,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:iu(e)}},toJsonSchema:()=>({minimum:e})})});var mU=KV({order:Fs,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:iu(e)}},toJsonSchema:()=>({maximum:e})})}),Mr=qV({order:Fs,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:iu(e.minimum),maximum:iu(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum})}}});function au(e){return Gt((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer",minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),arbitraryConstraint:{number:"integer"},...e})}var M=yr.check(au());function be(e,t){return e=hU(e),$V(e,Math.ceil(e/2),t)}function $V(e,t,r){return Gt((n)=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:n==="array"?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],[Pd]:!0,arbitraryConstraint:{minLength:e},...r})}function oe(e,t){return e=hU(e),Gt((r)=>r.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:r})=>r==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:r==="array"?{maxItems:e}:r===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],[Pd]:!0,arbitraryConstraint:{maxLength:e},...t})}function hU(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var WV=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),GV=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}};var iU=[];function yU(e){let t=WV(e),r=iU[t];if(r!==void 0)return r;let n=XV.pipe(os(H,jR(GV(t))));return iU[t]=n,n}var Tce=ma(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},expected:"RegExp",toCodecJson:()=>su()(p({source:a,flags:a}),sm({decode:(e,t)=>Pr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new Hr({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>z({source:e.source,flags:e.flags})}))}),zV=a.annotate({expected:"a string that will be decoded as a URL"}),Oce=ma(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},expected:"URL",toCodecJson:()=>su()(zV,QR)});var Pce=ma(globalThis.File,{representation:{id:"effect/schema/File",payload:null},expected:"File",toCodecJson:()=>su()(p({data:a.check(FV()),type:a,name:a,lastModified:M}),sm({decode:(e,t)=>Nl(nm(e.data),{onFailure:()=>he(new Hr({expected:"a valid Base64 string"},e.data,t)),onSuccess:(r)=>{let n=new globalThis.Uint8Array(r);return z(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>zs({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:rm(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new Hr({expected:"a readable File"},e,t)})}))});var Rce=ma(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},expected:"URLSearchParams",toCodecJson:()=>su()(a.annotate({expected:"a query string that will be decoded as URLSearchParams"}),am({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});var Nm=a.annotate({expected:"a string that will be decoded as a number"}).pipe(os(yr,Gd));var jV=a.check(LV()),Fr=a.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(os(jV,GR()));var QV=a.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),_ce=ma(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},expected:"Uint8Array",toCodecJson:()=>su()(QV,HR)});var HV=-8640000000000000,VV=8640000000000000,Uce=HV+50400000,Dce=VV-50400000;var JV=globalThis.Symbol.for("immer-draftable"),sb={};function gU(e,t,r,n,o){let i=ZV(r,t,n),s=SU(t),c=class extends e{constructor(...[l,S]){let g=S?.["~payload"],w=g?.token===sb?g.value:r.make(l??{},S);super(w,{...S,disableChecks:!0,"~payload":{token:sb,value:w}})}static[nu]=nu;get[s](){return s}static[JV]=!0;static identifier=t;static fields=r.fields;static get ast(){return i(this).ast}static pipe(){return et(this,arguments)}static rebuild(l){return i(this).rebuild(l)}static make(l,S){return Y_(di(i(this).ast),l??{},S,(m)=>xU(this,m))}static makeOption(l,S){return Mm(i(this))(l??{},S)}static makeEffect(l,S){return i(this).makeEffect(l??{},S)}static annotate(l){return this.rebuild(bm(this.ast,l))}static annotateKey(l){return this.rebuild(Em(this.ast,l))}static check(...l){return this.rebuild(aa(this.ast,l))}static extend(l){return(S,m)=>{let g=mb(S)?S:p(S),w={...r.fields,...g.fields},k=ym(w,r.ast.checks,{identifier:l});return gU(this,l,db(aa(k,g.ast.checks),w),m,o)}}static mapFields(l,S){return r.mapFields(l,S)}};if(o!==void 0)Object.assign(c.prototype,o(t));return c}function xU(e,t){return new e(t,{"~payload":{token:sb,value:t}})}function YV(e){return new ar(Bt((t)=>xU(e,t)),Ro())}function SU(e){return`~effect/Schema/Class/${e}`}function ZV(e,t,r){let n;return(o)=>{if(n!==void 0)return n;let i=SU(t),s=(S)=>S instanceof o||He(S,i),c=YV(o),l=Tt(new Vd([e.ast],()=>(S,m,g)=>s(S)?z(S):he(new ro(m,S,g)),{identifier:t,[Xf]:([S])=>({isConstructed:s,link:new Lr(S,c)}),toCodec:([S])=>new Lr(S.ast,c),toEquivalence:([S])=>S,toFormatter:([S])=>(m)=>`${o.identifier}(${S(m)})`,[Zf]:Hd(e.ast),...r}));return n=os(l,c)(e)}}function mb(e){return AV(e)}var cu=(e)=>(t,r)=>{let n=mb(t)?t:p(t);return gU(Np,e,n,r,(i)=>({name:i}))},so=(e)=>(t,r,n)=>{let o=mb(r)?r.mapFields((i)=>({_tag:is(t),...i}),{unsafePreserveChecks:!0}):DV(t,r);return cu(e??t)(o,n)};var bU=eU;var XV=Tt(N0);var IU="~effect/Terminal",hb="~effect/Terminal/QuitError";class pu extends cu("QuitError")({_tag:is("QuitError")}){[hb]=hb}var wU=(e)=>He(e,hb),ao=Ht("effect/Terminal"),EU=(e)=>ao.of({...e,[IU]:IU});import*as Km from"readline";var kU=Ie(function*(e=vU){let t=yield*Ys(),r=!1,n=!1,o=()=>{if(r=!0,!n)Oo(t)},i,s=()=>{if(i===void 0)if(i=process.stdin,i.readableEnded)o();else i.once("end",o);return i};yield*vc(()=>Be(()=>i?.off("end",o)));let c=yield*Hx({acquire:Dn(Be(()=>{let h=s(),x=Km.createInterface({input:h,escapeCodeTimeout:50}),G=(I)=>Zi(t,I),X=()=>{n=!1,Oo(t)};return n=!0,Km.emitKeypressEvents(h,x),x.on("line",G),x.once("close",X),{rl:x,onClose:X,onLine:G}}),({rl:h,onClose:x,onLine:G})=>Be(()=>{if(n=!1,h.off("line",G),h.off("close",x),h.close(),r)Oo(t)})),idleTimeToLive:"10 millis"}),l=(h)=>Be(()=>{let x=s();if(x.isTTY)x.setRawMode(h)}),S=yield*Hx({acquire:Dn(l(!0),()=>l(!1)),idleTimeToLive:"10 millis"}),m=Be(()=>process.stdout.columns??0),g=Be(()=>process.stdout.rows??0),w=kr(function*(){let h=process.stdout,x=yield*yP(1),G=()=>Zi(x,{columns:h.columns??0,rows:h.rows??0});return yield*vc(()=>Be(()=>{h.off("resize",G),Oo(x)})),h.on("resize",G),G(),x}),k=kr(function*(){let h=s(),x=yield*Ys(),G=(me,pe)=>{let K={input:ec(me),key:{name:pe.name??"",ctrl:!!pe.ctrl,meta:!!pe.meta,shift:!!pe.shift}};if(Zi(x,K),e(K))Oo(x)},X=setInterval(()=>{},2147483647),I=()=>{clearInterval(X),Oo(x)};if(yield*vc(()=>Be(()=>{clearInterval(X),h.off("keypress",G),h.off("end",I)})),h.on("keypress",G),r)I();else yield*Qf(c),yield*Qf(S),h.once("end",I);return x}),A=Ve(()=>SP(t).pipe(Ae($r({onNone:()=>Hs(Zn(Qf(c),ii(t))),onSome:z})),Rr(()=>new pu({}))));return EU({columns:m,rows:g,size:w,readInput:k,readLine:A,display:(h)=>Pf(nn((x)=>{process.stdout.write(h,(G)=>jA(G)?x(Je):x(he(mn({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:G}))))}))})}),AU=Ic(ao,kU(vU));function vU(e){let t=e.key;return t.name==="escape"||t.ctrl&&(t.name==="c"||t.name==="d")}var CU=AU;var r4=$S.pipe(fO(bf(x_,b_,A_,CU)));var n4=ix,OU=(e)=>Xe((t)=>e(t.getRef(n4)));var qm=(...e)=>OU((t)=>vt(()=>{t.error(...e)}));var gr=(...e)=>OU((t)=>vt(()=>{t.log(...e)}));var $m="~effect/ErrorReporter/ignore";var PU="~effect/Runtime/errorExitCode";var uu="~effect/Runtime/errorReported";var dt=a.check(L()),de=pt("WorkspaceId")(dt),fi=pt("WorkspaceInviteId")(dt),ss=pt("UserId")(dt),xb=pt("AuditEventId")(dt),_t=pt("PostId")(dt),cr=pt("TargetId")(dt),zt=pt("AttemptId")(dt),J=pt("AccountId")(dt),xn=pt("MediaId")(dt),bt=pt("ProfileId")(dt),ha=pt("ApiKeyId")(dt),lu=pt("WebhookEndpointId")(dt),Sn=pt("InboxConversationId")(dt),Nn=pt("InboxMessageId")(dt),jc=pt("InboxCommentThreadId")(dt),Qc=pt("InboxCommentId")(dt),Hc=pt("InboxMentionId")(dt),Wm=pt("InboxReviewId")(dt),Sb=pt("InboxAttachmentId")(dt),mi=pt("InboxActionId")(dt),$de=pt("InboundEventId")(dt),Wde=pt("WebhookDeliveryId")(dt),Lo=pt("AdCampaignId")(dt),ya=pt("AdGroupId")(dt),Vc=pt("AdCreativeId")(dt),as=pt("AdId")(dt),RU=pt("AdInsightId")(dt),hi=pt("AdOperationId")(dt),_U=pt("AdBoostId")(dt),UU=pt("AdRequestId")(dt);var DU=(e)=>e,LU=(e)=>e;var bb=Fr.check(be(1),oe(100)),Ib=a.check(be(1),oe(100)).annotate({description:"An IANA time zone such as America/New_York."}),ga=p({id:de,name:bb,defaultTimezone:Ib,role:j(["owner","member"])}),MU=p({workspaces:U(ga)}),FU=p({name:bb,defaultTimezone:u(Ib).annotate({description:"Default IANA time zone for new queues. Defaults to UTC; existing queues keep their own time zone."})}),Qde=p({name:u(bb),defaultTimezone:u(Ib)}).check(Gt(({name:e,defaultTimezone:t})=>e!==void 0||t!==void 0||"Provide a name, a default time zone, or both.")),Hde=p({workspaceId:de}),NU=Fr.check(be(1),oe(100)),wb=p({id:a.check(L()),email:a,displayName:D(NU)}),BU=p({displayName:D(NU)}),KU=p({deactivated:v(!0)}),qU=p({archived:v(!0)});var Bn=a.check(Ge(/^[A-Z]{3}$/)),xt=p({amountMinor:M,currency:Bn}).annotate({identifier:"Money"});var fu=p({estimatedCostMicros:M,estimatedCost:xt,includedRemaining:M,overagePublishes:M,xPublishes:M,blocked:D(p({code:j(["insufficient_credit","spend_cap_reached","billing_inactive"]),nextAction:a}))}).annotate({identifier:"PostBillingEstimate"});var o4=50,$U=100;var WU=a.check(be(1),oe(2048)).annotate({description:"Opaque cursor from a previous list response. Pass nextCursor verbatim."}),It=p({cursor:u(WU),limit:u(Nm.check(au(),Mr({minimum:1,maximum:$U})).annotate({description:`Page size from 1 to ${$U}. Defaults to ${o4}.`}))}).annotate({identifier:"PageQuery"}),ze={hasMore:Y,nextCursor:u(WU)},i4=p({v:v(1),k:a.check(oe(512)),id:a.check(be(1),oe(256))}),rue=kV(i4);var s4=j(["no_targets","schedule_out_of_range","publishing_not_supported","publish_permission_required","duplicate_target","account_not_found","provider_mismatch","account_not_ready","account_unverified","caption_too_long","empty_content","media_required","media_unresolved","media_not_ready","media_count","media_type","media_mime_type","media_too_large","media_upload_required","media_unverified","settings_conflict","tiktok_privacy_unsupported","tiktok_disclosure_required","tiktok_upload_required","tiktok_too_many_mentions","queue_and_time_conflict","invalid_field","account_ambiguous","unsupported_placement","schedule_required","selector_required","selector_conflict"]),co=p({code:s4,path:U(mt([a,M])),message:a}),iue=Qz();var cs=["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"],bn=j(cs),a4=[...cs,"meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],qe=j(a4);var Gm=j(["na","eu","fe"]),pr=j(["social_page","social_account","social_board","social_channel","ad_account"]),c4=j(["auth","permission","access_pending","rate_limit","not_found","deleted","conflict","invalid_request","transient","invalid_response","unsupported"]),cue=p({provider:qe,operation:a,kind:c4,providerStatus:u(M),providerCode:u(a),requestId:u(a),retryable:Y,retryAfterSeconds:u(M),missingScopes:u(U(a)),detail:u(a)}).annotate({identifier:"ProviderError"}),pue=j(["publish","read_insights","engage","ads"]),p4=p({provider:bn});var er=j(cs),Jc=a.check(L()),po=M.check(Pe(1)),d4=128,Vr=a.check(Ge(new RegExp(`^[A-Za-z0-9._~-]{1,${d4}}$`))),gue=p({"idempotency-key":Vr}),xue=p({"idempotency-key":u(Vr)}),GU=86400,Ut=a.check(Ge(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/),Gt((e)=>{let t=new Date(`${e.slice(0,19)}Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,19)===e.slice(0,19)&&Number.isFinite(Date.parse(e))||"Use a valid date and time with Z or an explicit offset"})),xr=j(["feed","reel","story","carousel","video","pin"]),zm=mt([Ut,pU]),u4=p({accountId:J,placement:xr,scheduledAt:u(zm),queueId:u(Jc)}).annotate({identifier:"DestinationSelection"}),Sue=p({expectedRevision:po,scheduledAt:u(Ut),accountIds:u(U(J).check(be(1),oe(50)).annotate({description:"Select every draft placement for these accounts. Use targets for exact selection instead."})),targets:u(U(u4).check(be(1),oe(50)).annotate({description:"Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."}))}),zU=p({postId:_t}),Eb=p({postId:_t,targetId:cr}),bue=p({expectedAttemptId:zt}),Iue=mt([p({expectedAttemptId:zt,action:v("reschedule"),scheduledAt:Ut}),p({expectedAttemptId:zt,action:v("reschedule"),queueId:Jc,pinned:u(p({slotId:Jc,occurrenceDate:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))}))}),p({expectedAttemptId:zt,action:j(["publish_now","cancel"])})]).annotate({identifier:"ScheduleChange"}),l4=u(a),jU={queueId:u(Jc),slotId:u(Jc),assignmentId:u(Jc),occurrenceDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localTime:u(a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/))),timezone:u(a)},QU={targetId:cr,attemptId:zt,accountId:J,scheduledAt:l4,...jU},Yc=j(["scheduled","queued","submitting","confirming","published","provider_draft","failed","unresolved","cancelled"]),jm=mt([v("draft"),Yc]).annotate({identifier:"PostState"}),mu=p({id:a.check(be(1)),kind:a.check(be(1))}).annotate({identifier:"DeliveryProviderRef"}),kb=p({...QU,status:Yc}),f4=p({targetId:cr,attemptId:zt,accountId:J,provider:er,placement:xr,status:Yc,scheduledAt:D(a),url:D(a),issue:D(a),canRetry:Y,canReconcile:Y,...jU}).annotate({identifier:"PublishAcceptedTarget"}),xa=p({postId:_t,idempotencyKey:Vr,targets:U(f4),warnings:U(co),billing:u(fu)}).annotate({identifier:"PublishAccepted"}),hu=j(["authorization_changed","account_not_ready","credential_unavailable","media_preparation_failed","video_compression_failed","audio_unavailable","provider_rejected","tiktok_settings_unavailable","tiktok_settings_not_allowed","tiktok_processing_failed","submission_uncertain","confirmation_unavailable"]),wue=j(["pending","sending","posted","failed","unresolved"]),Eue=j(["pending","updating","updated","failed","unresolved"]),kue=j(["pending","sending","invited","failed","unresolved"]),m4={...QU,revision:po,provider:er,placement:xr},Qm=p({...m4,status:Yc,providerRef:u(mu),url:u(a),issue:u(hu),canRetry:Y,canReconcile:Y,nextAction:u(a)}).annotate({identifier:"DeliveryStatus"}),Ab=p({postId:_t,status:jm,targets:U(Qm)}),Aue=p({settled:Y,post:Ab,retryAfterSeconds:u(M)}).annotate({identifier:"PublishWait"});function HU(e){return e==="draft"||!["scheduled","queued","submitting","confirming"].includes(e)}var h4=p({postId:_t,isDraft:Y,status:jm,textPreview:a,targetCount:M.check(Pe(0)),mediaCount:M.check(Pe(0)),revision:po,createdAt:a,updatedAt:a}).annotate({identifier:"PostSummary"}),VU=p({data:U(h4),...ze}).annotate({identifier:"PostList"}),y4=p({delivery:Qm,createdAt:a,updatedAt:a,replacesAttemptId:u(zt)}).annotate({identifier:"DeliveryAttemptSummary"}),JU=p({currentAttemptId:zt,data:U(y4),...ze}).annotate({identifier:"DeliveryHistory"});var Zc=j(["payg","pro","platform","enterprise"]),Hm=j(["month","year"]),Vm=j(["fake","stripe"]),yu=j(["active","trialing","past_due","canceled","incomplete","unpaid"]),Jm=j(["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]),g4=p({meter:Jm,includedPerPeriod:M,overageUnitPriceMicros:D(M),unitLabel:a}).annotate({identifier:"BillingPlanMeter"}),x4=p({id:Zc,name:a,monthlyPrice:D(xt),annualPrice:D(xt),meters:U(g4),seatsLimit:D(M),analyticsRetentionDays:M,whiteLabelOAuth:Y,ssoSaml:Y}).annotate({identifier:"BillingPlan"}),YU=p({data:U(x4)}).annotate({identifier:"BillingPlanList"}),S4=p({meter:Jm,includedPerPeriod:M,used:M,billable:M,costMicros:M}).annotate({identifier:"BillingMeterUsage"}),b4=p({monthlySpendCapMicros:D(M),version:M}).annotate({identifier:"BillingSpendControls"}),I4=j(["ok","payment_required","insufficient_credit","spend_cap_reached"]),Cb=p({workspaceId:de,plan:Zc,status:yu,paymentStatus:I4,interval:D(Hm),gateway:Vm,periodStart:a,periodEnd:a,cancelAtPeriodEnd:Y,creditBalanceMicros:M,creditBalance:xt,spendControls:b4,currentPeriod:p({meters:U(S4),totalVariableSpendMicros:M,seatsUsed:M,seatsLimit:D(M)})}).annotate({identifier:"WorkspaceBilling"}),Sa=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),vb=a.check(Ge(/^https?:\/\/[^\s]+$/)),_ue=p({from:u(Sa),to:u(Sa),meter:u(Jm),provider:u(er)}).annotate({identifier:"BillingUsageQuery"}),w4=p({date:Sa,meter:Jm,provider:D(er),quantity:M,billableQuantity:M,costMicros:M}).annotate({identifier:"BillingUsageDailyPoint"}),ZU=p({from:Sa,to:Sa,totals:p({quantity:M,billableQuantity:M,costMicros:M}),data:U(w4)}).annotate({identifier:"BillingUsage"}),Ym=j(["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]),Uue=p({kind:u(Ym),from:u(Sa),to:u(Sa),...It.fields}).annotate({identifier:"BillingLedgerQuery"}),E4=p({id:a.check(L()),kind:Ym,deltaMicros:M,balanceAfterMicros:M,description:a,referenceKind:D(a),referenceId:D(a),createdAt:a}).annotate({identifier:"BillingLedgerEntry"}),XU=p({data:U(E4),...ze}).annotate({identifier:"BillingLedgerList"}),Due=mt([p({mode:v("subscription"),plan:j(["pro","platform"]),interval:Hm,returnUrl:u(vb)}),p({mode:v("top_up"),amountMinor:M.check(Pe(1000),mU(1e7)),returnUrl:u(vb)})]).annotate({identifier:"CreateBillingCheckout"}),eD=p({url:a,expiresAt:u(a)}).annotate({identifier:"BillingCheckoutSession"}),Lue=p({returnUrl:u(vb)}).annotate({identifier:"CreateBillingPortal"}),tD=p({url:a}).annotate({identifier:"BillingPortalSession"}),Mue=p({version:M,monthlySpendCapMicros:D(M)}).annotate({identifier:"UpdateBillingSpendControls"});var rD=180,nD=365,sD=["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"],Tb=j(sD).annotate({identifier:"AuditAction"}),aD=["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"],Zm=j(aD).annotate({identifier:"AuditTargetKind"}),k4=j(["user","api_key"]).annotate({identifier:"AuditActorType"}),A4=mt([p({type:v("user"),id:ss,email:D(a),displayName:D(a)}),p({type:v("api_key"),id:ha,name:D(a),prefix:D(a)})]).annotate({identifier:"AuditActor"}),Ob=p({id:xb,workspaceId:de,profileId:D(bt),actor:A4,action:Tb,targetKind:Zm,targetId:a.check(L()),detail:Wt(a,H),createdAt:a}).annotate({identifier:"AuditEvent"}),cD=p({data:U(Ob),...ze}).annotate({identifier:"AuditEventList"}),Wue=p({workspaceId:de,eventId:xb}),oD=mt([Ut,a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))]),Gue=p({action:u(Tb),targetKind:u(Zm),targetId:u(a.check(L())),actorType:u(k4),actorId:u(a.check(L())),profileId:u(bt),from:u(oD).annotate({description:"Inclusive start instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),to:u(oD).annotate({description:"Inclusive end instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),...It.fields}),v4=p({action:Tb,targetKind:Zm,description:a,retentionDays:M}).annotate({identifier:"AuditActionCatalogEntry"}),pD=p({actions:U(v4),targetKinds:U(Zm),retention:p({standardDays:M,spendDays:M})}).annotate({identifier:"AuditActionCatalog"}),iD={"workspace.updated":{targetKind:"workspace",description:"Workspace name or default timezone updated."},"workspace.archived":{targetKind:"workspace",description:"Workspace archived by an owner."},"workspace.member.role_updated":{targetKind:"workspace_member",description:"Workspace member role changed between owner and member."},"workspace.member.removed":{targetKind:"workspace_member",description:"Workspace member removed or left the workspace."},"workspace.invite.created":{targetKind:"workspace_invite",description:"Workspace member invitation created."},"workspace.invite.resent":{targetKind:"workspace_invite",description:"Workspace member invitation token rotated and resent."},"workspace.invite.revoked":{targetKind:"workspace_invite",description:"Pending workspace invitation revoked."},"workspace.invite.accepted":{targetKind:"workspace_invite",description:"Workspace invitation accepted by the invited user."},"workspace.invite.declined":{targetKind:"workspace_invite",description:"A workspace invitation was declined."},"api_key.created":{targetKind:"api_key",description:"Workspace API key created (redacted prefix only)."},"api_key.updated":{targetKind:"api_key",description:"Workspace API key name or scopes updated."},"api_key.revoked":{targetKind:"api_key",description:"Workspace API key revoked."},"webhook.endpoint.created":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint registered."},"webhook.endpoint.updated":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint configuration updated."},"webhook.endpoint.deleted":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint permanently disabled."},"webhook.delivery.replayed":{targetKind:"webhook_delivery",description:"Settled webhook delivery queued for replay."},"account.connected":{targetKind:"provider_account",description:"Social or ad account connected via OAuth."},"account.reconnected":{targetKind:"provider_account",description:"Existing account grant reconnected via OAuth."},"account.disconnected":{targetKind:"integration_connection",description:"Provider connection disconnected and credentials cleared."},"account.enabled":{targetKind:"provider_account",description:"Connected publishing destination enabled."},"account.disabled":{targetKind:"provider_account",description:"Connected publishing destination disabled."},"account.moved":{targetKind:"provider_account",description:"Connected account moved to another workspace profile."},"profile.created":{targetKind:"workspace_profile",description:"Workspace brand profile created."},"profile.updated":{targetKind:"workspace_profile",description:"Workspace brand profile updated."},"profile.archived":{targetKind:"workspace_profile",description:"Workspace brand profile archived."},"queue.created":{targetKind:"schedule_queue",description:"Account schedule queue created."},"queue.updated":{targetKind:"schedule_queue",description:"Account schedule queue configuration updated."},"queue.paused":{targetKind:"schedule_queue",description:"Account schedule queue paused."},"queue.resumed":{targetKind:"schedule_queue",description:"Account schedule queue resumed."},"queue.archived":{targetKind:"schedule_queue",description:"Account schedule queue archived."},"queue.slots.replaced":{targetKind:"schedule_queue",description:"Weekly schedule queue slots replaced."},"queue.skip.created":{targetKind:"schedule_queue_skip",description:"Single queue slot occurrence skipped."},"queue.skip.deleted":{targetKind:"schedule_queue_skip",description:"Skipped queue slot occurrence restored."},"queue.blackout.created":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range created."},"queue.blackout.deleted":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range removed."},"billing.subscription.updated":{targetKind:"workspace_billing",description:"Workspace billing plan or subscription status updated."},"billing.credit.topped_up":{targetKind:"workspace_billing",description:"Workspace prepaid credit balance topped up."},"billing.spend_controls.updated":{targetKind:"workspace_billing",description:"Workspace monthly spend cap or auto-top-up controls updated."}},zue={actions:sD.map((e)=>({action:e,targetKind:iD[e].targetKind,description:iD[e].description,retentionDays:e.startsWith("billing.")||e.startsWith("ads.")?nD:rD})),targetKinds:[...aD],retention:{standardDays:rD,spendDays:nD}};var Pb=p({workspaceId:de,deliveryFailures:Y,connectionExpiring:Y,webhookFailures:Y,billingAlerts:Y,weeklyDigest:Y,updatedAt:D(a)}).annotate({identifier:"NotificationPreferences"}),Vue=p({deliveryFailures:u(Y),connectionExpiring:u(Y),webhookFailures:u(Y),billingAlerts:u(Y),weeklyDigest:u(Y)}).check(Gt((e)=>Object.values(e).some((t)=>t!==void 0)||"Provide at least one notification preference to update.")).annotate({identifier:"UpdateNotificationPreferences"});var Xc=j(["owner","member"]).annotate({identifier:"WorkspaceRole"}),C4=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,T4=Fr.pipe(os(a.check(be(3),oe(320),Ge(C4)),dj())).annotate({identifier:"NormalizedEmail",description:"Email address, trimmed and lowercased."}),Xm=p({workspaceId:de,userId:ss,email:a,displayName:D(a),role:Xc,joinedAt:a}).annotate({identifier:"WorkspaceMember"}),dD=p({data:U(Xm),...ze}).annotate({identifier:"WorkspaceMemberList"}),tle=p({role:u(Xc),...It.fields}),rle=p({workspaceId:de,userId:ss}),nle=p({role:Xc}).annotate({identifier:"UpdateWorkspaceMemberRole"}),uD=p({removed:v(!0)}).annotate({identifier:"WorkspaceMemberRemoved"}),lD=j(["pending","accepted","revoked","expired"]).annotate({identifier:"WorkspaceInviteStatus"}),Rb=p({id:fi,workspaceId:de,email:a,role:Xc,status:lD,deliveryState:j(["queued","sending","uncertain","sent"]),remoteRevocationPending:Y,invitedByUserId:ss,invitedByEmail:D(a),expiresAt:a,acceptedAt:D(a),revokedAt:D(a),createdAt:a}).annotate({identifier:"WorkspaceInvite"}),fD=p({data:U(Rb),...ze}).annotate({identifier:"WorkspaceInviteList"}),ole=p({status:u(lD),...It.fields}),ile=p({workspaceId:de,inviteId:fi}),sle=p({email:T4,role:u(Xc)}).annotate({identifier:"CreateWorkspaceInvite"}),mD=p({invite:Rb}).annotate({identifier:"WorkspaceInviteCreated"}),hD=p({invite:Rb,resendState:j(["sending","sent","uncertain"])}).annotate({identifier:"WorkspaceInviteResent"}),yD=p({revoked:v(!0),remoteRevocationPending:Y}).annotate({identifier:"WorkspaceInviteRevoked"}),O4=p({id:fi,workspaceId:de,workspaceName:a,role:Xc,invitedByEmail:D(a),invitedByName:D(a),expiresAt:a,createdAt:a}).annotate({identifier:"PendingUserInvite"}),gD=p({data:U(O4)}).annotate({identifier:"PendingUserInviteList"}),ale=mt([p({token:Fr.check(be(1),oe(256))}),p({inviteId:fi})]).annotate({identifier:"AcceptWorkspaceInvite"}),xD=p({workspace:ga,membership:Xm}).annotate({identifier:"WorkspaceInviteAccepted"}),SD=p({declined:v(!0),remoteRevocationPending:Y}).annotate({identifier:"WorkspaceInviteDeclined"}),cle=p({inviteId:fi});var P4="pubnio_sk_",_b=new RegExp(`^${P4}[A-Za-z0-9_-]{43}$`),gu=j(["read","publish","engage","ads_read","ads_manage"]),Ub=U(gu).check(be(1),oe(gu.literals.length),Gt((e)=>new Set(e).size===e.length||"Choose each scope once.")),Db=Fr.check(be(1),oe(100)),xu=p({id:ha,workspaceId:de,name:Db,prefix:a,scopes:Ub,createdAt:a,updatedAt:a,expiresAt:D(a),revokedAt:D(a)}).annotate({identifier:"ApiKey"}),mle=p({name:Db,scopes:u(Ub).annotate({description:"Defaults to read. publish permits delivery writes; engage permits inbox replies; ads_read and ads_manage permit ad operations. ads_spend requires a signed-in owner."}),expiresAt:u(Ut)}),hle=p({name:u(Db),scopes:u(Ub)}).check(Gt(({name:e,scopes:t})=>e!==void 0||t!==void 0||"Provide a name or scopes."));var yle=gu.literals;var gle=p({workspaceId:de,keyId:ha}),bD=p({key:xu,secret:a.check(Ge(_b)).annotate({description:"Copy this secret now. This is the only response that returns it."})}),ID=p({data:U(xu),...ze}).annotate({identifier:"ApiKeyList"}),wD=p({revoked:v(!0)});var eh=26214400,th=268435456,rh=16777216,R4=8388608;var ba=a.check(oe(2048),Ge(/^https:\/\//i),Gt((e)=>{let t=URL.parse(e);return Boolean(t?.hostname&&t.protocol==="https:"&&!t.username&&!t.password)||"Expected an HTTPS media URL without credentials"})),ED=p({mediaId:xn}),_4=p({url:ba}),U4=mt([ED,_4]).annotate({identifier:"MediaInput"}),Lb=35,ps=U(U4).check(oe(Lb)),Su=j(["image","video","document"]),ep=j(["image/jpeg","image/png","image/gif","image/webp","video/mp4","video/quicktime","video/webm","application/pdf"]);function D4(e,t){let r=(n)=>n.every((o,i)=>e[i]===o);switch(t){case"image/jpeg":return r([255,216,255]);case"image/png":return r([137,80,78,71,13,10,26,10]);case"image/webp":{let n=new TextDecoder().decode(e.subarray(0,12));return n.startsWith("RIFF")&&n.endsWith("WEBP")}case"video/webm":{if(!r([26,69,223,163]))return!1;let n=[66,130,132,119,101,98,109];return e.some((o,i)=>n.every((s,c)=>e[i+c]===s))}case"image/gif":{let n=new TextDecoder().decode(e.subarray(0,6));return n==="GIF87a"||n==="GIF89a"}case"video/mp4":case"video/quicktime":{if(e.length<16)return!1;let n=new TextDecoder().decode(e.subarray(4,12));return n.startsWith("ftyp")&&(t==="video/quicktime"?n==="ftypqt ":n!=="ftypqt ")}case"application/pdf":return r([37,80,68,70,45])}}function kD(e){return ep.literals.find((t)=>D4(e,t))}var kle=p({workspaceId:de,mimeType:ep}),Mb=p({mediaId:xn,type:Su,mimeType:ep,sizeBytes:M.check(Mr({minimum:1,maximum:th})),createdAt:a}).annotate({identifier:"MediaAsset"}),AD=p({data:U(Mb),...ze}).annotate({identifier:"MediaList"}),vD=p({deleted:v(!0)}),Ale=p({url:a.check(be(1),oe(8192))}).annotate({identifier:"MediaImport"}),vle=p({sizeBytes:M.check(Pe(1))}).annotate({identifier:"MediaUploadStart"}),CD=Mr({minimum:1,maximum:Math.ceil(th/rh)}),L4=M.check(CD),Cle=p({...ED.fields,partNumber:Nm.check(au(),CD)}),TD=p({mediaId:xn,partSizeBytes:v(rh),expiresAt:a}).annotate({identifier:"MediaUploadSession"}),OD=p({partNumber:L4}).annotate({identifier:"MediaPartReceipt"}),PD=p({code:j(["media_source_unavailable","media_storage_unavailable","media_too_large","unsupported_media","upload_expired"]),maxBytes:u(M)}).annotate({identifier:"MediaIntakeIssue"}),M4=j(["awaiting_upload","processing","ready","failed"]),F4=p({receivedPartCount:M.check(Pe(0)),partDigests:U(a.check(Ge(/^[A-Za-z0-9_-]{43}$/))),expiresAt:a}).annotate({identifier:"MediaUploadProgress"}),Ia=p({mediaId:xn,status:M4,asset:u(Mb),issue:u(PD),upload:u(F4),idempotencyKey:u(Vr),retryAfterSeconds:u(M)}).annotate({identifier:"MediaIntake"}),Tle=p({mediaId:xn,status:j(["ready","failed","timeout"]),asset:u(Mb),issue:u(PD),retryAfterSeconds:u(M)}).annotate({identifier:"MediaWait"}),Ole=p({data:a.check(be(1),oe(Math.ceil(R4/3)*4+4)).annotate({description:"Base64-encoded file bytes. Maximum 8 MiB after decoding."}),mimeType:ep,filename:u(a.check(be(1),oe(255)))}).annotate({identifier:"MediaInlineUpload"}),RD=j(["part_conflict","part_out_of_order","parts_missing","upload_closed","upload_expired"]);var Fb=["live","beta","upcoming"];var N4=["publish","read_insights","manage_comments"],nh=[...N4,"send_messages"],In={bluesky:{label:"Bluesky",availability:"beta",authFamily:"bluesky",accountKinds:["social_account"],capabilities:{social_account:nh},approvalRequired:{},limited:{}},facebook:{label:"Facebook",availability:"live",authFamily:"facebook",accountKinds:["social_page"],capabilities:{social_page:nh},approvalRequired:{},limited:{}},instagram:{label:"Instagram",availability:"live",authFamily:"instagram",accountKinds:["social_account"],capabilities:{social_account:nh},approvalRequired:{},limited:{}},linkedin:{label:"LinkedIn",availability:"live",authFamily:"linkedin",accountKinds:["social_account","social_page"],capabilities:{social_account:["publish","manage_comments"],social_page:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},pinterest:{label:"Pinterest",availability:"live",authFamily:"pinterest",accountKinds:["social_board"],capabilities:{social_board:["publish","read_insights"]},approvalRequired:{},limited:{}},reddit:{label:"Reddit",availability:"upcoming",authFamily:"reddit",accountKinds:["social_account"],capabilities:{social_account:nh},approvalRequired:{},limited:{}},snapchat:{label:"Snapchat",availability:"beta",authFamily:"snapchat",accountKinds:["social_page"],capabilities:{social_page:["publish"]},approvalRequired:{},limited:{}},tiktok:{label:"TikTok",availability:"live",authFamily:"tiktok",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights"]},approvalRequired:{},limited:{}},threads:{label:"Threads",availability:"upcoming",authFamily:"threads",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},x:{label:"X",availability:"live",authFamily:"x",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments","send_messages"]},approvalRequired:{},limited:{}},youtube:{label:"YouTube",availability:"live",authFamily:"youtube",accountKinds:["social_channel"],capabilities:{social_channel:["publish","read_insights"]},approvalRequired:{},limited:{}},google_business:{label:"Google Business Profile",availability:"upcoming",authFamily:"google_business",accountKinds:["social_page"],capabilities:{social_page:["publish","read_insights"]},approvalRequired:{},limited:{}}};var _le={bluesky:{...In.bluesky,publishCapable:!0},facebook:{...In.facebook,publishCapable:!0},instagram:{...In.instagram,publishCapable:!0},linkedin:{...In.linkedin,publishCapable:!0},pinterest:{...In.pinterest,publishCapable:!0},reddit:{...In.reddit,publishCapable:!0},snapchat:{...In.snapchat,publishCapable:!0},tiktok:{...In.tiktok,publishCapable:!0},threads:{...In.threads,publishCapable:!0},x:{...In.x,publishCapable:!0},youtube:{...In.youtube,publishCapable:!0},google_business:{...In.google_business,publishCapable:!0},meta_ads:{label:"Meta Ads",availability:"live",authFamily:"meta_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},google_ads:{label:"Google Ads",availability:"live",authFamily:"google_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},reddit_ads:{label:"Reddit Ads",availability:"live",authFamily:"reddit_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},pinterest_ads:{label:"Pinterest Ads",availability:"live",authFamily:"pinterest_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},tiktok_ads:{label:"TikTok Ads",availability:"live",authFamily:"tiktok_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},linkedin_ads:{label:"LinkedIn Ads",availability:"live",authFamily:"linkedin_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},snapchat_ads:{label:"Snapchat Ads",availability:"live",authFamily:"snapchat_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},amazon_ads:{label:"Amazon Ads",availability:"live",authFamily:"amazon_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},openai_ads:{label:"OpenAI Ads",availability:"beta",authFamily:"openai_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"}},Ule=cs.flatMap((e)=>{let t=In[e];return t.accountKinds.map((r)=>({provider:e,availability:t.availability,accountKind:r,capabilities:[...t.capabilities[r]??[]],approvalRequired:[...t.approvalRequired[r]??[]],limited:[...t.limited[r]??[]]}))});var B4=60,K4=3600;var q4={requestsPerMinute:300,publishesPerMinute:30,mediaUploadsPerMinute:10,windowSeconds:60},gi=mt([p({status:j(["ready","disabled","unavailable"])}),p({status:v("needs_reconnect"),reason:j(["disconnected","token_expired"])}),p({status:v("unverified"),reason:j(["scopes_unknown","page_tasks_unknown"])}),p({status:v("permission_required"),reason:v("missing_scope"),missingScopes:U(a)}),p({status:v("permission_required"),reason:v("missing_page_task")})]).annotate({identifier:"AccountReadiness"}),yi=j(["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]),$4=j(["supported","not_supported","access_pending","permission_missing","unverified","reconnect_required","unavailable"]),qle=p({scopes:u(U(a)),pageTasks:u(U(a)),roles:u(U(a)),loginMethods:u(U(a))}),xi=p({capability:yi,state:$4,missingScopes:U(a),missingRoles:U(a),reason:u(a)}).annotate({identifier:"AccountCapability"}),W4=p({accountId:J,profileId:bt,provider:qe,accountKind:pr,enabled:Y,publishingReadiness:gi,capabilities:U(xi),checkedAt:a}).annotate({identifier:"AccountCapabilities"}),_D=p({capabilities:U(W4)}),$le=p({workspaceId:de,profileId:u(bt),accountId:u(J),capability:u(yi)}),G4=p({provider:qe,availability:j(Fb),accountKind:pr,capabilities:U(yi),approvalRequired:U(yi),limited:U(yi)}).annotate({identifier:"CapabilityCatalogEntry"}),UD=p({entries:U(G4)}).annotate({identifier:"CapabilityCatalog"}),z4=p({accountId:J,provider:qe,accountKind:pr,name:a,enabled:Y,readiness:gi}).annotate({identifier:"AccountSummary"}),Wle=p({accounts:U(z4)}).annotate({identifier:"AccountSummaryList"}),j4=p({requestsPerMinute:M,publishesPerMinute:M,mediaUploadsPerMinute:M,windowSeconds:M}).annotate({identifier:"RateLimits"}),DD=p({uploadMaxBytes:M,assetMaxBytes:M,partMaxBytes:M,types:U(Su)}).annotate({identifier:"MediaLimits"}),Nb=p({targetsPerRequest:M,draftTextCharacters:M,idempotencyTtlSeconds:M,wait:p({defaultSeconds:M,maxSeconds:M}),media:DD,rateLimits:j4}).annotate({identifier:"ApiLimits"}),Q4=p({placement:xr,default:Y,mediaTypes:U(Su),maxMedia:M,captionCharacters:M}).annotate({identifier:"PlacementCapability"}),H4=p({provider:bn,label:a,availability:j(Fb),accountKinds:U(pr),placements:U(Q4),requiredScopes:U(a)}).annotate({identifier:"ProviderCapability"}),LD=p({providers:U(H4),accountKinds:U(pr),media:DD,limits:Nb}).annotate({identifier:"PublishCapabilities"}),Gle={targetsPerRequest:50,draftTextCharacters:128000,idempotencyTtlSeconds:GU,wait:{defaultSeconds:B4,maxSeconds:K4},media:{uploadMaxBytes:eh,assetMaxBytes:th,partMaxBytes:rh,types:[...Su.literals]},rateLimits:q4};var oh=j(["instagram_login","facebook_login","unified_login"]),MD=u(oh),V4=mt([p({provider:v("bluesky"),kind:v("account"),handle:a,did:a,service:a}),p({provider:v("facebook"),kind:v("page"),tasks:u(U(a))}),p({provider:v("instagram"),kind:v("professional_account"),username:a,loginMethod:MD,accountType:u(j(["business","creator"])),pageId:u(a),clientBusinessId:u(a),configId:u(a)}),p({provider:v("linkedin"),kind:v("member")}),p({provider:v("linkedin"),kind:v("organization")}),p({provider:v("pinterest"),kind:v("board"),username:u(a)}),p({provider:v("reddit"),kind:v("account"),username:a}),p({provider:v("snapchat"),kind:v("public_profile"),profileId:a,organizationId:u(a),username:u(a)}),p({provider:v("tiktok"),kind:v("account"),username:u(a),isBusiness:u(Y)}),p({provider:v("threads"),kind:v("account"),username:u(a)}),p({provider:v("x"),kind:v("account"),username:u(a)}),p({provider:v("youtube"),kind:v("channel")}),p({provider:v("google_business"),kind:v("location")}),p({provider:v("meta_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("google_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),managerId:u(a),loginCustomerId:u(a)}),p({provider:v("reddit_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("pinterest_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("tiktok_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("linkedin_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("snapchat_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("amazon_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),region:Gm,businessId:u(a),managerId:u(a)}),p({provider:v("openai_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"])})]);var tp=p({id:J,profileId:bt,connectionId:a.check(L()),provider:qe,accountKind:pr,parentAccountId:D(J),name:a,enabled:Y,available:Y,details:V4,readiness:gi,capabilities:U(xi)}).annotate({identifier:"ProviderAccount"}),Bb=p({accounts:U(tp)}),J4=p({id:J,enabled:Y});var ih=a.check(L()),qb=p({attemptId:ih}),bu=p({accountId:J}),FD=p({connectionId:ih}),$b=p({attemptId:ih,url:a,expiresAt:u(a)}),Y4=j(["provider_error","invalid_callback","account_mismatch","connection_changed","connection_failed"]),Kb={attemptId:ih,provider:qe},ND=mt([p({...Kb,status:j(["pending","denied","expired"])}),p({...Kb,status:v("connected"),accountIds:U(J)}),p({...Kb,status:v("failed"),reason:Y4})]).annotate({identifier:"ConnectionStatus"}),BD=p({disconnected:v(!0)}),Z4=p({handle:Fr.check(be(1),oe(253)),appPassword:Fr.check(be(1),oe(256)),service:u(a.check(oe(2048),Ge(/^https:\/\//i)))}).annotate({identifier:"BlueskyConnect"}),efe=p({...Z4.fields,accountId:u(J),profileId:u(bt)}).annotate({identifier:"BlueskySessionConnect"}),KD=p({used:M.check(Pe(0)),limit:M.check(Do(0)),windowSeconds:M.check(Do(0))}).annotate({identifier:"InstagramPublishingLimit"}),sh=j(["music","original_sound"]),rp=a.check(Ge(/^\d{1,32}$/)),tfe=p({...bu.fields,audioId:rp}),rfe=p({audioType:sh,q:u(Fr.check(be(1),oe(200)))}),Wb=p({audioId:rp,audioType:sh,title:a,durationMs:u(M.check(Pe(0))),artist:u(a),creator:u(a),previewUrl:u(a),coverUrl:u(a),instagramPreviewUrl:u(a)}).annotate({identifier:"InstagramAudio"}),qD=p({audio:U(Wb)});var zb=128000;var Qb=1250,X4=300;var $D=500,eJ=100,tJ=1e5,Gb=50,rJ=100;var ds=a.check(oe(zb)),GD=M.check(Pe(1)),gfe=p({workspaceId:de,isDraft:u(Y).annotate({description:"Filter to drafts (true) or submitted posts (false)."}),accountId:u(J).annotate({description:"Filter to posts targeting this connected account (applies to both drafts and submitted posts; pairs with deliveryStatus on the same target)."}),profileId:u(bt).annotate({description:"Filter to posts targeting any account in this workspace profile."}),...It.fields}),nJ=Lb,Cr={text:u(ds),media:u(ps),scheduledAt:u(zm),queueId:u(a.check(L()).annotate({description:"Assign this destination to its connected account's schedule queue."}))},Iu=a.check(Ge(/^\d+$/)),oJ=U(a.check(Ge(/^[A-Z]{2}$/))).check(be(1),oe(25)),zD={firstComment:u(ds),thread:u(U(a.check(be(1),oe(Qb))).check(oe(24))),nativeDraft:u(Y),countries:u(oJ)},jD=p({...zD,link:u(ba),textFormatPresetId:u(Iu),albumId:u(Iu)}).annotate({identifier:"FacebookFeedSettings"}),QD=p({...zD,title:u(ds),isAiGenerated:u(Y),collaboratorPageIds:u(U(Iu).check(be(1),oe(10),Gt((e)=>new Set(e).size===e.length||"Choose each collaborator Page once")))}).annotate({identifier:"FacebookReelSettings"}),HD=p({isAiGenerated:u(Y)}).annotate({identifier:"FacebookStorySettings"}),jb=a.check(Ge(/^@?[a-zA-Z0-9._]{1,30}$/)),WD=yr.check(Mr({minimum:0,maximum:1})),iJ=p({username:jb,x:u(WD),y:u(WD)}),VD={isAiGenerated:u(Y)},Hb={...VD,firstComment:u(ds),commentsEnabled:u(Y),collaborators:u(U(jb).check(oe(3))),locationId:u(Iu),isPaidPartnership:u(Y),brandedContentSponsors:u(U(mt([Iu,jb])).check(be(1),oe(2)))},ah=u(U(iJ).check(oe(20))),JD=u(a.check(oe(1000))),YD=p({...Hb,altText:JD,userTags:ah}).annotate({identifier:"InstagramFeedSettings"}),ZD=p({...Hb,shareToFeed:u(Y),muteAudio:u(Y),audioConfiguration:u(p({audioId:rp,audioVolume:u(M.check(Mr({minimum:1,maximum:100}))),videoVolume:u(M.check(Mr({minimum:0,maximum:100})))})),coverUrl:u(ba),thumbOffset:u(M.check(Pe(0))),audioName:u(a.check(oe(255))),trial:u(p({graduationStrategy:j(["MANUAL","SS_PERFORMANCE"])})),userTags:ah}).annotate({identifier:"InstagramReelSettings"}),XD=p({...Hb,muteAudio:u(Y),slides:u(U(p({altText:JD,userTags:ah})).check(oe(20)))}).annotate({identifier:"InstagramCarouselSettings"}),eL=p({...VD,muteAudio:u(Y),userTags:ah}).annotate({identifier:"InstagramStorySettings"}),tL=p({firstComment:u(a.check(be(1),oe(300))),thread:u(U(a.check(be(1),oe(300))).check(oe(24))),altText:u(a.check(oe(1000)))}).annotate({identifier:"BlueskyFeedSettings"}),rL=p({firstComment:u(ds),thread:u(U(a.check(be(1),oe(Qb))).check(oe(24))),visibility:u(j(["PUBLIC","CONNECTIONS"])),altText:u(a.check(oe(4086))),documentTitle:u(Fr.check(be(1),oe(rJ)))}).annotate({identifier:"LinkedInFeedSettings"}),nL=p({title:u(a.check(be(1),oe(100))),description:u(a.check(be(1),oe(800))),link:u(ba),altText:u(a.check(oe(500)))}).annotate({identifier:"PinterestPinSettings"}),sJ=a.check(Ge(/^(?:r\/)?[A-Za-z0-9_]{2,21}$/)),oL=p({subreddit:sJ,title:a.check(be(1),oe(X4)),link:u(ba),flairId:u(a.check(be(1),oe(100))),flairText:u(a.check(be(1),oe(64))),nsfw:u(Y),spoiler:u(Y),sendReplies:u(Y),thumbnailMediaId:u(xn),firstComment:u(ds)}).annotate({identifier:"RedditFeedSettings"}),iL=p({contentType:u(j(["story","saved_story","spotlight"])),title:u(a.check(be(1),oe(45))),description:u(a.check(be(1),oe(160))),link:u(ba),locale:u(a.check(Ge(/^[a-z]{2}_[A-Z]{2}$/)))}).annotate({identifier:"SnapchatStorySettings"}),sL=p({title:a.check(be(1),oe(100)),description:u(a.check(oe(5000))),privacyStatus:j(["public","unlisted","private"]),tags:u(U(a.check(oe(100))).check(oe(30))),categoryId:u(a.check(Ge(/^\d{1,3}$/))),madeForKids:u(Y),containsSyntheticMedia:u(Y),thumbnailMediaId:u(xn),notifySubscribers:u(Y),license:u(j(["youtube","creativeCommon"])),embeddable:u(Y),publicStatsViewable:u(Y)}).annotate({identifier:"YouTubeVideoSettings"}),aJ=p({title:a.check(be(1),oe(eJ)),content:a.check(be(1),oe(tJ))}).annotate({identifier:"XArticleDraftSettings"}),aL=p({firstComment:u(ds),thread:u(U(a.check(be(1),oe(280))).check(oe(24))),article:u(aJ)}).annotate({identifier:"XFeedSettings"}),cL=p({}).annotate({identifier:"GoogleBusinessFeedSettings"}),pL=p({firstComment:u(a.check(be(1),oe($D))),thread:u(U(a.check(be(1),oe($D))).check(oe(24)))}).annotate({identifier:"ThreadsFeedSettings"}),dL={privacy:j(["PUBLIC_TO_EVERYONE","MUTUAL_FOLLOW_FRIENDS","FOLLOWER_OF_CREATOR","SELF_ONLY"]),commercialDisclosure:u(j(["none","own_brand","paid_partnership"])),isAiGenerated:u(Y),disableComment:u(Y),nativeDraft:u(Y)},cJ=p({...dL,format:u(v("video")),disableDuet:u(Y),disableStitch:u(Y)}).annotate({identifier:"TikTokVideoSettings"}),pJ=p({...dL,format:v("photo"),title:u(a.check(oe(90))),coverIndex:u(M.check(Mr({minimum:0,maximum:nJ-1}))),autoAddMusic:u(Y)}).annotate({identifier:"TikTokPhotoSettings"}),uL=mt([cJ,pJ]).annotate({identifier:"TikTokFeedSettings"}),lL=mt([p({accountId:J,provider:v("bluesky"),placement:v("feed"),...Cr,settings:u(tL)}),p({accountId:J,provider:v("facebook"),placement:v("feed"),...Cr,settings:u(jD)}),p({accountId:J,provider:v("facebook"),placement:v("reel"),...Cr,settings:u(QD)}),p({accountId:J,provider:v("facebook"),placement:v("story"),...Cr,settings:u(HD)}),p({accountId:J,provider:v("instagram"),placement:v("feed"),...Cr,settings:u(YD)}),p({accountId:J,provider:v("instagram"),placement:v("reel"),...Cr,settings:u(ZD)}),p({accountId:J,provider:v("instagram"),placement:v("carousel"),...Cr,settings:u(XD)}),p({accountId:J,provider:v("instagram"),placement:v("story"),...Cr,settings:u(eL)}),p({accountId:J,provider:v("linkedin"),placement:v("feed"),...Cr,settings:u(rL)}),p({accountId:J,provider:v("threads"),placement:v("feed"),...Cr,settings:u(pL)}),p({accountId:J,provider:v("x"),placement:v("feed"),...Cr,settings:u(aL)}),p({accountId:J,provider:v("youtube"),placement:v("video"),...Cr,settings:sL}),p({accountId:J,provider:v("pinterest"),placement:v("pin"),...Cr,settings:u(nL)}),p({accountId:J,provider:v("reddit"),placement:v("feed"),...Cr,settings:oL}),p({accountId:J,provider:v("snapchat"),placement:v("story"),...Cr,settings:u(iL)}),p({accountId:J,provider:v("tiktok"),placement:v("feed"),...Cr,settings:u(uL)}),p({accountId:J,provider:v("google_business"),placement:v("feed"),...Cr,settings:u(cL)})]).annotate({identifier:"PublishTarget"}),xfe=rs(lL,{onExcessProperty:"error"}),dJ=a.check(be(1),oe(Qb)),uJ=U(dJ).check(be(1),oe(24)),lJ=mt([tL,jD,QD,HD,YD,ZD,XD,eL,rL,oL,iL,pL,aL,sL,nL,uL,cL]),fJ=p({accountId:J,provider:u(bn),placement:u(xr),text:u(ds),thread:u(uJ),media:u(ps),scheduledAt:u(zm),queueId:u(a.check(L()).annotate({description:"Assign this destination to its connected account's schedule queue."})),settings:u(lJ)}).annotate({identifier:"CreatePostTarget"}),Vb=Fr.check(oe(zb)).pipe(SV({description:`At most ${zb} characters after trimming.`})),fL=U(lL).check(oe(50)),Jb={text:u(Vb),targets:u(fL),media:u(ps)},Sfe=p(Jb).annotate({identifier:"PostContent"}),bfe=p({...Jb,scheduledAt:u(Ut)}).annotate({identifier:"PostPreflight"}),mL=p({text:u(Vb),platforms:u(U(bn).check(be(1),oe(Gb))),accounts:u(U(J).check(be(1),oe(Gb))),targets:u(U(fJ).check(be(1),oe(Gb))),media:u(ps),scheduledAt:u(Ut),publishNow:u(Y),isDraft:u(Y).annotate({description:"Save the post as a draft without submitting it. Defaults to false."})}).annotate({identifier:"CreatePost"}).annotate({description:"Send exactly one selector for a direct post: platforms resolves the single ready account per provider, accounts selects exact account IDs, and targets selects exact destinations. Provider and placement are derived when omitted. publishNow defaults to true when scheduledAt is absent. Set isDraft to true to save a draft without submitting; drafts accept text, media, and targets."}),mJ=p({...Jb,expectedRevision:u(GD)}).annotate({identifier:"UpdatePost"}),np=p({postId:_t,isDraft:Y,revision:GD,text:Vb,media:ps,targets:fL,deliveries:U(Qm),status:jm,createdAt:a,updatedAt:a}).annotate({identifier:"Post"}),Ife=p({...np.fields,idempotencyKey:u(Vr)}).annotate({identifier:"PostCreated"}),wfe=mt([np,xa]).annotate({identifier:"PostCreateResult"}),hL=p({archived:v(!0)}),Efe=rs(mJ,{onExcessProperty:"error"}),hJ=p({accountId:J,provider:bn,placement:xr,canPublish:Y,caption:p({count:M,limit:M}),errors:U(co),warnings:U(co)}),yL=p({canPublish:Y,errors:U(co),warnings:U(co),targets:U(hJ),billing:u(fu)}).annotate({identifier:"PostValidation"});var uo=a.check(L()),tr=uo,gL=uo,ch=Fr.check(be(1),oe(100)),op=a.check(be(1),oe(100)),xL=M.check(Mr({minimum:0,maximum:6})),ph=a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/)),yJ=50,wn=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),gJ=p({id:u(uo).annotate({description:"Round-trip an existing slot ID. Omit to create a new slot; a removed slot reports no ID."}),dayOfWeek:xL,time:ph}).annotate({identifier:"QueueSlotInput"}),xJ=p({id:uo,dayOfWeek:xL,time:ph}).annotate({identifier:"QueueSlot"}),SL=U(gJ).check(oe(yJ)),SJ=p({maxPerDay:D(M.check(Pe(1))).annotate({description:"Null uses the provider limit."}),maxPending:M.check(Pe(1)),minGapSeconds:M.check(Pe(1)),horizonDays:M.check(Mr({minimum:1,maximum:90})),providerMaxPerDay:M.check(Pe(1)),providerMinGapSeconds:M.check(Pe(1))}).annotate({identifier:"QueueLimits"}),bJ=j(["active","paused","archived"]),ip=p({id:tr,workspaceId:de,accountId:J,name:ch,timezone:op,status:bJ,isDefault:Y.annotate({description:"The queue nextSlot assignment uses for this account when none is given."}),limits:SJ,slots:U(xJ),version:M.check(Pe(1)),pausedAt:D(a),archivedAt:D(a),createdAt:a,updatedAt:a}).annotate({identifier:"Queue"}),bL=p({data:U(ip),...ze}).annotate({identifier:"QueueList"}),IL=p({archived:v(!0),version:M.check(Pe(1))}).annotate({identifier:"QueueArchived"}),wL={maxPending:u(M.check(Mr({minimum:1,maximum:1000}))),minGapSeconds:u(M.check(Mr({minimum:60,maximum:604800}))),horizonDays:u(M.check(Mr({minimum:1,maximum:90})))},EL=p({accountId:J,name:ch,timezone:u(op).annotate({description:"An IANA time zone such as America/New_York. Defaults to the workspace default time zone."}),slots:SL,isDefault:u(Y).annotate({description:"Promote this queue to the account default. The first active queue is always the default."}),maxPerDay:u(M.check(Mr({minimum:1,maximum:1000}))).annotate({description:"Defaults to the provider limit."}),...wL}).annotate({identifier:"CreateQueue"}),kL=p({expectedVersion:M.check(Pe(1)),name:u(ch),timezone:u(op),paused:u(Y),isDefault:u(Y).annotate({description:"Promote or demote the account default. Demoting the current default requires promoting another queue first."}),maxPerDay:u(D(M.check(Mr({minimum:1,maximum:1000})))),...wL}).annotate({identifier:"UpdateQueue"}),AL=p({expectedVersion:M.check(Pe(1)),slots:SL}).annotate({identifier:"ReplaceQueueSlots"}),vL=j(["paused","archived","account_not_ready"]),CL=j(["max_per_day","max_pending"]),IJ=j(["occupied","capacity","skipped","blacked_out"]),TL=p({queueId:tr,slotId:D(uo),scheduledFor:a.annotate({description:"The resolved UTC instant."}),occurrenceDate:wn.annotate({description:"The local date the assignment counts toward."}),localDate:wn,localTime:ph,timezone:op,available:Y,unavailableReason:u(IJ)}).annotate({identifier:"QueueOccurrence"}),OL=p({queueId:tr,occurrence:D(TL),horizonEndsAt:a}).annotate({identifier:"QueueNextSlot"}),PL=p({queueId:tr,timezone:op,horizonEndsAt:a,occurrences:U(TL)}).annotate({identifier:"QueueSlotPreview"}),wJ=j(["published_now","cancelled","archived","submitted","rescheduled"]),Rfe=p({id:gL,queueId:tr,slotId:D(uo),postId:_t,targetId:cr,attemptId:zt,scheduledFor:a,occurrenceDate:wn,releasedAt:D(a),releaseReason:D(wJ)}).annotate({identifier:"QueueAssignment"}),wu=uo,dh=uo,RL=p({slotId:uo,occurrenceDate:wn}).annotate({identifier:"SkipQueueSlot"}),Yb=p({id:wu,queueId:tr,slotId:uo,occurrenceDate:wn,createdAt:a}).annotate({identifier:"QueueSkip"}),_L=p({data:U(Yb),...ze}).annotate({identifier:"QueueSkipList"}),UL=Fr.check(oe(200)).annotate({description:"Optional note for why these dates are unavailable."}),DL=p({startsOn:wn,endsOn:wn,reason:u(UL)}).annotate({identifier:"CreateQueueBlackout"}),Zb=p({id:dh,queueId:tr,startsOn:wn,endsOn:wn,reason:D(UL),createdAt:a}).annotate({identifier:"QueueBlackout"}),LL=p({data:U(Zb),...ze}).annotate({identifier:"QueueBlackoutList"}),Xb=p({deleted:v(!0)}).annotate({identifier:"QueueDeleted"});var EJ=j(["scheduled","queued"]),kJ=p({postId:_t,targetId:cr,attemptId:zt,accountId:J,provider:er,placement:xr,queueId:u(tr),slotId:u(uo),assignmentId:u(gL),queueName:u(ch),scheduledFor:a.annotate({description:"The queued attempt's UTC instant."}),occurrenceDate:u(wn),timezone:u(op),localDate:u(wn),localTime:u(ph),status:EJ.annotate({description:"scheduled when scheduledFor is in the future; queued otherwise."}),textPreview:a.check(oe(160)).annotate({description:"Short single-line preview of the post text."})}).annotate({identifier:"ScheduleEntry"}),ML=p({data:U(kJ),...ze}).annotate({identifier:"ScheduleList"}),_fe=p({results:U(p({index:M.check(Pe(0)),accepted:u(xa),problem:u(a)}))}).annotate({identifier:"BulkPublishResult"}),AJ=j(["invalid_timezone","invalid_slot_time","duplicate_slot","too_many_slots","slot_gap_too_short","limit_above_provider_default","queue_account_mismatch","queue_and_time_conflict","queue_archived","occurrence_in_past","occurrence_outside_horizon","invalid_blackout_range"]),FL=p({code:AJ,path:U(mt([a,M])),message:a}).annotate({identifier:"QueueIssue"}),Ufe=p({workspaceId:de,accountId:u(J),...It.fields}),Dfe=p({workspaceId:de}),Lfe=p({workspaceId:de,expectedVersion:Nm.check(au(),Pe(1))}),Mfe=p({workspaceId:de,after:u(Ut)}),Ffe=p({workspaceId:de,count:Nm.check(au(),Mr({minimum:1,maximum:100})),after:u(Ut),includeOccupied:u(Y)}),Nfe=p({workspaceId:de,...It.fields}),Bfe=p({workspaceId:de,...It.fields}),Kfe=p({workspaceId:de,from:Ut.annotate({description:"Inclusive ISO start instant."}),to:Ut.annotate({description:"Inclusive ISO end instant, after from and within 90 days."}),accountId:u(J),queueId:u(tr),...It.fields}),qfe=p({queueId:tr,skipId:wu}),$fe=p({queueId:tr,blackoutId:dh});var vJ=j(["queued","running","succeeded","partial","failed","cancelled"]),CJ=j(["active","backoff","paused","inaccessible","deleted","complete"]),NL=a.check(L()),BL=a.check(L()),eI=p({id:NL,workspaceId:de,cursorId:BL,domain:a,provider:a,subjectKind:a,subjectId:a.check(L()),scope:a,status:vJ,startedAt:a,finishedAt:D(a),requestCount:M,pageCount:M,errorKind:D(a),providerStatus:D(M),retryAfterSeconds:D(M),detail:D(Wt(a,H)),createdAt:a}).annotate({identifier:"SyncRun"}),jfe=p({cursorId:D(BL),state:CJ,lastSuccessAt:D(a),nextDueAt:D(a),syncRunId:D(NL)}).annotate({identifier:"SyncResource"});var us="/api/v1/inbox",tme=`${us}/conversations`,rme=`${us}/comments`,nme=`${us}/mentions`,TJ=`${us}/reviews`,ome=`${TJ}/:reviewId`,ime=`${us}/unread-count`,sme=`${us}/capabilities`,ame=`${us}/sync`,cme=`${us}/attachments`,OJ=j(["conversation","message","comment_thread","comment","mention"]),KL=j(["inbox","message_request","spam","other"]),rI=j(["active","archived"]),nI=j(["inbound","outbound"]),PJ=j(["received","pending","sending","sent","delivered","failed","unresolved","deleted"]),oI=j(["text","media","template","interactive","system","unknown"]),RJ=j(["post","comment","story","other"]),_J=j(["image","video","audio","file","unknown"]),UJ=j(["pending","succeeded","failed","unresolved"]),DJ=j(["list","read","send","reply","edit","delete","hide","unhide","like","unlike"]),LJ=j(["webhook","polling","webhook_with_reconciliation"]),Eu=p({externalId:a,name:D(a),handle:D(a)}).annotate({identifier:"InboxParticipant"}),iI=j(["none","24_hours","x_dm_30_days"]),qL=p({open:Y,policy:iI,endsAt:D(a)}).annotate({identifier:"InboxReplyWindow"}),MJ=j(["fresh","stale","pending","failed"]),sI=p({status:MJ,observedAt:D(a),nextDueAt:D(a),syncRunId:D(a)}).annotate({identifier:"InboxFreshness"}),FJ=p({id:Sb,messageId:Nn,kind:_J,mimeType:D(a),sizeBytes:D(M),width:D(M),height:D(M),durationSeconds:D(yr),url:a.annotate({description:"Workspace-scoped PubNio attachment URL. It never contains a provider URL or token."}),createdAt:a}).annotate({identifier:"InboxAttachment"}),aI=p({id:Nn,conversationId:Sn,accountId:J,provider:qe,direction:nI,state:PJ,kind:oI,text:D(a),sender:Eu,replyToMessageId:D(Nn),attachments:U(FJ),actionId:D(mi),providerCreatedAt:a,providerUpdatedAt:D(a),readAt:D(a),deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxMessage"}),uh=p({id:Sn,workspaceId:de,accountId:J,provider:qe,participant:Eu,folder:KL,status:rI,unreadCount:M,lastMessageAt:D(a),lastInboundAt:D(a),lastOutboundAt:D(a),lastMessagePreview:D(a),providerUrl:D(a),lastReadAt:D(a),archivedAt:D(a),replyWindow:qL,freshness:sI,createdAt:a}).annotate({identifier:"InboxConversation"}),lh=p({id:Qc,threadId:jc,accountId:J,provider:qe,parentCommentId:D(Qc),author:Eu,text:D(a),likeCount:M,replyCount:M,likedByAccount:Y,hidden:Y,canReply:Y,canHide:Y,canLike:Y,canDelete:Y,permalink:D(a),actionId:D(mi),providerCreatedAt:a,providerUpdatedAt:D(a),deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxComment"}),$L=p({id:jc,workspaceId:de,accountId:J,provider:qe,providerPostId:a,postId:D(a.check(L())),permalink:D(a),caption:D(a),commentCount:M,unreadCount:M,lastCommentAt:D(a),lastReadAt:D(a),freshness:sI,createdAt:a}).annotate({identifier:"InboxCommentThread"}),NJ=p({id:Hc,workspaceId:de,accountId:J,provider:qe,kind:RJ,author:Eu,text:D(a),permalink:D(a),parentExternalId:D(a),canReply:Y,freshness:sI,providerCreatedAt:a,deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxMention"}),BJ=j(["positive","negative"]),cI=p({id:Wm,workspaceId:de,accountId:J,provider:qe,locationExternalId:D(a),author:Eu,rating:D(M.check(Mr({minimum:1,maximum:5}))),recommendation:D(BJ),text:D(a),permalink:D(a),providerCreatedAt:a,providerUpdatedAt:D(a),repliedAt:D(a),replyText:D(a),canReply:Y,deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxReview"}),WL=p({data:U(uh),...ze}).annotate({identifier:"InboxConversationList"}),GL=p({data:U(aI),...ze}).annotate({identifier:"InboxMessageList"}),zL=p({data:U($L),...ze}).annotate({identifier:"InboxCommentThreadList"}),jL=p({thread:$L,data:U(lh),...ze}).annotate({identifier:"InboxCommentThreadDetail"}),QL=p({data:U(NJ),...ze}).annotate({identifier:"InboxMentionList"}),HL=p({data:U(cI),...ze}).annotate({identifier:"InboxReviewList"}),VL=p({unreadCount:M}).annotate({identifier:"InboxUnreadCount"}),tI=p({resource:OJ,supported:Y,operations:U(DJ),attachments:Y,quickReplies:Y,buttons:Y,readReceipts:Y,moderation:Y,syncMode:LJ,backfillDays:M,missingScopes:U(a),missingTasks:U(a)}).annotate({identifier:"InboxChannelCapability"}),KJ=p({accountId:J,profileId:a.check(L()),provider:qe,accountKind:pr,enabled:Y,publishingReadiness:gi,accountCapabilities:U(xi),messaging:tI,comments:tI,mentions:tI,replyWindow:qL,lastSyncError:D(a),checkedAt:a}).annotate({identifier:"InboxAccountCapabilities"}),JL=p({accounts:U(KJ)}).annotate({identifier:"InboxCapabilities"}),pme=p({workspaceId:de,accountId:u(J)}),dme=p({workspaceId:de,conversationId:Sn}),ume=p({workspaceId:de,threadId:jc}),lme=p({workspaceId:de,commentId:Qc}),fme=p({workspaceId:de,mentionId:Hc}),mme=p({workspaceId:de,attachmentId:Sb}),hme=p({workspaceId:de,accountId:u(J),provider:u(qe),status:u(rI),folder:u(KL),unread:u(Y),search:u(a.check(oe(200))),...It.fields}),yme=p({workspaceId:de,order:u(j(["oldest","newest"])),...It.fields}),gme=p({workspaceId:de,accountId:u(J),postId:u(a.check(L())),providerPostId:u(a),unread:u(Y),...It.fields}),xme=p({workspaceId:de,...It.fields}),Sme=p({workspaceId:de,accountId:u(J),provider:u(qe),...It.fields}),bme=p({workspaceId:de,accountId:u(J),includeDeleted:u(Y),...It.fields}),Ime=p({status:u(rI),read:u(Y)}).check(Gt(({status:e,read:t})=>e!==void 0||t!==void 0||"Provide status or read.")),pI=Fr.check(be(1),oe(1e4)),wme=p({text:pI}).annotate({identifier:"SendInboxMessage"}),Eme=p({text:pI}).annotate({identifier:"ReplyInboxComment"}),kme=p({text:pI}).annotate({identifier:"ReplyInboxReview"}),Ame=p({hidden:u(Y),liked:u(Y)}).check(Gt(({hidden:e,liked:t})=>e!==void 0!==(t!==void 0)||"Provide exactly one of hidden or liked for one provider call.")),vme=p({"idempotency-key":Vr}),YL=p({deleted:v(!0),actionId:mi}).annotate({identifier:"InboxDeleted"}),ZL=p({mentionId:Hc,actionId:mi,status:UJ,providerResultId:D(a)}).annotate({identifier:"InboxMentionReply"}),Cme=p({workspaceId:de,accountId:u(J)}),XL=p({syncRunId:a.check(L()),status:eI.fields.status}).annotate({identifier:"InboxSyncAccepted"}),eM=p({syncRun:eI,counts:p({conversations:M,messages:M,commentThreads:M,comments:M,mentions:M})}).annotate({identifier:"InboxSyncStatus"}),Tme=p({workspaceId:de,syncRunId:a.check(L())});var ku=j(["post","comment"]);var qJ=Fr.check(be(1)),Lme=p({accountId:u(J).annotate({description:"Account that comments; derived when unambiguous."}),provider:u(bn),target:a.check(be(1),oe(2048)).annotate({description:"Provider ID or permalink."}),targetKind:u(ku),text:qJ.annotate({description:"Max 8000 characters."})}).annotate({identifier:"CreateComment"}),Mme=p({actionId:mi,idempotencyKey:Vr,commentId:a.check(be(1)),target:a,targetId:a.check(be(1)),targetKind:ku,accountId:J,provider:bn,status:v("posted"),permalink:u(a),replayed:Y}).annotate({identifier:"CommentCreated"});var $J=["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Ot=j($J);var WJ=j(["available","selected"]),dI=j(["active","disabled","pending","closed","unknown"]),GJ=p({provider:Ot,kind:v("ad_account"),externalId:a,currency:Bn,timezone:a,status:dI,businessId:u(a),managerId:u(a),loginCustomerId:u(a),region:u(Gm)}).annotate({identifier:"AdAccountDetails"}),zJ=p({configured:Y,killSwitchActive:Y,monthlyCap:D(xt),dailyCap:D(xt),maxCampaignDailyBudget:D(xt),maxCampaignLifetimeBudget:D(xt),revision:M.check(Pe(0))}).annotate({identifier:"AdAccountPolicy"}),lo=p({code:a,message:a,field:u(a),providerCode:u(a),missingScopes:u(U(a)),retryable:Y,providerMessage:u(a)}).annotate({identifier:"AdIssue"}),ls=j(["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]),fs=p({amountMinor:M.check(Pe(0)),currency:Bn,kind:j(["daily","lifetime"])}).annotate({identifier:"AdBudget"}),mh=p({accountId:J,currency:Bn,configured:Y,monthlyCap:D(xt),dailyCap:D(xt),maxCampaignDailyBudget:D(xt),maxCampaignLifetimeBudget:D(xt),killSwitchActive:Y,killSwitchAt:D(a),killSwitchReason:D(a),revision:M.check(Pe(0)),updatedAt:a}).annotate({identifier:"AdSpendPolicy"}),fh=D(xt),Hme=p({expectedRevision:M.check(Pe(0)),monthlyCap:fh,dailyCap:fh,maxCampaignDailyBudget:fh,maxCampaignLifetimeBudget:fh}).annotate({identifier:"AdSpendPolicyUpdate"}),Vme=p({active:Y,reason:u(a.check(oe(500)))}).annotate({identifier:"AdKillSwitchInput"}),tM=p({policy:mh,changed:Y,paused:p({campaigns:M.check(Pe(0)),adGroups:M.check(Pe(0)),ads:M.check(Pe(0))}),nextAction:a}).annotate({identifier:"AdKillSwitchResult"}),hh=j(["boost.create","campaign.create","campaign.activate","campaign.pause","campaign.archive","ad_group.status","ad_group.create","ad.status","ad.attach","creative.create","campaign.duplicate","budget.update"]),vu=j(["queued","preflight","creating","recording","reviewing","activating","succeeded","partial","failed","unresolved","cancelled"]),jJ=j(["queued","preflight","create","record","review","activate","finish"]),sn=p({id:hi,accountId:J,kind:hh,status:vu,step:jJ,input:Wt(a,H),result:D(Wt(a,H)),issues:U(lo),attempts:M.check(Pe(0)),canRetry:Y,nextAction:a,createdAt:a,updatedAt:a,startedAt:D(a),completedAt:D(a)}).annotate({identifier:"AdOperation"}),Jme=p({id:UU,accountId:J,idempotencyKey:a,intentHash:a,requestedByType:j(["user","api_key"]),requestedByUserId:D(ss),requestedByApiKeyId:D(ha),operationId:D(hi),createdAt:a}).annotate({identifier:"AdRequest"}),Yme=p({id:_U,accountId:J,provider:Ot,postId:_t,targetId:cr,actorAccountId:J,creativeId:D(Vc),campaignId:D(Lo),providerPostId:a,permalink:D(a),sourceHash:a,status:ls,revision:M.check(Pe(1)),operationId:D(hi),createdAt:a,updatedAt:a}).annotate({identifier:"AdBoost"}),Zme=p({expectedRevision:M.check(Do(0)),confirmation:v("activate_spend")}).annotate({identifier:"AdCampaignActivationInput"}),Xme=p({expectedRevision:M.check(Do(0))}).annotate({identifier:"AdCampaignPauseInput"}),ehe=p({expectedRevision:M.check(Do(0))}).annotate({identifier:"AdCampaignArchiveInput"}),the=p({status:j(["active","paused","archived"]),expectedRevision:M.check(Do(0))}).annotate({identifier:"AdEntityStatusUpdate"}),rhe=p({budget:fs,expectedRevision:M.check(Do(0))}).annotate({identifier:"AdBudgetUpdateInput"}),QJ=p({headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:u(a.check(oe(2048))),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdAttachAdCreative"}),nhe=p({name:a.check(be(1),oe(255)),budget:u(fs),targeting:u(Wt(a,H)),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdAdGroupCreateInput"}),ohe=p({actorAccountId:J,mediaId:a.check(L()),headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:a.check(oe(2048)),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCreativeCreateInput"}),ihe=p({name:u(a.check(be(1),oe(255)))}).annotate({identifier:"AdCampaignDuplicateInput"}),she=p({name:a.check(be(1),oe(255)),creativeId:u(Vc),creative:u(QJ),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdAttachAdInput"}),ahe=p({"idempotency-key":Vr}),HJ=p({id:J,name:a,provider:Ot,accountKind:v("ad_account"),available:Y,selected:Y,details:GJ,readiness:gi,capabilities:U(xi),policy:zJ,issues:U(lo),createdAt:a,updatedAt:a}).annotate({identifier:"AdAccount"}),rM=p({data:U(HJ),...ze}).annotate({identifier:"AdAccountList"}),che=p({workspaceId:de,state:u(WJ),...It.fields}),phe=p({workspaceId:de,provider:Ot,accountId:u(J)}),nM=p({attemptId:a.check(L()),provider:Ot,url:a,status:v("pending")}).annotate({identifier:"AdConnectLaunch"}),dhe=p({workspaceId:de,provider:v("openai_ads"),apiKey:a.check(be(1),oe(2048)),accountId:u(J),profileId:u(bt)}).annotate({identifier:"AdApiKeyConnectInput"}),oM=p({provider:v("openai_ads"),accountId:J,status:v("connected")}).annotate({identifier:"AdApiKeyConnectResult"}),uhe=p({workspaceId:de,accountId:J}),iM=p({accountId:J,selected:v(!0),campaignSyncQueued:Y,insightSyncQueued:Y}).annotate({identifier:"AdAccountSelection"}),sM=p({accountId:J,disconnected:v(!0),historyRetained:v(!0)}).annotate({identifier:"AdAccountDisconnected"}),aM=j(["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),VJ=j(["provider","pubnio"]),cM=a,Au=Wt(a,H),Cu=p({startAt:D(Ut),endAt:D(Ut),timezone:a}).annotate({identifier:"AdSchedule"}),pM=p({valid:Y,accountId:J,provider:Ot,actorAccountId:D(J),currency:Bn,budget:D(fs),schedule:D(Cu),killSwitchActive:Y,issues:U(lo),nextAction:a}).annotate({identifier:"AdValidation"}),JJ=p({postId:_t,postTargetId:u(cr),actorAccountId:u(J),budget:fs,schedule:u(Cu),targeting:u(Wt(a,H))}).annotate({identifier:"AdBoostDraft"}),lhe=p({workspaceId:de,accountId:J,...JJ.fields}).annotate({identifier:"AdBoostInput"}),YJ=j(["campaign.create","ad_group.create","creative.create","ad.create","campaign.activate","campaign.pause","campaign.archive","ad_group.activate","ad_group.pause","ad_group.archive","ad.activate","ad.pause","ad.archive","budget.update","boost.create"]),ZJ=p({budgetOwner:j(["campaign","ad_group","shared"]),maxAdGroups:u(M.check(Pe(1))),budgetUnit:j(["minor","micros"]),hierarchy:U(j(["campaign","ad_group","creative","ad"])),actor:j(["required","none"]),creative:j(["separate","embedded"]),review:j(["sync","pending","async"]),activation:j(["campaign","ad_group"])}).annotate({identifier:"AdCampaignPlanProfile"}),XJ=p({accountId:J,actorAccountId:u(J),budget:u(fs),schedule:u(Cu),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlanTarget"}),e3=p({headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:u(a.check(oe(2048))),media:u(ps),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlanCreative"}),t3=p({name:a.check(be(1),oe(255)),creative:e3,providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlanAd"}),r3=p({name:a.check(be(1),oe(255)),budget:u(fs),targeting:u(Wt(a,H)),providerSettings:u(Wt(a,H)),ads:U(t3).check(be(1),oe(50))}).annotate({identifier:"AdCampaignPlanAdGroup"}),fhe=p({name:a.check(be(1),oe(255)),objective:aM,budget:u(fs),schedule:u(Cu),targets:U(XJ).check(be(1),oe(50)),adGroups:U(r3).check(be(1),oe(50)),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlan"}),n3=p({accountId:J,provider:u(Ot),name:u(a),currency:u(Bn),budget:u(D(fs)),profile:u(ZJ),capabilities:u(U(YJ)),issues:U(lo)}).annotate({identifier:"AdCampaignPlanTargetValidation"}),dM=p({valid:Y,issues:U(lo),targets:U(n3)}).annotate({identifier:"AdCampaignPlanValidation"}),uI=j(["queued","creating","partial","succeeded","failed","unresolved"]),uM=p({accountId:J,provider:Ot,operationId:hi,status:vu}).annotate({identifier:"AdCampaignPlanTargetAccepted"}),lM=p({planId:a.check(L()),status:uI,targets:U(uM)}).annotate({identifier:"AdCampaignPlanAccepted"}),o3=p({planId:a.check(L()),status:uI,createdAt:a,targets:U(uM)}).annotate({identifier:"AdCampaignPlanListRow"}),fM=p({data:U(o3),...ze}).annotate({identifier:"AdCampaignPlanList"}),i3=p({accountId:J,provider:Ot,operationId:hi,campaignId:D(Lo),status:vu,issues:U(lo)}).annotate({identifier:"AdCampaignPlanTargetDetail"}),mM=p({planId:a.check(L()),status:uI,createdAt:a,targets:U(i3),issues:U(lo)}).annotate({identifier:"AdCampaignPlanDetail"}),hM=p({id:Lo,accountId:J,provider:Ot,externalId:a,name:a,objective:aM,status:ls,providerStatus:D(a),managed:VJ,revision:M.check(Pe(1)),budget:D(xt),bidStrategy:D(cM),schedule:Cu,providerSettings:Au,syncedAt:a}).annotate({identifier:"AdCampaign"}),yM=p({id:ya,campaignId:Lo,accountId:J,provider:Ot,kind:a,externalId:a,name:a,status:ls,providerStatus:D(a),revision:M.check(Pe(1)),budget:D(xt),bidStrategy:D(cM),targeting:Au,providerSettings:Au,syncedAt:a}).annotate({identifier:"AdGroup"}),Tu=p({id:Vc,accountId:J,provider:Ot,externalId:a,kind:a,actorAccountId:D(J),mediaId:D(a.check(L())),headline:D(a),body:D(a),callToAction:D(a),destinationUrl:D(a),providerSettings:Au,syncedAt:a}).annotate({identifier:"AdCreative"}),lI=j(["campaign","ad_group","ad"]),s3=a,a3=j(["fresh","stale","pending","partial","unavailable"]),wa=p({status:a3,syncedAt:D(a),nextSyncAt:u(a),retryAfter:u(a)}).annotate({identifier:"AdFreshness"}),mhe=p({accountId:u(J),campaignId:u(Lo),adGroupId:u(ya),adId:u(as),from:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),to:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),level:u(lI),metrics:u(U(s3).check(oe(30))),cursor:It.fields.cursor,limit:u(M.check(Pe(1),mU(100)))}).annotate({identifier:"AdInsightQuery"}),c3=p({id:RU,accountId:J,level:lI,campaignId:D(Lo),adGroupId:D(ya),adId:D(as),creativeId:D(Vc),date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),currency:Bn,spend:xt,impressions:M.check(Pe(0)),clicks:M.check(Pe(0)),conversions:yr.check(Pe(0)),revenue:xt,metrics:Wt(a,yr),syncedAt:a}).annotate({identifier:"AdInsightRow"}),p3=p({currency:Bn,spend:xt,impressions:M.check(Pe(0)),clicks:M.check(Pe(0)),conversions:yr.check(Pe(0)),revenue:xt,metrics:Wt(a,yr)}).annotate({identifier:"AdInsightTotals"}),fI=p({from:a,to:a,level:lI,totals:U(p3),rowCount:M.check(Pe(0)),freshness:wa}).annotate({identifier:"AdInsightSummary"}),yh=p({id:as,accountId:J,campaignId:Lo,adGroupId:ya,creativeId:D(Vc),provider:Ot,externalId:a,name:a,format:D(a),status:ls,providerStatus:D(a),revision:M.check(Pe(1)),providerSettings:Au,syncedAt:a,creative:u(D(Tu)),insights:u(D(fI))}).annotate({identifier:"Ad"}),mI=p({data:U(hM),...ze,freshness:wa}).annotate({identifier:"AdCampaignList"}),d3=p({...yM.fields,insights:u(D(fI))}).annotate({identifier:"AdGroupListRow"}),gM=p({data:U(d3),...ze,freshness:wa}).annotate({identifier:"AdGroupList"}),xM=p({data:U(yh),...ze,freshness:wa}).annotate({identifier:"AdList"}),SM=p({data:U(Tu),...ze,freshness:wa}).annotate({identifier:"AdCreativeList"}),hI=p({data:U(c3),summary:fI,...ze,freshness:wa}).annotate({identifier:"AdInsightList"}),u3=p({adGroup:yM,ads:U(p({ad:yh,creative:D(Tu)}))}).annotate({identifier:"AdTreeNode"}),l3=p({campaign:hM,adGroups:U(u3)}).annotate({identifier:"AdTreeCampaign"}),bM=p({data:U(l3),...ze,freshness:wa}).annotate({identifier:"AdTree"}),IM=p({accountId:J,queuedScopes:U(j(["campaigns","ads_insights"])),nextDueAt:a,retryAfterSeconds:u(M)}).annotate({identifier:"AdRefreshAccepted"});var yI="2026-12-02",wM=[yI],gh=j(wM),EM="PubNio-Version";var gI=Fr.check(be(1),oe(100)),xI=a.check(be(1),oe(128)),Ou=p({id:bt,workspaceId:de,name:gI,externalId:D(xI),isDefault:Y,archived:Y,createdAt:a,updatedAt:a}).annotate({identifier:"WorkspaceProfile"}),kM=p({data:U(Ou),...ze}).annotate({identifier:"ProfileList"}),Ihe=p({workspaceId:de,includeArchived:u(Y),...It.fields}),whe=p({name:gI,externalId:u(xI)}),Ehe=p({name:u(gI),externalId:u(D(xI))}).check(Gt(({name:e,externalId:t})=>e!==void 0||t!==void 0||"Provide a name or external ID.")),khe=p({profileId:bt}),AM=p({archived:v(!0)});var Phe=j(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),xh=j(["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]);var vM=p({id:a.check(L()),type:xh,version:v(1),timestamp:Ut.check(Ge(/Z$/)),workspaceId:de,profileId:u(bt)}).annotate({identifier:"WorkspaceEventEnvelope"});var SI=a.check(L()),f3=a.check(L()),CM=xh,PM=j([...xh.literals,"webhook.test"]),Ghe=p({eventTypes:U(PM)}).annotate({identifier:"WebhookEventTypes"}),Re=vM.fields,Pu={postId:_t,targetId:cr,attemptId:zt,accountId:J,provider:er,placement:xr,revision:po},TM={providerRef:mu,url:u(a)},Sh={canRetry:Y,canReconcile:Y,nextAction:a},m3=j(["published","provider_draft","failed","unresolved","cancelled"]),h3={targetId:cr,accountId:J,provider:er,placement:xr,status:m3,url:u(a),issue:u(hu)},y3={targetId:cr,accountId:J,scheduledAt:D(a)},bh={postId:_t,revision:po,targets:U(p(h3))},bI=j(["live","backfill"]),OM={messageId:Nn,conversationId:Sn,accountId:J,provider:er,direction:nI,kind:oI,providerCreatedAt:a,freshness:bI},g3={threadId:jc,commentId:Qc,accountId:J,provider:er,providerCreatedAt:a,freshness:bI},x3={mentionId:Hc,accountId:J,provider:er,providerCreatedAt:a,freshness:bI},Ru={reviewId:Wm,accountId:J,provider:qe,locationId:u(a)},_u={accountId:J,provider:qe,accountKind:pr},zhe=mt([p({...Re,type:v("post.delivery.published"),data:p({...Pu,status:v("published"),...TM})}),p({...Re,type:v("post.delivery.provider_draft"),data:p({...Pu,status:v("provider_draft"),...TM})}),p({...Re,type:v("post.delivery.failed"),data:p({...Pu,status:v("failed"),issue:hu,canRetry:Sh.canRetry,nextAction:Sh.nextAction,providerRef:u(mu),url:u(a)})}),p({...Re,type:v("post.delivery.unresolved"),data:p({...Pu,status:v("unresolved"),issue:hu,canReconcile:Sh.canReconcile,nextAction:Sh.nextAction,providerRef:u(mu),url:u(a)})}),p({...Re,type:v("post.delivery.cancelled"),data:p({...Pu,status:v("cancelled")})}),p({...Re,type:v("post.scheduled"),data:p({postId:_t,revision:po,targets:U(p(y3))})}),p({...Re,type:v("post.published"),data:p(bh)}),p({...Re,type:v("post.partial"),data:p(bh)}),p({...Re,type:v("post.failed"),data:p(bh)}),p({...Re,type:v("post.cancelled"),data:p(bh)}),p({...Re,type:v("inbox.message.received"),data:p(OM)}),p({...Re,type:v("inbox.message.sent"),data:p(OM)}),p({...Re,type:v("inbox.comment.received"),data:p(g3)}),p({...Re,type:v("inbox.review.new"),data:p(Ru)}),p({...Re,type:v("inbox.review.updated"),data:p(Ru)}),p({...Re,type:v("inbox.review.deleted"),data:p(Ru)}),p({...Re,type:v("inbox.review.restored"),data:p(Ru)}),p({...Re,type:v("inbox.review.replied"),data:p(Ru)}),p({...Re,type:v("inbox.mention.received"),data:p(x3)}),p({...Re,type:v("inbox.message.delivered"),data:p({messageIds:U(Nn),conversationId:u(Sn),accountId:J,provider:er,deliveredAt:a})}),p({...Re,type:v("inbox.message.read"),data:p({messageIds:U(Nn),conversationId:u(Sn),accountId:J,provider:er,readAt:a})}),p({...Re,type:v("inbox.message.edited"),data:p({messageId:Nn,conversationId:Sn,accountId:J,provider:er})}),p({...Re,type:v("inbox.message.deleted"),data:p({messageId:Nn,conversationId:Sn,accountId:J,provider:er})}),p({...Re,type:v("inbox.reaction.received"),data:p({messageId:u(Nn),conversationId:u(Sn),accountId:J,provider:er,reaction:a,action:j(["add","remove"])})}),p({...Re,type:v("inbox.referral.received"),data:p({messageId:u(Nn),conversationId:u(Sn),accountId:J,provider:er,ref:a,source:a,adId:u(a)})}),p({...Re,type:v("inbox.conversation.started"),data:p({conversationId:Sn,accountId:J,provider:er,participantExternalId:a})}),p({...Re,type:v("analytics.post.synced"),data:p({postId:_t,accountId:J,provider:qe})}),p({...Re,type:v("analytics.account.synced"),data:p({accountId:J,provider:qe})}),p({...Re,type:v("ads.operation.succeeded"),data:p({operationId:hi,accountId:J,kind:hh,status:j(["succeeded","partial"]),nextAction:a})}),p({...Re,type:v("ads.operation.failed"),data:p({operationId:hi,accountId:J,kind:hh,status:j(["failed","unresolved","cancelled"]),issue:lo,canRetry:Y,nextAction:a})}),p({...Re,type:v("ads.kill_switch.activated"),data:p({accountId:J,revision:M.check(Pe(1)),reason:D(a),pausedCampaigns:M.check(Pe(0)),pausedAdGroups:M.check(Pe(0)),pausedAds:M.check(Pe(0))})}),p({...Re,type:v("ads.lead.received"),data:p({accountId:J,leadId:a,pageId:u(a),formId:u(a),adId:u(a),adGroupId:u(a)})}),p({...Re,type:v("ads.campaign.status_changed"),data:p({accountId:J,campaignId:Lo,provider:Ot,status:ls})}),p({...Re,type:v("ads.ad_group.status_changed"),data:p({accountId:J,adGroupId:ya,provider:Ot,status:ls})}),p({...Re,type:v("ads.ad.status_changed"),data:p({accountId:J,adId:as,provider:Ot,status:ls})}),p({...Re,type:v("ads.ad_account.status_changed"),data:p({accountId:J,provider:Ot,status:dI})}),p({...Re,type:v("ads.ad.review.approved"),data:p({accountId:J,adId:as,provider:Ot})}),p({...Re,type:v("ads.ad.review.rejected"),data:p({accountId:J,adId:as,provider:Ot})}),p({...Re,type:v("ads.sync.failed"),data:p({accountId:J,provider:Ot})}),p({...Re,type:v("ads.sync.recovered"),data:p({accountId:J,provider:Ot})}),p({...Re,type:v("ads.initial_sync.completed"),data:p({accountId:J,provider:Ot})}),p({...Re,type:v("account.connected"),data:p({..._u,reconnected:Y})}),p({...Re,type:v("account.disconnected"),data:p({..._u,reason:j(["disconnected","expired","revoked","deauthorized"])})}),p({...Re,type:v("account.permissions_changed"),data:p({..._u,missingScopes:U(a),missingTasks:U(a)})}),p({...Re,type:v("account.restricted"),data:p({..._u,reason:v("publish_failures")})}),p({...Re,type:v("account.recovered"),data:p(_u)}),p({...Re,type:v("billing.subscription.updated"),data:p({plan:Zc,status:yu,interval:D(Hm),periodStart:a,periodEnd:a,cancelAtPeriodEnd:Y})}),p({...Re,type:v("billing.credit.topped_up"),data:p({amountMicros:M,balanceAfterMicros:M,kind:Ym})}),p({...Re,type:v("billing.credit.low"),data:p({balanceMicros:M,thresholdMicros:M})}),p({...Re,type:v("billing.spend_cap.reached"),data:p({capMicros:M,periodSpendMicros:M,estimatedMicros:M})}),p({...Re,type:v("billing.invoice.payment_failed"),data:p({invoiceId:a,amountDueMinor:M,hostedInvoiceUrl:D(a)})}),p({...Re,type:v("webhook.test"),data:p({endpointId:lu})})]).annotate({identifier:"WebhookEvent"}),II=j(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),wI=Fr.check(be(1),oe(100)),RM=a.check(oe(2048)),S3=u(U(J)).annotate({description:"Only deliver events for these accounts. Empty or omitted means every account. Duplicates are ignored."}),b3=u(U(II)).annotate({description:"Drop every event in these families. Empty or omitted means no family is dropped. Duplicates are ignored."}),I3=u(D(U(J))).annotate({description:"Only deliver events for these accounts. Omit to keep the current filter; null or an empty array clears it to every account."}),w3=u(D(U(II))).annotate({description:"Drop every event in these families. Omit to keep the current denylist; null or an empty array clears it."}),EI=U(CM).check(be(1),oe(CM.literals.length),Gt((e)=>new Set(e).size===e.length||"Choose each event type only once.")),E3=p({workspaceId:de,endpointId:lu}),jhe=p({...E3.fields,deliveryId:SI}),Qhe=p({name:wI,url:RM,eventTypes:EI,enabled:u(Y),profileId:u(bt),accountIds:S3,disabledResourceGroups:b3}),Hhe=p({name:u(wI),eventTypes:u(EI),enabled:u(Y),profileId:u(D(bt)),accountIds:I3,disabledResourceGroups:w3}).check(Gt((e)=>Object.keys(e).length>0||"Provide at least one endpoint change.")),Ih=p({id:lu,workspaceId:de,name:wI,eventTypes:EI,enabled:Y,profileId:D(bt),accountIds:U(J),disabledResourceGroups:U(II),apiVersion:gh,destinationOrigin:a,createdAt:a,updatedAt:a,deletedAt:D(a)}).annotate({identifier:"WebhookEndpoint"}),kI=p({...Ih.fields,url:D(RM)}),k3=a.check(Ge(/^whsec_[A-Za-z0-9+/]{43}=$/)),_M=p({endpoint:kI,secret:k3}),UM=p({data:U(Ih),...ze}).annotate({identifier:"WebhookEndpointList"}),DM=p({deleted:v(!0)}),LM=p({deliveryId:SI}),AI=j(["pending","sending","delivered","failed","cancelled"]),A3=j(["timeout","network","http_status","redirect","destination_rejected","configuration_unavailable","expired","attempts_exhausted"]),wh=p({id:SI,workspaceId:de,endpointId:lu,eventId:f3,eventType:PM,status:AI,attemptCount:M,createdAt:a,nextAttemptAt:D(a),lastAttemptAt:D(a),lastHttpStatus:D(M),lastError:D(A3),completedAt:D(a)}).annotate({identifier:"WebhookDelivery"}),MM=p({data:U(wh),...ze}).annotate({identifier:"WebhookDeliveryList"});var vI="~effect/http/HttpBody";class TI{[vI];constructor(){this[vI]=vI}[Xr](){return this.toJSON()}toString(){return rt(this,{ignoreToString:!0})}}class FM extends TI{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var NM=new FM;class CI extends TI{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(e,t,r,n){super();this._body=e,this.text=n,this.contentType=t,this.contentLength=r}get body(){return this._body??=v3(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var BM=new TextEncoder,Eh=globalThis.Buffer,v3=Eh!==void 0?(e)=>Eh.from(e,"utf8"):(e)=>BM.encode(e),KM=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(Eh!==void 0)return new CI(void 0,t??"text/plain",Eh.byteLength(e,"utf8"),e);let r=BM.encode(e);return new CI(r,t??"text/plain",r.length,e)},qM=(e,t)=>KM(JSON.stringify(e),t??"application/json");var C3=Object.getPrototypeOf(la),WM=()=>Object.create(C3);var GM="~effect/http/HttpServerResponse";var O3=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"]};var zM=(e,t)=>{let r=t?.headers?R_(t.headers):la;return R3({status:t?.status??200,statusText:t?.statusText,headers:r,cookies:t?.cookies,body:qM(e,O3(t,r))})};var P3={...qr,[GM]:GM,[$m]:!0,toJSON(){return{_id:"HttpServerResponse",status:this.status,statusText:this.statusText,headers:zn(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},R3=(e,t)=>{let r=Object.create(P3);if(r.status=e.status,r.statusText=e.statusText,r.cookies=e.cookies??T_,r.body=e.body??NM,r.body._tag!=="Empty"&&(r.body.contentType||r.body.contentLength!==void 0)){let n=t!==void 0,o=n?t:e.headers===void 0||e.headers===la?WM():__({...e.headers});if(r.body.contentType&&(!n||o["content-type"]===void 0))o["content-type"]=r.body.contentType;if(r.body.contentLength!==void 0&&(!n||o["content-length"]===void 0))o["content-length"]=r.body.contentLength.toString();r.headers=o}else r.headers=t??e.headers??la;return r};var QM="~effect/http/HttpServerRespondable";var kh="application/problem+json",VM="about:blank",Ea=(e)=>u(e).pipe(ub(()=>md)),JM=(e,t)=>fU(z(t))(e).pipe(ub(()=>fx(t))),OI=(e)=>JM(is(e),e),_3=dU(p({type:JM(a,VM),status:Ea(yr),title:Ea(a),detail:Ea(a),instance:Ea(a)}),[Wt(a,H)]);var U3={_tag:"Json",contentType:kh},ue=()=>(e,t,r,n)=>{let o=p({detail:Ea(a),instance:Ea(a),...r,type:is(t.type),status:OI(t.status),title:OI(t.title)}),i=cU(o),s=cu(e)(o,{description:t.title,httpApiStatus:t.status,"~httpApiEncoding":U3,...n});return Object.assign(s.prototype,{_tag:e,[$m]:t.status<500,[QM](){return De(i(this),(c)=>zM(c,{status:t.status,contentType:kh}))}}),Object.defineProperty(s.prototype,"message",{get(){return this.detail??t.title},configurable:!0}),s},D3=p({path:U(mt([a,yr])),message:a});class L3 extends ue()("UploadTooLarge",{type:"about:blank",status:413,title:"Content Too Large"}){}class ZM extends ue()("AuthenticationRequired",{type:"urn:pubnio:problem:authentication-required",status:401,title:"Unauthorized"},{docUrl:u(a)}){}class XM extends ue()("Forbidden",{type:"urn:pubnio:problem:forbidden",status:403,title:"Forbidden"},{requiredScope:u(gu),docUrl:u(a)}){}class eF extends ue()("HumanActorRequired",{type:"urn:pubnio:problem:human-actor-required",status:403,title:"Human actor required"},{code:v("human_actor_required"),nextAction:a}){}class tF extends ue()("OwnerRequired",{type:"urn:pubnio:problem:owner-required",status:403,title:"Owner permission required"},{code:v("owner_required"),nextAction:a}){}class rF extends ue()("SeatLimitReached",{type:"urn:pubnio:problem:seat-limit-reached",status:402,title:"Seat limit reached"},{code:v("seat_limit_reached"),seatsUsed:M,seatsLimit:M,nextAction:a}){}class nF extends ue()("AlreadyMember",{type:"urn:pubnio:problem:already-member",status:409,title:"Already a workspace member"},{code:v("already_member"),nextAction:a}){}class oF extends ue()("InviteAlreadyPending",{type:"urn:pubnio:problem:invite-already-pending",status:409,title:"Invite already pending"},{code:v("invite_already_pending"),nextAction:a}){}class iF extends ue()("LastOwnerRequired",{type:"urn:pubnio:problem:last-owner-required",status:409,title:"Last owner required"},{code:v("last_owner_required"),nextAction:a}){}class sF extends ue()("InviteExpired",{type:"urn:pubnio:problem:invite-expired",status:410,title:"Invite expired"},{code:v("invite_expired"),nextAction:a}){}class aF extends ue()("InviteEmailMismatch",{type:"urn:pubnio:problem:invite-email-mismatch",status:403,title:"Invite email mismatch"},{code:v("invite_email_mismatch"),nextAction:a}){}class cF extends ue()("NotFound",{type:"urn:pubnio:problem:not-found",status:404,title:"Not Found"}){}class pF extends ue()("Conflict",{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict"}){}class dF extends ue()("Unavailable",{type:"urn:pubnio:problem:unavailable",status:503,title:"Service Unavailable"}){}class uF extends ue()("UnsupportedApiVersion",{type:"urn:pubnio:problem:unsupported-api-version",status:400,title:"Unsupported API version"},{code:v("unsupported_api_version"),param:a,supportedVersions:U(gh),nextAction:a}){}class M3 extends ue()("InvalidCursor",{type:"urn:pubnio:problem:invalid-cursor",status:400,title:"Invalid cursor"},{code:u(v("invalid_cursor")),nextAction:u(a)}){}var Uu=p({accountId:J,name:a}).annotate({identifier:"ProblemCandidate"});class lF extends ue()("InvalidPublication",{type:"urn:pubnio:problem:invalid-publication",status:422,title:"Invalid publication"},{issues:U(co),candidates:u(U(Uu)),code:u(v("invalid_publication")),nextAction:u(a)}){}var fF="x-request-id",mF=D3;class hF extends ue()("InternalFailure",{type:"urn:pubnio:problem:internal-error",status:500,title:"Internal Server Error"},{requestId:a.check(L())}){}class yF extends ue()("AttemptChanged",{type:"urn:pubnio:problem:attempt-changed",status:409,title:"Delivery attempt changed"},{currentAttemptId:zt}){}class gF extends ue()("IdempotencyConflict",{type:"urn:pubnio:problem:idempotency-conflict",status:409,title:"Idempotency key already used"},{code:u(v("idempotency_conflict")),nextAction:u(a)}){}class xF extends ue()("AccountAmbiguous",{type:"urn:pubnio:problem:account-ambiguous",status:422,title:"Account ambiguous"},{code:v("account_ambiguous"),provider:qe,param:a,candidates:U(Uu),nextAction:a}){}class SF extends ue()("ProviderMismatch",{type:"urn:pubnio:problem:provider-mismatch",status:422,title:"Provider mismatch"},{code:v("provider_mismatch"),provider:qe,expectedProvider:qe,param:a,nextAction:a}){}class bF extends ue()("PublishAccountNotFound",{type:"urn:pubnio:problem:publish-account-not-found",status:422,title:"Publishing account not found"},{code:v("account_not_found"),provider:u(qe),accountId:u(J),param:a,candidates:u(U(Uu)),nextAction:a}){}class IF extends ue()("MediaUploadConflict",{type:"urn:pubnio:problem:media-upload-conflict",status:409,title:"Media upload conflict"},{reason:RD}){}class wF extends ue()("DestinationAlreadySubmitted",{type:"urn:pubnio:problem:destination-already-submitted",status:409,title:"Destination already submitted"}){}class EF extends ue()("DeliveryNotRetryable",{type:"urn:pubnio:problem:delivery-not-retryable",status:409,title:"Delivery cannot be retried"}){}class kF extends ue()("DeliveryNotReconcilable",{type:"urn:pubnio:problem:delivery-not-reconcilable",status:409,title:"Delivery cannot be reconciled"}){}class AF extends ue()("DeliveryScheduleLocked",{type:"urn:pubnio:problem:delivery-schedule-locked",status:409,title:"Delivery schedule cannot change"}){}class vF extends ue()("PostRevisionConflict",{type:"urn:pubnio:problem:post-revision-conflict",status:409,title:"Post revision changed"},{currentRevision:po}){}class CF extends ue()("QueueNotFound",{type:"urn:pubnio:problem:queue-not-found",status:404,title:"Queue not found"}){}class TF extends ue()("QueueAlreadyExists",{type:"urn:pubnio:problem:queue-already-exists",status:409,title:"Queue already exists"}){}class OF extends ue()("QueueDefaultRequired",{type:"urn:pubnio:problem:queue-default-required",status:409,title:"Queue default required"},{code:v("queue_default_required"),accountId:J,nextAction:a}){}class PF extends ue()("QueueVersionConflict",{type:"urn:pubnio:problem:queue-version-conflict",status:409,title:"Queue version changed"},{currentVersion:M.check(Pe(1))}){}class RF extends ue()("QueueUnavailable",{type:"urn:pubnio:problem:queue-unavailable",status:409,title:"Queue unavailable"},{reason:vL}){}class _F extends ue()("QueueCapacityReached",{type:"urn:pubnio:problem:queue-capacity-reached",status:409,title:"Queue capacity reached"},{reason:CL}){}class UF extends ue()("QueueNoSlotAvailable",{type:"urn:pubnio:problem:queue-no-slot-available",status:409,title:"No queue slot available"},{horizonEndsAt:a}){}class DF extends ue()("QueueSlotConflict",{type:"urn:pubnio:problem:queue-slot-conflict",status:409,title:"Queue slot conflict"},{scheduledAt:a,suggestedSlots:U(a)}){}class LF extends ue()("InvalidTimezone",{type:"urn:pubnio:problem:invalid-timezone",status:422,title:"Invalid time zone"},{code:v("invalid_timezone"),timezone:a,nextAction:a}){}class MF extends ue()("InvalidQueue",{type:"urn:pubnio:problem:invalid-queue",status:422,title:"Invalid queue"},{issues:U(FL)}){}class FF extends ue()("ScheduleRangeTooWide",{type:"urn:pubnio:problem:schedule-range-too-wide",status:422,title:"Schedule range too wide"},{maxDays:M}){}class NF extends ue()("WebhookTestRateLimited",{type:"urn:pubnio:problem:webhook-test-rate-limited",status:429,title:"Webhook test rate limited"}){}class BF extends ue()("WebhookDeliveryNotReplayable",{type:"urn:pubnio:problem:webhook-delivery-not-replayable",status:409,title:"Webhook delivery not replayable"},{code:v("webhook_delivery_not_replayable"),deliveryStatus:AI,nextAction:a}){}class KF extends ue()("ProviderPermissionRequired",{type:"urn:pubnio:problem:provider-permission-required",status:403,title:"Provider permission required"},{provider:qe,missingScopes:U(a),missingRoles:U(a),reason:u(a),reconnectRequired:u(Y)}){}class qF extends ue()("ProviderReconnectRequired",{type:"urn:pubnio:problem:provider-reconnect-required",status:409,title:"Provider reconnect required"},{provider:qe,missingScopes:U(a),reason:u(a)}){}class $F extends ue()("ProviderRateLimited",{type:"urn:pubnio:problem:provider-rate-limited",status:429,title:"Provider rate limited"},{provider:qe,retryAfterSeconds:u(M)}){}class WF extends ue()("ProviderUnavailable",{type:"urn:pubnio:problem:provider-unavailable",status:503,title:"Provider unavailable"},{provider:qe,retryAfterSeconds:u(M)}){}class GF extends ue()("CapabilityUnsupported",{type:"urn:pubnio:problem:capability-unsupported",status:422,title:"Capability unsupported"},{capability:yi,provider:qe,accountKind:pr}){}class zF extends ue()("AnalyticsRangeInvalid",{type:"urn:pubnio:problem:analytics-range-invalid",status:400,title:"Analytics range invalid"},{reason:j(["invalid_timezone","invalid_range","range_too_wide"])}){}class jF extends ue()("AnalyticsMetricUnsupported",{type:"urn:pubnio:problem:analytics-metric-unsupported",status:400,title:"Analytics metric unsupported"},{metrics:U(a),maxMetrics:u(M)}){}class QF extends ue()("AnalyticsRefreshConflict",{type:"urn:pubnio:problem:analytics-refresh-conflict",status:409,title:"Analytics refresh conflict"},{reason:j(["not_published","deleted","account_analytics_pending"])}){}class HF extends ue()("CapabilityUnverified",{type:"urn:pubnio:problem:capability-unverified",status:409,title:"Capability unverified"},{capability:yi,provider:qe}){}class VF extends ue()("InboxReplyWindowClosed",{type:"urn:pubnio:problem:inbox-reply-window-closed",status:409,title:"Inbox reply window closed"},{provider:qe,policy:iI,endsAt:D(a)}){}class JF extends ue()("InboxTargetChanged",{type:"urn:pubnio:problem:inbox-target-changed",status:409,title:"Inbox target changed"},{targetId:a,state:j(["deleted","changed","unsupported"])}){}class YF extends ue()("InboxSyncInProgress",{type:"urn:pubnio:problem:inbox-sync-in-progress",status:409,title:"Inbox sync already running"},{syncRunId:a.check(L()),retryAfterSeconds:M}){}class ZF extends ue()("InboxUnsupportedContent",{type:"urn:pubnio:problem:inbox-unsupported-content",status:422,title:"Inbox content unsupported"},{kind:j(["image","video","audio","file","text","unknown"]),capability:yi}){}var F3=[VF,JF,YF,ZF];class XF extends ue()("AdAccountNotReady",{type:"urn:pubnio:problem:ad-account-not-ready",status:409,title:"Ad account not ready"},{reason:j(["unavailable","needs_reconnect","permission_missing","account_disabled"]),missingScopes:u(U(a))}){}class eN extends ue()("AdAccountNotSelected",{type:"urn:pubnio:problem:ad-account-not-selected",status:409,title:"Ad account not selected"},{accountId:a}){}class tN extends ue()("AdInsightRangeInvalid",{type:"urn:pubnio:problem:ad-insight-range-invalid",status:422,title:"Ad insight range invalid"},{reason:j(["invalid_range","range_too_wide"]),maxDays:u(M)}){}class rN extends ue()("AdRefreshRateLimited",{type:"urn:pubnio:problem:ad-refresh-rate-limited",status:429,title:"Ad refresh rate limited"},{retryAfterSeconds:M.check(Pe(0))}){}class nN extends ue()("AdRevisionConflict",{type:"urn:pubnio:problem:ad-revision-conflict",status:409,title:"Ad resource revision conflict"},{resource:j(["spend_policy","campaign","ad_group","ad","boost"]),expectedRevision:M.check(Pe(0)),actualRevision:M.check(Pe(0)),nextAction:a}){}class oN extends ue()("AdBudgetExceeded",{type:"urn:pubnio:problem:ad-budget-exceeded",status:422,title:"Ad budget exceeds a spend cap"},{reason:j(["daily_cap","monthly_cap","campaign_daily_max","campaign_lifetime_max"]),limit:xt,requested:xt,committed:xt,nextAction:a}){}class iN extends ue()("AdBudgetBelowMinimum",{type:"urn:pubnio:problem:ad-budget-below-minimum",status:422,title:"Ad budget is below the provider minimum"},{minimum:xt,requested:xt,nextAction:a}){}class sN extends ue()("AdCurrencyMismatch",{type:"urn:pubnio:problem:ad-currency-mismatch",status:422,title:"Ad currency does not match the account"},{expected:Bn,actual:Bn,nextAction:a}){}class aN extends ue()("AdSpendForbidden",{type:"urn:pubnio:problem:ad-spend-forbidden",status:403,title:"Ad spend permission required"},{reason:j(["owner_required","api_key_forbidden","confirmation_required","monthly_cap_required","provider_managed"]),nextAction:a}){}class cN extends ue()("AdKillSwitchActive",{type:"urn:pubnio:problem:ad-kill-switch-active",status:409,title:"Ad kill switch is active"},{accountId:J,activatedAt:D(a),reason:D(a),nextAction:a}){}class pN extends ue()("AdOperationNotRetryable",{type:"urn:pubnio:problem:ad-operation-not-retryable",status:409,title:"Ad operation is not retryable"},{operationStatus:vu,nextAction:a}){}class dN extends ue()("AdProviderRejected",{type:"urn:pubnio:problem:ad-provider-rejected",status:422,title:"Ad provider rejected the request"},{provider:Ot,code:a,retryable:Y,providerCode:u(a),providerMessage:u(a),issues:U(lo),nextAction:a}){}class uN extends ue()("InvalidAdRequest",{type:"urn:pubnio:problem:invalid-ad-request",status:400,title:"Invalid ad request"},{reason:a,field:u(a),nextAction:a}){}var N3=[KF,qF,$F,WF,GF,HF];class B3 extends ue()("CommentTargetInvalid",{type:"urn:pubnio:problem:comment-target-invalid",status:400,title:"Comment target invalid"},{code:v("comment_target_invalid"),reason:a,targetKind:u(ku),nextAction:a}){}class K3 extends ue()("CommentRejected",{type:"urn:pubnio:problem:comment-rejected",status:422,title:"Comment rejected"},{code:v("comment_rejected"),provider:qe,targetKind:ku,nextAction:a}){}class q3 extends ue()("CommentUnresolved",{type:"urn:pubnio:problem:comment-unresolved",status:409,title:"Comment outcome unresolved"},{code:v("comment_unresolved"),actionId:mi,nextAction:a}){}var $3=[lF,yF,gF,wF,EF,kF,AF,vF,xF,SF,bF],W3=[zF,jF,QF],G3=[XF,eN,tN,rN,nN,oN,iN,sN,aN,cN,pN,dN,uN],z3=[CF,TF,OF,PF,RF,_F,UF,DF,MF,FF],j3=[LF];class lN extends ue()("InsufficientCredit",{type:"urn:pubnio:problem:insufficient-credit",status:402,title:"Insufficient prepaid credit"},{code:v("insufficient_credit"),balanceMicros:M,requiredMicros:M,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class fN extends ue()("SpendCapReached",{type:"urn:pubnio:problem:spend-cap-reached",status:402,title:"Monthly spend cap reached"},{code:v("spend_cap_reached"),capMicros:M,periodSpendMicros:M,estimatedMicros:M,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class mN extends ue()("BillingInactive",{type:"urn:pubnio:problem:billing-inactive",status:402,title:"Workspace billing is inactive"},{code:v("billing_inactive"),subscriptionStatus:yu,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class hN extends ue()("TopUpAmountInvalid",{type:"urn:pubnio:problem:top-up-amount-invalid",status:400,title:"Top-up amount is out of range"},{code:v("top_up_amount_invalid"),minMinor:M,maxMinor:M,nextAction:a}){}class yN extends ue()("InvalidBillingDateRange",{type:"urn:pubnio:problem:invalid-billing-date-range",status:400,title:"Invalid billing date range"},{code:v("invalid_billing_date_range"),nextAction:a}){}class gN extends ue()("BillingRevisionConflict",{type:"urn:pubnio:problem:billing-revision-conflict",status:409,title:"Billing settings changed concurrently"},{code:v("billing_revision_conflict"),expectedVersion:M,actualVersion:M,nextAction:a}){}class xN extends ue()("SubscriptionAlreadyActive",{type:"urn:pubnio:problem:subscription-already-active",status:409,title:"Subscription is already active"},{code:v("subscription_already_active"),plan:Zc,nextAction:a}){}class SN extends ue()("CheckoutAlreadyCompleted",{type:"urn:pubnio:problem:checkout-already-completed",status:409,title:"Checkout session already completed"},{code:v("checkout_already_completed"),checkoutId:a,nextAction:a}){}class bN extends ue()("BillingCustomerMissing",{type:"urn:pubnio:problem:billing-customer-missing",status:409,title:"No billing customer exists yet"},{code:v("billing_customer_missing"),nextAction:a}){}class IN extends ue()("BillingProviderMismatch",{type:"urn:pubnio:problem:billing-provider-mismatch",status:409,title:"Workspace billing gateway mismatch"},{code:v("billing_provider_mismatch"),workspaceGateway:Vm,requestedGateway:Vm,nextAction:a}){}class wN extends ue()("BillingNotConfigured",{type:"urn:pubnio:problem:billing-not-configured",status:503,title:"Billing gateway is not configured"},{code:v("billing_not_configured"),nextAction:a}){}class EN extends ue()("BillingUnavailable",{type:"urn:pubnio:problem:billing-unavailable",status:503,title:"Billing gateway is temporarily unavailable"},{code:v("billing_unavailable"),retryable:Y,nextAction:a}){}var Q3=[lN,fN,mN],H3=[...Q3,hN,yN,gN,xN,SN,bN,IN,wN,EN],V3=[rF,nF,oF,iF,sF,aF],kN=mt([ZM,XM,eF,tF,cF,pF,dF,uF,...$3,...H3,...z3,...j3,...V3,...F3,...N3,...W3,...G3,hF,NF,BF,IF]);var ka=j(["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]),AN=j(["count","milliseconds","ratio"]),vN=j(["sum","unique","latest","weighted","ratio"]),CN=j(["post","account"]),J3=j(["total","day"]),TN=j(["available","pending","unsupported","deprecated","renamed","permission_missing","access_pending","stale","deleted","private","not_applicable"]),Y3=Wt(a,yr),Ah=p({key:ka,value:D(yr),availability:TN,reason:u(a),replacedBy:u(ka),renamedTo:u(ka),missingScopes:u(U(a)),reconnectRequired:u(Y),retryAfter:u(a),observedAt:u(a),total:u(D(yr)),breakdown:u(Y3)}).annotate({identifier:"MetricReading"}),Z3=p({key:ka,scopes:U(CN),unit:AN,aggregation:vN,definition:a}).annotate({identifier:"MetricDefinition"}),X3=p({key:ka,scope:CN,granularity:J3,unit:AN,aggregation:vN,availability:TN,supported:Y,reason:u(a),renamedFrom:u(a),replacedBy:u(ka)}).annotate({identifier:"MetricCapability"}),e6=j(["ready","permission_required","access_pending","reconnect_required","disabled"]),t6=p({provider:qe,accountKinds:U(pr),placements:U(xr),metrics:U(X3),historyDays:M.check(Do(0)),latencySeconds:M.check(Pe(0)),firstAvailableAfterSeconds:M.check(Pe(0)),requiredScopes:U(a),comments:Y}).annotate({identifier:"ProviderCapabilities"}),r6=p({accountId:J,provider:qe,accountKind:pr,readiness:e6,capability:xi,missingScopes:U(a),reconnectRequired:Y,accessPending:Y}).annotate({identifier:"AnalyticsAccountCapability"}),ON=p({metrics:U(Z3),providers:U(t6),accounts:U(r6),checkedAt:a}).annotate({identifier:"AnalyticsCapabilities"}),n6=j(["fresh","stale","pending","partial","unavailable"]),vh=p({status:n6,observedAt:D(a),retryAfter:u(a)}).annotate({identifier:"AnalyticsFreshness"}),PN=p({from:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),to:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),timezone:v("UTC"),dayBasis:v("provider_utc")}).annotate({identifier:"AnalyticsDateRange"}),age=j(["provider_daily","snapshot_delta","provider_lifetime","provider_total"]),RN=p({date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),metrics:U(Ah)}).annotate({identifier:"AnalyticsPoint"}),o6=j(["available","pending","unavailable"]),i6=p({targetId:cr,attemptId:D(zt),accountId:J,provider:qe,placement:xr,providerPostId:D(a),publishedAt:D(a),state:o6,metrics:U(Ah),series:u(U(RN)),freshness:vh}).annotate({identifier:"PostAnalyticsTarget"}),RI=p({postId:_t,workspaceId:de,range:PN,targets:U(i6),freshness:vh}).annotate({identifier:"PostAnalytics"}),s6=p({accountId:J,provider:qe,accountKind:pr,profileId:bt,name:a,metrics:U(Ah),freshness:vh}).annotate({identifier:"AnalyticsAccountSummary"}),_N=p({accountId:J,workspaceId:de,provider:qe,accountKind:pr,profileId:bt,name:a,range:PN,metrics:U(Ah),series:u(U(RN)),freshness:vh}).annotate({identifier:"AccountAnalytics"}),UN=p({data:U(s6),...ze}).annotate({identifier:"AccountAnalyticsList"}),cge=p({workspaceId:de,postId:u(_t),targetId:u(cr),metrics:u(U(ka).check(oe(30)))}).check(Gt(({postId:e,targetId:t})=>e!==void 0||t!==void 0||"Send postId or targetId to refresh a published post.")),a6=j(["queued","running","succeeded","failed","paused","deleted","inaccessible"]),_I=p({id:a.check(L()),workspaceId:de,subjectKind:a,subjectId:a.check(L()),status:a6,nextDueAt:D(a),lastSuccessAt:D(a),errorKind:D(a),createdAt:a}).annotate({identifier:"AnalyticsRefresh"});var DN={name:"@pubnio/sdk",version:"0.2.7",description:"JavaScript and TypeScript client for the PubNio API",type:"module",exports:{".":"./src/index.ts","./solid":"./src/solid.ts","./internal":"./src/internal.ts","./package.json":"./package.json"},dependencies:{"@pubnio/protocol":"workspace:*",effect:"4.1.7"},peerDependencies:{"@tanstack/solid-query":"6.0.0-rc.6"},peerDependenciesMeta:{"@tanstack/solid-query":{optional:!0}},devDependencies:{"@hey-api/openapi-ts":"0.99.0","@tanstack/solid-query":"6.0.0-rc.6","dts-bundle-generator":"10.0.0",typescript:"6.0.3"},scripts:{pack:"bun script/pack.ts",build:"bun script/pack.ts"},sideEffects:!1,engines:{node:">=20.19.0"},publishConfig:{access:"public"},files:["dist","README.md"]};function LN({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:o,sseDefaultRetryDelay:i,sseMaxRetryAttempts:s,sseMaxRetryDelay:c,sseSleepFn:l,url:S,...m}){let g,w=l??((y)=>new Promise((h)=>setTimeout(h,y)));return{stream:async function*(){let y=i??3000,h=0,x=m.signal??new AbortController().signal;while(!0){if(x.aborted)break;h++;let G=m.headers instanceof Headers?m.headers:new Headers(m.headers);if(g!==void 0)G.set("Last-Event-ID",g);try{let X={redirect:"follow",...m,body:m.serializedBody,headers:G,signal:x},I=new Request(S,X);if(e)I=await e(S,X);let pe=await(m.fetch??globalThis.fetch)(I);if(!pe.ok)throw Error(`SSE failed: ${pe.status} ${pe.statusText}`);if(!pe.body)throw Error("No body in SSE response");let K=pe.body.pipeThrough(new TextDecoderStream).getReader(),ee="",Q=()=>{try{K.cancel()}catch{}};x.addEventListener("abort",Q);try{while(!0){let{done:te,value:re}=await K.read();if(te)break;ee+=re,ee=ee.replace(/\r\n?/g,`
35
+ `)n.push(y),o=!1;k++}else if(A==="'"||A==='"')s=A,c=l,n.push(""),o=!1;else{let h=vQ(A,y,n.length===0);if(h!==void 0)return S("UnsupportedSyntax",h);if(A==="{")i++;else if(A==="}"){if(i>0)i--}else if(i>0&&(A===","||A==="."&&y==="."))return S("UnsupportedSyntax","Brace expansion needs a shell");else if(A==="="&&r.length===0&&o&&AQ.test(n.join("")))return S("UnsupportedSyntax","A variable assignment needs a shell");n.push(A)}}return};for(;l<e.length;l++){let w=g(e[l]);if(w!==void 0)return w;if(l===t.length)break;let k=t[l];if(Array.isArray(k)){let A=e[l+1][0];if(n.length>0||(A===void 0?l+1<t.length:!BS(A)))return S("UnsupportedSyntax","An interpolated array must be a separate argument");for(let y of k)r.push(j0(y))}else n.push(j0(k)),o=!1}if(s!==void 0)return S("UnterminatedQuote","The quote is not closed",c);return m(),Zt(r)};var J0="~effect/process/ChildProcess",TQ={...Ui({label:"Command",evaluate(e){return Wp(e.context,Bc).spawn(this)}}),[J0]:J0};var Xd=(e,t,r)=>Object.assign(Object.create(TQ),{_tag:"StandardCommand",command:e,args:t,options:r});var vm=function(...t){if(Y0(t[0])){let[i,...s]=t,[c,l]=Z0(i,s);return Xd(c,l,{})}if(typeof t[0]==="object"&&!Array.isArray(t[0])&&!Y0(t[0])){let i=t[0];return function(s,...c){if(i.shell!==void 0&&i.shell!==!1)return Xd(OQ(s,c),[],i);let[l,S]=Z0(s,c);return Xd(l,S,i)}}if(typeof t[0]==="string"&&!Array.isArray(t[1])){let[i,s={}]=t;return Xd(i,[],s)}let[r,n=[],o={}]=t;return Xd(r,n,o)};var Y0=(e)=>Array.isArray(e)&&("raw"in e)&&Array.isArray(e.raw),Cm=(e)=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let r=parseInt(t[1],10);return r>=3?r:void 0},X0=(e)=>`fd${e}`,Z0=(e,t)=>{let[r="",...n]=mg(H0(e,...t));if(typeof r!=="string")throw new da({reason:"InvalidArgument",message:"The program name of a command cannot be Redacted"});return[r,n]},OQ=(e,t)=>{if(t.length>0)throw new da({reason:"UnsupportedSyntax",message:"A shell template cannot interpolate values; build the script with CommandLine.quote"});let r=e[0];if(r===void 0)throw new da({reason:"InvalidEscape",message:"Template part 0 contains an invalid escape sequence"});return r};import*as Rm from"child_process";import{PassThrough as KS}from"stream";var e_=(e,t,r)=>{let n=e.detached??r!=="win32";return{...t,detached:n,shell:e.shell,windowsHide:e.windowsHide??!n}};var ct=(e,t)=>(r,[n])=>{let o="Unknown";switch(r.code){case"ENOENT":o="NotFound";break;case"EACCES":case"EPERM":o="PermissionDenied";break;case"EEXIST":o="AlreadyExists";break;case"EISDIR":o="BadResource";break;case"ENOTDIR":o="BadResource";break;case"EBUSY":o="Busy";break;case"ELOOP":o="BadResource";break}return Xn({_tag:o,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})};import{finished as t_}from"stream";var Tm=(e,t,r)=>{if(!("closed"in e)){t(),r?.();return}let n=()=>{clearImmediate(i),e.off("error",n),e.off("close",n),r?.()},o=()=>{if(e.closed)n();else if(i=setImmediate(o),!r)i.unref()},i=setImmediate(o);if(!r)i.unref();if(e.once("error",n),e.once("close",n),t(),!e.closed)e.destroy()};var $c=(e)=>jx(qx(RQ(e),(t)=>[t])),RQ=(e)=>Ar((t)=>{let r=e.evaluate(),n=UQ({...e,writable:r,pull:t});return z(e.endOnDone===!1?n:oi(n,(o)=>ri(o)?Je:_Q(r)))}),_Q=(e)=>nn((t)=>{let r=()=>t(Je);if(e.closed){let n=t_(e,{readable:!1},()=>{n(),r()})}else Tm(e,Wo,r)}),UQ=(e)=>kc((t)=>{let r=t.currentDispatcher,n=Eo(),o=Eo(),i=(S)=>Vn(o,vf(()=>e.onError(S))),s=!1,c=(S)=>{s=!0,i(S)};e.writable.on("error",c);let l=t_(e.writable,{readable:!1},(S)=>{if(S)i(S);else Vn(n,Je)});return e.pull.pipe(Ae((S)=>{let m=0;return nn((g)=>{let w=!1,k=()=>r.scheduleTask(A,0),A=()=>{e.writable.off("drain",A),e.writable.off("finish",k);for(;m<S.length;){if(w)return;if(!e.writable.write(S[m++],e.encoding,(h)=>{if(!h)return;if(e.writable.closed)i(h);else r.scheduleTask(()=>i(h),0)})){if(!w)e.writable.once("drain",A),e.writable.once("finish",k);return}}if(!w)g(Je)};return A(),Be(()=>{w=!0,e.writable.off("drain",A),e.writable.off("finish",k)})})}),Co({disableYield:!0}),e.endOnDone!==!1?Yn((S)=>(e.writable.end(),Zn(zr(n),hr(S)))):Ee,Un(zr(o)),vo(Be(()=>{l();let S=()=>{e.writable.off("error",c),e.writable.off("error",S),e.writable.off("close",S)};if(e.writable.errored&&!e.writable.closed&&!s)e.writable.once("error",S),e.writable.once("close",S);else S()})))});import{finished as LQ,Readable as Rse}from"stream";var Wc=(e)=>on(MQ(e)),MQ=(e)=>Ar((t,r)=>FQ({scope:r,readable:e.evaluate(),onError:e.onError??NQ,chunkSize:e.chunkSize,readSize:e.readSize,closeOnDone:e.closeOnDone}));var FQ=(e)=>{let t=e.readable,r=e.chunkSize??4096,n=e.closeOnDone??!0,o=e.exit??cP(void 0),i=e.latch??iP(!1);function s(){i.openUnsafe()}t.on("readable",s);let c=LQ(t,{readable:!0,writable:!1},(S)=>{o.current??=_n(S?e.onError(S):ld()),i.openUnsafe()}),l=Ve(function S(){let m=e.readable.read(e.readSize);if(m===null){if(o.current)return o.current;if(t.readableEnded)return he(ld());return i.closeUnsafe(),Ae(i.await,S)}let g=Li(m);while(g.length<r){if(m=e.readable.read(e.readSize),m===null)break;g.push(m)}return z(g)});return sr(cd(e.scope,Be(()=>{if(t.off("readable",s),n)Tm(t,c);else c()})),l)};var NQ=(e)=>new hO(e);var ua=(e)=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),oo=(e,t,r)=>{let{commands:n}=WS(r),o=globalThis.process.platform==="win32"?"windows":"posix",i=n.map((s)=>Q0([s.command,...s.args],{format:o})).join(" | ");return ct("ChildProcess",e)(t,[i])},Pm=(e)=>no(e)?Kc(e):e,KQ=(e)=>{if(e.command.includes("\x00"))return"The command contains a NUL character";let t=e.args.findIndex((r)=>Pm(r).includes("\x00"));if(t!==-1)return`Argument ${t+1} contains a NUL character`;for(let[r,n]of Object.entries(e.options.env??{}))if(n!==void 0&&Pm(n).includes("\x00"))return`The environment variable ${r} contains a NUL character`;return},r_=1000,qQ=10,n_=(e)=>{let t=()=>{};e.on("error",t),e.once("close",()=>e.off("error",t))},qS=(e)=>e.exitCode!==null||e.signalCode!==null,Om=(e)=>globalThis.process.platform!=="win32"&&e.options.detached!==!1,i_=(e)=>e?.code==="EPERM",o_=(e,t)=>{if(t.lost===!0)return!1;if(!qS(t))return!0;if(!Om(e))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(r){return i_(r)}},$Q=(e,t=()=>{})=>{if(qS(e)){t(null);return}Rm.execFile("taskkill",["/pid",String(e.pid),"/T","/F"],{windowsHide:!0},t)},WQ=(e,t,r,n)=>{let o=Rm.spawn(e,t,r);for(let i of n){let s=o.stdio[i];if(s&&"allowHalfOpen"in s)s.allowHalfOpen=!0}return o},GQ=Ie(function*(e){let t=yield*Od,r=yield*ea,n=Ie(function*(K){if(ja(K.cwd))return;return yield*t.access(K.cwd),r.resolve(K.cwd)}),o=(K)=>{if(K.env===void 0)return;let ee=K.extendEnv===!0?{...globalThis.process.env}:{};for(let[Q,te]of Object.entries(K.env))if(te===void 0)delete ee[Q];else ee[Q]=Pm(te);return ee},i=(K)=>Zs(K)?"pipe":K,s=(K)=>vd(K)?"pipe":K,c=(K)=>{let ee={stream:"pipe",encoding:"utf-8",endOnDone:!0};if(ja(K.stdin))return ee;if(typeof K.stdin==="string")return{...ee,stream:K.stdin};if(Zs(K.stdin))return{...ee,stream:K.stdin};return{stream:K.stdin.stream,encoding:K.stdin.encoding??ee.encoding,endOnDone:K.stdin.endOnDone??ee.endOnDone}},l=(K,ee)=>{let Q=K[ee];if(ja(Q))return{stream:"pipe"};if(typeof Q==="string")return{stream:Q};if(vd(Q))return{stream:Q};return{stream:Q.stream}},S=(K)=>{if(ja(K.additionalFds))return[];let ee=[];for(let[Q,te]of Object.entries(K.additionalFds)){let re=Cm(Q);if(Jt(re))ee.push({fd:re,config:te})}return ee.sort((Q,te)=>Q.fd-te.fd)},m=(K,ee,Q,te)=>{let re=[i(K.stream),s(ee.stream),s(Q.stream)];if(te.length===0)return re;let ae=te.reduce((se,{fd:le})=>Math.max(se,le),2);for(let se=3;se<=ae;se++)re[se]="ignore";for(let{fd:se}of te)re[se]="pipe";return re},g=(K,ee,Q)=>Uf(uR(cR(K,(te)=>rO(Q,te)),ee)),w=Ie(function*(K,ee,Q,te){if(Q.length===0)return{getInputFd:()=>Cd,getOutputFd:()=>Rc};let re=new Map,ae=new Map,se=(Se,ve,ye)=>Ve(()=>{let $e=Cd;if(ve&&"write"in ve)n_(ve),$e=$c({evaluate:()=>ve,onError:(_e)=>oo(`fromWritable(fd${Se})`,ua(_e),K)});if(ye)return De(g(ye,$e,te),()=>{re.set(Se,$e)});return re.set(Se,$e),Je}),le=(Se,ve,ye)=>{let $e=Rc;if(ve&&"read"in ve){let _e=new KS,rr=void 0;_e.on("error",(Nr)=>{rr??=Nr}),ve.on("error",(Nr)=>_e.destroy(Nr)),ve.pipe(_e);let lr=(Nr)=>oo(`fromReadable(fd${Se})`,ua(Nr),K);$e=iR(()=>rr===void 0?Wc({evaluate:()=>_e,onError:lr}):Jx(lr(rr)))}if(ye)$e=Hf($e,ye);ae.set(Se,$e)};for(let{config:Se,fd:ve}of Q){let ye=ee.stdio[ve];switch(Se.type){case"input":{yield*se(ve,ye,Se.stream);break}case"output":{le(ve,ye,Se.sink);break}case"duplex":{le(ve,ye,Se.sink),yield*se(ve,ye,Se.stream);break}}}return{getInputFd:(Se)=>re.get(Se)??Cd,getOutputFd:(Se)=>ae.get(Se)??Rc}}),k=(K,ee,Q,te)=>Ve(()=>{let re=Cd;if(bl(ee.stdin))n_(ee.stdin),re=$c({evaluate:()=>ee.stdin,onError:(ae)=>oo("fromWritable(stdin)",ua(ae),K),endOnDone:Q.endOnDone,encoding:Q.encoding});if(Zs(Q.stream))return sr(g(Q.stream,re,te),re);return z(re)}),A=(K,ee,Q,te)=>{let re=ee.stdout?(()=>{let le=new KS;return ee.stdout.on("error",(Se)=>le.destroy(Se)),ee.stdout.pipe(le),Wc({evaluate:()=>le,onError:(Se)=>oo("fromReadable(stdout)",ua(Se),K)})})():Rc,ae=ee.stderr?(()=>{let le=new KS;return ee.stderr.on("error",(Se)=>le.destroy(Se)),ee.stderr.pipe(le),Wc({evaluate:()=>le,onError:(Se)=>oo("fromReadable(stderr)",ua(Se),K)})})():Rc;if(vd(Q.stream))re=Hf(re,Q.stream);if(vd(te.stream))ae=Hf(ae,te.stream);let se=aR(re,ae);return{stdout:re,stderr:ae,all:se}},y=(K,ee,Q,te)=>nn((re)=>{let ae=Eo(),se=K(ee.command,ee.args.map(Pm),Q,te);return se.on("error",(le)=>{if(ee.args.some(no))Object.assign(le,{spawnargs:[ee.command,...ee.args.map((Se)=>no(Se)?"<redacted>":Se)]});re(he(oo("spawn",le,ee)))}),se.on("exit",(...le)=>{Vn(ae,Gs(le))}),se.on("lost",(le)=>{Vn(ae,_n(oo("exitCode",le,ee)))}),se.on("spawn",()=>{re(z([se,ae]))}),Be(()=>{se.kill("SIGTERM")})}),h=(K,ee,Q)=>{if(globalThis.process.platform==="win32")return nn((te)=>{$Q(ee,(re)=>{if(re)te(he(oo("kill",ua(re),K)));else te(Je)})});return Pr({try:()=>{globalThis.process.kill(-ee.pid,Q)},catch:(te)=>oo("kill",ua(te),K)})},x=(K,ee)=>{try{globalThis.process.kill(-K.pid,ee)}catch{}},G=(K,ee,Q)=>Ve(()=>{if(!ee.kill(Q)){let re=new globalThis.Error("Failed to kill child process");return he(oo("kill",re,K))}return Je}),X=(K,ee,Q)=>nn((te)=>{let re=Date.now()+Q,ae,se=()=>{clearTimeout(ae),ee.removeListener("exit",le),ee.removeListener("lost",le)},le=()=>{if(clearTimeout(ae),Date.now()>=re||!o_(K,ee)){se(),te(Je);return}ae=setTimeout(le,qQ)};return ee.on("exit",le),ee.on("lost",le),le(),Be(se)}),I=Ie(function*(K,ee,Q,te){let re=(ae)=>globalThis.process.platform==="win32"||Om(K)?h(K,ee,ae).pipe(Qs((se)=>qS(ee)&&i_(se.cause)?Je:G(K,ee,ae))):G(K,ee,ae);if(yield*re(te?.killSignal??"SIGTERM"),ja(te?.forceKillAfter))yield*zr(Q),yield*X(K,ee,r_);else if(yield*X(K,ee,Gl(te.forceKillAfter)),o_(K,ee))yield*re("SIGKILL"),yield*X(K,ee,r_);yield*zr(Q)}),me=(K,ee)=>{let Q=ee??"stdout";switch(Q){case"stdout":return K.stdout;case"stderr":return K.stderr;case"all":return K.all;default:{let te=Cm(Q);if(Jt(te))return K.getOutputFd(te);return K.stdout}}},pe=Ie(function*(K){switch(K._tag){case"StandardCommand":{if(K.options.shell!==void 0&&K.options.shell!==!1&&K.args.length>0)return yield*he(mn({module:"ChildProcess",method:"spawn",description:"The shell option cannot be combined with arguments; pass the whole script as the command"}));let ee=KQ(K);if(ee!==void 0)return yield*he(mn({module:"ChildProcess",method:"spawn",description:ee}));let Q=c(K.options),te=l(K.options,"stdout"),re=l(K.options,"stderr"),ae=S(K.options),se=!0,le=yield*n(K.options),Se=o(K.options),ve=m(Q,te,re,ae),ye=ae.flatMap(({config:wr,fd:An})=>wr.type==="duplex"?[An]:[]),$e=Ie(function*(wr,An){if(wr.lost===!0||!se)return;if(xf(An)){let[Ko]=yield*Ao(zr(An));if((Ko===0||zA(Ko))&&!Om(K))return}yield*gx(I(K,wr,An,K.options))}),_e=yield*e,rr=Bi(),[lr,Nr]=yield*Dn(y(_e,K,e_(K.options,{cwd:le,env:Se,stdio:ve},process.platform),ye),([wr,An],Ko)=>Ec([en(rr,Ko),$e(wr,An)],{concurrency:"unbounded",discard:!0})),ws=$0(lr.pid);if(Om(K))lr.on("exit",(wr)=>{if(se&&wr!==0&&bl(wr))x(lr,K.options.killSignal??"SIGTERM")});let Es=Be(()=>{if(!se)lr.ref(),se=!0}),ks=Be(()=>{if(se)lr.unref(),se=!1;return Es}),yo=Eo(),al=yield*Ki(rr)(k(K,lr,Q,yo)),{all:cl,stderr:pl,stdout:dl}=A(K,lr,te,re),{getInputFd:ul,getOutputFd:ll}=yield*Ki(rr)(w(K,lr,ae,yo)),fl=Ve(()=>xf(Nr)?sr(zr(Nr),!1):z(!0)),ml=Ae(Un(zr(Nr),zr(yo)),([wr,An])=>{if(xf(yo))return zr(yo);if(bl(wr))return z(q0(wr));let Ko=new globalThis.Error(`Process interrupted due to receipt of signal: '${An}'`);return he(oo("exitCode",Ko,K))});return NS({pid:ws,exitCode:ml,isRunning:fl,kill:(wr)=>I(K,lr,Nr,wr),stdin:al,stdout:dl,stderr:pl,all:cl,getInputFd:ul,getOutputFd:ll,unref:ks})}case"PipedCommand":{let{commands:ee,pipeOptions:Q}=WS(K),[te,...re]=ee,ae=[yield*pe(te)];for(let ve=0;ve<re.length;ve++){let ye=re[ve],$e=Q[ve]??{},_e=c(ye.options),rr=Po(z(me(ae[ae.length-1],$e.from))),lr=$e.to??"stdin";if(lr==="stdin")ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,stdin:{..._e,stream:rr}})));else{let Nr=Cm(lr);if(Jt(Nr)){let ws=X0(Nr),Es=ye.options.additionalFds??{},ks=Es[ws],yo=ks?.type==="duplex"?{...ks,stream:rr}:{type:"input",stream:rr};ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,additionalFds:{...Es,[ws]:yo}})))}else ae.push(yield*pe(vm(ye.command,ye.args,{...ye.options,stdin:{..._e,stream:rr}})))}}let se=ae[ae.length-1],le=(ve)=>zi([...ae].reverse(),(ye)=>gx(ye.kill(ve)),{discard:!0}),Se=kr(function*(){let ve=[];for(let ye of ae)ve.push(yield*ye.unref);return zi([...ve].reverse(),(ye)=>ye,{discard:!0})});return NS({pid:se.pid,exitCode:se.exitCode,isRunning:se.isRunning,kill:le,stdin:ae[0].stdin,stdout:se.stdout,stderr:se.stderr,all:se.all,getInputFd:se.getInputFd,getOutputFd:se.getOutputFd,unref:Se})}}});return W0(pe)}),$S=Ic(Bc,GQ(z(WQ)));var WS=(e)=>{let t=[],r=[],n=(c)=>{switch(c._tag){case"StandardCommand":{t.push(c);break}case"PipedCommand":{n(c.left),r.push(c.options),n(c.right);break}}};if(n(e),t.length===0)throw Error("flattenCommand produced empty commands array");let[o,...i]=t;return{commands:[o,...i],pipeOptions:r}};import*as c_ from"crypto";import*as we from"fs";import*as p_ from"os";import*as li from"path";var gt=(e)=>(t)=>mn({module:"FileSystem",method:e,description:t.message??String(t)}),d_=(e,t)=>{let r=Number(e);if(!Number.isSafeInteger(r))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return r},s_=(e)=>ig(Ns(e),LO),u_=(e)=>BigInt.asUintN(64,e),GS=(e)=>Dl(Ns(e),u_),jQ=(e,t)=>Pr({try:()=>d_(e,"position"),catch:gt(t)}),QQ=(()=>{let e=Rt(we.access,ct("FileSystem","access"),gt("access"));return(t,r)=>{let n=we.constants.F_OK;if(r?.readable)n|=we.constants.R_OK;if(r?.writable)n|=we.constants.W_OK;return e(t,n)}})(),HQ=(()=>{let e=Rt(we.cp,ct("FileSystem","copy"),gt("copy"));return(t,r,n)=>e(t,r,{force:n?.overwrite??!1,preserveTimestamps:n?.preserveTimestamps??!1,recursive:!0})})(),VQ=(()=>{let e=Rt(we.copyFile,ct("FileSystem","copyFile"),gt("copyFile"));return(t,r)=>e(t,r)})(),JQ=(()=>{let e=Rt(we.chmod,ct("FileSystem","chmod"),gt("chmod"));return(t,r)=>e(t,r)})(),YQ=(()=>{let e=Rt(we.chown,ct("FileSystem","chown"),gt("chown"));return(t,r,n)=>e(t,r,n)})(),ZQ=(()=>{let e=Rt(we.link,ct("FileSystem","link"),gt("link"));return(t,r)=>e(t,r)})(),XQ=(()=>{let e=Rt(we.mkdir,ct("FileSystem","makeDirectory"),gt("makeDirectory"));return(t,r)=>e(t,{recursive:r?.recursive??!1,mode:r?.mode})})(),zS=(e)=>{let t=Rt(we.mkdtemp,ct("FileSystem",e),gt(e));return(r)=>Ve(()=>{let n=r?.prefix??"",o=typeof r?.directory==="string"?li.join(r.directory,"."):p_.tmpdir();return t(n?li.join(o,n):o+"/")})},eH=zS("makeTempDirectory"),jS=(e)=>{let t=Rt(we.rm,ct("FileSystem",e),gt(e));return(r,n)=>t(r,{recursive:n?.recursive??!1,force:n?.force??!1})},tH=jS("remove"),rH=(()=>{let e=zS("makeTempDirectoryScoped"),t=jS("makeTempDirectoryScoped");return(r)=>Dn(e(r),(n)=>Ao(t(n,{recursive:!0,force:!0})))})(),nH=(e)=>{let{O_APPEND:t,O_CREAT:r,O_EXCL:n,O_RDONLY:o,O_RDWR:i,O_TRUNC:s,O_WRONLY:c}=we.constants;switch(e){case"r":return o;case"r+":return i;case"w":return s|r|c;case"wx":return s|r|c|n;case"w+":return s|r|i;case"wx+":return s|r|i|n;case"a":return t|r|c;case"ax":return t|r|c|n;case"a+":return t|r|i;case"ax+":return t|r|i|n}},oH=(e,t)=>Ve(()=>{let{O_NOFOLLOW:r}=we.constants;if(process.platform==="win32"||typeof r!=="number"||r===0)return he(mn({module:"FileSystem",method:e,description:"noFollow is not supported on this platform"}));return z(nH(t)|r)}),iH=(e)=>{let t=Rt(we.open,ct("FileSystem",e),gt(e)),r=Rt(we.close,ct("FileSystem",e),gt(e));return(n,o)=>Oi(Dn(o?.noFollow===!0?Ae(oH(e,o.flag??"r"),(i)=>t(n,i,o.mode)):t(n,o?.flag??"r",o?.mode),(i)=>Ao(r(i))),De((i)=>cH(i,o?.flag?.startsWith("a")??!1)))},sH=iH("open"),aH=(e)=>e.reason.cause?.code==="ESPIPE",a_=(e)=>mn({module:"FileSystem",method:e,description:"Cannot read before the start of the file"}),cH=(()=>{let e=(m)=>Rt(we.read,ct("FileSystem",m),gt(m)),t=e("read"),r=e("readAlloc"),n=Rt(we.fstat,ct("FileSystem","stat"),gt("stat")),o=Rt(we.ftruncate,ct("FileSystem","truncate"),gt("truncate")),i=Rt(we.fsync,ct("FileSystem","sync"),gt("sync")),s=(m)=>{let g=Rt(we.write,ct("FileSystem",m),gt(m));return(w,k,A)=>g(w,k,0,k.length,A)},c=s("write"),l=s("writeAll");class S{[Vf];fd;append;position=BigInt(0);sequential=!1;constructor(m,g){this[Vf]=Vf,this.fd=m,this.append=g}get stat(){return Ae(n(this.fd,{bigint:!0}),m_)}get sync(){return i(this.fd)}atCursor(m){return Ve(()=>{if(this.sequential)return m(null);let g=this.position;return Qi(De(m(g),(w)=>(this.position=g+BigInt(w),w)),aH,()=>(this.sequential=!0,m(null)))})}writeOnce(m,g,w){return this.append?Ve(()=>g(this.fd,w,void 0)):this.atCursor((k)=>k===null?g(this.fd,w,void 0):Ae(jQ(k,m),(A)=>g(this.fd,w,A)))}seek(m,g){return Ve(()=>{let w=g==="start"?m:this.position+m;if(w<BigInt(0))return he(mn({module:"FileSystem",method:"seek",description:"Cannot seek before the start of the file"}));return this.position=w,z(w)})}read(m,g){return Ve(()=>{let w=g?.position;if(w===void 0)return this.atCursor((k)=>t(this.fd,{buffer:m,position:k}));return w<BigInt(0)?he(a_("read")):t(this.fd,{buffer:m,position:w})})}readAlloc(m,g){return Ve(()=>{try{if(!Number.isInteger(m)||m<0)throw RangeError("size must be a non-negative integer");let w=g?.position;if(w!==void 0&&w<BigInt(0))return he(a_("readAlloc"));let k=Buffer.allocUnsafeSlow(m),A=(y)=>r(this.fd,{buffer:k,position:y});return De(w===void 0?this.atCursor(A):A(w),(y)=>{if(y===0)return ge();if(y===m)return Ue(k);let h=Buffer.allocUnsafeSlow(y);return k.copy(h,0,0,y),Ue(h)})}catch(w){return he(gt("readAlloc")(w))}})}truncate(m){return De(o(this.fd,m||void 0),()=>{if(!this.append){let g=BigInt(m??0);if(this.position>g)this.position=g}})}write(m){return this.writeOnce("write",c,m)}writeAllChunk(m){return Ae(this.writeOnce("writeAll",l,m),(g)=>{if(g===0)return he(Xn({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"}));return g<m.length?this.writeAllChunk(m.subarray(g)):Je})}writeAll(m){return m.length===0?Je:this.writeAllChunk(m)}}return(m,g)=>new S(m,g)})(),l_=(e)=>{let t=zS(e);return Ie(function*(r){let n=yield*t(r),o=c_.randomBytes(6).toString("hex"),i=li.join(n,r?.suffix?`${o}${r.suffix}`:o);return yield*y_(i,new Uint8Array(0)),i})},pH=l_("makeTempFile"),dH=(()=>{let e=l_("makeTempFileScoped"),t=jS("makeTempFileScoped");return(r)=>Dn(e(r),(n)=>Ao(t(li.dirname(n),{recursive:!0,force:!0})))})(),uH=(e,t)=>zs({try:()=>we.promises.readdir(e,t),catch:(r)=>ct("FileSystem","readDirectory")(r,[e])}),lH=(e)=>zs({try:()=>we.promises.readdir(e,{withFileTypes:!0}),catch:(t)=>ct("FileSystem","readDirectoryEntries")(t,[e])}).pipe(De((t)=>t.map((r)=>({name:r.name,type:f_(r)})))),fH=(e)=>nn((t,r)=>{try{we.readFile(e,{signal:r},(n,o)=>{if(n)t(he(ct("FileSystem","readFile")(n,[e])));else t(z(o))})}catch(n){t(he(gt("readFile")(n)))}}),mH=(()=>{let e=Rt(we.readlink,ct("FileSystem","readLink"),gt("readLink"));return(t)=>e(t)})(),hH=(()=>{let e=Rt(process.platform==="win32"?we.realpath.native:we.realpath,ct("FileSystem","realPath"),gt("realPath"));return(t)=>e(t)})(),yH=(()=>{let e=Rt(we.rename,ct("FileSystem","rename"),gt("rename"));return(t,r)=>e(t,r)})(),f_=(e)=>e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",m_=(e,t="stat")=>Pr({try:()=>({type:f_(e),mtime:Ns(e.mtime),atime:Ns(e.atime),birthtime:Ns(e.birthtime),dev:u_(e.dev),rdev:GS(e.rdev),ino:GS(e.ino),mode:d_(e.mode,"mode"),nlink:GS(e.nlink),uid:s_(e.uid),gid:s_(e.gid),size:Ax(e.size),blksize:e.blksize!==void 0?Ue(Ax(e.blksize)):ge(),blocks:Ns(e.blocks)}),catch:gt(t)}),h_=(e,t)=>{let r=Rt(t,ct("FileSystem",e),gt(e));return(n)=>Ae(r(n,{bigint:!0}),(o)=>m_(o,e))},QS=h_("stat",we.stat),gH=h_("lstat",we.lstat),xH=(()=>{let e=Rt(we.symlink,ct("FileSystem","symlink"),gt("symlink"));return(t,r)=>e(t,r)})(),SH=(()=>{let e=Rt(we.truncate,ct("FileSystem","truncate"),gt("truncate"));return(t,r)=>e(t,r)})(),bH=(()=>{let e=Rt(we.utimes,ct("FileSystem","utime"),gt("utime"));return(t,r,n)=>e(t,r,n)})(),IH=(e,t,r)=>oR((n)=>Dn(Be(()=>{let o=t.type==="Directory"?e:li.dirname(e),i=we.watch(e,{recursive:r?.recursive??!1},(s,c)=>{if(!c)return;switch(s){case"rename":{Df(CO(QS(li.resolve(o,c)),{onSuccess:(l)=>wd(n,{_tag:"Create",path:c}),onFailure:(l)=>wd(n,{_tag:"Remove",path:c})}));return}case"change":{Zi(n,{_tag:"Update",path:c});return}}});return i.on("error",(s)=>{Ed(n,mO(Xn({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:e,cause:s})))}),i.on("close",()=>{Oo(n)}),i}),(o)=>Be(()=>o.close())).pipe(ji(()=>Be(()=>r?.onReady?.())))),wH=(e,t,r)=>Ec([QS(t),Tf(Jf)]).pipe(De(([n,o])=>Rv(o,()=>e).pipe(ig((i)=>i.register(t,n,r)),fr(()=>IH(t,n,r)))),Po),y_=(e,t,r)=>nn((n,o)=>{try{we.writeFile(e,t,{signal:o,flag:r?.flag,mode:r?.mode},(i)=>{if(i)n(he(ct("FileSystem","writeFile")(i,[e])));else n(Je)})}catch(i){n(he(gt("writeFile")(i)))}}),EH=De(Tf(Jf),(e)=>hR({access:QQ,chmod:JQ,chown:YQ,copy:HQ,copyFile:VQ,link:ZQ,lstat:gH,makeDirectory:XQ,makeTempDirectory:eH,makeTempDirectoryScoped:rH,makeTempFile:pH,makeTempFileScoped:dH,open:sH,readDirectory:uH,readDirectoryEntries:lH,readFile:fH,readLink:mH,realPath:hH,remove:tH,rename:yH,stat:QS,symlink:xH,truncate:SH,utimes:bH,watch(t,r){return wH(e,t,r)},writeFile:y_})),g_=Ic(Od)(EH);var x_=g_;import*as eu from"path";import*as _m from"url";var HS=(e)=>({fromFileUrl:(t)=>Pr({try:()=>_m.fileURLToPath(t,{windows:e}),catch:(r)=>new Id({module:"Path",method:"fromFileUrl",cause:r})}),toFileUrl:(t)=>Pr({try:()=>_m.pathToFileURL(t,{windows:e}),catch:(r)=>new Id({module:"Path",method:"toFileUrl",cause:r})})}),vH=bc(ea)(Yf({...eu.posix,...HS(!1)})),CH=bc(ea)(Yf({...eu.win32,...HS(!0)})),S_=bc(ea)(Yf({...eu,...HS(void 0)}));var b_=S_;var VS="~effect/Stdio",I_=Ht(VS),w_=(e)=>({[VS]:VS,stdinIsTerminal:z(!1),stdoutIsTerminal:z(!1),stderrIsTerminal:z(!1),...e});var PH=Be(()=>{process.nextTick(()=>{if(process.stdin.readableFlowing===null)process.stdin.pause()})}),k_=bc(I_,w_({args:Be(()=>process.argv.slice(2)),stdinIsTerminal:Be(()=>process.stdin.isTTY===!0),stdoutIsTerminal:Be(()=>process.stdout.isTTY===!0),stderrIsTerminal:Be(()=>process.stderr.isTTY===!0),stdout:(e)=>$c({evaluate:()=>process.stdout,onError:(t)=>Xn({module:"Stdio",method:"stdout",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stderr:(e)=>$c({evaluate:()=>process.stderr,onError:(t)=>Xn({module:"Stdio",method:"stderr",_tag:"Unknown",cause:t}),endOnDone:e?.endOnDone??!1}),stdin:Po(sr(vc(()=>PH),Wc({evaluate:()=>process.stdin,onError:(e)=>Xn({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})))}));var A_=k_;var v_="~effect/http/Cookies";var C_="~effect/http/Cookies/Cookie";var UH={[v_]:v_,..._i,toJSON(){return{_id:"effect/Cookies",cookies:Gv(this.cookies,(e)=>e.toJSON())}},pipe(){return et(this,arguments)}},DH=(e)=>{let t=Object.create(UH);return t.cookies=e,t},LH=(e)=>{let t={};for(let r of e)Zr(t,r.name,r);return DH(t)};var T_=LH([]);var Yse={[C_]:C_,..._i,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};var P_=Symbol.for("~effect/http/Headers");var Um=Object.defineProperties(Object.create(null),{[P_]:{value:P_},[Ps]:{value(e){return FH(this,dn(e,NH))}},toJSON:{value(){return zn(this)}},[At]:{value(e){return MH(this,e)}},[kt]:{value(){return Cp(this)}},toString:{value:_i.toString},[Xr]:{value:_i[Xr]}});var MH=jv(yv()),la=Object.create(Um),R_=(e)=>{if(e===void 0)return la;else if(Symbol.iterator in e){let r=Object.create(Um);for(let[n,o]of e){let i=n.toLowerCase();r[i]=i in r?`${r[i]}, ${o}`:o}return r}let t=Object.create(Um);for(let[r,n]of Object.entries(e))if(Array.isArray(n))t[r.toLowerCase()]=n.join(", ");else if(n!==void 0)t[r.toLowerCase()]=n;return t},__=(e)=>Object.setPrototypeOf(e,Um);var FH=q(2,(e,t)=>{let r={...e},n=(o)=>{if(typeof o==="string"){let i=o.toLowerCase();if(i in e)r[i]=pa(e[i])}else for(let i in e)if(i.search(o)!==-1)r[i]=pa(e[i])};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r});var NH=Vt("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key"]});var Dm=(e,t,r)=>Xt(e)?r(t):Qr(e,r);function D_(e){let t=BH(e);return(r,n,o)=>{try{return t(r,n,o)}catch(i){return Or(i)}}}function BH(e){if(e._tag==="Middleware")return(r,n,o)=>{let i=Xt(r)?e.decode(vr(_d(n)),o):e.decode(Mf(r,_d),o);return U_(i)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>Xt(r)?vr(n):r;case"Transform":{let r=(n)=>n===We?Ln:vr(t.transform(n));return(n,o)=>Dm(n,o,r)}case"TransformOptional":{let r=(n)=>tS(t.transform(_d(n)));return(n,o)=>Dm(n,o,r)}case"TransformEffect":return(r,n,o)=>Dm(r,n,(i)=>i===We?Ln:t.transform(i,o));case"TransformOptionalEffect":return(r,n,o)=>Dm(r,n,(i)=>U_(t.transform(_d(i),o)))}}var U_=(e)=>Qr(e,tS),L_=(e,t,r,n)=>jr(n,(o)=>js(()=>Gi(o,(i)=>new SR(e,i,t,r))));function KH(e,t){let r=D_(e.link.transformation),n;return(o,i)=>{if(o===We)return Ln;if(e.isConstructed(o))return si;let s=(n??=t(e.link.to))(o,i);return r(s,o,i)}}function qH(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==We&&n!==void 0)return t(n,o);let i=r;if(ft(i)&&i._tag==="Success"){let s=t(i[Me],o);return Xt(s)?i:s}return Qr(L_(e,n,o,i),(s)=>{let c=t(s,o);return Xt(c)?vr(s):c})}}function YS(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:qH(e,r)}function tu(e,t,r,n,o){if(e._tag==="Declaration")for(let A of e.typeParameters)t(A);let i=r?Am(e):void 0,s=i?KH(i,t):n??e.getParser(t,r),{checks:c,encoding:l}=e,S=l?.map((A)=>D_(A.transformation)),m=e.encodingChecks;if(!l&&!c&&!m)return s;let g,w=(A,y)=>{let h=s(A,y);try{if(m&&!y.disableChecks)if(ft(h)){if(h._tag==="Success"){let x=Xt(h)?A:h[Me];if(A!==We&&x!==We){let G=ts(m,A,void 0,e,y);if(G)h=he(new Ur(e,G,A,y))}}}else h=Ae(h,(x)=>{if(A!==We&&x!==We){let G=ts(m,A,void 0,e,y);if(G)return he(new Ur(e,G,A,y))}return z(x)});if(c&&!y.disableChecks)if(ft(h)){if(h._tag==="Success"){let x=Xt(h)?A:h[Me];if(x===We)return h;let G=ts(c,x,void 0,e,y);if(G)h=he(new Ur(e,G,x,y))}}else h=Ae(h,(x)=>{if(x!==We){let G=ts(c,x,void 0,e,y);if(G)return he(new Ur(e,G,x,y))}return z(x)});return h}catch(x){return Or(x)}},k=o===void 0?w:o(w);if(!l)return k;return(A,y)=>{let h=g??=l.map((X)=>t(X.to)),x=A,G=h[h.length-1](A,y);for(let X=l.length-1;X>=0;X--)if(G=S[X](G,x,y),X!==0){let I=h[X-1];if(G._tag==="Success")x=G[Me],G=I(x,y);else G=Qr(G,(me)=>{let pe=I(me,y);return Xt(pe)?vr(me):pe})}if(G._tag==="Success"){let X=G[Me],I=k(X,y);return Xt(I)?G:I}return G=L_(e,A,y,G),Qr(G,(X)=>{let I=k(X,y);return Xt(I)?vr(X):I})}}var ZS=Symbol(),M_=new WeakMap,F_,ru=!1;var WH=(e)=>ru?Lm(gn,e,"parser"):gn(e).parser,N_=(e)=>ru?Lm(gn,e,"makeEffect"):gn(e).makeEffect,GH=(e)=>YS(e,N_);class XS{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=tu(this.ast,WH)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=tu(this.ast,N_,GH)}}class B_ extends XS{compiled;resolve;constructor(e,t,r){super(e);this.compiled=t,this.resolve=r}save(e,t){return Object.defineProperty(this,e,{value:t}),t}operation(e){let t=this.compiled;return typeof t==="function"?t(this.ast,this.resolve,e):t?.[e]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get compiledMakeEffect(){return this.save("compiledMakeEffect",this.operation("makeEffect"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??tu(this.ast,(e)=>Lm(this.resolve,e,"parser")))}get parser(){let e=this.decode;return e===void 0?this.decodeEffect:this.save("parser",zH(e,()=>this.decodeEffect))}get makeEffect(){let e=this.compiledMakeEffect;if(e!==void 0)return this.save("makeEffect",e);let t=(r)=>Lm(this.resolve,r,"makeEffect");return this.save("makeEffect",tu(this.ast,t,(r)=>YS(r,t)))}}function zH(e,t){let r;return(n,o)=>{if(n!==We)try{let i=e(n,o);if(i!==ZS)return i===n?si:vr(i)}catch(i){return Or(i)}return(r??=t())(n,o)}}function Lm(e,t,r){let n=e(t);if(n.compiled===void 0||Object.hasOwn(n,r))return n[r];let o;return(i,s)=>(o??=n[r])(i,s)}function gn(e){let t=M_.get(e);if(t!==void 0)return t;let r=F_===void 0?new XS(e):new B_(e,F_(e,gn),gn);return M_.set(e,r),r}function tb(e){let t=e.ast,r;return(n,o)=>J_(r??=gn(di(t)),n,V_(o))}function Mm(e){let t=tb(e);return(r,n)=>YH(Js(t(r,n)))}function q_(e){return XH(di(e.ast))}function $_(e){return HH(e.ast)}function QH(e){if(!ru){let o=j_(nb(e));return(i)=>{let s=o(i,sa);if(tn(s))return!0;return ta(s.cause,"Type guard adapter can only return false for schema issues"),!1}}let t=gn(e),r=t.is;if(r!==void 0)return(o)=>{try{return r(o,sa)}catch(i){return ta(Ef(i),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return(o)=>{let i=Js(ob(n(o,sa),o));if(tn(i))return!0;return ta(i.cause,"Type guard adapter can only return false for schema issues"),!1}}function HH(e){let t=di(e),r=(n)=>(r=QH(t),r(n));return(n)=>r(n)}function rb(e,t){let r=nb(e.ast);return z_(r,t)}function W_(e,t){return JH(rb(e,t))}function G_(e,t){let r=nb(hn(e.ast));return z_(r,t)}function z_(e,t){return t===void 0?e:(r,n)=>e(r,n?{...t,...n}:t)}var K_=(e)=>{if(e===We)return he(new Hr);return z(e)};function nb(e){return VH(eV,e)}function ob(e,t){if(Xt(e))return z(t);if(!ft(e))return Qr(e,K_);return e[Me]===We?K_(We):e}function VH(e,t){let r;return(n,o)=>ob((r??=e(t))(n,o??sa),n)}function j_(e){return(t,r)=>Js(e(t,r))}function JH(e){let t=j_(e);return(r,n)=>{let o=t(r,n);if(tn(o))return Ue(o.value);return ta(o.cause,"Option adapter can only return none for schema issues"),ge()}}function YH(e){if(tn(e))return Ue(e.value);return ta(e.cause,"Option adapter can only return none for schema issues"),ge()}function ZH(e,t){let r=Js(e);if(tn(r))return r.value;let n=ta(r.cause,t);throw Error("Schema validation failed",{cause:n})}var Q_="Constructor adapter can only throw schema issues";function H_(e){throw Error(Q_,{cause:Ef(e)})}function XH(e){let t;return(r,n)=>eb(t??=gn(e),r,n)}function V_(e){return e?.disableChecks?{...e.parseOptions,disableChecks:!0}:e?.parseOptions??sa}function J_(e,t,r){return ob(e.makeEffect(t,r),t)}function eb(e,t,r){let n=V_(r),o=ru?e.make:void 0;if(o!==void 0&&t!==We){let i;try{i=o(t,n)}catch(s){H_(s)}if(i!==ZS&&i!==We)return i}return ZH(J_(e,t,n),Q_)}function Y_(e,t,r,n){let o=gn(e),i=Am(e);if(i===void 0||o.make!==void 0||o.compiledMakeEffect!==void 0)return eb(o,t,r);if(i.isConstructed(t))return t;let s=eb((o.resolve??gn)(i.link.to),t,r);try{return n(s)}catch(c){H_(c)}}var eV=(e)=>gn(e).parser;var Fm="~effect/Schema/Schema",Z_=Symbol(),tV={[Fm]:Fm,get make(){let e=q_(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=tb(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Mm(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return et(this,arguments)},annotate(e){return this.rebuild(bm(this.ast,e))},annotateKey(e){return this.rebuild(Em(this.ast,e))},check(...e){return this.rebuild(aa(this.ast,e))},rebuild(e){return Gc(e,this[Z_])}};function Gc(e,t){function r(){}let n=Object.setPrototypeOf(r,tV);if(t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__")))Object.defineProperties(n,Object.getOwnPropertyDescriptors({...t}));else Object.assign(n,t);return n[Z_]=t,n.ast=e,n}function iV(e,t){let r=Pi((o)=>{let i=Fc(o,void 0),s=e(i,n);return s===i?null:s}),n=wm((o)=>{let i=r(Jd(o));if(i===null)return o;let s=Fc(i,o.context);return o.context===void 0?s:v0(s,sV(o.context))},t);return n}function sV(e){return e.constructorDefault===void 0?e:new SS(e.isOptional,e.isMutable,void 0,e.annotations)}function aV(e){if(e.propertySignatures.some((t)=>typeof t.name!=="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function cV(e){return(t)=>{let r=[...t].sort((o,i)=>e(ui(o))-e(ui(i)));if(!r.some((o,i)=>o!==t[i]))return t;return r}}function eU(e){return Gc(hV(e.ast),{schema:e})}var pV=cV((e)=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function dV(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map((S)=>Gc(t(ui(S)))),o=e.annotations?.toCodecStringTree;if(xo(o)){let S=o(n);if(S===void 0)return e;return Dr(e,[Im(S,t)])}let i=e.annotations?.toCodecJson,s=xo(i)?i(n):void 0,c=s===void 0?e.annotations?.toCodec:void 0,l=s??(xo(c)?c(n):void 0);return l===void 0?r(e):Dr(e,[Im(l,t)])}case"Null":return Dr(e,[uV]);case"Boolean":return Dr(e,[lV]);case"Unknown":case"ObjectKeyword":return Dr(e,[MS]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return aV(e),e.recur(t,LS);case"Union":{let n=pV(e.types);if(n!==e.types)return new es(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var uV=new Lr(new _o("null"),new ar(Bt(()=>null),Bt(()=>"null"))),lV=new Lr(new es([new _o("true"),new _o("false")]),new ar(Bt((e)=>e==="true"),om())),fV=new ar(Bt((e)=>typeof e==="string"?[e]:e),Ro()),mV=(e)=>e.transformation===fV,hV=iV((e,t)=>dV(e,t,(r)=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})}),{stopAt:mV});var fa=(e)=>e;var zc="~effect/Schema/SchemaError";function rU(e){return He(e,zc)&&e[zc]===zc}var nu=Fm;function gV(){return(e,t,r)=>Tt(new Vd(e.map(gm),(n)=>t(n.map((o)=>Tt(o))),r))}function xV(e,t){return gV()([],()=>(r,n,o)=>e(r)?z(r):he(new ro(n,r,o)),t)}function SV(e){return(t)=>nU(nU(t).annotate(e))}class ab extends Jo("SchemaError"){[zc]=zc;constructor(e){let t=_s();jn(0);try{super({issue:e})}finally{jn(t)}}get message(){return TR(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Xr](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}}function bV(e){return rU(e)}function sU(e){if(ft(e))return IV(e);return jr(e,(t)=>js(()=>Gi(t,(r)=>new ab(r))))}function IV(e){return tn(e)?e:Wi(Gi(e.cause,(t)=>new ab(t)))}function aU(e,t){let r;for(let n of e.reasons){if(!wf(n)||!bV(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(r===void 0)throw new globalThis.Error(t,{cause:e});return r}function wV(e){return Ex(e).then((t)=>{if(tn(t))return t.value;throw aU(t.cause,"Promise adapter can only reject schema errors")})}function EV(e){let t=Js(e);if(tn(t))return t.value;throw aU(t.cause,"Sync adapter can only throw schema errors")}var cb=$_;function rs(e,t){let r=rb(e,t);return(n,o)=>sU(r(n,o))}var ns=W_;function io(e,t){let r=rs(e,t);return(n,o)=>wV(r(n,o))}function kV(e,t){let r=rs(e,t);return(n,o)=>EV(r(n,o))}function cU(e,t){let r=G_(e,t);return(n,o)=>sU(r(n,o))}var Tt=Gc;function AV(e){return He(e,nu)&&e[nu]===nu}var u=fa((e)=>Tt(km(e.ast),{schema:e}));var pb=fa((e)=>{let t=OV(e);return Tt(O0(e.ast),{schema:t})});var vV=fa((e)=>Tt(ui(e.ast),{schema:e})),ou="~effect/Schema/flip";function CV(e){return He(e,ou)&&e[ou]===ou}function nU(e){if(CV(e))return e.schema.rebuild(hn(e.ast));return Tt(hn(e.ast),{[ou]:ou,schema:e})}function v(e){let t=Tt(new _o(e),{literal:e,transform(r){return t.pipe(os(v(r),{decode:Bt(()=>r),encode:Bt(()=>e)}))}});return t}var H=Tt(Qd),pU=Tt(mm),TV=Tt(bS),a=Tt(Xi);var yr=Tt(IS),Y=Tt(a0);function db(e,t){return Tt(e,{fields:t,mapFields(r,n){let o=r(this.fields);return db(ym(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function p(e){return db(ym(e,void 0),e)}function Wt(e,t){return Tt(RS(e.ast,t.ast),{key:e,value:t})}function dU(e,t){return Tt(m0(e.ast,t.map(gm)),{schema:e,records:t})}var U=fa((e)=>Tt(new hm(!1,[],[e.ast]),{value:e}));function uU(e,t){return Tt(e,{members:t,mapMembers(r,n){let o=r(this.members);return uU(xm(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function mt(e,t){return uU(xm(e,t,void 0),e)}function j(e){let t=e.map(v);return Tt(xm(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return mt(r(this.members))},pick(r){return j(r)},transform(r){return mt(t.map((n,o)=>n.transform(r[o])))}})}var D=fa((e)=>mt([e,pU])),OV=fa((e)=>mt([e,TV]));function pt(e){return(t)=>Tt(t.ast,{schema:t,identifier:e})}function PV(e){return(t)=>Tt(C0(t.ast,new cS(e,Ee)),{schema:t})}function ub(e){return RV(e)}function RV(e){return(t)=>PV(_O(e))(t)}function os(e,t){return(r)=>Tt(PS(r.ast,e.ast,t?pS(t):cm()),{from:r,to:e})}var lb=j(["true","yes","on","1","y"]),fb=j(["false","no","off","0","n"]),lU=j([...lb.literals,...fb.literals]).pipe(os(Y,am({decode:(e)=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:(e)=>e?"true":"false"})));function _V(e){return(t)=>Tt(P0(t.ast,e),{schema:t})}function UV(e){if(ft(e)&&e._tag==="Success")return e;return jr(e,(t)=>js(()=>Gi(t,(r)=>r.issue)))}function fU(e,t){let r=t?.encodingStrategy==="omit"?NR():Ro();return(n)=>u(vV(n)).pipe(os(n,{decode:BR(UV(e)),encode:r}))}function is(e){return v(e).pipe(_V(z(e)))}function DV(e,t){return p({_tag:is(e),...t})}function ma(e,t){return xV((r)=>r instanceof e,t)}function su(){return(e,t)=>new Lr(e.ast,pS(t))}var Gt=Sm;var oU="^\\S[\\s\\S]*\\S$|^\\S$|^$";function LV(e){let t=new globalThis.RegExp(oU);return Gt((r)=>r.trim()===r,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),arbitraryConstraint:{patterns:[{source:oU,flags:""}]},...e})}function Ge(e,t){let{source:r,flags:n}=e,o=/^[dg]*uy?$/.test(n);return vS(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],...t})}var MV=(e)=>{if(e)return new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);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|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/};function L(e,t){let r=MV(e);return Ge(r,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:r.source,format:"uuid"}),...t})}function FV(e){let r=/^[0-9a-zA-Z+/]*={0,2}$/;return Gt((n)=>n.length%4===0&&r.test(n),{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$"}),arbitraryConstraint:{patterns:[{source:"^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$",flags:""}]},...e})}function NV(e){let t=qp(e.order),r=e.formatter??rt;return(n,o)=>Gt((i)=>t(i,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function BV(e){let t=og(e.order),r=e.formatter??rt;return(n,o)=>Gt((i)=>t(i,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...o})}function KV(e){let t=ng(e.order),r=e.formatter??rt;return(n,o)=>Gt((i)=>t(i,n),{expected:`a value less than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n},...e.annotate?.(n),...o})}function qV(e){let t=og(e.order),r=qp(e.order),n=ng(e.order),o=Pv(e.order),i=e.formatter??rt;return(s,c)=>{let l=s.exclusiveMinimum?r:t,S=s.exclusiveMaximum?o:n;return Gt((m)=>l(m,s.minimum)&&S(m,s.maximum),{expected:`a value between ${i(s.minimum)}${s.exclusiveMinimum?" (excluded)":""} and ${i(s.maximum)}${s.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:s.minimum,maximum:s.maximum,...s.exclusiveMinimum&&{exclusiveMinimum:!0},...s.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(s),...c})}}function iu(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${rt(e)}`);return e}var Do=NV({order:Fs,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:iu(e)}},toJsonSchema:()=>({exclusiveMinimum:e})})}),Pe=BV({order:Fs,annotate:(e)=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:iu(e)}},toJsonSchema:()=>({minimum:e})})});var mU=KV({order:Fs,annotate:(e)=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:iu(e)}},toJsonSchema:()=>({maximum:e})})}),Mr=qV({order:Fs,annotate:(e)=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:iu(e.minimum),maximum:iu(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum})}}});function au(e){return Gt((t)=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer",minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),arbitraryConstraint:{number:"integer"},...e})}var M=yr.check(au());function be(e,t){return e=hU(e),$V(e,Math.ceil(e/2),t)}function $V(e,t,r){return Gt((n)=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:n==="array"?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],[Pd]:!0,arbitraryConstraint:{minLength:e},...r})}function oe(e,t){return e=hU(e),Gt((r)=>r.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:r})=>r==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:r==="array"?{maxItems:e}:r===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],[Pd]:!0,arbitraryConstraint:{maxLength:e},...t})}function hU(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}var WV=(e)=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),GV=(e)=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}};var iU=[];function yU(e){let t=WV(e),r=iU[t];if(r!==void 0)return r;let n=XV.pipe(os(H,jR(GV(t))));return iU[t]=n,n}var Tce=ma(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},expected:"RegExp",toCodecJson:()=>su()(p({source:a,flags:a}),sm({decode:(e,t)=>Pr({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new Hr({expected:"valid RegExp source and flags"},e,t)}),encode:(e)=>z({source:e.source,flags:e.flags})}))}),zV=a.annotate({expected:"a string that will be decoded as a URL"}),Oce=ma(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},expected:"URL",toCodecJson:()=>su()(zV,QR)});var Pce=ma(globalThis.File,{representation:{id:"effect/schema/File",payload:null},expected:"File",toCodecJson:()=>su()(p({data:a.check(FV()),type:a,name:a,lastModified:M}),sm({decode:(e,t)=>Nl(nm(e.data),{onFailure:()=>he(new Hr({expected:"a valid Base64 string"},e.data,t)),onSuccess:(r)=>{let n=new globalThis.Uint8Array(r);return z(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>zs({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:rm(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new Hr({expected:"a readable File"},e,t)})}))});var Rce=ma(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},expected:"URLSearchParams",toCodecJson:()=>su()(a.annotate({expected:"a query string that will be decoded as URLSearchParams"}),am({decode:(e)=>new globalThis.URLSearchParams(e),encode:(e)=>e.toString()}))});var Nm=a.annotate({expected:"a string that will be decoded as a number"}).pipe(os(yr,Gd));var jV=a.check(LV()),Fr=a.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(os(jV,GR()));var QV=a.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),_ce=ma(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},expected:"Uint8Array",toCodecJson:()=>su()(QV,HR)});var HV=-8640000000000000,VV=8640000000000000,Uce=HV+50400000,Dce=VV-50400000;var JV=globalThis.Symbol.for("immer-draftable"),sb={};function gU(e,t,r,n,o){let i=ZV(r,t,n),s=SU(t),c=class extends e{constructor(...[l,S]){let g=S?.["~payload"],w=g?.token===sb?g.value:r.make(l??{},S);super(w,{...S,disableChecks:!0,"~payload":{token:sb,value:w}})}static[nu]=nu;get[s](){return s}static[JV]=!0;static identifier=t;static fields=r.fields;static get ast(){return i(this).ast}static pipe(){return et(this,arguments)}static rebuild(l){return i(this).rebuild(l)}static make(l,S){return Y_(di(i(this).ast),l??{},S,(m)=>xU(this,m))}static makeOption(l,S){return Mm(i(this))(l??{},S)}static makeEffect(l,S){return i(this).makeEffect(l??{},S)}static annotate(l){return this.rebuild(bm(this.ast,l))}static annotateKey(l){return this.rebuild(Em(this.ast,l))}static check(...l){return this.rebuild(aa(this.ast,l))}static extend(l){return(S,m)=>{let g=mb(S)?S:p(S),w={...r.fields,...g.fields},k=ym(w,r.ast.checks,{identifier:l});return gU(this,l,db(aa(k,g.ast.checks),w),m,o)}}static mapFields(l,S){return r.mapFields(l,S)}};if(o!==void 0)Object.assign(c.prototype,o(t));return c}function xU(e,t){return new e(t,{"~payload":{token:sb,value:t}})}function YV(e){return new ar(Bt((t)=>xU(e,t)),Ro())}function SU(e){return`~effect/Schema/Class/${e}`}function ZV(e,t,r){let n;return(o)=>{if(n!==void 0)return n;let i=SU(t),s=(S)=>S instanceof o||He(S,i),c=YV(o),l=Tt(new Vd([e.ast],()=>(S,m,g)=>s(S)?z(S):he(new ro(m,S,g)),{identifier:t,[Xf]:([S])=>({isConstructed:s,link:new Lr(S,c)}),toCodec:([S])=>new Lr(S.ast,c),toEquivalence:([S])=>S,toFormatter:([S])=>(m)=>`${o.identifier}(${S(m)})`,[Zf]:Hd(e.ast),...r}));return n=os(l,c)(e)}}function mb(e){return AV(e)}var cu=(e)=>(t,r)=>{let n=mb(t)?t:p(t);return gU(Np,e,n,r,(i)=>({name:i}))},so=(e)=>(t,r,n)=>{let o=mb(r)?r.mapFields((i)=>({_tag:is(t),...i}),{unsafePreserveChecks:!0}):DV(t,r);return cu(e??t)(o,n)};var bU=eU;var XV=Tt(N0);var IU="~effect/Terminal",hb="~effect/Terminal/QuitError";class pu extends cu("QuitError")({_tag:is("QuitError")}){[hb]=hb}var wU=(e)=>He(e,hb),ao=Ht("effect/Terminal"),EU=(e)=>ao.of({...e,[IU]:IU});import*as Km from"readline";var kU=Ie(function*(e=vU){let t=yield*Ys(),r=!1,n=!1,o=()=>{if(r=!0,!n)Oo(t)},i,s=()=>{if(i===void 0)if(i=process.stdin,i.readableEnded)o();else i.once("end",o);return i};yield*vc(()=>Be(()=>i?.off("end",o)));let c=yield*Hx({acquire:Dn(Be(()=>{let h=s(),x=Km.createInterface({input:h,escapeCodeTimeout:50}),G=(I)=>Zi(t,I),X=()=>{n=!1,Oo(t)};return n=!0,Km.emitKeypressEvents(h,x),x.on("line",G),x.once("close",X),{rl:x,onClose:X,onLine:G}}),({rl:h,onClose:x,onLine:G})=>Be(()=>{if(n=!1,h.off("line",G),h.off("close",x),h.close(),r)Oo(t)})),idleTimeToLive:"10 millis"}),l=(h)=>Be(()=>{let x=s();if(x.isTTY)x.setRawMode(h)}),S=yield*Hx({acquire:Dn(l(!0),()=>l(!1)),idleTimeToLive:"10 millis"}),m=Be(()=>process.stdout.columns??0),g=Be(()=>process.stdout.rows??0),w=kr(function*(){let h=process.stdout,x=yield*yP(1),G=()=>Zi(x,{columns:h.columns??0,rows:h.rows??0});return yield*vc(()=>Be(()=>{h.off("resize",G),Oo(x)})),h.on("resize",G),G(),x}),k=kr(function*(){let h=s(),x=yield*Ys(),G=(me,pe)=>{let K={input:ec(me),key:{name:pe.name??"",ctrl:!!pe.ctrl,meta:!!pe.meta,shift:!!pe.shift}};if(Zi(x,K),e(K))Oo(x)},X=setInterval(()=>{},2147483647),I=()=>{clearInterval(X),Oo(x)};if(yield*vc(()=>Be(()=>{clearInterval(X),h.off("keypress",G),h.off("end",I)})),h.on("keypress",G),r)I();else yield*Qf(c),yield*Qf(S),h.once("end",I);return x}),A=Ve(()=>SP(t).pipe(Ae($r({onNone:()=>Hs(Zn(Qf(c),ii(t))),onSome:z})),Rr(()=>new pu({}))));return EU({columns:m,rows:g,size:w,readInput:k,readLine:A,display:(h)=>Pf(nn((x)=>{process.stdout.write(h,(G)=>jA(G)?x(Je):x(he(mn({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:G}))))}))})}),AU=Ic(ao,kU(vU));function vU(e){let t=e.key;return t.name==="escape"||t.ctrl&&(t.name==="c"||t.name==="d")}var CU=AU;var r4=$S.pipe(fO(bf(x_,b_,A_,CU)));var n4=ix,OU=(e)=>Xe((t)=>e(t.getRef(n4)));var qm=(...e)=>OU((t)=>vt(()=>{t.error(...e)}));var gr=(...e)=>OU((t)=>vt(()=>{t.log(...e)}));var $m="~effect/ErrorReporter/ignore";var PU="~effect/Runtime/errorExitCode";var uu="~effect/Runtime/errorReported";var dt=a.check(L()),de=pt("WorkspaceId")(dt),fi=pt("WorkspaceInviteId")(dt),ss=pt("UserId")(dt),xb=pt("AuditEventId")(dt),_t=pt("PostId")(dt),cr=pt("TargetId")(dt),zt=pt("AttemptId")(dt),J=pt("AccountId")(dt),xn=pt("MediaId")(dt),bt=pt("ProfileId")(dt),ha=pt("ApiKeyId")(dt),lu=pt("WebhookEndpointId")(dt),Sn=pt("InboxConversationId")(dt),Nn=pt("InboxMessageId")(dt),jc=pt("InboxCommentThreadId")(dt),Qc=pt("InboxCommentId")(dt),Hc=pt("InboxMentionId")(dt),Wm=pt("InboxReviewId")(dt),Sb=pt("InboxAttachmentId")(dt),mi=pt("InboxActionId")(dt),$de=pt("InboundEventId")(dt),Wde=pt("WebhookDeliveryId")(dt),Lo=pt("AdCampaignId")(dt),ya=pt("AdGroupId")(dt),Vc=pt("AdCreativeId")(dt),as=pt("AdId")(dt),RU=pt("AdInsightId")(dt),hi=pt("AdOperationId")(dt),_U=pt("AdBoostId")(dt),UU=pt("AdRequestId")(dt);var DU=(e)=>e,LU=(e)=>e;var bb=Fr.check(be(1),oe(100)),Ib=a.check(be(1),oe(100)).annotate({description:"An IANA time zone such as America/New_York."}),ga=p({id:de,name:bb,defaultTimezone:Ib,role:j(["owner","member"])}),MU=p({workspaces:U(ga)}),FU=p({name:bb,defaultTimezone:u(Ib).annotate({description:"Default IANA time zone for new queues. Defaults to UTC; existing queues keep their own time zone."})}),Qde=p({name:u(bb),defaultTimezone:u(Ib)}).check(Gt(({name:e,defaultTimezone:t})=>e!==void 0||t!==void 0||"Provide a name, a default time zone, or both.")),Hde=p({workspaceId:de}),NU=Fr.check(be(1),oe(100)),wb=p({id:a.check(L()),email:a,displayName:D(NU)}),BU=p({displayName:D(NU)}),KU=p({deactivated:v(!0)}),qU=p({archived:v(!0)});var Bn=a.check(Ge(/^[A-Z]{3}$/)),xt=p({amountMinor:M,currency:Bn}).annotate({identifier:"Money"});var fu=p({estimatedCostMicros:M,estimatedCost:xt,includedRemaining:M,overagePublishes:M,xPublishes:M,blocked:D(p({code:j(["insufficient_credit","spend_cap_reached","billing_inactive"]),nextAction:a}))}).annotate({identifier:"PostBillingEstimate"});var o4=50,$U=100;var WU=a.check(be(1),oe(2048)).annotate({description:"Opaque cursor from a previous list response. Pass nextCursor verbatim."}),It=p({cursor:u(WU),limit:u(Nm.check(au(),Mr({minimum:1,maximum:$U})).annotate({description:`Page size from 1 to ${$U}. Defaults to ${o4}.`}))}).annotate({identifier:"PageQuery"}),ze={hasMore:Y,nextCursor:u(WU)},i4=p({v:v(1),k:a.check(oe(512)),id:a.check(be(1),oe(256))}),rue=kV(i4);var s4=j(["no_targets","schedule_out_of_range","publishing_not_supported","publish_permission_required","duplicate_target","account_not_found","provider_mismatch","account_not_ready","account_unverified","caption_too_long","empty_content","media_required","media_unresolved","media_not_ready","media_count","media_type","media_mime_type","media_too_large","media_upload_required","media_unverified","settings_conflict","tiktok_privacy_unsupported","tiktok_disclosure_required","tiktok_upload_required","tiktok_too_many_mentions","queue_and_time_conflict","invalid_field","account_ambiguous","unsupported_placement","schedule_required","selector_required","selector_conflict"]),co=p({code:s4,path:U(mt([a,M])),message:a}),iue=Qz();var cs=["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"],bn=j(cs),a4=[...cs,"meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],qe=j(a4);var Gm=j(["na","eu","fe"]),pr=j(["social_page","social_account","social_board","social_channel","ad_account"]),c4=j(["auth","permission","access_pending","rate_limit","not_found","deleted","conflict","invalid_request","transient","invalid_response","unsupported"]),cue=p({provider:qe,operation:a,kind:c4,providerStatus:u(M),providerCode:u(a),requestId:u(a),retryable:Y,retryAfterSeconds:u(M),missingScopes:u(U(a)),detail:u(a)}).annotate({identifier:"ProviderError"}),pue=j(["publish","read_insights","engage","ads"]),p4=p({provider:bn});var er=j(cs),Jc=a.check(L()),po=M.check(Pe(1)),d4=128,Vr=a.check(Ge(new RegExp(`^[A-Za-z0-9._~-]{1,${d4}}$`))),gue=p({"idempotency-key":Vr}),xue=p({"idempotency-key":u(Vr)}),GU=86400,Ut=a.check(Ge(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/),Gt((e)=>{let t=new Date(`${e.slice(0,19)}Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,19)===e.slice(0,19)&&Number.isFinite(Date.parse(e))||"Use a valid date and time with Z or an explicit offset"})),xr=j(["feed","reel","story","carousel","video","pin"]),zm=mt([Ut,pU]),u4=p({accountId:J,placement:xr,scheduledAt:u(zm),queueId:u(Jc)}).annotate({identifier:"DestinationSelection"}),Sue=p({expectedRevision:po,scheduledAt:u(Ut),accountIds:u(U(J).check(be(1),oe(50)).annotate({description:"Select every draft placement for these accounts. Use targets for exact selection instead."})),targets:u(U(u4).check(be(1),oe(50)).annotate({description:"Select exact draft destinations and optionally override each schedule. Omit accountIds when using targets."}))}),zU=p({postId:_t}),Eb=p({postId:_t,targetId:cr}),bue=p({expectedAttemptId:zt}),Iue=mt([p({expectedAttemptId:zt,action:v("reschedule"),scheduledAt:Ut}),p({expectedAttemptId:zt,action:v("reschedule"),queueId:Jc,pinned:u(p({slotId:Jc,occurrenceDate:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))}))}),p({expectedAttemptId:zt,action:j(["publish_now","cancel"])})]).annotate({identifier:"ScheduleChange"}),l4=u(a),jU={queueId:u(Jc),slotId:u(Jc),assignmentId:u(Jc),occurrenceDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localDate:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),localTime:u(a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/))),timezone:u(a)},QU={targetId:cr,attemptId:zt,accountId:J,scheduledAt:l4,...jU},Yc=j(["scheduled","queued","submitting","confirming","published","provider_draft","failed","unresolved","cancelled"]),jm=mt([v("draft"),Yc]).annotate({identifier:"PostState"}),mu=p({id:a.check(be(1)),kind:a.check(be(1))}).annotate({identifier:"DeliveryProviderRef"}),kb=p({...QU,status:Yc}),f4=p({targetId:cr,attemptId:zt,accountId:J,provider:er,placement:xr,status:Yc,scheduledAt:D(a),url:D(a),issue:D(a),canRetry:Y,canReconcile:Y,...jU}).annotate({identifier:"PublishAcceptedTarget"}),xa=p({postId:_t,idempotencyKey:Vr,targets:U(f4),warnings:U(co),billing:u(fu)}).annotate({identifier:"PublishAccepted"}),hu=j(["authorization_changed","account_not_ready","credential_unavailable","media_preparation_failed","video_compression_failed","audio_unavailable","provider_rejected","tiktok_settings_unavailable","tiktok_settings_not_allowed","tiktok_processing_failed","submission_uncertain","confirmation_unavailable"]),wue=j(["pending","sending","posted","failed","unresolved"]),Eue=j(["pending","updating","updated","failed","unresolved"]),kue=j(["pending","sending","invited","failed","unresolved"]),m4={...QU,revision:po,provider:er,placement:xr},Qm=p({...m4,status:Yc,providerRef:u(mu),url:u(a),issue:u(hu),canRetry:Y,canReconcile:Y,nextAction:u(a)}).annotate({identifier:"DeliveryStatus"}),Ab=p({postId:_t,status:jm,targets:U(Qm)}),Aue=p({settled:Y,post:Ab,retryAfterSeconds:u(M)}).annotate({identifier:"PublishWait"});function HU(e){return e==="draft"||!["scheduled","queued","submitting","confirming"].includes(e)}var h4=p({postId:_t,isDraft:Y,status:jm,textPreview:a,targetCount:M.check(Pe(0)),mediaCount:M.check(Pe(0)),revision:po,createdAt:a,updatedAt:a}).annotate({identifier:"PostSummary"}),VU=p({data:U(h4),...ze}).annotate({identifier:"PostList"}),y4=p({delivery:Qm,createdAt:a,updatedAt:a,replacesAttemptId:u(zt)}).annotate({identifier:"DeliveryAttemptSummary"}),JU=p({currentAttemptId:zt,data:U(y4),...ze}).annotate({identifier:"DeliveryHistory"});var Zc=j(["payg","pro","platform","enterprise"]),Hm=j(["month","year"]),Vm=j(["fake","stripe"]),yu=j(["active","trialing","past_due","canceled","incomplete","unpaid"]),Jm=j(["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]),g4=p({meter:Jm,includedPerPeriod:M,overageUnitPriceMicros:D(M),unitLabel:a}).annotate({identifier:"BillingPlanMeter"}),x4=p({id:Zc,name:a,monthlyPrice:D(xt),annualPrice:D(xt),meters:U(g4),seatsLimit:D(M),analyticsRetentionDays:M,whiteLabelOAuth:Y,ssoSaml:Y}).annotate({identifier:"BillingPlan"}),YU=p({data:U(x4)}).annotate({identifier:"BillingPlanList"}),S4=p({meter:Jm,includedPerPeriod:M,used:M,billable:M,costMicros:M}).annotate({identifier:"BillingMeterUsage"}),b4=p({monthlySpendCapMicros:D(M),version:M}).annotate({identifier:"BillingSpendControls"}),I4=j(["ok","payment_required","insufficient_credit","spend_cap_reached"]),Cb=p({workspaceId:de,plan:Zc,status:yu,paymentStatus:I4,interval:D(Hm),gateway:Vm,periodStart:a,periodEnd:a,cancelAtPeriodEnd:Y,creditBalanceMicros:M,creditBalance:xt,spendControls:b4,currentPeriod:p({meters:U(S4),totalVariableSpendMicros:M,seatsUsed:M,seatsLimit:D(M)})}).annotate({identifier:"WorkspaceBilling"}),Sa=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),vb=a.check(Ge(/^https?:\/\/[^\s]+$/)),_ue=p({from:u(Sa),to:u(Sa),meter:u(Jm),provider:u(er)}).annotate({identifier:"BillingUsageQuery"}),w4=p({date:Sa,meter:Jm,provider:D(er),quantity:M,billableQuantity:M,costMicros:M}).annotate({identifier:"BillingUsageDailyPoint"}),ZU=p({from:Sa,to:Sa,totals:p({quantity:M,billableQuantity:M,costMicros:M}),data:U(w4)}).annotate({identifier:"BillingUsage"}),Ym=j(["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]),Uue=p({kind:u(Ym),from:u(Sa),to:u(Sa),...It.fields}).annotate({identifier:"BillingLedgerQuery"}),E4=p({id:a.check(L()),kind:Ym,deltaMicros:M,balanceAfterMicros:M,description:a,referenceKind:D(a),referenceId:D(a),createdAt:a}).annotate({identifier:"BillingLedgerEntry"}),XU=p({data:U(E4),...ze}).annotate({identifier:"BillingLedgerList"}),Due=mt([p({mode:v("subscription"),plan:j(["pro","platform"]),interval:Hm,returnUrl:u(vb)}),p({mode:v("top_up"),amountMinor:M.check(Pe(1000),mU(1e7)),returnUrl:u(vb)})]).annotate({identifier:"CreateBillingCheckout"}),eD=p({url:a,expiresAt:u(a)}).annotate({identifier:"BillingCheckoutSession"}),Lue=p({returnUrl:u(vb)}).annotate({identifier:"CreateBillingPortal"}),tD=p({url:a}).annotate({identifier:"BillingPortalSession"}),Mue=p({version:M,monthlySpendCapMicros:D(M)}).annotate({identifier:"UpdateBillingSpendControls"});var rD=180,nD=365,sD=["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"],Tb=j(sD).annotate({identifier:"AuditAction"}),aD=["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"],Zm=j(aD).annotate({identifier:"AuditTargetKind"}),k4=j(["user","api_key"]).annotate({identifier:"AuditActorType"}),A4=mt([p({type:v("user"),id:ss,email:D(a),displayName:D(a)}),p({type:v("api_key"),id:ha,name:D(a),prefix:D(a)})]).annotate({identifier:"AuditActor"}),Ob=p({id:xb,workspaceId:de,profileId:D(bt),actor:A4,action:Tb,targetKind:Zm,targetId:a.check(L()),detail:Wt(a,H),createdAt:a}).annotate({identifier:"AuditEvent"}),cD=p({data:U(Ob),...ze}).annotate({identifier:"AuditEventList"}),Wue=p({workspaceId:de,eventId:xb}),oD=mt([Ut,a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))]),Gue=p({action:u(Tb),targetKind:u(Zm),targetId:u(a.check(L())),actorType:u(k4),actorId:u(a.check(L())),profileId:u(bt),from:u(oD).annotate({description:"Inclusive start instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),to:u(oD).annotate({description:"Inclusive end instant (ISO 8601 timestamp or YYYY-MM-DD UTC date)."}),...It.fields}),v4=p({action:Tb,targetKind:Zm,description:a,retentionDays:M}).annotate({identifier:"AuditActionCatalogEntry"}),pD=p({actions:U(v4),targetKinds:U(Zm),retention:p({standardDays:M,spendDays:M})}).annotate({identifier:"AuditActionCatalog"}),iD={"workspace.updated":{targetKind:"workspace",description:"Workspace name or default timezone updated."},"workspace.archived":{targetKind:"workspace",description:"Workspace archived by an owner."},"workspace.member.role_updated":{targetKind:"workspace_member",description:"Workspace member role changed between owner and member."},"workspace.member.removed":{targetKind:"workspace_member",description:"Workspace member removed or left the workspace."},"workspace.invite.created":{targetKind:"workspace_invite",description:"Workspace member invitation created."},"workspace.invite.resent":{targetKind:"workspace_invite",description:"Workspace member invitation token rotated and resent."},"workspace.invite.revoked":{targetKind:"workspace_invite",description:"Pending workspace invitation revoked."},"workspace.invite.accepted":{targetKind:"workspace_invite",description:"Workspace invitation accepted by the invited user."},"workspace.invite.declined":{targetKind:"workspace_invite",description:"A workspace invitation was declined."},"api_key.created":{targetKind:"api_key",description:"Workspace API key created (redacted prefix only)."},"api_key.updated":{targetKind:"api_key",description:"Workspace API key name or scopes updated."},"api_key.revoked":{targetKind:"api_key",description:"Workspace API key revoked."},"webhook.endpoint.created":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint registered."},"webhook.endpoint.updated":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint configuration updated."},"webhook.endpoint.deleted":{targetKind:"webhook_endpoint",description:"Outbound webhook endpoint permanently disabled."},"webhook.delivery.replayed":{targetKind:"webhook_delivery",description:"Settled webhook delivery queued for replay."},"account.connected":{targetKind:"provider_account",description:"Social or ad account connected via OAuth."},"account.reconnected":{targetKind:"provider_account",description:"Existing account grant reconnected via OAuth."},"account.disconnected":{targetKind:"integration_connection",description:"Provider connection disconnected and credentials cleared."},"account.enabled":{targetKind:"provider_account",description:"Connected publishing destination enabled."},"account.disabled":{targetKind:"provider_account",description:"Connected publishing destination disabled."},"account.moved":{targetKind:"provider_account",description:"Connected account moved to another workspace profile."},"profile.created":{targetKind:"workspace_profile",description:"Workspace brand profile created."},"profile.updated":{targetKind:"workspace_profile",description:"Workspace brand profile updated."},"profile.archived":{targetKind:"workspace_profile",description:"Workspace brand profile archived."},"queue.created":{targetKind:"schedule_queue",description:"Account schedule queue created."},"queue.updated":{targetKind:"schedule_queue",description:"Account schedule queue configuration updated."},"queue.paused":{targetKind:"schedule_queue",description:"Account schedule queue paused."},"queue.resumed":{targetKind:"schedule_queue",description:"Account schedule queue resumed."},"queue.archived":{targetKind:"schedule_queue",description:"Account schedule queue archived."},"queue.slots.replaced":{targetKind:"schedule_queue",description:"Weekly schedule queue slots replaced."},"queue.skip.created":{targetKind:"schedule_queue_skip",description:"Single queue slot occurrence skipped."},"queue.skip.deleted":{targetKind:"schedule_queue_skip",description:"Skipped queue slot occurrence restored."},"queue.blackout.created":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range created."},"queue.blackout.deleted":{targetKind:"schedule_queue_blackout",description:"Queue blackout date range removed."},"billing.subscription.updated":{targetKind:"workspace_billing",description:"Workspace billing plan or subscription status updated."},"billing.credit.topped_up":{targetKind:"workspace_billing",description:"Workspace prepaid credit balance topped up."},"billing.spend_controls.updated":{targetKind:"workspace_billing",description:"Workspace monthly spend cap or auto-top-up controls updated."}},zue={actions:sD.map((e)=>({action:e,targetKind:iD[e].targetKind,description:iD[e].description,retentionDays:e.startsWith("billing.")||e.startsWith("ads.")?nD:rD})),targetKinds:[...aD],retention:{standardDays:rD,spendDays:nD}};var Pb=p({workspaceId:de,deliveryFailures:Y,connectionExpiring:Y,webhookFailures:Y,billingAlerts:Y,weeklyDigest:Y,updatedAt:D(a)}).annotate({identifier:"NotificationPreferences"}),Vue=p({deliveryFailures:u(Y),connectionExpiring:u(Y),webhookFailures:u(Y),billingAlerts:u(Y),weeklyDigest:u(Y)}).check(Gt((e)=>Object.values(e).some((t)=>t!==void 0)||"Provide at least one notification preference to update.")).annotate({identifier:"UpdateNotificationPreferences"});var Xc=j(["owner","member"]).annotate({identifier:"WorkspaceRole"}),C4=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,T4=Fr.pipe(os(a.check(be(3),oe(320),Ge(C4)),dj())).annotate({identifier:"NormalizedEmail",description:"Email address, trimmed and lowercased."}),Xm=p({workspaceId:de,userId:ss,email:a,displayName:D(a),role:Xc,joinedAt:a}).annotate({identifier:"WorkspaceMember"}),dD=p({data:U(Xm),...ze}).annotate({identifier:"WorkspaceMemberList"}),tle=p({role:u(Xc),...It.fields}),rle=p({workspaceId:de,userId:ss}),nle=p({role:Xc}).annotate({identifier:"UpdateWorkspaceMemberRole"}),uD=p({removed:v(!0)}).annotate({identifier:"WorkspaceMemberRemoved"}),lD=j(["pending","accepted","revoked","expired"]).annotate({identifier:"WorkspaceInviteStatus"}),Rb=p({id:fi,workspaceId:de,email:a,role:Xc,status:lD,deliveryState:j(["queued","sending","uncertain","sent"]),remoteRevocationPending:Y,invitedByUserId:ss,invitedByEmail:D(a),expiresAt:a,acceptedAt:D(a),revokedAt:D(a),createdAt:a}).annotate({identifier:"WorkspaceInvite"}),fD=p({data:U(Rb),...ze}).annotate({identifier:"WorkspaceInviteList"}),ole=p({status:u(lD),...It.fields}),ile=p({workspaceId:de,inviteId:fi}),sle=p({email:T4,role:u(Xc)}).annotate({identifier:"CreateWorkspaceInvite"}),mD=p({invite:Rb}).annotate({identifier:"WorkspaceInviteCreated"}),hD=p({invite:Rb,resendState:j(["sending","sent","uncertain"])}).annotate({identifier:"WorkspaceInviteResent"}),yD=p({revoked:v(!0),remoteRevocationPending:Y}).annotate({identifier:"WorkspaceInviteRevoked"}),O4=p({id:fi,workspaceId:de,workspaceName:a,role:Xc,invitedByEmail:D(a),invitedByName:D(a),expiresAt:a,createdAt:a}).annotate({identifier:"PendingUserInvite"}),gD=p({data:U(O4)}).annotate({identifier:"PendingUserInviteList"}),ale=mt([p({token:Fr.check(be(1),oe(256))}),p({inviteId:fi})]).annotate({identifier:"AcceptWorkspaceInvite"}),xD=p({workspace:ga,membership:Xm}).annotate({identifier:"WorkspaceInviteAccepted"}),SD=p({declined:v(!0),remoteRevocationPending:Y}).annotate({identifier:"WorkspaceInviteDeclined"}),cle=p({inviteId:fi});var P4="pubnio_sk_",_b=new RegExp(`^${P4}[A-Za-z0-9_-]{43}$`),gu=j(["read","publish","engage","ads_read","ads_manage"]),Ub=U(gu).check(be(1),oe(gu.literals.length),Gt((e)=>new Set(e).size===e.length||"Choose each scope once.")),Db=Fr.check(be(1),oe(100)),xu=p({id:ha,workspaceId:de,name:Db,prefix:a,scopes:Ub,createdAt:a,updatedAt:a,expiresAt:D(a),revokedAt:D(a)}).annotate({identifier:"ApiKey"}),mle=p({name:Db,scopes:u(Ub).annotate({description:"Defaults to read. publish permits delivery writes; engage permits inbox replies; ads_read and ads_manage permit ad operations. ads_spend requires a signed-in owner."}),expiresAt:u(Ut)}),hle=p({name:u(Db),scopes:u(Ub)}).check(Gt(({name:e,scopes:t})=>e!==void 0||t!==void 0||"Provide a name or scopes."));var yle=gu.literals;var gle=p({workspaceId:de,keyId:ha}),bD=p({key:xu,secret:a.check(Ge(_b)).annotate({description:"Copy this secret now. This is the only response that returns it."})}),ID=p({data:U(xu),...ze}).annotate({identifier:"ApiKeyList"}),wD=p({revoked:v(!0)});var eh=26214400,th=268435456,rh=16777216,R4=8388608;var ba=a.check(oe(2048),Ge(/^https:\/\//i),Gt((e)=>{let t=URL.parse(e);return Boolean(t?.hostname&&t.protocol==="https:"&&!t.username&&!t.password)||"Expected an HTTPS media URL without credentials"})),ED=p({mediaId:xn}),_4=p({url:ba}),U4=mt([ED,_4]).annotate({identifier:"MediaInput"}),Lb=35,ps=U(U4).check(oe(Lb)),Su=j(["image","video","document"]),ep=j(["image/jpeg","image/png","image/gif","image/webp","video/mp4","video/quicktime","video/webm","application/pdf"]);function D4(e,t){let r=(n)=>n.every((o,i)=>e[i]===o);switch(t){case"image/jpeg":return r([255,216,255]);case"image/png":return r([137,80,78,71,13,10,26,10]);case"image/webp":{let n=new TextDecoder().decode(e.subarray(0,12));return n.startsWith("RIFF")&&n.endsWith("WEBP")}case"video/webm":{if(!r([26,69,223,163]))return!1;let n=[66,130,132,119,101,98,109];return e.some((o,i)=>n.every((s,c)=>e[i+c]===s))}case"image/gif":{let n=new TextDecoder().decode(e.subarray(0,6));return n==="GIF87a"||n==="GIF89a"}case"video/mp4":case"video/quicktime":{if(e.length<16)return!1;let n=new TextDecoder().decode(e.subarray(4,12));return n.startsWith("ftyp")&&(t==="video/quicktime"?n==="ftypqt ":n!=="ftypqt ")}case"application/pdf":return r([37,80,68,70,45])}}function kD(e){return ep.literals.find((t)=>D4(e,t))}var kle=p({workspaceId:de,mimeType:ep}),Mb=p({mediaId:xn,type:Su,mimeType:ep,sizeBytes:M.check(Mr({minimum:1,maximum:th})),createdAt:a}).annotate({identifier:"MediaAsset"}),AD=p({data:U(Mb),...ze}).annotate({identifier:"MediaList"}),vD=p({deleted:v(!0)}),Ale=p({url:a.check(be(1),oe(8192))}).annotate({identifier:"MediaImport"}),vle=p({sizeBytes:M.check(Pe(1))}).annotate({identifier:"MediaUploadStart"}),CD=Mr({minimum:1,maximum:Math.ceil(th/rh)}),L4=M.check(CD),Cle=p({...ED.fields,partNumber:Nm.check(au(),CD)}),TD=p({mediaId:xn,partSizeBytes:v(rh),expiresAt:a}).annotate({identifier:"MediaUploadSession"}),OD=p({partNumber:L4}).annotate({identifier:"MediaPartReceipt"}),PD=p({code:j(["media_source_unavailable","media_storage_unavailable","media_too_large","unsupported_media","upload_expired"]),maxBytes:u(M)}).annotate({identifier:"MediaIntakeIssue"}),M4=j(["awaiting_upload","processing","ready","failed"]),F4=p({receivedPartCount:M.check(Pe(0)),partDigests:U(a.check(Ge(/^[A-Za-z0-9_-]{43}$/))),expiresAt:a}).annotate({identifier:"MediaUploadProgress"}),Ia=p({mediaId:xn,status:M4,asset:u(Mb),issue:u(PD),upload:u(F4),idempotencyKey:u(Vr),retryAfterSeconds:u(M)}).annotate({identifier:"MediaIntake"}),Tle=p({mediaId:xn,status:j(["ready","failed","timeout"]),asset:u(Mb),issue:u(PD),retryAfterSeconds:u(M)}).annotate({identifier:"MediaWait"}),Ole=p({data:a.check(be(1),oe(Math.ceil(R4/3)*4+4)).annotate({description:"Base64-encoded file bytes. Maximum 8 MiB after decoding."}),mimeType:ep,filename:u(a.check(be(1),oe(255)))}).annotate({identifier:"MediaInlineUpload"}),RD=j(["part_conflict","part_out_of_order","parts_missing","upload_closed","upload_expired"]);var Fb=["live","beta","upcoming"];var N4=["publish","read_insights","manage_comments"],nh=[...N4,"send_messages"],In={bluesky:{label:"Bluesky",availability:"beta",authFamily:"bluesky",accountKinds:["social_account"],capabilities:{social_account:nh},approvalRequired:{},limited:{}},facebook:{label:"Facebook",availability:"live",authFamily:"facebook",accountKinds:["social_page"],capabilities:{social_page:nh},approvalRequired:{},limited:{}},instagram:{label:"Instagram",availability:"live",authFamily:"instagram",accountKinds:["social_account"],capabilities:{social_account:nh},approvalRequired:{},limited:{}},linkedin:{label:"LinkedIn",availability:"live",authFamily:"linkedin",accountKinds:["social_account","social_page"],capabilities:{social_account:["publish","manage_comments"],social_page:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},pinterest:{label:"Pinterest",availability:"live",authFamily:"pinterest",accountKinds:["social_board"],capabilities:{social_board:["publish","read_insights"]},approvalRequired:{},limited:{}},reddit:{label:"Reddit",availability:"upcoming",authFamily:"reddit",accountKinds:["social_account"],capabilities:{social_account:nh},approvalRequired:{},limited:{}},snapchat:{label:"Snapchat",availability:"beta",authFamily:"snapchat",accountKinds:["social_page"],capabilities:{social_page:["publish"]},approvalRequired:{},limited:{}},tiktok:{label:"TikTok",availability:"live",authFamily:"tiktok",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights"]},approvalRequired:{},limited:{}},threads:{label:"Threads",availability:"upcoming",authFamily:"threads",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments"]},approvalRequired:{},limited:{}},x:{label:"X",availability:"live",authFamily:"x",accountKinds:["social_account"],capabilities:{social_account:["publish","read_insights","manage_comments","send_messages"]},approvalRequired:{},limited:{}},youtube:{label:"YouTube",availability:"live",authFamily:"youtube",accountKinds:["social_channel"],capabilities:{social_channel:["publish","read_insights"]},approvalRequired:{},limited:{}},google_business:{label:"Google Business Profile",availability:"upcoming",authFamily:"google_business",accountKinds:["social_page"],capabilities:{social_page:["publish","read_insights"]},approvalRequired:{},limited:{}}};var _le={bluesky:{...In.bluesky,publishCapable:!0},facebook:{...In.facebook,publishCapable:!0},instagram:{...In.instagram,publishCapable:!0},linkedin:{...In.linkedin,publishCapable:!0},pinterest:{...In.pinterest,publishCapable:!0},reddit:{...In.reddit,publishCapable:!0},snapchat:{...In.snapchat,publishCapable:!0},tiktok:{...In.tiktok,publishCapable:!0},threads:{...In.threads,publishCapable:!0},x:{...In.x,publishCapable:!0},youtube:{...In.youtube,publishCapable:!0},google_business:{...In.google_business,publishCapable:!0},meta_ads:{label:"Meta Ads",availability:"live",authFamily:"meta_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},google_ads:{label:"Google Ads",availability:"live",authFamily:"google_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},reddit_ads:{label:"Reddit Ads",availability:"live",authFamily:"reddit_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},pinterest_ads:{label:"Pinterest Ads",availability:"live",authFamily:"pinterest_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},tiktok_ads:{label:"TikTok Ads",availability:"live",authFamily:"tiktok_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},linkedin_ads:{label:"LinkedIn Ads",availability:"live",authFamily:"linkedin_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},snapchat_ads:{label:"Snapchat Ads",availability:"live",authFamily:"snapchat_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},amazon_ads:{label:"Amazon Ads",availability:"live",authFamily:"amazon_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"},openai_ads:{label:"OpenAI Ads",availability:"beta",authFamily:"openai_ads",accountKinds:["ad_account"],capabilities:{ad_account:["ads_read"]},approvalRequired:{},limited:{},publishCapable:!1,integrationState:"connectable"}},Ule=cs.flatMap((e)=>{let t=In[e];return t.accountKinds.map((r)=>({provider:e,availability:t.availability,accountKind:r,capabilities:[...t.capabilities[r]??[]],approvalRequired:[...t.approvalRequired[r]??[]],limited:[...t.limited[r]??[]]}))});var B4=60,K4=3600;var q4={requestsPerMinute:300,publishesPerMinute:30,mediaUploadsPerMinute:10,windowSeconds:60},gi=mt([p({status:j(["ready","disabled","unavailable"])}),p({status:v("needs_reconnect"),reason:j(["disconnected","token_expired"])}),p({status:v("unverified"),reason:j(["scopes_unknown","page_tasks_unknown"])}),p({status:v("permission_required"),reason:v("missing_scope"),missingScopes:U(a)}),p({status:v("permission_required"),reason:v("missing_page_task")})]).annotate({identifier:"AccountReadiness"}),yi=j(["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]),$4=j(["supported","not_supported","access_pending","permission_missing","unverified","reconnect_required","unavailable"]),qle=p({scopes:u(U(a)),pageTasks:u(U(a)),roles:u(U(a)),loginMethods:u(U(a))}),xi=p({capability:yi,state:$4,missingScopes:U(a),missingRoles:U(a),reason:u(a)}).annotate({identifier:"AccountCapability"}),W4=p({accountId:J,profileId:bt,provider:qe,accountKind:pr,enabled:Y,publishingReadiness:gi,capabilities:U(xi),checkedAt:a}).annotate({identifier:"AccountCapabilities"}),_D=p({capabilities:U(W4)}),$le=p({workspaceId:de,profileId:u(bt),accountId:u(J),capability:u(yi)}),G4=p({provider:qe,availability:j(Fb),accountKind:pr,capabilities:U(yi),approvalRequired:U(yi),limited:U(yi)}).annotate({identifier:"CapabilityCatalogEntry"}),UD=p({entries:U(G4)}).annotate({identifier:"CapabilityCatalog"}),z4=p({accountId:J,provider:qe,accountKind:pr,name:a,enabled:Y,readiness:gi}).annotate({identifier:"AccountSummary"}),Wle=p({accounts:U(z4)}).annotate({identifier:"AccountSummaryList"}),j4=p({requestsPerMinute:M,publishesPerMinute:M,mediaUploadsPerMinute:M,windowSeconds:M}).annotate({identifier:"RateLimits"}),DD=p({uploadMaxBytes:M,assetMaxBytes:M,partMaxBytes:M,types:U(Su)}).annotate({identifier:"MediaLimits"}),Nb=p({targetsPerRequest:M,draftTextCharacters:M,idempotencyTtlSeconds:M,wait:p({defaultSeconds:M,maxSeconds:M}),media:DD,rateLimits:j4}).annotate({identifier:"ApiLimits"}),Q4=p({placement:xr,default:Y,mediaTypes:U(Su),maxMedia:M,captionCharacters:M}).annotate({identifier:"PlacementCapability"}),H4=p({provider:bn,label:a,availability:j(Fb),accountKinds:U(pr),placements:U(Q4),requiredScopes:U(a)}).annotate({identifier:"ProviderCapability"}),LD=p({providers:U(H4),accountKinds:U(pr),media:DD,limits:Nb}).annotate({identifier:"PublishCapabilities"}),Gle={targetsPerRequest:50,draftTextCharacters:128000,idempotencyTtlSeconds:GU,wait:{defaultSeconds:B4,maxSeconds:K4},media:{uploadMaxBytes:eh,assetMaxBytes:th,partMaxBytes:rh,types:[...Su.literals]},rateLimits:q4};var oh=j(["instagram_login","facebook_login","unified_login"]),MD=u(oh),V4=mt([p({provider:v("bluesky"),kind:v("account"),handle:a,did:a,service:a}),p({provider:v("facebook"),kind:v("page"),tasks:u(U(a))}),p({provider:v("instagram"),kind:v("professional_account"),username:a,loginMethod:MD,accountType:u(j(["business","creator"])),pageId:u(a),clientBusinessId:u(a),configId:u(a)}),p({provider:v("linkedin"),kind:v("member")}),p({provider:v("linkedin"),kind:v("organization")}),p({provider:v("pinterest"),kind:v("board"),username:u(a)}),p({provider:v("reddit"),kind:v("account"),username:a}),p({provider:v("snapchat"),kind:v("public_profile"),profileId:a,organizationId:u(a),username:u(a)}),p({provider:v("tiktok"),kind:v("account"),username:u(a),isBusiness:u(Y)}),p({provider:v("threads"),kind:v("account"),username:u(a)}),p({provider:v("x"),kind:v("account"),username:u(a)}),p({provider:v("youtube"),kind:v("channel")}),p({provider:v("google_business"),kind:v("location")}),p({provider:v("meta_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("google_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),managerId:u(a),loginCustomerId:u(a)}),p({provider:v("reddit_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("pinterest_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("tiktok_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("linkedin_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a),managerId:u(a)}),p({provider:v("snapchat_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),businessId:u(a)}),p({provider:v("amazon_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"]),region:Gm,businessId:u(a),managerId:u(a)}),p({provider:v("openai_ads"),kind:v("ad_account"),externalId:a,currency:a.check(Ge(/^[A-Z]{3}$/)),timezone:a,status:j(["active","disabled","pending","closed","unknown"])})]);var tp=p({id:J,profileId:bt,connectionId:a.check(L()),provider:qe,accountKind:pr,parentAccountId:D(J),name:a,enabled:Y,available:Y,details:V4,readiness:gi,capabilities:U(xi)}).annotate({identifier:"ProviderAccount"}),Bb=p({accounts:U(tp)}),J4=p({id:J,enabled:Y});var ih=a.check(L()),qb=p({attemptId:ih}),bu=p({accountId:J}),FD=p({connectionId:ih}),$b=p({attemptId:ih,url:a,expiresAt:u(a)}),Y4=j(["provider_error","invalid_callback","account_mismatch","connection_changed","connection_failed"]),Kb={attemptId:ih,provider:qe},ND=mt([p({...Kb,status:j(["pending","denied","expired"])}),p({...Kb,status:v("connected"),accountIds:U(J)}),p({...Kb,status:v("failed"),reason:Y4})]).annotate({identifier:"ConnectionStatus"}),BD=p({disconnected:v(!0)}),Z4=p({handle:Fr.check(be(1),oe(253)),appPassword:Fr.check(be(1),oe(256)),service:u(a.check(oe(2048),Ge(/^https:\/\//i)))}).annotate({identifier:"BlueskyConnect"}),efe=p({...Z4.fields,accountId:u(J),profileId:u(bt)}).annotate({identifier:"BlueskySessionConnect"}),KD=p({used:M.check(Pe(0)),limit:M.check(Do(0)),windowSeconds:M.check(Do(0))}).annotate({identifier:"InstagramPublishingLimit"}),sh=j(["music","original_sound"]),rp=a.check(Ge(/^\d{1,32}$/)),tfe=p({...bu.fields,audioId:rp}),rfe=p({audioType:sh,q:u(Fr.check(be(1),oe(200)))}),Wb=p({audioId:rp,audioType:sh,title:a,durationMs:u(M.check(Pe(0))),artist:u(a),creator:u(a),previewUrl:u(a),coverUrl:u(a),instagramPreviewUrl:u(a)}).annotate({identifier:"InstagramAudio"}),qD=p({audio:U(Wb)});var zb=128000;var Qb=1250,X4=300;var $D=500,eJ=100,tJ=1e5,Gb=50,rJ=100;var ds=a.check(oe(zb)),GD=M.check(Pe(1)),gfe=p({workspaceId:de,isDraft:u(Y).annotate({description:"Filter to drafts (true) or submitted posts (false)."}),accountId:u(J).annotate({description:"Filter to posts targeting this connected account (applies to both drafts and submitted posts; pairs with deliveryStatus on the same target)."}),profileId:u(bt).annotate({description:"Filter to posts targeting any account in this workspace profile."}),...It.fields}),nJ=Lb,Cr={text:u(ds),media:u(ps),scheduledAt:u(zm),queueId:u(a.check(L()).annotate({description:"Assign this destination to its connected account's schedule queue."}))},Iu=a.check(Ge(/^\d+$/)),oJ=U(a.check(Ge(/^[A-Z]{2}$/))).check(be(1),oe(25)),zD={firstComment:u(ds),thread:u(U(a.check(be(1),oe(Qb))).check(oe(24))),nativeDraft:u(Y),countries:u(oJ)},jD=p({...zD,link:u(ba),textFormatPresetId:u(Iu),albumId:u(Iu)}).annotate({identifier:"FacebookFeedSettings"}),QD=p({...zD,title:u(ds),isAiGenerated:u(Y),collaboratorPageIds:u(U(Iu).check(be(1),oe(10),Gt((e)=>new Set(e).size===e.length||"Choose each collaborator Page once")))}).annotate({identifier:"FacebookReelSettings"}),HD=p({isAiGenerated:u(Y)}).annotate({identifier:"FacebookStorySettings"}),jb=a.check(Ge(/^@?[a-zA-Z0-9._]{1,30}$/)),WD=yr.check(Mr({minimum:0,maximum:1})),iJ=p({username:jb,x:u(WD),y:u(WD)}),VD={isAiGenerated:u(Y)},Hb={...VD,firstComment:u(ds),commentsEnabled:u(Y),collaborators:u(U(jb).check(oe(3))),locationId:u(Iu),isPaidPartnership:u(Y),brandedContentSponsors:u(U(mt([Iu,jb])).check(be(1),oe(2)))},ah=u(U(iJ).check(oe(20))),JD=u(a.check(oe(1000))),YD=p({...Hb,altText:JD,userTags:ah}).annotate({identifier:"InstagramFeedSettings"}),ZD=p({...Hb,shareToFeed:u(Y),muteAudio:u(Y),audioConfiguration:u(p({audioId:rp,audioVolume:u(M.check(Mr({minimum:1,maximum:100}))),videoVolume:u(M.check(Mr({minimum:0,maximum:100})))})),coverUrl:u(ba),thumbOffset:u(M.check(Pe(0))),audioName:u(a.check(oe(255))),trial:u(p({graduationStrategy:j(["MANUAL","SS_PERFORMANCE"])})),userTags:ah}).annotate({identifier:"InstagramReelSettings"}),XD=p({...Hb,muteAudio:u(Y),slides:u(U(p({altText:JD,userTags:ah})).check(oe(20)))}).annotate({identifier:"InstagramCarouselSettings"}),eL=p({...VD,muteAudio:u(Y),userTags:ah}).annotate({identifier:"InstagramStorySettings"}),tL=p({firstComment:u(a.check(be(1),oe(300))),thread:u(U(a.check(be(1),oe(300))).check(oe(24))),altText:u(a.check(oe(1000)))}).annotate({identifier:"BlueskyFeedSettings"}),rL=p({firstComment:u(ds),thread:u(U(a.check(be(1),oe(Qb))).check(oe(24))),visibility:u(j(["PUBLIC","CONNECTIONS"])),altText:u(a.check(oe(4086))),documentTitle:u(Fr.check(be(1),oe(rJ)))}).annotate({identifier:"LinkedInFeedSettings"}),nL=p({title:u(a.check(be(1),oe(100))),description:u(a.check(be(1),oe(800))),link:u(ba),altText:u(a.check(oe(500)))}).annotate({identifier:"PinterestPinSettings"}),sJ=a.check(Ge(/^(?:r\/)?[A-Za-z0-9_]{2,21}$/)),oL=p({subreddit:sJ,title:a.check(be(1),oe(X4)),link:u(ba),flairId:u(a.check(be(1),oe(100))),flairText:u(a.check(be(1),oe(64))),nsfw:u(Y),spoiler:u(Y),sendReplies:u(Y),thumbnailMediaId:u(xn),firstComment:u(ds)}).annotate({identifier:"RedditFeedSettings"}),iL=p({contentType:u(j(["story","saved_story","spotlight"])),title:u(a.check(be(1),oe(45))),description:u(a.check(be(1),oe(160))),link:u(ba),locale:u(a.check(Ge(/^[a-z]{2}_[A-Z]{2}$/)))}).annotate({identifier:"SnapchatStorySettings"}),sL=p({title:a.check(be(1),oe(100)),description:u(a.check(oe(5000))),privacyStatus:j(["public","unlisted","private"]),tags:u(U(a.check(oe(100))).check(oe(30))),categoryId:u(a.check(Ge(/^\d{1,3}$/))),madeForKids:u(Y),containsSyntheticMedia:u(Y),thumbnailMediaId:u(xn),notifySubscribers:u(Y),license:u(j(["youtube","creativeCommon"])),embeddable:u(Y),publicStatsViewable:u(Y)}).annotate({identifier:"YouTubeVideoSettings"}),aJ=p({title:a.check(be(1),oe(eJ)),content:a.check(be(1),oe(tJ))}).annotate({identifier:"XArticleDraftSettings"}),aL=p({firstComment:u(ds),thread:u(U(a.check(be(1),oe(280))).check(oe(24))),article:u(aJ)}).annotate({identifier:"XFeedSettings"}),cL=p({}).annotate({identifier:"GoogleBusinessFeedSettings"}),pL=p({firstComment:u(a.check(be(1),oe($D))),thread:u(U(a.check(be(1),oe($D))).check(oe(24)))}).annotate({identifier:"ThreadsFeedSettings"}),dL={privacy:j(["PUBLIC_TO_EVERYONE","MUTUAL_FOLLOW_FRIENDS","FOLLOWER_OF_CREATOR","SELF_ONLY"]),commercialDisclosure:u(j(["none","own_brand","paid_partnership"])),isAiGenerated:u(Y),disableComment:u(Y),nativeDraft:u(Y)},cJ=p({...dL,format:u(v("video")),disableDuet:u(Y),disableStitch:u(Y)}).annotate({identifier:"TikTokVideoSettings"}),pJ=p({...dL,format:v("photo"),title:u(a.check(oe(90))),coverIndex:u(M.check(Mr({minimum:0,maximum:nJ-1}))),autoAddMusic:u(Y)}).annotate({identifier:"TikTokPhotoSettings"}),uL=mt([cJ,pJ]).annotate({identifier:"TikTokFeedSettings"}),lL=mt([p({accountId:J,provider:v("bluesky"),placement:v("feed"),...Cr,settings:u(tL)}),p({accountId:J,provider:v("facebook"),placement:v("feed"),...Cr,settings:u(jD)}),p({accountId:J,provider:v("facebook"),placement:v("reel"),...Cr,settings:u(QD)}),p({accountId:J,provider:v("facebook"),placement:v("story"),...Cr,settings:u(HD)}),p({accountId:J,provider:v("instagram"),placement:v("feed"),...Cr,settings:u(YD)}),p({accountId:J,provider:v("instagram"),placement:v("reel"),...Cr,settings:u(ZD)}),p({accountId:J,provider:v("instagram"),placement:v("carousel"),...Cr,settings:u(XD)}),p({accountId:J,provider:v("instagram"),placement:v("story"),...Cr,settings:u(eL)}),p({accountId:J,provider:v("linkedin"),placement:v("feed"),...Cr,settings:u(rL)}),p({accountId:J,provider:v("threads"),placement:v("feed"),...Cr,settings:u(pL)}),p({accountId:J,provider:v("x"),placement:v("feed"),...Cr,settings:u(aL)}),p({accountId:J,provider:v("youtube"),placement:v("video"),...Cr,settings:sL}),p({accountId:J,provider:v("pinterest"),placement:v("pin"),...Cr,settings:u(nL)}),p({accountId:J,provider:v("reddit"),placement:v("feed"),...Cr,settings:oL}),p({accountId:J,provider:v("snapchat"),placement:v("story"),...Cr,settings:u(iL)}),p({accountId:J,provider:v("tiktok"),placement:v("feed"),...Cr,settings:u(uL)}),p({accountId:J,provider:v("google_business"),placement:v("feed"),...Cr,settings:u(cL)})]).annotate({identifier:"PublishTarget"}),xfe=rs(lL,{onExcessProperty:"error"}),dJ=a.check(be(1),oe(Qb)),uJ=U(dJ).check(be(1),oe(24)),lJ=mt([tL,jD,QD,HD,YD,ZD,XD,eL,rL,oL,iL,pL,aL,sL,nL,uL,cL]),fJ=p({accountId:J,provider:u(bn),placement:u(xr),text:u(ds),thread:u(uJ),media:u(ps),scheduledAt:u(zm),queueId:u(a.check(L()).annotate({description:"Assign this destination to its connected account's schedule queue."})),settings:u(lJ)}).annotate({identifier:"CreatePostTarget"}),Vb=Fr.check(oe(zb)).pipe(SV({description:`At most ${zb} characters after trimming.`})),fL=U(lL).check(oe(50)),Jb={text:u(Vb),targets:u(fL),media:u(ps)},Sfe=p(Jb).annotate({identifier:"PostContent"}),bfe=p({...Jb,scheduledAt:u(Ut)}).annotate({identifier:"PostPreflight"}),mL=p({text:u(Vb),platforms:u(U(bn).check(be(1),oe(Gb))),accounts:u(U(J).check(be(1),oe(Gb))),targets:u(U(fJ).check(be(1),oe(Gb))),media:u(ps),scheduledAt:u(Ut),publishNow:u(Y),isDraft:u(Y).annotate({description:"Save the post as a draft without submitting it. Defaults to false."})}).annotate({identifier:"CreatePost"}).annotate({description:"Send exactly one selector for a direct post: platforms resolves the single ready account per provider, accounts selects exact account IDs, and targets selects exact destinations. Provider and placement are derived when omitted. publishNow defaults to true when scheduledAt is absent. Set isDraft to true to save a draft without submitting; drafts accept text, media, and targets."}),mJ=p({...Jb,expectedRevision:u(GD)}).annotate({identifier:"UpdatePost"}),np=p({postId:_t,isDraft:Y,revision:GD,text:Vb,media:ps,targets:fL,deliveries:U(Qm),status:jm,createdAt:a,updatedAt:a}).annotate({identifier:"Post"}),Ife=p({...np.fields,idempotencyKey:u(Vr)}).annotate({identifier:"PostCreated"}),wfe=mt([np,xa]).annotate({identifier:"PostCreateResult"}),hL=p({archived:v(!0)}),Efe=rs(mJ,{onExcessProperty:"error"}),hJ=p({accountId:J,provider:bn,placement:xr,canPublish:Y,caption:p({count:M,limit:M}),errors:U(co),warnings:U(co)}),yL=p({canPublish:Y,errors:U(co),warnings:U(co),targets:U(hJ),billing:u(fu)}).annotate({identifier:"PostValidation"});var uo=a.check(L()),tr=uo,gL=uo,ch=Fr.check(be(1),oe(100)),op=a.check(be(1),oe(100)),xL=M.check(Mr({minimum:0,maximum:6})),ph=a.check(Ge(/^(?:[01]\d|2[0-3]):[0-5]\d$/)),yJ=50,wn=a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),gJ=p({id:u(uo).annotate({description:"Round-trip an existing slot ID. Omit to create a new slot; a removed slot reports no ID."}),dayOfWeek:xL,time:ph}).annotate({identifier:"QueueSlotInput"}),xJ=p({id:uo,dayOfWeek:xL,time:ph}).annotate({identifier:"QueueSlot"}),SL=U(gJ).check(oe(yJ)),SJ=p({maxPerDay:D(M.check(Pe(1))).annotate({description:"Null uses the provider limit."}),maxPending:M.check(Pe(1)),minGapSeconds:M.check(Pe(1)),horizonDays:M.check(Mr({minimum:1,maximum:90})),providerMaxPerDay:M.check(Pe(1)),providerMinGapSeconds:M.check(Pe(1))}).annotate({identifier:"QueueLimits"}),bJ=j(["active","paused","archived"]),ip=p({id:tr,workspaceId:de,accountId:J,name:ch,timezone:op,status:bJ,isDefault:Y.annotate({description:"The queue nextSlot assignment uses for this account when none is given."}),limits:SJ,slots:U(xJ),version:M.check(Pe(1)),pausedAt:D(a),archivedAt:D(a),createdAt:a,updatedAt:a}).annotate({identifier:"Queue"}),bL=p({data:U(ip),...ze}).annotate({identifier:"QueueList"}),IL=p({archived:v(!0),version:M.check(Pe(1))}).annotate({identifier:"QueueArchived"}),wL={maxPending:u(M.check(Mr({minimum:1,maximum:1000}))),minGapSeconds:u(M.check(Mr({minimum:60,maximum:604800}))),horizonDays:u(M.check(Mr({minimum:1,maximum:90})))},EL=p({accountId:J,name:ch,timezone:u(op).annotate({description:"An IANA time zone such as America/New_York. Defaults to the workspace default time zone."}),slots:SL,isDefault:u(Y).annotate({description:"Promote this queue to the account default. The first active queue is always the default."}),maxPerDay:u(M.check(Mr({minimum:1,maximum:1000}))).annotate({description:"Defaults to the provider limit."}),...wL}).annotate({identifier:"CreateQueue"}),kL=p({expectedVersion:M.check(Pe(1)),name:u(ch),timezone:u(op),paused:u(Y),isDefault:u(Y).annotate({description:"Promote or demote the account default. Demoting the current default requires promoting another queue first."}),maxPerDay:u(D(M.check(Mr({minimum:1,maximum:1000})))),...wL}).annotate({identifier:"UpdateQueue"}),AL=p({expectedVersion:M.check(Pe(1)),slots:SL}).annotate({identifier:"ReplaceQueueSlots"}),vL=j(["paused","archived","account_not_ready"]),CL=j(["max_per_day","max_pending"]),IJ=j(["occupied","capacity","skipped","blacked_out"]),TL=p({queueId:tr,slotId:D(uo),scheduledFor:a.annotate({description:"The resolved UTC instant."}),occurrenceDate:wn.annotate({description:"The local date the assignment counts toward."}),localDate:wn,localTime:ph,timezone:op,available:Y,unavailableReason:u(IJ)}).annotate({identifier:"QueueOccurrence"}),OL=p({queueId:tr,occurrence:D(TL),horizonEndsAt:a}).annotate({identifier:"QueueNextSlot"}),PL=p({queueId:tr,timezone:op,horizonEndsAt:a,occurrences:U(TL)}).annotate({identifier:"QueueSlotPreview"}),wJ=j(["published_now","cancelled","archived","submitted","rescheduled"]),Rfe=p({id:gL,queueId:tr,slotId:D(uo),postId:_t,targetId:cr,attemptId:zt,scheduledFor:a,occurrenceDate:wn,releasedAt:D(a),releaseReason:D(wJ)}).annotate({identifier:"QueueAssignment"}),wu=uo,dh=uo,RL=p({slotId:uo,occurrenceDate:wn}).annotate({identifier:"SkipQueueSlot"}),Yb=p({id:wu,queueId:tr,slotId:uo,occurrenceDate:wn,createdAt:a}).annotate({identifier:"QueueSkip"}),_L=p({data:U(Yb),...ze}).annotate({identifier:"QueueSkipList"}),UL=Fr.check(oe(200)).annotate({description:"Optional note for why these dates are unavailable."}),DL=p({startsOn:wn,endsOn:wn,reason:u(UL)}).annotate({identifier:"CreateQueueBlackout"}),Zb=p({id:dh,queueId:tr,startsOn:wn,endsOn:wn,reason:D(UL),createdAt:a}).annotate({identifier:"QueueBlackout"}),LL=p({data:U(Zb),...ze}).annotate({identifier:"QueueBlackoutList"}),Xb=p({deleted:v(!0)}).annotate({identifier:"QueueDeleted"});var EJ=j(["scheduled","queued"]),kJ=p({postId:_t,targetId:cr,attemptId:zt,accountId:J,provider:er,placement:xr,queueId:u(tr),slotId:u(uo),assignmentId:u(gL),queueName:u(ch),scheduledFor:a.annotate({description:"The queued attempt's UTC instant."}),occurrenceDate:u(wn),timezone:u(op),localDate:u(wn),localTime:u(ph),status:EJ.annotate({description:"scheduled when scheduledFor is in the future; queued otherwise."}),textPreview:a.check(oe(160)).annotate({description:"Short single-line preview of the post text."})}).annotate({identifier:"ScheduleEntry"}),ML=p({data:U(kJ),...ze}).annotate({identifier:"ScheduleList"}),_fe=p({results:U(p({index:M.check(Pe(0)),accepted:u(xa),problem:u(a)}))}).annotate({identifier:"BulkPublishResult"}),AJ=j(["invalid_timezone","invalid_slot_time","duplicate_slot","too_many_slots","slot_gap_too_short","limit_above_provider_default","queue_account_mismatch","queue_and_time_conflict","queue_archived","occurrence_in_past","occurrence_outside_horizon","invalid_blackout_range"]),FL=p({code:AJ,path:U(mt([a,M])),message:a}).annotate({identifier:"QueueIssue"}),Ufe=p({workspaceId:de,accountId:u(J),...It.fields}),Dfe=p({workspaceId:de}),Lfe=p({workspaceId:de,expectedVersion:Nm.check(au(),Pe(1))}),Mfe=p({workspaceId:de,after:u(Ut)}),Ffe=p({workspaceId:de,count:Nm.check(au(),Mr({minimum:1,maximum:100})),after:u(Ut),includeOccupied:u(Y)}),Nfe=p({workspaceId:de,...It.fields}),Bfe=p({workspaceId:de,...It.fields}),Kfe=p({workspaceId:de,from:Ut.annotate({description:"Inclusive ISO start instant."}),to:Ut.annotate({description:"Inclusive ISO end instant, after from and within 90 days."}),accountId:u(J),queueId:u(tr),...It.fields}),qfe=p({queueId:tr,skipId:wu}),$fe=p({queueId:tr,blackoutId:dh});var vJ=j(["queued","running","succeeded","partial","failed","cancelled"]),CJ=j(["active","backoff","paused","inaccessible","deleted","complete"]),NL=a.check(L()),BL=a.check(L()),eI=p({id:NL,workspaceId:de,cursorId:BL,domain:a,provider:a,subjectKind:a,subjectId:a.check(L()),scope:a,status:vJ,startedAt:a,finishedAt:D(a),requestCount:M,pageCount:M,errorKind:D(a),providerStatus:D(M),retryAfterSeconds:D(M),detail:D(Wt(a,H)),createdAt:a}).annotate({identifier:"SyncRun"}),jfe=p({cursorId:D(BL),state:CJ,lastSuccessAt:D(a),nextDueAt:D(a),syncRunId:D(NL)}).annotate({identifier:"SyncResource"});var us="/api/v1/inbox",tme=`${us}/conversations`,rme=`${us}/comments`,nme=`${us}/mentions`,TJ=`${us}/reviews`,ome=`${TJ}/:reviewId`,ime=`${us}/unread-count`,sme=`${us}/capabilities`,ame=`${us}/sync`,cme=`${us}/attachments`,OJ=j(["conversation","message","comment_thread","comment","mention"]),KL=j(["inbox","message_request","spam","other"]),rI=j(["active","archived"]),nI=j(["inbound","outbound"]),PJ=j(["received","pending","sending","sent","delivered","failed","unresolved","deleted"]),oI=j(["text","media","template","interactive","system","unknown"]),RJ=j(["post","comment","story","other"]),_J=j(["image","video","audio","file","unknown"]),UJ=j(["pending","succeeded","failed","unresolved"]),DJ=j(["list","read","send","reply","edit","delete","hide","unhide","like","unlike"]),LJ=j(["webhook","polling","webhook_with_reconciliation"]),Eu=p({externalId:a,name:D(a),handle:D(a)}).annotate({identifier:"InboxParticipant"}),iI=j(["none","24_hours","x_dm_30_days"]),qL=p({open:Y,policy:iI,endsAt:D(a)}).annotate({identifier:"InboxReplyWindow"}),MJ=j(["fresh","stale","pending","failed"]),sI=p({status:MJ,observedAt:D(a),nextDueAt:D(a),syncRunId:D(a)}).annotate({identifier:"InboxFreshness"}),FJ=p({id:Sb,messageId:Nn,kind:_J,mimeType:D(a),sizeBytes:D(M),width:D(M),height:D(M),durationSeconds:D(yr),url:a.annotate({description:"Workspace-scoped PubNio attachment URL. It never contains a provider URL or token."}),createdAt:a}).annotate({identifier:"InboxAttachment"}),aI=p({id:Nn,conversationId:Sn,accountId:J,provider:qe,direction:nI,state:PJ,kind:oI,text:D(a),sender:Eu,replyToMessageId:D(Nn),attachments:U(FJ),actionId:D(mi),providerCreatedAt:a,providerUpdatedAt:D(a),readAt:D(a),deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxMessage"}),uh=p({id:Sn,workspaceId:de,accountId:J,provider:qe,participant:Eu,folder:KL,status:rI,unreadCount:M,lastMessageAt:D(a),lastInboundAt:D(a),lastOutboundAt:D(a),lastMessagePreview:D(a),providerUrl:D(a),lastReadAt:D(a),archivedAt:D(a),replyWindow:qL,freshness:sI,createdAt:a}).annotate({identifier:"InboxConversation"}),lh=p({id:Qc,threadId:jc,accountId:J,provider:qe,parentCommentId:D(Qc),author:Eu,text:D(a),likeCount:M,replyCount:M,likedByAccount:Y,hidden:Y,canReply:Y,canHide:Y,canLike:Y,canDelete:Y,permalink:D(a),actionId:D(mi),providerCreatedAt:a,providerUpdatedAt:D(a),deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxComment"}),$L=p({id:jc,workspaceId:de,accountId:J,provider:qe,providerPostId:a,postId:D(a.check(L())),permalink:D(a),caption:D(a),commentCount:M,unreadCount:M,lastCommentAt:D(a),lastReadAt:D(a),freshness:sI,createdAt:a}).annotate({identifier:"InboxCommentThread"}),NJ=p({id:Hc,workspaceId:de,accountId:J,provider:qe,kind:RJ,author:Eu,text:D(a),permalink:D(a),parentExternalId:D(a),canReply:Y,freshness:sI,providerCreatedAt:a,deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxMention"}),BJ=j(["positive","negative"]),cI=p({id:Wm,workspaceId:de,accountId:J,provider:qe,locationExternalId:D(a),author:Eu,rating:D(M.check(Mr({minimum:1,maximum:5}))),recommendation:D(BJ),text:D(a),permalink:D(a),providerCreatedAt:a,providerUpdatedAt:D(a),repliedAt:D(a),replyText:D(a),canReply:Y,deletedAt:D(a),createdAt:a}).annotate({identifier:"InboxReview"}),WL=p({data:U(uh),...ze}).annotate({identifier:"InboxConversationList"}),GL=p({data:U(aI),...ze}).annotate({identifier:"InboxMessageList"}),zL=p({data:U($L),...ze}).annotate({identifier:"InboxCommentThreadList"}),jL=p({thread:$L,data:U(lh),...ze}).annotate({identifier:"InboxCommentThreadDetail"}),QL=p({data:U(NJ),...ze}).annotate({identifier:"InboxMentionList"}),HL=p({data:U(cI),...ze}).annotate({identifier:"InboxReviewList"}),VL=p({unreadCount:M}).annotate({identifier:"InboxUnreadCount"}),tI=p({resource:OJ,supported:Y,operations:U(DJ),attachments:Y,quickReplies:Y,buttons:Y,readReceipts:Y,moderation:Y,syncMode:LJ,backfillDays:M,missingScopes:U(a),missingTasks:U(a)}).annotate({identifier:"InboxChannelCapability"}),KJ=p({accountId:J,profileId:a.check(L()),provider:qe,accountKind:pr,enabled:Y,publishingReadiness:gi,accountCapabilities:U(xi),messaging:tI,comments:tI,mentions:tI,replyWindow:qL,lastSyncError:D(a),checkedAt:a}).annotate({identifier:"InboxAccountCapabilities"}),JL=p({accounts:U(KJ)}).annotate({identifier:"InboxCapabilities"}),pme=p({workspaceId:de,accountId:u(J)}),dme=p({workspaceId:de,conversationId:Sn}),ume=p({workspaceId:de,threadId:jc}),lme=p({workspaceId:de,commentId:Qc}),fme=p({workspaceId:de,mentionId:Hc}),mme=p({workspaceId:de,attachmentId:Sb}),hme=p({workspaceId:de,accountId:u(J),provider:u(qe),status:u(rI),folder:u(KL),unread:u(Y),search:u(a.check(oe(200))),...It.fields}),yme=p({workspaceId:de,order:u(j(["oldest","newest"])),...It.fields}),gme=p({workspaceId:de,accountId:u(J),postId:u(a.check(L())),providerPostId:u(a),unread:u(Y),...It.fields}),xme=p({workspaceId:de,...It.fields}),Sme=p({workspaceId:de,accountId:u(J),provider:u(qe),...It.fields}),bme=p({workspaceId:de,accountId:u(J),includeDeleted:u(Y),...It.fields}),Ime=p({status:u(rI),read:u(Y)}).check(Gt(({status:e,read:t})=>e!==void 0||t!==void 0||"Provide status or read.")),pI=Fr.check(be(1),oe(1e4)),wme=p({text:pI}).annotate({identifier:"SendInboxMessage"}),Eme=p({text:pI}).annotate({identifier:"ReplyInboxComment"}),kme=p({text:pI}).annotate({identifier:"ReplyInboxReview"}),Ame=p({hidden:u(Y),liked:u(Y)}).check(Gt(({hidden:e,liked:t})=>e!==void 0!==(t!==void 0)||"Provide exactly one of hidden or liked for one provider call.")),vme=p({"idempotency-key":Vr}),YL=p({deleted:v(!0),actionId:mi}).annotate({identifier:"InboxDeleted"}),ZL=p({mentionId:Hc,actionId:mi,status:UJ,providerResultId:D(a)}).annotate({identifier:"InboxMentionReply"}),Cme=p({workspaceId:de,accountId:u(J)}),XL=p({syncRunId:a.check(L()),status:eI.fields.status}).annotate({identifier:"InboxSyncAccepted"}),eM=p({syncRun:eI,counts:p({conversations:M,messages:M,commentThreads:M,comments:M,mentions:M})}).annotate({identifier:"InboxSyncStatus"}),Tme=p({workspaceId:de,syncRunId:a.check(L())});var ku=j(["post","comment"]);var qJ=Fr.check(be(1)),Lme=p({accountId:u(J).annotate({description:"Account that comments; derived when unambiguous."}),provider:u(bn),target:a.check(be(1),oe(2048)).annotate({description:"Provider ID or permalink."}),targetKind:u(ku),text:qJ.annotate({description:"Max 8000 characters."})}).annotate({identifier:"CreateComment"}),Mme=p({actionId:mi,idempotencyKey:Vr,commentId:a.check(be(1)),target:a,targetId:a.check(be(1)),targetKind:ku,accountId:J,provider:bn,status:v("posted"),permalink:u(a),replayed:Y}).annotate({identifier:"CommentCreated"});var $J=["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"],Ot=j($J);var WJ=j(["available","selected"]),dI=j(["active","disabled","pending","closed","unknown"]),GJ=p({provider:Ot,kind:v("ad_account"),externalId:a,currency:Bn,timezone:a,status:dI,businessId:u(a),managerId:u(a),loginCustomerId:u(a),region:u(Gm)}).annotate({identifier:"AdAccountDetails"}),zJ=p({configured:Y,killSwitchActive:Y,monthlyCap:D(xt),dailyCap:D(xt),maxCampaignDailyBudget:D(xt),maxCampaignLifetimeBudget:D(xt),revision:M.check(Pe(0))}).annotate({identifier:"AdAccountPolicy"}),lo=p({code:a,message:a,field:u(a),providerCode:u(a),missingScopes:u(U(a)),retryable:Y,providerMessage:u(a)}).annotate({identifier:"AdIssue"}),ls=j(["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]),fs=p({amountMinor:M.check(Pe(0)),currency:Bn,kind:j(["daily","lifetime"])}).annotate({identifier:"AdBudget"}),mh=p({accountId:J,currency:Bn,configured:Y,monthlyCap:D(xt),dailyCap:D(xt),maxCampaignDailyBudget:D(xt),maxCampaignLifetimeBudget:D(xt),killSwitchActive:Y,killSwitchAt:D(a),killSwitchReason:D(a),revision:M.check(Pe(0)),updatedAt:a}).annotate({identifier:"AdSpendPolicy"}),fh=D(xt),Hme=p({expectedRevision:M.check(Pe(0)),monthlyCap:fh,dailyCap:fh,maxCampaignDailyBudget:fh,maxCampaignLifetimeBudget:fh}).annotate({identifier:"AdSpendPolicyUpdate"}),Vme=p({active:Y,reason:u(a.check(oe(500)))}).annotate({identifier:"AdKillSwitchInput"}),tM=p({policy:mh,changed:Y,paused:p({campaigns:M.check(Pe(0)),adGroups:M.check(Pe(0)),ads:M.check(Pe(0))}),nextAction:a}).annotate({identifier:"AdKillSwitchResult"}),hh=j(["boost.create","campaign.create","campaign.activate","campaign.pause","campaign.archive","ad_group.status","ad_group.create","ad.status","ad.attach","creative.create","campaign.duplicate","budget.update"]),vu=j(["queued","preflight","creating","recording","reviewing","activating","succeeded","partial","failed","unresolved","cancelled"]),jJ=j(["queued","preflight","create","record","review","activate","finish"]),sn=p({id:hi,accountId:J,kind:hh,status:vu,step:jJ,input:Wt(a,H),result:D(Wt(a,H)),issues:U(lo),attempts:M.check(Pe(0)),canRetry:Y,nextAction:a,createdAt:a,updatedAt:a,startedAt:D(a),completedAt:D(a)}).annotate({identifier:"AdOperation"}),Jme=p({id:UU,accountId:J,idempotencyKey:a,intentHash:a,requestedByType:j(["user","api_key"]),requestedByUserId:D(ss),requestedByApiKeyId:D(ha),operationId:D(hi),createdAt:a}).annotate({identifier:"AdRequest"}),Yme=p({id:_U,accountId:J,provider:Ot,postId:_t,targetId:cr,actorAccountId:J,creativeId:D(Vc),campaignId:D(Lo),providerPostId:a,permalink:D(a),sourceHash:a,status:ls,revision:M.check(Pe(1)),operationId:D(hi),createdAt:a,updatedAt:a}).annotate({identifier:"AdBoost"}),Zme=p({expectedRevision:M.check(Do(0)),confirmation:v("activate_spend")}).annotate({identifier:"AdCampaignActivationInput"}),Xme=p({expectedRevision:M.check(Do(0))}).annotate({identifier:"AdCampaignPauseInput"}),ehe=p({expectedRevision:M.check(Do(0))}).annotate({identifier:"AdCampaignArchiveInput"}),the=p({status:j(["active","paused","archived"]),expectedRevision:M.check(Do(0))}).annotate({identifier:"AdEntityStatusUpdate"}),rhe=p({budget:fs,expectedRevision:M.check(Do(0))}).annotate({identifier:"AdBudgetUpdateInput"}),QJ=p({headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:u(a.check(oe(2048))),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdAttachAdCreative"}),nhe=p({name:a.check(be(1),oe(255)),budget:u(fs),targeting:u(Wt(a,H)),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdAdGroupCreateInput"}),ohe=p({actorAccountId:J,mediaId:a.check(L()),headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:a.check(oe(2048)),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCreativeCreateInput"}),ihe=p({name:u(a.check(be(1),oe(255)))}).annotate({identifier:"AdCampaignDuplicateInput"}),she=p({name:a.check(be(1),oe(255)),creativeId:u(Vc),creative:u(QJ),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdAttachAdInput"}),ahe=p({"idempotency-key":Vr}),HJ=p({id:J,name:a,provider:Ot,accountKind:v("ad_account"),available:Y,selected:Y,details:GJ,readiness:gi,capabilities:U(xi),policy:zJ,issues:U(lo),createdAt:a,updatedAt:a}).annotate({identifier:"AdAccount"}),rM=p({data:U(HJ),...ze}).annotate({identifier:"AdAccountList"}),che=p({workspaceId:de,state:u(WJ),...It.fields}),phe=p({workspaceId:de,provider:Ot,accountId:u(J)}),nM=p({attemptId:a.check(L()),provider:Ot,url:a,status:v("pending")}).annotate({identifier:"AdConnectLaunch"}),dhe=p({workspaceId:de,provider:v("openai_ads"),apiKey:a.check(be(1),oe(2048)),accountId:u(J),profileId:u(bt)}).annotate({identifier:"AdApiKeyConnectInput"}),oM=p({provider:v("openai_ads"),accountId:J,status:v("connected")}).annotate({identifier:"AdApiKeyConnectResult"}),uhe=p({workspaceId:de,accountId:J}),iM=p({accountId:J,selected:v(!0),campaignSyncQueued:Y,insightSyncQueued:Y}).annotate({identifier:"AdAccountSelection"}),sM=p({accountId:J,disconnected:v(!0),historyRetained:v(!0)}).annotate({identifier:"AdAccountDisconnected"}),aM=j(["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),VJ=j(["provider","pubnio"]),cM=a,Au=Wt(a,H),Cu=p({startAt:D(Ut),endAt:D(Ut),timezone:a}).annotate({identifier:"AdSchedule"}),pM=p({valid:Y,accountId:J,provider:Ot,actorAccountId:D(J),currency:Bn,budget:D(fs),schedule:D(Cu),killSwitchActive:Y,issues:U(lo),nextAction:a}).annotate({identifier:"AdValidation"}),JJ=p({postId:_t,postTargetId:u(cr),actorAccountId:u(J),budget:fs,schedule:u(Cu),targeting:u(Wt(a,H))}).annotate({identifier:"AdBoostDraft"}),lhe=p({workspaceId:de,accountId:J,...JJ.fields}).annotate({identifier:"AdBoostInput"}),YJ=j(["campaign.create","ad_group.create","creative.create","ad.create","campaign.activate","campaign.pause","campaign.archive","ad_group.activate","ad_group.pause","ad_group.archive","ad.activate","ad.pause","ad.archive","budget.update","boost.create"]),ZJ=p({budgetOwner:j(["campaign","ad_group","shared"]),maxAdGroups:u(M.check(Pe(1))),budgetUnit:j(["minor","micros"]),hierarchy:U(j(["campaign","ad_group","creative","ad"])),actor:j(["required","none"]),creative:j(["separate","embedded"]),review:j(["sync","pending","async"]),activation:j(["campaign","ad_group"])}).annotate({identifier:"AdCampaignPlanProfile"}),XJ=p({accountId:J,actorAccountId:u(J),budget:u(fs),schedule:u(Cu),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlanTarget"}),e3=p({headline:u(a.check(oe(255))),body:u(a.check(oe(2000))),callToAction:u(a.check(oe(64))),destinationUrl:u(a.check(oe(2048))),media:u(ps),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlanCreative"}),t3=p({name:a.check(be(1),oe(255)),creative:e3,providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlanAd"}),r3=p({name:a.check(be(1),oe(255)),budget:u(fs),targeting:u(Wt(a,H)),providerSettings:u(Wt(a,H)),ads:U(t3).check(be(1),oe(50))}).annotate({identifier:"AdCampaignPlanAdGroup"}),fhe=p({name:a.check(be(1),oe(255)),objective:aM,budget:u(fs),schedule:u(Cu),targets:U(XJ).check(be(1),oe(50)),adGroups:U(r3).check(be(1),oe(50)),providerSettings:u(Wt(a,H))}).annotate({identifier:"AdCampaignPlan"}),n3=p({accountId:J,provider:u(Ot),name:u(a),currency:u(Bn),budget:u(D(fs)),profile:u(ZJ),capabilities:u(U(YJ)),issues:U(lo)}).annotate({identifier:"AdCampaignPlanTargetValidation"}),dM=p({valid:Y,issues:U(lo),targets:U(n3)}).annotate({identifier:"AdCampaignPlanValidation"}),uI=j(["queued","creating","partial","succeeded","failed","unresolved"]),uM=p({accountId:J,provider:Ot,operationId:hi,status:vu}).annotate({identifier:"AdCampaignPlanTargetAccepted"}),lM=p({planId:a.check(L()),status:uI,targets:U(uM)}).annotate({identifier:"AdCampaignPlanAccepted"}),o3=p({planId:a.check(L()),status:uI,createdAt:a,targets:U(uM)}).annotate({identifier:"AdCampaignPlanListRow"}),fM=p({data:U(o3),...ze}).annotate({identifier:"AdCampaignPlanList"}),i3=p({accountId:J,provider:Ot,operationId:hi,campaignId:D(Lo),status:vu,issues:U(lo)}).annotate({identifier:"AdCampaignPlanTargetDetail"}),mM=p({planId:a.check(L()),status:uI,createdAt:a,targets:U(i3),issues:U(lo)}).annotate({identifier:"AdCampaignPlanDetail"}),hM=p({id:Lo,accountId:J,provider:Ot,externalId:a,name:a,objective:aM,status:ls,providerStatus:D(a),managed:VJ,revision:M.check(Pe(1)),budget:D(xt),bidStrategy:D(cM),schedule:Cu,providerSettings:Au,syncedAt:a}).annotate({identifier:"AdCampaign"}),yM=p({id:ya,campaignId:Lo,accountId:J,provider:Ot,kind:a,externalId:a,name:a,status:ls,providerStatus:D(a),revision:M.check(Pe(1)),budget:D(xt),bidStrategy:D(cM),targeting:Au,providerSettings:Au,syncedAt:a}).annotate({identifier:"AdGroup"}),Tu=p({id:Vc,accountId:J,provider:Ot,externalId:a,kind:a,actorAccountId:D(J),mediaId:D(a.check(L())),headline:D(a),body:D(a),callToAction:D(a),destinationUrl:D(a),providerSettings:Au,syncedAt:a}).annotate({identifier:"AdCreative"}),lI=j(["campaign","ad_group","ad"]),s3=a,a3=j(["fresh","stale","pending","partial","unavailable"]),wa=p({status:a3,syncedAt:D(a),nextSyncAt:u(a),retryAfter:u(a)}).annotate({identifier:"AdFreshness"}),mhe=p({accountId:u(J),campaignId:u(Lo),adGroupId:u(ya),adId:u(as),from:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),to:u(a.check(Ge(/^\d{4}-\d{2}-\d{2}$/))),level:u(lI),metrics:u(U(s3).check(oe(30))),cursor:It.fields.cursor,limit:u(M.check(Pe(1),mU(100)))}).annotate({identifier:"AdInsightQuery"}),c3=p({id:RU,accountId:J,level:lI,campaignId:D(Lo),adGroupId:D(ya),adId:D(as),creativeId:D(Vc),date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),currency:Bn,spend:xt,impressions:M.check(Pe(0)),clicks:M.check(Pe(0)),conversions:yr.check(Pe(0)),revenue:xt,metrics:Wt(a,yr),syncedAt:a}).annotate({identifier:"AdInsightRow"}),p3=p({currency:Bn,spend:xt,impressions:M.check(Pe(0)),clicks:M.check(Pe(0)),conversions:yr.check(Pe(0)),revenue:xt,metrics:Wt(a,yr)}).annotate({identifier:"AdInsightTotals"}),fI=p({from:a,to:a,level:lI,totals:U(p3),rowCount:M.check(Pe(0)),freshness:wa}).annotate({identifier:"AdInsightSummary"}),yh=p({id:as,accountId:J,campaignId:Lo,adGroupId:ya,creativeId:D(Vc),provider:Ot,externalId:a,name:a,format:D(a),status:ls,providerStatus:D(a),revision:M.check(Pe(1)),providerSettings:Au,syncedAt:a,creative:u(D(Tu)),insights:u(D(fI))}).annotate({identifier:"Ad"}),mI=p({data:U(hM),...ze,freshness:wa}).annotate({identifier:"AdCampaignList"}),d3=p({...yM.fields,insights:u(D(fI))}).annotate({identifier:"AdGroupListRow"}),gM=p({data:U(d3),...ze,freshness:wa}).annotate({identifier:"AdGroupList"}),xM=p({data:U(yh),...ze,freshness:wa}).annotate({identifier:"AdList"}),SM=p({data:U(Tu),...ze,freshness:wa}).annotate({identifier:"AdCreativeList"}),hI=p({data:U(c3),summary:fI,...ze,freshness:wa}).annotate({identifier:"AdInsightList"}),u3=p({adGroup:yM,ads:U(p({ad:yh,creative:D(Tu)}))}).annotate({identifier:"AdTreeNode"}),l3=p({campaign:hM,adGroups:U(u3)}).annotate({identifier:"AdTreeCampaign"}),bM=p({data:U(l3),...ze,freshness:wa}).annotate({identifier:"AdTree"}),IM=p({accountId:J,queuedScopes:U(j(["campaigns","ads_insights"])),nextDueAt:a,retryAfterSeconds:u(M)}).annotate({identifier:"AdRefreshAccepted"});var yI="2026-12-02",wM=[yI],gh=j(wM),EM="PubNio-Version";var gI=Fr.check(be(1),oe(100)),xI=a.check(be(1),oe(128)),Ou=p({id:bt,workspaceId:de,name:gI,externalId:D(xI),isDefault:Y,archived:Y,createdAt:a,updatedAt:a}).annotate({identifier:"WorkspaceProfile"}),kM=p({data:U(Ou),...ze}).annotate({identifier:"ProfileList"}),Ihe=p({workspaceId:de,includeArchived:u(Y),...It.fields}),whe=p({name:gI,externalId:u(xI)}),Ehe=p({name:u(gI),externalId:u(D(xI))}).check(Gt(({name:e,externalId:t})=>e!==void 0||t!==void 0||"Provide a name or external ID.")),khe=p({profileId:bt}),AM=p({archived:v(!0)});var Phe=j(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),xh=j(["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]);var vM=p({id:a.check(L()),type:xh,version:v(1),timestamp:Ut.check(Ge(/Z$/)),workspaceId:de,profileId:u(bt)}).annotate({identifier:"WorkspaceEventEnvelope"});var SI=a.check(L()),f3=a.check(L()),CM=xh,PM=j([...xh.literals,"webhook.test"]),Ghe=p({eventTypes:U(PM)}).annotate({identifier:"WebhookEventTypes"}),Re=vM.fields,Pu={postId:_t,targetId:cr,attemptId:zt,accountId:J,provider:er,placement:xr,revision:po},TM={providerRef:mu,url:u(a)},Sh={canRetry:Y,canReconcile:Y,nextAction:a},m3=j(["published","provider_draft","failed","unresolved","cancelled"]),h3={targetId:cr,accountId:J,provider:er,placement:xr,status:m3,url:u(a),issue:u(hu)},y3={targetId:cr,accountId:J,scheduledAt:D(a)},bh={postId:_t,revision:po,targets:U(p(h3))},bI=j(["live","backfill"]),OM={messageId:Nn,conversationId:Sn,accountId:J,provider:er,direction:nI,kind:oI,providerCreatedAt:a,freshness:bI},g3={threadId:jc,commentId:Qc,accountId:J,provider:er,providerCreatedAt:a,freshness:bI},x3={mentionId:Hc,accountId:J,provider:er,providerCreatedAt:a,freshness:bI},Ru={reviewId:Wm,accountId:J,provider:qe,locationId:u(a)},_u={accountId:J,provider:qe,accountKind:pr},zhe=mt([p({...Re,type:v("post.delivery.published"),data:p({...Pu,status:v("published"),...TM})}),p({...Re,type:v("post.delivery.provider_draft"),data:p({...Pu,status:v("provider_draft"),...TM})}),p({...Re,type:v("post.delivery.failed"),data:p({...Pu,status:v("failed"),issue:hu,canRetry:Sh.canRetry,nextAction:Sh.nextAction,providerRef:u(mu),url:u(a)})}),p({...Re,type:v("post.delivery.unresolved"),data:p({...Pu,status:v("unresolved"),issue:hu,canReconcile:Sh.canReconcile,nextAction:Sh.nextAction,providerRef:u(mu),url:u(a)})}),p({...Re,type:v("post.delivery.cancelled"),data:p({...Pu,status:v("cancelled")})}),p({...Re,type:v("post.scheduled"),data:p({postId:_t,revision:po,targets:U(p(y3))})}),p({...Re,type:v("post.published"),data:p(bh)}),p({...Re,type:v("post.partial"),data:p(bh)}),p({...Re,type:v("post.failed"),data:p(bh)}),p({...Re,type:v("post.cancelled"),data:p(bh)}),p({...Re,type:v("inbox.message.received"),data:p(OM)}),p({...Re,type:v("inbox.message.sent"),data:p(OM)}),p({...Re,type:v("inbox.comment.received"),data:p(g3)}),p({...Re,type:v("inbox.review.new"),data:p(Ru)}),p({...Re,type:v("inbox.review.updated"),data:p(Ru)}),p({...Re,type:v("inbox.review.deleted"),data:p(Ru)}),p({...Re,type:v("inbox.review.restored"),data:p(Ru)}),p({...Re,type:v("inbox.review.replied"),data:p(Ru)}),p({...Re,type:v("inbox.mention.received"),data:p(x3)}),p({...Re,type:v("inbox.message.delivered"),data:p({messageIds:U(Nn),conversationId:u(Sn),accountId:J,provider:er,deliveredAt:a})}),p({...Re,type:v("inbox.message.read"),data:p({messageIds:U(Nn),conversationId:u(Sn),accountId:J,provider:er,readAt:a})}),p({...Re,type:v("inbox.message.edited"),data:p({messageId:Nn,conversationId:Sn,accountId:J,provider:er})}),p({...Re,type:v("inbox.message.deleted"),data:p({messageId:Nn,conversationId:Sn,accountId:J,provider:er})}),p({...Re,type:v("inbox.reaction.received"),data:p({messageId:u(Nn),conversationId:u(Sn),accountId:J,provider:er,reaction:a,action:j(["add","remove"])})}),p({...Re,type:v("inbox.referral.received"),data:p({messageId:u(Nn),conversationId:u(Sn),accountId:J,provider:er,ref:a,source:a,adId:u(a)})}),p({...Re,type:v("inbox.conversation.started"),data:p({conversationId:Sn,accountId:J,provider:er,participantExternalId:a})}),p({...Re,type:v("analytics.post.synced"),data:p({postId:_t,accountId:J,provider:qe})}),p({...Re,type:v("analytics.account.synced"),data:p({accountId:J,provider:qe})}),p({...Re,type:v("ads.operation.succeeded"),data:p({operationId:hi,accountId:J,kind:hh,status:j(["succeeded","partial"]),nextAction:a})}),p({...Re,type:v("ads.operation.failed"),data:p({operationId:hi,accountId:J,kind:hh,status:j(["failed","unresolved","cancelled"]),issue:lo,canRetry:Y,nextAction:a})}),p({...Re,type:v("ads.kill_switch.activated"),data:p({accountId:J,revision:M.check(Pe(1)),reason:D(a),pausedCampaigns:M.check(Pe(0)),pausedAdGroups:M.check(Pe(0)),pausedAds:M.check(Pe(0))})}),p({...Re,type:v("ads.lead.received"),data:p({accountId:J,leadId:a,pageId:u(a),formId:u(a),adId:u(a),adGroupId:u(a)})}),p({...Re,type:v("ads.campaign.status_changed"),data:p({accountId:J,campaignId:Lo,provider:Ot,status:ls})}),p({...Re,type:v("ads.ad_group.status_changed"),data:p({accountId:J,adGroupId:ya,provider:Ot,status:ls})}),p({...Re,type:v("ads.ad.status_changed"),data:p({accountId:J,adId:as,provider:Ot,status:ls})}),p({...Re,type:v("ads.ad_account.status_changed"),data:p({accountId:J,provider:Ot,status:dI})}),p({...Re,type:v("ads.ad.review.approved"),data:p({accountId:J,adId:as,provider:Ot})}),p({...Re,type:v("ads.ad.review.rejected"),data:p({accountId:J,adId:as,provider:Ot})}),p({...Re,type:v("ads.sync.failed"),data:p({accountId:J,provider:Ot})}),p({...Re,type:v("ads.sync.recovered"),data:p({accountId:J,provider:Ot})}),p({...Re,type:v("ads.initial_sync.completed"),data:p({accountId:J,provider:Ot})}),p({...Re,type:v("account.connected"),data:p({..._u,reconnected:Y})}),p({...Re,type:v("account.disconnected"),data:p({..._u,reason:j(["disconnected","expired","revoked","deauthorized"])})}),p({...Re,type:v("account.permissions_changed"),data:p({..._u,missingScopes:U(a),missingTasks:U(a)})}),p({...Re,type:v("account.restricted"),data:p({..._u,reason:v("publish_failures")})}),p({...Re,type:v("account.recovered"),data:p(_u)}),p({...Re,type:v("billing.subscription.updated"),data:p({plan:Zc,status:yu,interval:D(Hm),periodStart:a,periodEnd:a,cancelAtPeriodEnd:Y})}),p({...Re,type:v("billing.credit.topped_up"),data:p({amountMicros:M,balanceAfterMicros:M,kind:Ym})}),p({...Re,type:v("billing.credit.low"),data:p({balanceMicros:M,thresholdMicros:M})}),p({...Re,type:v("billing.spend_cap.reached"),data:p({capMicros:M,periodSpendMicros:M,estimatedMicros:M})}),p({...Re,type:v("billing.invoice.payment_failed"),data:p({invoiceId:a,amountDueMinor:M,hostedInvoiceUrl:D(a)})}),p({...Re,type:v("webhook.test"),data:p({endpointId:lu})})]).annotate({identifier:"WebhookEvent"}),II=j(["publishing","inbox","analytics","ads","scheduling","accounts","billing"]),wI=Fr.check(be(1),oe(100)),RM=a.check(oe(2048)),S3=u(U(J)).annotate({description:"Only deliver events for these accounts. Empty or omitted means every account. Duplicates are ignored."}),b3=u(U(II)).annotate({description:"Drop every event in these families. Empty or omitted means no family is dropped. Duplicates are ignored."}),I3=u(D(U(J))).annotate({description:"Only deliver events for these accounts. Omit to keep the current filter; null or an empty array clears it to every account."}),w3=u(D(U(II))).annotate({description:"Drop every event in these families. Omit to keep the current denylist; null or an empty array clears it."}),EI=U(CM).check(be(1),oe(CM.literals.length),Gt((e)=>new Set(e).size===e.length||"Choose each event type only once.")),E3=p({workspaceId:de,endpointId:lu}),jhe=p({...E3.fields,deliveryId:SI}),Qhe=p({name:wI,url:RM,eventTypes:EI,enabled:u(Y),profileId:u(bt),accountIds:S3,disabledResourceGroups:b3}),Hhe=p({name:u(wI),eventTypes:u(EI),enabled:u(Y),profileId:u(D(bt)),accountIds:I3,disabledResourceGroups:w3}).check(Gt((e)=>Object.keys(e).length>0||"Provide at least one endpoint change.")),Ih=p({id:lu,workspaceId:de,name:wI,eventTypes:EI,enabled:Y,profileId:D(bt),accountIds:U(J),disabledResourceGroups:U(II),apiVersion:gh,destinationOrigin:a,createdAt:a,updatedAt:a,deletedAt:D(a)}).annotate({identifier:"WebhookEndpoint"}),kI=p({...Ih.fields,url:D(RM)}),k3=a.check(Ge(/^whsec_[A-Za-z0-9+/]{43}=$/)),_M=p({endpoint:kI,secret:k3}),UM=p({data:U(Ih),...ze}).annotate({identifier:"WebhookEndpointList"}),DM=p({deleted:v(!0)}),LM=p({deliveryId:SI}),AI=j(["pending","sending","delivered","failed","cancelled"]),A3=j(["timeout","network","http_status","redirect","destination_rejected","configuration_unavailable","expired","attempts_exhausted"]),wh=p({id:SI,workspaceId:de,endpointId:lu,eventId:f3,eventType:PM,status:AI,attemptCount:M,createdAt:a,nextAttemptAt:D(a),lastAttemptAt:D(a),lastHttpStatus:D(M),lastError:D(A3),completedAt:D(a)}).annotate({identifier:"WebhookDelivery"}),MM=p({data:U(wh),...ze}).annotate({identifier:"WebhookDeliveryList"});var vI="~effect/http/HttpBody";class TI{[vI];constructor(){this[vI]=vI}[Xr](){return this.toJSON()}toString(){return rt(this,{ignoreToString:!0})}}class FM extends TI{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}}var NM=new FM;class CI extends TI{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(e,t,r,n){super();this._body=e,this.text=n,this.contentType=t,this.contentLength=r}get body(){return this._body??=v3(this.text)}toJSON(){return{_id:"effect/HttpBody",_tag:"Uint8Array",body:this.contentType.startsWith("text/")||this.contentType.endsWith("json")?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}}var BM=new TextEncoder,Eh=globalThis.Buffer,v3=Eh!==void 0?(e)=>Eh.from(e,"utf8"):(e)=>BM.encode(e),KM=(e,t)=>{if(typeof e!=="string")e=e===void 0?"":String(e);if(Eh!==void 0)return new CI(void 0,t??"text/plain",Eh.byteLength(e,"utf8"),e);let r=BM.encode(e);return new CI(r,t??"text/plain",r.length,e)},qM=(e,t)=>KM(JSON.stringify(e),t??"application/json");var C3=Object.getPrototypeOf(la),WM=()=>Object.create(C3);var GM="~effect/http/HttpServerResponse";var O3=(e,t)=>{if(e?.contentType)return e.contentType;else if(e?.headers)return t["content-type"]};var zM=(e,t)=>{let r=t?.headers?R_(t.headers):la;return R3({status:t?.status??200,statusText:t?.statusText,headers:r,cookies:t?.cookies,body:qM(e,O3(t,r))})};var P3={...qr,[GM]:GM,[$m]:!0,toJSON(){return{_id:"HttpServerResponse",status:this.status,statusText:this.statusText,headers:zn(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},R3=(e,t)=>{let r=Object.create(P3);if(r.status=e.status,r.statusText=e.statusText,r.cookies=e.cookies??T_,r.body=e.body??NM,r.body._tag!=="Empty"&&(r.body.contentType||r.body.contentLength!==void 0)){let n=t!==void 0,o=n?t:e.headers===void 0||e.headers===la?WM():__({...e.headers});if(r.body.contentType&&(!n||o["content-type"]===void 0))o["content-type"]=r.body.contentType;if(r.body.contentLength!==void 0&&(!n||o["content-length"]===void 0))o["content-length"]=r.body.contentLength.toString();r.headers=o}else r.headers=t??e.headers??la;return r};var QM="~effect/http/HttpServerRespondable";var kh="application/problem+json",VM="about:blank",Ea=(e)=>u(e).pipe(ub(()=>md)),JM=(e,t)=>fU(z(t))(e).pipe(ub(()=>fx(t))),OI=(e)=>JM(is(e),e),_3=dU(p({type:JM(a,VM),status:Ea(yr),title:Ea(a),detail:Ea(a),instance:Ea(a)}),[Wt(a,H)]);var U3={_tag:"Json",contentType:kh},ue=()=>(e,t,r,n)=>{let o=p({detail:Ea(a),instance:Ea(a),...r,type:is(t.type),status:OI(t.status),title:OI(t.title)}),i=cU(o),s=cu(e)(o,{description:t.title,httpApiStatus:t.status,"~httpApiEncoding":U3,...n});return Object.assign(s.prototype,{_tag:e,[$m]:t.status<500,[QM](){return De(i(this),(c)=>zM(c,{status:t.status,contentType:kh}))}}),Object.defineProperty(s.prototype,"message",{get(){return this.detail??t.title},configurable:!0}),s},D3=p({path:U(mt([a,yr])),message:a});class L3 extends ue()("UploadTooLarge",{type:"about:blank",status:413,title:"Content Too Large"}){}class ZM extends ue()("AuthenticationRequired",{type:"urn:pubnio:problem:authentication-required",status:401,title:"Unauthorized"},{docUrl:u(a)}){}class XM extends ue()("Forbidden",{type:"urn:pubnio:problem:forbidden",status:403,title:"Forbidden"},{requiredScope:u(gu),docUrl:u(a)}){}class eF extends ue()("HumanActorRequired",{type:"urn:pubnio:problem:human-actor-required",status:403,title:"Human actor required"},{code:v("human_actor_required"),nextAction:a}){}class tF extends ue()("OwnerRequired",{type:"urn:pubnio:problem:owner-required",status:403,title:"Owner permission required"},{code:v("owner_required"),nextAction:a}){}class rF extends ue()("SeatLimitReached",{type:"urn:pubnio:problem:seat-limit-reached",status:402,title:"Seat limit reached"},{code:v("seat_limit_reached"),seatsUsed:M,seatsLimit:M,nextAction:a}){}class nF extends ue()("AlreadyMember",{type:"urn:pubnio:problem:already-member",status:409,title:"Already a workspace member"},{code:v("already_member"),nextAction:a}){}class oF extends ue()("InviteAlreadyPending",{type:"urn:pubnio:problem:invite-already-pending",status:409,title:"Invite already pending"},{code:v("invite_already_pending"),nextAction:a}){}class iF extends ue()("LastOwnerRequired",{type:"urn:pubnio:problem:last-owner-required",status:409,title:"Last owner required"},{code:v("last_owner_required"),nextAction:a}){}class sF extends ue()("InviteExpired",{type:"urn:pubnio:problem:invite-expired",status:410,title:"Invite expired"},{code:v("invite_expired"),nextAction:a}){}class aF extends ue()("InviteEmailMismatch",{type:"urn:pubnio:problem:invite-email-mismatch",status:403,title:"Invite email mismatch"},{code:v("invite_email_mismatch"),nextAction:a}){}class cF extends ue()("NotFound",{type:"urn:pubnio:problem:not-found",status:404,title:"Not Found"}){}class pF extends ue()("Conflict",{type:"urn:pubnio:problem:conflict",status:409,title:"Conflict"}){}class dF extends ue()("Unavailable",{type:"urn:pubnio:problem:unavailable",status:503,title:"Service Unavailable"}){}class uF extends ue()("UnsupportedApiVersion",{type:"urn:pubnio:problem:unsupported-api-version",status:400,title:"Unsupported API version"},{code:v("unsupported_api_version"),param:a,supportedVersions:U(gh),nextAction:a}){}class M3 extends ue()("InvalidCursor",{type:"urn:pubnio:problem:invalid-cursor",status:400,title:"Invalid cursor"},{code:u(v("invalid_cursor")),nextAction:u(a)}){}var Uu=p({accountId:J,name:a}).annotate({identifier:"ProblemCandidate"});class lF extends ue()("InvalidPublication",{type:"urn:pubnio:problem:invalid-publication",status:422,title:"Invalid publication"},{issues:U(co),candidates:u(U(Uu)),code:u(v("invalid_publication")),nextAction:u(a)}){}var fF="x-request-id",mF=D3;class hF extends ue()("InternalFailure",{type:"urn:pubnio:problem:internal-error",status:500,title:"Internal Server Error"},{requestId:a.check(L())}){}class yF extends ue()("AttemptChanged",{type:"urn:pubnio:problem:attempt-changed",status:409,title:"Delivery attempt changed"},{currentAttemptId:zt}){}class gF extends ue()("IdempotencyConflict",{type:"urn:pubnio:problem:idempotency-conflict",status:409,title:"Idempotency key already used"},{code:u(v("idempotency_conflict")),nextAction:u(a)}){}class xF extends ue()("AccountAmbiguous",{type:"urn:pubnio:problem:account-ambiguous",status:422,title:"Account ambiguous"},{code:v("account_ambiguous"),provider:qe,param:a,candidates:U(Uu),nextAction:a}){}class SF extends ue()("ProviderMismatch",{type:"urn:pubnio:problem:provider-mismatch",status:422,title:"Provider mismatch"},{code:v("provider_mismatch"),provider:qe,expectedProvider:qe,param:a,nextAction:a}){}class bF extends ue()("PublishAccountNotFound",{type:"urn:pubnio:problem:publish-account-not-found",status:422,title:"Publishing account not found"},{code:v("account_not_found"),provider:u(qe),accountId:u(J),param:a,candidates:u(U(Uu)),nextAction:a}){}class IF extends ue()("MediaUploadConflict",{type:"urn:pubnio:problem:media-upload-conflict",status:409,title:"Media upload conflict"},{reason:RD}){}class wF extends ue()("DestinationAlreadySubmitted",{type:"urn:pubnio:problem:destination-already-submitted",status:409,title:"Destination already submitted"}){}class EF extends ue()("DeliveryNotRetryable",{type:"urn:pubnio:problem:delivery-not-retryable",status:409,title:"Delivery cannot be retried"}){}class kF extends ue()("DeliveryNotReconcilable",{type:"urn:pubnio:problem:delivery-not-reconcilable",status:409,title:"Delivery cannot be reconciled"}){}class AF extends ue()("DeliveryScheduleLocked",{type:"urn:pubnio:problem:delivery-schedule-locked",status:409,title:"Delivery schedule cannot change"}){}class vF extends ue()("PostRevisionConflict",{type:"urn:pubnio:problem:post-revision-conflict",status:409,title:"Post revision changed"},{currentRevision:po}){}class CF extends ue()("QueueNotFound",{type:"urn:pubnio:problem:queue-not-found",status:404,title:"Queue not found"}){}class TF extends ue()("QueueAlreadyExists",{type:"urn:pubnio:problem:queue-already-exists",status:409,title:"Queue already exists"}){}class OF extends ue()("QueueDefaultRequired",{type:"urn:pubnio:problem:queue-default-required",status:409,title:"Queue default required"},{code:v("queue_default_required"),accountId:J,nextAction:a}){}class PF extends ue()("QueueVersionConflict",{type:"urn:pubnio:problem:queue-version-conflict",status:409,title:"Queue version changed"},{currentVersion:M.check(Pe(1))}){}class RF extends ue()("QueueUnavailable",{type:"urn:pubnio:problem:queue-unavailable",status:409,title:"Queue unavailable"},{reason:vL}){}class _F extends ue()("QueueCapacityReached",{type:"urn:pubnio:problem:queue-capacity-reached",status:409,title:"Queue capacity reached"},{reason:CL}){}class UF extends ue()("QueueNoSlotAvailable",{type:"urn:pubnio:problem:queue-no-slot-available",status:409,title:"No queue slot available"},{horizonEndsAt:a}){}class DF extends ue()("QueueSlotConflict",{type:"urn:pubnio:problem:queue-slot-conflict",status:409,title:"Queue slot conflict"},{scheduledAt:a,suggestedSlots:U(a)}){}class LF extends ue()("InvalidTimezone",{type:"urn:pubnio:problem:invalid-timezone",status:422,title:"Invalid time zone"},{code:v("invalid_timezone"),timezone:a,nextAction:a}){}class MF extends ue()("InvalidQueue",{type:"urn:pubnio:problem:invalid-queue",status:422,title:"Invalid queue"},{issues:U(FL)}){}class FF extends ue()("ScheduleRangeTooWide",{type:"urn:pubnio:problem:schedule-range-too-wide",status:422,title:"Schedule range too wide"},{maxDays:M}){}class NF extends ue()("WebhookTestRateLimited",{type:"urn:pubnio:problem:webhook-test-rate-limited",status:429,title:"Webhook test rate limited"}){}class BF extends ue()("WebhookDeliveryNotReplayable",{type:"urn:pubnio:problem:webhook-delivery-not-replayable",status:409,title:"Webhook delivery not replayable"},{code:v("webhook_delivery_not_replayable"),deliveryStatus:AI,nextAction:a}){}class KF extends ue()("ProviderPermissionRequired",{type:"urn:pubnio:problem:provider-permission-required",status:403,title:"Provider permission required"},{provider:qe,missingScopes:U(a),missingRoles:U(a),reason:u(a),reconnectRequired:u(Y)}){}class qF extends ue()("ProviderReconnectRequired",{type:"urn:pubnio:problem:provider-reconnect-required",status:409,title:"Provider reconnect required"},{provider:qe,missingScopes:U(a),reason:u(a)}){}class $F extends ue()("ProviderRateLimited",{type:"urn:pubnio:problem:provider-rate-limited",status:429,title:"Provider rate limited"},{provider:qe,retryAfterSeconds:u(M)}){}class WF extends ue()("ProviderUnavailable",{type:"urn:pubnio:problem:provider-unavailable",status:503,title:"Provider unavailable"},{provider:qe,retryAfterSeconds:u(M)}){}class GF extends ue()("CapabilityUnsupported",{type:"urn:pubnio:problem:capability-unsupported",status:422,title:"Capability unsupported"},{capability:yi,provider:qe,accountKind:pr}){}class zF extends ue()("AnalyticsRangeInvalid",{type:"urn:pubnio:problem:analytics-range-invalid",status:400,title:"Analytics range invalid"},{reason:j(["invalid_timezone","invalid_range","range_too_wide"])}){}class jF extends ue()("AnalyticsMetricUnsupported",{type:"urn:pubnio:problem:analytics-metric-unsupported",status:400,title:"Analytics metric unsupported"},{metrics:U(a),maxMetrics:u(M)}){}class QF extends ue()("AnalyticsRefreshConflict",{type:"urn:pubnio:problem:analytics-refresh-conflict",status:409,title:"Analytics refresh conflict"},{reason:j(["not_published","deleted","account_analytics_pending"])}){}class HF extends ue()("CapabilityUnverified",{type:"urn:pubnio:problem:capability-unverified",status:409,title:"Capability unverified"},{capability:yi,provider:qe}){}class VF extends ue()("InboxReplyWindowClosed",{type:"urn:pubnio:problem:inbox-reply-window-closed",status:409,title:"Inbox reply window closed"},{provider:qe,policy:iI,endsAt:D(a)}){}class JF extends ue()("InboxTargetChanged",{type:"urn:pubnio:problem:inbox-target-changed",status:409,title:"Inbox target changed"},{targetId:a,state:j(["deleted","changed","unsupported"])}){}class YF extends ue()("InboxSyncInProgress",{type:"urn:pubnio:problem:inbox-sync-in-progress",status:409,title:"Inbox sync already running"},{syncRunId:a.check(L()),retryAfterSeconds:M}){}class ZF extends ue()("InboxUnsupportedContent",{type:"urn:pubnio:problem:inbox-unsupported-content",status:422,title:"Inbox content unsupported"},{kind:j(["image","video","audio","file","text","unknown"]),capability:yi}){}var F3=[VF,JF,YF,ZF];class XF extends ue()("AdAccountNotReady",{type:"urn:pubnio:problem:ad-account-not-ready",status:409,title:"Ad account not ready"},{reason:j(["unavailable","needs_reconnect","permission_missing","account_disabled"]),missingScopes:u(U(a))}){}class eN extends ue()("AdAccountNotSelected",{type:"urn:pubnio:problem:ad-account-not-selected",status:409,title:"Ad account not selected"},{accountId:a}){}class tN extends ue()("AdInsightRangeInvalid",{type:"urn:pubnio:problem:ad-insight-range-invalid",status:422,title:"Ad insight range invalid"},{reason:j(["invalid_range","range_too_wide"]),maxDays:u(M)}){}class rN extends ue()("AdRefreshRateLimited",{type:"urn:pubnio:problem:ad-refresh-rate-limited",status:429,title:"Ad refresh rate limited"},{retryAfterSeconds:M.check(Pe(0))}){}class nN extends ue()("AdRevisionConflict",{type:"urn:pubnio:problem:ad-revision-conflict",status:409,title:"Ad resource revision conflict"},{resource:j(["spend_policy","campaign","ad_group","ad","boost"]),expectedRevision:M.check(Pe(0)),actualRevision:M.check(Pe(0)),nextAction:a}){}class oN extends ue()("AdBudgetExceeded",{type:"urn:pubnio:problem:ad-budget-exceeded",status:422,title:"Ad budget exceeds a spend cap"},{reason:j(["daily_cap","monthly_cap","campaign_daily_max","campaign_lifetime_max"]),limit:xt,requested:xt,committed:xt,nextAction:a}){}class iN extends ue()("AdBudgetBelowMinimum",{type:"urn:pubnio:problem:ad-budget-below-minimum",status:422,title:"Ad budget is below the provider minimum"},{minimum:xt,requested:xt,nextAction:a}){}class sN extends ue()("AdCurrencyMismatch",{type:"urn:pubnio:problem:ad-currency-mismatch",status:422,title:"Ad currency does not match the account"},{expected:Bn,actual:Bn,nextAction:a}){}class aN extends ue()("AdSpendForbidden",{type:"urn:pubnio:problem:ad-spend-forbidden",status:403,title:"Ad spend permission required"},{reason:j(["owner_required","api_key_forbidden","confirmation_required","monthly_cap_required","provider_managed"]),nextAction:a}){}class cN extends ue()("AdKillSwitchActive",{type:"urn:pubnio:problem:ad-kill-switch-active",status:409,title:"Ad kill switch is active"},{accountId:J,activatedAt:D(a),reason:D(a),nextAction:a}){}class pN extends ue()("AdOperationNotRetryable",{type:"urn:pubnio:problem:ad-operation-not-retryable",status:409,title:"Ad operation is not retryable"},{operationStatus:vu,nextAction:a}){}class dN extends ue()("AdProviderRejected",{type:"urn:pubnio:problem:ad-provider-rejected",status:422,title:"Ad provider rejected the request"},{provider:Ot,code:a,retryable:Y,providerCode:u(a),providerMessage:u(a),issues:U(lo),nextAction:a}){}class uN extends ue()("InvalidAdRequest",{type:"urn:pubnio:problem:invalid-ad-request",status:400,title:"Invalid ad request"},{reason:a,field:u(a),nextAction:a}){}var N3=[KF,qF,$F,WF,GF,HF];class B3 extends ue()("CommentTargetInvalid",{type:"urn:pubnio:problem:comment-target-invalid",status:400,title:"Comment target invalid"},{code:v("comment_target_invalid"),reason:a,targetKind:u(ku),nextAction:a}){}class K3 extends ue()("CommentRejected",{type:"urn:pubnio:problem:comment-rejected",status:422,title:"Comment rejected"},{code:v("comment_rejected"),provider:qe,targetKind:ku,nextAction:a}){}class q3 extends ue()("CommentUnresolved",{type:"urn:pubnio:problem:comment-unresolved",status:409,title:"Comment outcome unresolved"},{code:v("comment_unresolved"),actionId:mi,nextAction:a}){}var $3=[lF,yF,gF,wF,EF,kF,AF,vF,xF,SF,bF],W3=[zF,jF,QF],G3=[XF,eN,tN,rN,nN,oN,iN,sN,aN,cN,pN,dN,uN],z3=[CF,TF,OF,PF,RF,_F,UF,DF,MF,FF],j3=[LF];class lN extends ue()("InsufficientCredit",{type:"urn:pubnio:problem:insufficient-credit",status:402,title:"Insufficient prepaid credit"},{code:v("insufficient_credit"),balanceMicros:M,requiredMicros:M,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class fN extends ue()("SpendCapReached",{type:"urn:pubnio:problem:spend-cap-reached",status:402,title:"Monthly spend cap reached"},{code:v("spend_cap_reached"),capMicros:M,periodSpendMicros:M,estimatedMicros:M,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class mN extends ue()("BillingInactive",{type:"urn:pubnio:problem:billing-inactive",status:402,title:"Workspace billing is inactive"},{code:v("billing_inactive"),subscriptionStatus:yu,fundingUrl:a,canManageBilling:Y,nextAction:a}){}class hN extends ue()("TopUpAmountInvalid",{type:"urn:pubnio:problem:top-up-amount-invalid",status:400,title:"Top-up amount is out of range"},{code:v("top_up_amount_invalid"),minMinor:M,maxMinor:M,nextAction:a}){}class yN extends ue()("InvalidBillingDateRange",{type:"urn:pubnio:problem:invalid-billing-date-range",status:400,title:"Invalid billing date range"},{code:v("invalid_billing_date_range"),nextAction:a}){}class gN extends ue()("BillingRevisionConflict",{type:"urn:pubnio:problem:billing-revision-conflict",status:409,title:"Billing settings changed concurrently"},{code:v("billing_revision_conflict"),expectedVersion:M,actualVersion:M,nextAction:a}){}class xN extends ue()("SubscriptionAlreadyActive",{type:"urn:pubnio:problem:subscription-already-active",status:409,title:"Subscription is already active"},{code:v("subscription_already_active"),plan:Zc,nextAction:a}){}class SN extends ue()("CheckoutAlreadyCompleted",{type:"urn:pubnio:problem:checkout-already-completed",status:409,title:"Checkout session already completed"},{code:v("checkout_already_completed"),checkoutId:a,nextAction:a}){}class bN extends ue()("BillingCustomerMissing",{type:"urn:pubnio:problem:billing-customer-missing",status:409,title:"No billing customer exists yet"},{code:v("billing_customer_missing"),nextAction:a}){}class IN extends ue()("BillingProviderMismatch",{type:"urn:pubnio:problem:billing-provider-mismatch",status:409,title:"Workspace billing gateway mismatch"},{code:v("billing_provider_mismatch"),workspaceGateway:Vm,requestedGateway:Vm,nextAction:a}){}class wN extends ue()("BillingNotConfigured",{type:"urn:pubnio:problem:billing-not-configured",status:503,title:"Billing gateway is not configured"},{code:v("billing_not_configured"),nextAction:a}){}class EN extends ue()("BillingUnavailable",{type:"urn:pubnio:problem:billing-unavailable",status:503,title:"Billing gateway is temporarily unavailable"},{code:v("billing_unavailable"),retryable:Y,nextAction:a}){}var Q3=[lN,fN,mN],H3=[...Q3,hN,yN,gN,xN,SN,bN,IN,wN,EN],V3=[rF,nF,oF,iF,sF,aF],kN=mt([ZM,XM,eF,tF,cF,pF,dF,uF,...$3,...H3,...z3,...j3,...V3,...F3,...N3,...W3,...G3,hF,NF,BF,IF]);var ka=j(["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]),AN=j(["count","milliseconds","ratio"]),vN=j(["sum","unique","latest","weighted","ratio"]),CN=j(["post","account"]),J3=j(["total","day"]),TN=j(["available","pending","unsupported","deprecated","renamed","permission_missing","access_pending","stale","deleted","private","not_applicable"]),Y3=Wt(a,yr),Ah=p({key:ka,value:D(yr),availability:TN,reason:u(a),replacedBy:u(ka),renamedTo:u(ka),missingScopes:u(U(a)),reconnectRequired:u(Y),retryAfter:u(a),observedAt:u(a),total:u(D(yr)),breakdown:u(Y3)}).annotate({identifier:"MetricReading"}),Z3=p({key:ka,scopes:U(CN),unit:AN,aggregation:vN,definition:a}).annotate({identifier:"MetricDefinition"}),X3=p({key:ka,scope:CN,granularity:J3,unit:AN,aggregation:vN,availability:TN,supported:Y,reason:u(a),renamedFrom:u(a),replacedBy:u(ka)}).annotate({identifier:"MetricCapability"}),e6=j(["ready","permission_required","access_pending","reconnect_required","disabled"]),t6=p({provider:qe,accountKinds:U(pr),placements:U(xr),metrics:U(X3),historyDays:M.check(Do(0)),latencySeconds:M.check(Pe(0)),firstAvailableAfterSeconds:M.check(Pe(0)),requiredScopes:U(a),comments:Y}).annotate({identifier:"ProviderCapabilities"}),r6=p({accountId:J,provider:qe,accountKind:pr,readiness:e6,capability:xi,missingScopes:U(a),reconnectRequired:Y,accessPending:Y}).annotate({identifier:"AnalyticsAccountCapability"}),ON=p({metrics:U(Z3),providers:U(t6),accounts:U(r6),checkedAt:a}).annotate({identifier:"AnalyticsCapabilities"}),n6=j(["fresh","stale","pending","partial","unavailable"]),vh=p({status:n6,observedAt:D(a),retryAfter:u(a)}).annotate({identifier:"AnalyticsFreshness"}),PN=p({from:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),to:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),timezone:v("UTC"),dayBasis:v("provider_utc")}).annotate({identifier:"AnalyticsDateRange"}),age=j(["provider_daily","snapshot_delta","provider_lifetime","provider_total"]),RN=p({date:a.check(Ge(/^\d{4}-\d{2}-\d{2}$/)),metrics:U(Ah)}).annotate({identifier:"AnalyticsPoint"}),o6=j(["available","pending","unavailable"]),i6=p({targetId:cr,attemptId:D(zt),accountId:J,provider:qe,placement:xr,providerPostId:D(a),publishedAt:D(a),state:o6,metrics:U(Ah),series:u(U(RN)),freshness:vh}).annotate({identifier:"PostAnalyticsTarget"}),RI=p({postId:_t,workspaceId:de,range:PN,targets:U(i6),freshness:vh}).annotate({identifier:"PostAnalytics"}),s6=p({accountId:J,provider:qe,accountKind:pr,profileId:bt,name:a,metrics:U(Ah),freshness:vh}).annotate({identifier:"AnalyticsAccountSummary"}),_N=p({accountId:J,workspaceId:de,provider:qe,accountKind:pr,profileId:bt,name:a,range:PN,metrics:U(Ah),series:u(U(RN)),freshness:vh}).annotate({identifier:"AccountAnalytics"}),UN=p({data:U(s6),...ze}).annotate({identifier:"AccountAnalyticsList"}),cge=p({workspaceId:de,postId:u(_t),targetId:u(cr),metrics:u(U(ka).check(oe(30)))}).check(Gt(({postId:e,targetId:t})=>e!==void 0||t!==void 0||"Send postId or targetId to refresh a published post.")),a6=j(["queued","running","succeeded","failed","paused","deleted","inaccessible"]),_I=p({id:a.check(L()),workspaceId:de,subjectKind:a,subjectId:a.check(L()),status:a6,nextDueAt:D(a),lastSuccessAt:D(a),errorKind:D(a),createdAt:a}).annotate({identifier:"AnalyticsRefresh"});var DN={name:"@pubnio/sdk",version:"0.2.8",description:"JavaScript and TypeScript client for the PubNio API",type:"module",exports:{".":"./src/index.ts","./solid":"./src/solid.ts","./internal":"./src/internal.ts","./package.json":"./package.json"},dependencies:{"@pubnio/protocol":"workspace:*",effect:"4.1.7"},peerDependencies:{"@tanstack/solid-query":"6.0.0-rc.6"},peerDependenciesMeta:{"@tanstack/solid-query":{optional:!0}},devDependencies:{"@hey-api/openapi-ts":"0.99.0","@tanstack/solid-query":"6.0.0-rc.6","dts-bundle-generator":"10.0.0",typescript:"6.0.3"},scripts:{pack:"bun script/pack.ts",build:"bun script/pack.ts"},sideEffects:!1,engines:{node:">=20.19.0"},publishConfig:{access:"public"},files:["dist","README.md"]};function LN({onRequest:e,onSseError:t,onSseEvent:r,responseTransformer:n,responseValidator:o,sseDefaultRetryDelay:i,sseMaxRetryAttempts:s,sseMaxRetryDelay:c,sseSleepFn:l,url:S,...m}){let g,w=l??((y)=>new Promise((h)=>setTimeout(h,y)));return{stream:async function*(){let y=i??3000,h=0,x=m.signal??new AbortController().signal;while(!0){if(x.aborted)break;h++;let G=m.headers instanceof Headers?m.headers:new Headers(m.headers);if(g!==void 0)G.set("Last-Event-ID",g);try{let X={redirect:"follow",...m,body:m.serializedBody,headers:G,signal:x},I=new Request(S,X);if(e)I=await e(S,X);let pe=await(m.fetch??globalThis.fetch)(I);if(!pe.ok)throw Error(`SSE failed: ${pe.status} ${pe.statusText}`);if(!pe.body)throw Error("No body in SSE response");let K=pe.body.pipeThrough(new TextDecoderStream).getReader(),ee="",Q=()=>{try{K.cancel()}catch{}};x.addEventListener("abort",Q);try{while(!0){let{done:te,value:re}=await K.read();if(te)break;ee+=re,ee=ee.replace(/\r\n?/g,`
36
36
  `);let ae=ee.split(`
37
37
 
38
38
  `);ee=ae.pop()??"";for(let se of ae){let le=se.split(`
@@ -268,5 +268,5 @@ ${s}${i}ERRORS${o}`);for(let[,m]of l)for(let g of m)S.push(` ${Vh(g.message)}${
268
268
  `)};var oq=(e)=>Uk(e),iq=(e,t,r)=>{switch(t){case"bash":return WK(e,r);case"zsh":return nq(e,r);case"fish":return jK(e,r);case"powershell":return JK(e,r)}};var C=(e)=>Wh(fo,e),ht=(e)=>_K(fo,e),Le=(e)=>Sk(fo,e);var Kk=(e,t)=>Gh(fo,e,t),ke=(e,t)=>zh(fo,e,t);var qk=q(2,(e,t)=>UK(e,t)),Oe=q(2,(e,t)=>bk(e,t));var $k=q(2,(e,t)=>vk(e,t));var E=(e)=>up(e),tt=Ek;var Ir=q(2,(e,t)=>Ak(e,t)),f9=q(2,(e,t)=>kk(e,t));var fe=q(2,(e,t)=>Qh(e,t));var Wk=(e)=>{let t=new Set,r=[];for(let n of e){if(t.has(n))continue;t.add(n),r.push(n)}return r},aq=(e,t)=>{let r=[e],n=e;for(let o=1;o<t.length;o++){let i=t[o],s=void 0;for(let c of n.subcommands)if(s=c.commands.find((l)=>l.name===i),s)break;if(!s)break;r.push(s),n=s}return r},Gk=(e,t,r)=>{let o=aq(e,t).flatMap((i)=>Dt(i).globalFlags);return Wk([...r,...o])},m9=(e)=>{let t=[],r=(n)=>{let o=Dt(n);for(let i of o.globalFlags)t.push(i);for(let i of n.subcommands)for(let s of i.commands)r(s)};return r(e),Wk(t)},h9=(e,t)=>{if(e.length<=1)return[];let r=new Set(t.map((o)=>o.name)),n=[];for(let o of e.slice(0,-1)){let i=Dt(o);for(let s of i.contextConfig.flags){let c=Kt(s),l=No(s);for(let S of c){if(r.has(S.name))continue;if(S.hidden)continue;r.add(S.name),n.push(Zh(S,l))}}}return n},cq=(e,t)=>Wk([...t,...m9(e)]),ty=(e,t,r)=>kr(function*(){let n=aq(e,t),o=n.length>0?n[n.length-1]:e,i=Dt(o).buildHelpDoc(t),s=h9(n,i.flags),c=Gk(e,t,r),l=[];for(let m of c){let g=Kt(m.flag),w=No(m.flag);for(let k of g){if(k.hidden)continue;l.push({...Zh(k,w),required:!1})}}let S=1;for(let m=n.length-1;m>0;m--)if(Dt(n[m]).globalFlags.length>0){S=m+1;break}return{...i,inheritedFlags:s,globalFlags:l,globalFlagsScope:t.slice(0,S),commandPath:t}});var ry=(e)=>({_tag:"Action",flag:e.flag,run:e.run}),g9=(e)=>(t)=>{pq+=1;let r=Ht(`effect/cli/GlobalFlag/${e}/${pq}`);return Object.assign(r,{_tag:"Setting",id:e,flag:t.flag})},pq=0,x9=ry({flag:ht("help").pipe(qk("h"),Oe("Show help information"),tt(!1)),run:Ie(function*(e,{builtIns:t,command:r,commandPath:n}){let o=yield*fp,i=yield*ty(r,n,t);yield*o.present({_tag:"Help",reason:"Requested",commandPath:n,helpDoc:i})})}),S9=ry({flag:ht("version").pipe(qk("v"),Oe("Show version information"),tt(!1)),run:Ie(function*(e,{command:t,version:r}){yield*(yield*fp).present({_tag:"Version",name:t.name,version:r})})}),zk=ry({flag:ht("wizard").pipe(Oe("Start wizard mode for a command"),tt(!1)),run:()=>Je}),b9=ry({flag:Kk("completions",[["bash","bash"],["zsh","zsh"],["fish","fish"],["powershell","powershell"],["sh","bash"],["pwsh","powershell"]]).pipe(E,$k("<bash|zsh|fish|powershell|sh|pwsh>"),Oe("Print shell completion script")),run:Ie(function*(e,{command:t}){if(ir(e))return;let r=oq(t);yield*gr(iq(t.name,e.value,r))})}),mp=g9("log-level")({flag:Kk("log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(E,Oe("Sets the minimum log level"),$k("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),dq=[x9,S9,zk,b9,mp];class ny extends Vt("effect/cli/CliConfig",{defaultValue:()=>I9}){}var I9={builtIns:dq};var lq=Ix((e)=>z(nc(e,Ok)??Yh({colors:dn(e,qh).canColor})));function mq(e){let t=e.indexOf("--");if(t===-1)return{tokens:fq(e),trailingOperands:[]};return{tokens:fq(e.slice(0,t)),trailingOperands:e.slice(t+1)}}var hq=(e)=>{if(e._tag==="Value")return e.value;if(e._tag==="LongOption")return e.raw;let t=yq.test(e.raw)?`--${e.flag}`:e.raw;return e.value===void 0?t:`${t}=${e.value}`},yq=/^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,fq=(e)=>{let t=[];for(let r of e)if(!r.startsWith("-")||yq.test(r))t.push({_tag:"Value",value:r});else if(r.startsWith("--")){let n=r.indexOf("=");if(n!==-1){let o=r.slice(2,n);if(o==="")t.push({_tag:"Value",value:r});else{let i=r.slice(n+1);t.push({_tag:"LongOption",name:o,raw:r,value:i})}}else t.push({_tag:"LongOption",name:r.slice(2),raw:r})}else if(r.length>1){let n=r.slice(1),o=n.indexOf("=");if(o!==-1){let i=Array.from(n.slice(0,o)),s=i.pop()??"";for(let c of i)t.push({_tag:"ShortOption",flag:c,raw:`-${c}`});t.push({_tag:"ShortOption",flag:s,raw:`-${s}`,value:n.slice(o+1)})}else for(let i of n)t.push({_tag:"ShortOption",flag:i,raw:`-${i}`})}else t.push({_tag:"Value",value:r});return t};var E9=(e,t)=>{let r=e.length,n=t.length,o=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let i=0;i<=r;i++)o[i][0]=i;for(let i=0;i<=n;i++)o[0][i]=i;for(let i=1;i<=r;i++)for(let s=1;s<=n;s++){let c=e[i-1]===t[s-1]?0:1;o[i][s]=Math.min(o[i-1][s]+1,o[i][s-1]+1,o[i-1][s-1]+c)}return o[r][n]},Qk=(e,t)=>{let r=t.map((o)=>[E9(e,o),o]).filter(([o])=>o<=2).sort(([o],[i])=>o-i);if(r.length===0)return[];let n=r[0][0];return r.filter(([o])=>o===n).map(([,o])=>o)};var Vk=(e)=>$r(e.subcommand,{onNone:()=>[],onSome:(t)=>[t.name,...Vk(t.parsedInput)]}),Jk=(e,t,r=[])=>kr(function*(){let{tokens:n,trailingOperands:o}=e,i=[...r,t.name],s=Tq(n,Cq(t,i));if(s._tag==="Leaf")return{flags:s.flags,arguments:[...s.arguments,...o],subcommand:ge(),...s.errors.length>0&&{errors:s.errors}};let c={tokens:s.childTokens,trailingOperands:o},l=yield*Jk(c,s.sub,i),S=[...s.errors,...l.errors??[]];return{flags:s.flags,arguments:[],subcommand:Ue({name:s.sub.name,parsedInput:l}),...S.length>0&&{errors:S}}}),Yk=(e,t)=>{let r=Tq(e,Cq(t,[]));return r._tag==="Leaf"?e:Yk(r.childTokens,r.sub)},oy=(e)=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},Sq=(e)=>!ek(e.primitiveType)||e.negation===!1?void 0:e.negation??`no-${e.name}`,yp=(e)=>{let t=new Map,r=new Map;for(let n of e){if(t.has(n.name))throw Error(`Duplicate flag name "${n.name}" in command definition`);t.set(n.name,n);for(let i of n.aliases){if(t.has(i))throw Error(`Duplicate flag/alias "${i}" in command definition (conflicts with "${t.get(i).name}")`);t.set(i,n)}let o=Sq(n);if(o!==void 0){if(r.has(o))throw Error(`Duplicate negation "${o}" in command definition (conflicts with "${r.get(o).name}")`);r.set(o,n)}}return{params:e,index:t,negations:r}},bq=(e)=>{let t=new Map,r=(n,o)=>{let i=t.get(n);if(i&&i!==o)throw Error(`Duplicate subcommand name/alias "${n}" in command definition (conflicts with "${i.name}")`);t.set(n,o)};for(let n of e)for(let o of n.commands)if(r(o.name,o),o.alias&&o.alias!==o.name)r(o.alias,o);return t},Zk=(e)=>Object.fromEntries(e.map((t)=>[t.name,[]])),k9=(e)=>{let t=Zk(e);return{add:(r,n)=>{if(n!==void 0)t[r].push(n)},merge:(r)=>{for(let n in r){let o=r[n];if(o?.length)for(let i=0;i<o.length;i++)t[n].push(o[i])}},snapshot:()=>t}},iy=(e)=>e._tag==="LongOption"||e._tag==="ShortOption",Iq=(e)=>e._tag==="LongOption"?e.name:e.flag,hp=(e,t)=>{let r=Iq(e),n=t.index.get(r);if(n&&n.name===r)return{param:n,negated:!1};let o=e._tag==="LongOption"?t.negations.get(e.name):void 0;if(o)return{param:o,negated:!0};if(n)return{param:n,negated:!1};return},gq=(e,t,r)=>new En({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),A9=(e)=>{let t=bi(e.primitiveType);return new En({option:e.name,value:"",expected:t===void 0?e.typeName??Bu(e.primitiveType):t.join(" | "),kind:"flag"})},xq=(e)=>e?._tag==="Value"&&(FB(e.value)||NB(e.value))?e.value:void 0,wq=(e,t,r,n=!1)=>{let o=Yu(e,t,r,n);switch(o._tag){case"Value":return{_tag:"Value",value:o.value};case"Error":return{_tag:"Error",error:o.error}}},Yu=(e,t,r,n=!1)=>{if(n){if(t.value!==void 0)return{_tag:"Error",error:gq(t,r,t.value),tokens:[]};let i=r.optionalValue===void 0?xq(e.peek()):void 0;if(i!==void 0){let s=e.take();return{_tag:"Error",error:gq(t,r,i),tokens:s===void 0?[]:[s]}}return{_tag:"Value",value:"false",tokens:[]}}if(t.value!==void 0)return{_tag:"Value",value:t.value,tokens:[]};if(r.optionalValue!==void 0)return{_tag:"Value",value:r.optionalValue,tokens:[]};if(ek(r.primitiveType)){let i=xq(e.peek()),s=i!==void 0?e.take():void 0;return{_tag:"Value",value:i??"true",tokens:s===void 0?[]:[s]}}let o=e.peek();if(o?._tag==="Value"){let i=e.take();return{_tag:"Value",value:o.value,tokens:i===void 0?[]:[i]}}return{_tag:"Error",error:A9(r),tokens:[]}},v9=(e,t)=>{let r=Zk(t.params),n=[],o=[],i=oy(e);for(let s=i.take();s;s=i.take()){if(!iy(s)){n.push(s);continue}let c=hp(s,t);if(!c){n.push(s);continue}let l=wq(i,s,c.param,c.negated);if(l._tag==="Error"){o.push(l.error);continue}if(l.value!==void 0)r[c.param.name].push(l.value)}return{flagMap:r,remainder:n,errors:o}},Eq=(e)=>Dt(e).config.flags.flatMap(Kt).filter(zu),kq=(e)=>Dt(e).contextConfig.flags.flatMap(Kt).filter(zu),Aq=(e,t)=>{for(let r of t){let n=hp(e,r);if(n!==void 0)return n}return},Hk=(e,t,r,n)=>{e.push(r);let o=Yu(t,r,n.param,n.negated);e.push(...o.tokens)},C9=(e,t,r,n,o)=>{let i=oy(t);Yu(i,e,r.param,r.negated);for(let s=i.take();s;s=i.take()){if(iy(s)){let c=Aq(s,o);if(c!==void 0)Yu(i,s,c.param,c.negated);continue}if(s._tag==="Value")return n.has(s.value)}return!1},vq=(e,t,r)=>{let n=Zk(r.params),o=[],i=(s,c,l)=>{let S=yp(Eq(c)),m=yp(kq(c)),g=bq(c.subcommands),w=oy(s),k=[],A=!0;for(let y=w.take();y;y=w.take()){if(iy(y)){let h=Aq(y,l);if(h!==void 0){Hk(k,w,y,h);continue}let x=hp(y,m);if(x!==void 0){Hk(k,w,y,x);continue}let G=hp(y,S),X=hp(y,r);if(G!==void 0){if(X===void 0||!A||!C9(y,w.rest(),G,g,[S,m,r])){Hk(k,w,y,G);continue}}if(X!==void 0){let I=Yu(w,y,X.param,X.negated);if(I._tag==="Error"){o.push(I.error);continue}if(I.value!==void 0)n[X.param.name].push(I.value);continue}k.push(y);continue}if(y._tag==="Value"&&A){let h=g.get(y.value);if(h!==void 0)return k.push(y),k.push(...i(w.rest(),h,[...l,m])),k;A=!1}k.push(y)}return k};return{flagMap:n,remainder:i(e,t,[]),errors:o}},T9=(e,t,r)=>{let n=e._tag==="LongOption"?`--${e.name}`:`-${e.flag}`,o=[];for(let s of t){if(s.hidden)continue;o.push(s.name);let c=Sq(s);if(c!==void 0)o.push(c);for(let l of s.aliases)o.push(l)}let i=Qk(Iq(e),o).map((s)=>s.length===1?`-${s}`:`--${s}`);return new va({option:n,suggestions:i,command:r})},O9=(e)=>({flags:k9(e.params),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}}),P9=(e)=>({_tag:"Leaf",flags:e.flags.snapshot(),arguments:e.arguments,errors:e.errors}),R9=(e,t,r,n)=>{let{command:o,commandPath:i,inheritedFlagRegistry:s,localFlagNames:c}=r,l=bq(o.subcommands),S=l.get(e);if(S){let g=[...i,S.name],w=n.flags.snapshot();for(let A of c){let y=w[A];if(y!==void 0&&y.length>0)n.errors.push(new va({option:`--${A}`,suggestions:[],command:g}))}let k=v9(t.rest(),s);return n.flags.merge(k.flagMap),n.errors.push(...k.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:n.flags.snapshot(),sub:S,childTokens:k.remainder,errors:n.errors}}}if(!(Dt(o).config.arguments.length>0)&&l.size>0){let g=[];for(let[k,A]of l)if(!A.unlisted)g.push(k);let w=Qk(e,g);n.errors.push(new Lh({subcommand:e,parent:i,suggestions:w}))}return{_tag:"Argument"}},_9=(e,t,r,n)=>{let{commandPath:o,flagRegistry:i}=r,s=hp(e,i);if(!s){n.errors.push(T9(e,i.params,o));return}let c=wq(t,e,s.param,s.negated);if(c._tag==="Error"){n.errors.push(c.error);return}n.flags.add(s.param.name,c.value)},U9=(e,t,r,n)=>{if(n.mode._tag==="AwaitingFirstValue"){let o=R9(e,t,r,n);if(o._tag==="Subcommand")return o.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e);return},Cq=(e,t)=>{let r=Eq(e),n=kq(e),o=new Set(n.map((i)=>i.name));return{command:e,commandPath:t,flagRegistry:yp(r),inheritedFlagRegistry:yp(n),localFlagNames:r.filter((i)=>!o.has(i.name)).map((i)=>i.name)}},Tq=(e,t)=>{let r=oy(e),n=O9(t.flagRegistry);for(let o=r.take();o;o=r.take()){if(iy(o)){_9(o,r,t,n);continue}if(o._tag==="Value"){let i=U9(o.value,r,t,n);if(i)return i}}return P9(n)};var Rq=Ie(function*(e,t){let r=t?.commandPath??[e.name],n=L9(e,r),o=(t?.prefix??r).map((s)=>$n(s)),{colors:i}=yield*$u;return yield*sy(o,i),yield*_q(n,o,n===e?"ROOT":n.name,i),{args:o.map((s)=>s.value),displayArgs:o.map((s)=>s.displayValue)}}),L9=(e,t)=>{let r=e;for(let n of t.slice(1)){let o=r.subcommands.flatMap((i)=>i.commands).find((i)=>i.name===n||i.alias===n);if(o===void 0)break;r=o}return r},_q=Ie(function*(e,t,r,n){let o=Dt(e),i=e.subcommands.flatMap((l)=>l.commands.filter((S)=>!S.unlisted)),s=i.length===0?o.config:o.contextConfig;if(s.flags.length>0){yield*gr(Pq(r,"FLAGS",n));for(let l of s.flags)t.push(...yield*Oq(l));if(s.arguments.length>0||i.length>0)yield*sy(t,n)}if(s.arguments.length>0){if(yield*gr(Pq(r,"ARGUMENTS",n)),i.length===0)t.push($n("--"));for(let l of s.arguments)t.push(...yield*Oq(l));if(i.length>0)yield*sy(t,n)}if(i.length===0)return;let c=yield*an(pk({message:"Command",choices:i.map((l)=>({title:l.name,value:l,...l.shortDescription!==void 0?{description:l.shortDescription}:l.description!==void 0?{description:l.description}:{}}))}));if(yield*gr(),t.push($n(c.name)),M9(c))yield*sy(t,n);yield*_q(c,t,c.name,n)}),M9=(e)=>e.subcommands.some((r)=>r.commands.some((n)=>!n.unlisted))||Dt(e).config.orderedParams.length>0,Oq=Ie(function*(e){let t=Hh(e),r=No(e);if(r.isOptional){if(!(yield*an(ak({message:`Set ${Xk(t)}?`,initial:!1}))))return yield*gr(),[]}let n=!r.isVariadic?1:yield*an(ck({message:`${Xk(t)} count`,default:fr(r.variadicMin,()=>0),min:fr(r.variadicMin,()=>0),...O(r.variadicMax)?{max:r.variadicMax.value}:{}})),o=[];for(let s=0;s<n;s++)o.push(yield*F9(t));let i=t.kind===fo?{flags:{[t.name]:o.map((s)=>s.value)},arguments:[]}:{flags:{},arguments:o.map((s)=>s.value)};if(yield*e.parse(i),yield*gr(),t.kind===lp)return o;return o.flatMap((s)=>t.optionalValue!==void 0||s.value.startsWith("-")&&s.value.length>1?[$n(`--${t.name}=${s.value}`,`--${t.name}=${s.displayValue}`)]:[$n(`--${t.name}`),s])}),F9=(e)=>{let t=B9(e);switch(e.primitiveType._tag){case"Boolean":return De(an(ak({message:t,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),(r)=>$n(String(r)));case"Choice":{let r=bi(e.primitiveType)??[];return De(an(pk({message:t,choices:r.map((n)=>({title:n,value:n}))})),$n)}case"Date":return De(an(iK({message:t})),(r)=>$n(r.toISOString()));case"Finite":return De(an(sK({message:t})),(r)=>$n(String(r)));case"Int":return De(an(ck({message:t})),(r)=>$n(String(r)));case"Redacted":return De(an(aK({message:t})),(r)=>$n(Kc(r),"<redacted>"));default:return De(an(cK({message:t})),$n)}},$n=(e,t=e)=>({value:e,displayValue:t}),N9=(e)=>e.kind===fo?`--${e.name}`:e.name,B9=(e)=>Xk(e),Xk=(e)=>{let t=f(e.description)?.trim(),r=e.kind===fo&&t!==void 0&&t.length<=32?t:K9(e.name);return e.kind===fo?`${r} (${N9(e)})`:r},K9=(e)=>{let t=e.split(/[-_]+/).filter((r)=>r.length>0);if(t.length===0)return e;return[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},sy=(e,t)=>gr(Mq("Current command",e.map((r)=>r.displayValue),t,HB)),Pq=(e,t,r)=>`${wt(r,e.toUpperCase(),Ii,pp)} ${wt(r,"\xB7",qu)} ${wt(r,t,Ii,Oa)}`,Uq=(e,t,r,n)=>[`${wt(n,e,Ii,pp)} ${wt(n,`v${t}`,Oa)} ${wt(n,"\xB7 Command wizard",Ii,Oa)}`,...r===void 0||r.length===0?[]:[r],wt(n,"Build a command interactively. Press Ctrl+C to cancel.",qu),""].join(`
269
269
  `),Dq=(e,t)=>Mq("Command ready",e,t,pp,Bh),Lq=(e)=>`
270
270
  ${wt(e,"Wizard cancelled.",Nh)}`,Mq=(e,t,r,n,o=Oa)=>{let i=q9(t);return[wt(r,e,Ii,o),...i.map((s)=>wt(r,s,n)),""].join(`
271
- `)},q9=(e)=>{let o=e.map($9),i=[],s=" $ ";for(let c of o){let l=s===" $ "||s===" "?"":" ";if(s.length+l.length+c.length>88&&s!==" $ ")i.push(`${s} \\`),s=` ${c}`;else s+=`${l}${c}`}if(s!==" $ ")i.push(s);return i},$9=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var G9=(e)=>He(e,Qu),T=(e,t,r)=>{let n=Pk(t??{});return Hu({name:e,config:n,...Jt(r)?{handle:r}:{}})};var z9=(e)=>{let t=[],r=new Map,n=(s,c)=>{t.push(c);let l=r.get(s);if(l)l.push(c);else r.set(s,[c])};for(let s of e){if(G9(s)){n(void 0,s);continue}for(let c of s.commands)n(s.group,c)}let o=[],i=r.get(void 0);if(i&&i.length>0)o.push({group:void 0,commands:i});for(let[s,c]of r){if(s===void 0)continue;o.push({group:s,commands:c})}return{flat:t,groups:o}},Ze=q(2,(e,t)=>{let r=z9(t);BK(e,r.flat);let n=Dt(e),o=new Map(r.flat.map((l)=>[l.name,Dt(l)])),i=Symbol("effect/cli/SubcommandState"),s=Ie(function*(l){if(ir(l.subcommand))return yield*n.parse(l);let S=o.get(l.subcommand.value.name);if(!S)return yield*n.parse(l);let m=yield*n.parseContext(l),g=yield*S.parse(l.subcommand.value.parsedInput);return{...m,[i]:{name:S.name,result:g}}}),c=Ie(function*(l,S){let g=l[i];if(g){let w=o.get(g.name);if(!w)return yield*new Si({commandPath:S,errors:[]});return yield*w.handle(g.result,[...S,w.name]).pipe(Vi(n.service,l))}return yield*n.handle(l,S)});return Hu({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,resolveExamples:n.resolveExamples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:c})});var P=q(2,(e,t)=>Hu({...Dt(e),description:t}));var F=q(3,(e,t,r)=>{let n=Dt(e);return Hu({...n,annotations:wo(n.annotations,t,r)})});var j9=(e,t,r,n)=>{let o=new Set(t),i=[],s=new Set;for(let c of e){if(o.has(c))continue;let l=Kt(c.flag);for(let S of l){let m=r[S.name];if(!m||m.length===0)continue;let g=`--${S.name}`;if(s.has(g))continue;s.add(g),i.push(new va({option:g,suggestions:[],command:n}))}}return i},Q9=(e,t,r)=>kr(function*(){let{builtIns:n}=yield*ny,o=yield*fp,{commandPath:i,errors:s}=t,c=yield*ty(e,i,n);yield*o.present(r&&s.length>0?{_tag:"InvalidInvocation",commandPath:i,helpDoc:c,errors:s}:{_tag:"Help",reason:"Implicit",commandPath:i,helpDoc:c})}),H9=(e,t)=>kr(function*(){let r=yield*lq,n=e instanceof Nu?e:new Nu({cause:e,userMessage:t});yield*qm(r.formatError(n)),Object.assign(e,{[uu]:!1})});var Fq=(e,t)=>{let r=Dt(e);return Ie(function*(n){let{builtIns:o}=yield*ny,{tokens:i,trailingOperands:s}=mq(n),c=cq(e,o),l=c.flatMap((Q)=>Kt(Q.flag)),S=yp(l.filter(zu)),{flagMap:m,remainder:g,errors:w}=vq(i,e,S),k={flags:m,arguments:[]},A=yield*Jk({tokens:g,trailingOperands:s},e),y=[e.name,...Vk(A)],h=(Q)=>Q._tag==="ShowHelp"?Q:new Si({commandPath:y,errors:[Q]}),x=Rr(h),G={builtIns:o,command:e,commandPath:y,version:t.version},X=Gk(e,y,o),I=j9(c,X,m,y);if(I.length>0||w.length>0){let Q=A.errors??[];return yield*new Si({commandPath:y,errors:[...w,...I,...Q]})}for(let Q of X){if(Q._tag!=="Action")continue;if(!Kt(Q.flag).some((se)=>{let le=m[se.name];return le!==void 0&&le.length>0}))continue;let[,ae]=yield*Q.flag.parse(k).pipe(x);if(Q===zk){let{colors:se}=yield*$u;return yield*kr(function*(){yield*gr(Uq(e.name,t.version,e.description,se));let le=new Set(Yk(g,e)),Se=[e.name,...i.filter(($e)=>!le.has($e)&&!($e._tag==="LongOption"&&$e.name==="wizard")).map(hq)],ve=yield*Rq(e,{commandPath:y,prefix:Se});if(yield*gr(Dq(ve.displayArgs,se)),yield*an(pK({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*gr(),yield*Fq(e,{...t,renderErrors:!1})(ve.args.slice(1))}).pipe(yd("QuitError",()=>gr(Lq(se))))}yield*Q.run(ae,G);return}if(A.errors&&A.errors.length>0)return yield*new Si({commandPath:y,errors:A.errors});let me=yield*r.parse(A).pipe(Rr((Q)=>XE(Q)?h(Q):Q)),pe=r.handle(me,[e.name]),K=X.includes(mp)?(yield*mp.flag.parse(k).pipe(x))[1]:ge();pe=Vi(pe,mp,K);for(let Q of X){if(Q._tag!=="Setting"||Q===mp)continue;let[,te]=yield*Q.flag.parse(k).pipe(x);pe=Vi(pe,Q,te)}let ee=$r(K,{onNone:()=>un(),onSome:(Q)=>Bs(nO,Q)});yield*Hi(pe,ee)},Cf((n)=>XE(n)&&n._tag==="ShowHelp"?Zt(n):Nt(n),(n)=>Zn(Q9(e,n,t.renderErrors!==!1),he(n))),Cf((n)=>{if(t.renderErrors===!1||!Pp(n))return Nt(n);let o=LB(n);return o===void 0?Nt(n):Zt({error:n,userMessage:o})},({error:n,userMessage:o})=>Zn(H9(n,o),he(n))),Cf((n)=>wU(n)?Zt(n):Nt(n),(n)=>Sd))};var Zu={name:"@pubnio/cli",version:"0.2.7",type:"module",description:"PubNio command-line interface.",homepage:"https://pubnio.com/docs/cli/",keywords:["pubnio","cli","social","publishing","api","agents","mcp"],publishConfig:{access:"public"},bin:{pnio:"./dist/index.js"},files:["dist","README.md"],engines:{bun:">=1.4.0"},scripts:{build:"bun build --target=bun --minify --outfile dist/index.js ./src/index.ts && bun run copy:skill","copy:skill":"mkdir -p dist/skills/pnio && cp ../docs/skills/pnio/SKILL.md dist/skills/pnio/SKILL.md",pack:"bun script/pack.ts",compile:"bun build --compile --minify --compile-exec-argv=--use-system-ca --outfile dist/pnio ./src/index.ts","compile:all":"bun run compile:darwin-arm64 && bun run compile:darwin-x64 && bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64","compile:darwin-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-arm64 --outfile dist/pnio-darwin-arm64 ./src/index.ts","compile:darwin-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-x64 --outfile dist/pnio-darwin-x64 ./src/index.ts","compile:linux-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-x64 --outfile dist/pnio-linux-x64 ./src/index.ts","compile:linux-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-arm64 --outfile dist/pnio-linux-arm64 ./src/index.ts","compile:windows-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-windows-x64 --outfile dist/pnio-windows-x64.exe ./src/index.ts",prepack:"bun run build"},dependencies:{"@effect/platform-bun":"4.1.7","@pubnio/protocol":"workspace:*","@pubnio/sdk":"workspace:*",effect:"4.1.7",jose:"6.2.19","proper-lockfile":"4.1.2"},devDependencies:{"@types/proper-lockfile":"4.1.4"}};function Nq(e){let t,r=Aa({...e,onRuntime:(n)=>{t=n}});if(!t)throw Error("PubNio client runtime was not captured.");return{client:r,runtime:t}}class _ extends Ht()("@pubnio/cli/CliOperations"){}function Bq(e={}){let t=process.env,r=e.json===!0||t.PUBNIO_NON_INTERACTIVE==="1"||t.CI==="1"||t.CI==="true"||Boolean(t.OPENCODE_AGENT)||Boolean(t.CLAUDECODE)||!process.stdout.isTTY;return{interactive:!r,browser:!r}}var N=C("workspace").pipe(fe(de),E,Oe("Workspace ID. Defaults to PUBNIO_WORKSPACE_ID or your only workspace.")),Kq=ne("id").pipe(ie(de)),Ebe=C("name").pipe(fe(FU.fields.name)),kbe=C("default-timezone").pipe(E,Oe("Default IANA time zone for new queues, e.g. America/New_York.")),Xu=ht("browser").pipe(tt(Bq().browser),Oe("Open the browser automatically. Defaults to on only for an interactive terminal; pass --browser or --no-browser to override.")),eA=C("account").pipe(fe(J),E,Oe("Publishing account ID.")),qq=C("account").pipe(fe(J),Ir(0),Oe("Publish to this exact publishing account ID, or save it as a draft target. Repeat for several accounts.")),$q=C("account").pipe(fe(bu.fields.accountId),E,Oe("Publish to this existing post target account.")),ot=C("idempotency-key").pipe(fe(Vr),E,Oe("Reuse a key to replay this request safely. Generated when omitted.")),xs={cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)};class Fe extends Error{}function Et(e){return(e==="-"?Bun.stdin:Bun.file(e)).json().catch(()=>{throw new Fe("Could not read JSON input.")})}function R(e){return zs({try:e,catch:(t)=>t}).pipe(ji((t)=>Be(()=>console.log(JSON.stringify(t,null,2)))))}function ay(e){let t=process.platform==="darwin"?"open":process.platform==="linux"?"xdg-open":void 0;if(!t||!Bun.which(t))return;Bun.spawn([t,e],{stdin:"ignore",stdout:"ignore",stderr:"ignore"}).unref()}var Wq=p({clientId:a});var Gq="/api/auth/cli";var zq=new TextDecoder,jq=new TextDecoder("utf-8",{fatal:!0});function Qq(e,t=!1){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e,{alphabet:t?"base64url":"base64"});if(t){if(e.includes("+")||e.includes("/"))throw TypeError("Invalid base64url");e=e.replace(/-/g,"+").replace(/_/g,"/")}let r=atob(e),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n}class Hq extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class Ei extends Hq{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}var J9="The input to be decoded is not correctly encoded.";function Vq(e){try{return Qq(typeof e=="string"?e:zq.decode(e),!0)}catch(t){throw TypeError(J9,{cause:t})}}function Jq(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function tA(e){if(typeof e!="string")throw new Ei("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new Ei("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new Ei("Invalid JWT");if(!t)throw new Ei("JWTs must contain a payload");let n;try{n=Vq(t)}catch(i){throw new Ei("Failed to base64url decode the payload",{cause:i})}let o;try{o=JSON.parse(jq.decode(n))}catch(i){throw new Ei("Failed to parse the decoded payload as JSON",{cause:i})}if(!Jq(o))throw new Ei("Invalid JWT Claims Set");return o}var v$=H1(E$(),1);import{mkdir as L5,rename as k$,rm as Ba,writeFile as A$}from"fs/promises";import{homedir as M5}from"os";import{join as xA}from"path";var F5="https://api.workos.com/user_management",N5=(e)=>{let t=xA(process.env.XDG_CONFIG_HOME||xA(M5(),".config"),"pubnio"),r=new Bun.CryptoHasher("sha256").update(e).digest("hex");return{dir:t,file:xA(t,`${r}.json`)}},SA=p({access_token:a,refresh_token:a}),B5=p({clientId:a,...SA.fields,workspaceId:u(de)}),C$=p({device_code:a,user_code:a,verification_uri:a,verification_uri_complete:a,expires_in:yr.check(Do(0)),interval:yr.check(Do(0))});class by extends Error{code;status;constructor(e,t){super(`WorkOS request failed (HTTP ${t}).`);this.code=e;this.status=t}}var K5="Sign in with `pnio auth login`.";async function bA(e,t,r,n){let o=await e(`${F5}/${t}`,{method:"POST",body:new URLSearchParams(r),redirect:"error",signal:AbortSignal.timeout(1e4)}),i=await o.json().catch(()=>null);if(o.ok)return io(n)(i);let s=i&&typeof i==="object"&&"error"in i&&typeof i.error==="string"?i.error:"unknown";throw new by(s,o.status)}var q5=p({clientId:a,device:C$,expiresAt:yr}),T$=(e)=>`${e}.device.json`;async function $5(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await A$(r,JSON.stringify(t),{mode:384,flag:"wx"}),await k$(r,e)}finally{await Ba(r,{force:!0})}}async function W5(e,t=fetch){let r=await bA(t,"authorize/device",{client_id:e},C$),n=new URL(r.verification_uri),o=new URL(r.verification_uri_complete);if(n.protocol!=="https:"||o.origin!==n.origin)throw Error("WorkOS returned an invalid sign-in URL.");return{device:r,url:n.href,completeUrl:o.href}}async function O$(e){let t=await kA(e,"GET"),{clientId:r}=await io(Wq)(await t.json()),{device:n,url:o,completeUrl:i}=await W5(r),s=Date.now()+n.expires_in*1000;return await il(e,async(c)=>{await $5(T$(c),{clientId:r,device:n,expiresAt:s})}),{url:o,completeUrl:i,userCode:n.user_code,expiresAt:new Date(s).toISOString()}}async function G5(e,t,r,n=fetch){let o=Math.min(Date.now()+t.expires_in*1000,Date.now()+r),i=t.interval*1000;while(Date.now()+i<o){await Bun.sleep(i);try{let s=await bA(n,"authenticate",{client_id:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t.device_code},SA);return{clientId:e,...s}}catch(s){if(s instanceof by){if(s.code==="authorization_pending")continue;if(s.code==="slow_down"||s.status===429||s.status>=500){i+=5000;continue}if(s.code==="expired_token")break;if(s.code==="access_denied")throw Error("Sign-in was declined.",{cause:s})}if(s instanceof Error&&s.name==="TimeoutError"){i*=2;continue}throw s}}throw Error("Sign-in is still pending. Run `pnio auth complete` to keep waiting, or `pnio auth login` to start over.")}async function IA(e,{timeoutMs:t=600000}={}){return il(e,async(r)=>{let n=T$(r),o=await z5(n);if(!o)throw Error("No sign-in is pending. Run `pnio auth login`.");if(o.expiresAt<=Date.now())throw await Ba(n,{force:!0}),Error("Sign-in expired. Run `pnio auth login` again.");let i=await G5(o.clientId,o.device,Math.min(t,o.expiresAt-Date.now())).catch(async(s)=>{throw await Ba(n,{force:!0}),s});return await kA(e,"POST",i.access_token),await EA(r,i),await Ba(n,{force:!0}),i.access_token})}async function z5(e){let t=Bun.file(e);if(!await t.exists())return;return io(q5)(await t.json())}async function wA(e){let t=Bun.file(e);if(!await t.exists())return;return io(B5)(await t.json())}async function EA(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await A$(r,JSON.stringify(t),{mode:384,flag:"wx"}),await k$(r,e)}finally{await Ba(r,{force:!0})}}async function il(e,t){let{dir:r,file:n}=N5(e);await L5(r,{recursive:!0,mode:448});let o=await v$.default.lock(n,{realpath:!1,retries:{retries:20,minTimeout:100,maxTimeout:1000}});try{return await t(n)}finally{await o()}}async function kA(e,t,r){let n=await fetch(`${e}${Gq}`,{method:t,headers:r?{Authorization:`Bearer ${r}`}:{},redirect:"error",signal:AbortSignal.timeout(15000)});if(!n.ok)throw Error(`PubNio sign-in request failed (HTTP ${n.status}).`);return n}async function P$(e,t){let{exp:r}=tA(t.access_token);if(r&&r*1000>Date.now()+30000)return t.access_token;try{let n=await bA(fetch,"authenticate",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:t.refresh_token},SA);return await EA(e,{...t,...n}),n.access_token}catch(n){if(!(n instanceof by&&n.code==="invalid_grant"))throw n;await Ba(e,{force:!0});return}}async function R$(e){return il(e,async(t)=>{let r=await wA(t),n=r&&await P$(t,r);if(!n||!r)throw Error(K5);return{token:n,workspaceId:r.workspaceId}})}async function _$(e,t,r){await il(e,async(n)=>{let o=await wA(n);if(o?.access_token!==t)throw Error("The CLI session changed. Run the workspace command again.");await EA(n,{...o,workspaceId:r})})}async function U$(e){return il(e,async(t)=>{let r=await wA(t),n=r&&await P$(t,r);if(n)await kA(e,"DELETE",n);await Ba(t,{force:!0})})}function Ai(){let e=URL.parse(process.env.PUBNIO_BASE_URL??"https://pubnio.com");if(!e||e.username||e.password||e.pathname!=="/"||e.search||e.hash||e.protocol!=="https:"&&!(e.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(e.hostname)))throw new Fe("PUBNIO_BASE_URL must be an HTTPS origin or a local HTTP origin.");return e.origin}async function D$(e,t){let r=t==="default"?process.env.PUBNIO_API_KEY:void 0;if(r!==void 0&&!_b.test(r))throw new Fe("PUBNIO_API_KEY is not a valid PubNio API key.");let n=r===void 0?await R$(e):void 0;return{apiKey:r,session:n}}async function ho(e=Ai(),t="default"){let{apiKey:r,session:n}=await D$(e,t),o=Aa({baseUrl:e,clientName:"cli",clientVersion:Zu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}});return{...o,selectedWorkspaceId:n?.workspaceId,useWorkspace:async(i)=>{let s=await o.workspaces.get(i);if(n)await _$(e,n.token,s.id);return s}}}async function V(e=Ai(),t="default"){let{apiKey:r,session:n}=await D$(e,t);return{...Nq({baseUrl:e,clientName:"cli",clientVersion:Zu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}}),selectedWorkspaceId:n?.workspaceId}}async function Z(e,t,r){let n=t??process.env.PUBNIO_WORKSPACE_ID??e.selectedWorkspaceId??r;if(n!==void 0){let i=ns(de)(n);if(i._tag==="None")throw new Fe("Expected a workspace UUID.");return i.value}let{workspaces:o}=await e.workspaces.list();if(o.length!==1)throw new Fe("Select a workspace with `pnio workspaces use <id>` or pass --workspace. Run `pnio workspaces list` to see your workspaces.");return o[0].id}async function Ke(e,{origin:t,auth:r}={}){let n=await ho(t,r);return n.workspace(await Z(n,e))}var L$=[T("list-accounts",{workspace:N,state:ke("state",["available","selected"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Jw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.state)?{state:f(e.state)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listAccounts"]),P("List available and selected ad accounts")),T("connect-account",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,Yw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.connectAccount"]),P("Start an ad account OAuth connection")),T("connect-api-key-account",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),provider:ke("provider",["openai_ads"]),apiKey:C("api-key"),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,Zw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,apiKey:e.apiKey,...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.connectApiKeyAccount"]),P("Connect an ad account with an API key")),T("disconnect-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,iE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.disconnectAccount"]),P("Stop syncing an ad account")),T("select-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,oE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.selectAccount"]),P("Select a discovered ad account")),T("list-campaigns",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:ke("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,sE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listCampaigns"]),P("List one account's campaigns newest first")),T("list-workspace-campaigns",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:ke("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,eE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listWorkspaceCampaigns"]),P("List campaigns across selected ad accounts")),T("get-tree",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,aE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.getTree"]),P("Read a campaign, ad group, ad, and creative tree")),T("list-ads",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,cE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listAds"]),P("List ads with a performance summary")),T("list-ad-groups",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,pE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listAdGroups"]),P("List ad groups with a performance summary")),T("get-ad",{workspace:N,adId:ne("ad-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,dE({client:t.runtime.client,path:{adId:e.adId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getAd"]),P("Read one ad with its creative and metrics")),T("list-creatives",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,uE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listCreatives"]),P("List ad creatives")),T("get-creative",{workspace:N,creativeId:ne("creative-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,fE({client:t.runtime.client,path:{creativeId:e.creativeId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getCreative"]),P("Read one ad creative")),T("list-insights",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:ke("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,hE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listInsights"]),P("Read one ad account's daily insights")),T("list-workspace-insights",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:ke("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,mE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listWorkspaceInsights"]),P("Read daily insights across selected ad accounts")),T("refresh-insights",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,yE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.refreshInsights"]),P("Queue an ad insight refresh")),T("activate-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),confirmation:ke("confirmation",["activate_spend"]),idempotencyKey:ot},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,EE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision,confirmation:e.confirmation},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.activateCampaign"]),P("Activate one paused boost campaign")),T("pause-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,kE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.pauseCampaign"]),P("Pause one campaign")),T("archive-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,AE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.archiveCampaign"]),P("Archive one campaign")),T("duplicate-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,vE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.duplicateCampaign"]),P("Duplicate a campaign tree as paused")),T("create-ad-group",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),name:C("name"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name}:await Et(r);return t.runtime.decode(H,PE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createAdGroup"]),P("Create a paused ad group under a campaign")),T("create-creative",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))),mediaId:C("media-id").pipe(fe(a.check(L()))),headline:C("headline").pipe(E),body:C("body").pipe(E),callToAction:C("call-to-action").pipe(E),destinationUrl:C("destination-url"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{actorAccountId:e.actorAccountId,mediaId:e.mediaId,...O(e.headline)?{headline:f(e.headline)}:{},...O(e.body)?{body:f(e.body)}:{},...O(e.callToAction)?{callToAction:f(e.callToAction)}:{},destinationUrl:e.destinationUrl}:await Et(r);return t.runtime.decode(H,lE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createCreative"]),P("Create a paused provider creative")),T("set-campaign-budget",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,CE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setCampaignBudget"]),P("Update a campaign budget")),T("set-ad-group-budget",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,TE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setAdGroupBudget"]),P("Update an ad group budget")),T("set-ad-group-status",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),status:ke("status",["active","paused","archived"]),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,OE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setAdGroupStatus"]),P("Pause, resume, or archive an ad group")),T("set-ad-status",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adId:ne("ad-id").pipe(ie(a.check(L()))),status:ke("status",["active","paused","archived"]),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,_E({client:t.runtime.client,path:{accountId:e.accountId,adId:e.adId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setAdStatus"]),P("Pause, resume, or archive an ad")),T("attach-ad",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),name:C("name"),creativeId:C("creative-id").pipe(fe(a.check(L()))).pipe(E),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name,...O(e.creativeId)?{creativeId:f(e.creativeId)}:{}}:await Et(r);return t.runtime.decode(H,RE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.attachAd"]),P("Attach a paused ad to an existing ad group")),T("create-boost",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))),postTargetId:C("post-target-id").pipe(fe(a.check(L()))).pipe(E),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))).pipe(E),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await Et(r);return t.runtime.decode(H,wE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createBoost"]),P("Create a paused Facebook Page post boost")),T("validate-boost",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))),postTargetId:C("post-target-id").pipe(fe(a.check(L()))).pipe(E),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))).pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await Et(r);return t.runtime.decode(H,IE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.validateBoost"]),P("Validate a Facebook Page post boost")),T("validate-campaign-plan",{workspace:N,name:C("name"),objective:ke("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await Et(r);return t.runtime.decode(H,Xw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.validateCampaignPlan"]),P("Validate a unified campaign plan")),T("create-campaign-plan",{workspace:N,name:C("name"),objective:ke("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await Et(r);return t.runtime.decode(H,tE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createCampaignPlan"]),P("Create a paused campaign plan")),T("get-campaign-plan",{workspace:N,planId:ne("plan-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,nE({client:t.runtime.client,path:{planId:e.planId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getCampaignPlan"]),P("Read a campaign plan and its target operations")),T("list-campaign-plans",{workspace:N,status:ke("status",["queued","creating","partial","succeeded","failed","unresolved"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,rE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listCampaignPlans"]),P("List campaign plans")),T("get-operation",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),operationId:ne("operation-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,bE({client:t.runtime.client,path:{accountId:e.accountId,operationId:e.operationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getOperation"]),P("Read one ad operation")),T("get-spend-policy",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,gE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getSpendPolicy"]),P("Read an ad account's spend policy")),T("update-spend-policy",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,xE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.updateSpendPolicy"]),P("Replace an ad account's spend policy")),T("set-kill-switch",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),active:ht("active").pipe(tt(!1)),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,SE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{active:e.active,...O(e.reason)?{reason:f(e.reason)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.setKillSwitch"]),P("Set or clear an ad account kill switch"))];var M$=T("ads").pipe(P("Read and manage ad accounts, campaigns, and boosts."),Ze(L$));var F$=[T("accounts").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(Ir(0)),platform:ke("platform",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Sw({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...e.accountId.length?{accountId:[...e.accountId]}:{},...O(e.platform)?{platform:f(e.platform)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.accounts.list"]),P("List account analytics summaries")),T("get",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,bw({client:t.runtime.client,path:{accountId:e.accountId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.accounts.get"]),P("Read one account's analytics"))])),T("posts").pipe(P(""),Ze([T("get",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.posts.get"]),P("Read target-scoped post analytics totals")),T("series",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,xw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.posts.series"]),P("Read daily post analytics series"))])),T("capabilities").pipe(P(""),Ze([T("get",{workspace:N},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Iw({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["analytics.capabilities.get"]),P("Read the analytics metric catalog and provider support"))])),T("refreshes").pipe(P(""),Ze([T("create",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))).pipe(E),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),metrics:ke("metrics",["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,ww({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.postId)?{postId:f(e.postId)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.refreshes.create"]),P("Queue a priority analytics refresh")),T("get",{workspace:N,refreshId:ne("refresh-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Ew({client:t.runtime.client,path:{refreshId:e.refreshId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["analytics.refreshes.get"]),P("Read an analytics refresh status"))]))];var N$=T("analytics").pipe(P("Read post, account, and refresh analytics."),Ze(F$));var B$=[T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,$I({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.list"]),P("List workspace API keys")),T("create",{workspace:N,name:C("name"),scopes:ke("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ir(0)),expiresAt:C("expires-at").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,WI({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...e.scopes.length?{scopes:[...e.scopes]}:{},...O(e.expiresAt)?{expiresAt:f(e.expiresAt)}:{}},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.create"]),P("Create a workspace API key")),T("get",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,zI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.get"]),P("Read API key metadata")),T("update",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),scopes:ke("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,jI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{},...e.scopes.length?{scopes:[...e.scopes]}:{}},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.update"]),P("Rename an API key or change its access")),T("revoke",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,GI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.revoke"]),P("Revoke a workspace API key"))];var K$=T("api-keys").pipe(P("Manage workspace API keys as a signed-in owner."),Ze(B$));var q$=[T("list",{workspace:N,action:ke("action",["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"]).pipe(E),targetKind:ke("target-kind",["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"]).pipe(E),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),actorType:ke("actor-type",["user","api_key"]).pipe(E),actorId:C("actor-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,UE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.action)?{action:f(e.action)}:{},...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.actorType)?{actorType:f(e.actorType)}:{},...O(e.actorId)?{actorId:f(e.actorId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["audit.list"]),P("List workspace audit events")),T("get",{workspace:N,eventId:ne("event-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,DE({client:t.runtime.client,path:{eventId:e.eventId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["audit.get"]),P("Read one audit event")),T("actions").pipe(P(""),Ze([T("list",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,YE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["audit.actions.list"]),P("List documented audit actions"))]))];var $$=T("audit").pipe(P("Read the workspace audit history."),Ze(q$));var W$=Le("timeout").pipe(tt(600),Oe("Maximum seconds to wait for sign-in.")),j5=T("login",{browser:Xu,timeout:W$,noWait:ht("no-wait").pipe(tt(!1),Oe("Print the verification URL and code, then exit. Finish with `pnio auth complete`."))},(e)=>R(async()=>{let t=Ai(),r=await O$(t);if(console.error(`Open ${r.url} and confirm code ${r.userCode}.`),e.browser)ay(r.completeUrl);if(e.noWait)return r;let n=await IA(t,{timeoutMs:e.timeout*1000});return Aa({baseUrl:t,accessToken:n}).me.get()})).pipe(P("Sign in with a WorkOS device code, or hand off with --no-wait.")),Q5=T("complete",{timeout:W$},(e)=>R(async()=>{let t=Ai(),r=await IA(t,{timeoutMs:e.timeout*1000});return Aa({baseUrl:t,accessToken:r}).me.get()})).pipe(P("Finish a sign-in started with `pnio auth login --no-wait`.")),H5=T("status",{},()=>R(async()=>(await ho(void 0,"human")).me.get())).pipe(P("Show the current PubNio account.")),V5=T("logout",{},()=>R(async()=>(await U$(Ai()),{signedOut:!0}))).pipe(P("Revoke the CLI session and clear local credentials.")),G$=T("auth").pipe(P("Manage your CLI session."),Ze([j5,Q5,H5,V5]));var z$=[T("status",{workspace:N},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,GE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["billing.get"]),P("Get workspace billing status")),T("usage",{workspace:N,from:C("from").pipe(E),to:C("to").pipe(E),meter:ke("meter",["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,zE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.meter)?{meter:f(e.meter)}:{},...O(e.provider)?{provider:f(e.provider)}:{}},...t.runtime.transport()}))})).pipe(F(_,["billing.usage.get"]),P("Get workspace daily usage summary")),T("ledger",{workspace:N,kind:ke("kind",["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,jE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.kind)?{kind:f(e.kind)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["billing.ledger.list"]),P("List workspace prepaid credit ledger")),T("plans",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,JE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["billing.plans.list"]),P("List public billing plans")),T("top-up",{workspace:N,idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{}:await Et(r);return t.runtime.decode(H,QE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["billing.checkout.create"]),P("Create a hosted checkout session for a plan upgrade or credit top-up")),T("portal",{workspace:N,returnUrl:C("return-url").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,HE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.returnUrl)?{returnUrl:f(e.returnUrl)}:{}},...t.runtime.transport()}))})).pipe(F(_,["billing.portal.create"]),P("Create a hosted billing portal session")),T("spend-cap",{workspace:N,version:Le("version"),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{version:e.version}:await Et(r);return t.runtime.decode(H,VE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["billing.spendControls.update"]),P("Update monthly spend cap"))];var j$=T("billing").pipe(P("Manage workspace billing, usage, and checkout."),Ze(z$));var Q$=[T("catalog",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,lw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["capabilities.catalog"]),P("Read the static provider capability catalog")),T("get",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,dw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["capabilities.get"]),P("Read the publish capability catalog")),T("list",{workspace:N,profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),capability:ke("capability",["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,uw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.capability)?{capability:f(e.capability)}:{}},...t.runtime.transport()}))})).pipe(F(_,["capabilities.list"]),P("List computed capabilities for connected accounts"))];var H$=T("capabilities").pipe(P("Read publishing capabilities, placements, and limits."),Ze(Q$));var V$=[T("create",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E),target:C("target"),targetKind:ke("target-kind",["post","comment"]).pipe(E),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,k6({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},target:e.target,...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["comments.create"]),P("Comment on or reply to a provider post"))];var J$=T("comments").pipe(P("Create comments where a destination supports them."),Ze(V$));var Y$=[T("get",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,fw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["limits.get"]),P("Read documented API limits"))];var Z$=T("limits").pipe(P("Read workspace publishing limits."),Ze(Y$));var X$=[T("capabilities",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Bw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.capabilities.get"]),P("Read per-account inbox channel capabilities")),T("unread-count",{workspace:N},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Nw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.unread.count"]),P("Count conversations with at least one unread inbound message")),T("conversations").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["active","archived"]).pipe(E),folder:ke("folder",["inbox","message_request","spam","other"]).pipe(E),unread:ke("unread",["true","false"]).pipe(E),search:C("search").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,kw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.folder)?{folder:f(e.folder)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.search)?{search:f(e.search)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.list"]),P("List DM conversations newest first")),T("get",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Aw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.get"]),P("Read one conversation and reply window")),T("update",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),status:ke("status",["active","archived"]).pipe(E),read:ht("read").pipe(tt(!1))},(e)=>R(async()=>{let t=await V();if(!(O(e.status)||e.read))throw new Fe("Provide --status or --read.");return t.runtime.decode(H,vw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.status)?{status:f(e.status)}:{},...e.read?{read:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.update"]),P("Mark read or archive a conversation"))])),T("messages").pipe(P(""),Ze([T("list",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),order:ke("order",["oldest","newest"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Cw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.order)?{order:f(e.order)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.messages.list"]),P("Page messages oldest or newest first")),T("send",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Tw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.messages.send"]),P("Send a text reply inside the provider window"))])),T("comments").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),postId:C("post-id").pipe(fe(a.check(L()))).pipe(E),providerPostId:C("provider-post-id").pipe(E),unread:ke("unread",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Ow({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.postId)?{postId:f(e.postId)}:{},...O(e.providerPostId)?{providerPostId:f(e.providerPostId)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.list"]),P("List comment threads with counts")),T("get",{workspace:N,threadId:ne("thread-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Pw({client:t.runtime.client,path:{threadId:e.threadId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.get"]),P("Read a comment thread and its comments")),T("reply",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Rw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.reply"]),P("Reply to a comment")),T("moderate",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L()))),hidden:ht("hidden").pipe(tt(!1)),liked:ht("liked").pipe(tt(!1))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Uw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.hidden?{hidden:!0}:{},...e.liked?{liked:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.moderate"]),P("Hide, unhide, like, or unlike a comment")),T("delete",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,_w({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.delete"]),P("Delete a comment where the provider supports it"))])),T("mentions").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Dw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.mentions.list"]),P("List mentions of a connected account")),T("reply",{workspace:N,mentionId:ne("mention-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Lw({client:t.runtime.client,path:{mentionId:e.mentionId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.mentions.reply"]),P("Reply to a mention where supported"))])),T("sync").pipe(P(""),Ze([T("start",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Kw({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.sync.start"]),P("Queue a bounded inbox sync")),T("status",{workspace:N,syncRunId:ne("sync-run-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,qw({client:t.runtime.client,path:{syncRunId:e.syncRunId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.sync.get"]),P("Read a sync run and current inbox counts"))])),T("attachments").pipe(P(""),Ze([T("get",{workspace:N,attachmentId:ne("attachment-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,$w({client:t.runtime.client,path:{attachmentId:e.attachmentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.attachments.get"]),P("Stream an inbound attachment"))])),T("reviews").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),includeDeleted:ke("include-deleted",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Mw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.includeDeleted)?{includeDeleted:f(e.includeDeleted)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.list"]),P("List stored Google Business Profile reviews newest first")),T("get",{workspace:N,reviewId:ne("review-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Fw({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.get"]),P("Read one stored Google Business Profile review")),T("reply",{workspace:N,reviewId:ne("review-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,E6({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.reply"]),P("Reply to a Google Business Profile review"))]))];var e1=T("inbox").pipe(P("Read and reply from the unified inbox."),Ze(X$));var t1=[T("get-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),includeAdAccounts:ke("include-ad-accounts",["true","false"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,nw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeAdAccounts)?{includeAdAccounts:f(e.includeAdAccounts)}:{}},...t.runtime.transport()}))})).pipe(F(_,["integrations.getAccount"]),P("Check account readiness")),T("bluesky-session",{workspace:N,handle:C("handle"),appPassword:C("app-password"),service:C("service").pipe(E),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,w6({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{handle:e.handle,appPassword:e.appPassword,...O(e.service)?{service:f(e.service)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["integrations.blueskySession"]),P("Connect Bluesky with an app password")),T("get-instagram-audio",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),audioId:ne("audio-id")},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,ow({client:t.runtime.client,path:{accountId:e.accountId,audioId:e.audioId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["integrations.getInstagramAudio"]),P("Read current Instagram audio metadata and refresh its preview URL")),T("move-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),profileId:C("profile-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,rw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{profileId:e.profileId},...t.runtime.transport()}))})).pipe(F(_,["integrations.moveAccount"]),P("Move an account to another profile"))];var bp=ne("account-id").pipe(ie(bu.fields.accountId)),n1=ke("login-method",oh.literals).pipe(E),o1=Le("timeout").pipe(tt(120),Oe("Maximum seconds to wait for consent."));async function i1(e,t,r){let n=Date.now()+Math.max(0,r)*1000;for(;;){let o=await e.accounts.connectionStatus(t);if(o.status!=="pending")return o;if(Date.now()>=n)return{...o,timedOut:!0};await Bun.sleep(1000)}}function s1(e,t,r){if(new URL(e.url).origin!==t)throw Error("PubNio returned an invalid connection URL.");if(console.error(`Open the URL as the same PubNio user, then check \`pnio integrations wait ${e.attemptId}\`.`),r)ay(e.url);return e}var J5=T("list",{workspace:N},({workspace:e})=>R(async()=>(await Ke(f(e))).accounts.list())).pipe(F(_,["integrations.list"]),P("List publishing destinations.")),Y5=T("connect",{provider:U8("provider",bn.literals),workspace:N,browser:Xu,loginMethod:n1,wait:ht("wait").pipe(tt(!1),Oe("Wait for consent before returning.")),timeout:o1},(e)=>R(async()=>{let t=Ai(),r=await Ke(f(e.workspace),{origin:t}),n=await r.accounts.prepareConnection(e.provider,f(e.loginMethod)),o=s1(n,t,e.browser);if(!e.wait)return o;let i=await i1(r,n.attemptId,e.timeout);if(i.status!=="connected")process.exitCode=1;return{...o,connection:i}})).pipe(F(_,["integrations.prepareConnection","integrations.connectionStatus"]),P("Connect Facebook, Instagram, or TikTok.")),Z5=T("wait",{attempt:ne("attempt-id").pipe(ie(qb.fields.attemptId)),workspace:N,timeout:o1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await i1(t,e.attempt,e.timeout);if(r.status!=="connected")process.exitCode=1;return r})).pipe(F(_,["integrations.connectionStatus"]),P("Wait for an account connection to finish.")),X5=T("status",{attempt:ne("attempt-id").pipe(ie(qb.fields.attemptId)),workspace:N},({attempt:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.connectionStatus(e))).pipe(F(_,["integrations.connectionStatus"]),P("Check whether social account OAuth completed.")),eZ=T("health",{account:bp,workspace:N},({account:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.get(e))).pipe(F(_,["integrations.getAccount"]),P("Check account readiness using the last recorded grant.")),tZ=T("instagram-quota",{account:bp,workspace:N},({account:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.instagramPublishingLimit(e))).pipe(F(_,["integrations.instagramPublishingLimit"]),P("Read the Instagram account\u2019s current publishing quota.")),rZ=T("instagram-audio",{account:bp,workspace:N,type:ke("type",sh.literals).pipe(tt("music")),query:C("query").pipe(E)},({account:e,workspace:t,type:r,query:n})=>R(async()=>(await Ke(f(t))).accounts.searchInstagramAudio(e,{audioType:r,q:f(n)}))).pipe(F(_,["integrations.searchInstagramAudio"]),P("Search Instagram\u2019s catalog or list trending audio.")),nZ=T("instagram-audio-info",{account:bp,workspace:N,audioId:ne("audio-id").pipe(ie(rp))},({account:e,workspace:t,audioId:r})=>R(async()=>(await Ke(f(t))).accounts.getInstagramAudio(e,r))).pipe(F(_,["integrations.getInstagramAudio"]),P("Read current metadata for an Instagram audio track.")),oZ=T("reconnect",{account:bp,workspace:N,browser:Xu,loginMethod:n1},(e)=>R(async()=>{let t=Ai(),r=await Ke(f(e.workspace),{origin:t});return s1(await r.accounts.reconnect(e.account,f(e.loginMethod)),t,e.browser)})).pipe(F(_,["integrations.reconnect"]),P("Reauthorize a connected account while keeping its ID.")),iZ=T("disconnect",{connection:ne("connection-id").pipe(ie(FD.fields.connectionId)),workspace:N,yes:ht("yes").pipe(tt(!1))},({connection:e,workspace:t,yes:r})=>R(async()=>{if(!r)throw new Fe("Pass --yes to disconnect the grant and disable all accounts using it.");return(await Ke(f(t))).accounts.disconnect(e)})).pipe(F(_,["integrations.disconnect"]),P("Remove a grant and disable its accounts."));function r1(e){return T(e,{account:bp,workspace:N},({account:t,workspace:r})=>R(async()=>(await Ke(f(r))).accounts.setEnabled({id:t,enabled:e==="enable"}))).pipe(F(_,["integrations.setEnabled"]),P(`${e==="enable"?"Enable":"Disable"} a publishing destination.`))}var a1=T("integrations").pipe(P("Connect and select publishing destinations."),Ze([J5,Y5,Z5,X5,eZ,tZ,rZ,nZ,oZ,iZ,r1("enable"),r1("disable"),...t1]));import{writeFile as sZ}from"fs/promises";var c1=[T("status",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Rh({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.status"]),P("Get workspace media intake status")),T("get",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,yw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.get"]),P("Get workspace media metadata")),T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E),type:ke("type",["image","video","document"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,mw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{},...O(e.type)?{type:f(e.type)}:{}},...t.runtime.transport()}))})).pipe(F(_,["media.list"]),P("List ready workspace media")),T("delete",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,hw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.delete"]),P("Delete unused workspace media"))];var p1=ne("media-id").pipe(ie(xn)),aZ=T("upload",{file:ne("file"),workspace:N,mime:ke("mime",ep.literals).pipe(E),key:ot},(e)=>R(async()=>{let t=Bun.file(e.file);if(!await t.exists())throw new Fe("Choose an existing media file.");return(await Ke(f(e.workspace))).media.upload(t,{mimeType:f(e.mime),idempotencyKey:f(e.key)})})).pipe(F(_,["media.upload","media.startUpload","media.uploadPart","media.completeUpload"]),P("Upload an image, video, or document for use in posts.")),cZ=T("import",{url:ne("url"),workspace:N,key:ot},(e)=>R(async()=>(await Ke(f(e.workspace))).media.importUrl(e.url,{idempotencyKey:f(e.key)}))).pipe(F(_,["media.import"]),P("Copy a public or signed HTTPS URL into private workspace media.")),pZ=T("wait",{mediaId:p1,workspace:N,timeoutSeconds:Le("timeout").pipe(tt(30),Oe("Maximum seconds to wait for media readiness."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>300)throw new Fe("Use a timeout between 0 and 300 seconds.");let t=await(await Ke(f(e.workspace))).media.wait(e.mediaId,{timeoutMs:e.timeoutSeconds*1000});if(t.status!=="ready")process.exitCode=1;return t})).pipe(F(_,["media.status"]),P("Wait for media readiness and return ready, failed, or timeout.")),dZ=T("download",{mediaId:p1,workspace:N,out:C("out")},(e)=>R(async()=>{let t=await(await Ke(f(e.workspace))).media.download(e.mediaId);return await sZ(e.out,new Uint8Array(await t.arrayBuffer()),{flag:"wx"}),{path:e.out,sizeBytes:t.size}})).pipe(F(_,["media.download"]),P("Save private media to a new local file.")),d1=T("media").pipe(P("Manage workspace media files."),Ze([aZ,cZ,...c1,pZ,dZ]));var u1=[T("get",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,zw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["posts.get"]),P("Read a post or draft")),T("attempts",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Qw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["posts.attempts"]),P("Read a destination's delivery attempt history")),T("retry",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),expectedAttemptId:C("expected-attempt-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Hw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(F(_,["posts.retry"]),P("Retry a failed delivery")),T("reconcile",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),expectedAttemptId:C("expected-attempt-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Vw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(F(_,["posts.reconcile"]),P("Recheck a recorded provider receipt")),T("update",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),text:C("text").pipe(E),expectedRevision:Le("revision").pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{...O(e.text)?{text:f(e.text)}:{},...O(e.expectedRevision)?{expectedRevision:f(e.expectedRevision)}:{}}:await Et(r);return t.runtime.decode(H,jw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["posts.update"]),P("Edit a draft")),T("delete",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["posts.delete"]),P("Archive a post or draft"))];var uZ=io(mL,{onExcessProperty:"error"}),Iy=ne("post-id").pipe(ie(zU.fields.postId)),lZ=Le("revision").pipe(fe(po),Oe("Expected revision from posts get.")),fZ=T("create",{workspace:N,text:C("text").pipe(E,Oe("Post text for the one-call path.")),platform:ke("platform",cs).pipe(Ir(0),Oe("Publish to the single ready account for this provider. Repeat for several platforms.")),account:qq,mediaId:C("media-id").pipe(fe(xn),Ir(0),Oe("Attach ready workspace media by ID.")),mediaUrl:C("media-url").pipe(Ir(0),Oe("Attach a public HTTPS media URL.")),schedule:C("schedule").pipe(fe(Ut),E,Oe("Schedule with an ISO time and explicit offset.")),publishNow:ht("publish-now").pipe(tt(!0),Oe("Publish now when --schedule is absent.")),draft:ht("draft").pipe(tt(!1),Oe("Save a draft without submitting it.")),file:C("file").pipe(E,Oe("Advanced: read a full Level 2 post JSON document from a file or stdin with -.")),key:ot,queue:C("queue").pipe(fe(tr),E,Oe("Assign every file-provided destination to this account queue."))},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.key),n=f(e.file),o=f(e.schedule);if(e.draft&&o)throw new Fe("Drafts cannot set --schedule until published.");if(n){if(O(e.text)||e.platform.length||e.account.length||e.mediaId.length||e.mediaUrl.length||o&&!e.draft||!e.publishNow&&!e.draft)throw new Fe("Use --file alone, or provide --text with --platform or --account.");let c=await uZ(await Et(n)).catch(()=>{throw new Fe("Post JSON does not match the PubNio API contract.")}),l=f(e.queue);if(l&&e.draft)throw new Fe("Drafts cannot be assigned a queue.");if(l&&(c.targets??[]).some((S)=>S.scheduledAt!==void 0||S.queueId!==void 0))throw new Fe("Remove per-target schedules or queues when using --queue.");return t.posts.create({...l?{...c,targets:(c.targets??[]).map((S)=>({...S,queueId:l}))}:c,...e.draft?{isDraft:!0}:{},...r?{idempotencyKey:r}:{}})}let i=f(e.text);if(i===void 0)throw new Fe("Provide --text or --file.");if(e.draft&&e.platform.length)throw new Fe("Drafts select exact --account IDs, not platforms.");if(!e.draft&&O(e.queue))throw new Fe("--queue requires --file.");if(!e.draft&&e.platform.length&&e.account.length)throw new Fe("Use --platform or --account, not both.");if(!e.draft&&!e.platform.length&&!e.account.length)throw new Fe("Provide at least one --platform or --account.");let s=[...e.mediaId.map((c)=>({mediaId:c})),...e.mediaUrl.map((c)=>({url:c}))];if(e.draft)return t.posts.create({text:i,isDraft:!0,...e.account.length?{targets:e.account.map((c)=>({accountId:c}))}:{},...s.length?{media:s}:{}});return t.posts.create({text:i,...e.platform.length?{platforms:[...e.platform]}:{},...e.account.length?{accounts:[...e.account]}:{},...s.length?{media:s}:{},...o?{scheduledAt:o}:{},publishNow:e.publishNow,...r?{idempotencyKey:r}:{}})})).pipe(F(_,["posts.create"]),P("Create and submit a post in one call, or save a draft with --draft.")),mZ=T("list",{workspace:N,...xs,draft:ht("draft").pipe(tt(!1),Oe("List only drafts. Omit to list posts and drafts.")),deliveryStatus:ke("delivery-status",Yc.literals).pipe(E)},(e)=>R(async()=>(await Ke(f(e.workspace))).posts.list({cursor:f(e.cursor),limit:f(e.limit),...e.draft?{isDraft:!0}:{},deliveryStatus:f(e.deliveryStatus)}))).pipe(F(_,["posts.list"]),P("List posts and drafts, and filter their current deliveries.")),hZ=T("validate",{workspace:N,id:Iy},(e)=>R(async()=>{let t=await(await Ke(f(e.workspace))).posts.validate(e.id);if(!t.canPublish)process.exitCode=1;return t})).pipe(F(_,["posts.validate"]),P("Validate a saved draft before publishing.")),yZ=T("publish",{id:Iy,workspace:N,revision:lZ,key:ot,at:C("at").pipe(fe(Ut),E),queue:C("queue").pipe(fe(tr),E),account:$q,placement:ke("placement",xr.literals).pipe(E)},(e)=>R(async()=>{let t=f(e.placement),r=f(e.account),n=f(e.at),o=f(e.queue),i=f(e.key);if(t&&!r)throw new Fe("Use --placement with --account.");if(n&&o)throw new Fe("Use --at or --queue, not both.");let s=await Ke(f(e.workspace));if(o){let l=(await s.posts.get(e.id)).targets.filter((S)=>!r||S.accountId.toLowerCase()===r.toLowerCase());if(!l.length||t&&l.some((S)=>S.placement!==t))throw new Fe("No matching destination exists in this post for --queue.");return s.posts.publish(e.id,{expectedRevision:e.revision,idempotencyKey:i,targets:l.map((S)=>({accountId:S.accountId,placement:S.placement,queueId:o}))})}return s.posts.publish(e.id,{expectedRevision:e.revision,scheduledAt:n,idempotencyKey:i,...r&&t?{targets:[{accountId:r,placement:t,scheduledAt:n}]}:r?{accountIds:[r]}:{}})})).pipe(F(_,["posts.get","posts.publish"]),P("Publish a saved draft now or at --at.")),gZ=T("status",{workspace:N,id:Iy},(e)=>R(async()=>(await Ke(f(e.workspace))).posts.status(e.id))).pipe(F(_,["posts.get"]),P("Read delivery outcomes for a post.")),xZ=T("wait",{workspace:N,id:Iy,timeoutSeconds:Le("timeout").pipe(tt(60),Oe("Maximum seconds to wait for delivery."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>3600)throw new Fe("Use a timeout between 0 and 3600 seconds.");let t=await(await Ke(f(e.workspace))).posts.wait(e.id,{timeoutMs:e.timeoutSeconds*1000});if(!t.settled)process.exitCode=1;return t})).pipe(F(_,["posts.get"]),P("Wait for a post to reach a settled delivery outcome."));function AA(e,t){return R(async()=>(await Ke(f(e.workspace))).schedule.change(DU(e.postId),LU(e.targetId),t))}var vA={postId:ne("post-id").pipe(ie(Eb.fields.postId)),targetId:ne("target-id").pipe(ie(Eb.fields.targetId)),expectedAttemptId:C("attempt").pipe(fe(zt),Oe("Current attempt ID from posts status.")),workspace:N},SZ=T("reschedule",{...vA,at:C("at").pipe(fe(Ut),E),queue:C("queue").pipe(fe(tr),E),slot:C("slot").pipe(fe(a.check(L())),E),date:C("date").pipe(fe(wn),E)},(e)=>{let t=f(e.at),r=f(e.queue),n=f(e.slot),o=f(e.date);if(t===void 0===(r===void 0))throw new Fe("Use exactly one of --at or --queue.");if(r&&n===void 0!==(o===void 0))throw new Fe("Use --slot and --date together to pin a slot.");return AA(e,r?{action:"reschedule",expectedAttemptId:e.expectedAttemptId,queueId:r,...n&&o?{pinned:{slotId:n,occurrenceDate:o}}:{}}:{action:"reschedule",expectedAttemptId:e.expectedAttemptId,scheduledAt:t})}).pipe(F(_,["schedule.change"]),P("Move a pending delivery to a queue slot or time.")),bZ=T("cancel",vA,(e)=>AA(e,{action:"cancel",expectedAttemptId:e.expectedAttemptId})).pipe(F(_,["schedule.change"]),P("Cancel a delivery before the provider write is reserved.")),IZ=T("publish-now",vA,(e)=>AA(e,{action:"publish_now",expectedAttemptId:e.expectedAttemptId})).pipe(F(_,["schedule.change"]),P("Bring a pending delivery forward.")),l1=T("posts").pipe(P("Create and publish posts, save drafts, and manage delivery status."),Ze([fZ,mZ,...u1,hZ,yZ,gZ,xZ,SZ,bZ,IZ]));var kn=ne("queue-id").pipe(ie(tr)),wy=Le("version").pipe(Oe("Expected version from the last queue read.")),m1={maxPerDay:Le("max-per-day").pipe(E),maxPending:Le("max-pending").pipe(E),minGap:Le("min-gap").pipe(E),horizon:Le("horizon-days").pipe(E)},h1={slot:C("slot").pipe(f9(50),Oe("Weekly slot as DAY:HH:mm where 0 is Sunday."))},wZ=io(EL,{onExcessProperty:"error"}),EZ=io(kL,{onExcessProperty:"error"}),kZ=io(AL,{onExcessProperty:"error"}),AZ=io(RL,{onExcessProperty:"error"}),vZ=io(DL,{onExcessProperty:"error"});function y1(e){let t=/^([0-6]):((?:[01]\d|2[0-3]):[0-5]\d)$/.exec(e);if(!t)throw new Fe("Use --slot DAY:HH:mm where DAY is 0-6, 0 Sunday.");return{dayOfWeek:Number(t[1]),time:t[2]}}function g1(e){let t=f(e.maxPerDay),r=f(e.maxPending),n=f(e.minGap),o=f(e.horizon);return{...t===void 0?{}:{maxPerDay:t},...r===void 0?{}:{maxPending:r},...n===void 0?{}:{minGapSeconds:n},...o===void 0?{}:{horizonDays:o}}}var CZ=T("list",{workspace:N,account:eA,...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.list({accountId:f(e.account),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.list"]),P("List account schedule queues.")),TZ=T("create",{workspace:N,file:C("file").pipe(E,Oe("Read CreateQueue JSON from a file or stdin with -.")),account:eA,name:C("name").pipe(E),timezone:C("timezone").pipe(E,Oe("IANA time zone, e.g. America/New_York. Defaults to the workspace default time zone.")),default:ht("default").pipe(E,Oe("Promote the new queue to the account default. The first active queue is always the default.")),...h1,...m1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.file),n=await wZ(r?await Et(r):{accountId:f(e.account),name:f(e.name),...ir(e.timezone)?{}:{timezone:e.timezone.value},slots:e.slot.map(y1),...ir(e.default)?{}:{isDefault:e.default.value},...g1(e)}).catch(()=>{throw new Fe("Queue JSON does not match the PubNio API contract.")});return t.queues.create(n)})).pipe(F(_,["queues.create"]),P("Create a weekly queue for an account; the first is the default. Omit --timezone to use the workspace default.")),OZ=T("get",{workspace:N,queueId:kn},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.get(e.queueId))).pipe(F(_,["queues.get"]),P("Read a queue, its slots, and its limits.")),PZ=T("update",{workspace:N,queueId:kn,version:wy,file:C("file").pipe(E,Oe("Read UpdateQueue JSON from a file or stdin with -.")),name:C("name").pipe(E),timezone:C("timezone").pipe(E),pause:ht("pause").pipe(tt(!1)),resume:ht("resume").pipe(tt(!1)),default:ht("default").pipe(E,Oe("Promote or demote the account default. Demote only after promoting another queue.")),...m1},(e)=>R(async()=>{if(e.pause&&e.resume)throw new Fe("Use --pause or --resume, not both.");let t=await Ke(f(e.workspace)),r=f(e.file),n=await EZ(r?await Et(r):{expectedVersion:e.version,...ir(e.name)?{}:{name:e.name.value},...ir(e.timezone)?{}:{timezone:e.timezone.value},...e.pause?{paused:!0}:e.resume?{paused:!1}:{},...ir(e.default)?{}:{isDefault:e.default.value},...g1(e)}).catch(()=>{throw new Fe("Queue update JSON does not match the PubNio API contract.")});return t.queues.update(e.queueId,n)})).pipe(F(_,["queues.update"]),P("Update limits, name, time zone, default, pause, or resume a queue.")),RZ=T("archive",{workspace:N,queueId:kn,version:wy},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.archive(e.queueId,e.version))).pipe(F(_,["queues.archive"]),P("Archive a queue and keep queued work.")),_Z=T("slots",{workspace:N,queueId:kn,version:wy,file:C("file").pipe(E,Oe("Read ReplaceQueueSlots JSON from a file or stdin.")),...h1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.file),n=await kZ(r?await Et(r):{expectedVersion:e.version,slots:e.slot.map(y1)}).catch(()=>{throw new Fe("Queue slot JSON does not match the PubNio API contract.")});return t.queues.replaceSlots(e.queueId,n)})).pipe(F(_,["queues.slots.replace"]),P("Replace every weekly queue slot.")),UZ=T("next-slot",{workspace:N,queueId:kn,after:C("after").pipe(E)},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.nextSlot(e.queueId,f(e.after)))).pipe(F(_,["queues.slots.next"]),P("Read the next free queue occurrence.")),DZ=T("preview",{workspace:N,queueId:kn,count:Le("count").pipe(tt(10)),after:C("after").pipe(E),includeOccupied:ht("include-occupied").pipe(tt(!1))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.previewSlots(e.queueId,{count:e.count,after:f(e.after),includeOccupied:e.includeOccupied}))).pipe(F(_,["queues.slots.preview"]),P("Preview upcoming queue occurrences.")),LZ=T("skips",{workspace:N,queueId:kn,...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.skips(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.skips.list"]),P("List skipped queue occurrences.")),MZ=T("skip",{workspace:N,queueId:kn,slotId:C("slot-id").pipe(fe(wu)),occurrenceDate:C("occurrence-date")},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await AZ({slotId:e.slotId,occurrenceDate:e.occurrenceDate}).catch(()=>{throw new Fe("Use --slot-id with a queue slot UUID and --occurrence-date YYYY-MM-DD.")});return t.queues.skip(e.queueId,r.slotId,r.occurrenceDate)})).pipe(F(_,["queues.skips.create"]),P("Skip one queue occurrence.")),FZ=T("unskip",{workspace:N,queueId:kn,skipId:C("skip-id").pipe(fe(wu))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.unskip(e.queueId,e.skipId))).pipe(F(_,["queues.skips.delete"]),P("Restore a skipped queue occurrence.")),NZ=T("blackouts",{workspace:N,queueId:kn,...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.blackouts(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.blackouts.list"]),P("List queue blackout date ranges.")),BZ=T("blackout",{workspace:N,queueId:kn,startsOn:C("starts-on"),endsOn:C("ends-on"),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await vZ({startsOn:e.startsOn,endsOn:e.endsOn,reason:f(e.reason)}).catch(()=>{throw new Fe("Use --starts-on and --ends-on as YYYY-MM-DD; --reason is at most 200 characters.")});return t.queues.blackout(e.queueId,r)})).pipe(F(_,["queues.blackouts.create"]),P("Black out a queue date range.")),KZ=T("unblackout",{workspace:N,queueId:kn,blackoutId:C("blackout-id").pipe(fe(dh))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.unblackout(e.queueId,e.blackoutId))).pipe(F(_,["queues.blackouts.delete"]),P("Remove a queue blackout.")),f1=(e)=>T(e?"pause":"resume",{workspace:N,queueId:kn,version:wy},(t)=>R(async()=>(await Ke(f(t.workspace))).queues.update(t.queueId,{expectedVersion:t.version,paused:e}))).pipe(F(_,["queues.update"]),P(e?"Pause new assignments while queued attempts still publish.":"Resume new assignments.")),x1=T("queues").pipe(P("Manage weekly account publishing queues."),Ze([CZ,TZ,OZ,PZ,RZ,_Z,UZ,DZ,LZ,MZ,FZ,NZ,BZ,KZ,f1(!0),f1(!1)]));var qZ=T("list",{workspace:N,from:C("from").pipe(Oe("Inclusive ISO start instant, for example 2026-12-01T00:00:00Z.")),to:C("to").pipe(Oe("Inclusive ISO end instant, at most 90 days after --from.")),accountId:C("account-id").pipe(fe(J),E,Oe("Filter by the target publishing account.")),queueId:C("queue-id").pipe(fe(tr),E,Oe("Filter by the open queue assignment.")),...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).schedule.list({from:e.from,to:e.to,accountId:f(e.accountId),queueId:f(e.queueId),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["schedule.list"]),P("List queued attempts in a time range.")),$Z=T("skip-to-next",{workspace:N,postId:C("post-id").pipe(fe(_t)),targetId:C("target-id").pipe(fe(cr)),queueId:C("queue-id").pipe(fe(tr),E,Oe("Override the target delivery's current queue.")),expectedAttemptId:C("expected-attempt-id").pipe(fe(zt),E,Oe("Override the target delivery's current attempt."))},(e)=>R(async()=>(await Ke(f(e.workspace))).schedule.skipToNext(e.postId,e.targetId,{queueId:f(e.queueId),expectedAttemptId:f(e.expectedAttemptId)}))).pipe(F(_,["posts.get","queues.slots.next","schedule.change"]),P("Move a queue-assigned target to the next free occurrence.")),S1=T("schedule").pipe(P("Read the publishing calendar and skip ahead."),Ze([qZ,$Z]));var b1=[T("preferences").pipe(P(""),Ze([T("get",{workspace:N},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,LE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["notifications.preferences.get"]),P("Read email notification preferences")),T("update",{workspace:N,deliveryFailures:ht("delivery-failures").pipe(tt(!1)),connectionExpiring:ht("connection-expiring").pipe(tt(!1)),webhookFailures:ht("webhook-failures").pipe(tt(!1)),billingAlerts:ht("billing-alerts").pipe(tt(!1)),weeklyDigest:ht("weekly-digest").pipe(tt(!1))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,ME({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.deliveryFailures?{deliveryFailures:!0}:{},...e.connectionExpiring?{connectionExpiring:!0}:{},...e.webhookFailures?{webhookFailures:!0}:{},...e.billingAlerts?{billingAlerts:!0}:{},...e.weeklyDigest?{weeklyDigest:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["notifications.preferences.update"]),P("Update email notification preferences"))]))];var I1=T("notifications").pipe(P("Read and update notification preferences."),Ze(b1));var w1=[T("get",{},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,MI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["profile.get"]),P("Get your profile"))];var WZ=T("update",{name:C("name").pipe(E),clear:ht("clear-name").pipe(tt(!1))},({name:e,clear:t})=>R(async()=>{if(e._tag==="Some"===t)throw new Fe("Provide exactly one of --name or --clear-name.");let r=ns(BU)({displayName:e._tag==="Some"?e.value:null});if(r._tag==="None")throw new Fe("Display name must be between 1 and 100 characters.");return(await ho()).me.update(r.value)})).pipe(F(_,["profile.update"]),P("Change or clear your display name.")),GZ=T("deactivate",{yes:ht("yes").pipe(tt(!1))},({yes:e})=>R(async()=>{if(!e)throw new Fe("Pass --yes to deactivate the current profile.");return(await ho()).me.deactivate()})).pipe(F(_,["profile.deactivate"]),P("Deactivate your profile after archiving owned workspaces.")),zZ=T("list",{},()=>R(async()=>(await ho(void 0,"human")).me.invites())).pipe(F(_,["me.invites.list"])),jZ=T("accept",{inviteId:ne("invite-id").pipe(ie(fi))},({inviteId:e})=>R(async()=>(await ho(void 0,"human")).me.acceptInvite({inviteId:e}))).pipe(F(_,["me.invites.accept"])),QZ=T("decline",{inviteId:ne("invite-id").pipe(ie(fi))},({inviteId:e})=>R(async()=>(await ho(void 0,"human")).me.declineInvite(e))).pipe(F(_,["me.invites.decline"])),HZ=T("invites").pipe(P("Manage your workspace invitations."),Ze([zZ,jZ,QZ])),E1=T("profile").pipe(P("Manage your PubNio profile."),Ze([...w1,WZ,GZ,HZ]));var k1=[T("list",{workspace:N,includeArchived:ke("include-archived",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,iw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeArchived)?{includeArchived:f(e.includeArchived)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["profiles.list"]),P("List workspace profiles")),T("create",{workspace:N,name:C("name"),externalId:C("external-id").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,sw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...O(e.externalId)?{externalId:f(e.externalId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["profiles.create"]),P("Create a workspace profile")),T("get",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,cw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["profiles.get"]),P("Read a workspace profile")),T("update",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{}}:await Et(r);return t.runtime.decode(H,pw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["profiles.update"]),P("Rename a profile or change its external ID")),T("archive",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,aw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["profiles.archive"]),P("Archive a workspace profile"))];var A1=T("profiles").pipe(P("Manage posting profiles."),Ze(k1));var v1=[T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,QI({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["webhooks.list"]),P("List webhook endpoints")),T("create",{workspace:N,name:C("name"),url:C("url"),eventTypes:ke("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Ir(0)),enabled:ht("paused").pipe(tt(!1)),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),accountIds:C("account-ids").pipe(Ir(0)),disabledResourceGroups:ke("disabled-resource-groups",["publishing","inbox","analytics","ads","scheduling","accounts","billing"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,HI({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,url:e.url,eventTypes:[...e.eventTypes],...e.enabled?{enabled:!1}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...e.accountIds.length?{accountIds:[...e.accountIds]}:{},...e.disabledResourceGroups.length?{disabledResourceGroups:[...e.disabledResourceGroups]}:{}},...t.runtime.transport()}))})).pipe(F(_,["webhooks.create"]),P("Register a webhook endpoint")),T("get",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,JI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.get"]),P("Inspect a webhook endpoint")),T("update",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),eventTypes:ke("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Ir(0)),enabled:ht("paused").pipe(tt(!1)),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{},...e.eventTypes.length?{eventTypes:[...e.eventTypes]}:{},...e.enabled?{enabled:!1}:{}}:await Et(r);return t.runtime.decode(H,YI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["webhooks.update"]),P("Edit or pause a webhook endpoint")),T("delete",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,VI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.delete"]),P("Permanently disable a webhook endpoint")),T("test",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,ZI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.test"]),P("Enqueue a webhook test event")),T("list-deliveries",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,XI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["webhooks.listDeliveries"]),P("List webhook deliveries")),T("get-delivery",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),deliveryId:ne("delivery-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,ew({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.getDelivery"]),P("Inspect a webhook delivery")),T("replay-delivery",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),deliveryId:ne("delivery-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,tw({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.replayDelivery"]),P("Replay a settled webhook delivery")),T("event-types",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,I6({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["webhooks.eventTypes"]),P("List supported webhook event types"))];var C1=T("webhooks").pipe(P("Manage workspace webhooks as a signed-in owner."),Ze(v1));var T1=[T("list",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,FI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["workspaces.list"]),P("List workspaces")),T("create",{name:C("name"),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,NI({client:t.runtime.client,body:{name:e.name,...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.create"]),P("Create a workspace")),T("get",{id:ne("id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,KI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(F(_,["workspaces.get"]),P("Get a workspace")),T("update",{id:ne("id").pipe(ie(a.check(L()))),name:C("name").pipe(E),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");if(!(O(e.name)||O(e.defaultTimezone)))throw new Fe("Provide --name or --default-timezone.");return t.runtime.decode(H,qI({client:t.runtime.client,path:{workspaceId:e.id},body:{...O(e.name)?{name:f(e.name)}:{},...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.update"]),P("Update a workspace you own")),T("archive",{id:ne("id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,BI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(F(_,["workspaces.archive"]),P("Archive a workspace you own")),T("invites").pipe(P(""),Ze([T("list",{workspace:N,status:ke("status",["pending","accepted","revoked","expired"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,KE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.list"]),P("List workspace invitations")),T("create",{workspace:N,email:C("email"),role:ke("role",["owner","member"]).pipe(E),idempotencyKey:ot},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,qE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{email:e.email,...O(e.role)?{role:f(e.role)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.create"]),P("Create a workspace invitation")),T("resend",{workspace:N,inviteId:ne("invite-id").pipe(ie(a.check(L()))),idempotencyKey:ot},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,$E({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.resend"]),P("Resend a pending invitation email")),T("revoke",{workspace:N,inviteId:ne("invite-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,WE({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.revoke"]),P("Revoke a pending workspace invitation"))])),T("members").pipe(P(""),Ze([T("list",{workspace:N,role:ke("role",["owner","member"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,FE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.role)?{role:f(e.role)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.list"]),P("List workspace members")),T("remove",{workspace:N,userId:ne("user-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,NE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.remove"]),P("Remove a workspace member or leave the workspace")),T("update-role",{workspace:N,userId:ne("user-id").pipe(ie(a.check(L()))),role:ke("role",["owner","member"])},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,BE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{role:e.role},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.updateRole"]),P("Update a workspace member's role"))]))];var VZ=T("use",{id:Kq},({id:e})=>R(async()=>(await ho()).useWorkspace(e))).pipe(F(_,["workspaces.get"]),P("Remember the active workspace for this CLI session.")),O1=T("workspaces").pipe(P("Manage PubNio workspaces."),Ze([...T1,VZ]));var P1=T("pnio").pipe(P("Connect accounts and manage PubNio content."),Ze([G$,E1,O1,A1,K$,N$,$$,I1,a1,H$,J$,Z$,M$,l1,x1,S1,d1,C1,e1,j$]));var JZ=Fq(P1,{version:Zu.version}),sl=process.argv.slice(2);try{await RO(JZ(sl.length?sl:["--help"]).pipe(TO(r4),Vi(fp,{present:(e)=>e._tag==="InvalidInvocation"?Be(()=>console.error(e.errors.map((t)=>t.message).join(`
271
+ `)},q9=(e)=>{let o=e.map($9),i=[],s=" $ ";for(let c of o){let l=s===" $ "||s===" "?"":" ";if(s.length+l.length+c.length>88&&s!==" $ ")i.push(`${s} \\`),s=` ${c}`;else s+=`${l}${c}`}if(s!==" $ ")i.push(s);return i},$9=(e)=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`;var G9=(e)=>He(e,Qu),T=(e,t,r)=>{let n=Pk(t??{});return Hu({name:e,config:n,...Jt(r)?{handle:r}:{}})};var z9=(e)=>{let t=[],r=new Map,n=(s,c)=>{t.push(c);let l=r.get(s);if(l)l.push(c);else r.set(s,[c])};for(let s of e){if(G9(s)){n(void 0,s);continue}for(let c of s.commands)n(s.group,c)}let o=[],i=r.get(void 0);if(i&&i.length>0)o.push({group:void 0,commands:i});for(let[s,c]of r){if(s===void 0)continue;o.push({group:s,commands:c})}return{flat:t,groups:o}},Ze=q(2,(e,t)=>{let r=z9(t);BK(e,r.flat);let n=Dt(e),o=new Map(r.flat.map((l)=>[l.name,Dt(l)])),i=Symbol("effect/cli/SubcommandState"),s=Ie(function*(l){if(ir(l.subcommand))return yield*n.parse(l);let S=o.get(l.subcommand.value.name);if(!S)return yield*n.parse(l);let m=yield*n.parseContext(l),g=yield*S.parse(l.subcommand.value.parsedInput);return{...m,[i]:{name:S.name,result:g}}}),c=Ie(function*(l,S){let g=l[i];if(g){let w=o.get(g.name);if(!w)return yield*new Si({commandPath:S,errors:[]});return yield*w.handle(g.result,[...S,w.name]).pipe(Vi(n.service,l))}return yield*n.handle(l,S)});return Hu({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,unlisted:n.unlisted,annotations:n.annotations,globalFlags:n.globalFlags,resolveExamples:n.resolveExamples,service:n.service,subcommands:r.groups,parse:s,parseContext:n.parseContext,handle:c})});var P=q(2,(e,t)=>Hu({...Dt(e),description:t}));var F=q(3,(e,t,r)=>{let n=Dt(e);return Hu({...n,annotations:wo(n.annotations,t,r)})});var j9=(e,t,r,n)=>{let o=new Set(t),i=[],s=new Set;for(let c of e){if(o.has(c))continue;let l=Kt(c.flag);for(let S of l){let m=r[S.name];if(!m||m.length===0)continue;let g=`--${S.name}`;if(s.has(g))continue;s.add(g),i.push(new va({option:g,suggestions:[],command:n}))}}return i},Q9=(e,t,r)=>kr(function*(){let{builtIns:n}=yield*ny,o=yield*fp,{commandPath:i,errors:s}=t,c=yield*ty(e,i,n);yield*o.present(r&&s.length>0?{_tag:"InvalidInvocation",commandPath:i,helpDoc:c,errors:s}:{_tag:"Help",reason:"Implicit",commandPath:i,helpDoc:c})}),H9=(e,t)=>kr(function*(){let r=yield*lq,n=e instanceof Nu?e:new Nu({cause:e,userMessage:t});yield*qm(r.formatError(n)),Object.assign(e,{[uu]:!1})});var Fq=(e,t)=>{let r=Dt(e);return Ie(function*(n){let{builtIns:o}=yield*ny,{tokens:i,trailingOperands:s}=mq(n),c=cq(e,o),l=c.flatMap((Q)=>Kt(Q.flag)),S=yp(l.filter(zu)),{flagMap:m,remainder:g,errors:w}=vq(i,e,S),k={flags:m,arguments:[]},A=yield*Jk({tokens:g,trailingOperands:s},e),y=[e.name,...Vk(A)],h=(Q)=>Q._tag==="ShowHelp"?Q:new Si({commandPath:y,errors:[Q]}),x=Rr(h),G={builtIns:o,command:e,commandPath:y,version:t.version},X=Gk(e,y,o),I=j9(c,X,m,y);if(I.length>0||w.length>0){let Q=A.errors??[];return yield*new Si({commandPath:y,errors:[...w,...I,...Q]})}for(let Q of X){if(Q._tag!=="Action")continue;if(!Kt(Q.flag).some((se)=>{let le=m[se.name];return le!==void 0&&le.length>0}))continue;let[,ae]=yield*Q.flag.parse(k).pipe(x);if(Q===zk){let{colors:se}=yield*$u;return yield*kr(function*(){yield*gr(Uq(e.name,t.version,e.description,se));let le=new Set(Yk(g,e)),Se=[e.name,...i.filter(($e)=>!le.has($e)&&!($e._tag==="LongOption"&&$e.name==="wizard")).map(hq)],ve=yield*Rq(e,{commandPath:y,prefix:Se});if(yield*gr(Dq(ve.displayArgs,se)),yield*an(pK({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))yield*gr(),yield*Fq(e,{...t,renderErrors:!1})(ve.args.slice(1))}).pipe(yd("QuitError",()=>gr(Lq(se))))}yield*Q.run(ae,G);return}if(A.errors&&A.errors.length>0)return yield*new Si({commandPath:y,errors:A.errors});let me=yield*r.parse(A).pipe(Rr((Q)=>XE(Q)?h(Q):Q)),pe=r.handle(me,[e.name]),K=X.includes(mp)?(yield*mp.flag.parse(k).pipe(x))[1]:ge();pe=Vi(pe,mp,K);for(let Q of X){if(Q._tag!=="Setting"||Q===mp)continue;let[,te]=yield*Q.flag.parse(k).pipe(x);pe=Vi(pe,Q,te)}let ee=$r(K,{onNone:()=>un(),onSome:(Q)=>Bs(nO,Q)});yield*Hi(pe,ee)},Cf((n)=>XE(n)&&n._tag==="ShowHelp"?Zt(n):Nt(n),(n)=>Zn(Q9(e,n,t.renderErrors!==!1),he(n))),Cf((n)=>{if(t.renderErrors===!1||!Pp(n))return Nt(n);let o=LB(n);return o===void 0?Nt(n):Zt({error:n,userMessage:o})},({error:n,userMessage:o})=>Zn(H9(n,o),he(n))),Cf((n)=>wU(n)?Zt(n):Nt(n),(n)=>Sd))};var Zu={name:"@pubnio/cli",version:"0.2.8",type:"module",description:"PubNio command-line interface.",homepage:"https://pubnio.com/docs/cli/",keywords:["pubnio","cli","social","publishing","api","agents","mcp"],publishConfig:{access:"public"},bin:{pnio:"./dist/index.js"},files:["dist","README.md"],engines:{bun:">=1.4.0"},scripts:{build:"bun build --target=bun --minify --outfile dist/index.js ./src/index.ts && bun run copy:skill","copy:skill":"mkdir -p dist/skills/pnio && cp ../docs/skills/pnio/SKILL.md dist/skills/pnio/SKILL.md",pack:"bun script/pack.ts",compile:"bun build --compile --minify --compile-exec-argv=--use-system-ca --outfile dist/pnio ./src/index.ts","compile:all":"bun run compile:darwin-arm64 && bun run compile:darwin-x64 && bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64","compile:darwin-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-arm64 --outfile dist/pnio-darwin-arm64 ./src/index.ts","compile:darwin-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-darwin-x64 --outfile dist/pnio-darwin-x64 ./src/index.ts","compile:linux-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-x64 --outfile dist/pnio-linux-x64 ./src/index.ts","compile:linux-arm64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-linux-arm64 --outfile dist/pnio-linux-arm64 ./src/index.ts","compile:windows-x64":"bun build --compile --minify --compile-exec-argv=--use-system-ca --target=bun-windows-x64 --outfile dist/pnio-windows-x64.exe ./src/index.ts",prepack:"bun run build"},dependencies:{"@effect/platform-bun":"4.1.7","@pubnio/protocol":"workspace:*","@pubnio/sdk":"workspace:*",effect:"4.1.7",jose:"6.2.19","proper-lockfile":"4.1.2"},devDependencies:{"@types/proper-lockfile":"4.1.4"}};function Nq(e){let t,r=Aa({...e,onRuntime:(n)=>{t=n}});if(!t)throw Error("PubNio client runtime was not captured.");return{client:r,runtime:t}}class _ extends Ht()("@pubnio/cli/CliOperations"){}function Bq(e={}){let t=process.env,r=e.json===!0||t.PUBNIO_NON_INTERACTIVE==="1"||t.CI==="1"||t.CI==="true"||Boolean(t.OPENCODE_AGENT)||Boolean(t.CLAUDECODE)||!process.stdout.isTTY;return{interactive:!r,browser:!r}}var N=C("workspace").pipe(fe(de),E,Oe("Workspace ID. Defaults to PUBNIO_WORKSPACE_ID or your only workspace.")),Kq=ne("id").pipe(ie(de)),Ebe=C("name").pipe(fe(FU.fields.name)),kbe=C("default-timezone").pipe(E,Oe("Default IANA time zone for new queues, e.g. America/New_York.")),Xu=ht("browser").pipe(tt(Bq().browser),Oe("Open the browser automatically. Defaults to on only for an interactive terminal; pass --browser or --no-browser to override.")),eA=C("account").pipe(fe(J),E,Oe("Publishing account ID.")),qq=C("account").pipe(fe(J),Ir(0),Oe("Publish to this exact publishing account ID, or save it as a draft target. Repeat for several accounts.")),$q=C("account").pipe(fe(bu.fields.accountId),E,Oe("Publish to this existing post target account.")),ot=C("idempotency-key").pipe(fe(Vr),E,Oe("Reuse a key to replay this request safely. Generated when omitted.")),xs={cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)};class Fe extends Error{}function Et(e){return(e==="-"?Bun.stdin:Bun.file(e)).json().catch(()=>{throw new Fe("Could not read JSON input.")})}function R(e){return zs({try:e,catch:(t)=>t}).pipe(ji((t)=>Be(()=>console.log(JSON.stringify(t,null,2)))))}function ay(e){let t=process.platform==="darwin"?"open":process.platform==="linux"?"xdg-open":void 0;if(!t||!Bun.which(t))return;Bun.spawn([t,e],{stdin:"ignore",stdout:"ignore",stderr:"ignore"}).unref()}var Wq=p({clientId:a});var Gq="/api/auth/cli";var zq=new TextDecoder,jq=new TextDecoder("utf-8",{fatal:!0});function Qq(e,t=!1){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e,{alphabet:t?"base64url":"base64"});if(t){if(e.includes("+")||e.includes("/"))throw TypeError("Invalid base64url");e=e.replace(/-/g,"+").replace(/_/g,"/")}let r=atob(e),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n}class Hq extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class Ei extends Hq{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}var J9="The input to be decoded is not correctly encoded.";function Vq(e){try{return Qq(typeof e=="string"?e:zq.decode(e),!0)}catch(t){throw TypeError(J9,{cause:t})}}function Jq(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||Object.getPrototypeOf(t)===null}function tA(e){if(typeof e!="string")throw new Ei("JWTs must use Compact JWS serialization, JWT must be a string");let{1:t,length:r}=e.split(".");if(r===5)throw new Ei("Only JWTs using Compact JWS serialization can be decoded");if(r!==3)throw new Ei("Invalid JWT");if(!t)throw new Ei("JWTs must contain a payload");let n;try{n=Vq(t)}catch(i){throw new Ei("Failed to base64url decode the payload",{cause:i})}let o;try{o=JSON.parse(jq.decode(n))}catch(i){throw new Ei("Failed to parse the decoded payload as JSON",{cause:i})}if(!Jq(o))throw new Ei("Invalid JWT Claims Set");return o}var v$=H1(E$(),1);import{mkdir as L5,rename as k$,rm as Ba,writeFile as A$}from"fs/promises";import{homedir as M5}from"os";import{join as xA}from"path";var F5="https://api.workos.com/user_management",N5=(e)=>{let t=xA(process.env.XDG_CONFIG_HOME||xA(M5(),".config"),"pubnio"),r=new Bun.CryptoHasher("sha256").update(e).digest("hex");return{dir:t,file:xA(t,`${r}.json`)}},SA=p({access_token:a,refresh_token:a}),B5=p({clientId:a,...SA.fields,workspaceId:u(de)}),C$=p({device_code:a,user_code:a,verification_uri:a,verification_uri_complete:a,expires_in:yr.check(Do(0)),interval:yr.check(Do(0))});class by extends Error{code;status;constructor(e,t){super(`WorkOS request failed (HTTP ${t}).`);this.code=e;this.status=t}}var K5="Sign in with `pnio auth login`.";async function bA(e,t,r,n){let o=await e(`${F5}/${t}`,{method:"POST",body:new URLSearchParams(r),redirect:"error",signal:AbortSignal.timeout(1e4)}),i=await o.json().catch(()=>null);if(o.ok)return io(n)(i);let s=i&&typeof i==="object"&&"error"in i&&typeof i.error==="string"?i.error:"unknown";throw new by(s,o.status)}var q5=p({clientId:a,device:C$,expiresAt:yr}),T$=(e)=>`${e}.device.json`;async function $5(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await A$(r,JSON.stringify(t),{mode:384,flag:"wx"}),await k$(r,e)}finally{await Ba(r,{force:!0})}}async function W5(e,t=fetch){let r=await bA(t,"authorize/device",{client_id:e},C$),n=new URL(r.verification_uri),o=new URL(r.verification_uri_complete);if(n.protocol!=="https:"||o.origin!==n.origin)throw Error("WorkOS returned an invalid sign-in URL.");return{device:r,url:n.href,completeUrl:o.href}}async function O$(e){let t=await kA(e,"GET"),{clientId:r}=await io(Wq)(await t.json()),{device:n,url:o,completeUrl:i}=await W5(r),s=Date.now()+n.expires_in*1000;return await il(e,async(c)=>{await $5(T$(c),{clientId:r,device:n,expiresAt:s})}),{url:o,completeUrl:i,userCode:n.user_code,expiresAt:new Date(s).toISOString()}}async function G5(e,t,r,n=fetch){let o=Math.min(Date.now()+t.expires_in*1000,Date.now()+r),i=t.interval*1000;while(Date.now()+i<o){await Bun.sleep(i);try{let s=await bA(n,"authenticate",{client_id:e,grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:t.device_code},SA);return{clientId:e,...s}}catch(s){if(s instanceof by){if(s.code==="authorization_pending")continue;if(s.code==="slow_down"||s.status===429||s.status>=500){i+=5000;continue}if(s.code==="expired_token")break;if(s.code==="access_denied")throw Error("Sign-in was declined.",{cause:s})}if(s instanceof Error&&s.name==="TimeoutError"){i*=2;continue}throw s}}throw Error("Sign-in is still pending. Run `pnio auth complete` to keep waiting, or `pnio auth login` to start over.")}async function IA(e,{timeoutMs:t=600000}={}){return il(e,async(r)=>{let n=T$(r),o=await z5(n);if(!o)throw Error("No sign-in is pending. Run `pnio auth login`.");if(o.expiresAt<=Date.now())throw await Ba(n,{force:!0}),Error("Sign-in expired. Run `pnio auth login` again.");let i=await G5(o.clientId,o.device,Math.min(t,o.expiresAt-Date.now())).catch(async(s)=>{throw await Ba(n,{force:!0}),s});return await kA(e,"POST",i.access_token),await EA(r,i),await Ba(n,{force:!0}),i.access_token})}async function z5(e){let t=Bun.file(e);if(!await t.exists())return;return io(q5)(await t.json())}async function wA(e){let t=Bun.file(e);if(!await t.exists())return;return io(B5)(await t.json())}async function EA(e,t){let r=`${e}.${crypto.randomUUID()}.tmp`;try{await A$(r,JSON.stringify(t),{mode:384,flag:"wx"}),await k$(r,e)}finally{await Ba(r,{force:!0})}}async function il(e,t){let{dir:r,file:n}=N5(e);await L5(r,{recursive:!0,mode:448});let o=await v$.default.lock(n,{realpath:!1,retries:{retries:20,minTimeout:100,maxTimeout:1000}});try{return await t(n)}finally{await o()}}async function kA(e,t,r){let n=await fetch(`${e}${Gq}`,{method:t,headers:r?{Authorization:`Bearer ${r}`}:{},redirect:"error",signal:AbortSignal.timeout(15000)});if(!n.ok)throw Error(`PubNio sign-in request failed (HTTP ${n.status}).`);return n}async function P$(e,t){let{exp:r}=tA(t.access_token);if(r&&r*1000>Date.now()+30000)return t.access_token;try{let n=await bA(fetch,"authenticate",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:t.refresh_token},SA);return await EA(e,{...t,...n}),n.access_token}catch(n){if(!(n instanceof by&&n.code==="invalid_grant"))throw n;await Ba(e,{force:!0});return}}async function R$(e){return il(e,async(t)=>{let r=await wA(t),n=r&&await P$(t,r);if(!n||!r)throw Error(K5);return{token:n,workspaceId:r.workspaceId}})}async function _$(e,t,r){await il(e,async(n)=>{let o=await wA(n);if(o?.access_token!==t)throw Error("The CLI session changed. Run the workspace command again.");await EA(n,{...o,workspaceId:r})})}async function U$(e){return il(e,async(t)=>{let r=await wA(t),n=r&&await P$(t,r);if(n)await kA(e,"DELETE",n);await Ba(t,{force:!0})})}function Ai(){let e=URL.parse(process.env.PUBNIO_BASE_URL??"https://pubnio.com");if(!e||e.username||e.password||e.pathname!=="/"||e.search||e.hash||e.protocol!=="https:"&&!(e.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(e.hostname)))throw new Fe("PUBNIO_BASE_URL must be an HTTPS origin or a local HTTP origin.");return e.origin}async function D$(e,t){let r=t==="default"?process.env.PUBNIO_API_KEY:void 0;if(r!==void 0&&!_b.test(r))throw new Fe("PUBNIO_API_KEY is not a valid PubNio API key.");let n=r===void 0?await R$(e):void 0;return{apiKey:r,session:n}}async function ho(e=Ai(),t="default"){let{apiKey:r,session:n}=await D$(e,t),o=Aa({baseUrl:e,clientName:"cli",clientVersion:Zu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}});return{...o,selectedWorkspaceId:n?.workspaceId,useWorkspace:async(i)=>{let s=await o.workspaces.get(i);if(n)await _$(e,n.token,s.id);return s}}}async function V(e=Ai(),t="default"){let{apiKey:r,session:n}=await D$(e,t);return{...Nq({baseUrl:e,clientName:"cli",clientVersion:Zu.version,...r!==void 0?{apiKey:r}:{accessToken:n?.token}}),selectedWorkspaceId:n?.workspaceId}}async function Z(e,t,r){let n=t??process.env.PUBNIO_WORKSPACE_ID??e.selectedWorkspaceId??r;if(n!==void 0){let i=ns(de)(n);if(i._tag==="None")throw new Fe("Expected a workspace UUID.");return i.value}let{workspaces:o}=await e.workspaces.list();if(o.length!==1)throw new Fe("Select a workspace with `pnio workspaces use <id>` or pass --workspace. Run `pnio workspaces list` to see your workspaces.");return o[0].id}async function Ke(e,{origin:t,auth:r}={}){let n=await ho(t,r);return n.workspace(await Z(n,e))}var L$=[T("list-accounts",{workspace:N,state:ke("state",["available","selected"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Jw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.state)?{state:f(e.state)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listAccounts"]),P("List available and selected ad accounts")),T("connect-account",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,Yw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.connectAccount"]),P("Start an ad account OAuth connection")),T("connect-api-key-account",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),provider:ke("provider",["openai_ads"]),apiKey:C("api-key"),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,Zw({client:t.runtime.client,body:{workspaceId:e.workspaceId,provider:e.provider,apiKey:e.apiKey,...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.connectApiKeyAccount"]),P("Connect an ad account with an API key")),T("disconnect-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,iE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.disconnectAccount"]),P("Stop syncing an ad account")),T("select-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,oE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.selectAccount"]),P("Select a discovered ad account")),T("list-campaigns",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:ke("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,sE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listCampaigns"]),P("List one account's campaigns newest first")),T("list-workspace-campaigns",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),managed:ke("managed",["provider","pubnio"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,eE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.managed)?{managed:f(e.managed)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listWorkspaceCampaigns"]),P("List campaigns across selected ad accounts")),T("get-tree",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,aE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.getTree"]),P("Read a campaign, ad group, ad, and creative tree")),T("list-ads",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,cE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listAds"]),P("List ads with a performance summary")),T("list-ad-groups",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["draft","paused","activating","active","pending_review","rejected","completed","archived","unknown"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,pE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listAdGroups"]),P("List ad groups with a performance summary")),T("get-ad",{workspace:N,adId:ne("ad-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,dE({client:t.runtime.client,path:{adId:e.adId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getAd"]),P("Read one ad with its creative and metrics")),T("list-creatives",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,uE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listCreatives"]),P("List ad creatives")),T("get-creative",{workspace:N,creativeId:ne("creative-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,fE({client:t.runtime.client,path:{creativeId:e.creativeId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getCreative"]),P("Read one ad creative")),T("list-insights",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:ke("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,hE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listInsights"]),P("Read one ad account's daily insights")),T("list-workspace-insights",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),campaignId:C("campaign-id").pipe(fe(a.check(L()))).pipe(E),adGroupId:C("ad-group-id").pipe(fe(a.check(L()))).pipe(E),adId:C("ad-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),level:ke("level",["campaign","ad_group","ad"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,mE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.campaignId)?{campaignId:f(e.campaignId)}:{},...O(e.adGroupId)?{adGroupId:f(e.adGroupId)}:{},...O(e.adId)?{adId:f(e.adId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.level)?{level:f(e.level)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listWorkspaceInsights"]),P("Read daily insights across selected ad accounts")),T("refresh-insights",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,yE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.refreshInsights"]),P("Queue an ad insight refresh")),T("activate-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),confirmation:ke("confirmation",["activate_spend"]),idempotencyKey:ot},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,EE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision,confirmation:e.confirmation},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.activateCampaign"]),P("Activate one paused boost campaign")),T("pause-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,kE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.pauseCampaign"]),P("Pause one campaign")),T("archive-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,AE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.archiveCampaign"]),P("Archive one campaign")),T("duplicate-campaign",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,vE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.duplicateCampaign"]),P("Duplicate a campaign tree as paused")),T("create-ad-group",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),name:C("name"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name}:await Et(r);return t.runtime.decode(H,PE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createAdGroup"]),P("Create a paused ad group under a campaign")),T("create-creative",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))),mediaId:C("media-id").pipe(fe(a.check(L()))),headline:C("headline").pipe(E),body:C("body").pipe(E),callToAction:C("call-to-action").pipe(E),destinationUrl:C("destination-url"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{actorAccountId:e.actorAccountId,mediaId:e.mediaId,...O(e.headline)?{headline:f(e.headline)}:{},...O(e.body)?{body:f(e.body)}:{},...O(e.callToAction)?{callToAction:f(e.callToAction)}:{},destinationUrl:e.destinationUrl}:await Et(r);return t.runtime.decode(H,lE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createCreative"]),P("Create a paused provider creative")),T("set-campaign-budget",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),campaignId:ne("campaign-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,CE({client:t.runtime.client,path:{accountId:e.accountId,campaignId:e.campaignId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setCampaignBudget"]),P("Update a campaign budget")),T("set-ad-group-budget",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,TE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setAdGroupBudget"]),P("Update an ad group budget")),T("set-ad-group-status",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),status:ke("status",["active","paused","archived"]),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,OE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setAdGroupStatus"]),P("Pause, resume, or archive an ad group")),T("set-ad-status",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adId:ne("ad-id").pipe(ie(a.check(L()))),status:ke("status",["active","paused","archived"]),expectedRevision:Le("expected-revision"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,_E({client:t.runtime.client,path:{accountId:e.accountId,adId:e.adId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{status:e.status,expectedRevision:e.expectedRevision},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.setAdStatus"]),P("Pause, resume, or archive an ad")),T("attach-ad",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),adGroupId:ne("ad-group-id").pipe(ie(a.check(L()))),name:C("name"),creativeId:C("creative-id").pipe(fe(a.check(L()))).pipe(E),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name,...O(e.creativeId)?{creativeId:f(e.creativeId)}:{}}:await Et(r);return t.runtime.decode(H,RE({client:t.runtime.client,path:{accountId:e.accountId,adGroupId:e.adGroupId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.attachAd"]),P("Attach a paused ad to an existing ad group")),T("create-boost",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))),postTargetId:C("post-target-id").pipe(fe(a.check(L()))).pipe(E),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))).pipe(E),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await Et(r);return t.runtime.decode(H,wE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createBoost"]),P("Create a paused Facebook Page post boost")),T("validate-boost",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))),postTargetId:C("post-target-id").pipe(fe(a.check(L()))).pipe(E),actorAccountId:C("actor-account-id").pipe(fe(a.check(L()))).pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{postId:e.postId,...O(e.postTargetId)?{postTargetId:f(e.postTargetId)}:{},...O(e.actorAccountId)?{actorAccountId:f(e.actorAccountId)}:{}}:await Et(r);return t.runtime.decode(H,IE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.validateBoost"]),P("Validate a Facebook Page post boost")),T("validate-campaign-plan",{workspace:N,name:C("name"),objective:ke("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await Et(r);return t.runtime.decode(H,Xw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.validateCampaignPlan"]),P("Validate a unified campaign plan")),T("create-campaign-plan",{workspace:N,name:C("name"),objective:ke("objective",["awareness","traffic","engagement","leads","sales","app_promotion","video_views","reach","conversions","unknown"]),idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{name:e.name,objective:e.objective}:await Et(r);return t.runtime.decode(H,tE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["ads.createCampaignPlan"]),P("Create a paused campaign plan")),T("get-campaign-plan",{workspace:N,planId:ne("plan-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,nE({client:t.runtime.client,path:{planId:e.planId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getCampaignPlan"]),P("Read a campaign plan and its target operations")),T("list-campaign-plans",{workspace:N,status:ke("status",["queued","creating","partial","succeeded","failed","unresolved"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,rE({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.listCampaignPlans"]),P("List campaign plans")),T("get-operation",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),operationId:ne("operation-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,bE({client:t.runtime.client,path:{accountId:e.accountId,operationId:e.operationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getOperation"]),P("Read one ad operation")),T("get-spend-policy",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,gE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["ads.getSpendPolicy"]),P("Read an ad account's spend policy")),T("update-spend-policy",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),expectedRevision:Le("expected-revision"),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{expectedRevision:e.expectedRevision}:await Et(r);return t.runtime.decode(H,xE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["ads.updateSpendPolicy"]),P("Replace an ad account's spend policy")),T("set-kill-switch",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),active:ht("active").pipe(tt(!1)),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,SE({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{active:e.active,...O(e.reason)?{reason:f(e.reason)}:{}},...t.runtime.transport()}))})).pipe(F(_,["ads.setKillSwitch"]),P("Set or clear an ad account kill switch"))];var M$=T("ads").pipe(P("Read and manage ad accounts, campaigns, and boosts."),Ze(L$));var F$=[T("accounts").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(Ir(0)),platform:ke("platform",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0)),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Sw({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...e.accountId.length?{accountId:[...e.accountId]}:{},...O(e.platform)?{platform:f(e.platform)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.accounts.list"]),P("List account analytics summaries")),T("get",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,bw({client:t.runtime.client,path:{accountId:e.accountId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.accounts.get"]),P("Read one account's analytics"))])),T("posts").pipe(P(""),Ze([T("get",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.posts.get"]),P("Read target-scoped post analytics totals")),T("series",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),timezone:C("timezone").pipe(E),granularity:ke("granularity",["day","total"]).pipe(E),metrics:C("metrics").pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,xw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.timezone)?{timezone:f(e.timezone)}:{},...O(e.granularity)?{granularity:f(e.granularity)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.posts.series"]),P("Read daily post analytics series"))])),T("capabilities").pipe(P(""),Ze([T("get",{workspace:N},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Iw({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["analytics.capabilities.get"]),P("Read the analytics metric catalog and provider support"))])),T("refreshes").pipe(P(""),Ze([T("create",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),postId:C("post-id").pipe(fe(a.check(L()))).pipe(E),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),metrics:ke("metrics",["impressions","reach","views","likes","comments","shares","saves","clicks","link_clicks","profile_visits","page_views","follows","followers","follower_gained","follower_lost","watch_time_ms","avg_watch_time_ms","completion_rate","engagement","engagement_rate"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,ww({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.postId)?{postId:f(e.postId)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...e.metrics.length?{metrics:[...e.metrics]}:{}},...t.runtime.transport()}))})).pipe(F(_,["analytics.refreshes.create"]),P("Queue a priority analytics refresh")),T("get",{workspace:N,refreshId:ne("refresh-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Ew({client:t.runtime.client,path:{refreshId:e.refreshId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["analytics.refreshes.get"]),P("Read an analytics refresh status"))]))];var N$=T("analytics").pipe(P("Read post, account, and refresh analytics."),Ze(F$));var B$=[T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,$I({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.list"]),P("List workspace API keys")),T("create",{workspace:N,name:C("name"),scopes:ke("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ir(0)),expiresAt:C("expires-at").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,WI({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...e.scopes.length?{scopes:[...e.scopes]}:{},...O(e.expiresAt)?{expiresAt:f(e.expiresAt)}:{}},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.create"]),P("Create a workspace API key")),T("get",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,zI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.get"]),P("Read API key metadata")),T("update",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),scopes:ke("scope",["read","publish","engage","ads_read","ads_manage"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,jI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.name)?{name:f(e.name)}:{},...e.scopes.length?{scopes:[...e.scopes]}:{}},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.update"]),P("Rename an API key or change its access")),T("revoke",{workspace:N,keyId:ne("key-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,GI({client:t.runtime.client,path:{keyId:e.keyId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["apiKeys.revoke"]),P("Revoke a workspace API key"))];var K$=T("api-keys").pipe(P("Manage workspace API keys as a signed-in owner."),Ze(B$));var q$=[T("list",{workspace:N,action:ke("action",["workspace.updated","workspace.archived","workspace.member.role_updated","workspace.member.removed","workspace.invite.created","workspace.invite.resent","workspace.invite.revoked","workspace.invite.accepted","workspace.invite.declined","api_key.created","api_key.updated","api_key.revoked","webhook.endpoint.created","webhook.endpoint.updated","webhook.endpoint.deleted","webhook.delivery.replayed","account.connected","account.reconnected","account.disconnected","account.enabled","account.disabled","account.moved","profile.created","profile.updated","profile.archived","queue.created","queue.updated","queue.paused","queue.resumed","queue.archived","queue.slots.replaced","queue.skip.created","queue.skip.deleted","queue.blackout.created","queue.blackout.deleted","billing.subscription.updated","billing.credit.topped_up","billing.spend_controls.updated"]).pipe(E),targetKind:ke("target-kind",["workspace","workspace_member","workspace_invite","workspace_profile","api_key","webhook_endpoint","webhook_delivery","integration_connection","provider_account","schedule_queue","schedule_queue_skip","schedule_queue_blackout","workspace_billing"]).pipe(E),targetId:C("target-id").pipe(fe(a.check(L()))).pipe(E),actorType:ke("actor-type",["user","api_key"]).pipe(E),actorId:C("actor-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,UE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.action)?{action:f(e.action)}:{},...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},...O(e.targetId)?{targetId:f(e.targetId)}:{},...O(e.actorType)?{actorType:f(e.actorType)}:{},...O(e.actorId)?{actorId:f(e.actorId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["audit.list"]),P("List workspace audit events")),T("get",{workspace:N,eventId:ne("event-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,DE({client:t.runtime.client,path:{eventId:e.eventId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["audit.get"]),P("Read one audit event")),T("actions").pipe(P(""),Ze([T("list",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,YE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["audit.actions.list"]),P("List documented audit actions"))]))];var $$=T("audit").pipe(P("Read the workspace audit history."),Ze(q$));var W$=Le("timeout").pipe(tt(600),Oe("Maximum seconds to wait for sign-in.")),j5=T("login",{browser:Xu,timeout:W$,noWait:ht("no-wait").pipe(tt(!1),Oe("Print the verification URL and code, then exit. Finish with `pnio auth complete`."))},(e)=>R(async()=>{let t=Ai(),r=await O$(t);if(console.error(`Open ${r.url} and confirm code ${r.userCode}.`),e.browser)ay(r.completeUrl);if(e.noWait)return r;let n=await IA(t,{timeoutMs:e.timeout*1000});return Aa({baseUrl:t,accessToken:n}).me.get()})).pipe(P("Sign in with a WorkOS device code, or hand off with --no-wait.")),Q5=T("complete",{timeout:W$},(e)=>R(async()=>{let t=Ai(),r=await IA(t,{timeoutMs:e.timeout*1000});return Aa({baseUrl:t,accessToken:r}).me.get()})).pipe(P("Finish a sign-in started with `pnio auth login --no-wait`.")),H5=T("status",{},()=>R(async()=>(await ho(void 0,"human")).me.get())).pipe(P("Show the current PubNio account.")),V5=T("logout",{},()=>R(async()=>(await U$(Ai()),{signedOut:!0}))).pipe(P("Revoke the CLI session and clear local credentials.")),G$=T("auth").pipe(P("Manage your CLI session."),Ze([j5,Q5,H5,V5]));var z$=[T("status",{workspace:N},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,GE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["billing.get"]),P("Get workspace billing status")),T("usage",{workspace:N,from:C("from").pipe(E),to:C("to").pipe(E),meter:ke("meter",["confirmed_publish","x_passthrough","managed_ad","inbox_reply","automation_run"]).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,zE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.meter)?{meter:f(e.meter)}:{},...O(e.provider)?{provider:f(e.provider)}:{}},...t.runtime.transport()}))})).pipe(F(_,["billing.usage.get"]),P("Get workspace daily usage summary")),T("ledger",{workspace:N,kind:ke("kind",["top_up","auto_top_up","overage_debit","x_passthrough_debit","refund","adjustment"]).pipe(E),from:C("from").pipe(E),to:C("to").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,jE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.kind)?{kind:f(e.kind)}:{},...O(e.from)?{from:f(e.from)}:{},...O(e.to)?{to:f(e.to)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["billing.ledger.list"]),P("List workspace prepaid credit ledger")),T("plans",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,JE({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["billing.plans.list"]),P("List public billing plans")),T("top-up",{workspace:N,idempotencyKey:ot,file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{}:await Et(r);return t.runtime.decode(H,QE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["billing.checkout.create"]),P("Create a hosted checkout session for a plan upgrade or credit top-up")),T("portal",{workspace:N,returnUrl:C("return-url").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,HE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.returnUrl)?{returnUrl:f(e.returnUrl)}:{}},...t.runtime.transport()}))})).pipe(F(_,["billing.portal.create"]),P("Create a hosted billing portal session")),T("spend-cap",{workspace:N,version:Le("version"),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{version:e.version}:await Et(r);return t.runtime.decode(H,VE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["billing.spendControls.update"]),P("Update monthly spend cap"))];var j$=T("billing").pipe(P("Manage workspace billing, usage, and checkout."),Ze(z$));var Q$=[T("catalog",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,lw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["capabilities.catalog"]),P("Read the static provider capability catalog")),T("get",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,dw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["capabilities.get"]),P("Read the publish capability catalog")),T("list",{workspace:N,profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),capability:ke("capability",["publish","read_insights","manage_comments","send_messages","ads_read","ads_write","ads_spend"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,uw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.profileId)?{profileId:f(e.profileId)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.capability)?{capability:f(e.capability)}:{}},...t.runtime.transport()}))})).pipe(F(_,["capabilities.list"]),P("List computed capabilities for connected accounts"))];var H$=T("capabilities").pipe(P("Read publishing capabilities, placements, and limits."),Ze(Q$));var V$=[T("create",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business"]).pipe(E),target:C("target"),targetKind:ke("target-kind",["post","comment"]).pipe(E),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,k6({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},target:e.target,...O(e.targetKind)?{targetKind:f(e.targetKind)}:{},text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["comments.create"]),P("Comment on or reply to a provider post"))];var J$=T("comments").pipe(P("Create comments where a destination supports them."),Ze(V$));var Y$=[T("get",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,fw({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["limits.get"]),P("Read documented API limits"))];var Z$=T("limits").pipe(P("Read workspace publishing limits."),Ze(Y$));var X$=[T("capabilities",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Bw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.capabilities.get"]),P("Read per-account inbox channel capabilities")),T("unread-count",{workspace:N},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Nw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.unread.count"]),P("Count conversations with at least one unread inbound message")),T("conversations").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),status:ke("status",["active","archived"]).pipe(E),folder:ke("folder",["inbox","message_request","spam","other"]).pipe(E),unread:ke("unread",["true","false"]).pipe(E),search:C("search").pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,kw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.status)?{status:f(e.status)}:{},...O(e.folder)?{folder:f(e.folder)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.search)?{search:f(e.search)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.list"]),P("List DM conversations newest first")),T("get",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Aw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.get"]),P("Read one conversation and reply window")),T("update",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),status:ke("status",["active","archived"]).pipe(E),read:ht("read").pipe(tt(!1))},(e)=>R(async()=>{let t=await V();if(!(O(e.status)||e.read))throw new Fe("Provide --status or --read.");return t.runtime.decode(H,vw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...O(e.status)?{status:f(e.status)}:{},...e.read?{read:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.conversations.update"]),P("Mark read or archive a conversation"))])),T("messages").pipe(P(""),Ze([T("list",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),order:ke("order",["oldest","newest"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Cw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.order)?{order:f(e.order)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.messages.list"]),P("Page messages oldest or newest first")),T("send",{workspace:N,conversationId:ne("conversation-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Tw({client:t.runtime.client,path:{conversationId:e.conversationId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.messages.send"]),P("Send a text reply inside the provider window"))])),T("comments").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),postId:C("post-id").pipe(fe(a.check(L()))).pipe(E),providerPostId:C("provider-post-id").pipe(E),unread:ke("unread",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Ow({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.postId)?{postId:f(e.postId)}:{},...O(e.providerPostId)?{providerPostId:f(e.providerPostId)}:{},...O(e.unread)?{unread:f(e.unread)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.list"]),P("List comment threads with counts")),T("get",{workspace:N,threadId:ne("thread-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Pw({client:t.runtime.client,path:{threadId:e.threadId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.get"]),P("Read a comment thread and its comments")),T("reply",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Rw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.reply"]),P("Reply to a comment")),T("moderate",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L()))),hidden:ht("hidden").pipe(tt(!1)),liked:ht("liked").pipe(tt(!1))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Uw({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.hidden?{hidden:!0}:{},...e.liked?{liked:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.moderate"]),P("Hide, unhide, like, or unlike a comment")),T("delete",{workspace:N,commentId:ne("comment-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,_w({client:t.runtime.client,path:{commentId:e.commentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.comments.delete"]),P("Delete a comment where the provider supports it"))])),T("mentions").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),provider:ke("provider",["bluesky","facebook","instagram","linkedin","pinterest","reddit","snapchat","tiktok","threads","x","youtube","google_business","meta_ads","google_ads","reddit_ads","pinterest_ads","tiktok_ads","linkedin_ads","snapchat_ads","amazon_ads","openai_ads"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Dw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.provider)?{provider:f(e.provider)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.mentions.list"]),P("List mentions of a connected account")),T("reply",{workspace:N,mentionId:ne("mention-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Lw({client:t.runtime.client,path:{mentionId:e.mentionId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.mentions.reply"]),P("Reply to a mention where supported"))])),T("sync").pipe(P(""),Ze([T("start",{workspaceId:C("workspace-id").pipe(fe(a.check(L()))),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Kw({client:t.runtime.client,body:{workspaceId:e.workspaceId,...O(e.accountId)?{accountId:f(e.accountId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.sync.start"]),P("Queue a bounded inbox sync")),T("status",{workspace:N,syncRunId:ne("sync-run-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,qw({client:t.runtime.client,path:{syncRunId:e.syncRunId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.sync.get"]),P("Read a sync run and current inbox counts"))])),T("attachments").pipe(P(""),Ze([T("get",{workspace:N,attachmentId:ne("attachment-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,$w({client:t.runtime.client,path:{attachmentId:e.attachmentId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.attachments.get"]),P("Stream an inbound attachment"))])),T("reviews").pipe(P(""),Ze([T("list",{workspace:N,accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),includeDeleted:ke("include-deleted",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Mw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.includeDeleted)?{includeDeleted:f(e.includeDeleted)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.list"]),P("List stored Google Business Profile reviews newest first")),T("get",{workspace:N,reviewId:ne("review-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Fw({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.get"]),P("Read one stored Google Business Profile review")),T("reply",{workspace:N,reviewId:ne("review-id").pipe(ie(a.check(L()))),text:C("text"),idempotencyKey:ot},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,E6({client:t.runtime.client,path:{reviewId:e.reviewId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{text:e.text},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["inbox.reviews.reply"]),P("Reply to a Google Business Profile review"))]))];var e1=T("inbox").pipe(P("Read and reply from the unified inbox."),Ze(X$));var t1=[T("get-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),includeAdAccounts:ke("include-ad-accounts",["true","false"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,nw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeAdAccounts)?{includeAdAccounts:f(e.includeAdAccounts)}:{}},...t.runtime.transport()}))})).pipe(F(_,["integrations.getAccount"]),P("Check account readiness")),T("bluesky-session",{workspace:N,handle:C("handle"),appPassword:C("app-password"),service:C("service").pipe(E),accountId:C("account-id").pipe(fe(a.check(L()))).pipe(E),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,w6({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{handle:e.handle,appPassword:e.appPassword,...O(e.service)?{service:f(e.service)}:{},...O(e.accountId)?{accountId:f(e.accountId)}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["integrations.blueskySession"]),P("Connect Bluesky with an app password")),T("get-instagram-audio",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),audioId:ne("audio-id")},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,ow({client:t.runtime.client,path:{accountId:e.accountId,audioId:e.audioId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["integrations.getInstagramAudio"]),P("Read current Instagram audio metadata and refresh its preview URL")),T("move-account",{workspace:N,accountId:ne("account-id").pipe(ie(a.check(L()))),profileId:C("profile-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,rw({client:t.runtime.client,path:{accountId:e.accountId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{profileId:e.profileId},...t.runtime.transport()}))})).pipe(F(_,["integrations.moveAccount"]),P("Move an account to another profile"))];var bp=ne("account-id").pipe(ie(bu.fields.accountId)),n1=ke("login-method",oh.literals).pipe(E),o1=Le("timeout").pipe(tt(120),Oe("Maximum seconds to wait for consent."));async function i1(e,t,r){let n=Date.now()+Math.max(0,r)*1000;for(;;){let o=await e.accounts.connectionStatus(t);if(o.status!=="pending")return o;if(Date.now()>=n)return{...o,timedOut:!0};await Bun.sleep(1000)}}function s1(e,t,r){if(new URL(e.url).origin!==t)throw Error("PubNio returned an invalid connection URL.");if(console.error(`Open the URL as the same PubNio user, then check \`pnio integrations wait ${e.attemptId}\`.`),r)ay(e.url);return e}var J5=T("list",{workspace:N},({workspace:e})=>R(async()=>(await Ke(f(e))).accounts.list())).pipe(F(_,["integrations.list"]),P("List publishing destinations.")),Y5=T("connect",{provider:U8("provider",bn.literals),workspace:N,browser:Xu,loginMethod:n1,wait:ht("wait").pipe(tt(!1),Oe("Wait for consent before returning.")),timeout:o1},(e)=>R(async()=>{let t=Ai(),r=await Ke(f(e.workspace),{origin:t}),n=await r.accounts.prepareConnection(e.provider,f(e.loginMethod)),o=s1(n,t,e.browser);if(!e.wait)return o;let i=await i1(r,n.attemptId,e.timeout);if(i.status!=="connected")process.exitCode=1;return{...o,connection:i}})).pipe(F(_,["integrations.prepareConnection","integrations.connectionStatus"]),P("Connect Facebook, Instagram, or TikTok.")),Z5=T("wait",{attempt:ne("attempt-id").pipe(ie(qb.fields.attemptId)),workspace:N,timeout:o1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await i1(t,e.attempt,e.timeout);if(r.status!=="connected")process.exitCode=1;return r})).pipe(F(_,["integrations.connectionStatus"]),P("Wait for an account connection to finish.")),X5=T("status",{attempt:ne("attempt-id").pipe(ie(qb.fields.attemptId)),workspace:N},({attempt:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.connectionStatus(e))).pipe(F(_,["integrations.connectionStatus"]),P("Check whether social account OAuth completed.")),eZ=T("health",{account:bp,workspace:N},({account:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.get(e))).pipe(F(_,["integrations.getAccount"]),P("Check account readiness using the last recorded grant.")),tZ=T("instagram-quota",{account:bp,workspace:N},({account:e,workspace:t})=>R(async()=>(await Ke(f(t))).accounts.instagramPublishingLimit(e))).pipe(F(_,["integrations.instagramPublishingLimit"]),P("Read the Instagram account\u2019s current publishing quota.")),rZ=T("instagram-audio",{account:bp,workspace:N,type:ke("type",sh.literals).pipe(tt("music")),query:C("query").pipe(E)},({account:e,workspace:t,type:r,query:n})=>R(async()=>(await Ke(f(t))).accounts.searchInstagramAudio(e,{audioType:r,q:f(n)}))).pipe(F(_,["integrations.searchInstagramAudio"]),P("Search Instagram\u2019s catalog or list trending audio.")),nZ=T("instagram-audio-info",{account:bp,workspace:N,audioId:ne("audio-id").pipe(ie(rp))},({account:e,workspace:t,audioId:r})=>R(async()=>(await Ke(f(t))).accounts.getInstagramAudio(e,r))).pipe(F(_,["integrations.getInstagramAudio"]),P("Read current metadata for an Instagram audio track.")),oZ=T("reconnect",{account:bp,workspace:N,browser:Xu,loginMethod:n1},(e)=>R(async()=>{let t=Ai(),r=await Ke(f(e.workspace),{origin:t});return s1(await r.accounts.reconnect(e.account,f(e.loginMethod)),t,e.browser)})).pipe(F(_,["integrations.reconnect"]),P("Reauthorize a connected account while keeping its ID.")),iZ=T("disconnect",{connection:ne("connection-id").pipe(ie(FD.fields.connectionId)),workspace:N,yes:ht("yes").pipe(tt(!1))},({connection:e,workspace:t,yes:r})=>R(async()=>{if(!r)throw new Fe("Pass --yes to disconnect the grant and disable all accounts using it.");return(await Ke(f(t))).accounts.disconnect(e)})).pipe(F(_,["integrations.disconnect"]),P("Remove a grant and disable its accounts."));function r1(e){return T(e,{account:bp,workspace:N},({account:t,workspace:r})=>R(async()=>(await Ke(f(r))).accounts.setEnabled({id:t,enabled:e==="enable"}))).pipe(F(_,["integrations.setEnabled"]),P(`${e==="enable"?"Enable":"Disable"} a publishing destination.`))}var a1=T("integrations").pipe(P("Connect and select publishing destinations."),Ze([J5,Y5,Z5,X5,eZ,tZ,rZ,nZ,oZ,iZ,r1("enable"),r1("disable"),...t1]));import{writeFile as sZ}from"fs/promises";var c1=[T("status",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Rh({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.status"]),P("Get workspace media intake status")),T("get",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,yw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.get"]),P("Get workspace media metadata")),T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E),type:ke("type",["image","video","document"]).pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,mw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{},...O(e.type)?{type:f(e.type)}:{}},...t.runtime.transport()}))})).pipe(F(_,["media.list"]),P("List ready workspace media")),T("delete",{workspace:N,mediaId:ne("media-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,hw({client:t.runtime.client,path:{mediaId:e.mediaId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["media.delete"]),P("Delete unused workspace media"))];var p1=ne("media-id").pipe(ie(xn)),aZ=T("upload",{file:ne("file"),workspace:N,mime:ke("mime",ep.literals).pipe(E),key:ot},(e)=>R(async()=>{let t=Bun.file(e.file);if(!await t.exists())throw new Fe("Choose an existing media file.");return(await Ke(f(e.workspace))).media.upload(t,{mimeType:f(e.mime),idempotencyKey:f(e.key)})})).pipe(F(_,["media.upload","media.startUpload","media.uploadPart","media.completeUpload"]),P("Upload an image, video, or document for use in posts.")),cZ=T("import",{url:ne("url"),workspace:N,key:ot},(e)=>R(async()=>(await Ke(f(e.workspace))).media.importUrl(e.url,{idempotencyKey:f(e.key)}))).pipe(F(_,["media.import"]),P("Copy a public or signed HTTPS URL into private workspace media.")),pZ=T("wait",{mediaId:p1,workspace:N,timeoutSeconds:Le("timeout").pipe(tt(30),Oe("Maximum seconds to wait for media readiness."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>300)throw new Fe("Use a timeout between 0 and 300 seconds.");let t=await(await Ke(f(e.workspace))).media.wait(e.mediaId,{timeoutMs:e.timeoutSeconds*1000});if(t.status!=="ready")process.exitCode=1;return t})).pipe(F(_,["media.status"]),P("Wait for media readiness and return ready, failed, or timeout.")),dZ=T("download",{mediaId:p1,workspace:N,out:C("out")},(e)=>R(async()=>{let t=await(await Ke(f(e.workspace))).media.download(e.mediaId);return await sZ(e.out,new Uint8Array(await t.arrayBuffer()),{flag:"wx"}),{path:e.out,sizeBytes:t.size}})).pipe(F(_,["media.download"]),P("Save private media to a new local file.")),d1=T("media").pipe(P("Manage workspace media files."),Ze([aZ,cZ,...c1,pZ,dZ]));var u1=[T("get",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,zw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["posts.get"]),P("Read a post or draft")),T("attempts",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Qw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["posts.attempts"]),P("Read a destination's delivery attempt history")),T("retry",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),expectedAttemptId:C("expected-attempt-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Hw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(F(_,["posts.retry"]),P("Retry a failed delivery")),T("reconcile",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),targetId:ne("target-id").pipe(ie(a.check(L()))),expectedAttemptId:C("expected-attempt-id").pipe(fe(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Vw({client:t.runtime.client,path:{postId:e.postId,targetId:e.targetId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{expectedAttemptId:e.expectedAttemptId},...t.runtime.transport()}))})).pipe(F(_,["posts.reconcile"]),P("Recheck a recorded provider receipt")),T("update",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L()))),text:C("text").pipe(E),expectedRevision:Le("revision").pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(),r=f(e.file),n=r===void 0?{...O(e.text)?{text:f(e.text)}:{},...O(e.expectedRevision)?{expectedRevision:f(e.expectedRevision)}:{}}:await Et(r);return t.runtime.decode(H,jw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["posts.update"]),P("Edit a draft")),T("delete",{workspace:N,postId:ne("post-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,Gw({client:t.runtime.client,path:{postId:e.postId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["posts.delete"]),P("Archive a post or draft"))];var uZ=io(mL,{onExcessProperty:"error"}),Iy=ne("post-id").pipe(ie(zU.fields.postId)),lZ=Le("revision").pipe(fe(po),Oe("Expected revision from posts get.")),fZ=T("create",{workspace:N,text:C("text").pipe(E,Oe("Post text for the one-call path.")),platform:ke("platform",cs).pipe(Ir(0),Oe("Publish to the single ready account for this provider. Repeat for several platforms.")),account:qq,mediaId:C("media-id").pipe(fe(xn),Ir(0),Oe("Attach ready workspace media by ID.")),mediaUrl:C("media-url").pipe(Ir(0),Oe("Attach a public HTTPS media URL.")),schedule:C("schedule").pipe(fe(Ut),E,Oe("Schedule with an ISO time and explicit offset.")),publishNow:ht("publish-now").pipe(tt(!0),Oe("Publish now when --schedule is absent.")),draft:ht("draft").pipe(tt(!1),Oe("Save a draft without submitting it.")),file:C("file").pipe(E,Oe("Advanced: read a full Level 2 post JSON document from a file or stdin with -.")),key:ot,queue:C("queue").pipe(fe(tr),E,Oe("Assign every file-provided destination to this account queue."))},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.key),n=f(e.file),o=f(e.schedule);if(e.draft&&o)throw new Fe("Drafts cannot set --schedule until published.");if(n){if(O(e.text)||e.platform.length||e.account.length||e.mediaId.length||e.mediaUrl.length||o&&!e.draft||!e.publishNow&&!e.draft)throw new Fe("Use --file alone, or provide --text with --platform or --account.");let c=await uZ(await Et(n)).catch(()=>{throw new Fe("Post JSON does not match the PubNio API contract.")}),l=f(e.queue);if(l&&e.draft)throw new Fe("Drafts cannot be assigned a queue.");if(l&&(c.targets??[]).some((S)=>S.scheduledAt!==void 0||S.queueId!==void 0))throw new Fe("Remove per-target schedules or queues when using --queue.");return t.posts.create({...l?{...c,targets:(c.targets??[]).map((S)=>({...S,queueId:l}))}:c,...e.draft?{isDraft:!0}:{},...r?{idempotencyKey:r}:{}})}let i=f(e.text);if(i===void 0)throw new Fe("Provide --text or --file.");if(e.draft&&e.platform.length)throw new Fe("Drafts select exact --account IDs, not platforms.");if(!e.draft&&O(e.queue))throw new Fe("--queue requires --file.");if(!e.draft&&e.platform.length&&e.account.length)throw new Fe("Use --platform or --account, not both.");if(!e.draft&&!e.platform.length&&!e.account.length)throw new Fe("Provide at least one --platform or --account.");let s=[...e.mediaId.map((c)=>({mediaId:c})),...e.mediaUrl.map((c)=>({url:c}))];if(e.draft)return t.posts.create({text:i,isDraft:!0,...e.account.length?{targets:e.account.map((c)=>({accountId:c}))}:{},...s.length?{media:s}:{}});return t.posts.create({text:i,...e.platform.length?{platforms:[...e.platform]}:{},...e.account.length?{accounts:[...e.account]}:{},...s.length?{media:s}:{},...o?{scheduledAt:o}:{},publishNow:e.publishNow,...r?{idempotencyKey:r}:{}})})).pipe(F(_,["posts.create"]),P("Create and submit a post in one call, or save a draft with --draft.")),mZ=T("list",{workspace:N,...xs,draft:ht("draft").pipe(tt(!1),Oe("List only drafts. Omit to list posts and drafts.")),deliveryStatus:ke("delivery-status",Yc.literals).pipe(E)},(e)=>R(async()=>(await Ke(f(e.workspace))).posts.list({cursor:f(e.cursor),limit:f(e.limit),...e.draft?{isDraft:!0}:{},deliveryStatus:f(e.deliveryStatus)}))).pipe(F(_,["posts.list"]),P("List posts and drafts, and filter their current deliveries.")),hZ=T("validate",{workspace:N,id:Iy},(e)=>R(async()=>{let t=await(await Ke(f(e.workspace))).posts.validate(e.id);if(!t.canPublish)process.exitCode=1;return t})).pipe(F(_,["posts.validate"]),P("Validate a saved draft before publishing.")),yZ=T("publish",{id:Iy,workspace:N,revision:lZ,key:ot,at:C("at").pipe(fe(Ut),E),queue:C("queue").pipe(fe(tr),E),account:$q,placement:ke("placement",xr.literals).pipe(E)},(e)=>R(async()=>{let t=f(e.placement),r=f(e.account),n=f(e.at),o=f(e.queue),i=f(e.key);if(t&&!r)throw new Fe("Use --placement with --account.");if(n&&o)throw new Fe("Use --at or --queue, not both.");let s=await Ke(f(e.workspace));if(o){let l=(await s.posts.get(e.id)).targets.filter((S)=>!r||S.accountId.toLowerCase()===r.toLowerCase());if(!l.length||t&&l.some((S)=>S.placement!==t))throw new Fe("No matching destination exists in this post for --queue.");return s.posts.publish(e.id,{expectedRevision:e.revision,idempotencyKey:i,targets:l.map((S)=>({accountId:S.accountId,placement:S.placement,queueId:o}))})}return s.posts.publish(e.id,{expectedRevision:e.revision,scheduledAt:n,idempotencyKey:i,...r&&t?{targets:[{accountId:r,placement:t,scheduledAt:n}]}:r?{accountIds:[r]}:{}})})).pipe(F(_,["posts.get","posts.publish"]),P("Publish a saved draft now or at --at.")),gZ=T("status",{workspace:N,id:Iy},(e)=>R(async()=>(await Ke(f(e.workspace))).posts.status(e.id))).pipe(F(_,["posts.get"]),P("Read delivery outcomes for a post.")),xZ=T("wait",{workspace:N,id:Iy,timeoutSeconds:Le("timeout").pipe(tt(60),Oe("Maximum seconds to wait for delivery."))},(e)=>R(async()=>{if(e.timeoutSeconds<0||e.timeoutSeconds>3600)throw new Fe("Use a timeout between 0 and 3600 seconds.");let t=await(await Ke(f(e.workspace))).posts.wait(e.id,{timeoutMs:e.timeoutSeconds*1000});if(!t.settled)process.exitCode=1;return t})).pipe(F(_,["posts.get"]),P("Wait for a post to reach a settled delivery outcome."));function AA(e,t){return R(async()=>(await Ke(f(e.workspace))).schedule.change(DU(e.postId),LU(e.targetId),t))}var vA={postId:ne("post-id").pipe(ie(Eb.fields.postId)),targetId:ne("target-id").pipe(ie(Eb.fields.targetId)),expectedAttemptId:C("attempt").pipe(fe(zt),Oe("Current attempt ID from posts status.")),workspace:N},SZ=T("reschedule",{...vA,at:C("at").pipe(fe(Ut),E),queue:C("queue").pipe(fe(tr),E),slot:C("slot").pipe(fe(a.check(L())),E),date:C("date").pipe(fe(wn),E)},(e)=>{let t=f(e.at),r=f(e.queue),n=f(e.slot),o=f(e.date);if(t===void 0===(r===void 0))throw new Fe("Use exactly one of --at or --queue.");if(r&&n===void 0!==(o===void 0))throw new Fe("Use --slot and --date together to pin a slot.");return AA(e,r?{action:"reschedule",expectedAttemptId:e.expectedAttemptId,queueId:r,...n&&o?{pinned:{slotId:n,occurrenceDate:o}}:{}}:{action:"reschedule",expectedAttemptId:e.expectedAttemptId,scheduledAt:t})}).pipe(F(_,["schedule.change"]),P("Move a pending delivery to a queue slot or time.")),bZ=T("cancel",vA,(e)=>AA(e,{action:"cancel",expectedAttemptId:e.expectedAttemptId})).pipe(F(_,["schedule.change"]),P("Cancel a delivery before the provider write is reserved.")),IZ=T("publish-now",vA,(e)=>AA(e,{action:"publish_now",expectedAttemptId:e.expectedAttemptId})).pipe(F(_,["schedule.change"]),P("Bring a pending delivery forward.")),l1=T("posts").pipe(P("Create and publish posts, save drafts, and manage delivery status."),Ze([fZ,mZ,...u1,hZ,yZ,gZ,xZ,SZ,bZ,IZ]));var kn=ne("queue-id").pipe(ie(tr)),wy=Le("version").pipe(Oe("Expected version from the last queue read.")),m1={maxPerDay:Le("max-per-day").pipe(E),maxPending:Le("max-pending").pipe(E),minGap:Le("min-gap").pipe(E),horizon:Le("horizon-days").pipe(E)},h1={slot:C("slot").pipe(f9(50),Oe("Weekly slot as DAY:HH:mm where 0 is Sunday."))},wZ=io(EL,{onExcessProperty:"error"}),EZ=io(kL,{onExcessProperty:"error"}),kZ=io(AL,{onExcessProperty:"error"}),AZ=io(RL,{onExcessProperty:"error"}),vZ=io(DL,{onExcessProperty:"error"});function y1(e){let t=/^([0-6]):((?:[01]\d|2[0-3]):[0-5]\d)$/.exec(e);if(!t)throw new Fe("Use --slot DAY:HH:mm where DAY is 0-6, 0 Sunday.");return{dayOfWeek:Number(t[1]),time:t[2]}}function g1(e){let t=f(e.maxPerDay),r=f(e.maxPending),n=f(e.minGap),o=f(e.horizon);return{...t===void 0?{}:{maxPerDay:t},...r===void 0?{}:{maxPending:r},...n===void 0?{}:{minGapSeconds:n},...o===void 0?{}:{horizonDays:o}}}var CZ=T("list",{workspace:N,account:eA,...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.list({accountId:f(e.account),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.list"]),P("List account schedule queues.")),TZ=T("create",{workspace:N,file:C("file").pipe(E,Oe("Read CreateQueue JSON from a file or stdin with -.")),account:eA,name:C("name").pipe(E),timezone:C("timezone").pipe(E,Oe("IANA time zone, e.g. America/New_York. Defaults to the workspace default time zone.")),default:ht("default").pipe(E,Oe("Promote the new queue to the account default. The first active queue is always the default.")),...h1,...m1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.file),n=await wZ(r?await Et(r):{accountId:f(e.account),name:f(e.name),...ir(e.timezone)?{}:{timezone:e.timezone.value},slots:e.slot.map(y1),...ir(e.default)?{}:{isDefault:e.default.value},...g1(e)}).catch(()=>{throw new Fe("Queue JSON does not match the PubNio API contract.")});return t.queues.create(n)})).pipe(F(_,["queues.create"]),P("Create a weekly queue for an account; the first is the default. Omit --timezone to use the workspace default.")),OZ=T("get",{workspace:N,queueId:kn},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.get(e.queueId))).pipe(F(_,["queues.get"]),P("Read a queue, its slots, and its limits.")),PZ=T("update",{workspace:N,queueId:kn,version:wy,file:C("file").pipe(E,Oe("Read UpdateQueue JSON from a file or stdin with -.")),name:C("name").pipe(E),timezone:C("timezone").pipe(E),pause:ht("pause").pipe(tt(!1)),resume:ht("resume").pipe(tt(!1)),default:ht("default").pipe(E,Oe("Promote or demote the account default. Demote only after promoting another queue.")),...m1},(e)=>R(async()=>{if(e.pause&&e.resume)throw new Fe("Use --pause or --resume, not both.");let t=await Ke(f(e.workspace)),r=f(e.file),n=await EZ(r?await Et(r):{expectedVersion:e.version,...ir(e.name)?{}:{name:e.name.value},...ir(e.timezone)?{}:{timezone:e.timezone.value},...e.pause?{paused:!0}:e.resume?{paused:!1}:{},...ir(e.default)?{}:{isDefault:e.default.value},...g1(e)}).catch(()=>{throw new Fe("Queue update JSON does not match the PubNio API contract.")});return t.queues.update(e.queueId,n)})).pipe(F(_,["queues.update"]),P("Update limits, name, time zone, default, pause, or resume a queue.")),RZ=T("archive",{workspace:N,queueId:kn,version:wy},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.archive(e.queueId,e.version))).pipe(F(_,["queues.archive"]),P("Archive a queue and keep queued work.")),_Z=T("slots",{workspace:N,queueId:kn,version:wy,file:C("file").pipe(E,Oe("Read ReplaceQueueSlots JSON from a file or stdin.")),...h1},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=f(e.file),n=await kZ(r?await Et(r):{expectedVersion:e.version,slots:e.slot.map(y1)}).catch(()=>{throw new Fe("Queue slot JSON does not match the PubNio API contract.")});return t.queues.replaceSlots(e.queueId,n)})).pipe(F(_,["queues.slots.replace"]),P("Replace every weekly queue slot.")),UZ=T("next-slot",{workspace:N,queueId:kn,after:C("after").pipe(E)},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.nextSlot(e.queueId,f(e.after)))).pipe(F(_,["queues.slots.next"]),P("Read the next free queue occurrence.")),DZ=T("preview",{workspace:N,queueId:kn,count:Le("count").pipe(tt(10)),after:C("after").pipe(E),includeOccupied:ht("include-occupied").pipe(tt(!1))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.previewSlots(e.queueId,{count:e.count,after:f(e.after),includeOccupied:e.includeOccupied}))).pipe(F(_,["queues.slots.preview"]),P("Preview upcoming queue occurrences.")),LZ=T("skips",{workspace:N,queueId:kn,...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.skips(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.skips.list"]),P("List skipped queue occurrences.")),MZ=T("skip",{workspace:N,queueId:kn,slotId:C("slot-id").pipe(fe(wu)),occurrenceDate:C("occurrence-date")},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await AZ({slotId:e.slotId,occurrenceDate:e.occurrenceDate}).catch(()=>{throw new Fe("Use --slot-id with a queue slot UUID and --occurrence-date YYYY-MM-DD.")});return t.queues.skip(e.queueId,r.slotId,r.occurrenceDate)})).pipe(F(_,["queues.skips.create"]),P("Skip one queue occurrence.")),FZ=T("unskip",{workspace:N,queueId:kn,skipId:C("skip-id").pipe(fe(wu))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.unskip(e.queueId,e.skipId))).pipe(F(_,["queues.skips.delete"]),P("Restore a skipped queue occurrence.")),NZ=T("blackouts",{workspace:N,queueId:kn,...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.blackouts(e.queueId,{cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["queues.blackouts.list"]),P("List queue blackout date ranges.")),BZ=T("blackout",{workspace:N,queueId:kn,startsOn:C("starts-on"),endsOn:C("ends-on"),reason:C("reason").pipe(E)},(e)=>R(async()=>{let t=await Ke(f(e.workspace)),r=await vZ({startsOn:e.startsOn,endsOn:e.endsOn,reason:f(e.reason)}).catch(()=>{throw new Fe("Use --starts-on and --ends-on as YYYY-MM-DD; --reason is at most 200 characters.")});return t.queues.blackout(e.queueId,r)})).pipe(F(_,["queues.blackouts.create"]),P("Black out a queue date range.")),KZ=T("unblackout",{workspace:N,queueId:kn,blackoutId:C("blackout-id").pipe(fe(dh))},(e)=>R(async()=>(await Ke(f(e.workspace))).queues.unblackout(e.queueId,e.blackoutId))).pipe(F(_,["queues.blackouts.delete"]),P("Remove a queue blackout.")),f1=(e)=>T(e?"pause":"resume",{workspace:N,queueId:kn,version:wy},(t)=>R(async()=>(await Ke(f(t.workspace))).queues.update(t.queueId,{expectedVersion:t.version,paused:e}))).pipe(F(_,["queues.update"]),P(e?"Pause new assignments while queued attempts still publish.":"Resume new assignments.")),x1=T("queues").pipe(P("Manage weekly account publishing queues."),Ze([CZ,TZ,OZ,PZ,RZ,_Z,UZ,DZ,LZ,MZ,FZ,NZ,BZ,KZ,f1(!0),f1(!1)]));var qZ=T("list",{workspace:N,from:C("from").pipe(Oe("Inclusive ISO start instant, for example 2026-12-01T00:00:00Z.")),to:C("to").pipe(Oe("Inclusive ISO end instant, at most 90 days after --from.")),accountId:C("account-id").pipe(fe(J),E,Oe("Filter by the target publishing account.")),queueId:C("queue-id").pipe(fe(tr),E,Oe("Filter by the open queue assignment.")),...xs},(e)=>R(async()=>(await Ke(f(e.workspace))).schedule.list({from:e.from,to:e.to,accountId:f(e.accountId),queueId:f(e.queueId),cursor:f(e.cursor),limit:f(e.limit)}))).pipe(F(_,["schedule.list"]),P("List queued attempts in a time range.")),$Z=T("skip-to-next",{workspace:N,postId:C("post-id").pipe(fe(_t)),targetId:C("target-id").pipe(fe(cr)),queueId:C("queue-id").pipe(fe(tr),E,Oe("Override the target delivery's current queue.")),expectedAttemptId:C("expected-attempt-id").pipe(fe(zt),E,Oe("Override the target delivery's current attempt."))},(e)=>R(async()=>(await Ke(f(e.workspace))).schedule.skipToNext(e.postId,e.targetId,{queueId:f(e.queueId),expectedAttemptId:f(e.expectedAttemptId)}))).pipe(F(_,["posts.get","queues.slots.next","schedule.change"]),P("Move a queue-assigned target to the next free occurrence.")),S1=T("schedule").pipe(P("Read the publishing calendar and skip ahead."),Ze([qZ,$Z]));var b1=[T("preferences").pipe(P(""),Ze([T("get",{workspace:N},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,LE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["notifications.preferences.get"]),P("Read email notification preferences")),T("update",{workspace:N,deliveryFailures:ht("delivery-failures").pipe(tt(!1)),connectionExpiring:ht("connection-expiring").pipe(tt(!1)),webhookFailures:ht("webhook-failures").pipe(tt(!1)),billingAlerts:ht("billing-alerts").pipe(tt(!1)),weeklyDigest:ht("weekly-digest").pipe(tt(!1))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,ME({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{...e.deliveryFailures?{deliveryFailures:!0}:{},...e.connectionExpiring?{connectionExpiring:!0}:{},...e.webhookFailures?{webhookFailures:!0}:{},...e.billingAlerts?{billingAlerts:!0}:{},...e.weeklyDigest?{weeklyDigest:!0}:{}},...t.runtime.transport()}))})).pipe(F(_,["notifications.preferences.update"]),P("Update email notification preferences"))]))];var I1=T("notifications").pipe(P("Read and update notification preferences."),Ze(b1));var w1=[T("get",{},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,MI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["profile.get"]),P("Get your profile"))];var WZ=T("update",{name:C("name").pipe(E),clear:ht("clear-name").pipe(tt(!1))},({name:e,clear:t})=>R(async()=>{if(e._tag==="Some"===t)throw new Fe("Provide exactly one of --name or --clear-name.");let r=ns(BU)({displayName:e._tag==="Some"?e.value:null});if(r._tag==="None")throw new Fe("Display name must be between 1 and 100 characters.");return(await ho()).me.update(r.value)})).pipe(F(_,["profile.update"]),P("Change or clear your display name.")),GZ=T("deactivate",{yes:ht("yes").pipe(tt(!1))},({yes:e})=>R(async()=>{if(!e)throw new Fe("Pass --yes to deactivate the current profile.");return(await ho()).me.deactivate()})).pipe(F(_,["profile.deactivate"]),P("Deactivate your profile after archiving owned workspaces.")),zZ=T("list",{},()=>R(async()=>(await ho(void 0,"human")).me.invites())).pipe(F(_,["me.invites.list"])),jZ=T("accept",{inviteId:ne("invite-id").pipe(ie(fi))},({inviteId:e})=>R(async()=>(await ho(void 0,"human")).me.acceptInvite({inviteId:e}))).pipe(F(_,["me.invites.accept"])),QZ=T("decline",{inviteId:ne("invite-id").pipe(ie(fi))},({inviteId:e})=>R(async()=>(await ho(void 0,"human")).me.declineInvite(e))).pipe(F(_,["me.invites.decline"])),HZ=T("invites").pipe(P("Manage your workspace invitations."),Ze([zZ,jZ,QZ])),E1=T("profile").pipe(P("Manage your PubNio profile."),Ze([...w1,WZ,GZ,HZ]));var k1=[T("list",{workspace:N,includeArchived:ke("include-archived",["true","false"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,iw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId),...O(e.includeArchived)?{includeArchived:f(e.includeArchived)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["profiles.list"]),P("List workspace profiles")),T("create",{workspace:N,name:C("name"),externalId:C("external-id").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,sw({client:t.runtime.client,query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,...O(e.externalId)?{externalId:f(e.externalId)}:{}},...t.runtime.transport()}))})).pipe(F(_,["profiles.create"]),P("Create a workspace profile")),T("get",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,cw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["profiles.get"]),P("Read a workspace profile")),T("update",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{}}:await Et(r);return t.runtime.decode(H,pw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["profiles.update"]),P("Rename a profile or change its external ID")),T("archive",{workspace:N,profileId:ne("profile-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,aw({client:t.runtime.client,path:{profileId:e.profileId},query:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["profiles.archive"]),P("Archive a workspace profile"))];var A1=T("profiles").pipe(P("Manage posting profiles."),Ze(k1));var v1=[T("list",{workspace:N,cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,QI({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["webhooks.list"]),P("List webhook endpoints")),T("create",{workspace:N,name:C("name"),url:C("url"),eventTypes:ke("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Ir(0)),enabled:ht("paused").pipe(tt(!1)),profileId:C("profile-id").pipe(fe(a.check(L()))).pipe(E),accountIds:C("account-ids").pipe(Ir(0)),disabledResourceGroups:ke("disabled-resource-groups",["publishing","inbox","analytics","ads","scheduling","accounts","billing"]).pipe(Ir(0))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,HI({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{name:e.name,url:e.url,eventTypes:[...e.eventTypes],...e.enabled?{enabled:!1}:{},...O(e.profileId)?{profileId:f(e.profileId)}:{},...e.accountIds.length?{accountIds:[...e.accountIds]}:{},...e.disabledResourceGroups.length?{disabledResourceGroups:[...e.disabledResourceGroups]}:{}},...t.runtime.transport()}))})).pipe(F(_,["webhooks.create"]),P("Register a webhook endpoint")),T("get",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,JI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.get"]),P("Inspect a webhook endpoint")),T("update",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),name:C("name").pipe(E),eventTypes:ke("event",["post.delivery.published","post.delivery.provider_draft","post.delivery.failed","post.delivery.unresolved","post.delivery.cancelled","post.scheduled","post.published","post.partial","post.failed","post.cancelled","inbox.message.received","inbox.comment.received","inbox.review.new","inbox.review.updated","inbox.review.deleted","inbox.review.restored","inbox.review.replied","inbox.mention.received","inbox.message.sent","inbox.message.delivered","inbox.message.read","inbox.message.edited","inbox.message.deleted","inbox.reaction.received","inbox.referral.received","inbox.conversation.started","analytics.post.synced","analytics.account.synced","ads.operation.succeeded","ads.operation.failed","ads.campaign.activated","ads.campaign.paused","ads.budget.changed","ads.kill_switch.activated","ads.lead.received","ads.campaign.status_changed","ads.ad_group.status_changed","ads.ad.status_changed","ads.ad_account.status_changed","ads.ad.review.approved","ads.ad.review.rejected","ads.sync.failed","ads.sync.recovered","ads.initial_sync.completed","schedule.assignment.changed","account.connected","account.disconnected","account.permissions_changed","account.restricted","account.recovered","billing.subscription.updated","billing.credit.topped_up","billing.credit.low","billing.spend_cap.reached","billing.invoice.payment_failed"]).pipe(Ir(0)),enabled:ht("paused").pipe(tt(!1)),file:C("file").pipe(E,Oe("Read the body JSON from a file or stdin with -."))},(e)=>R(async()=>{let t=await V(void 0,"human"),r=f(e.file),n=r===void 0?{...O(e.name)?{name:f(e.name)}:{},...e.eventTypes.length?{eventTypes:[...e.eventTypes]}:{},...e.enabled?{enabled:!1}:{}}:await Et(r);return t.runtime.decode(H,YI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:n,...t.runtime.transport()}))})).pipe(F(_,["webhooks.update"]),P("Edit or pause a webhook endpoint")),T("delete",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,VI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.delete"]),P("Permanently disable a webhook endpoint")),T("test",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,ZI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.test"]),P("Enqueue a webhook test event")),T("list-deliveries",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,XI({client:t.runtime.client,path:{endpointId:e.endpointId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["webhooks.listDeliveries"]),P("List webhook deliveries")),T("get-delivery",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),deliveryId:ne("delivery-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,ew({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.getDelivery"]),P("Inspect a webhook delivery")),T("replay-delivery",{workspace:N,endpointId:ne("endpoint-id").pipe(ie(a.check(L()))),deliveryId:ne("delivery-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,tw({client:t.runtime.client,path:{endpointId:e.endpointId,deliveryId:e.deliveryId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["webhooks.replayDelivery"]),P("Replay a settled webhook delivery")),T("event-types",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,I6({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["webhooks.eventTypes"]),P("List supported webhook event types"))];var C1=T("webhooks").pipe(P("Manage workspace webhooks as a signed-in owner."),Ze(v1));var T1=[T("list",{},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,FI({client:t.runtime.client,...t.runtime.transport()}))})).pipe(F(_,["workspaces.list"]),P("List workspaces")),T("create",{name:C("name"),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,NI({client:t.runtime.client,body:{name:e.name,...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.create"]),P("Create a workspace")),T("get",{id:ne("id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V();return t.runtime.decode(H,KI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(F(_,["workspaces.get"]),P("Get a workspace")),T("update",{id:ne("id").pipe(ie(a.check(L()))),name:C("name").pipe(E),defaultTimezone:C("default-timezone").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");if(!(O(e.name)||O(e.defaultTimezone)))throw new Fe("Provide --name or --default-timezone.");return t.runtime.decode(H,qI({client:t.runtime.client,path:{workspaceId:e.id},body:{...O(e.name)?{name:f(e.name)}:{},...O(e.defaultTimezone)?{defaultTimezone:f(e.defaultTimezone)}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.update"]),P("Update a workspace you own")),T("archive",{id:ne("id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,BI({client:t.runtime.client,path:{workspaceId:e.id},...t.runtime.transport()}))})).pipe(F(_,["workspaces.archive"]),P("Archive a workspace you own")),T("invites").pipe(P(""),Ze([T("list",{workspace:N,status:ke("status",["pending","accepted","revoked","expired"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,KE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.status)?{status:f(e.status)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.list"]),P("List workspace invitations")),T("create",{workspace:N,email:C("email"),role:ke("role",["owner","member"]).pipe(E),idempotencyKey:ot},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,qE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{email:e.email,...O(e.role)?{role:f(e.role)}:{}},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.create"]),P("Create a workspace invitation")),T("resend",{workspace:N,inviteId:ne("invite-id").pipe(ie(a.check(L()))),idempotencyKey:ot},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,$E({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},headers:{"idempotency-key":f(e.idempotencyKey)??crypto.randomUUID()},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.resend"]),P("Resend a pending invitation email")),T("revoke",{workspace:N,inviteId:ne("invite-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,WE({client:t.runtime.client,path:{inviteId:e.inviteId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["workspaces.invites.revoke"]),P("Revoke a pending workspace invitation"))])),T("members").pipe(P(""),Ze([T("list",{workspace:N,role:ke("role",["owner","member"]).pipe(E),cursor:C("cursor").pipe(E),limit:Le("limit").pipe(E)},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,FE({client:t.runtime.client,path:{workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},query:{...O(e.role)?{role:f(e.role)}:{},...O(e.cursor)?{cursor:f(e.cursor)}:{},...O(e.limit)?{limit:String(f(e.limit))}:{}},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.list"]),P("List workspace members")),T("remove",{workspace:N,userId:ne("user-id").pipe(ie(a.check(L())))},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,NE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.remove"]),P("Remove a workspace member or leave the workspace")),T("update-role",{workspace:N,userId:ne("user-id").pipe(ie(a.check(L()))),role:ke("role",["owner","member"])},(e)=>R(async()=>{let t=await V(void 0,"human");return t.runtime.decode(H,BE({client:t.runtime.client,path:{userId:e.userId,workspaceId:await Z(t.client,f(e.workspace),t.selectedWorkspaceId)},body:{role:e.role},...t.runtime.transport()}))})).pipe(F(_,["workspaces.members.updateRole"]),P("Update a workspace member's role"))]))];var VZ=T("use",{id:Kq},({id:e})=>R(async()=>(await ho()).useWorkspace(e))).pipe(F(_,["workspaces.get"]),P("Remember the active workspace for this CLI session.")),O1=T("workspaces").pipe(P("Manage PubNio workspaces."),Ze([...T1,VZ]));var P1=T("pnio").pipe(P("Connect accounts and manage PubNio content."),Ze([G$,E1,O1,A1,K$,N$,$$,I1,a1,H$,J$,Z$,M$,l1,x1,S1,d1,C1,e1,j$]));var JZ=Fq(P1,{version:Zu.version}),sl=process.argv.slice(2);try{await RO(JZ(sl.length?sl:["--help"]).pipe(TO(r4),Vi(fp,{present:(e)=>e._tag==="InvalidInvocation"?Be(()=>console.error(e.errors.map((t)=>t.message).join(`
272
272
  `))):MK.present(e)})))}catch(e){if(e instanceof Si){if(e.errors.length)process.exitCode=2}else if(e instanceof Kn){let t=e.status===401?process.env.PUBNIO_API_KEY!==void 0&&sl[0]!=="api-keys"&&sl[0]!=="webhooks"&&sl[0]!=="auth"?"PubNio rejected the API key. Check PUBNIO_API_KEY.":"PubNio session is unavailable. Run `pnio auth login`.":e.message;console.error(JSON.stringify({kind:e.kind,message:t,status:e.status,type:e.problemType,requestId:e.requestId,issues:e.issues.length?e.issues:void 0,errors:e.requestIssues.length?e.requestIssues:void 0,retryable:e.retryable,idempotencyKey:e.idempotencyKey,currentAttemptId:e.currentAttemptId,currentRevision:e.currentRevision})),process.exitCode=1}else console.error(e instanceof Error?e.message:"PubNio command failed."),process.exitCode=e instanceof Fe?2:1}