@graffiti-garden/wrapper-synchronize 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{b as a,c as u,d as c}from"./chunk-YB7WCAZH.js";a();c();u();a();c();u();a();c();u();a();c();u();var Lt={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},Jr={...Lt,required:["value","channels"]};a();c();u();var W=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},oe=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}};a();c();u();function ae(e){return typeof e=="string"?e:e.url}function Fe(e,t){return!Array.isArray(e.allowed)||typeof t?.actor=="string"&&(e.actor===t.actor||e.allowed.includes(t.actor))}function Ve(e,t,r){if(r===e.actor)return e;let n=e.allowed&&r?[r]:void 0,i=e.channels.filter(o=>t.includes(o));return{...e,...n?{allowed:n}:{},channels:i}}var be;async function Ge(e){if(!be){let{default:t}=await import("./ajv-UZKI6BMI.js");be=new t({strict:!1})}try{return be.compile(e)}catch(t){throw new oe(t instanceof Error?t.message:String(t))}}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var Rt=Object.freeze({status:"aborted"});function I(e,t,r){function n(l,m){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:m,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,m);let d=s.prototype,h=Object.keys(d);for(let _=0;_<h.length;_++){let f=h[_];f in l||(l[f]=d[f].bind(l))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(l){var m;let d=r?.Parent?new o:this;n(d,l),(m=d._zod).deferred??(m.deferred=[]);for(let h of d._zod.deferred)h();return d}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var D=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};var ke={};function N(e){return e&&Object.assign(ke,e),ke}a();c();u();a();c();u();a();c();u();function Be(e,t){return typeof t=="bigint"?t.toString():t}function Ie(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function se(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var Je=Symbol("evaluating");function w(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Je)return n===void 0&&(n=Je,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ct(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ft(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}var Se="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Vt=Ie(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ke(e){if(ce(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ce(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function q(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function U(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function We(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var qe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Xe(e,t){if(!Ke(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=Ft(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Ct(this,"shape",o),o}});return q(e,i)}function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function le(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ue(e){return typeof e=="string"?e:e?.message}function A(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=ue(e.inst?._zod.def?.error?.(e))??ue(t?.error?.(e))??ue(r.customError?.(e))??ue(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function we(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Ye=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Be,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},He=I("$ZodError",Ye),X=I("$ZodError",Ye,{Parent:Error});var Jt=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new D;if(s.issues.length){let l=new(i?.Err??e)(s.issues.map(m=>A(m,o,N())));throw Se(l,i?.callee),l}return s.value},de=Jt(X),Bt=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let l=new(i?.Err??e)(s.issues.map(m=>A(m,o,N())));throw Se(l,i?.callee),l}return s.value},me=Bt(X),Kt=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new D;return o.issues.length?{success:!1,error:new(e??He)(o.issues.map(s=>A(s,i,N())))}:{success:!0,data:o.value}},Y=Kt(X),Wt=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>A(s,i,N())))}:{success:!0,data:o.value}},H=Wt(X);a();c();u();a();c();u();a();c();u();var qt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Xt=new RegExp(`^${qt}$`);var et=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var tt=/^-?\d+$/,rt=/^-?\d+(?:\.\d+)?$/;var M=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Yt={number:"number",bigint:"bigint",object:"date"};var nt=I("$ZodCheckGreaterThan",(e,t)=>{M.init(e,t);let r=Yt[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var it=I("$ZodCheckNumberFormat",(e,t)=>{M.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=qe[t.format];e._zod.onattach.push(s=>{let l=s._zod.bag;l.format=t.format,l.minimum=i,l.maximum=o,r&&(l.pattern=tt)}),e._zod.check=s=>{let l=s.value;if(r){if(!Number.isInteger(l)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?s.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}l<i&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>o&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var ot=I("$ZodCheckStringFormat",(e,t)=>{var r,n;M.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})});a();c();u();a();c();u();var ut={major:4,minor:3,patch:6};var P=I("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ut;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(s,l,m)=>{let d=F(s),h;for(let _ of l){if(_._zod.def.when){if(!_._zod.def.when(s))continue}else if(d)continue;let f=s.issues.length,k=_._zod.check(s);if(k instanceof Promise&&m?.async===!1)throw new D;if(h||k instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await k,s.issues.length!==f&&(d||(d=F(s,f)))});else{if(s.issues.length===f)continue;d||(d=F(s,f))}}return h?h.then(()=>s):s},o=(s,l,m)=>{if(F(s))return s.aborted=!0,s;let d=i(l,n,m);if(d instanceof Promise){if(m.async===!1)throw new D;return d.then(h=>e._zod.parse(h,m))}return e._zod.parse(d,m)};e._zod.run=(s,l)=>{if(l.skipChecks)return e._zod.parse(s,l);if(l.direction==="backward"){let d=e._zod.parse({value:s.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(h=>o(h,s,l)):o(d,s,l)}let m=e._zod.parse(s,l);if(m instanceof Promise){if(l.async===!1)throw new D;return m.then(d=>i(d,n,l))}return i(m,n,l)}}w(e,"~standard",()=>({validate:i=>{try{let o=Y(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return H(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),pe=I("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??et(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),je=I("$ZodStringFormat",(e,t)=>{ot.init(e,t),pe.init(e,t)});var mt=I("$ZodURL",(e,t)=>{je.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}});var Pe=I("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??rt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),ft=I("$ZodNumberFormat",(e,t)=>{it.init(e,t),Pe.init(e,t)});var pt=I("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=r=>r});function ct(e,t,r){e.issues.length&&t.issues.push(...le(r,e.issues)),t.value[r]=e.value}var gt=I("$ZodArray",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let l=i[s],m=t.element._zod.run({value:l,issues:[]},n);m instanceof Promise?o.push(m.then(d=>ct(d,r,s))):ct(m,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function fe(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...le(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Qt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=We(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function er(e,t,r,n,i,o){let s=[],l=i.keySet,m=i.catchall._zod,d=m.def.type,h=m.optout==="optional";for(let _ in t){if(l.has(_))continue;if(d==="never"){s.push(_);continue}let f=m.run({value:t[_],issues:[]},n);f instanceof Promise?e.push(f.then(k=>fe(k,r,_,t,h))):fe(f,r,_,t,h)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var vt=I("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let l=t.shape;Object.defineProperty(t,"shape",{get:()=>{let m={...l};return Object.defineProperty(t,"shape",{value:m}),m}})}let n=Ie(()=>Qt(t));w(e._zod,"propValues",()=>{let l=t.shape,m={};for(let d in l){let h=l[d]._zod;if(h.values){m[d]??(m[d]=new Set);for(let _ of h.values)m[d].add(_)}}return m});let i=ce,o=t.catchall,s;e._zod.parse=(l,m)=>{s??(s=n.value);let d=l.value;if(!i(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};let h=[],_=s.shape;for(let f of s.keys){let k=_[f],z=k._zod.optout==="optional",S=k._zod.run({value:d[f],issues:[]},m);S instanceof Promise?h.push(S.then(j=>fe(j,l,f,d,z))):fe(S,l,f,d,z)}return o?er(h,d,l,m,n.value,e):h.length?Promise.all(h).then(()=>l):l}});function st(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!F(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>A(s,n,N())))}),t)}var ht=I("$ZodUnion",(e,t)=>{P.init(e,t),w(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),w(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),w(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),w(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>se(o.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let s=!1,l=[];for(let m of t.options){let d=m._zod.run({value:i.value,issues:[]},o);if(d instanceof Promise)l.push(d),s=!0;else{if(d.issues.length===0)return d;l.push(d)}}return s?Promise.all(l).then(m=>st(m,i,e,o)):st(l,i,e,o)}});function lt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var $t=I("$ZodOptional",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.optout="optional",w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${se(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>lt(o,r.value)):lt(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var _t=I("$ZodNullable",(e,t)=>{P.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${se(r.source)}|null)$`):void 0}),w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)});var yt=I("$ZodCustom",(e,t)=>{M.init(e,t),P.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>dt(o,r,n,e));dt(i,r,n,e)}});function dt(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(we(i))}}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var bt;var Ue=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function kt(){return new Ue}(bt=globalThis).__zod_globalRegistry??(bt.__zod_globalRegistry=kt());var Oe=globalThis.__zod_globalRegistry;a();c();u();function zt(e,t){return new e({type:"string",...U(t)})}function It(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function St(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function wt(e){return new e({type:"unknown"})}function De(e,t){return new nt({check:"greater_than",...U(t),value:e,inclusive:!0})}function Ze(e){return De(0,e)}function jt(e,t,r){let n=U(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var Z=I("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");P.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>de(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Y(e,r,n),e.parseAsync=async(r,n)=>me(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>H(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>q(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Te=I("ZodMiniString",(e,t)=>{pe.init(e,t),Z.init(e,t)});function Ne(e){return zt(Te,e)}var Pt=I("ZodMiniStringFormat",(e,t)=>{je.init(e,t),Te.init(e,t)});var pr=I("ZodMiniURL",(e,t)=>{mt.init(e,t),Pt.init(e,t)});function T(e){return It(pr,e)}var Ut=I("ZodMiniNumber",(e,t)=>{Pe.init(e,t),Z.init(e,t)});var gr=I("ZodMiniNumberFormat",(e,t)=>{ft.init(e,t),Ut.init(e,t)});function Ot(e){return St(gr,e)}var vr=I("ZodMiniUnknown",(e,t)=>{pt.init(e,t),Z.init(e,t)});function hr(){return wt(vr)}var $r=I("ZodMiniArray",(e,t)=>{gt.init(e,t),Z.init(e,t)});function ee(e,t){return new $r({type:"array",element:e,...U(t)})}var _r=I("ZodMiniObject",(e,t)=>{vt.init(e,t),Z.init(e,t),w(e,"shape",()=>t.shape)});function L(e,t){return new _r({type:"object",shape:e,catchall:hr(),...U(t)})}function Ee(e,t){return Xe(e,t)}var yr=I("ZodMiniUnion",(e,t)=>{ht.init(e,t),Z.init(e,t)});function Dt(e,t){return new yr({type:"union",options:e,...U(t)})}var xr=I("ZodMiniOptional",(e,t)=>{$t.init(e,t),Z.init(e,t)});function V(e){return new xr({type:"optional",innerType:e})}var br=I("ZodMiniNullable",(e,t)=>{_t.init(e,t),Z.init(e,t)});function ve(e){return new br({type:"nullable",innerType:e})}var kr=I("ZodMiniCustom",(e,t)=>{yt.init(e,t),Z.init(e,t)});function zr(e,t){return jt(kr,e??(()=>!0),t)}function Zt(e,t={}){let r=zr(n=>n instanceof e,t);return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}a();c();u();a();c();u();a();c();u();var Pr=L({value:L({}),channels:ee(Ne()),allowed:V(ve(ee(T())))}),Bp=Ee(Pr,{url:T(),actor:T()}),Kp=Dt([L({url:T()}),T()]),Ur=L({actor:T()}),Wp=V(ve(Ur)),Or=L({data:Zt(Blob),allowed:V(ve(ee(T())))}),qp=Ee(Or,{actor:T()}),Xp=L({types:V(ee(Ne())),maxBytes:V(Ot().check(Ze()))});a();c();u();var Me=function(e,t){return Me=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Me(e,t)};function Dr(e,t){Me(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function J(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function l(h){try{d(n.next(h))}catch(_){s(_)}}function m(h){try{d(n.throw(h))}catch(_){s(_)}}function d(h){h.done?o(h.value):i(h.value).then(l,m)}d((n=n.apply(e,t||[])).next())})}function E(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(d){return function(h){return m([d,h])}}function m(d){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=d[0]&2?i.return:d[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,d[1])).done)return o;switch(i=0,o&&(d=[d[0]&2,o.value]),d[0]){case 0:case 1:o=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,i=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!o||d[1]>o[0]&&d[1]<o[3])){r.label=d[1];break}if(d[0]===6&&r.label<o[1]){r.label=o[1],o=d;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(d);break}o[2]&&r.ops.pop(),r.trys.pop();continue}d=t.call(e,r)}catch(h){d=[6,h],i=0}finally{n=o=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function B(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function re(e){return this instanceof re?(this.v=e,this):new re(e)}function Zr(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){n[f]&&(i[f]=function(k){return new Promise(function(z,S){o.push([f,k,z,S])>1||l(f,k)})})}function l(f,k){try{m(n[f](k))}catch(z){_(o[0][3],z)}}function m(f){f.value instanceof re?Promise.resolve(f.value.v).then(d,h):_(o[0][2],f)}function d(f){l("next",f)}function h(f){l("throw",f)}function _(f,k){f(k),o.shift(),o.length&&l(o[0][0],o[0][1])}}var At=(function(e){Dr(t,e);function t(r){var n=e.call(this,r)||this;return Object.defineProperty(n,"name",{value:"RepeaterOverflowError",enumerable:!1}),typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(n,n.constructor.prototype):n.__proto__=n.constructor.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(n,n.constructor),n}return t})(Error),lg=(function(){function e(t){if(t<0)throw new RangeError("Capacity may not be less than 0");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),e.prototype.add=function(t){if(this.full)throw new Error("Buffer full");this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})(),dg=(function(){function e(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(t){for(;this._q.length>=this._c;)this._q.shift();this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})(),mg=(function(){function e(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(t){this._q.length<this._c&&this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})();function Le(e){e!=null&&typeof e.then=="function"&&e.then(ye,ye)}var Ae=0,Nt=1,C=2,$e=3,Re=4,_e=1024,ye=function(){};function G(e){var t=e.err,r=Promise.resolve(e.execution).then(function(n){if(t!=null)throw t;return n});return e.err=void 0,e.execution=r.then(function(){},function(){}),e.pending===void 0?r:e.pending.then(function(){return r})}function R(e,t){var r=e.state>=$e;return Promise.resolve(t).then(function(n){return!r&&e.state>=Re?G(e).then(function(i){return{value:i,done:!0}}):{value:n,done:r}})}function Ce(e,t){var r,n;if(!(e.state>=C))if(e.state=C,e.onnext(),e.onstop(),e.err==null&&(e.err=t),e.pushes.length===0&&(typeof e.buffer>"u"||e.buffer.empty))te(e);else try{for(var i=B(e.pushes),o=i.next();!o.done;o=i.next()){var s=o.value;s.resolve()}}catch(l){r={error:l}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}function te(e){var t,r;if(!(e.state>=$e)){e.state<C&&Ce(e),e.state=$e,e.buffer=void 0;try{for(var n=B(e.nexts),i=n.next();!i.done;i=n.next()){var o=i.value,s=e.pending===void 0?G(e):e.pending.then(function(){return G(e)});o.resolve(R(e,s))}}catch(l){t={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e.pushes=[],e.nexts=[]}}function Et(e){e.state>=Re||(e.state<$e&&te(e),e.state=Re)}function Tr(e,t){if(Le(t),e.pushes.length>=_e)throw new At("No more than "+_e+" pending calls to push are allowed on a single repeater.");if(e.state>=C)return Promise.resolve(void 0);var r=e.pending===void 0?Promise.resolve(t):e.pending.then(function(){return t});r=r.catch(function(m){e.state<C&&(e.err=m),Et(e)});var n;if(e.nexts.length){var i=e.nexts.shift();i.resolve(R(e,r)),e.nexts.length?n=Promise.resolve(e.nexts[0].value):typeof e.buffer<"u"&&!e.buffer.full?n=Promise.resolve(void 0):n=new Promise(function(m){return e.onnext=m})}else typeof e.buffer<"u"&&!e.buffer.full?(e.buffer.add(r),n=Promise.resolve(void 0)):n=new Promise(function(m){return e.pushes.push({resolve:m,value:r})});var o=!0,s={},l=n.catch(function(m){if(o)throw m});return s.then=function(m,d){return o=!1,Promise.prototype.then.call(n,m,d)},s.catch=function(m){return o=!1,Promise.prototype.catch.call(n,m)},s.finally=n.finally.bind(n),e.pending=r.then(function(){return l}).catch(function(m){e.err=m,Et(e)}),s}function Nr(e){var t=Ce.bind(null,e),r=new Promise(function(n){return e.onstop=n});return t.then=r.then.bind(r),t.catch=r.catch.bind(r),t.finally=r.finally.bind(r),t}function Er(e){if(!(e.state>=Nt)){e.state=Nt;var t=Tr.bind(null,e),r=Nr(e);e.execution=new Promise(function(n){return n(e.executor(t,r))}),e.execution.catch(function(){return Ce(e)})}}var he=new WeakMap,K=(function(){function e(t,r){he.set(this,{executor:t,buffer:r,err:void 0,state:Ae,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:ye,onstop:ye})}return e.prototype.next=function(t){Le(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");if(r.nexts.length>=_e)throw new At("No more than "+_e+" pending calls to next are allowed on a single repeater.");if(r.state<=Ae&&Er(r),r.onnext(t),typeof r.buffer<"u"&&!r.buffer.empty){var n=R(r,r.buffer.remove());if(r.pushes.length){var i=r.pushes.shift();r.buffer.add(i.value),r.onnext=i.resolve}return n}else if(r.pushes.length){var o=r.pushes.shift();return r.onnext=o.resolve,R(r,o.value)}else if(r.state>=C)return te(r),R(r,G(r));return new Promise(function(s){return r.nexts.push({resolve:s,value:t})})},e.prototype.return=function(t){Le(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");return te(r),r.execution=Promise.resolve(r.execution).then(function(){return t}),R(r,G(r))},e.prototype.throw=function(t){var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");return r.state<=Ae||r.state>=C||typeof r.buffer<"u"&&!r.buffer.empty?(te(r),r.err==null&&(r.err=t),R(r,G(r))):this.next(Promise.reject(t))},e.prototype[Symbol.asyncIterator]=function(){return this},e.race=Ar,e.merge=Mr,e.zip=Lr,e.latest=Rr,e})();function xe(e,t){var r,n,i=[],o=function(d){d!=null&&typeof d[Symbol.asyncIterator]=="function"?i.push(d[Symbol.asyncIterator]()):d!=null&&typeof d[Symbol.iterator]=="function"?i.push(d[Symbol.iterator]()):i.push((function(){return Zr(this,arguments,function(){return E(this,function(f){switch(f.label){case 0:return t.yieldValues?[4,re(d)]:[3,3];case 1:return[4,f.sent()];case 2:f.sent(),f.label=3;case 3:return t.returnValues?[4,re(d)]:[3,5];case 4:return[2,f.sent()];case 5:return[2]}})})})())};try{for(var s=B(e),l=s.next();!l.done;l=s.next()){var m=l.value;o(m)}}catch(d){r={error:d}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}function Ar(e){var t=this,r=xe(e,{returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m,d,h;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2];s=!1,i.then(function(){o(),s=!0}),_.label=1;case 1:_.trys.push([1,,5,7]),m=void 0,d=0,h=function(){var f,k,z,S,j,ne;return E(this,function(ie){switch(ie.label){case 0:f=d;try{for(k=(j=void 0,B(r)),z=k.next();!z.done;z=k.next())S=z.value,Promise.resolve(S.next()).then(function(O){O.done?(i(),l===void 0&&(l=O)):d===f&&(d++,o(O))},function(O){return i(O)})}catch(O){j={error:O}}finally{try{z&&!z.done&&(ne=k.return)&&ne.call(k)}finally{if(j)throw j.error}}return[4,new Promise(function(O){return o=O})];case 1:return m=ie.sent(),m===void 0?[3,3]:[4,n(m.value)];case 2:ie.sent(),ie.label=3;case 3:return[2]}})},_.label=2;case 2:return s?[3,4]:[5,h()];case 3:return _.sent(),[3,2];case 4:return[2,l&&l.value];case 5:return i(),[4,Promise.race(r.map(function(f){return f.return&&f.return()}))];case 6:return _.sent(),[7];case 7:return[2]}})})})}function Mr(e){var t=this,r=xe(e,{yieldValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m=this;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2];o=[],s=!1,i.then(function(){var h,_;s=!0;try{for(var f=B(o),k=f.next();!k.done;k=f.next()){var z=k.value;z()}}catch(S){h={error:S}}finally{try{k&&!k.done&&(_=f.return)&&_.call(f)}finally{if(h)throw h.error}}}),d.label=1;case 1:return d.trys.push([1,,3,4]),[4,Promise.all(r.map(function(h,_){return J(m,void 0,void 0,function(){var f,k;return E(this,function(z){switch(z.label){case 0:z.trys.push([0,,6,9]),z.label=1;case 1:return s?[3,5]:(Promise.resolve(h.next()).then(function(S){return o[_](S)},function(S){return i(S)}),[4,new Promise(function(S){o[_]=S})]);case 2:return f=z.sent(),f===void 0?[3,4]:f.done?(l=f,[2]):[4,n(f.value)];case 3:z.sent(),z.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return k=h.return,k?[4,h.return()]:[3,8];case 7:k=z.sent(),z.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return d.sent(),[2,l&&l.value];case 3:return i(),[7];case 4:return[2]}})})})}function Lr(e){var t=this,r=xe(e,{returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2,[]];s=!1,i.then(function(){o(),s=!0}),d.label=1;case 1:d.trys.push([1,,6,8]),d.label=2;case 2:return s?[3,5]:(Promise.all(r.map(function(h){return h.next()})).then(function(h){return o(h)},function(h){return i(h)}),[4,new Promise(function(h){return o=h})]);case 3:return l=d.sent(),l===void 0?[2]:(m=l.map(function(h){return h.value}),l.some(function(h){return h.done})?[2,m]:[4,n(m)]);case 4:return d.sent(),[3,2];case 5:return[3,8];case 6:return i(),[4,Promise.all(r.map(function(h){return h.return&&h.return()}))];case 7:return d.sent(),[7];case 8:return[2]}})})})}function Rr(e){var t=this,r=xe(e,{yieldValues:!0,returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m,d,h=this;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2,[]];s=[],l=!1,i.then(function(){var f,k;o();try{for(var z=B(s),S=z.next();!S.done;S=z.next()){var j=S.value;j()}}catch(ne){f={error:ne}}finally{try{S&&!S.done&&(k=z.return)&&k.call(z)}finally{if(f)throw f.error}}l=!0}),_.label=1;case 1:return _.trys.push([1,,5,7]),Promise.all(r.map(function(f){return f.next()})).then(function(f){return o(f)},function(f){return i(f)}),[4,new Promise(function(f){return o=f})];case 2:return m=_.sent(),m===void 0?[2]:(d=m.map(function(f){return f.value}),m.every(function(f){return f.done})?[2,d]:[4,n(d.slice())]);case 3:return _.sent(),[4,Promise.all(r.map(function(f,k){return J(h,void 0,void 0,function(){var z;return E(this,function(S){switch(S.label){case 0:if(m[k].done)return[2,m[k].value];S.label=1;case 1:return l?[3,4]:(Promise.resolve(f.next()).then(function(j){return s[k](j)},function(j){return i(j)}),[4,new Promise(function(j){return s[k]=j})]);case 2:return z=S.sent(),z===void 0?[2,m[k].value]:z.done?[2,z.value]:(d[k]=z.value,[4,n(d.slice())]);case 3:return S.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,_.sent()];case 5:return i(),[4,Promise.all(r.map(function(f){return f.return&&f.return()}))];case 6:return _.sent(),[7];case 7:return[2]}})})})}var Mt=class{graffiti;callbacks=new Set;options;login;logout;sessionEvents;postMedia;getMedia;deleteMedia;actorToHandle;handleToActor;constructor(t,r){this.options=r??{},this.graffiti=t,this.login=t.login.bind(t),this.logout=t.logout.bind(t),this.sessionEvents=t.sessionEvents,this.postMedia=t.postMedia.bind(t),this.getMedia=t.getMedia.bind(t),this.deleteMedia=t.deleteMedia.bind(t),this.actorToHandle=t.actorToHandle.bind(t),this.handleToActor=t.handleToActor.bind(t)}synchronize(t,r,n,i,o=new Set){let s=new K(async(l,m)=>{let d=await Ge(n),h=_=>{if(_?.tombstone)o.has(_.object.url)&&l(_);else if(_&&t(_.object)&&(this.options.omniscient||Fe(_.object,i))){let f=JSON.parse(JSON.stringify(_.object));this.options.omniscient||(f=Ve(f,r,i?.actor)),d(f)&&(l({object:f}),o.add(f.url))}};this.callbacks.add(h),await m,this.callbacks.delete(h)});return(async function*(){for await(let l of s)yield l})()}synchronizeDiscover(t,r,n){function i(o){return o.channels.some(s=>t.includes(s))}return this.synchronize(i,t,r,n)}synchronizeGet(t,r,n){let i=ae(t);function o(s){return s.url===i}return this.synchronize(o,[],r,n,new Set([i]))}synchronizeAll(t,r){return this.synchronize(()=>!0,[],t,r)}async synchronizeDispatch(t,r=!1){for(let n of this.callbacks)n(t);r&&await new Promise(n=>setTimeout(n,0))}get=async(...t)=>{try{let r=await this.graffiti.get(...t);return this.synchronizeDispatch({object:r}),r}catch(r){throw r instanceof W&&this.synchronizeDispatch({tombstone:!0,object:{url:ae(t[0])}}),r}};post=async(...t)=>{let r=await this.graffiti.post(...t);return await this.synchronizeDispatch({object:r},!0),r};delete=async(...t)=>{let r={tombstone:!0,object:{url:ae(t[0])}};try{let n=await this.graffiti.delete(...t);return await this.synchronizeDispatch(r,!0),n}catch(n){throw n instanceof W&&await this.synchronizeDispatch(r,!0),n}};objectStream(t){let r=this;return(async function*(){for(;;){let n=await t.next();if(n.done)return n.value;if(!n.value.error){let i=n.value;r.synchronizeDispatch(i)}yield n.value}})()}discover=(...t)=>{let r=this.graffiti.discover(...t);return this.objectStream(r)};continueDiscover=(...t)=>{let r=this.graffiti.continueDiscover(...t);return this.objectStream(r)}};export{Mt as GraffitiSynchronize};
1
+ import{b as a,c as u,d as c}from"./chunk-YB7WCAZH.js";a();c();u();a();c();u();a();c();u();a();c();u();var Lt={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},Jr={...Lt,required:["value","channels"]};a();c();u();var W=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},oe=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}};a();c();u();function ae(e){return typeof e=="string"?e:e.url}function Fe(e,t){return!Array.isArray(e.allowed)||typeof t?.actor=="string"&&(e.actor===t.actor||e.allowed.includes(t.actor))}function Ve(e,t,r){if(r===e.actor)return e;let n=e.allowed&&r?[r]:void 0,i=e.channels.filter(o=>t.includes(o));return{...e,...n?{allowed:n}:{},channels:i}}var be;async function Ge(e){if(!be){let{default:t}=await import("./ajv-UZKI6BMI.js");be=new t({strict:!1})}try{return be.compile(e)}catch(t){throw new oe(t instanceof Error?t.message:String(t))}}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var Rt=Object.freeze({status:"aborted"});function I(e,t,r){function n(l,m){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:m,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,m);let d=s.prototype,h=Object.keys(d);for(let _=0;_<h.length;_++){let f=h[_];f in l||(l[f]=d[f].bind(l))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function s(l){var m;let d=r?.Parent?new o:this;n(d,l),(m=d._zod).deferred??(m.deferred=[]);for(let h of d._zod.deferred)h();return d}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:l=>r?.Parent&&l instanceof r.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var D=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};var ke={};function N(e){return e&&Object.assign(ke,e),ke}a();c();u();a();c();u();a();c();u();function Be(e,t){return typeof t=="bigint"?t.toString():t}function Ie(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function se(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}var Je=Symbol("evaluating");function w(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Je)return n===void 0&&(n=Je,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ct(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ft(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}var Se="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Vt=Ie(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ke(e){if(ce(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ce(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function q(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function U(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function We(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var qe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Xe(e,t){if(!Ke(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=Ft(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Ct(this,"shape",o),o}});return q(e,i)}function F(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function le(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ue(e){return typeof e=="string"?e:e?.message}function A(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=ue(e.inst?._zod.def?.error?.(e))??ue(t?.error?.(e))??ue(r.customError?.(e))??ue(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function we(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}var Ye=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Be,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},He=I("$ZodError",Ye),X=I("$ZodError",Ye,{Parent:Error});var Jt=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new D;if(s.issues.length){let l=new(i?.Err??e)(s.issues.map(m=>A(m,o,N())));throw Se(l,i?.callee),l}return s.value},de=Jt(X),Bt=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let l=new(i?.Err??e)(s.issues.map(m=>A(m,o,N())));throw Se(l,i?.callee),l}return s.value},me=Bt(X),Kt=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new D;return o.issues.length?{success:!1,error:new(e??He)(o.issues.map(s=>A(s,i,N())))}:{success:!0,data:o.value}},Y=Kt(X),Wt=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>A(s,i,N())))}:{success:!0,data:o.value}},H=Wt(X);a();c();u();a();c();u();a();c();u();var qt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Xt=new RegExp(`^${qt}$`);var et=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var tt=/^-?\d+$/,rt=/^-?\d+(?:\.\d+)?$/;var M=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Yt={number:"number",bigint:"bigint",object:"date"};var nt=I("$ZodCheckGreaterThan",(e,t)=>{M.init(e,t);let r=Yt[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var it=I("$ZodCheckNumberFormat",(e,t)=>{M.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=qe[t.format];e._zod.onattach.push(s=>{let l=s._zod.bag;l.format=t.format,l.minimum=i,l.maximum=o,r&&(l.pattern=tt)}),e._zod.check=s=>{let l=s.value;if(r){if(!Number.isInteger(l)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?s.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}l<i&&s.issues.push({origin:"number",input:l,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),l>o&&s.issues.push({origin:"number",input:l,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var ot=I("$ZodCheckStringFormat",(e,t)=>{var r,n;M.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})});a();c();u();a();c();u();var ut={major:4,minor:3,patch:6};var P=I("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ut;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(s,l,m)=>{let d=F(s),h;for(let _ of l){if(_._zod.def.when){if(!_._zod.def.when(s))continue}else if(d)continue;let f=s.issues.length,k=_._zod.check(s);if(k instanceof Promise&&m?.async===!1)throw new D;if(h||k instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await k,s.issues.length!==f&&(d||(d=F(s,f)))});else{if(s.issues.length===f)continue;d||(d=F(s,f))}}return h?h.then(()=>s):s},o=(s,l,m)=>{if(F(s))return s.aborted=!0,s;let d=i(l,n,m);if(d instanceof Promise){if(m.async===!1)throw new D;return d.then(h=>e._zod.parse(h,m))}return e._zod.parse(d,m)};e._zod.run=(s,l)=>{if(l.skipChecks)return e._zod.parse(s,l);if(l.direction==="backward"){let d=e._zod.parse({value:s.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(h=>o(h,s,l)):o(d,s,l)}let m=e._zod.parse(s,l);if(m instanceof Promise){if(l.async===!1)throw new D;return m.then(d=>i(d,n,l))}return i(m,n,l)}}w(e,"~standard",()=>({validate:i=>{try{let o=Y(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return H(e,i).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),pe=I("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??et(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),je=I("$ZodStringFormat",(e,t)=>{ot.init(e,t),pe.init(e,t)});var mt=I("$ZodURL",(e,t)=>{je.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}});var Pe=I("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??rt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),ft=I("$ZodNumberFormat",(e,t)=>{it.init(e,t),Pe.init(e,t)});var pt=I("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=r=>r});function ct(e,t,r){e.issues.length&&t.issues.push(...le(r,e.issues)),t.value[r]=e.value}var gt=I("$ZodArray",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let s=0;s<i.length;s++){let l=i[s],m=t.element._zod.run({value:l,issues:[]},n);m instanceof Promise?o.push(m.then(d=>ct(d,r,s))):ct(m,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function fe(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...le(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Qt(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=We(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function er(e,t,r,n,i,o){let s=[],l=i.keySet,m=i.catchall._zod,d=m.def.type,h=m.optout==="optional";for(let _ in t){if(l.has(_))continue;if(d==="never"){s.push(_);continue}let f=m.run({value:t[_],issues:[]},n);f instanceof Promise?e.push(f.then(k=>fe(k,r,_,t,h))):fe(f,r,_,t,h)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var vt=I("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let l=t.shape;Object.defineProperty(t,"shape",{get:()=>{let m={...l};return Object.defineProperty(t,"shape",{value:m}),m}})}let n=Ie(()=>Qt(t));w(e._zod,"propValues",()=>{let l=t.shape,m={};for(let d in l){let h=l[d]._zod;if(h.values){m[d]??(m[d]=new Set);for(let _ of h.values)m[d].add(_)}}return m});let i=ce,o=t.catchall,s;e._zod.parse=(l,m)=>{s??(s=n.value);let d=l.value;if(!i(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};let h=[],_=s.shape;for(let f of s.keys){let k=_[f],z=k._zod.optout==="optional",S=k._zod.run({value:d[f],issues:[]},m);S instanceof Promise?h.push(S.then(j=>fe(j,l,f,d,z))):fe(S,l,f,d,z)}return o?er(h,d,l,m,n.value,e):h.length?Promise.all(h).then(()=>l):l}});function st(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!F(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>A(s,n,N())))}),t)}var ht=I("$ZodUnion",(e,t)=>{P.init(e,t),w(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),w(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),w(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),w(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>se(o.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let s=!1,l=[];for(let m of t.options){let d=m._zod.run({value:i.value,issues:[]},o);if(d instanceof Promise)l.push(d),s=!0;else{if(d.issues.length===0)return d;l.push(d)}}return s?Promise.all(l).then(m=>st(m,i,e,o)):st(l,i,e,o)}});function lt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var $t=I("$ZodOptional",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.optout="optional",w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${se(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>lt(o,r.value)):lt(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var _t=I("$ZodNullable",(e,t)=>{P.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${se(r.source)}|null)$`):void 0}),w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)});var yt=I("$ZodCustom",(e,t)=>{M.init(e,t),P.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>dt(o,r,n,e));dt(i,r,n,e)}});function dt(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(we(i))}}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var bt;var Ue=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function kt(){return new Ue}(bt=globalThis).__zod_globalRegistry??(bt.__zod_globalRegistry=kt());var Oe=globalThis.__zod_globalRegistry;a();c();u();function zt(e,t){return new e({type:"string",...U(t)})}function It(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function St(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function wt(e){return new e({type:"unknown"})}function De(e,t){return new nt({check:"greater_than",...U(t),value:e,inclusive:!0})}function Ze(e){return De(0,e)}function jt(e,t,r){let n=U(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();a();c();u();var Z=I("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");P.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>de(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Y(e,r,n),e.parseAsync=async(r,n)=>me(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>H(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>q(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Te=I("ZodMiniString",(e,t)=>{pe.init(e,t),Z.init(e,t)});function Ne(e){return zt(Te,e)}var Pt=I("ZodMiniStringFormat",(e,t)=>{je.init(e,t),Te.init(e,t)});var pr=I("ZodMiniURL",(e,t)=>{mt.init(e,t),Pt.init(e,t)});function T(e){return It(pr,e)}var Ut=I("ZodMiniNumber",(e,t)=>{Pe.init(e,t),Z.init(e,t)});var gr=I("ZodMiniNumberFormat",(e,t)=>{ft.init(e,t),Ut.init(e,t)});function Ot(e){return St(gr,e)}var vr=I("ZodMiniUnknown",(e,t)=>{pt.init(e,t),Z.init(e,t)});function hr(){return wt(vr)}var $r=I("ZodMiniArray",(e,t)=>{gt.init(e,t),Z.init(e,t)});function ee(e,t){return new $r({type:"array",element:e,...U(t)})}var _r=I("ZodMiniObject",(e,t)=>{vt.init(e,t),Z.init(e,t),w(e,"shape",()=>t.shape)});function L(e,t){return new _r({type:"object",shape:e,catchall:hr(),...U(t)})}function Ee(e,t){return Xe(e,t)}var yr=I("ZodMiniUnion",(e,t)=>{ht.init(e,t),Z.init(e,t)});function Dt(e,t){return new yr({type:"union",options:e,...U(t)})}var xr=I("ZodMiniOptional",(e,t)=>{$t.init(e,t),Z.init(e,t)});function V(e){return new xr({type:"optional",innerType:e})}var br=I("ZodMiniNullable",(e,t)=>{_t.init(e,t),Z.init(e,t)});function ve(e){return new br({type:"nullable",innerType:e})}var kr=I("ZodMiniCustom",(e,t)=>{yt.init(e,t),Z.init(e,t)});function zr(e,t){return jt(kr,e??(()=>!0),t)}function Zt(e,t={}){let r=zr(n=>n instanceof e,t);return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}a();c();u();a();c();u();a();c();u();var Pr=L({value:L({}),channels:ee(Ne()),allowed:V(ve(ee(T())))}),Bp=Ee(Pr,{url:T(),actor:T()}),Kp=Dt([L({url:T()}),T()]),Ur=L({actor:T()}),Wp=V(ve(Ur)),Or=L({data:Zt(Blob),allowed:V(ve(ee(T())))}),qp=Ee(Or,{actor:T()}),Xp=L({types:V(ee(Ne())),maxBytes:V(Ot().check(Ze()))});a();c();u();var Me=function(e,t){return Me=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Me(e,t)};function Dr(e,t){Me(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function J(e,t,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function l(h){try{d(n.next(h))}catch(_){s(_)}}function m(h){try{d(n.throw(h))}catch(_){s(_)}}function d(h){h.done?o(h.value):i(h.value).then(l,m)}d((n=n.apply(e,t||[])).next())})}function E(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(d){return function(h){return m([d,h])}}function m(d){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=d[0]&2?i.return:d[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,d[1])).done)return o;switch(i=0,o&&(d=[d[0]&2,o.value]),d[0]){case 0:case 1:o=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,i=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!o||d[1]>o[0]&&d[1]<o[3])){r.label=d[1];break}if(d[0]===6&&r.label<o[1]){r.label=o[1],o=d;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(d);break}o[2]&&r.ops.pop(),r.trys.pop();continue}d=t.call(e,r)}catch(h){d=[6,h],i=0}finally{n=o=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function B(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function re(e){return this instanceof re?(this.v=e,this):new re(e)}function Zr(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){n[f]&&(i[f]=function(k){return new Promise(function(z,S){o.push([f,k,z,S])>1||l(f,k)})})}function l(f,k){try{m(n[f](k))}catch(z){_(o[0][3],z)}}function m(f){f.value instanceof re?Promise.resolve(f.value.v).then(d,h):_(o[0][2],f)}function d(f){l("next",f)}function h(f){l("throw",f)}function _(f,k){f(k),o.shift(),o.length&&l(o[0][0],o[0][1])}}var At=(function(e){Dr(t,e);function t(r){var n=e.call(this,r)||this;return Object.defineProperty(n,"name",{value:"RepeaterOverflowError",enumerable:!1}),typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(n,n.constructor.prototype):n.__proto__=n.constructor.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(n,n.constructor),n}return t})(Error),lg=(function(){function e(t){if(t<0)throw new RangeError("Capacity may not be less than 0");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),e.prototype.add=function(t){if(this.full)throw new Error("Buffer full");this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})(),dg=(function(){function e(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(t){for(;this._q.length>=this._c;)this._q.shift();this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})(),mg=(function(){function e(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}return Object.defineProperty(e.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.add=function(t){this._q.length<this._c&&this._q.push(t)},e.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},e})();function Le(e){e!=null&&typeof e.then=="function"&&e.then(ye,ye)}var Ae=0,Nt=1,C=2,$e=3,Re=4,_e=1024,ye=function(){};function G(e){var t=e.err,r=Promise.resolve(e.execution).then(function(n){if(t!=null)throw t;return n});return e.err=void 0,e.execution=r.then(function(){},function(){}),e.pending===void 0?r:e.pending.then(function(){return r})}function R(e,t){var r=e.state>=$e;return Promise.resolve(t).then(function(n){return!r&&e.state>=Re?G(e).then(function(i){return{value:i,done:!0}}):{value:n,done:r}})}function Ce(e,t){var r,n;if(!(e.state>=C))if(e.state=C,e.onnext(),e.onstop(),e.err==null&&(e.err=t),e.pushes.length===0&&(typeof e.buffer>"u"||e.buffer.empty))te(e);else try{for(var i=B(e.pushes),o=i.next();!o.done;o=i.next()){var s=o.value;s.resolve()}}catch(l){r={error:l}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}function te(e){var t,r;if(!(e.state>=$e)){e.state<C&&Ce(e),e.state=$e,e.buffer=void 0;try{for(var n=B(e.nexts),i=n.next();!i.done;i=n.next()){var o=i.value,s=e.pending===void 0?G(e):e.pending.then(function(){return G(e)});o.resolve(R(e,s))}}catch(l){t={error:l}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}e.pushes=[],e.nexts=[]}}function Et(e){e.state>=Re||(e.state<$e&&te(e),e.state=Re)}function Tr(e,t){if(Le(t),e.pushes.length>=_e)throw new At("No more than "+_e+" pending calls to push are allowed on a single repeater.");if(e.state>=C)return Promise.resolve(void 0);var r=e.pending===void 0?Promise.resolve(t):e.pending.then(function(){return t});r=r.catch(function(m){e.state<C&&(e.err=m),Et(e)});var n;if(e.nexts.length){var i=e.nexts.shift();i.resolve(R(e,r)),e.nexts.length?n=Promise.resolve(e.nexts[0].value):typeof e.buffer<"u"&&!e.buffer.full?n=Promise.resolve(void 0):n=new Promise(function(m){return e.onnext=m})}else typeof e.buffer<"u"&&!e.buffer.full?(e.buffer.add(r),n=Promise.resolve(void 0)):n=new Promise(function(m){return e.pushes.push({resolve:m,value:r})});var o=!0,s={},l=n.catch(function(m){if(o)throw m});return s.then=function(m,d){return o=!1,Promise.prototype.then.call(n,m,d)},s.catch=function(m){return o=!1,Promise.prototype.catch.call(n,m)},s.finally=n.finally.bind(n),e.pending=r.then(function(){return l}).catch(function(m){e.err=m,Et(e)}),s}function Nr(e){var t=Ce.bind(null,e),r=new Promise(function(n){return e.onstop=n});return t.then=r.then.bind(r),t.catch=r.catch.bind(r),t.finally=r.finally.bind(r),t}function Er(e){if(!(e.state>=Nt)){e.state=Nt;var t=Tr.bind(null,e),r=Nr(e);e.execution=new Promise(function(n){return n(e.executor(t,r))}),e.execution.catch(function(){return Ce(e)})}}var he=new WeakMap,K=(function(){function e(t,r){he.set(this,{executor:t,buffer:r,err:void 0,state:Ae,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:ye,onstop:ye})}return e.prototype.next=function(t){Le(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");if(r.nexts.length>=_e)throw new At("No more than "+_e+" pending calls to next are allowed on a single repeater.");if(r.state<=Ae&&Er(r),r.onnext(t),typeof r.buffer<"u"&&!r.buffer.empty){var n=R(r,r.buffer.remove());if(r.pushes.length){var i=r.pushes.shift();r.buffer.add(i.value),r.onnext=i.resolve}return n}else if(r.pushes.length){var o=r.pushes.shift();return r.onnext=o.resolve,R(r,o.value)}else if(r.state>=C)return te(r),R(r,G(r));return new Promise(function(s){return r.nexts.push({resolve:s,value:t})})},e.prototype.return=function(t){Le(t);var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");return te(r),r.execution=Promise.resolve(r.execution).then(function(){return t}),R(r,G(r))},e.prototype.throw=function(t){var r=he.get(this);if(r===void 0)throw new Error("WeakMap error");return r.state<=Ae||r.state>=C||typeof r.buffer<"u"&&!r.buffer.empty?(te(r),r.err==null&&(r.err=t),R(r,G(r))):this.next(Promise.reject(t))},e.prototype[Symbol.asyncIterator]=function(){return this},e.race=Ar,e.merge=Mr,e.zip=Lr,e.latest=Rr,e})();function xe(e,t){var r,n,i=[],o=function(d){d!=null&&typeof d[Symbol.asyncIterator]=="function"?i.push(d[Symbol.asyncIterator]()):d!=null&&typeof d[Symbol.iterator]=="function"?i.push(d[Symbol.iterator]()):i.push((function(){return Zr(this,arguments,function(){return E(this,function(f){switch(f.label){case 0:return t.yieldValues?[4,re(d)]:[3,3];case 1:return[4,f.sent()];case 2:f.sent(),f.label=3;case 3:return t.returnValues?[4,re(d)]:[3,5];case 4:return[2,f.sent()];case 5:return[2]}})})})())};try{for(var s=B(e),l=s.next();!l.done;l=s.next()){var m=l.value;o(m)}}catch(d){r={error:d}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}function Ar(e){var t=this,r=xe(e,{returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m,d,h;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2];s=!1,i.then(function(){o(),s=!0}),_.label=1;case 1:_.trys.push([1,,5,7]),m=void 0,d=0,h=function(){var f,k,z,S,j,ne;return E(this,function(ie){switch(ie.label){case 0:f=d;try{for(k=(j=void 0,B(r)),z=k.next();!z.done;z=k.next())S=z.value,Promise.resolve(S.next()).then(function(O){O.done?(i(),l===void 0&&(l=O)):d===f&&(d++,o(O))},function(O){return i(O)})}catch(O){j={error:O}}finally{try{z&&!z.done&&(ne=k.return)&&ne.call(k)}finally{if(j)throw j.error}}return[4,new Promise(function(O){return o=O})];case 1:return m=ie.sent(),m===void 0?[3,3]:[4,n(m.value)];case 2:ie.sent(),ie.label=3;case 3:return[2]}})},_.label=2;case 2:return s?[3,4]:[5,h()];case 3:return _.sent(),[3,2];case 4:return[2,l&&l.value];case 5:return i(),[4,Promise.race(r.map(function(f){return f.return&&f.return()}))];case 6:return _.sent(),[7];case 7:return[2]}})})})}function Mr(e){var t=this,r=xe(e,{yieldValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m=this;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2];o=[],s=!1,i.then(function(){var h,_;s=!0;try{for(var f=B(o),k=f.next();!k.done;k=f.next()){var z=k.value;z()}}catch(S){h={error:S}}finally{try{k&&!k.done&&(_=f.return)&&_.call(f)}finally{if(h)throw h.error}}}),d.label=1;case 1:return d.trys.push([1,,3,4]),[4,Promise.all(r.map(function(h,_){return J(m,void 0,void 0,function(){var f,k;return E(this,function(z){switch(z.label){case 0:z.trys.push([0,,6,9]),z.label=1;case 1:return s?[3,5]:(Promise.resolve(h.next()).then(function(S){return o[_](S)},function(S){return i(S)}),[4,new Promise(function(S){o[_]=S})]);case 2:return f=z.sent(),f===void 0?[3,4]:f.done?(l=f,[2]):[4,n(f.value)];case 3:z.sent(),z.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return k=h.return,k?[4,h.return()]:[3,8];case 7:k=z.sent(),z.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return d.sent(),[2,l&&l.value];case 3:return i(),[7];case 4:return[2]}})})})}function Lr(e){var t=this,r=xe(e,{returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m;return E(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2,[]];s=!1,i.then(function(){o(),s=!0}),d.label=1;case 1:d.trys.push([1,,6,8]),d.label=2;case 2:return s?[3,5]:(Promise.all(r.map(function(h){return h.next()})).then(function(h){return o(h)},function(h){return i(h)}),[4,new Promise(function(h){return o=h})]);case 3:return l=d.sent(),l===void 0?[2]:(m=l.map(function(h){return h.value}),l.some(function(h){return h.done})?[2,m]:[4,n(m)]);case 4:return d.sent(),[3,2];case 5:return[3,8];case 6:return i(),[4,Promise.all(r.map(function(h){return h.return&&h.return()}))];case 7:return d.sent(),[7];case 8:return[2]}})})})}function Rr(e){var t=this,r=xe(e,{yieldValues:!0,returnValues:!0});return new K(function(n,i){return J(t,void 0,void 0,function(){var o,s,l,m,d,h=this;return E(this,function(_){switch(_.label){case 0:if(!r.length)return i(),[2,[]];s=[],l=!1,i.then(function(){var f,k;o();try{for(var z=B(s),S=z.next();!S.done;S=z.next()){var j=S.value;j()}}catch(ne){f={error:ne}}finally{try{S&&!S.done&&(k=z.return)&&k.call(z)}finally{if(f)throw f.error}}l=!0}),_.label=1;case 1:return _.trys.push([1,,5,7]),Promise.all(r.map(function(f){return f.next()})).then(function(f){return o(f)},function(f){return i(f)}),[4,new Promise(function(f){return o=f})];case 2:return m=_.sent(),m===void 0?[2]:(d=m.map(function(f){return f.value}),m.every(function(f){return f.done})?[2,d]:[4,n(d.slice())]);case 3:return _.sent(),[4,Promise.all(r.map(function(f,k){return J(h,void 0,void 0,function(){var z;return E(this,function(S){switch(S.label){case 0:if(m[k].done)return[2,m[k].value];S.label=1;case 1:return l?[3,4]:(Promise.resolve(f.next()).then(function(j){return s[k](j)},function(j){return i(j)}),[4,new Promise(function(j){return s[k]=j})]);case 2:return z=S.sent(),z===void 0?[2,m[k].value]:z.done?[2,z.value]:(d[k]=z.value,[4,n(d.slice())]);case 3:return S.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,_.sent()];case 5:return i(),[4,Promise.all(r.map(function(f){return f.return&&f.return()}))];case 6:return _.sent(),[7];case 7:return[2]}})})})}var Mt=class{graffiti;callbacks=new Set;options;login;logout;sessionEvents;postMedia;getMedia;deleteMedia;actorToHandle;handleToActor;constructor(t,r){this.options=r??{},this.graffiti=t,this.login=t.login.bind(t),this.logout=t.logout.bind(t),this.sessionEvents=t.sessionEvents,this.postMedia=t.postMedia.bind(t),this.getMedia=t.getMedia.bind(t),this.deleteMedia=t.deleteMedia.bind(t),this.actorToHandle=t.actorToHandle.bind(t),this.handleToActor=t.handleToActor.bind(t)}synchronize(t,r,n,i,o=new Set){let s=new K(async(l,m)=>{let d=await Ge(n),h=_=>{if(_?.tombstone)o.has(_.object.url)&&l(_);else if(_&&t(_.object)&&(this.options.omniscient||Fe(_.object,i))){let f=JSON.parse(JSON.stringify(_.object));this.options.omniscient||(f=Ve(f,r,i?.actor)),d(f)&&(l({object:f}),o.add(f.url))}};this.callbacks.add(h),await m,this.callbacks.delete(h)});return(async function*(){for await(let l of s)yield l})()}synchronizeDiscover(t,r,n){function i(o){return o.channels.some(s=>t.includes(s))}return this.synchronize(i,t,r,n)}synchronizeGet(t,r,n){let i=ae(t);function o(s){return s.url===i}return this.synchronize(o,[],r,n,new Set([i]))}synchronizeAll(t,r){return this.synchronize(()=>!0,[],t,r)}async synchronizeDispatch(t,r=!1){for(let n of this.callbacks)n(t);r&&await new Promise(n=>setTimeout(n,0))}get=async(...t)=>{try{let r=await this.graffiti.get(...t);return this.synchronizeDispatch({object:r}),r}catch(r){throw(r instanceof W||r instanceof Error&&r.name==="GraffitiErrorNotFound")&&this.synchronizeDispatch({tombstone:!0,object:{url:ae(t[0])}}),r}};post=async(...t)=>{let r=await this.graffiti.post(...t);return await this.synchronizeDispatch({object:r},!0),r};delete=async(...t)=>{let r={tombstone:!0,object:{url:ae(t[0])}};try{let n=await this.graffiti.delete(...t);return await this.synchronizeDispatch(r,!0),n}catch(n){throw(n instanceof W||n instanceof Error&&n.name==="GraffitiErrorNotFound")&&await this.synchronizeDispatch(r,!0),n}};objectStream(t){let r=this;return(async function*(){try{for(;;){let n=await t.next();if(n.done)return n.value;if(!n.value.error){let i=n.value;r.synchronizeDispatch(i)}yield n.value}}finally{await t.return({cursor:""})}})()}discover=(...t)=>{let r=this.graffiti.discover(...t);return this.objectStream(r)};continueDiscover=(...t)=>{let r=this.graffiti.continueDiscover(...t);return this.objectStream(r)}};export{Mt as GraffitiSynchronize};
2
2
  /*! Bundled license information:
3
3
 
4
4
  @repeaterjs/repeater/repeater.js: