{"version":3,"file":"PollCreationDialog.mjs","names":[],"sources":["../../../../../src/components/Poll/PollCreationDialog/PollCreationDialog.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport type { PollComposerState } from 'stream-chat';\nimport { MultipleAnswersField } from './MultipleAnswersField';\nimport { NameField } from './NameField';\nimport { OptionFieldSet } from './OptionFieldSet';\nimport { PollCreationDialogControls as DefaultPollCreationDialogControls } from './PollCreationDialogControls';\nimport { Prompt } from '../../Dialog';\nimport { SwitchField } from '../../Form/SwitchField';\nimport { useInteractionAnnouncements } from '../../Accessibility';\nimport { useMessageComposerController } from '../../MessageComposer/hooks/useMessageComposerController';\nimport { useComponentContext, useTranslationContext } from '../../../context';\nimport { useStateStore } from '../../../store';\n\nexport type PollCreationDialogProps = {\n  close: () => void;\n};\n\nconst pollComposerStateSelector = (state: PollComposerState) => ({\n  allow_answers: state.data.allow_answers,\n  allow_user_suggested_options: state.data.allow_user_suggested_options,\n  voting_visibility: state.data.voting_visibility,\n});\n\nexport const PollCreationDialog = ({ close }: PollCreationDialogProps) => {\n  const { PollCreationDialogControls = DefaultPollCreationDialogControls } =\n    useComponentContext();\n  const { t } = useTranslationContext();\n  const { announceInteraction } = useInteractionAnnouncements();\n  const { pollComposer } = useMessageComposerController();\n  const { allow_answers, allow_user_suggested_options, voting_visibility } =\n    useStateStore(pollComposer.state, pollComposerStateSelector);\n\n  useEffect(() => {\n    announceInteraction('poll.dialogOpened');\n  }, [announceInteraction]);\n\n  return (\n    <Prompt.Root\n      className='str-chat__poll-creation-dialog'\n      data-testid='poll-creation-dialog'\n    >\n      <Prompt.Header\n        close={close}\n        description={t(\n          'common.createQuestionAddOptions.label',\n          'Create a question, add options, and configure poll settings',\n        )}\n        title={t('poll.creationDialog.createPoll.title', 'Create Poll')}\n      />\n      <Prompt.Body>\n        <form autoComplete='off'>\n          <NameField />\n          <OptionFieldSet />\n          <div className='str-chat__poll-creation-dialog__features-selectors'>\n            <MultipleAnswersField />\n            <SwitchField\n              checked={voting_visibility === 'anonymous'}\n              description={t(\n                'poll.creationDialog.hideWhoVoted.description',\n                'Hide Who Voted',\n              )}\n              id='voting_visibility'\n              onChange={(e) =>\n                pollComposer.updateFields({\n                  data: { voting_visibility: e.target.checked ? 'anonymous' : 'public' },\n                })\n              }\n              title={t('poll.creationDialog.anonymousPoll.title', 'Anonymous Poll')}\n            />\n            <SwitchField\n              checked={allow_user_suggested_options}\n              description={t(\n                'poll.creationDialog.letOthersAddOptions.description',\n                'Let Others Add Options',\n              )}\n              id='allow_user_suggested_options'\n              onChange={(e) =>\n                pollComposer.updateFields({\n                  data: { allow_user_suggested_options: e.target.checked },\n                })\n              }\n              title={t('poll.actions.suggestOption.label', 'Suggest an Option')}\n            />\n            <SwitchField\n              checked={allow_answers}\n              description={t(\n                'poll.creationDialog.allowOthersAddComments.description',\n                'Allow Others to Add Comments',\n              )}\n              id='allow_answers'\n              onChange={(e) =>\n                pollComposer.updateFields({ data: { allow_answers: e.target.checked } })\n              }\n              title={t('poll.addCommentPrompt.addComment.label', 'Add a Comment')}\n            />\n          </div>\n        </form>\n      </Prompt.Body>\n      <PollCreationDialogControls close={close} />\n    </Prompt.Root>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAM,6BAA6B,WAA8B;CAC/D,eAAe,MAAM,KAAK;CAC1B,8BAA8B,MAAM,KAAK;CACzC,mBAAmB,MAAM,KAAK;AAChC;AAEA,IAAa,sBAAsB,EAAE,YAAqC;CACxE,MAAM,EAAE,4BAAA,+BAA6B,+BACnC,oBAAoB;CACtB,MAAM,EAAE,MAAM,sBAAsB;CACpC,MAAM,EAAE,wBAAwB,4BAA4B;CAC5D,MAAM,EAAE,iBAAiB,6BAA6B;CACtD,MAAM,EAAE,eAAe,8BAA8B,sBACnD,cAAc,aAAa,OAAO,yBAAyB;CAE7D,gBAAgB;EACd,oBAAoB,mBAAmB;CACzC,GAAG,CAAC,mBAAmB,CAAC;CAExB,OACE,qBAAC,OAAO,MAAR;EACE,W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