import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t,t as n}from"./jsx-runtime-CiQ1k8xo.js";import{t as r}from"./clsx-BcPLHiun.js";import{c as i,o as a}from"./lib-MoKmYgcO.js";import{t as o}from"./button-Bi7lGVi1.js";import{a as s,i as c,l,n as u,o as d,r as f}from"./dialog-layout-CJEsoqFP.js";import{t as p}from"./check-md-BzLzXDM7.js";import{t as m}from"./plus-d3DP-DMx.js";var h=e(t(),1),g=n();function _({belowFreeformContent:e,closeOnSubmit:t=`after-submit`,freeformFeedbackRequired:n,onClose:_,onSubmit:v,options:y}){let b=i(),[x,S]=(0,h.useState)(``),[C,w]=(0,h.useState)(!1),[T,E]=(0,h.useState)(null),D=x.trim(),O=n?b.formatMessage({id:`feedbackFormDialog.detailsPlaceholder.required`,defaultMessage:`Share details (required)`,description:`Placeholder for a required freeform feedback details field`}):b.formatMessage({id:`feedbackFormDialog.detailsPlaceholder.optional`,defaultMessage:`Share details (optional)`,description:`Placeholder for an optional freeform feedback details field`}),k=b.formatMessage({id:`feedbackFormDialog.optionsLabel`,defaultMessage:`Feedback options`,description:`Accessible label for feedback options`}),A=T==null||n&&D.length===0;return(0,g.jsx)(l,{open:!0,onOpenChange:e=>{e||_()},size:`wide`,children:(0,g.jsxs)(u,{as:`form`,className:`gap-2`,onSubmit:async e=>{if(e.preventDefault(),T==null||C||A)return;if(t===`immediate`){v({selectedOptionId:T,details:D})!==!1&&_();return}w(!0);let n=!1;try{n=await v({selectedOptionId:T,details:D})!==!1}finally{w(!1)}n&&_()},children:[(0,g.jsx)(s,{children:(0,g.jsx)(c,{title:(0,g.jsx)(a,{id:`feedbackFormDialog.title`,defaultMessage:`Share feedback`,description:`Title for feedback dialog`}),titleSize:`dialog`})}),(0,g.jsx)(s,{children:(0,g.jsxs)(d,{className:`gap-3`,children:[(0,g.jsx)(`div`,{role:`radiogroup`,"aria-label":k,className:`flex flex-wrap gap-2`,children:y.map(e=>{let t=T===e.id,n=t?p:m;return(0,g.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,onClick:()=>{E(e.id)},className:r(`border-token-border cursor-interaction flex items-center gap-1 rounded-full border px-3 py-1`,`focus-visible:ring-token-focus-border focus-visible:outline-none focus-visible:ring-1`,t?`bg-token-foreground text-token-dropdown-background`:`text-token-foreground hover:bg-token-menu-background/60`),children:[(0,g.jsx)(n,{className:`icon-xxs`}),(0,g.jsx)(a,{...e.label})]},e.id)})}),(0,g.jsx)(`textarea`,{autoFocus:!0,className:`min-h-[120px] w-full rounded-2xl border border-token-border px-3 py-2 text-token-input-foreground shadow-sm outline-none focus:ring-1 focus:ring-token-focus-border`,placeholder:O,"aria-label":O,value:x,onChange:e=>{S(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&e.metaKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),e]})}),(0,g.jsx)(s,{children:(0,g.jsx)(f,{children:(0,g.jsx)(o,{color:`primary`,disabled:A,loading:C,type:`submit`,children:(0,g.jsx)(a,{id:`feedbackFormDialog.submit`,defaultMessage:`Submit`,description:`Label for the button that submits feedback`})})})})]})})}export{_ as t};
//# sourceMappingURL=feedback-form-dialog-Bq6t_qKM.js.map