1 line
3.2 KiB
JavaScript
1 line
3.2 KiB
JavaScript
import{u as b}from"./stringify-DnirLPRY.js";let p;const A=new Uint8Array(16);function S(){if(!p&&(p=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!p))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return p(A)}const x=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),f={randomUUID:x};function D(e,t,n){if(f.randomUUID&&!t&&!e)return f.randomUUID();e=e||{};const r=e.random||(e.rng||S)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,b(r)}const{addons:I}=__STORYBOOK_MODULE_PREVIEW_API__,{global:d}=__STORYBOOK_MODULE_GLOBAL__,{ImplicitActionsDuringRendering:v}=__STORYBOOK_MODULE_CORE_EVENTS_PREVIEW_ERRORS__;var w="storybook/actions",U=`${w}/action-event`,j={depth:10,clearOnStoryChange:!0,limit:50},R=(e,t)=>{let n=Object.getPrototypeOf(e);return!n||t(n)?n:R(n,t)},V=e=>!!(typeof e=="object"&&e&&R(e,t=>/^Synthetic(?:Base)?Event$/.test(t.constructor.name))&&typeof e.persist=="function"),C=e=>{if(V(e)){let t=Object.create(e.constructor.prototype,Object.getOwnPropertyDescriptors(e));t.persist();let n=Object.getOwnPropertyDescriptor(t,"view"),r=n==null?void 0:n.value;return typeof r=="object"&&(r==null?void 0:r.constructor.name)==="Window"&&Object.defineProperty(t,"view",{...n,value:Object.create(r.constructor.prototype)}),t}return e},K=()=>typeof crypto=="object"&&typeof crypto.getRandomValues=="function"?D():Date.now().toString(36)+Math.random().toString(36).substring(2);function _(e,t={}){let n={...j,...t},r=function(...i){var u,O;if(t.implicit){let g=(u="__STORYBOOK_PREVIEW__"in d?d.__STORYBOOK_PREVIEW__:void 0)==null?void 0:u.storyRenders.find(c=>c.phase==="playing"||c.phase==="rendering");if(g){let c=!((O=window==null?void 0:window.FEATURES)!=null&&O.disallowImplicitActionsInRenderV8),y=new v({phase:g.phase,name:e,deprecated:c});if(c)console.warn(y);else throw y}}let o=I.getChannel(),s=K(),a=5,l=i.map(C),E=i.length>1?l:l[0],T={id:s,count:0,data:{name:e,args:E},options:{...n,maxDepth:a+(n.depth||3),allowFunction:n.allowFunction||!1}};o.emit(U,T)};return r.isAction=!0,r.implicit=t.implicit,r}var h=(e,t)=>typeof t[e]>"u"&&!(e in t),L=e=>{let{initialArgs:t,argTypes:n,id:r,parameters:{actions:i}}=e;if(!i||i.disable||!i.argTypesRegex||!n)return{};let o=new RegExp(i.argTypesRegex);return Object.entries(n).filter(([s])=>!!o.test(s)).reduce((s,[a,l])=>(h(a,t)&&(s[a]=_(a,{implicit:!0,id:r})),s),{})},B=e=>{let{initialArgs:t,argTypes:n,parameters:{actions:r}}=e;return r!=null&&r.disable||!n?{}:Object.entries(n).filter(([i,o])=>!!o.action).reduce((i,[o,s])=>(h(o,t)&&(i[o]=_(typeof s.action=="string"?s.action:o)),i),{})},Y=[B,L],m=!1,M=e=>{let{parameters:{actions:t}}=e;if(!(t!=null&&t.disable)&&!m&&"__STORYBOOK_TEST_ON_MOCK_CALL__"in d&&typeof d.__STORYBOOK_TEST_ON_MOCK_CALL__=="function"){let n=d.__STORYBOOK_TEST_ON_MOCK_CALL__;n((r,i)=>{let o=r.getMockName();o!=="spy"&&(!/^next\/.*::/.test(o)||["next/router::useRouter()","next/navigation::useRouter()","next/navigation::redirect","next/cache::","next/headers::cookies().set","next/headers::cookies().delete","next/headers::headers().set","next/headers::headers().delete"].some(s=>o.startsWith(s)))&&_(o)(i)}),m=!0}},N=[M];export{Y as argsEnhancers,N as loaders};
|