"use strict";(globalThis.webpackChunk_elliemae_pui_app_sdk=globalThis.webpackChunk_elliemae_pui_app_sdk||[]).push([[1800],{"./lib/view/error-toast/index.stories.tsx":(b,c,t)=>{t.r(c),t.d(c,{BasicError:()=>w,ToastDifferentTypes:()=>g,__namedExportsOrder:()=>W,default:()=>O});var d=t("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/objectWithoutProperties.js"),T=t.n(d),r=t("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/jsx.js"),n=t.n(r),B=t("./node_modules/.pnpm/@babel+runtime@7.28.4/node_modules/@babel/runtime/helpers/slicedToArray.js"),R=t.n(B),m=t("./node_modules/.pnpm/react@18.3.1/node_modules/react/index.js"),a=t("./node_modules/.pnpm/@elliemae+ds-toast@3.54.6_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-toast/dist/esm/constants.js"),k=t("./node_modules/.pnpm/@elliemae+ds-legacy-button-v1@1.0.16_@elliemae+pui-theme@2.13.0/node_modules/@elliemae/ds-legacy-button-v1/dist/esm/DSButton.js"),f=t("./lib/data/useAppDispatch.ts"),h=t("./lib/data/error/index.ts"),S=t("./lib/view/error-toast/index.tsx"),C=t("./node_modules/.pnpm/react@18.3.1/node_modules/react/jsx-runtime.js"),A=["messageText","type"],E,x,D=`
    
    // @ts-nocheck
    // @ts-ignore
    var __STORY__ = "import { Meta } from '@storybook/react';\\nimport { useEffect, useState } from 'react';\\nimport { ToastType } from '@elliemae/ds-toast';\\nimport { DSButton } from '@elliemae/ds-button';\\nimport { useAppDispatch } from '../../data/react.js';\\nimport { error } from '../../index.js';\\nimport { ErrorToast } from './index.js';\\n\\nexport default {\\n  title: 'Components/ErrorToast',\\n  Component: ErrorToast,\\n} as Meta;\\n\\nconst Renderer = ({ Comp }: { Comp: React.ComponentType }) => {\\n  const [show, setShow] = useState(false);\\n  useEffect(() => {\\n    setShow(true);\\n  }, []);\\n  return show ? <Comp /> : null;\\n};\\n\\nconst Basic = () => {\\n  const dispatch = useAppDispatch();\\n  useEffect(() => {\\n    dispatch(error.set({ description: 'This is Error Toast' }));\\n  }, [dispatch]);\\n  return null;\\n};\\n\\nexport const BasicError = () => <Renderer Comp={Basic} />;\\n\\ninterface ShowToastProps {\\n  messageText?: string;\\n  type: (typeof ToastType)[keyof typeof ToastType];\\n}\\n// Action wrappers for readability\\nconst showToast = ({\\n  messageText = 'Toast Message',\\n  type = ToastType.DEFAULT,\\n  ...props\\n}: ShowToastProps) =>\\n  error.set({\\n    type,\\n    messageText,\\n    messageTitle: type,\\n    containerId: 'app-toast',\\n    ...props,\\n  });\\nconst successToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.SUCCESS });\\nconst infoToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.INFO });\\nconst warningToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.WARNING });\\nconst errorToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.ERROR });\\n\\nconst ToastButton = ({\\n  labelText,\\n  onClick,\\n}: {\\n  labelText: string;\\n  onClick: () => void;\\n}) => <DSButton buttonType=\\"text\\" labelText={labelText} onClick={onClick} />;\\n\\ntype ToastActionFn = ({\\n  description,\\n}: {\\n  description: string;\\n}) => ReturnType<typeof showToast>;\\n\\nconst ToastMultipleTypes = () => {\\n  const dispatch = useAppDispatch();\\n  const openToast = (toastAction: ToastActionFn) => () =>\\n    dispatch(toastAction({ description: 'This is Error Toast' }));\\n  return (\\n    <>\\n      <ToastButton labelText=\\"Success\\" onClick={openToast(successToast)} />\\n      <ToastButton labelText=\\"Info\\" onClick={openToast(infoToast)} />\\n      <ToastButton labelText=\\"Warning\\" onClick={openToast(warningToast)} />\\n      <ToastButton labelText=\\"Error\\" onClick={openToast(errorToast)} />\\n    </>\\n  );\\n};\\n\\nexport const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;\\n";
    // @ts-ignore
    var __LOCATIONS_MAP__ = {"BasicError":{"startLoc":{"col":26,"line":30},"endLoc":{"col":57,"line":30},"startBody":{"col":26,"line":30},"endBody":{"col":57,"line":30}},"ToastDifferentTypes":{"startLoc":{"col":35,"line":86},"endLoc":{"col":79,"line":86},"startBody":{"col":35,"line":86},"endBody":{"col":79,"line":86}}};
    
import { Meta } from '@storybook/react';
import { useEffect, useState } from 'react';
import { ToastType } from '@elliemae/ds-toast';
import { DSButton } from '@elliemae/ds-button';
import { useAppDispatch } from '../../data/react.js';
import { error } from '../../index.js';
import { ErrorToast } from './index.js';

export default {parameters: {"storySource":{"source":"import { Meta } from '@storybook/react';\\nimport { useEffect, useState } from 'react';\\nimport { ToastType } from '@elliemae/ds-toast';\\nimport { DSButton } from '@elliemae/ds-button';\\nimport { useAppDispatch } from '../../data/react.js';\\nimport { error } from '../../index.js';\\nimport { ErrorToast } from './index.js';\\n\\nexport default {\\n  title: 'Components/ErrorToast',\\n  Component: ErrorToast,\\n} as Meta;\\n\\nconst Renderer = ({ Comp }: { Comp: React.ComponentType }) => {\\n  const [show, setShow] = useState(false);\\n  useEffect(() => {\\n    setShow(true);\\n  }, []);\\n  return show ? <Comp /> : null;\\n};\\n\\nconst Basic = () => {\\n  const dispatch = useAppDispatch();\\n  useEffect(() => {\\n    dispatch(error.set({ description: 'This is Error Toast' }));\\n  }, [dispatch]);\\n  return null;\\n};\\n\\nexport const BasicError = () => <Renderer Comp={Basic} />;\\n\\ninterface ShowToastProps {\\n  messageText?: string;\\n  type: (typeof ToastType)[keyof typeof ToastType];\\n}\\n// Action wrappers for readability\\nconst showToast = ({\\n  messageText = 'Toast Message',\\n  type = ToastType.DEFAULT,\\n  ...props\\n}: ShowToastProps) =>\\n  error.set({\\n    type,\\n    messageText,\\n    messageTitle: type,\\n    containerId: 'app-toast',\\n    ...props,\\n  });\\nconst successToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.SUCCESS });\\nconst infoToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.INFO });\\nconst warningToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.WARNING });\\nconst errorToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.ERROR });\\n\\nconst ToastButton = ({\\n  labelText,\\n  onClick,\\n}: {\\n  labelText: string;\\n  onClick: () => void;\\n}) => <DSButton buttonType=\\"text\\" labelText={labelText} onClick={onClick} />;\\n\\ntype ToastActionFn = ({\\n  description,\\n}: {\\n  description: string;\\n}) => ReturnType<typeof showToast>;\\n\\nconst ToastMultipleTypes = () => {\\n  const dispatch = useAppDispatch();\\n  const openToast = (toastAction: ToastActionFn) => () =>\\n    dispatch(toastAction({ description: 'This is Error Toast' }));\\n  return (\\n    <>\\n      <ToastButton labelText=\\"Success\\" onClick={openToast(successToast)} />\\n      <ToastButton labelText=\\"Info\\" onClick={openToast(infoToast)} />\\n      <ToastButton labelText=\\"Warning\\" onClick={openToast(warningToast)} />\\n      <ToastButton labelText=\\"Error\\" onClick={openToast(errorToast)} />\\n    </>\\n  );\\n};\\n\\nexport const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;\\n","locationsMap":{"basic-error":{"startLoc":{"col":26,"line":30},"endLoc":{"col":57,"line":30},"startBody":{"col":26,"line":30},"endBody":{"col":57,"line":30}},"toast-different-types":{"startLoc":{"col":35,"line":86},"endLoc":{"col":79,"line":86},"startBody":{"col":35,"line":86},"endBody":{"col":79,"line":86}}}},},
  title: 'Components/ErrorToast',
  Component: ErrorToast,
} as Meta;

const Renderer = ({ Comp }: { Comp: React.ComponentType }) => {
  const [show, setShow] = useState(false);
  useEffect(() => {
    setShow(true);
  }, []);
  return show ? <Comp /> : null;
};

const Basic = () => {
  const dispatch = useAppDispatch();
  useEffect(() => {
    dispatch(error.set({ description: 'This is Error Toast' }));
  }, [dispatch]);
  return null;
};

export const BasicError = () => <Renderer Comp={Basic} />;;

interface ShowToastProps {
  messageText?: string;
  type: (typeof ToastType)[keyof typeof ToastType];
}
// Action wrappers for readability
const showToast = ({
  messageText = 'Toast Message',
  type = ToastType.DEFAULT,
  ...props
}: ShowToastProps) =>
  error.set({
    type,
    messageText,
    messageTitle: type,
    containerId: 'app-toast',
    ...props,
  });
const successToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.SUCCESS });
const infoToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.INFO });
const warningToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.WARNING });
const errorToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.ERROR });

const ToastButton = ({
  labelText,
  onClick,
}: {
  labelText: string;
  onClick: () => void;
}) => <DSButton buttonType="text" labelText={labelText} onClick={onClick} />;

type ToastActionFn = ({
  description,
}: {
  description: string;
}) => ReturnType<typeof showToast>;

const ToastMultipleTypes = () => {
  const dispatch = useAppDispatch();
  const openToast = (toastAction: ToastActionFn) => () =>
    dispatch(toastAction({ description: 'This is Error Toast' }));
  return (
    <>
      <ToastButton labelText="Success" onClick={openToast(successToast)} />
      <ToastButton labelText="Info" onClick={openToast(infoToast)} />
      <ToastButton labelText="Warning" onClick={openToast(warningToast)} />
      <ToastButton labelText="Error" onClick={openToast(errorToast)} />
    </>
  );
};

export const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;
`,M={BasicError:{startLoc:{col:26,line:38},endLoc:{col:57,line:38},startBody:{col:26,line:38},endBody:{col:57,line:38}},ToastDifferentTypes:{startLoc:{col:35,line:94},endLoc:{col:79,line:94},startBody:{col:35,line:94},endBody:{col:79,line:94}}},D=`import { Meta } from '@storybook/react';
import { useEffect, useState } from 'react';
import { ToastType } from '@elliemae/ds-toast';
import { DSButton } from '@elliemae/ds-button';
import { useAppDispatch } from '../../data/react.js';
import { error } from '../../index.js';
import { ErrorToast } from './index.js';

export default {
  title: 'Components/ErrorToast',
  Component: ErrorToast,
} as Meta;

const Renderer = ({ Comp }: { Comp: React.ComponentType }) => {
  const [show, setShow] = useState(false);
  useEffect(() => {
    setShow(true);
  }, []);
  return show ? <Comp /> : null;
};

const Basic = () => {
  const dispatch = useAppDispatch();
  useEffect(() => {
    dispatch(error.set({ description: 'This is Error Toast' }));
  }, [dispatch]);
  return null;
};

export const BasicError = () => <Renderer Comp={Basic} />;

interface ShowToastProps {
  messageText?: string;
  type: (typeof ToastType)[keyof typeof ToastType];
}
// Action wrappers for readability
const showToast = ({
  messageText = 'Toast Message',
  type = ToastType.DEFAULT,
  ...props
}: ShowToastProps) =>
  error.set({
    type,
    messageText,
    messageTitle: type,
    containerId: 'app-toast',
    ...props,
  });
const successToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.SUCCESS });
const infoToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.INFO });
const warningToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.WARNING });
const errorToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.ERROR });

const ToastButton = ({
  labelText,
  onClick,
}: {
  labelText: string;
  onClick: () => void;
}) => <DSButton buttonType="text" labelText={labelText} onClick={onClick} />;

type ToastActionFn = ({
  description,
}: {
  description: string;
}) => ReturnType<typeof showToast>;

const ToastMultipleTypes = () => {
  const dispatch = useAppDispatch();
  const openToast = (toastAction: ToastActionFn) => () =>
    dispatch(toastAction({ description: 'This is Error Toast' }));
  return (
    <>
      <ToastButton labelText="Success" onClick={openToast(successToast)} />
      <ToastButton labelText="Info" onClick={openToast(infoToast)} />
      <ToastButton labelText="Warning" onClick={openToast(warningToast)} />
      <ToastButton labelText="Error" onClick={openToast(errorToast)} />
    </>
  );
};

export const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;
`,M={BasicError:{startLoc:{col:26,line:30},endLoc:{col:57,line:30},startBody:{col:26,line:30},endBody:{col:57,line:30}},ToastDifferentTypes:{startLoc:{col:35,line:86},endLoc:{col:79,line:86},startBody:{col:35,line:86},endBody:{col:79,line:86}}};const O={parameters:{storySource:{source:`
    
    // @ts-nocheck
    // @ts-ignore
    var __STORY__ = "import { Meta } from '@storybook/react';\\nimport { useEffect, useState } from 'react';\\nimport { ToastType } from '@elliemae/ds-toast';\\nimport { DSButton } from '@elliemae/ds-button';\\nimport { useAppDispatch } from '../../data/react.js';\\nimport { error } from '../../index.js';\\nimport { ErrorToast } from './index.js';\\n\\nexport default {\\n  title: 'Components/ErrorToast',\\n  Component: ErrorToast,\\n} as Meta;\\n\\nconst Renderer = ({ Comp }: { Comp: React.ComponentType }) => {\\n  const [show, setShow] = useState(false);\\n  useEffect(() => {\\n    setShow(true);\\n  }, []);\\n  return show ? <Comp /> : null;\\n};\\n\\nconst Basic = () => {\\n  const dispatch = useAppDispatch();\\n  useEffect(() => {\\n    dispatch(error.set({ description: 'This is Error Toast' }));\\n  }, [dispatch]);\\n  return null;\\n};\\n\\nexport const BasicError = () => <Renderer Comp={Basic} />;\\n\\ninterface ShowToastProps {\\n  messageText?: string;\\n  type: (typeof ToastType)[keyof typeof ToastType];\\n}\\n// Action wrappers for readability\\nconst showToast = ({\\n  messageText = 'Toast Message',\\n  type = ToastType.DEFAULT,\\n  ...props\\n}: ShowToastProps) =>\\n  error.set({\\n    type,\\n    messageText,\\n    messageTitle: type,\\n    containerId: 'app-toast',\\n    ...props,\\n  });\\nconst successToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.SUCCESS });\\nconst infoToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.INFO });\\nconst warningToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.WARNING });\\nconst errorToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.ERROR });\\n\\nconst ToastButton = ({\\n  labelText,\\n  onClick,\\n}: {\\n  labelText: string;\\n  onClick: () => void;\\n}) => <DSButton buttonType=\\"text\\" labelText={labelText} onClick={onClick} />;\\n\\ntype ToastActionFn = ({\\n  description,\\n}: {\\n  description: string;\\n}) => ReturnType<typeof showToast>;\\n\\nconst ToastMultipleTypes = () => {\\n  const dispatch = useAppDispatch();\\n  const openToast = (toastAction: ToastActionFn) => () =>\\n    dispatch(toastAction({ description: 'This is Error Toast' }));\\n  return (\\n    <>\\n      <ToastButton labelText=\\"Success\\" onClick={openToast(successToast)} />\\n      <ToastButton labelText=\\"Info\\" onClick={openToast(infoToast)} />\\n      <ToastButton labelText=\\"Warning\\" onClick={openToast(warningToast)} />\\n      <ToastButton labelText=\\"Error\\" onClick={openToast(errorToast)} />\\n    </>\\n  );\\n};\\n\\nexport const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;\\n";
    // @ts-ignore
    var __LOCATIONS_MAP__ = {"BasicError":{"startLoc":{"col":26,"line":30},"endLoc":{"col":57,"line":30},"startBody":{"col":26,"line":30},"endBody":{"col":57,"line":30}},"ToastDifferentTypes":{"startLoc":{"col":35,"line":86},"endLoc":{"col":79,"line":86},"startBody":{"col":35,"line":86},"endBody":{"col":79,"line":86}}};
    
import { Meta } from '@storybook/react';
import { useEffect, useState } from 'react';
import { ToastType } from '@elliemae/ds-toast';
import { DSButton } from '@elliemae/ds-button';
import { useAppDispatch } from '../../data/react.js';
import { error } from '../../index.js';
import { ErrorToast } from './index.js';

export default {parameters: {"storySource":{"source":"import { Meta } from '@storybook/react';\\nimport { useEffect, useState } from 'react';\\nimport { ToastType } from '@elliemae/ds-toast';\\nimport { DSButton } from '@elliemae/ds-button';\\nimport { useAppDispatch } from '../../data/react.js';\\nimport { error } from '../../index.js';\\nimport { ErrorToast } from './index.js';\\n\\nexport default {\\n  title: 'Components/ErrorToast',\\n  Component: ErrorToast,\\n} as Meta;\\n\\nconst Renderer = ({ Comp }: { Comp: React.ComponentType }) => {\\n  const [show, setShow] = useState(false);\\n  useEffect(() => {\\n    setShow(true);\\n  }, []);\\n  return show ? <Comp /> : null;\\n};\\n\\nconst Basic = () => {\\n  const dispatch = useAppDispatch();\\n  useEffect(() => {\\n    dispatch(error.set({ description: 'This is Error Toast' }));\\n  }, [dispatch]);\\n  return null;\\n};\\n\\nexport const BasicError = () => <Renderer Comp={Basic} />;\\n\\ninterface ShowToastProps {\\n  messageText?: string;\\n  type: (typeof ToastType)[keyof typeof ToastType];\\n}\\n// Action wrappers for readability\\nconst showToast = ({\\n  messageText = 'Toast Message',\\n  type = ToastType.DEFAULT,\\n  ...props\\n}: ShowToastProps) =>\\n  error.set({\\n    type,\\n    messageText,\\n    messageTitle: type,\\n    containerId: 'app-toast',\\n    ...props,\\n  });\\nconst successToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.SUCCESS });\\nconst infoToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.INFO });\\nconst warningToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.WARNING });\\nconst errorToast = (props: Record<string, unknown>) =>\\n  showToast({ ...props, type: ToastType.ERROR });\\n\\nconst ToastButton = ({\\n  labelText,\\n  onClick,\\n}: {\\n  labelText: string;\\n  onClick: () => void;\\n}) => <DSButton buttonType=\\"text\\" labelText={labelText} onClick={onClick} />;\\n\\ntype ToastActionFn = ({\\n  description,\\n}: {\\n  description: string;\\n}) => ReturnType<typeof showToast>;\\n\\nconst ToastMultipleTypes = () => {\\n  const dispatch = useAppDispatch();\\n  const openToast = (toastAction: ToastActionFn) => () =>\\n    dispatch(toastAction({ description: 'This is Error Toast' }));\\n  return (\\n    <>\\n      <ToastButton labelText=\\"Success\\" onClick={openToast(successToast)} />\\n      <ToastButton labelText=\\"Info\\" onClick={openToast(infoToast)} />\\n      <ToastButton labelText=\\"Warning\\" onClick={openToast(warningToast)} />\\n      <ToastButton labelText=\\"Error\\" onClick={openToast(errorToast)} />\\n    </>\\n  );\\n};\\n\\nexport const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;\\n","locationsMap":{"basic-error":{"startLoc":{"col":26,"line":30},"endLoc":{"col":57,"line":30},"startBody":{"col":26,"line":30},"endBody":{"col":57,"line":30}},"toast-different-types":{"startLoc":{"col":35,"line":86},"endLoc":{"col":79,"line":86},"startBody":{"col":35,"line":86},"endBody":{"col":79,"line":86}}}},},
  title: 'Components/ErrorToast',
  Component: ErrorToast,
} as Meta;

const Renderer = ({ Comp }: { Comp: React.ComponentType }) => {
  const [show, setShow] = useState(false);
  useEffect(() => {
    setShow(true);
  }, []);
  return show ? <Comp /> : null;
};

const Basic = () => {
  const dispatch = useAppDispatch();
  useEffect(() => {
    dispatch(error.set({ description: 'This is Error Toast' }));
  }, [dispatch]);
  return null;
};

export const BasicError = () => <Renderer Comp={Basic} />;;

interface ShowToastProps {
  messageText?: string;
  type: (typeof ToastType)[keyof typeof ToastType];
}
// Action wrappers for readability
const showToast = ({
  messageText = 'Toast Message',
  type = ToastType.DEFAULT,
  ...props
}: ShowToastProps) =>
  error.set({
    type,
    messageText,
    messageTitle: type,
    containerId: 'app-toast',
    ...props,
  });
const successToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.SUCCESS });
const infoToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.INFO });
const warningToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.WARNING });
const errorToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.ERROR });

const ToastButton = ({
  labelText,
  onClick,
}: {
  labelText: string;
  onClick: () => void;
}) => <DSButton buttonType="text" labelText={labelText} onClick={onClick} />;

type ToastActionFn = ({
  description,
}: {
  description: string;
}) => ReturnType<typeof showToast>;

const ToastMultipleTypes = () => {
  const dispatch = useAppDispatch();
  const openToast = (toastAction: ToastActionFn) => () =>
    dispatch(toastAction({ description: 'This is Error Toast' }));
  return (
    <>
      <ToastButton labelText="Success" onClick={openToast(successToast)} />
      <ToastButton labelText="Info" onClick={openToast(infoToast)} />
      <ToastButton labelText="Warning" onClick={openToast(warningToast)} />
      <ToastButton labelText="Error" onClick={openToast(errorToast)} />
    </>
  );
};

export const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;
`,locationsMap:{"basic-error":{startLoc:{col:26,line:38},endLoc:{col:57,line:38},startBody:{col:26,line:38},endBody:{col:57,line:38}},"toast-different-types":{startLoc:{col:35,line:94},endLoc:{col:79,line:94},startBody:{col:35,line:94},endBody:{col:79,line:94}}}},storySource:{source:`import { Meta } from '@storybook/react';
import { useEffect, useState } from 'react';
import { ToastType } from '@elliemae/ds-toast';
import { DSButton } from '@elliemae/ds-button';
import { useAppDispatch } from '../../data/react.js';
import { error } from '../../index.js';
import { ErrorToast } from './index.js';

export default {
  title: 'Components/ErrorToast',
  Component: ErrorToast,
} as Meta;

const Renderer = ({ Comp }: { Comp: React.ComponentType }) => {
  const [show, setShow] = useState(false);
  useEffect(() => {
    setShow(true);
  }, []);
  return show ? <Comp /> : null;
};

const Basic = () => {
  const dispatch = useAppDispatch();
  useEffect(() => {
    dispatch(error.set({ description: 'This is Error Toast' }));
  }, [dispatch]);
  return null;
};

export const BasicError = () => <Renderer Comp={Basic} />;

interface ShowToastProps {
  messageText?: string;
  type: (typeof ToastType)[keyof typeof ToastType];
}
// Action wrappers for readability
const showToast = ({
  messageText = 'Toast Message',
  type = ToastType.DEFAULT,
  ...props
}: ShowToastProps) =>
  error.set({
    type,
    messageText,
    messageTitle: type,
    containerId: 'app-toast',
    ...props,
  });
const successToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.SUCCESS });
const infoToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.INFO });
const warningToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.WARNING });
const errorToast = (props: Record<string, unknown>) =>
  showToast({ ...props, type: ToastType.ERROR });

const ToastButton = ({
  labelText,
  onClick,
}: {
  labelText: string;
  onClick: () => void;
}) => <DSButton buttonType="text" labelText={labelText} onClick={onClick} />;

type ToastActionFn = ({
  description,
}: {
  description: string;
}) => ReturnType<typeof showToast>;

const ToastMultipleTypes = () => {
  const dispatch = useAppDispatch();
  const openToast = (toastAction: ToastActionFn) => () =>
    dispatch(toastAction({ description: 'This is Error Toast' }));
  return (
    <>
      <ToastButton labelText="Success" onClick={openToast(successToast)} />
      <ToastButton labelText="Info" onClick={openToast(infoToast)} />
      <ToastButton labelText="Warning" onClick={openToast(warningToast)} />
      <ToastButton labelText="Error" onClick={openToast(errorToast)} />
    </>
  );
};

export const ToastDifferentTypes = () => <Renderer Comp={ToastMultipleTypes} />;
`,locationsMap:{"basic-error":{startLoc:{col:26,line:30},endLoc:{col:57,line:30},startBody:{col:26,line:30},endBody:{col:57,line:30}},"toast-different-types":{startLoc:{col:35,line:86},endLoc:{col:79,line:86},startBody:{col:35,line:86},endBody:{col:79,line:86}}}}},title:"Components/ErrorToast",Component:S.Q};var _=function(o){var e=o.Comp,s=(0,m.useState)(!1),i=R()(s,2),u=i[0],y=i[1];return(0,m.useEffect)(function(){y(!0)},[]),u?n()(e,{}):null},L=function(){var o=(0,f.j)();return(0,m.useEffect)(function(){o(h.o.set({description:"This is Error Toast"}))},[o]),null},w=function(){return E||(E=n()(_,{Comp:L}))};w.displayName="BasicError";var l=function(o){var e=o.messageText,s=e===void 0?"Toast Message":e,i=o.type,u=i===void 0?a.Ck.DEFAULT:i,y=T()(o,A);return h.o.set(Object.assign({type:u,messageText:s,messageTitle:u,containerId:"app-toast"},y))},v=function(o){return l(Object.assign({},o,{type:a.Ck.SUCCESS}))},I=function(o){return l(Object.assign({},o,{type:a.Ck.INFO}))},j=function(o){return l(Object.assign({},o,{type:a.Ck.WARNING}))},P=function(o){return l(Object.assign({},o,{type:a.Ck.ERROR}))},p=function(o){var e=o.labelText,s=o.onClick;return n()(k.IF,{buttonType:"text",labelText:e,onClick:s})};p.displayName="ToastButton";var F=function(){var o=(0,f.j)(),e=function(s){return function(){return o(s({description:"This is Error Toast"}))}};return(0,C.jsxs)(C.Fragment,{children:[n()(p,{labelText:"Success",onClick:e(v)}),n()(p,{labelText:"Info",onClick:e(I)}),n()(p,{labelText:"Warning",onClick:e(j)}),n()(p,{labelText:"Error",onClick:e(P)})]})},g=function(){return x||(x=n()(_,{Comp:F}))};g.displayName="ToastDifferentTypes";var W=["BasicError","ToastDifferentTypes"]},"./node_modules/.pnpm/obj-str@1.1.0/node_modules/obj-str/dist/obj-str.mjs":(b,c,t)=>{t.d(c,{A:()=>d});function d(T){var r,n="";for(r in T)T[r]&&(n&&(n+=" "),n+=r);return n}}}]);
