@kaptures/storybook 0.15.1 → 0.15.2

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 +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -36,4 +36,4 @@ import{PLAY_FUNCTION_THREW_EXCEPTION as e,STORY_FINISHED as t,STORY_RENDER_PHASE
36
36
 
37
37
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=w,s=!pe.jitless,c=s&&we.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Fn([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Rn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!k(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>M(e,r,b())))}),t)}const zn=v(`$ZodUnion`,(e,t)=>{L.init(e,t),x(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),x(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),x(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),x(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ve(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Rn(t,i,e,a)):Rn(s,i,e,a)}}),Bn=v(`$ZodIntersection`,(e,t)=>{L.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Hn(e,t,n)):Hn(e,i,a)}});function Vn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(T(e)&&T(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Vn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Vn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Hn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),k(e))return e;let o=Vn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Un=v(`$ZodTuple`,(e,t)=>{L.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=[...n].reverse().findIndex(e=>e._zod.optin!==`optional`),c=s===-1?0:n.length-s;if(!t.rest){let t=a.length>n.length,i=a.length<c-1;if(t||i)return r.issues.push({...t?{code:`too_big`,maximum:n.length,inclusive:!0}:{code:`too_small`,minimum:n.length},input:a,inst:e,origin:`array`}),r}let l=-1;for(let e of n){if(l++,l>=a.length&&l>=c)continue;let t=e._zod.run({value:a[l],issues:[]},i);t instanceof Promise?o.push(t.then(e=>B(e,r,l))):B(t,r,l)}if(t.rest){let e=a.slice(n.length);for(let n of e){l++;let e=t.rest._zod.run({value:n,issues:[]},i);e instanceof Promise?o.push(e.then(e=>B(e,r,l))):B(e,r,l)}}return o.length?Promise.all(o).then(()=>r):r}});function B(e,t,n){e.issues.length&&t.issues.push(...A(n,e.issues)),t.value[n]=e.value}const Wn=v(`$ZodRecord`,(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!T(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...A(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...A(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Ot.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>M(e,r,b())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...A(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...A(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Gn=v(`$ZodEnum`,(e,t)=>{L.init(e,t);let n=me(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Ee.has(typeof e)).map(e=>typeof e==`string`?E(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Kn=v(`$ZodTransform`,(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new fe(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new y;return n.value=i,n}});function qn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Jn=v(`$ZodOptional`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,x(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),x(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ve(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>qn(t,e.value)):qn(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Yn=v(`$ZodExactOptional`,(e,t)=>{Jn.init(e,t),x(e._zod,`values`,()=>t.innerType._zod.values),x(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Xn=v(`$ZodNullable`,(e,t)=>{L.init(e,t),x(e._zod,`optin`,()=>t.innerType._zod.optin),x(e._zod,`optout`,()=>t.innerType._zod.optout),x(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ve(e.source)}|null)$`):void 0}),x(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Zn=v(`$ZodDefault`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,x(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Qn(e,t)):Qn(r,t)}});function Qn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $n=v(`$ZodPrefault`,(e,t)=>{L.init(e,t),e._zod.optin=`optional`,x(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),er=v(`$ZodNonOptional`,(e,t)=>{L.init(e,t),x(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>tr(t,e)):tr(i,e)}});function tr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const nr=v(`$ZodCatch`,(e,t)=>{L.init(e,t),x(e._zod,`optin`,()=>t.innerType._zod.optin),x(e._zod,`optout`,()=>t.innerType._zod.optout),x(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,b()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>M(e,n,b()))},input:e.value}),e.issues=[]),e)}}),rr=v(`$ZodPipe`,(e,t)=>{L.init(e,t),x(e._zod,`values`,()=>t.in._zod.values),x(e._zod,`optin`,()=>t.in._zod.optin),x(e._zod,`optout`,()=>t.out._zod.optout),x(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>V(e,t.in,n)):V(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>V(e,t.out,n)):V(r,t.out,n)}});function V(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const ir=v(`$ZodReadonly`,(e,t)=>{L.init(e,t),x(e._zod,`propValues`,()=>t.innerType._zod.propValues),x(e._zod,`values`,()=>t.innerType._zod.values),x(e._zod,`optin`,()=>t.innerType?._zod?.optin),x(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ar):ar(r)}});function ar(e){return e.value=Object.freeze(e.value),e}const or=v(`$ZodFunction`,(e,t)=>(L.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return function(...n){let r=e._def.input?Ue(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?Ue(e._def.output,i):i}},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...n){let r=e._def.input?await Ge(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await Ge(e._def.output,i):i}},e._zod.parse=(t,n)=>typeof t.value==`function`?(t.value=e._def.output&&e._def.output._zod.def.type===`promise`?e.implementAsync(t.value):e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new Un({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),sr=v(`$ZodLazy`,(e,t)=>{L.init(e,t),x(e._zod,`innerType`,()=>t.getter()),x(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),x(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),x(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),x(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),cr=v(`$ZodCustom`,(e,t)=>{F.init(e,t),L.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>lr(t,n,r,e));lr(i,n,r,e)}});function lr(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(N(e))}}var ur,dr=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function fr(){return new dr}(ur=globalThis).__zod_globalRegistry??(ur.__zod_globalRegistry=fr());const H=globalThis.__zod_globalRegistry;function pr(e,t){return new e({type:`string`,...O(t)})}function mr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...O(t)})}function hr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...O(t)})}function gr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...O(t)})}function _r(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...O(t)})}function vr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...O(t)})}function yr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...O(t)})}function br(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...O(t)})}function xr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...O(t)})}function Sr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...O(t)})}function Cr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...O(t)})}function wr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...O(t)})}function Tr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...O(t)})}function Er(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...O(t)})}function Dr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...O(t)})}function Or(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...O(t)})}function kr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...O(t)})}function Ar(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...O(t)})}function jr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...O(t)})}function Mr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...O(t)})}function Nr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...O(t)})}function Pr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...O(t)})}function Fr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...O(t)})}function Ir(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...O(t)})}function Lr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...O(t)})}function Rr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...O(t)})}function zr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...O(t)})}function Br(e,t){return new e({type:`number`,checks:[],...O(t)})}function Vr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...O(t)})}function Hr(e,t){return new e({type:`boolean`,...O(t)})}function Ur(e,t){return new e({type:`undefined`,...O(t)})}function Wr(e,t){return new e({type:`null`,...O(t)})}function Gr(e){return new e({type:`unknown`})}function Kr(e,t){return new e({type:`never`,...O(t)})}function qr(e,t){return new Ft({check:`less_than`,...O(t),value:e,inclusive:!1})}function Jr(e,t){return new Ft({check:`less_than`,...O(t),value:e,inclusive:!0})}function Yr(e,t){return new It({check:`greater_than`,...O(t),value:e,inclusive:!1})}function Xr(e,t){return new It({check:`greater_than`,...O(t),value:e,inclusive:!0})}function Zr(e,t){return new Lt({check:`multiple_of`,...O(t),value:e})}function Qr(e,t){return new zt({check:`max_length`,...O(t),maximum:e})}function U(e,t){return new Bt({check:`min_length`,...O(t),minimum:e})}function $r(e,t){return new Vt({check:`length_equals`,...O(t),length:e})}function ei(e,t){return new Ht({check:`string_format`,format:`regex`,...O(t),pattern:e})}function ti(e){return new Ut({check:`string_format`,format:`lowercase`,...O(e)})}function ni(e){return new Wt({check:`string_format`,format:`uppercase`,...O(e)})}function ri(e,t){return new Gt({check:`string_format`,format:`includes`,...O(t),includes:e})}function ii(e,t){return new Kt({check:`string_format`,format:`starts_with`,...O(t),prefix:e})}function ai(e,t){return new qt({check:`string_format`,format:`ends_with`,...O(t),suffix:e})}function W(e){return new Jt({check:`overwrite`,tx:e})}function oi(e){return W(t=>t.normalize(e))}function si(){return W(e=>e.trim())}function ci(){return W(e=>e.toLowerCase())}function li(){return W(e=>e.toUpperCase())}function ui(){return W(e=>Se(e))}function di(e,t,n){return new e({type:`array`,element:t,...O(n)})}function fi(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...O(n)})}function pi(e){let t=mi(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(N(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(N(r))}},e(n.value,n)));return t}function mi(e,t){let n=new F({check:`custom`,...O(t)});return n._zod.check=e,n}function hi(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??H,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function G(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,G(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&K(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function gi(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
38
38
 
39
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function _i(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:q(t,`input`,e.processors),output:q(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function K(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return K(r.element,n);if(r.type===`set`)return K(r.valueType,n);if(r.type===`lazy`)return K(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return K(r.innerType,n);if(r.type===`intersection`)return K(r.left,n)||K(r.right,n);if(r.type===`record`||r.type===`map`)return K(r.keyType,n)||K(r.valueType,n);if(r.type===`pipe`)return K(r.in,n)||K(r.out,n);if(r.type===`object`){for(let e in r.shape)if(K(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(K(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(K(e,n))return!0;return!!(r.rest&&K(r.rest,n))}return!1}const vi=(e,t={})=>n=>{let r=hi({...n,processors:t});return G(e,r),gi(r,e),_i(r,e)},q=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=hi({...i??{},target:a,io:t,processors:n});return G(e,o),gi(o,e),_i(o,e)},yi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},bi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=yi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},xi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Si=(e,t,n,r)=>{n.type=`boolean`},Ci=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},wi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Ti=(e,t,n,r)=>{n.not={}},Ei=(e,t,n,r)=>{let i=e._zod.def,a=me(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Di=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Oi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},ki=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ai=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=G(a.element,t,{...r,path:[...r.path,`items`]})},ji=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=G(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=G(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Mi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>G(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ni=(e,t,n,r)=>{let i=e._zod.def,a=G(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=G(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Pi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>G(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?G(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Fi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=G(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=G(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=G(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Ii=(e,t,n,r)=>{let i=e._zod.def,a=G(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Li=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ri=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},zi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Bi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Vi=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;G(a,t,r);let o=t.seen.get(e);o.ref=a},Hi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ui=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Wi=(e,t,n,r)=>{let i=e._zod.innerType;G(i,t,r);let a=t.seen.get(e);a.ref=i},Gi=v(`ZodISODateTime`,(e,t)=>{un.init(e,t),Z.init(e,t)});function Ki(e){return Ir(Gi,e)}const qi=v(`ZodISODate`,(e,t)=>{dn.init(e,t),Z.init(e,t)});function Ji(e){return Lr(qi,e)}const Yi=v(`ZodISOTime`,(e,t)=>{fn.init(e,t),Z.init(e,t)});function Xi(e){return Rr(Yi,e)}const Zi=v(`ZodISODuration`,(e,t)=>{pn.init(e,t),Z.init(e,t)});function Qi(e){return zr(Zi,e)}const $i=(e,t)=>{Re.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ve(e,t)},flatten:{value:t=>Be(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,he,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,he,2)}},isEmpty:{get(){return e.issues.length===0}}})},ea=v(`ZodError`,$i),J=v(`ZodError`,$i,{Parent:Error}),ta=He(J),na=We(J),ra=Ke(J),ia=P(J),aa=Ye(J),oa=Xe(J),sa=Ze(J),ca=Qe(J),la=$e(J),ua=et(J),da=tt(J),fa=nt(J),Y=v(`ZodType`,(e,t)=>(L.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:q(e,`input`),output:q(e,`output`)}}),e.toJSONSchema=vi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(C(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>D(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ta(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ra(e,t,n),e.parseAsync=async(t,n)=>na(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ia(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>aa(e,t,n),e.decode=(t,n)=>oa(e,t,n),e.encodeAsync=async(t,n)=>sa(e,t,n),e.decodeAsync=async(t,n)=>ca(e,t,n),e.safeEncode=(t,n)=>la(e,t,n),e.safeDecode=(t,n)=>ua(e,t,n),e.safeEncodeAsync=async(t,n)=>da(e,t,n),e.safeDecodeAsync=async(t,n)=>fa(e,t,n),e.refine=(t,n)=>e.check(Mo(t,n)),e.superRefine=t=>e.check(No(t)),e.overwrite=t=>e.check(W(t)),e.optional=()=>lo(e),e.exactOptional=()=>fo(e),e.nullable=()=>mo(e),e.nullish=()=>lo(mo(e)),e.nonoptional=t=>bo(e,t),e.array=()=>Ja(e),e.or=t=>Za([e,t]),e.and=t=>$a(e,t),e.transform=t=>wo(e,so(t)),e.default=t=>go(e,t),e.prefault=t=>vo(e,t),e.catch=t=>So(e,t),e.pipe=t=>wo(e,t),e.readonly=()=>Eo(e),e.describe=t=>{let n=e.clone();return H.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return H.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return H.get(e);let n=e.clone();return H.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),pa=v(`_ZodString`,(e,t)=>{Zt.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ei(...t)),e.includes=(...t)=>e.check(ri(...t)),e.startsWith=(...t)=>e.check(ii(...t)),e.endsWith=(...t)=>e.check(ai(...t)),e.min=(...t)=>e.check(U(...t)),e.max=(...t)=>e.check(Qr(...t)),e.length=(...t)=>e.check($r(...t)),e.nonempty=(...t)=>e.check(U(1,...t)),e.lowercase=t=>e.check(ti(t)),e.uppercase=t=>e.check(ni(t)),e.trim=()=>e.check(si()),e.normalize=(...t)=>e.check(oi(...t)),e.toLowerCase=()=>e.check(ci()),e.toUpperCase=()=>e.check(li()),e.slugify=()=>e.check(ui())}),ma=v(`ZodString`,(e,t)=>{Zt.init(e,t),pa.init(e,t),e.email=t=>e.check(mr(ha,t)),e.url=t=>e.check(br(va,t)),e.jwt=t=>e.check(Fr(Na,t)),e.emoji=t=>e.check(xr(ya,t)),e.guid=t=>e.check(hr(ga,t)),e.uuid=t=>e.check(gr(_a,t)),e.uuidv4=t=>e.check(_r(_a,t)),e.uuidv6=t=>e.check(vr(_a,t)),e.uuidv7=t=>e.check(yr(_a,t)),e.nanoid=t=>e.check(Sr(ba,t)),e.guid=t=>e.check(hr(ga,t)),e.cuid=t=>e.check(Cr(xa,t)),e.cuid2=t=>e.check(wr(Sa,t)),e.ulid=t=>e.check(Tr(Ca,t)),e.base64=t=>e.check(Mr(Aa,t)),e.base64url=t=>e.check(Nr(ja,t)),e.xid=t=>e.check(Er(wa,t)),e.ksuid=t=>e.check(Dr(Ta,t)),e.ipv4=t=>e.check(Or(Ea,t)),e.ipv6=t=>e.check(kr(Da,t)),e.cidrv4=t=>e.check(Ar(Oa,t)),e.cidrv6=t=>e.check(jr(ka,t)),e.e164=t=>e.check(Pr(Ma,t)),e.datetime=t=>e.check(Ki(t)),e.date=t=>e.check(Ji(t)),e.time=t=>e.check(Xi(t)),e.duration=t=>e.check(Qi(t))});function X(e){return pr(ma,e)}const Z=v(`ZodStringFormat`,(e,t)=>{R.init(e,t),pa.init(e,t)}),ha=v(`ZodEmail`,(e,t)=>{en.init(e,t),Z.init(e,t)}),ga=v(`ZodGUID`,(e,t)=>{Qt.init(e,t),Z.init(e,t)}),_a=v(`ZodUUID`,(e,t)=>{$t.init(e,t),Z.init(e,t)}),va=v(`ZodURL`,(e,t)=>{tn.init(e,t),Z.init(e,t)}),ya=v(`ZodEmoji`,(e,t)=>{nn.init(e,t),Z.init(e,t)}),ba=v(`ZodNanoID`,(e,t)=>{rn.init(e,t),Z.init(e,t)}),xa=v(`ZodCUID`,(e,t)=>{an.init(e,t),Z.init(e,t)}),Sa=v(`ZodCUID2`,(e,t)=>{on.init(e,t),Z.init(e,t)}),Ca=v(`ZodULID`,(e,t)=>{sn.init(e,t),Z.init(e,t)}),wa=v(`ZodXID`,(e,t)=>{cn.init(e,t),Z.init(e,t)}),Ta=v(`ZodKSUID`,(e,t)=>{ln.init(e,t),Z.init(e,t)}),Ea=v(`ZodIPv4`,(e,t)=>{mn.init(e,t),Z.init(e,t)}),Da=v(`ZodIPv6`,(e,t)=>{hn.init(e,t),Z.init(e,t)}),Oa=v(`ZodCIDRv4`,(e,t)=>{gn.init(e,t),Z.init(e,t)}),ka=v(`ZodCIDRv6`,(e,t)=>{_n.init(e,t),Z.init(e,t)}),Aa=v(`ZodBase64`,(e,t)=>{yn.init(e,t),Z.init(e,t)}),ja=v(`ZodBase64URL`,(e,t)=>{xn.init(e,t),Z.init(e,t)}),Ma=v(`ZodE164`,(e,t)=>{Sn.init(e,t),Z.init(e,t)}),Na=v(`ZodJWT`,(e,t)=>{wn.init(e,t),Z.init(e,t)}),Pa=v(`ZodNumber`,(e,t)=>{Tn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.gt=(t,n)=>e.check(Yr(t,n)),e.gte=(t,n)=>e.check(Xr(t,n)),e.min=(t,n)=>e.check(Xr(t,n)),e.lt=(t,n)=>e.check(qr(t,n)),e.lte=(t,n)=>e.check(Jr(t,n)),e.max=(t,n)=>e.check(Jr(t,n)),e.int=t=>e.check(La(t)),e.safe=t=>e.check(La(t)),e.positive=t=>e.check(Yr(0,t)),e.nonnegative=t=>e.check(Xr(0,t)),e.negative=t=>e.check(qr(0,t)),e.nonpositive=t=>e.check(Jr(0,t)),e.multipleOf=(t,n)=>e.check(Zr(t,n)),e.step=(t,n)=>e.check(Zr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Fa(e){return Br(Pa,e)}const Ia=v(`ZodNumberFormat`,(e,t)=>{En.init(e,t),Pa.init(e,t)});function La(e){return Vr(Ia,e)}const Ra=v(`ZodBoolean`,(e,t)=>{Dn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r)});function za(e){return Hr(Ra,e)}const Ba=v(`ZodUndefined`,(e,t)=>{On.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r)});function Va(e){return Ur(Ba,e)}const Ha=v(`ZodNull`,(e,t)=>{kn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r)});function Ua(e){return Wr(Ha,e)}const Wa=v(`ZodUnknown`,(e,t)=>{An.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Q(){return Gr(Wa)}const Ga=v(`ZodNever`,(e,t)=>{jn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r)});function Ka(e){return Kr(Ga,e)}const qa=v(`ZodArray`,(e,t)=>{Nn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(U(t,n)),e.nonempty=t=>e.check(U(1,t)),e.max=(t,n)=>e.check(Qr(t,n)),e.length=(t,n)=>e.check($r(t,n)),e.unwrap=()=>e.element});function Ja(e,t){return di(qa,e,t)}const Ya=v(`ZodObject`,(e,t)=>{Ln.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),x(e,`shape`,()=>t.shape),e.keyof=()=>ao(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Q()}),e.loose=()=>e.clone({...e._zod.def,catchall:Q()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ka()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>je(e,t),e.safeExtend=t=>Me(e,t),e.merge=t=>Ne(e,t),e.pick=t=>ke(e,t),e.omit=t=>Ae(e,t),e.partial=(...t)=>Pe(co,e,t[0]),e.required=(...t)=>Fe(yo,e,t[0])});function $(e,t){let n={type:`object`,shape:e??{},...O(t)};return new Ya(n)}const Xa=v(`ZodUnion`,(e,t)=>{zn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.options=t.options});function Za(e,t){return new Xa({type:`union`,options:e,...O(t)})}const Qa=v(`ZodIntersection`,(e,t)=>{Bn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r)});function $a(e,t){return new Qa({type:`intersection`,left:e,right:t})}const eo=v(`ZodTuple`,(e,t)=>{Un.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function to(e,t,n){let r=t instanceof L;return new eo({type:`tuple`,items:e,rest:r?t:null,...O(r?n:t)})}const no=v(`ZodRecord`,(e,t)=>{Wn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ro(e,t,n){return new no({type:`record`,keyType:e,valueType:t,...O(n)})}const io=v(`ZodEnum`,(e,t)=>{Gn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new io({...t,checks:[],...O(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new io({...t,checks:[],...O(r),entries:i})}});function ao(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new io({type:`enum`,entries:n,...O(t)})}const oo=v(`ZodTransform`,(e,t)=>{Kn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new fe(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(N(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(N(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function so(e){return new oo({type:`transform`,transform:e})}const co=v(`ZodOptional`,(e,t)=>{Jn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lo(e){return new co({type:`optional`,innerType:e})}const uo=v(`ZodExactOptional`,(e,t)=>{Yn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fo(e){return new uo({type:`optional`,innerType:e})}const po=v(`ZodNullable`,(e,t)=>{Xn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mo(e){return new po({type:`nullable`,innerType:e})}const ho=v(`ZodDefault`,(e,t)=>{Zn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function go(e,t){return new ho({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Te(t)}})}const _o=v(`ZodPrefault`,(e,t)=>{$n.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vo(e,t){return new _o({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Te(t)}})}const yo=v(`ZodNonOptional`,(e,t)=>{er.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bo(e,t){return new yo({type:`nonoptional`,innerType:e,...O(t)})}const xo=v(`ZodCatch`,(e,t)=>{nr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function So(e,t){return new xo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Co=v(`ZodPipe`,(e,t)=>{rr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vi(e,t,n,r),e.in=t.in,e.out=t.out});function wo(e,t){return new Co({type:`pipe`,in:e,out:t})}const To=v(`ZodReadonly`,(e,t)=>{ir.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eo(e){return new To({type:`readonly`,innerType:e})}const Do=v(`ZodLazy`,(e,t)=>{sr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wi(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Oo(e){return new Do({type:`lazy`,getter:e})}const ko=v(`ZodFunction`,(e,t)=>{or.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r)});function Ao(e){return new ko({type:`function`,input:Array.isArray(e?.input)?to(e?.input):e?.input??Ja(Q()),output:e?.output??Q()})}const jo=v(`ZodCustom`,(e,t)=>{cr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r)});function Mo(e,t={}){return fi(jo,e,t)}function No(e){return pi(e)}var Po=`0.15.1`;const Fo={set:e=>setTimeout(e,0),clear:e=>clearTimeout(e)};function Io(e,t,n=Fo){let r=0,i,a,o=new Map,s=[],c=()=>{a!==void 0&&n.clear(a),a=void 0},l=()=>{if(!i)return;let{configurationError:n,storybookError:r,...a}=i;t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`rendering`,...a})},u=(e,t)=>{let n={storyId:e,generation:++r,renderId:t};return o.set(n.generation,n),i=n,n},d=(r,o)=>{c(),a=n.set(()=>{if(a=void 0,!(!i||i.generation!==r.generation)&&!(r.configurationError||r.storybookError)){if(o===`error`){t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:r.storyId,generation:r.generation,renderId:r.renderId,error:{kind:`storybook`,message:`Storybook failed while rendering, playing, or finishing this story.`}});return}if(r.renderId===void 0||r.parameters===void 0){t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:r.storyId,generation:r.generation,renderId:r.renderId,error:{kind:`configuration`,message:`Kapture did not receive resolved story parameters before Storybook finished.`}});return}t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`ready`,storyId:r.storyId,generation:r.generation,renderId:r.renderId,parameters:r.parameters})}})};return{boot(){c(),r=0,i=void 0,o.clear(),s.length=0,t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`booting`})},startStory(e,t){return c(),(!i||i.storyId!==e||i.parameters!==void 0||i.configurationError!==void 0||i.storybookError!==void 0)&&(i=u(e)),i.parameters=t,l(),i.generation},completeStory(e,t){let n=o.get(t);!n||n.storyId!==e||n.configurationError||n.storybookError||s.includes(t)||s.push(t)},failConfiguration(n,r){c(),(!i||i.storyId!==n||i.parameters!==void 0)&&(i=u(n)),i.configurationError=r.message,t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:n,generation:i.generation,renderId:i.renderId,error:{kind:`configuration`,message:r.message}})},failStorybook(n){c(),i&&(i.storybookError=n.message,t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:i.storyId,generation:i.generation,renderId:i.renderId,error:{kind:`storybook`,message:n.message}}))},handlePhase(e){if(e.newPhase===`loading`){c(),u(e.storyId,e.renderId),l();return}i?.storyId===e.storyId&&(i.renderId=e.renderId)},handleFinished(e){let t=s.findIndex(t=>o.get(t)?.storyId===e.storyId),n=t<0?void 0:s.splice(t,1)[0],r=n===void 0?i:o.get(n);!r||r.storyId!==e.storyId||r.configurationError||r.storybookError||(e.status!==`success`||n!==void 0)&&d(r,e.status)},dispose(){c(),i=void 0,o.clear(),s.length=0}}}const Lo=Oo(()=>Za([X(),Fa(),za(),Ua(),Va(),Ja(Lo),ro(X(),Lo)])),Ro=$({name:X(),width:Fa(),height:Fa()}),zo=$({kapture:$({captureViewports:Ja(Za([X(),Ro])).optional(),captureEnabled:Q().optional(),captureArea:Q().optional(),captureDelayMs:Q().optional(),waitForElement:Q().optional(),animationState:Q().optional(),maskSelectors:Q().optional(),diffIgnoreSelectors:Q().optional(),waitForFonts:Q().optional(),fontAssertions:Q().optional(),diff:Q().optional()},{error:`parameters.kapture must be an object`}).optional(),viewport:Q().optional()},{error:`Storybook parameters must be an object`}),Bo=Ao({input:[X(),Q()]}).implement((e,t)=>{try{let e=zo.parse(t),n=e.kapture??{},r=n.captureViewports?.map(t=>{let n=X().safeParse(t);if(!n.success)return Ro.parse(t);let r=n.data;if(!r.trim())throw Error(`captureViewports entries must not be empty`);let i=$({options:ro(X(),Q())},{error:`parameters.viewport must be an object`}).parse(e.viewport).options,a=$({styles:$({width:Q().optional(),height:Q().optional()}).optional()},{error:`viewport option ${r} must be an object`}).parse(i[r]);return{name:r,width:Vo(`${r}.styles.width`).parse(a.styles?.width),height:Vo(`${r}.styles.height`).parse(a.styles?.height)}});return o(Lo.parse({...n,captureViewports:r}))}catch(t){let n=t instanceof ea?t.issues[0]?.message??t.message:t instanceof Error?t.message:String(t);throw Error(`Kapture story ${e}: ${n}`,{cause:t})}});function Vo(e){return X({error:`${e} must be an exact pixel dimension`}).trim().regex(/^\d+px$/,`${e} must use an exact pixel dimension such as 360px`).transform(e=>Number(e.slice(0,-2))).refine(e=>e>0,`${e} must be positive`)}function Ho(e){Object.defineProperty(globalThis,"__KAPTURE_STORYBOOK__",{value:e,writable:!0,enumerable:!0,configurable:!0})}function Uo(){let o=Io(Po,Ho),s=new WeakMap;return i({beforeAll(){o.boot();let i=a.getChannel(),s=e=>o.handlePhase(e),c=e=>o.handleFinished(e),l=e=>o.failStorybook(Wo(e));return i.on(n,s),i.on(t,c),i.on(e,l),i.on(r,l),()=>{i.off(n,s),i.off(t,c),i.off(e,l),i.off(r,l),o.dispose()}},beforeEach(e){try{let t=o.startStory(e.id,Bo(e.id,e.parameters));s.set(e,t)}catch(t){let n=t instanceof Error?t:Error(String(t));throw o.failConfiguration(e.id,n),n}},afterEach(e){let t=s.get(e);t!==void 0&&o.completeStory(e.id,t)}})}function Wo(e){let t=Array.isArray(e)?e[0]:e,n=$({message:X().refine(e=>e.trim().length>0)}).safeParse(t);return Error(n.success?`Storybook play function failed: ${n.data.message}`:`Storybook play function failed.`)}const Go=Uo;var Ko=Uo;export{Ko as default,Go as kapture};
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function _i(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:q(t,`input`,e.processors),output:q(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function K(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return K(r.element,n);if(r.type===`set`)return K(r.valueType,n);if(r.type===`lazy`)return K(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return K(r.innerType,n);if(r.type===`intersection`)return K(r.left,n)||K(r.right,n);if(r.type===`record`||r.type===`map`)return K(r.keyType,n)||K(r.valueType,n);if(r.type===`pipe`)return K(r.in,n)||K(r.out,n);if(r.type===`object`){for(let e in r.shape)if(K(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(K(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(K(e,n))return!0;return!!(r.rest&&K(r.rest,n))}return!1}const vi=(e,t={})=>n=>{let r=hi({...n,processors:t});return G(e,r),gi(r,e),_i(r,e)},q=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=hi({...i??{},target:a,io:t,processors:n});return G(e,o),gi(o,e),_i(o,e)},yi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},bi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=yi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},xi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Si=(e,t,n,r)=>{n.type=`boolean`},Ci=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},wi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Ti=(e,t,n,r)=>{n.not={}},Ei=(e,t,n,r)=>{let i=e._zod.def,a=me(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Di=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Oi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},ki=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ai=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=G(a.element,t,{...r,path:[...r.path,`items`]})},ji=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=G(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=G(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Mi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>G(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ni=(e,t,n,r)=>{let i=e._zod.def,a=G(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=G(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Pi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>G(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?G(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Fi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=G(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=G(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=G(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Ii=(e,t,n,r)=>{let i=e._zod.def,a=G(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Li=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ri=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},zi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Bi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Vi=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;G(a,t,r);let o=t.seen.get(e);o.ref=a},Hi=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ui=(e,t,n,r)=>{let i=e._zod.def;G(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Wi=(e,t,n,r)=>{let i=e._zod.innerType;G(i,t,r);let a=t.seen.get(e);a.ref=i},Gi=v(`ZodISODateTime`,(e,t)=>{un.init(e,t),Z.init(e,t)});function Ki(e){return Ir(Gi,e)}const qi=v(`ZodISODate`,(e,t)=>{dn.init(e,t),Z.init(e,t)});function Ji(e){return Lr(qi,e)}const Yi=v(`ZodISOTime`,(e,t)=>{fn.init(e,t),Z.init(e,t)});function Xi(e){return Rr(Yi,e)}const Zi=v(`ZodISODuration`,(e,t)=>{pn.init(e,t),Z.init(e,t)});function Qi(e){return zr(Zi,e)}const $i=(e,t)=>{Re.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ve(e,t)},flatten:{value:t=>Be(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,he,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,he,2)}},isEmpty:{get(){return e.issues.length===0}}})},ea=v(`ZodError`,$i),J=v(`ZodError`,$i,{Parent:Error}),ta=He(J),na=We(J),ra=Ke(J),ia=P(J),aa=Ye(J),oa=Xe(J),sa=Ze(J),ca=Qe(J),la=$e(J),ua=et(J),da=tt(J),fa=nt(J),Y=v(`ZodType`,(e,t)=>(L.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:q(e,`input`),output:q(e,`output`)}}),e.toJSONSchema=vi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(C(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>D(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ta(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ra(e,t,n),e.parseAsync=async(t,n)=>na(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ia(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>aa(e,t,n),e.decode=(t,n)=>oa(e,t,n),e.encodeAsync=async(t,n)=>sa(e,t,n),e.decodeAsync=async(t,n)=>ca(e,t,n),e.safeEncode=(t,n)=>la(e,t,n),e.safeDecode=(t,n)=>ua(e,t,n),e.safeEncodeAsync=async(t,n)=>da(e,t,n),e.safeDecodeAsync=async(t,n)=>fa(e,t,n),e.refine=(t,n)=>e.check(Mo(t,n)),e.superRefine=t=>e.check(No(t)),e.overwrite=t=>e.check(W(t)),e.optional=()=>lo(e),e.exactOptional=()=>fo(e),e.nullable=()=>mo(e),e.nullish=()=>lo(mo(e)),e.nonoptional=t=>bo(e,t),e.array=()=>Ja(e),e.or=t=>Za([e,t]),e.and=t=>$a(e,t),e.transform=t=>wo(e,so(t)),e.default=t=>go(e,t),e.prefault=t=>vo(e,t),e.catch=t=>So(e,t),e.pipe=t=>wo(e,t),e.readonly=()=>Eo(e),e.describe=t=>{let n=e.clone();return H.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return H.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return H.get(e);let n=e.clone();return H.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),pa=v(`_ZodString`,(e,t)=>{Zt.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ei(...t)),e.includes=(...t)=>e.check(ri(...t)),e.startsWith=(...t)=>e.check(ii(...t)),e.endsWith=(...t)=>e.check(ai(...t)),e.min=(...t)=>e.check(U(...t)),e.max=(...t)=>e.check(Qr(...t)),e.length=(...t)=>e.check($r(...t)),e.nonempty=(...t)=>e.check(U(1,...t)),e.lowercase=t=>e.check(ti(t)),e.uppercase=t=>e.check(ni(t)),e.trim=()=>e.check(si()),e.normalize=(...t)=>e.check(oi(...t)),e.toLowerCase=()=>e.check(ci()),e.toUpperCase=()=>e.check(li()),e.slugify=()=>e.check(ui())}),ma=v(`ZodString`,(e,t)=>{Zt.init(e,t),pa.init(e,t),e.email=t=>e.check(mr(ha,t)),e.url=t=>e.check(br(va,t)),e.jwt=t=>e.check(Fr(Na,t)),e.emoji=t=>e.check(xr(ya,t)),e.guid=t=>e.check(hr(ga,t)),e.uuid=t=>e.check(gr(_a,t)),e.uuidv4=t=>e.check(_r(_a,t)),e.uuidv6=t=>e.check(vr(_a,t)),e.uuidv7=t=>e.check(yr(_a,t)),e.nanoid=t=>e.check(Sr(ba,t)),e.guid=t=>e.check(hr(ga,t)),e.cuid=t=>e.check(Cr(xa,t)),e.cuid2=t=>e.check(wr(Sa,t)),e.ulid=t=>e.check(Tr(Ca,t)),e.base64=t=>e.check(Mr(Aa,t)),e.base64url=t=>e.check(Nr(ja,t)),e.xid=t=>e.check(Er(wa,t)),e.ksuid=t=>e.check(Dr(Ta,t)),e.ipv4=t=>e.check(Or(Ea,t)),e.ipv6=t=>e.check(kr(Da,t)),e.cidrv4=t=>e.check(Ar(Oa,t)),e.cidrv6=t=>e.check(jr(ka,t)),e.e164=t=>e.check(Pr(Ma,t)),e.datetime=t=>e.check(Ki(t)),e.date=t=>e.check(Ji(t)),e.time=t=>e.check(Xi(t)),e.duration=t=>e.check(Qi(t))});function X(e){return pr(ma,e)}const Z=v(`ZodStringFormat`,(e,t)=>{R.init(e,t),pa.init(e,t)}),ha=v(`ZodEmail`,(e,t)=>{en.init(e,t),Z.init(e,t)}),ga=v(`ZodGUID`,(e,t)=>{Qt.init(e,t),Z.init(e,t)}),_a=v(`ZodUUID`,(e,t)=>{$t.init(e,t),Z.init(e,t)}),va=v(`ZodURL`,(e,t)=>{tn.init(e,t),Z.init(e,t)}),ya=v(`ZodEmoji`,(e,t)=>{nn.init(e,t),Z.init(e,t)}),ba=v(`ZodNanoID`,(e,t)=>{rn.init(e,t),Z.init(e,t)}),xa=v(`ZodCUID`,(e,t)=>{an.init(e,t),Z.init(e,t)}),Sa=v(`ZodCUID2`,(e,t)=>{on.init(e,t),Z.init(e,t)}),Ca=v(`ZodULID`,(e,t)=>{sn.init(e,t),Z.init(e,t)}),wa=v(`ZodXID`,(e,t)=>{cn.init(e,t),Z.init(e,t)}),Ta=v(`ZodKSUID`,(e,t)=>{ln.init(e,t),Z.init(e,t)}),Ea=v(`ZodIPv4`,(e,t)=>{mn.init(e,t),Z.init(e,t)}),Da=v(`ZodIPv6`,(e,t)=>{hn.init(e,t),Z.init(e,t)}),Oa=v(`ZodCIDRv4`,(e,t)=>{gn.init(e,t),Z.init(e,t)}),ka=v(`ZodCIDRv6`,(e,t)=>{_n.init(e,t),Z.init(e,t)}),Aa=v(`ZodBase64`,(e,t)=>{yn.init(e,t),Z.init(e,t)}),ja=v(`ZodBase64URL`,(e,t)=>{xn.init(e,t),Z.init(e,t)}),Ma=v(`ZodE164`,(e,t)=>{Sn.init(e,t),Z.init(e,t)}),Na=v(`ZodJWT`,(e,t)=>{wn.init(e,t),Z.init(e,t)}),Pa=v(`ZodNumber`,(e,t)=>{Tn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.gt=(t,n)=>e.check(Yr(t,n)),e.gte=(t,n)=>e.check(Xr(t,n)),e.min=(t,n)=>e.check(Xr(t,n)),e.lt=(t,n)=>e.check(qr(t,n)),e.lte=(t,n)=>e.check(Jr(t,n)),e.max=(t,n)=>e.check(Jr(t,n)),e.int=t=>e.check(La(t)),e.safe=t=>e.check(La(t)),e.positive=t=>e.check(Yr(0,t)),e.nonnegative=t=>e.check(Xr(0,t)),e.negative=t=>e.check(qr(0,t)),e.nonpositive=t=>e.check(Jr(0,t)),e.multipleOf=(t,n)=>e.check(Zr(t,n)),e.step=(t,n)=>e.check(Zr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Fa(e){return Br(Pa,e)}const Ia=v(`ZodNumberFormat`,(e,t)=>{En.init(e,t),Pa.init(e,t)});function La(e){return Vr(Ia,e)}const Ra=v(`ZodBoolean`,(e,t)=>{Dn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r)});function za(e){return Hr(Ra,e)}const Ba=v(`ZodUndefined`,(e,t)=>{On.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r)});function Va(e){return Ur(Ba,e)}const Ha=v(`ZodNull`,(e,t)=>{kn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r)});function Ua(e){return Wr(Ha,e)}const Wa=v(`ZodUnknown`,(e,t)=>{An.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Q(){return Gr(Wa)}const Ga=v(`ZodNever`,(e,t)=>{jn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r)});function Ka(e){return Kr(Ga,e)}const qa=v(`ZodArray`,(e,t)=>{Nn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(U(t,n)),e.nonempty=t=>e.check(U(1,t)),e.max=(t,n)=>e.check(Qr(t,n)),e.length=(t,n)=>e.check($r(t,n)),e.unwrap=()=>e.element});function Ja(e,t){return di(qa,e,t)}const Ya=v(`ZodObject`,(e,t)=>{Ln.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),x(e,`shape`,()=>t.shape),e.keyof=()=>ao(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Q()}),e.loose=()=>e.clone({...e._zod.def,catchall:Q()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ka()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>je(e,t),e.safeExtend=t=>Me(e,t),e.merge=t=>Ne(e,t),e.pick=t=>ke(e,t),e.omit=t=>Ae(e,t),e.partial=(...t)=>Pe(co,e,t[0]),e.required=(...t)=>Fe(yo,e,t[0])});function $(e,t){let n={type:`object`,shape:e??{},...O(t)};return new Ya(n)}const Xa=v(`ZodUnion`,(e,t)=>{zn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.options=t.options});function Za(e,t){return new Xa({type:`union`,options:e,...O(t)})}const Qa=v(`ZodIntersection`,(e,t)=>{Bn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r)});function $a(e,t){return new Qa({type:`intersection`,left:e,right:t})}const eo=v(`ZodTuple`,(e,t)=>{Un.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function to(e,t,n){let r=t instanceof L;return new eo({type:`tuple`,items:e,rest:r?t:null,...O(r?n:t)})}const no=v(`ZodRecord`,(e,t)=>{Wn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ro(e,t,n){return new no({type:`record`,keyType:e,valueType:t,...O(n)})}const io=v(`ZodEnum`,(e,t)=>{Gn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new io({...t,checks:[],...O(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new io({...t,checks:[],...O(r),entries:i})}});function ao(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new io({type:`enum`,entries:n,...O(t)})}const oo=v(`ZodTransform`,(e,t)=>{Kn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new fe(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(N(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(N(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function so(e){return new oo({type:`transform`,transform:e})}const co=v(`ZodOptional`,(e,t)=>{Jn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lo(e){return new co({type:`optional`,innerType:e})}const uo=v(`ZodExactOptional`,(e,t)=>{Yn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fo(e){return new uo({type:`optional`,innerType:e})}const po=v(`ZodNullable`,(e,t)=>{Xn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mo(e){return new po({type:`nullable`,innerType:e})}const ho=v(`ZodDefault`,(e,t)=>{Zn.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function go(e,t){return new ho({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Te(t)}})}const _o=v(`ZodPrefault`,(e,t)=>{$n.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vo(e,t){return new _o({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Te(t)}})}const yo=v(`ZodNonOptional`,(e,t)=>{er.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bo(e,t){return new yo({type:`nonoptional`,innerType:e,...O(t)})}const xo=v(`ZodCatch`,(e,t)=>{nr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function So(e,t){return new xo({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Co=v(`ZodPipe`,(e,t)=>{rr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vi(e,t,n,r),e.in=t.in,e.out=t.out});function wo(e,t){return new Co({type:`pipe`,in:e,out:t})}const To=v(`ZodReadonly`,(e,t)=>{ir.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eo(e){return new To({type:`readonly`,innerType:e})}const Do=v(`ZodLazy`,(e,t)=>{sr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wi(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Oo(e){return new Do({type:`lazy`,getter:e})}const ko=v(`ZodFunction`,(e,t)=>{or.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r)});function Ao(e){return new ko({type:`function`,input:Array.isArray(e?.input)?to(e?.input):e?.input??Ja(Q()),output:e?.output??Q()})}const jo=v(`ZodCustom`,(e,t)=>{cr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r)});function Mo(e,t={}){return fi(jo,e,t)}function No(e){return pi(e)}var Po=`0.15.2`;const Fo={set:e=>setTimeout(e,0),clear:e=>clearTimeout(e)};function Io(e,t,n=Fo){let r=0,i,a,o=new Map,s=[],c=()=>{a!==void 0&&n.clear(a),a=void 0},l=()=>{if(!i)return;let{configurationError:n,storybookError:r,...a}=i;t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`rendering`,...a})},u=(e,t)=>{let n={storyId:e,generation:++r,renderId:t};return o.set(n.generation,n),i=n,n},d=(r,o)=>{c(),a=n.set(()=>{if(a=void 0,!(!i||i.generation!==r.generation)&&!(r.configurationError||r.storybookError)){if(o===`error`){t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:r.storyId,generation:r.generation,renderId:r.renderId,error:{kind:`storybook`,message:`Storybook failed while rendering, playing, or finishing this story.`}});return}if(r.renderId===void 0||r.parameters===void 0){t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:r.storyId,generation:r.generation,renderId:r.renderId,error:{kind:`configuration`,message:`Kapture did not receive resolved story parameters before Storybook finished.`}});return}t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`ready`,storyId:r.storyId,generation:r.generation,renderId:r.renderId,parameters:r.parameters})}})};return{boot(){c(),r=0,i=void 0,o.clear(),s.length=0,t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`booting`})},startStory(e,t){return c(),(!i||i.storyId!==e||i.parameters!==void 0||i.configurationError!==void 0||i.storybookError!==void 0)&&(i=u(e)),i.parameters=t,l(),i.generation},completeStory(e,t){let n=o.get(t);!n||n.storyId!==e||n.configurationError||n.storybookError||s.includes(t)||s.push(t)},failConfiguration(n,r){c(),(!i||i.storyId!==n||i.parameters!==void 0)&&(i=u(n)),i.configurationError=r.message,t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:n,generation:i.generation,renderId:i.renderId,error:{kind:`configuration`,message:r.message}})},failStorybook(n){c(),i&&(i.storybookError=n.message,t({protocolVersion:4,captureContractVersion:1,adapterVersion:e,state:`error`,storyId:i.storyId,generation:i.generation,renderId:i.renderId,error:{kind:`storybook`,message:n.message}}))},handlePhase(e){if(e.newPhase===`loading`){c(),u(e.storyId,e.renderId),l();return}i?.storyId===e.storyId&&(i.renderId=e.renderId)},handleFinished(e){let t=s.findIndex(t=>o.get(t)?.storyId===e.storyId),n=t<0?void 0:s.splice(t,1)[0],r=n===void 0?i:o.get(n);!r||r.storyId!==e.storyId||r.configurationError||r.storybookError||(e.status!==`success`||n!==void 0)&&d(r,e.status)},dispose(){c(),i=void 0,o.clear(),s.length=0}}}const Lo=Oo(()=>Za([X(),Fa(),za(),Ua(),Va(),Ja(Lo),ro(X(),Lo)])),Ro=$({name:X(),width:Fa(),height:Fa()}),zo=$({kapture:$({captureViewports:Ja(Za([X(),Ro])).optional(),captureEnabled:Q().optional(),captureArea:Q().optional(),captureDelayMs:Q().optional(),waitForElement:Q().optional(),animationState:Q().optional(),maskSelectors:Q().optional(),diffIgnoreSelectors:Q().optional(),waitForFonts:Q().optional(),fontAssertions:Q().optional(),diff:Q().optional()},{error:`parameters.kapture must be an object`}).optional(),viewport:Q().optional()},{error:`Storybook parameters must be an object`}),Bo=Ao({input:[X(),Q()]}).implement((e,t)=>{try{let e=zo.parse(t),n=e.kapture??{},r=n.captureViewports?.map(t=>{let n=X().safeParse(t);if(!n.success)return Ro.parse(t);let r=n.data;if(!r.trim())throw Error(`captureViewports entries must not be empty`);let i=$({options:ro(X(),Q())},{error:`parameters.viewport must be an object`}).parse(e.viewport).options,a=$({styles:$({width:Q().optional(),height:Q().optional()}).optional()},{error:`viewport option ${r} must be an object`}).parse(i[r]);return{name:r,width:Vo(`${r}.styles.width`).parse(a.styles?.width),height:Vo(`${r}.styles.height`).parse(a.styles?.height)}});return o(Lo.parse({...n,captureViewports:r}))}catch(t){let n=t instanceof ea?t.issues[0]?.message??t.message:t instanceof Error?t.message:String(t);throw Error(`Kapture story ${e}: ${n}`,{cause:t})}});function Vo(e){return X({error:`${e} must be an exact pixel dimension`}).trim().regex(/^\d+px$/,`${e} must use an exact pixel dimension such as 360px`).transform(e=>Number(e.slice(0,-2))).refine(e=>e>0,`${e} must be positive`)}function Ho(e){Object.defineProperty(globalThis,"__KAPTURE_STORYBOOK__",{value:e,writable:!0,enumerable:!0,configurable:!0})}function Uo(){let o=Io(Po,Ho),s=new WeakMap;return i({beforeAll(){o.boot();let i=a.getChannel(),s=e=>o.handlePhase(e),c=e=>o.handleFinished(e),l=e=>o.failStorybook(Wo(e));return i.on(n,s),i.on(t,c),i.on(e,l),i.on(r,l),()=>{i.off(n,s),i.off(t,c),i.off(e,l),i.off(r,l),o.dispose()}},beforeEach(e){try{let t=o.startStory(e.id,Bo(e.id,e.parameters));s.set(e,t)}catch(t){let n=t instanceof Error?t:Error(String(t));throw o.failConfiguration(e.id,n),n}},afterEach(e){let t=s.get(e);t!==void 0&&o.completeStory(e.id,t)}})}function Wo(e){let t=Array.isArray(e)?e[0]:e,n=$({message:X().refine(e=>e.trim().length>0)}).safeParse(t);return Error(n.success?`Storybook play function failed: ${n.data.message}`:`Storybook play function failed.`)}const Go=Uo;var Ko=Uo;export{Ko as default,Go as kapture};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaptures/storybook",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "Typed Storybook lifecycle adapter for Kapture visual review",
5
5
  "type": "module",
6
6
  "license": "MIT",