113 lines
342 KiB
JavaScript
113 lines
342 KiB
JavaScript
|
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __require=(x2=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x2,{get:(a,b2)=>(typeof require<"u"?require:a)[b2]}):x2)(function(x2){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x2+'" is not supported')});var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __export=(target,all)=>{for(var name2 in all)__defProp(target,name2,{get:all[name2],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key2 of __getOwnPropNames(from))!__hasOwnProp.call(to,key2)&&key2!==except&&__defProp(to,key2,{get:()=>from[key2],enumerable:!(desc=__getOwnPropDesc(from,key2))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));var require_memoizerific=__commonJS({"../../node_modules/memoizerific/memoizerific.js"(exports,module){"use strict";(function(f3){if(typeof exports=="object"&&typeof module<"u")module.exports=f3();else if(typeof define=="function"&&define.amd)define([],f3);else{var g;typeof window<"u"?g=window:typeof global<"u"?g=global:typeof self<"u"?g=self:g=this,g.memoizerific=f3()}})(function(){var define2,module2,exports2;return function e(t,n,r){function s(o2,u2){if(!n[o2]){if(!t[o2]){var a=typeof __require=="function"&&__require;if(!u2&&a)return a(o2,!0);if(i)return i(o2,!0);var f3=new Error("Cannot find module '"+o2+"'");throw f3.code="MODULE_NOT_FOUND",f3}var l=n[o2]={exports:{}};t[o2][0].call(l.exports,function(e2){var n2=t[o2][1][e2];return s(n2||e2)},l,l.exports,e,t,n,r)}return n[o2].exports}for(var i=typeof __require=="function"&&__require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module3,exports3){module3.exports=function(forceSimilar){if(typeof Map!="function"||forceSimilar){var Similar=_dereq_("./similar");return new Similar}else return new Map}},{"./similar":2}],2:[function(_dereq_,module3,exports3){function Similar(){return this.list=[],this.lastItem=void 0,this.size=0,this}Similar.prototype.get=function(key2){var index;if(this.lastItem&&this.isEqual(this.lastItem.key,key2))return this.lastItem.val;if(index=this.indexOf(key2),index>=0)return this.lastItem=this.list[index],this.list[index].val},Similar.prototype.set=function(key2,val){var index;return this.lastItem&&this.isEqual(this.lastItem.key,key2)?(this.lastItem.val=val,this):(index=this.indexOf(key2),index>=0?(this.lastItem=this.list[index],this.list[index].val=val,this):(this.lastItem={key:key2,val},this.list.push(this.lastItem),this.size++,this))},Similar.prototype.delete=function(key2){var index;if(this.lastItem&&this.isEqual(this.lastItem.key,key2)&&(this.lastItem=void 0),index=this.indexOf(key2),index>=0)return this.size--,this.list.splice(index,1)[0]},Similar.prototype.has=function(key2){var index;return this.lastItem&&this.isEqual(this.lastItem.key,key2)?!0:(index=this.indexOf(key2),index>=0?(this.lastItem=this.list[index],!0):!1)},Similar.prototype.forEach=function(callback,thisArg){var i;for(i=0;i<this.size;i++)callback.call(thisArg||this,this.list[i].val,this.list[i].key,this)},Similar.prototype.indexOf=function(key2){var i;for(i=0;i<this.size;i++)if(this.isEqual(this.list[i].key,key2))return i;return-1},Similar.prototype.isEqual=function(val1,val2){return val1===val2||val1!==val1&&val2!==val2},module3.exports=Similar},{}],3:[function(_dereq_,module3,exports3){var MapOrSimilar=_dereq_("map-or-similar");module3.exports=function(limit){var cache=new MapOrSimilar(!1),lru=[];return function(fn){var memoizerific=function(){var currentCache=cache,newMap,fnResult,argsLengthMinusOne=arguments.length-1,lruPath=Array(argsLengthMinusOne+1
|
||
|
`)>=0)return!1;return!0}function getIndent(opts,depth){var baseIndent;if(opts.indent===" ")baseIndent=" ";else if(typeof opts.indent=="number"&&opts.indent>0)baseIndent=$join.call(Array(opts.indent+1)," ");else return null;return{base:baseIndent,prev:$join.call(Array(depth+1),baseIndent)}}function indentedJoin(xs,indent){if(xs.length===0)return"";var lineJoiner=`
|
||
|
`+indent.prev+indent.base;return lineJoiner+$join.call(xs,","+lineJoiner)+`
|
||
|
`+indent.prev}function arrObjKeys(obj,inspect){var isArr=isArray2(obj),xs=[];if(isArr){xs.length=obj.length;for(var i=0;i<obj.length;i++)xs[i]=has2(obj,i)?inspect(obj[i],obj):""}var syms=typeof gOPS=="function"?gOPS(obj):[],symMap;if(hasShammedSymbols){symMap={};for(var k=0;k<syms.length;k++)symMap["$"+syms[k]]=syms[k]}for(var key2 in obj)has2(obj,key2)&&(isArr&&String(Number(key2))===key2&&key2<obj.length||hasShammedSymbols&&symMap["$"+key2]instanceof Symbol||($test.call(/[^\w$]/,key2)?xs.push(inspect(key2,obj)+": "+inspect(obj[key2],obj)):xs.push(key2+": "+inspect(obj[key2],obj))));if(typeof gOPS=="function")for(var j=0;j<syms.length;j++)isEnumerable.call(obj,syms[j])&&xs.push("["+inspect(syms[j])+"]: "+inspect(obj[syms[j]],obj));return xs}}});var require_side_channel=__commonJS({"../../node_modules/side-channel/index.js"(exports,module){"use strict";var GetIntrinsic=require_get_intrinsic2(),callBound=require_callBound2(),inspect=require_object_inspect(),$TypeError=GetIntrinsic("%TypeError%"),$WeakMap=GetIntrinsic("%WeakMap%",!0),$Map=GetIntrinsic("%Map%",!0),$weakMapGet=callBound("WeakMap.prototype.get",!0),$weakMapSet=callBound("WeakMap.prototype.set",!0),$weakMapHas=callBound("WeakMap.prototype.has",!0),$mapGet=callBound("Map.prototype.get",!0),$mapSet=callBound("Map.prototype.set",!0),$mapHas=callBound("Map.prototype.has",!0),listGetNode=function(list,key2){for(var prev=list,curr;(curr=prev.next)!==null;prev=curr)if(curr.key===key2)return prev.next=curr.next,curr.next=list.next,list.next=curr,curr},listGet=function(objects,key2){var node=listGetNode(objects,key2);return node&&node.value},listSet=function(objects,key2,value2){var node=listGetNode(objects,key2);node?node.value=value2:objects.next={key:key2,next:objects.next,value:value2}},listHas=function(objects,key2){return!!listGetNode(objects,key2)};module.exports=function(){var $wm,$m,$o,channel={assert:function(key2){if(!channel.has(key2))throw new $TypeError("Side channel does not contain "+inspect(key2))},get:function(key2){if($WeakMap&&key2&&(typeof key2=="object"||typeof key2=="function")){if($wm)return $weakMapGet($wm,key2)}else if($Map){if($m)return $mapGet($m,key2)}else if($o)return listGet($o,key2)},has:function(key2){if($WeakMap&&key2&&(typeof key2=="object"||typeof key2=="function")){if($wm)return $weakMapHas($wm,key2)}else if($Map){if($m)return $mapHas($m,key2)}else if($o)return listHas($o,key2);return!1},set:function(key2,value2){$WeakMap&&key2&&(typeof key2=="object"||typeof key2=="function")?($wm||($wm=new $WeakMap),$weakMapSet($wm,key2,value2)):$Map?($m||($m=new $Map),$mapSet($m,key2,value2)):($o||($o={key:{},next:null}),listSet($o,key2,value2))}};return channel}}});var require_formats=__commonJS({"../../node_modules/qs/lib/formats.js"(exports,module){"use strict";var replace=String.prototype.replace,percentTwenties=/%20/g,Format={RFC1738:"RFC1738",RFC3986:"RFC3986"};module.exports={default:Format.RFC3986,formatters:{RFC1738:function(value2){return replace.call(value2,percentTwenties,"+")},RFC3986:function(value2){return String(value2)}},RFC1738:Format.RFC1738,RFC3986:Format.RFC3986}}});var require_utils=__commonJS({"../../node_modules/qs/lib/utils.js"(exports,module){"use strict";var formats=require_formats(),has2=Object.prototype.hasOwnProperty,isArray2=Array.isArray,hexTable=function(){for(var array=[],i=0;i<256;++i)array.push("%"+((i<16?"0":"")+i.toString(16)).toUpperCase());return array}(),compactQueue=function(queue){for(;queue.length>1;){var item=queue.pop(),obj=item.obj[item.prop];if(isArray2(obj)){for(var compacted=[],j=0;j<obj.length;++j)typeof obj[j]<"u"&&compacted.push(obj[j]);item.obj[item.prop]=compacted}}},arrayToObject=function(source2,options2){for(var obj=options2&&options2.plainObjects?Object.create(null):{},i=0;i<source2.length;++i)typeof source2[i]<"u"&&(obj[i]=source2[i]);return obj},merge=function merge2(target,source2,options2){if(!source2)return target;if(typeof source2!="object"){if(isArray2(target))target.push(source2);else if(target&&typeof target=="object")(options2&&(options2.plainObjects||options2.allowPrototypes)|
|
||
|
`&&inQuoteChar!=="`")&&(inQuoteChar=null),inRegexLiteral&&(code[i]==="/"&&code[i-1]!=="\\"||code[i]===`
|
||
|
`)&&(inRegexLiteral=!1),inBlockComment&&code[i-1]==="/"&&code[i-2]==="*"&&(inBlockComment=!1),inLineComment&&code[i]===`
|
||
|
`&&(inLineComment=!1)),!inBlockComment&&!inLineComment&&(newCode+=code[i]);else newCode=code;return newCode},cleanCode=(0,import_memoizerific.default)(1e4)(code=>removeCodeComments(code).replace(/\n\s*/g,"").trim()),convertShorthandMethods=function(key2,stringified){let fnHead=stringified.slice(0,stringified.indexOf("{")),fnBody=stringified.slice(stringified.indexOf("{"));if(fnHead.includes("=>")||fnHead.includes("function"))return stringified;let modifiedHead=fnHead;return modifiedHead=modifiedHead.replace(key2,"function"),modifiedHead+fnBody},dateFormat=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/,isJSON=input=>input.match(/^[\[\{\"\}].*[\]\}\"]$/);function convertUnconventionalData(data){if(!isObject3(data))return data;let result2=data,wasMutated=!1;return typeof Event<"u"&&data instanceof Event&&(result2=extractEventHiddenProperties(result2),wasMutated=!0),result2=Object.keys(result2).reduce((acc,key2)=>{try{result2[key2]&&result2[key2].toJSON,acc[key2]=result2[key2]}catch{wasMutated=!0}return acc},{}),wasMutated?result2:data}var replacer=function(options2){let objects,map2,stack,keys;return function(key2,value2){try{if(key2==="")return keys=[],objects=new Map([[value2,"[]"]]),map2=new Map,stack=[],value2;let origin=map2.get(this)||this;for(;stack.length&&origin!==stack[0];)stack.shift(),keys.pop();if(typeof value2=="boolean")return value2;if(value2===void 0)return options2.allowUndefined?"_undefined_":void 0;if(value2===null)return null;if(typeof value2=="number")return value2===-1/0?"_-Infinity_":value2===1/0?"_Infinity_":Number.isNaN(value2)?"_NaN_":value2;if(typeof value2=="bigint")return`_bigint_${value2.toString()}`;if(typeof value2=="string")return dateFormat.test(value2)?options2.allowDate?`_date_${value2}`:void 0:value2;if((0,import_is_regex.default)(value2))return options2.allowRegExp?`_regexp_${value2.flags}|${value2.source}`:void 0;if((0,import_is_function.default)(value2)){if(!options2.allowFunction)return;let{name:name2}=value2,stringified=value2.toString();return stringified.match(/(\[native code\]|WEBPACK_IMPORTED_MODULE|__webpack_exports__|__webpack_require__)/)?`_function_${name2}|${(()=>{}).toString()}`:`_function_${name2}|${cleanCode(convertShorthandMethods(key2,stringified))}`}if((0,import_is_symbol.default)(value2)){if(!options2.allowSymbol)return;let globalRegistryKey=Symbol.keyFor(value2);return globalRegistryKey!==void 0?`_gsymbol_${globalRegistryKey}`:`_symbol_${value2.toString().slice(7,-1)}`}if(stack.length>=options2.maxDepth)return Array.isArray(value2)?`[Array(${value2.length})]`:"[Object]";if(value2===this)return`_duplicate_${JSON.stringify(keys)}`;if(value2 instanceof Error&&options2.allowError)return{__isConvertedError__:!0,errorProperties:{...value2.cause?{cause:value2.cause}:{},...value2,name:value2.name,message:value2.message,stack:value2.stack,"_constructor-name_":value2.constructor.name}};if(value2.constructor&&value2.constructor.name&&value2.constructor.name!=="Object"&&!Array.isArray(value2)&&!options2.allowClass)return;let found=objects.get(value2);if(!found){let converted=Array.isArray(value2)?value2:convertUnconventionalData(value2);if(value2.constructor&&value2.constructor.name&&value2.constructor.name!=="Object"&&!Array.isArray(value2)&&options2.allowClass)try{Object.assign(converted,{"_constructor-name_":value2.constructor.name})}catch{}return keys.push(key2),stack.unshift(converted),objects.set(value2,JSON.stringify(keys)),value2!==converted&&map2.set(value2,converted),converted}return`_duplicate_${found}`}catch{return}}},reviver2=function reviver(options){let refs=[],root;return function revive(key,value){if(key===""&&(root=value,refs.forEach(({target,container,replacement})=>{let replacementArr=isJSON(replacement)?JSON.parse(replacement):replacement.split(".");replacementArr.length===0?container[target]=root:container[target]=get_default(root,replacementArr)})),key==="_constructor-name_")return value;if(isObject3(value)&&value.__isConvertedError__){let{message,...properties}=value.errorProperties,error=new Error(message);return Object.assign(error,properties),er
|
||
|
Previous: ${hook.deps}
|
||
|
Incoming: ${deps}`),(deps==null||hook.deps==null||!areDepsEqual(deps,hook.deps))&&(callback(hook),hook.deps=deps),hook}throw invalidHooksError()}function useMemoLike(name2,nextCreate,deps){let{memoizedState}=useHook(name2,hook=>{hook.memoizedState=nextCreate()},deps);return memoizedState}function useMemo(nextCreate,deps){return useMemoLike("useMemo",nextCreate,deps)}function useCallback(callback,deps){return useMemoLike("useCallback",()=>callback,deps)}function useRefLike(name2,initialValue){return useMemoLike(name2,()=>({current:initialValue}),[])}function useRef(initialValue){return useRefLike("useRef",initialValue)}function triggerUpdate(){let hooks=getHooksContextOrNull();if(hooks!=null&&hooks.currentPhase!=="NONE")hooks.hasUpdates=!0;else try{addons.getChannel().emit(FORCE_RE_RENDER)}catch{logger.warn("State updates of Storybook preview hooks work only in browser")}}function useStateLike(name2,initialState){let stateRef=useRefLike(name2,typeof initialState=="function"?initialState():initialState),setState=update=>{stateRef.current=typeof update=="function"?update(stateRef.current):update,triggerUpdate()};return[stateRef.current,setState]}function useState(initialState){return useStateLike("useState",initialState)}function useReducer(reducer,initialArg,init){let initialState=init!=null?()=>init(initialArg):initialArg,[state,setState]=useStateLike("useReducer",initialState);return[state,action=>setState(prevState=>reducer(prevState,action))]}function useEffect(create,deps){let hooks=getHooksContextOrThrow(),effect=useMemoLike("useEffect",()=>({create}),deps);hooks.currentEffects.includes(effect)||hooks.currentEffects.push(effect)}function useChannel(eventMap,deps=[]){let channel=addons.getChannel();return useEffect(()=>(Object.entries(eventMap).forEach(([type,listener])=>channel.on(type,listener)),()=>{Object.entries(eventMap).forEach(([type,listener])=>channel.removeListener(type,listener))}),[...Object.keys(eventMap),...deps]),useCallback(channel.emit.bind(channel),[channel])}function useStoryContext(){let{currentContext}=getHooksContextOrThrow();if(currentContext==null)throw invalidHooksError();return currentContext}function useParameter(parameterKey,defaultValue){let{parameters}=useStoryContext();if(parameterKey)return parameters[parameterKey]??defaultValue}function useArgs(){let channel=addons.getChannel(),{id:storyId,args:args2}=useStoryContext(),updateArgs=useCallback(updatedArgs=>channel.emit(UPDATE_STORY_ARGS,{storyId,updatedArgs}),[channel,storyId]),resetArgs=useCallback(argNames=>channel.emit(RESET_STORY_ARGS,{storyId,argNames}),[channel,storyId]);return[args2,updateArgs,resetArgs]}function useGlobals(){let channel=addons.getChannel(),{globals}=useStoryContext(),updateGlobals=useCallback(newGlobals=>channel.emit(UPDATE_GLOBALS,{globals:newGlobals}),[channel]);return[globals,updateGlobals]}var import_memoizerific2=__toESM(require_memoizerific(),1),import_mapValues=__toESM(require_mapValues(),1),import_pick=__toESM(require_pick(),1),import_synchronous_promise=__toESM(require_synchronous_promise(),1);var StorybookError=class extends Error{constructor(){super(...arguments),this.data={},this.documentation=!1,this.fromStorybook=!0}get fullErrorCode(){let paddedCode=String(this.code).padStart(4,"0");return`SB_${this.category}_${paddedCode}`}get name(){let errorName=this.constructor.name;return`${this.fullErrorCode} (${errorName})`}get message(){let page;return this.documentation===!0?page=`https://storybook.js.org/error/${this.fullErrorCode}`:typeof this.documentation=="string"?page=this.documentation:Array.isArray(this.documentation)&&(page=`
|
||
|
${this.documentation.map(doc=>` - ${doc}`).join(`
|
||
|
`)}`),`${this.template()}${page!=null?`
|
||
|
|
||
|
More info: ${page}
|
||
|
`:""}`}};function dedent(templ){for(var values=[],_i=1;_i<arguments.length;_i++)values[_i-1]=arguments[_i];var strings=Array.from(typeof templ=="string"?[templ]:templ);strings[strings.length-1]=strings[strings.length-1].replace(/\r?\n([\t ]*)$/,"");var indentLengths=strings.reduce(function(arr,str){var matches2=str.match(/\n([\t ]+|(?!\s).)/g);return matches2?arr.concat(matches2.map(function(match){var _a,_b;return(_b=(_a=match.match(/[\t ]/g))===null||_a===void 0?void 0:_a.length)!==null&&_b!==void 0?_b:0})):arr},[]);if(indentLengths.length){var pattern_1=new RegExp(`
|
||
|
[ ]{`+Math.min.apply(Math,indentLengths)+"}","g");strings=strings.map(function(str){return str.replace(pattern_1,`
|
||
|
`)})}strings[0]=strings[0].replace(/^\r?\n/,"");var string=strings[0];return values.forEach(function(value2,i){var endentations=string.match(/(?:^|\n)( *)$/),endentation=endentations?endentations[1]:"",indentedValue=value2;typeof value2=="string"&&value2.includes(`
|
||
|
`)&&(indentedValue=String(value2).split(`
|
||
|
`).map(function(str,i2){return i2===0?str:""+endentation+str}).join(`
|
||
|
`)),string+=indentedValue+strings[i+1]}),string}var esm_default=dedent;var Category=(Category2=>(Category2.PREVIEW_CLIENT_LOGGER="PREVIEW_CLIENT-LOGGER",Category2.PREVIEW_CHANNELS="PREVIEW_CHANNELS",Category2.PREVIEW_CORE_EVENTS="PREVIEW_CORE-EVENTS",Category2.PREVIEW_INSTRUMENTER="PREVIEW_INSTRUMENTER",Category2.PREVIEW_API="PREVIEW_API",Category2.PREVIEW_REACT_DOM_SHIM="PREVIEW_REACT-DOM-SHIM",Category2.PREVIEW_ROUTER="PREVIEW_ROUTER",Category2.PREVIEW_THEMING="PREVIEW_THEMING",Category2.RENDERER_HTML="RENDERER_HTML",Category2.RENDERER_PREACT="RENDERER_PREACT",Category2.RENDERER_REACT="RENDERER_REACT",Category2.RENDERER_SERVER="RENDERER_SERVER",Category2.RENDERER_SVELTE="RENDERER_SVELTE",Category2.RENDERER_VUE="RENDERER_VUE",Category2.RENDERER_VUE3="RENDERER_VUE3",Category2.RENDERER_WEB_COMPONENTS="RENDERER_WEB-COMPONENTS",Category2))(Category||{}),MissingStoryAfterHmrError=class extends StorybookError{constructor(data){super(),this.data=data,this.category="PREVIEW_API",this.code=1}template(){return esm_default`
|
||
|
Couldn't find story matching id '${this.data.storyId}' after HMR.
|
||
|
- Did you just rename a story?
|
||
|
- Did you remove it from your CSF file?
|
||
|
- Are you sure a story with the id '${this.data.storyId}' exists?
|
||
|
- Please check the values in the stories field of your main.js config and see if they would match your CSF File.
|
||
|
- Also check the browser console and terminal for potential error messages.`}};var has=Object.prototype.hasOwnProperty;function find(iter,tar,key2){for(key2 of iter.keys())if(dequal(key2,tar))return key2}function dequal(foo,bar){var ctor,len,tmp;if(foo===bar)return!0;if(foo&&bar&&(ctor=foo.constructor)===bar.constructor){if(ctor===Date)return foo.getTime()===bar.getTime();if(ctor===RegExp)return foo.toString()===bar.toString();if(ctor===Array){if((len=foo.length)===bar.length)for(;len--&&dequal(foo[len],bar[len]););return len===-1}if(ctor===Set){if(foo.size!==bar.size)return!1;for(len of foo)if(tmp=len,tmp&&typeof tmp=="object"&&(tmp=find(bar,tmp),!tmp)||!bar.has(tmp))return!1;return!0}if(ctor===Map){if(foo.size!==bar.size)return!1;for(len of foo)if(tmp=len[0],tmp&&typeof tmp=="object"&&(tmp=find(bar,tmp),!tmp)||!dequal(len[1],bar.get(tmp)))return!1;return!0}if(ctor===ArrayBuffer)foo=new Uint8Array(foo),bar=new Uint8Array(bar);else if(ctor===DataView){if((len=foo.byteLength)===bar.byteLength)for(;len--&&foo.getInt8(len)===bar.getInt8(len););return len===-1}if(ArrayBuffer.isView(foo)){if((len=foo.byteLength)===bar.byteLength)for(;len--&&foo[len]===bar[len];);return len===-1}if(!ctor||typeof foo=="object"){len=0;for(ctor in foo)if(has.call(foo,ctor)&&++len&&!has.call(bar,ctor)||!(ctor in bar)||!dequal(foo[ctor],bar[ctor]))return!1;return Object.keys(bar).length===len}}return foo!==foo&&bar!==bar}var import_isPlainObject=__toESM(require_isPlainObject(),1);var B=Object.create,R=Object.defineProperty,b=Object.getOwnPropertyDescriptor,C=Object.getOwnPropertyNames,h=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty,I=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),E=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of C(e))!w.call(r,a)&&a!==n&&R(r,a,{get:()=>e[a],enumerable:!(t=b(e,a))||t.enumerable});return r},v=(r,e,n)=>(n=r!=null?B(h(r)):{},E(e||!r||!r.__esModule?R(n,"default",{value:r,enumerable:!0}):n,r)),x=I(T=>{Object.defineProperty(T,"__esModule",{value:!0}),T.isEqual=function(){var r=Object.prototype.toString,e=Object.getPrototypeOf,n=Object.getOwnPropertySymbols?function(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}:Object.keys;return function(t,a){return function i(o,s,p){var y,g,d,A=r.call(o),F=r.call(s);if(o===s)return!0;if(o==null||s==null)return!1;if(p.indexOf(o)>-1&&p.indexOf(s)>-1)return!0;if(p.push(o,s),A!=F||(y=n(o),g=n(s),y.length!=g.length||y.some(function(l){return!i(o[l],s[l],p)})))return!1;switch(A.slice(8,-1)){case"Symbol":return o.valueOf()==s.valueOf();case"Date":case"Number":return+o==+s||+o!=+o&&+s!=+s;case"RegExp":case"Function":case"String":case"Boolean":return""+o==""+s;case"Set":case"Map":y=o.entries(),g=s.entries();do if(!i((d=y.next()).value,g.next().value,p))return!1;while(!d.done);return!0;case"ArrayBuffer":o=new Uint8Array(o),s=new Uint8Array(s);case"DataView":o=new Uint8Array(o.buffer),s=new Uint8Array(s.buffer);case"Float32Array":case"Float64Array":case"Int8Array":case"Int16Array":case"Int32Array":case"Uint8Array":case"Uint16Array":case"Uint32Array":case"Uint8ClampedArray":case"Arguments":case"Array":if(o.length!=s.length)return!1;for(d=0;d<o.length;d++)if((d in o||d in s)&&(d in o!=d in s||!i(o[d],s[d],p)))return!1;return!0;case"Object":return i(e(o),e(s),p);default:return!1}}(t,a,[])}}()});function u(r){return r.replace(/_/g," ").replace(/-/g," ").replace(/\./g," ").replace(/([^\n])([A-Z])([a-z])/g,(e,n,t,a)=>`${n} ${t}${a}`).replace(/([a-z])([A-Z])/g,(e,n,t)=>`${n} ${t}`).replace(/([a-z])([0-9])/gi,(e,n,t)=>`${n} ${t}`).replace(/([0-9])([a-z])/gi,(e,n,t)=>`${n} ${t}`).replace(/(\s|^)(\w)/g,(e,n,t)=>`${n}${t.toUpperCase()}`).replace(/ +/g," ").trim()}var c=v(x()),S=r=>r.map(e=>typeof e<"u").filter(Boolean).length,P=(r,e)=>{let{exists:n,eq:t,neq:a,truthy:i}=r;if(S([n,t,a,i])>1)throw new Error(`Invalid conditional test ${JSON.stringify({exists:n,eq:t,neq:a})}`);if(typeof t<"u")return(0,c.isEqual)(e,t);if(typeof a<"u")return!(0,c.isEqual)(e,a);if(typeof n<"u"){let s=typeof e<"u";return n?s:!s}return typeof i>"u"||i?!!e:!e},O=(r,e,n)
|
||
|
Invalid argType: '${key2}.options' should be an array.
|
||
|
|
||
|
More info: https://storybook.js.org/docs/react/api/argtypes
|
||
|
`),allowArg();if(options2.some(opt=>opt&&["object","function"].includes(typeof opt)))return once.error(dedent`
|
||
|
Invalid argType: '${key2}.options' should only contain primitives. Use a 'mapping' for complex values.
|
||
|
|
||
|
More info: https://storybook.js.org/docs/react/writing-stories/args#mapping-to-complex-arg-values
|
||
|
`),allowArg();let isArray2=Array.isArray(args2[key2]),invalidIndex=isArray2&&args2[key2].findIndex(val=>!options2.includes(val)),isValidArray=isArray2&&invalidIndex===-1;if(args2[key2]===void 0||options2.includes(args2[key2])||isValidArray)return allowArg();let field=isArray2?`${key2}[${invalidIndex}]`:key2,supportedOptions=options2.map(opt=>typeof opt=="string"?`'${opt}'`:String(opt)).join(", ");return once.warn(`Received illegal value for '${field}'. Supported options: ${supportedOptions}`),acc},{}),DEEPLY_EQUAL=Symbol("Deeply equal"),deepDiff=(value2,update)=>{if(typeof value2!=typeof update)return update;if(dequal(value2,update))return DEEPLY_EQUAL;if(Array.isArray(value2)&&Array.isArray(update)){let res=update.reduce((acc,upd,index)=>{let diff=deepDiff(value2[index],upd);return diff!==DEEPLY_EQUAL&&(acc[index]=diff),acc},new Array(update.length));return update.length>=value2.length?res:res.concat(new Array(value2.length-update.length).fill(void 0))}return(0,import_isPlainObject.default)(value2)&&(0,import_isPlainObject.default)(update)?Object.keys({...value2,...update}).reduce((acc,key2)=>{let diff=deepDiff(value2?.[key2],update?.[key2]);return diff===DEEPLY_EQUAL?acc:Object.assign(acc,{[key2]:diff})},{}):update},UNTARGETED="UNTARGETED";function groupArgsByTarget({args:args2,argTypes}){let groupedArgs={};return Object.entries(args2).forEach(([name2,value2])=>{let{target=UNTARGETED}=argTypes[name2]||{};groupedArgs[target]=groupedArgs[target]||{},groupedArgs[target][name2]=value2}),groupedArgs}function noTargetArgs(context){return groupArgsByTarget(context)[UNTARGETED]}function deleteUndefined(obj){return Object.keys(obj).forEach(key2=>obj[key2]===void 0&&delete obj[key2]),obj}var ArgsStore=class{constructor(){this.initialArgsByStoryId={},this.argsByStoryId={}}get(storyId){if(!(storyId in this.argsByStoryId))throw new Error(`No args known for ${storyId} -- has it been rendered yet?`);return this.argsByStoryId[storyId]}setInitial(story){if(!this.initialArgsByStoryId[story.id])this.initialArgsByStoryId[story.id]=story.initialArgs,this.argsByStoryId[story.id]=story.initialArgs;else if(this.initialArgsByStoryId[story.id]!==story.initialArgs){let delta=deepDiff(this.initialArgsByStoryId[story.id],this.argsByStoryId[story.id]);this.initialArgsByStoryId[story.id]=story.initialArgs,this.argsByStoryId[story.id]=story.initialArgs,delta!==DEEPLY_EQUAL&&this.updateFromDelta(story,delta)}}updateFromDelta(story,delta){let validatedDelta=validateOptions(delta,story.argTypes);this.argsByStoryId[story.id]=combineArgs(this.argsByStoryId[story.id],validatedDelta)}updateFromPersisted(story,persisted){let mappedPersisted=mapArgsToTypes(persisted,story.argTypes);return this.updateFromDelta(story,mappedPersisted)}update(storyId,argsUpdate){if(!(storyId in this.argsByStoryId))throw new Error(`No args known for ${storyId} -- has it been rendered yet?`);this.argsByStoryId[storyId]=deleteUndefined({...this.argsByStoryId[storyId],...argsUpdate})}},getValuesFromArgTypes=(argTypes={})=>Object.entries(argTypes).reduce((acc,[arg,{defaultValue}])=>(typeof defaultValue<"u"&&(acc[arg]=defaultValue),acc),{}),GlobalsStore=class{constructor({globals={},globalTypes={}}){this.set({globals,globalTypes})}set({globals={},globalTypes={}}){let delta=this.initialGlobals&&deepDiff(this.initialGlobals,this.globals);this.allowedGlobalNames=new Set([...Object.keys(globals),...Object.keys(globalTypes)]);let defaultGlobals=getValuesFromArgTypes(globalTypes);this.initialGlobals={...defaultGlobals,...globals},this.globals=this.initialGlobals,delta&&delta!==DEEPLY_EQUAL&&this.updateFromPersisted(delta)}filterAllowedGlobals(globals){return Object.entries(globals).reduce((acc,[key2,value2])=>(this.allowedGlobalNames.has(key2)?acc[key2]=value2:logger.warn(`Attempted to set a global (${key2}) that is not defined in initial globals or globalTypes`),acc),{})}updateFromPersisted(persisted){let allowedUrlGlobals=this.filterAllowedGlobals(persisted);this.globals={...this.globals,...allowedUrlGlobals}}get(){return this.globals}update(newGlobals){this.globals={...this.globals
|
||
|
CSF .story annotations deprecated; annotate story functions directly:
|
||
|
- StoryFn.story.name => StoryFn.storyName
|
||
|
- StoryFn.story.(parameters|decorators) => StoryFn.(parameters|decorators)
|
||
|
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations for details and codemod.
|
||
|
`,deprecatedStoryAnnotationWarning=(0,import_util_deprecate.default)(()=>{},deprecatedStoryAnnotation);function normalizeStory(key2,storyAnnotations,meta){let storyObject=storyAnnotations,userStoryFn=typeof storyAnnotations=="function"?storyAnnotations:null,{story}=storyObject;story&&(logger.debug("deprecated story",story),deprecatedStoryAnnotationWarning());let exportName=M(key2),name2=typeof storyObject!="function"&&storyObject.name||storyObject.storyName||story?.name||exportName,decorators=[...normalizeArrays(storyObject.decorators),...normalizeArrays(story?.decorators)],parameters={...story?.parameters,...storyObject.parameters},args2={...story?.args,...storyObject.args},argTypes={...story?.argTypes,...storyObject.argTypes},loaders=[...normalizeArrays(storyObject.loaders),...normalizeArrays(story?.loaders)],{render,play,tags=[]}=storyObject,id=parameters.__id||N(meta.id,exportName);return{moduleExport:storyAnnotations,id,name:name2,tags,decorators,parameters,args:args2,argTypes:normalizeInputTypes(argTypes),loaders,...render&&{render},...userStoryFn&&{userStoryFn},...play&&{play}}}function normalizeComponentAnnotations(defaultExport,title=defaultExport.title,importPath){let{id,argTypes}=defaultExport;return{id:L(id||title),...defaultExport,title,...argTypes&&{argTypes:normalizeInputTypes(argTypes)},parameters:{fileName:importPath,...defaultExport.parameters}}}var checkGlobals=parameters=>{let{globals,globalTypes}=parameters;(globals||globalTypes)&&logger.error("Global args/argTypes can only be set globally",JSON.stringify({globals,globalTypes}))},checkStorySort=parameters=>{let{options:options2}=parameters;options2?.storySort&&logger.error("The storySort option parameter can only be set globally")},checkDisallowedParameters=parameters=>{parameters&&(checkGlobals(parameters),checkStorySort(parameters))},checkSubcomponents=meta=>{meta.subcomponents&&deprecate(esm_default`The \`subcomponents\` annotation is deprecated.
|
||
|
|
||
|
Please refer to the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#argstable-block'
|
||
|
`)};function processCSFFile(moduleExports,importPath,title){let{default:defaultExport,__namedExportsOrder,...namedExports}=moduleExports,meta=normalizeComponentAnnotations(defaultExport,title,importPath);checkDisallowedParameters(meta.parameters),checkSubcomponents(meta);let csfFile={meta,stories:{},moduleExports};return Object.keys(namedExports).forEach(key2=>{if(G(key2,meta)){let storyMeta=normalizeStory(key2,namedExports[key2],meta);checkDisallowedParameters(storyMeta.parameters),csfFile.stories[storyMeta.id]=storyMeta}}),csfFile}var combineParameters=(...parameterSets)=>{let mergeKeys={},definedParametersSets=parameterSets.filter(Boolean),combined=definedParametersSets.reduce((acc,parameters)=>(Object.entries(parameters).forEach(([key2,value2])=>{let existing=acc[key2];Array.isArray(value2)||typeof existing>"u"?acc[key2]=value2:(0,import_isPlainObject.default)(value2)&&(0,import_isPlainObject.default)(existing)?mergeKeys[key2]=!0:typeof value2<"u"&&(acc[key2]=value2)}),acc),{});return Object.keys(mergeKeys).forEach(key2=>{let mergeValues=definedParametersSets.filter(Boolean).map(p=>p[key2]).filter(value2=>typeof value2<"u");mergeValues.every(value2=>(0,import_isPlainObject.default)(value2))?combined[key2]=combineParameters(...mergeValues):combined[key2]=mergeValues[mergeValues.length-1]}),combined};function decorateStory(storyFn,decorator,bindWithContext){let boundStoryFunction=bindWithContext(storyFn);return context=>decorator(boundStoryFunction,context)}function sanitizeStoryContextUpdate({componentId,title,kind,id,name:name2,story,parameters,initialArgs,argTypes,...update}={}){return update}function defaultDecorateStory(storyFn,decorators){let contextStore={},bindWithContext=decoratedStoryFn=>update=>{if(!contextStore.value)throw new Error("Decorated function called without init");return contextStore.value={...contextStore.value,...sanitizeStoryContextUpdate(update)},decoratedStoryFn(contextStore.value)},decoratedWithContextStore=decorators.reduce((story,decorator)=>decorateStory(story,decorator,bindWithContext),storyFn);return context=>(contextStore.value=context,decoratedWithContextStore(context))}function prepareStory(storyAnnotations,componentAnnotations,projectAnnotations){let{moduleExport,id,name:name2}=storyAnnotations||{},partialAnnotations=preparePartialAnnotations(storyAnnotations,componentAnnotations,projectAnnotations),applyLoaders=async context=>{let updatedContext={...context,loaded:{}};for(let loaders of[..."__STORYBOOK_TEST_LOADERS__"in scope&&Array.isArray(scope.__STORYBOOK_TEST_LOADERS__)?[scope.__STORYBOOK_TEST_LOADERS__]:[],normalizeArrays(projectAnnotations.loaders),normalizeArrays(componentAnnotations.loaders),normalizeArrays(storyAnnotations.loaders)]){let loadResults=await Promise.all(loaders.map(loader=>loader(updatedContext))),loaded=Object.assign({},...loadResults);updatedContext={...updatedContext,loaded:{...updatedContext.loaded,...loaded}}}return updatedContext},undecoratedStoryFn=context=>{let{passArgsFirst:renderTimePassArgsFirst=!0}=context.parameters;return renderTimePassArgsFirst?render(context.args,context):render(context)},{applyDecorators=defaultDecorateStory,runStep}=projectAnnotations,decorators=[...normalizeArrays(storyAnnotations?.decorators),...normalizeArrays(componentAnnotations?.decorators),...normalizeArrays(projectAnnotations?.decorators)],render=storyAnnotations?.userStoryFn||storyAnnotations?.render||componentAnnotations.render||projectAnnotations.render;if(!render)throw new Error(`No render function available for storyId '${id}'`);let decoratedStoryFn=applyHooks(applyDecorators)(undecoratedStoryFn,decorators),unboundStoryFn=context=>decoratedStoryFn(context),play=storyAnnotations?.play||componentAnnotations.play;return{...partialAnnotations,moduleExport,id,name:name2,story:name2,originalStoryFn:render,undecoratedStoryFn,unboundStoryFn,applyLoaders,playFunction:play&&(async storyContext=>{let playFunctionContext={...storyContext,step:(label,play2)=>runStep(label,play2,playFunctionContext)};return play(playFunctionContext)})}}function prepareMeta(componentAnnot
|
||
|
We've detected a cycle in arg '${name2}'. Args should be JSON-serializable.
|
||
|
|
||
|
Consider using the mapping feature or fully custom args:
|
||
|
- Mapping: https://storybook.js.org/docs/react/writing-stories/args#mapping-to-complex-arg-values
|
||
|
- Custom args: https://storybook.js.org/docs/react/essentials/controls#fully-custom-args
|
||
|
`),{name:"other",value:"cyclic object"}):(visited.add(value2),Array.isArray(value2)?{name:"array",value:value2.length>0?inferType(value2[0],name2,new Set(visited)):{name:"other",value:"unknown"}}:{name:"object",value:(0,import_mapValues.default)(value2,field=>inferType(field,name2,new Set(visited)))}):{name:"object",value:{}}},inferArgTypes=context=>{let{id,argTypes:userArgTypes={},initialArgs={}}=context,argTypes=(0,import_mapValues.default)(initialArgs,(arg,key2)=>({name:key2,type:inferType(arg,`${id}.${key2}`,new Set)})),userArgTypesNames=(0,import_mapValues.default)(userArgTypes,(argType,key2)=>({name:key2}));return combineParameters(argTypes,userArgTypesNames,userArgTypes)};inferArgTypes.secondPass=!0;var matches=(name2,descriptor)=>Array.isArray(descriptor)?descriptor.includes(name2):name2.match(descriptor),filterArgTypes=(argTypes,include,exclude)=>!include&&!exclude?argTypes:argTypes&&(0,import_pickBy.default)(argTypes,(argType,key2)=>{let name2=argType.name||key2;return(!include||matches(name2,include))&&(!exclude||!matches(name2,exclude))}),inferControl=(argType,name2,matchers)=>{let{type,options:options2}=argType;if(type){if(matchers.color&&matchers.color.test(name2)){let controlType=type.name;if(controlType==="string")return{control:{type:"color"}};controlType!=="enum"&&logger.warn(`Addon controls: Control of type color only supports string, received "${controlType}" instead`)}if(matchers.date&&matchers.date.test(name2))return{control:{type:"date"}};switch(type.name){case"array":return{control:{type:"object"}};case"boolean":return{control:{type:"boolean"}};case"string":return{control:{type:"text"}};case"number":return{control:{type:"number"}};case"enum":{let{value:value2}=type;return{control:{type:value2?.length<=5?"radio":"select"},options:value2}}case"function":case"symbol":return null;default:return{control:{type:options2?"select":"object"}}}}},inferControls=context=>{let{argTypes,parameters:{__isArgsStory,controls:{include=null,exclude=null,matchers={}}={}}}=context;if(!__isArgsStory)return argTypes;let filteredArgTypes=filterArgTypes(argTypes,include,exclude),withControls=(0,import_mapValues.default)(filteredArgTypes,(argType,name2)=>argType?.type&&inferControl(argType,name2,matchers));return combineParameters(withControls,filteredArgTypes)};inferControls.secondPass=!0;function normalizeProjectAnnotations({argTypes,globalTypes,argTypesEnhancers,decorators,loaders,...annotations}){return{...argTypes&&{argTypes:normalizeInputTypes(argTypes)},...globalTypes&&{globalTypes:normalizeInputTypes(globalTypes)},decorators:normalizeArrays(decorators),loaders:normalizeArrays(loaders),argTypesEnhancers:[...argTypesEnhancers||[],inferArgTypes,inferControls],...annotations}}function composeStepRunners(stepRunners){return async(label,play,playContext)=>{await stepRunners.reduceRight((innerPlay,stepRunner)=>async()=>stepRunner(label,innerPlay,playContext),async()=>play(playContext))()}}function getField(moduleExportList,field){return moduleExportList.map(xs=>xs.default?.[field]??xs[field]).filter(Boolean)}function getArrayField(moduleExportList,field,options2={}){return getField(moduleExportList,field).reduce((a,b2)=>options2.reverseFileOrder?[...b2,...a]:[...a,...b2],[])}function getObjectField(moduleExportList,field){return Object.assign({},...getField(moduleExportList,field))}function getSingletonField(moduleExportList,field){return getField(moduleExportList,field).pop()}function composeConfigs(moduleExportList){let allArgTypeEnhancers=getArrayField(moduleExportList,"argTypesEnhancers"),stepRunners=getField(moduleExportList,"runStep");return{parameters:combineParameters(...getField(moduleExportList,"parameters")),decorators:getArrayField(moduleExportList,"decorators",{reverseFileOrder:!(scope.FEATURES?.legacyDecoratorFileOrder??!1)}),args:getObjectField(moduleExportList,"args"),argsEnhancers:getArrayField(moduleExportList,"argsEnhancers"),argTypes:getObjectField(moduleExportList,"argTypes"),argTypesEnhancers:[...allArgTypeEnhancers.filter(e=>!e.secondPass),...allArgTypeEnhancers.filter(e=>e.secondPass)],globals
|
||
|
CSF Auto-title received a numeric fileName. This typically happens when
|
||
|
webpack is mis-configured in production mode. To force webpack to produce
|
||
|
filenames, set optimization.moduleIds = "named" in your webpack config.
|
||
|
`);let normalizedFileName=slash(String(fileName));if(importPathMatcher.exec(normalizedFileName)){if(!userTitle){let suffix=normalizedFileName.replace(directory,""),path=slash(pathJoin([titlePrefix,suffix])).split("/");return path=stripExtension(path),path=removeRedundantFilename(path),path.join("/")}return titlePrefix?slash(pathJoin([titlePrefix,userTitle])):userTitle}},userOrAutoTitle=(fileName,storiesEntries,userTitle)=>{for(let i=0;i<storiesEntries.length;i+=1){let title=userOrAutoTitleFromSpecifier(fileName,storiesEntries[i],userTitle);if(title)return title}return userTitle||void 0},STORY_KIND_PATH_SEPARATOR=/\s*\/\s*/,storySort=(options2={})=>(a,b2)=>{if(a.title===b2.title&&!options2.includeNames)return 0;let method=options2.method||"configure",order=options2.order||[],storyTitleA=a.title.trim().split(STORY_KIND_PATH_SEPARATOR),storyTitleB=b2.title.trim().split(STORY_KIND_PATH_SEPARATOR);options2.includeNames&&(storyTitleA.push(a.name),storyTitleB.push(b2.name));let depth=0;for(;storyTitleA[depth]||storyTitleB[depth];){if(!storyTitleA[depth])return-1;if(!storyTitleB[depth])return 1;let nameA=storyTitleA[depth],nameB=storyTitleB[depth];if(nameA!==nameB){let indexA=order.indexOf(nameA),indexB=order.indexOf(nameB),indexWildcard=order.indexOf("*");return indexA!==-1||indexB!==-1?(indexA===-1&&(indexWildcard!==-1?indexA=indexWildcard:indexA=order.length),indexB===-1&&(indexWildcard!==-1?indexB=indexWildcard:indexB=order.length),indexA-indexB):method==="configure"?0:nameA.localeCompare(nameB,options2.locales?options2.locales:void 0,{numeric:!0,sensitivity:"accent"})}let index=order.indexOf(nameA);index===-1&&(index=order.indexOf("*")),order=index!==-1&&Array.isArray(order[index+1])?order[index+1]:[],depth+=1}return 0},sortStoriesCommon=(stories,storySortParameter,fileNameOrder)=>{if(storySortParameter){let sortFn;typeof storySortParameter=="function"?sortFn=storySortParameter:sortFn=storySort(storySortParameter),stories.sort(sortFn)}else stories.sort((s1,s2)=>fileNameOrder.indexOf(s1.importPath)-fileNameOrder.indexOf(s2.importPath));return stories},sortStoriesV7=(stories,storySortParameter,fileNameOrder)=>{try{return sortStoriesCommon(stories,storySortParameter,fileNameOrder)}catch(err){throw new Error(dedent`
|
||
|
Error sorting stories with sort parameter ${storySortParameter}:
|
||
|
|
||
|
> ${err.message}
|
||
|
|
||
|
Are you using a V6-style sort function in V7 mode?
|
||
|
|
||
|
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#v7-style-story-sort
|
||
|
`)}},toIndexEntry=story=>{let{id,title,name:name2,parameters,type}=story;return{id,title,name:name2,importPath:parameters.fileName,type}},sortStoriesV6=(stories,storySortParameter,fileNameOrder)=>{if(storySortParameter&&typeof storySortParameter=="function")return stories.sort(storySortParameter),stories.map(s=>toIndexEntry(s[1]));let storiesV7=stories.map(s=>toIndexEntry(s[1]));return sortStoriesCommon(storiesV7,storySortParameter,fileNameOrder)};var import_synchronous_promise2=__toESM(require_synchronous_promise(),1),import_qs2=__toESM(require_lib(),1),AUTODOCS_TAG="autodocs",STORIES_MDX_TAG="stories-mdx",StoryStoreFacade=class{constructor(){this.projectAnnotations={loaders:[],decorators:[],parameters:{},argsEnhancers:[],argTypesEnhancers:[],args:{},argTypes:{}},this.entries={},this.csfExports={}}importFn(path){return import_synchronous_promise2.SynchronousPromise.resolve().then(()=>{let moduleExports=this.csfExports[path];if(!moduleExports)throw new Error(`Unknown path: ${path}`);return moduleExports})}getStoryIndex(store){let fileNameOrder=Object.keys(this.csfExports),storySortParameter=this.projectAnnotations.parameters?.options?.storySort,sortableV6=Object.entries(this.entries).map(([storyId,{type,importPath,...entry}])=>{let exports=this.csfExports[importPath],csfFile=store.processCSFFileWithCache(exports,importPath,exports.default.title),storyLike;return type==="story"?storyLike=store.storyFromCSFFile({storyId,csfFile}):storyLike={...entry,story:entry.name,kind:entry.title,componentId:N(entry.componentId||entry.title),parameters:{fileName:importPath}},[storyId,storyLike,csfFile.meta.parameters,this.projectAnnotations.parameters||{}]}),sortedV7;try{sortedV7=sortStoriesV6(sortableV6,storySortParameter,fileNameOrder)}catch(err){throw typeof storySortParameter=="function"?new Error(dedent`
|
||
|
Error sorting stories with sort parameter ${storySortParameter}:
|
||
|
|
||
|
> ${err.message}
|
||
|
|
||
|
Are you using a V7-style sort function in V6 compatibility mode?
|
||
|
|
||
|
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#v7-style-story-sort
|
||
|
`):err}return{v:4,entries:sortedV7.reduce((acc,s)=>(acc[s.id]=this.entries[s.id],acc),{})}}clearFilenameExports(fileName){this.csfExports[fileName]&&(Object.entries(this.entries).forEach(([id,{importPath}])=>{importPath===fileName&&delete this.entries[id]}),this.csfExports[fileName]={})}addStoriesFromExports(fileName,fileExports){if(fileName.match(/\.mdx$/)&&!fileName.match(/\.stories\.mdx$/)&&scope.FEATURES?.storyStoreV7MdxErrors!==!1)throw new Error(dedent`
|
||
|
Cannot index \`.mdx\` file (\`${fileName}\`) in \`storyStoreV7: false\` mode.
|
||
|
|
||
|
The legacy story store does not support new-style \`.mdx\` files. If the file above
|
||
|
is not intended to be indexed (i.e. displayed as an entry in the sidebar), either
|
||
|
exclude it from your \`stories\` glob, or add <Meta isTemplate /> to it.
|
||
|
|
||
|
If you wanted to index the file, you'll need to name it \`stories.mdx\` and stick to the
|
||
|
legacy (6.x) MDX API, or use the new store.`);if(this.csfExports[fileName]===fileExports)return;this.clearFilenameExports(fileName);let{default:defaultExport,__namedExportsOrder,...namedExports}=fileExports,{id:componentId,title,tags:componentTags=[]}=defaultExport||{},specifiers=(scope.STORIES||[]).map(specifier=>({...specifier,importPathMatcher:new RegExp(specifier.importPathMatcher)}));if(title=userOrAutoTitle(fileName,specifiers,title),!title){logger.info(`Unexpected default export without title in '${fileName}': ${JSON.stringify(fileExports.default)}`);return}this.csfExports[fileName]={...fileExports,default:{...defaultExport,title}};let sortedExports=namedExports;Array.isArray(__namedExportsOrder)&&(sortedExports={},__namedExportsOrder.forEach(name2=>{let namedExport=namedExports[name2];namedExport&&(sortedExports[name2]=namedExport)}));let storyExports=Object.entries(sortedExports).filter(([key2])=>G(key2,defaultExport)),docsOptions=scope.DOCS_OPTIONS||{},{autodocs}=docsOptions,componentAutodocs=componentTags.includes(AUTODOCS_TAG),autodocsOptedIn=autodocs===!0||autodocs==="tag"&&componentAutodocs;if(storyExports.length&&(componentTags.includes(STORIES_MDX_TAG)||autodocsOptedIn)){let name2=docsOptions.defaultName,docsId=N(componentId||title,name2);this.entries[docsId]={type:"docs",id:docsId,title,name:name2,importPath:fileName,...componentId&&{componentId},tags:[...componentTags,"docs",...autodocsOptedIn&&!componentAutodocs?[AUTODOCS_TAG]:[]],storiesImports:[]}}storyExports.forEach(([key2,storyExport])=>{let exportName=M(key2),id=storyExport.parameters?.__id||N(componentId||title,exportName),name2=typeof storyExport!="function"&&storyExport.name||storyExport.storyName||storyExport.story?.name||exportName;storyExport.parameters?.docsOnly||(this.entries[id]={type:"story",id,name:name2,title,importPath:fileName,...componentId&&{componentId},tags:[...storyExport.tags||componentTags,"story"]})})}},warningAlternatives={addDecorator:"Instead, use `export const decorators = [];` in your `preview.js`.",addParameters:"Instead, use `export const parameters = {};` in your `preview.js`.",addLoader:"Instead, use `export const loaders = [];` in your `preview.js`.",addArgs:"",addArgTypes:"",addArgsEnhancer:"",addArgTypesEnhancer:"",addStepRunner:"",getGlobalRender:"",setGlobalRender:""},checkMethod=method=>{if(scope.FEATURES?.storyStoreV7)throw new Error(dedent`You cannot use \`${method}\` with the new Story Store.
|
||
|
|
||
|
${warningAlternatives[method]}`);if(!scope.__STORYBOOK_CLIENT_API__)throw new Error(`Singleton client API not yet initialized, cannot call \`${method}\`.`)},addDecorator=decorator=>{checkMethod("addDecorator"),scope.__STORYBOOK_CLIENT_API__?.addDecorator(decorator)},addParameters=parameters=>{checkMethod("addParameters"),scope.__STORYBOOK_CLIENT_API__?.addParameters(parameters)},addLoader=loader=>{checkMethod("addLoader"),scope.__STORYBOOK_CLIENT_API__?.addLoader(loader)},addArgs=args2=>{checkMethod("addArgs"),scope.__STORYBOOK_CLIENT_API__?.addArgs(args2)},addArgTypes=argTypes=>{checkMethod("addArgTypes"),scope.__STORYBOOK_CLIENT_API__?.addArgTypes(argTypes)},addArgsEnhancer=enhancer=>{checkMethod("addArgsEnhancer"),scope.__STORYBOOK_CLIENT_API__?.addArgsEnhancer(enhancer)},addArgTypesEnhancer=enhancer=>{checkMethod("addArgTypesEnhancer"),scope.__STORYBOOK_CLIENT_API__?.addArgTypesEnhancer(enhancer)},addStepRunner=stepRunner=>{checkMethod("addStepRunner"),scope.__STORYBOOK_CLIENT_API__?.addStepRunner(stepRunner)},setGlobalRender=render=>{checkMethod("setGlobalRender"),scope.__STORYBOOK_CLIENT_API__&&(scope.__STORYBOOK_CLIENT_API__.facade.projectAnnotations.render=render)},invalidStoryTypes=new Set(["string","number","boolean","symbol"]),ClientApi=class{constructor({storyStore}={}){this.lastFileName=0,this.addDecorator=decorator=>{this.facade.projectAnnotations.decorators?.push(decorator)},this.addParameters=({globals,globalTypes,...parameters})=>{this.facade.projectAnnotations.parameters=combineParameters(this.facade.projectAnnotations.parameters,parameters),globals&&(this.facade.projectAnnotations.globals={...this.facade.projectAnnotations.globals,...globals}),globalTypes&&(this.facade.projectAnnotations.globalTypes={...this.facade.projectAnnotations.globalTypes,...normalizeInputTypes(globalTypes)})},this.addStepRunner=stepRunner=>{this.facade.projectAnnotations.runStep=composeStepRunners([this.facade.projectAnnotations.runStep,stepRunner].filter(Boolean))},this.addLoader=loader=>{this.facade.projectAnnotations.loaders?.push(loader)},this.addArgs=args2=>{this.facade.projectAnnotations.args={...this.facade.projectAnnotations.args,...args2}},this.addArgTypes=argTypes=>{this.facade.projectAnnotations.argTypes={...this.facade.projectAnnotations.argTypes,...normalizeInputTypes(argTypes)}},this.addArgsEnhancer=enhancer=>{this.facade.projectAnnotations.argsEnhancers?.push(enhancer)},this.addArgTypesEnhancer=enhancer=>{this.facade.projectAnnotations.argTypesEnhancers?.push(enhancer)},this._addedExports={},this.storiesOf=(kind,m2)=>{if(!kind&&typeof kind!="string")throw new Error("Invalid or missing kind provided for stories, should be a string");if(m2||logger.warn(`Missing 'module' parameter for story with a kind of '${kind}'. It will break your HMR`),m2){let proto=Object.getPrototypeOf(m2);proto.exports&&proto.exports.default&&logger.error(`Illegal mix of CSF default export and storiesOf calls in a single file: ${proto.i}`)}let baseFilename=m2&&m2.id?`${m2.id}`:(this.lastFileName++).toString(),fileName=baseFilename,i=1;for(;this._addedExports[fileName];)i+=1,fileName=`${baseFilename}-${i}`;m2&&m2.hot&&m2.hot.accept&&(m2.hot.accept(),m2.hot.dispose(()=>{this.facade.clearFilenameExports(fileName),delete this._addedExports[fileName],setTimeout(()=>{this._loadAddedExports(),this.onImportFnChanged?.({importFn:this.importFn.bind(this)})},0)}));let hasAdded=!1,api={kind:kind.toString(),add:()=>api,addDecorator:()=>api,addLoader:()=>api,addParameters:()=>api};Object.keys(this.addons).forEach(name2=>{let addon=this.addons[name2];api[name2]=(...args2)=>(addon.apply(api,args2),api)});let meta={id:L(kind),title:kind,decorators:[],loaders:[],parameters:{}};this._addedExports[fileName]={default:meta};let counter=0;return api.add=(storyName,storyFn,parameters={})=>{if(hasAdded=!0,typeof storyName!="string")throw new Error(`Invalid or missing storyName provided for a "${kind}" story.`);if(!storyFn||Array.isArray(storyFn)||invalidStoryTypes.has(typeof storyFn))throw new Error(`Cannot load story "${storyName}" in "${kind}" due to invali
|
||
|
Read more here: https://github.com/storybookjs/storybook/blob/master/MIGRATION.md#can-no-longer-add-decoratorsparameters-after-stories`);return meta.decorators?.push(decorator),api},api.addLoader=loader=>{if(hasAdded)throw new Error("You cannot add a loader after the first story for a kind.");return meta.loaders?.push(loader),api},api.addParameters=({component,args:args2,argTypes,tags,...parameters})=>{if(hasAdded)throw new Error(`You cannot add parameters after the first story for a kind.
|
||
|
Read more here: https://github.com/storybookjs/storybook/blob/master/MIGRATION.md#can-no-longer-add-decoratorsparameters-after-stories`);return meta.parameters=combineParameters(meta.parameters,parameters),component&&(meta.component=component),args2&&(meta.args={...meta.args,...args2}),argTypes&&(meta.argTypes={...meta.argTypes,...argTypes}),tags&&(meta.tags=tags),api},api},this.raw=()=>this.storyStore?.raw(),this.facade=new StoryStoreFacade,this.addons={},this.storyStore=storyStore}importFn(path){return this.facade.importFn(path)}getStoryIndex(){if(!this.storyStore)throw new Error("Cannot get story index before setting storyStore");return this.facade.getStoryIndex(this.storyStore)}_loadAddedExports(){Object.entries(this._addedExports).forEach(([fileName,fileExports])=>this.facade.addStoriesFromExports(fileName,fileExports))}get _storyStore(){return this.storyStore}},getQueryParams=()=>{let{document:document4}=scope;return document4&&document4.location&&document4.location.search?(0,import_qs2.parse)(document4.location.search,{ignoreQueryPrefix:!0}):{}},getQueryParam=key2=>getQueryParams()[key2];var import_synchronous_promise3=__toESM(require_synchronous_promise(),1);var import_qs3=__toESM(require_lib(),1),import_isPlainObject2=__toESM(require_isPlainObject(),1),require_entities=__commonJS3({"../../node_modules/entities/lib/maps/entities.json"(exports,module){module.exports={Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",amp:"&",AMP:"&",andand:"\u2A55",And:"\u2A53",and:"\u2227",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angmsd:"\u2221",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",apacir:"\u2A6F",ap:"\u2248",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",barwed:"\u2305",Barwed:"\u2306",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",because:"\u2235",Because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxdl:"\u2510",boxdL:"\u2555",boxDl:"\u2556",boxDL:"\u2557",boxdr:"\u250C",boxdR:"\u2552",boxDr:"\u2553",boxDR:"\u2554",boxh:"\u2500",boxH:"\u2550",boxhd:"\u252C",boxHd:"\u2564",boxhD:"\u2565",boxHD:"\u2566",boxhu:"\u2534",boxHu:"\u2567",boxhU:"\u2568",boxHU:"\u2569",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxul:"\u2518",boxuL:"\u255B",boxUl:"\u255C",boxUL:"\u255D",boxur:"\u2514",
|
||
|
`,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nharr:"\u21AE",nhArr:"\u21CE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlarr:"\u219A",nlArr:"\u21CD",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nleftarrow:"\u219A",nLeftarrow:"\u21CD",nleftrightarrow:"\u21AE",nLeftrightarrow:"\u21CE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",nopf:"\u{1D55F}",Nopf:"\u2115",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangle:"\u22EA",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangle:"\u22EB",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",nparallel:"\u2226",npar:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",nprec:"\u2280",npreceq:"\u2AAF\u0338",npre:"\u2AAF\u0338",nrarrc:"\u2933\u0338",nrarr:"\u219B",nrArr:"\u21CF",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nRightarrow:"\u21CF",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvDash:"\u22AD",nVdash:"\u22AE",nVDash:"\u22AF",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwarr:"\u2196",nwArr:"\u21D6",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",Ocirc:"\xD4",ocirc:"\xF4",ocir:"\u229A",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u01
|
||
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var it,normalCompletion=!0,didErr=!1,err;return{s:function(){it=o[Symbol.iterator]()},n:function(){var step=it.next();return normalCompletion=step.done,step},e:function(_e2){didErr=!0,err=_e2},f:function(){try{!normalCompletion&&it.return!=null&&it.return()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(o){if(typeof o=="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor&&(n=o.constructor.name),n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}}function _arrayLikeToArray(arr,len){(len==null||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}var entities=require_lib2(),defaults={fg:"#FFF",bg:"#000",newline:!1,escapeXML:!1,stream:!1,colors:getDefaultColors()};function getDefaultColors(){var colors={0:"#000",1:"#A00",2:"#0A0",3:"#A50",4:"#00A",5:"#A0A",6:"#0AA",7:"#AAA",8:"#555",9:"#F55",10:"#5F5",11:"#FF5",12:"#55F",13:"#F5F",14:"#5FF",15:"#FFF"};return range(0,5).forEach(function(red){range(0,5).forEach(function(green){range(0,5).forEach(function(blue){return setStyleColor(red,green,blue,colors)})})}),range(0,23).forEach(function(gray){var c2=gray+232,l=toHexString(gray*10+8);colors[c2]="#"+l+l+l}),colors}function setStyleColor(red,green,blue,colors){var c2=16+red*36+green*6+blue,r=red>0?red*40+55:0,g=green>0?green*40+55:0,b2=blue>0?blue*40+55:0;colors[c2]=toColorHexString([r,g,b2])}function toHexString(num){for(var str=num.toString(16);str.length<2;)str="0"+str;return str}function toColorHexString(ref){var results=[],_iterator=_createForOfIteratorHelper(ref),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var r=_step.value;results.push(toHexString(r))}}catch(err){_iterator.e(err)}finally{_iterator.f()}return"#"+results.join("")}function generateOutput(stack,token,data,options2){var result2;return token==="text"?result2=pushText(data,options2):token==="display"?result2=handleDisplay(stack,data,options2):token==="xterm256"?result2=pushForegroundColor(stack,options2.colors[data]):token==="rgb"&&(result2=handleRgb(stack,data)),result2}function handleRgb(stack,data){data=data.substring(2).slice(0,-1);var operation=+data.substr(0,2),color=data.substring(5).split(";"),rgb=color.map(function(value2){return("0"+Number(value2).toString(16)).substr(-2)}).join("");return pushStyle(stack,(operation===38?"color:#":"background-color:#")+rgb)}function handleDisplay(stack,code,options2){code=parseInt(code,10);var codeMap={"-1":function(){return"<br/>"},0:function(){return stack.length&&resetStyles(stack)},1:function(){return pushTag(stack,"b")},3:function(){return pushTag(stack,"i")},4:function(){return pushTag(stack,"u")},8:function(){return pushStyle(stack,"display:none")},9:function(){return pushTag(stack,"strike")},22:function(){return pushStyle(stack,"font-weight:normal;text-decoration:none;font-style:normal")},23:function(){return closeTag(stack,"i")},24:function(){return closeTag(stack,"u")},39:function(){return pushForegroundColor(stack,options2.fg)},49:function(){return pushBackgroundColor(stack,options2.bg)},53:function(){return pushStyle(stack,"text-decoration:overline")}},result2;return codeMap[code]?result2=codeMap[code]():4<code&&code<7?result2=pushTag(stack,"blink"):29<code&&code<38?result2=pushForegroundColor(stack,options2.colors[code-30]):39<code&&code<48?result2=pushBackgroundColor(stack,options2.colors[code-40]):89<code&&code<98?result2=pushForegroundColor(stack,options2.colors[8+(code-90)]):99<code&&code<108&&(result2=pushBackgroundColor(stack,options2.colors[8+(code-100)])),result2}function resetStyles(stack){var stackClone=stack.slice(0);return stack.length=0,stackClone.reverse().map(function(tag){return"</"+tag+">"}).join("")}function range(low,high){for(var results=[],j=low;j<=high;j++)results.push(j);return results}function notCategory(category){return function(e)
|
||
|
Expected your framework's preset to export a \`renderToCanvas\` field.
|
||
|
|
||
|
Perhaps it needs to be upgraded for Storybook 6.4?
|
||
|
|
||
|
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mainjs-framework-field
|
||
|
`);return projectAnnotations}).catch(err=>{throw this.renderPreviewEntryError("Error reading preview.js:",err),err})}initializeWithProjectAnnotations(projectAnnotations){this.storyStore.setProjectAnnotations(projectAnnotations),this.setInitialGlobals();let storyIndexPromise;if(scope.FEATURES?.storyStoreV7)storyIndexPromise=this.getStoryIndexFromServer();else{if(!this.getStoryIndex)throw new Error("No `getStoryIndex` passed defined in v6 mode");storyIndexPromise=import_synchronous_promise3.SynchronousPromise.resolve().then(this.getStoryIndex)}return storyIndexPromise.then(storyIndex=>this.initializeWithStoryIndex(storyIndex)).catch(err=>{throw this.renderPreviewEntryError("Error loading story index:",err),err})}async setInitialGlobals(){this.emitGlobals()}emitGlobals(){if(!this.storyStore.globals||!this.storyStore.projectAnnotations)throw new Error("Cannot emit before initialization");let payload={globals:this.storyStore.globals.get()||{},globalTypes:this.storyStore.projectAnnotations.globalTypes||{}};this.channel.emit(SET_GLOBALS,payload)}async getStoryIndexFromServer(){let result2=await fetch(STORY_INDEX_PATH);if(result2.status===200)return result2.json();throw new Error(await result2.text())}initializeWithStoryIndex(storyIndex){if(!this.importFn)throw new Error("Cannot call initializeWithStoryIndex before initialization");return this.storyStore.initialize({storyIndex,importFn:this.importFn,cache:!scope.FEATURES?.storyStoreV7})}async onGetProjectAnnotationsChanged({getProjectAnnotations}){delete this.previewEntryError;let projectAnnotations=await this.getProjectAnnotationsOrRenderError(getProjectAnnotations);if(!this.storyStore.projectAnnotations){await this.initializeWithProjectAnnotations(projectAnnotations);return}await this.storyStore.setProjectAnnotations(projectAnnotations),this.emitGlobals()}async onStoryIndexChanged(){if(delete this.previewEntryError,!!this.storyStore.projectAnnotations)try{let storyIndex=await this.getStoryIndexFromServer();this.storyStore.storyIndex||await this.initializeWithStoryIndex(storyIndex),await this.onStoriesChanged({storyIndex})}catch(err){throw this.renderPreviewEntryError("Error loading story index:",err),err}}async onStoriesChanged({importFn,storyIndex}){await this.storyStore.onStoriesChanged({importFn,storyIndex})}async onUpdateGlobals({globals}){if(!this.storyStore.globals)throw new Error("Cannot call onUpdateGlobals before initialization");this.storyStore.globals.update(globals),await Promise.all(this.storyRenders.map(r=>r.rerender())),this.channel.emit(GLOBALS_UPDATED,{globals:this.storyStore.globals.get(),initialGlobals:this.storyStore.globals.initialGlobals})}async onUpdateArgs({storyId,updatedArgs}){this.storyStore.args.update(storyId,updatedArgs),await Promise.all(this.storyRenders.filter(r=>r.id===storyId&&!r.renderOptions.forceInitialArgs).map(r=>r.rerender())),this.channel.emit(STORY_ARGS_UPDATED,{storyId,args:this.storyStore.args.get(storyId)})}async onResetArgs({storyId,argNames}){let story=this.storyRenders.find(r=>r.id===storyId)?.story||await this.storyStore.loadStory({storyId}),updatedArgs=(argNames||[...new Set([...Object.keys(story.initialArgs),...Object.keys(this.storyStore.args.get(storyId))])]).reduce((acc,argName)=>(acc[argName]=story.initialArgs[argName],acc),{});await this.onUpdateArgs({storyId,updatedArgs})}async onForceReRender(){await Promise.all(this.storyRenders.map(r=>r.rerender()))}async onForceRemount({storyId}){await Promise.all(this.storyRenders.filter(r=>r.id===storyId).map(r=>r.remount()))}renderStoryToElement(story,element,callbacks,options2){if(!this.renderToCanvas)throw new Error("Cannot call renderStoryToElement before initialization");let render=new StoryRender(this.channel,this.storyStore,this.renderToCanvas,callbacks,story.id,"docs",options2,story);return render.renderToElement(element),this.storyRenders.push(render),async()=>{await this.teardownRender(render)}}async teardownRender(render,{viewModeChanged}={}){this.storyRenders=this.storyRenders.filter(r=>r!==render),await render?.teardown?.({viewModeChanged})}async extract(op
|
||
|
|
||
|
Do you have an error in your \`preview.js\`? Check your Storybook's browser console for errors.`);return scope.FEATURES?.storyStoreV7&&await this.storyStore.cacheAllCSFFiles(),this.storyStore.extract(options2)}renderPreviewEntryError(reason,err){this.previewEntryError=err,logger.error(reason),logger.error(err),this.channel.emit(CONFIG_ERROR,err)}},DocsContext=class{constructor(channel,store,renderStoryToElement,csfFiles){this.channel=channel,this.store=store,this.renderStoryToElement=renderStoryToElement,this.storyIdByName=storyName=>{let storyId=this.nameToStoryId.get(storyName);if(storyId)return storyId;throw new Error(`No story found with that name: ${storyName}`)},this.componentStories=()=>this.componentStoriesValue,this.storyById=storyId=>{if(!storyId){if(!this.primaryStory)throw new Error("No primary story defined for docs entry. Did you forget to use `<Meta>`?");return this.primaryStory}let csfFile=this.storyIdToCSFFile.get(storyId);if(!csfFile)throw new Error(`Called \`storyById\` for story that was never loaded: ${storyId}`);return this.store.storyFromCSFFile({storyId,csfFile})},this.getStoryContext=story=>({...this.store.getStoryContext(story),viewMode:"docs"}),this.loadStory=id=>this.store.loadStory({storyId:id}),this.storyIdToCSFFile=new Map,this.exportToStory=new Map,this.exportsToCSFFile=new Map,this.nameToStoryId=new Map,this.componentStoriesValue=[],csfFiles.forEach((csfFile,index)=>{this.referenceCSFFile(csfFile)})}referenceCSFFile(csfFile){this.exportsToCSFFile.set(csfFile.moduleExports,csfFile),this.exportsToCSFFile.set(csfFile.moduleExports.default,csfFile),this.store.componentStoriesFromCSFFile({csfFile}).forEach(story=>{let annotation=csfFile.stories[story.id];this.storyIdToCSFFile.set(annotation.id,csfFile),this.exportToStory.set(annotation.moduleExport,story)})}attachCSFFile(csfFile){if(!this.exportsToCSFFile.has(csfFile.moduleExports))throw new Error("Cannot attach a CSF file that has not been referenced");this.attachedCSFFile=csfFile,this.store.componentStoriesFromCSFFile({csfFile}).forEach(story=>{this.nameToStoryId.set(story.name,story.id),this.componentStoriesValue.push(story),this.primaryStory||(this.primaryStory=story)})}referenceMeta(metaExports,attach){let resolved=this.resolveModuleExport(metaExports);if(resolved.type!=="meta")throw new Error("<Meta of={} /> must reference a CSF file module export or meta export. Did you mistakenly reference your component instead of your CSF file?");attach&&this.attachCSFFile(resolved.csfFile)}get projectAnnotations(){let{projectAnnotations}=this.store;if(!projectAnnotations)throw new Error("Can't get projectAnnotations from DocsContext before they are initialized");return projectAnnotations}resolveAttachedModuleExportType(moduleExportType){if(moduleExportType==="story"){if(!this.primaryStory)throw new Error("No primary story attached to this docs file, did you forget to use <Meta of={} />?");return{type:"story",story:this.primaryStory}}if(!this.attachedCSFFile)throw new Error("No CSF file attached to this docs file, did you forget to use <Meta of={} />?");if(moduleExportType==="meta")return{type:"meta",csfFile:this.attachedCSFFile};let{component}=this.attachedCSFFile.meta;if(!component)throw new Error("Attached CSF file does not defined a component, did you forget to export one?");return{type:"component",component}}resolveModuleExport(moduleExportOrType){let csfFile=this.exportsToCSFFile.get(moduleExportOrType);if(csfFile)return{type:"meta",csfFile};let story=this.exportToStory.get(moduleExportOrType);return story?{type:"story",story}:{type:"component",component:moduleExportOrType}}resolveOf(moduleExportOrType,validTypes=[]){let resolved;if(["component","meta","story"].includes(moduleExportOrType)){let type=moduleExportOrType;resolved=this.resolveAttachedModuleExportType(type)}else resolved=this.resolveModuleExport(moduleExportOrType);if(validTypes.length&&!validTypes.includes(resolved.type)){let prettyType=resolved.type==="component"?"component or unknown":resolved.type;throw new Error(esm_default`Invalid value passed to the 'of' prop. The valu
|
||
|
- Did you pass a component to the 'of' prop when the block only supports a story or a meta?
|
||
|
- ... or vice versa?
|
||
|
- Did you pass a story, CSF file or meta to the 'of' prop that is not indexed, ie. is not targeted by the 'stories' globs in the main configuration?`)}switch(resolved.type){case"component":return{...resolved,projectAnnotations:this.projectAnnotations};case"meta":return{...resolved,preparedMeta:this.store.preparedMetaFromCSFFile({csfFile:resolved.csfFile})};case"story":default:return resolved}}},CsfDocsRender=class{constructor(channel,store,entry,callbacks){this.channel=channel,this.store=store,this.entry=entry,this.callbacks=callbacks,this.type="docs",this.subtype="csf",this.torndown=!1,this.disableKeyListeners=!1,this.preparing=!1,this.id=entry.id}isPreparing(){return this.preparing}async prepare(){this.preparing=!0;let{entryExports,csfFiles=[]}=await this.store.loadEntry(this.id);if(this.torndown)throw PREPARE_ABORTED;let{importPath,title}=this.entry,primaryCsfFile=this.store.processCSFFileWithCache(entryExports,importPath,title),primaryStoryId=Object.keys(primaryCsfFile.stories)[0];this.story=this.store.storyFromCSFFile({storyId:primaryStoryId,csfFile:primaryCsfFile}),this.csfFiles=[primaryCsfFile,...csfFiles],this.preparing=!1}isEqual(other){return!!(this.id===other.id&&this.story&&this.story===other.story)}docsContext(renderStoryToElement){if(!this.csfFiles)throw new Error("Cannot render docs before preparing");let docsContext=new DocsContext(this.channel,this.store,renderStoryToElement,this.csfFiles);return this.csfFiles.forEach(csfFile=>docsContext.attachCSFFile(csfFile)),docsContext}async renderToElement(canvasElement,renderStoryToElement){if(!this.story||!this.csfFiles)throw new Error("Cannot render docs before preparing");let docsContext=this.docsContext(renderStoryToElement),{docs:docsParameter}=this.story.parameters||{};if(!docsParameter)throw new Error("Cannot render a story in viewMode=docs if `@storybook/addon-docs` is not installed");let renderer=await docsParameter.renderer(),{render}=renderer,renderDocs=async()=>{try{await render(docsContext,docsParameter,canvasElement),this.channel.emit(DOCS_RENDERED,this.id)}catch(err){this.callbacks.showException(err)}};return this.rerender=async()=>renderDocs(),this.teardownRender=async({viewModeChanged})=>{!viewModeChanged||!canvasElement||renderer.unmount(canvasElement)},renderDocs()}async teardown({viewModeChanged}={}){this.teardownRender?.({viewModeChanged}),this.torndown=!0}},MdxDocsRender=class{constructor(channel,store,entry,callbacks){this.channel=channel,this.store=store,this.entry=entry,this.callbacks=callbacks,this.type="docs",this.subtype="mdx",this.torndown=!1,this.disableKeyListeners=!1,this.preparing=!1,this.id=entry.id}isPreparing(){return this.preparing}async prepare(){this.preparing=!0;let{entryExports,csfFiles=[]}=await this.store.loadEntry(this.id);if(this.torndown)throw PREPARE_ABORTED;this.csfFiles=csfFiles,this.exports=entryExports,this.preparing=!1}isEqual(other){return!!(this.id===other.id&&this.exports&&this.exports===other.exports)}docsContext(renderStoryToElement){if(!this.csfFiles)throw new Error("Cannot render docs before preparing");return new DocsContext(this.channel,this.store,renderStoryToElement,this.csfFiles)}async renderToElement(canvasElement,renderStoryToElement){if(!this.exports||!this.csfFiles||!this.store.projectAnnotations)throw new Error("Cannot render docs before preparing");let docsContext=this.docsContext(renderStoryToElement),{docs}=this.store.projectAnnotations.parameters||{};if(!docs)throw new Error("Cannot render a story in viewMode=docs if `@storybook/addon-docs` is not installed");let docsParameter={...docs,page:this.exports.default},renderer=await docs.renderer(),{render}=renderer,renderDocs=async()=>{try{await render(docsContext,docsParameter,canvasElement),this.channel.emit(DOCS_RENDERED,this.id)}catch(err){this.callbacks.showException(err)}};return this.rerender=async()=>renderDocs(),this.teardownRender=async({viewModeChanged}={})=>{!viewModeChanged||!canvasElement||(renderer.unmount(canvasElement),this.torndown=!0)},renderDocs()}async teardown({viewModeChanged}={}){this.teardownRender?.({viewModeChan
|
||
|
Couldn't find any stories in your Storybook.
|
||
|
- Please check your stories field of your main.js config.
|
||
|
- Also check the browser console and terminal for error messages.
|
||
|
`)):this.renderStoryLoadingException(storySpecifier,new Error(dedent`
|
||
|
Couldn't find story matching '${storySpecifier}'.
|
||
|
- Are you sure a story with that id exists?
|
||
|
- Please check your stories field of your main.js config.
|
||
|
- Also check the browser console and terminal for error messages.
|
||
|
`));return}let{id:storyId,type:viewMode}=entry;this.selectionStore.setSelection({storyId,viewMode}),this.channel.emit(STORY_SPECIFIED,this.selectionStore.selection),this.channel.emit(CURRENT_STORY_WAS_SET,this.selectionStore.selection),await this.renderSelection({persistedArgs:args2})}async onGetProjectAnnotationsChanged({getProjectAnnotations}){await super.onGetProjectAnnotationsChanged({getProjectAnnotations}),this.selectionStore.selection&&this.renderSelection()}async onStoriesChanged({importFn,storyIndex}){await super.onStoriesChanged({importFn,storyIndex}),scope.FEATURES?.storyStoreV7||this.channel.emit(SET_INDEX,await this.storyStore.getSetIndexPayload()),this.selectionStore.selection?await this.renderSelection():await this.selectSpecifiedStory()}onKeydown(event){if(!this.storyRenders.find(r=>r.disableKeyListeners)&&!focusInInput(event)){let{altKey,ctrlKey,metaKey,shiftKey,key:key2,code,keyCode}=event;this.channel.emit(PREVIEW_KEYDOWN,{event:{altKey,ctrlKey,metaKey,shiftKey,key:key2,code,keyCode}})}}async onSetCurrentStory(selection){this.selectionStore.setSelection({viewMode:"story",...selection}),await this.storyStore.initializationPromise,this.channel.emit(CURRENT_STORY_WAS_SET,this.selectionStore.selection),this.renderSelection()}onUpdateQueryParams(queryParams){this.selectionStore.setQueryParams(queryParams)}async onUpdateGlobals({globals}){super.onUpdateGlobals({globals}),(this.currentRender instanceof MdxDocsRender||this.currentRender instanceof CsfDocsRender)&&await this.currentRender.rerender?.()}async onUpdateArgs({storyId,updatedArgs}){super.onUpdateArgs({storyId,updatedArgs})}async onPreloadStories({ids}){await Promise.allSettled(ids.map(id=>this.storyStore.loadEntry(id)))}async renderSelection({persistedArgs}={}){let{renderToCanvas}=this;if(!renderToCanvas)throw new Error("Cannot call renderSelection before initialization");let{selection}=this.selectionStore;if(!selection)throw new Error("Cannot call renderSelection as no selection was made");let{storyId}=selection,entry;try{entry=await this.storyStore.storyIdToEntry(storyId)}catch(err){this.currentRender&&await this.teardownRender(this.currentRender),this.renderStoryLoadingException(storyId,err);return}let storyIdChanged=this.currentSelection?.storyId!==storyId,viewModeChanged=this.currentRender?.type!==entry.type;entry.type==="story"?this.view.showPreparingStory({immediate:viewModeChanged}):this.view.showPreparingDocs({immediate:viewModeChanged}),this.currentRender?.isPreparing()&&await this.teardownRender(this.currentRender);let render;entry.type==="story"?render=new StoryRender(this.channel,this.storyStore,(...args2)=>(this.view.showStoryDuringRender(),renderToCanvas(...args2)),this.mainStoryCallbacks(storyId),storyId,"story"):isMdxEntry(entry)?render=new MdxDocsRender(this.channel,this.storyStore,entry,this.mainStoryCallbacks(storyId)):render=new CsfDocsRender(this.channel,this.storyStore,entry,this.mainStoryCallbacks(storyId));let lastSelection=this.currentSelection;this.currentSelection=selection;let lastRender=this.currentRender;this.currentRender=render;try{await render.prepare()}catch(err){err!==PREPARE_ABORTED&&(lastRender&&await this.teardownRender(lastRender),this.renderStoryLoadingException(storyId,err));return}let implementationChanged=!storyIdChanged&&lastRender&&!render.isEqual(lastRender);if(persistedArgs&&isStoryRender(render)){if(!render.story)throw new Error("Render has not been prepared!");this.storyStore.args.updateFromPersisted(render.story,persistedArgs)}if(lastRender&&!lastRender.torndown&&!storyIdChanged&&!implementationChanged&&!viewModeChanged){this.currentRender=lastRender,this.channel.emit(STORY_UNCHANGED,storyId),this.view.showMain();return}if(lastRender&&await this.teardownRender(lastRender,{viewModeChanged}),lastSelection&&(storyIdChanged||viewModeChanged)&&this.channel.emit(STORY_CHANGED,storyId),isStoryRender(render)){if(!render.story)throw new Error("Render has not been prepared!");let{parameters,initialArgs,argTypes,unmappedArgs}=this.storyStore.getStoryContext(render.story);scope.FEATURES?.storyStoreV7&
|
||
|
|
||
|
Do you have an error in your \`preview.js\`? Check your Storybook's browser console for errors.`);return scope.FEATURES?.storyStoreV7&&await this.storyStore.cacheAllCSFFiles(),this.storyStore.extract(options2)}mainStoryCallbacks(storyId){return{showMain:()=>this.view.showMain(),showError:err=>this.renderError(storyId,err),showException:err=>this.renderException(storyId,err)}}renderPreviewEntryError(reason,err){super.renderPreviewEntryError(reason,err),this.view.showErrorDisplay(err)}renderMissingStory(){this.view.showNoPreview(),this.channel.emit(STORY_MISSING)}renderStoryLoadingException(storySpecifier,err){logger.error(err),this.view.showErrorDisplay(err),this.channel.emit(STORY_MISSING,storySpecifier)}renderException(storyId,error){let{name:name2="Error",message=String(error),stack}=error;this.channel.emit(STORY_THREW_EXCEPTION,{name:name2,message,stack}),this.channel.emit(STORY_RENDER_PHASE_CHANGED,{newPhase:"errored",storyId}),error.message?.startsWith("ignoredException")||(this.view.showErrorDisplay(error),logger.error(`Error rendering story '${storyId}':`),logger.error(error))}renderError(storyId,{title,description}){logger.error(`Error rendering story ${title}: ${description}`),this.channel.emit(STORY_ERRORED,{title,description}),this.channel.emit(STORY_RENDER_PHASE_CHANGED,{newPhase:"errored",storyId}),this.view.showErrorDisplay({message:title,stack:description})}},VALIDATION_REGEXP=/^[a-zA-Z0-9 _-]*$/,NUMBER_REGEXP=/^-?[0-9]+(\.[0-9]+)?$/,HEX_REGEXP=/^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i,COLOR_REGEXP=/^(rgba?|hsla?)\(([0-9]{1,3}),\s?([0-9]{1,3})%?,\s?([0-9]{1,3})%?,?\s?([0-9](\.[0-9]{1,2})?)?\)$/i,validateArgs=(key2="",value2)=>key2===null||key2===""||!VALIDATION_REGEXP.test(key2)?!1:value2==null||value2 instanceof Date||typeof value2=="number"||typeof value2=="boolean"?!0:typeof value2=="string"?VALIDATION_REGEXP.test(value2)||NUMBER_REGEXP.test(value2)||HEX_REGEXP.test(value2)||COLOR_REGEXP.test(value2):Array.isArray(value2)?value2.every(v2=>validateArgs(key2,v2)):(0,import_isPlainObject2.default)(value2)?Object.entries(value2).every(([k,v2])=>validateArgs(k,v2)):!1,QS_OPTIONS={delimiter:";",allowDots:!0,allowSparse:!0,decoder(str,defaultDecoder,charset,type){if(type==="value"&&str.startsWith("!")){if(str==="!undefined")return;if(str==="!null")return null;if(str==="!true")return!0;if(str==="!false")return!1;if(str.startsWith("!date(")&&str.endsWith(")"))return new Date(str.slice(6,-1));if(str.startsWith("!hex(")&&str.endsWith(")"))return`#${str.slice(5,-1)}`;let color=str.slice(1).match(COLOR_REGEXP);if(color)return str.startsWith("!rgba")?`${color[1]}(${color[2]}, ${color[3]}, ${color[4]}, ${color[5]})`:str.startsWith("!hsla")?`${color[1]}(${color[2]}, ${color[3]}%, ${color[4]}%, ${color[5]})`:str.startsWith("!rgb")?`${color[1]}(${color[2]}, ${color[3]}, ${color[4]})`:`${color[1]}(${color[2]}, ${color[3]}%, ${color[4]}%)`}return type==="value"&&NUMBER_REGEXP.test(str)?Number(str):defaultDecoder(str,defaultDecoder,charset)}},parseArgsParam=argsString=>{let parts=argsString.split(";").map(part=>part.replace("=","~").replace(":","="));return Object.entries(import_qs3.default.parse(parts.join(";"),QS_OPTIONS)).reduce((acc,[key2,value2])=>validateArgs(key2,value2)?Object.assign(acc,{[key2]:value2}):(once.warn(dedent`
|
||
|
Omitted potentially unsafe URL args.
|
||
|
|
||
|
More info: https://storybook.js.org/docs/react/writing-stories/args#setting-args-through-the-url
|
||
|
`),acc),{})},{history,document:document3}=scope;function pathToId(path){let match=(path||"").match(/^\/story\/(.+)/);if(!match)throw new Error(`Invalid path '${path}', must start with '/story/'`);return match[1]}var getQueryString=({selection,extraParams})=>{let{search=""}=document3.location,{path,selectedKind,selectedStory,...rest}=import_qs3.default.parse(search,{ignoreQueryPrefix:!0});return import_qs3.default.stringify({...rest,...extraParams,...selection&&{id:selection.storyId,viewMode:selection.viewMode}},{encode:!1,addQueryPrefix:!0})},setPath=selection=>{if(!selection)return;let query=getQueryString({selection}),{hash=""}=document3.location;document3.title=selection.storyId,history.replaceState({},"",`${document3.location.pathname}${query}${hash}`)},isObject4=val=>val!=null&&typeof val=="object"&&Array.isArray(val)===!1,getFirstString=v2=>{if(v2!==void 0){if(typeof v2=="string")return v2;if(Array.isArray(v2))return getFirstString(v2[0]);if(isObject4(v2))return getFirstString(Object.values(v2).filter(Boolean))}},getSelectionSpecifierFromPath=()=>{let query=import_qs3.default.parse(document3?.location?.search,{ignoreQueryPrefix:!0}),args2=typeof query.args=="string"?parseArgsParam(query.args):void 0,globals=typeof query.globals=="string"?parseArgsParam(query.globals):void 0,viewMode=getFirstString(query.viewMode);(typeof viewMode!="string"||!viewMode.match(/docs|story/))&&(viewMode="story");let path=getFirstString(query.path),storyId=path?pathToId(path):getFirstString(query.id);return storyId?{storySpecifier:storyId,args:args2,globals,viewMode}:null},UrlStore=class{constructor(){this.selectionSpecifier=getSelectionSpecifierFromPath()}setSelection(selection){this.selection=selection,setPath(this.selection)}setQueryParams(queryParams){let query=getQueryString({extraParams:queryParams}),{hash=""}=document3.location;history.replaceState({},"",`${document3.location.pathname}${query}${hash}`)}},import_ansi_to_html=__toESM3(require_ansi_to_html()),{document:document22}=scope,PREPARING_DELAY=100,Mode=(Mode2=>(Mode2.MAIN="MAIN",Mode2.NOPREVIEW="NOPREVIEW",Mode2.PREPARING_STORY="PREPARING_STORY",Mode2.PREPARING_DOCS="PREPARING_DOCS",Mode2.ERROR="ERROR",Mode2))(Mode||{}),classes={PREPARING_STORY:"sb-show-preparing-story",PREPARING_DOCS:"sb-show-preparing-docs",MAIN:"sb-show-main",NOPREVIEW:"sb-show-nopreview",ERROR:"sb-show-errordisplay"},layoutClassMap={centered:"sb-main-centered",fullscreen:"sb-main-fullscreen",padded:"sb-main-padded"},ansiConverter=new import_ansi_to_html.default({escapeXML:!0}),WebView=class{constructor(){this.testing=!1;let{__SPECIAL_TEST_PARAMETER__}=import_qs3.default.parse(document22?.location?.search,{ignoreQueryPrefix:!0});switch(__SPECIAL_TEST_PARAMETER__){case"preparing-story":{this.showPreparingStory(),this.testing=!0;break}case"preparing-docs":{this.showPreparingDocs(),this.testing=!0;break}}}prepareForStory(story){return this.showStory(),this.applyLayout(story.parameters.layout),document22.documentElement.scrollTop=0,document22.documentElement.scrollLeft=0,this.storyRoot()}storyRoot(){return document22.getElementById("storybook-root")}prepareForDocs(){return this.showMain(),this.showDocs(),this.applyLayout("fullscreen"),document22.documentElement.scrollTop=0,document22.documentElement.scrollLeft=0,this.docsRoot()}docsRoot(){return document22.getElementById("storybook-docs")}applyLayout(layout="padded"){if(layout==="none"){document22.body.classList.remove(this.currentLayoutClass),this.currentLayoutClass=null;return}this.checkIfLayoutExists(layout);let layoutClass=layoutClassMap[layout];document22.body.classList.remove(this.currentLayoutClass),document22.body.classList.add(layoutClass),this.currentLayoutClass=layoutClass}checkIfLayoutExists(layout){layoutClassMap[layout]||logger.warn(dedent`The desired layout: ${layout} is not a valid option.
|
||
|
The possible options are: ${Object.keys(layoutClassMap).join(", ")}, none.`)}showMode(mode){clearTimeout(this.preparingTimeout),Object.keys(Mode).forEach(otherMode=>{otherMode===mode?document22.body.classList.add(classes[otherMode]):document22.body.classList.remove(classes[otherMode])})}showErrorDisplay({message="",stack=""}){let header=message,detail=stack,parts=message.split(`
|
||
|
`);parts.length>1&&([header]=parts,detail=parts.slice(1).join(`
|
||
|
`)),document22.getElementById("error-message").innerHTML=ansiConverter.toHtml(header),document22.getElementById("error-stack").innerHTML=ansiConverter.toHtml(detail),this.showMode("ERROR")}showNoPreview(){this.testing||(this.showMode("NOPREVIEW"),this.storyRoot()?.setAttribute("hidden","true"),this.docsRoot()?.setAttribute("hidden","true"))}showPreparingStory({immediate=!1}={}){clearTimeout(this.preparingTimeout),immediate?this.showMode("PREPARING_STORY"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_STORY"),PREPARING_DELAY)}showPreparingDocs({immediate=!1}={}){clearTimeout(this.preparingTimeout),immediate?this.showMode("PREPARING_DOCS"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_DOCS"),PREPARING_DELAY)}showMain(){this.showMode("MAIN")}showDocs(){this.storyRoot().setAttribute("hidden","true"),this.docsRoot().removeAttribute("hidden")}showStory(){this.docsRoot().setAttribute("hidden","true"),this.storyRoot().removeAttribute("hidden")}showStoryDuringRender(){document22.body.classList.add(classes.MAIN)}},PreviewWeb=class extends PreviewWithSelection{constructor(){super(new UrlStore,new WebView),scope.__STORYBOOK_PREVIEW__=this}},{document:document32}=scope,runScriptTypes=["application/javascript","application/ecmascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript","module"],SCRIPT="script",SCRIPTS_ROOT_ID="scripts-root";function simulateDOMContentLoaded(){let DOMContentLoadedEvent=document32.createEvent("Event");DOMContentLoadedEvent.initEvent("DOMContentLoaded",!0,!0),document32.dispatchEvent(DOMContentLoadedEvent)}function insertScript($script,callback,$scriptRoot){let scriptEl=document32.createElement("script");scriptEl.type=$script.type==="module"?"module":"text/javascript",$script.src?(scriptEl.onload=callback,scriptEl.onerror=callback,scriptEl.src=$script.src):scriptEl.textContent=$script.innerText,$scriptRoot?$scriptRoot.appendChild(scriptEl):document32.head.appendChild(scriptEl),$script.parentNode.removeChild($script),$script.src||callback()}function insertScriptsSequentially(scriptsToExecute,callback,index=0){scriptsToExecute[index](()=>{index++,index===scriptsToExecute.length?callback():insertScriptsSequentially(scriptsToExecute,callback,index)})}function simulatePageLoad($container){let $scriptsRoot=document32.getElementById(SCRIPTS_ROOT_ID);$scriptsRoot?$scriptsRoot.innerHTML="":($scriptsRoot=document32.createElement("div"),$scriptsRoot.id=SCRIPTS_ROOT_ID,document32.body.appendChild($scriptsRoot));let $scripts=Array.from($container.querySelectorAll(SCRIPT));if($scripts.length){let scriptsToExecute=[];$scripts.forEach($script=>{let typeAttr=$script.getAttribute("type");(!typeAttr||runScriptTypes.includes(typeAttr))&&scriptsToExecute.push(callback=>insertScript($script,callback,$scriptsRoot))}),scriptsToExecute.length&&insertScriptsSequentially(scriptsToExecute,simulateDOMContentLoaded,void 0)}else simulateDOMContentLoaded()}function executeLoadable(loadable){let reqs=null;Array.isArray(loadable)?reqs=loadable:loadable.keys&&(reqs=[loadable]);let exportsMap=new Map;if(reqs)reqs.forEach(req=>{req.keys().forEach(filename=>{try{let fileExports=req(filename);exportsMap.set(typeof req.resolve=="function"?req.resolve(filename):filename,fileExports)}catch(error){let errorString=error.message&&error.stack?`${error.message}
|
||
|
${error.stack}`:error.toString();logger.error(`Unexpected error while loading ${filename}: ${errorString}`)}})});else{let exported=loadable();Array.isArray(exported)&&exported.every(obj=>obj.default!=null)?exportsMap=new Map(exported.map((fileExports,index)=>[`exports-map-${index}`,fileExports])):exported&&logger.warn(`Loader function passed to 'configure' should return void or an array of module exports that all contain a 'default' export. Received: ${JSON.stringify(exported)}`)}return exportsMap}function executeLoadableForChanges(loadable,m2){let lastExportsMap=m2?.hot?.data?.lastExportsMap||new Map;m2?.hot?.dispose&&(m2.hot.accept(),m2.hot.dispose(data=>{data.lastExportsMap=lastExportsMap}));let exportsMap=executeLoadable(loadable),added=new Map;Array.from(exportsMap.entries()).filter(([,fileExports])=>!!fileExports.default).filter(([fileName,fileExports])=>lastExportsMap.get(fileName)!==fileExports).forEach(([fileName,fileExports])=>added.set(fileName,fileExports));let removed=new Map;return Array.from(lastExportsMap.keys()).filter(fileName=>!exportsMap.has(fileName)).forEach(fileName=>{let value2=lastExportsMap.get(fileName);value2&&removed.set(fileName,value2)}),lastExportsMap=exportsMap,{added,removed}}var{FEATURES}=scope,removedApi=name2=>()=>{throw new Error(`@storybook/client-api:${name2} was removed in storyStoreV7.`)};function start(renderToCanvas,{decorateStory:decorateStory2,render}={}){if(scope&&(scope.IS_STORYBOOK=!0),FEATURES?.storyStoreV7)return{forceReRender:removedApi("forceReRender"),configure:removedApi("configure"),clientApi:{storiesOf:removedApi("clientApi.storiesOf"),raw:removedApi("raw")}};let channel=createBrowserChannel({page:"preview"});addons.setChannel(channel);let clientApi=scope?.__STORYBOOK_CLIENT_API__||new ClientApi,preview=scope?.__STORYBOOK_PREVIEW__||new PreviewWeb,initialized=!1,importFn=path=>clientApi.importFn(path);function onStoriesChanged(){let storyIndex=clientApi.getStoryIndex();preview.onStoriesChanged({storyIndex,importFn})}return clientApi.onImportFnChanged=onStoriesChanged,clientApi.storyStore=preview.storyStore,scope&&(scope.__STORYBOOK_CLIENT_API__=clientApi,scope.__STORYBOOK_ADDONS_CHANNEL__=channel,scope.__STORYBOOK_PREVIEW__=preview,scope.__STORYBOOK_STORY_STORE__=preview.storyStore),{forceReRender:()=>channel.emit(FORCE_RE_RENDER),clientApi,configure(renderer,loadable,m2,disableBackwardCompatibility=!0){if(disableBackwardCompatibility)throw new Error("unexpected configure() call");clientApi.addParameters({renderer});let getProjectAnnotations=()=>{let{added,removed}=executeLoadableForChanges(loadable,m2);return clientApi._loadAddedExports(),Array.from(added.entries()).forEach(([fileName,fileExports])=>clientApi.facade.addStoriesFromExports(fileName,fileExports)),Array.from(removed.entries()).forEach(([fileName])=>clientApi.facade.clearFilenameExports(fileName)),{render,...clientApi.facade.projectAnnotations,renderToCanvas,applyDecorators:decorateStory2}};initialized?(getProjectAnnotations(),onStoriesChanged()):(preview.initialize({getStoryIndex:()=>clientApi.getStoryIndex(),importFn,getProjectAnnotations}),initialized=!0)}}}var makeDecorator=({name:name2,parameterName,wrapper,skipIfNoParametersOrOptions=!1})=>{let decorator=options2=>(storyFn,context)=>{let parameters=context.parameters&&context.parameters[parameterName];return parameters&¶meters.disable||skipIfNoParametersOrOptions&&!options2&&!parameters?storyFn(context):wrapper(storyFn,context,{options:options2,parameters})};return(...args2)=>typeof args2[0]=="function"?decorator()(...args2):(...innerArgs)=>{if(innerArgs.length>1)return args2.length>1?decorator(args2)(...innerArgs):decorator(...args2)(...innerArgs);throw new Error(`Passing stories directly into ${name2}() is not allowed,
|
||
|
instead use addDecorator(${name2}) and pass options with the '${parameterName}' parameter`)}};var dist_exports6={};__export(dist_exports6,{Addon_TypesEnum:()=>Addon_TypesEnum});var Addon_TypesEnum=(Addon_TypesEnum2=>(Addon_TypesEnum2.TAB="tab",Addon_TypesEnum2.PANEL="panel",Addon_TypesEnum2.TOOL="tool",Addon_TypesEnum2.TOOLEXTRA="toolextra",Addon_TypesEnum2.PREVIEW="preview",Addon_TypesEnum2.experimental_PAGE="page",Addon_TypesEnum2.experimental_SIDEBAR_BOTTOM="sidebar-bottom",Addon_TypesEnum2.experimental_SIDEBAR_TOP="sidebar-top",Addon_TypesEnum2.NOTES_ELEMENT="notes-element",Addon_TypesEnum2))(Addon_TypesEnum||{});var addons_exports={};__export(addons_exports,{AddonStore:()=>AddonStore,HooksContext:()=>HooksContext,addons:()=>addons,applyHooks:()=>applyHooks,makeDecorator:()=>makeDecorator,mockChannel:()=>mockChannel,useArgs:()=>useArgs,useCallback:()=>useCallback,useChannel:()=>useChannel,useEffect:()=>useEffect,useGlobals:()=>useGlobals,useMemo:()=>useMemo,useParameter:()=>useParameter,useReducer:()=>useReducer,useRef:()=>useRef,useState:()=>useState,useStoryContext:()=>useStoryContext});var client_api_exports={};__export(client_api_exports,{ClientApi:()=>ClientApi,DEEPLY_EQUAL:()=>DEEPLY_EQUAL,HooksContext:()=>HooksContext,StoryStore:()=>StoryStore,UNTARGETED:()=>UNTARGETED,addArgTypes:()=>addArgTypes,addArgTypesEnhancer:()=>addArgTypesEnhancer,addArgs:()=>addArgs,addArgsEnhancer:()=>addArgsEnhancer,addDecorator:()=>addDecorator,addLoader:()=>addLoader,addParameters:()=>addParameters,addStepRunner:()=>addStepRunner,applyHooks:()=>applyHooks,combineArgs:()=>combineArgs,combineParameters:()=>combineParameters,composeConfigs:()=>composeConfigs,composeStepRunners:()=>composeStepRunners,composeStories:()=>composeStories,composeStory:()=>composeStory,decorateStory:()=>decorateStory,deepDiff:()=>deepDiff,defaultDecorateStory:()=>defaultDecorateStory,filterArgTypes:()=>filterArgTypes,getArrayField:()=>getArrayField,getField:()=>getField,getObjectField:()=>getObjectField,getQueryParam:()=>getQueryParam,getQueryParams:()=>getQueryParams,getSingletonField:()=>getSingletonField,getValuesFromArgTypes:()=>getValuesFromArgTypes,groupArgsByTarget:()=>groupArgsByTarget,inferControls:()=>inferControls,mapArgsToTypes:()=>mapArgsToTypes,noTargetArgs:()=>noTargetArgs,normalizeComponentAnnotations:()=>normalizeComponentAnnotations,normalizeInputType:()=>normalizeInputType,normalizeInputTypes:()=>normalizeInputTypes,normalizeProjectAnnotations:()=>normalizeProjectAnnotations,normalizeStory:()=>normalizeStory,prepareContext:()=>prepareContext,prepareMeta:()=>prepareMeta,prepareStory:()=>prepareStory,processCSFFile:()=>processCSFFile,sanitizeStoryContextUpdate:()=>sanitizeStoryContextUpdate,setGlobalRender:()=>setGlobalRender,setProjectAnnotations:()=>setProjectAnnotations,sortStoriesV6:()=>sortStoriesV6,sortStoriesV7:()=>sortStoriesV7,useAddonState:()=>useAddonState,useArgs:()=>useArgs,useCallback:()=>useCallback,useChannel:()=>useChannel,useEffect:()=>useEffect,useGlobals:()=>useGlobals,useMemo:()=>useMemo,useParameter:()=>useParameter,useReducer:()=>useReducer,useRef:()=>useRef,useSharedState:()=>useSharedState,useState:()=>useState,useStoryContext:()=>useStoryContext,userOrAutoTitle:()=>userOrAutoTitle,userOrAutoTitleFromSpecifier:()=>userOrAutoTitleFromSpecifier,validateOptions:()=>validateOptions});var core_client_exports={};__export(core_client_exports,{ClientApi:()=>ClientApi,StoryStore:()=>StoryStore,start:()=>start});var preview_web_exports={};__export(preview_web_exports,{DocsContext:()=>DocsContext,Preview:()=>Preview,PreviewWeb:()=>PreviewWeb,PreviewWithSelection:()=>PreviewWithSelection,composeConfigs:()=>composeConfigs,simulateDOMContentLoaded:()=>simulateDOMContentLoaded,simulatePageLoad:()=>simulatePageLoad});var store_exports={};__export(store_exports,{DEEPLY_EQUAL:()=>DEEPLY_EQUAL,HooksContext:()=>HooksContext,StoryStore:()=>StoryStore,UNTARGETED:()=>UNTARGETED,applyHooks:()=>applyHooks,combineArgs:()=>combineArgs,combineParameters:()=>combineParameters,composeConfigs:()=>composeConfigs,composeStepRunners:()=>co
|