1import{a as e,i as t,r as n,s as r}from"./loadReactComponent.CRGJNnQn.chunk.js";import{l as i}from"./api.generated._yGp5TCT.chunk.js";import{t as a}from"./classnames.Bais1xbC.chunk.js";import{n as o}from"./index.esm.Bkwclt4j.chunk.js";import{t as s}from"./purify.es.CYRiAeUx.chunk.js";import{t as c}from"./withClientOnly.CVf8Abam.chunk.js";import{n as l,t as u}from"./withApiProvider.sxRx6nyi.chunk.js";var d=r(a(),1),f=r(e(),1),p=function(e){return e[e.Ready=0]=`Ready`,e[e.Submitting=1]=`Submitting`,e[e.Success=2]=`Success`,e[e.Error=3]=`Error`,e}({}),m=e=>{let{feedbackApiClient:t}=(0,f.useContext)(l),{register:n,handleSubmit:r,formState:{isSubmitting:i,isSubmitSuccessful:a,errors:c},setError:u,setValue:d,watch:p}=o({defaultValues:{contentId:e.contentId}}),m=p(`answer`),h=p(`comment`),g=p(`comment2`),_=n(`comment2`),v=n(`answer`),y=n(`comment`,{required:m===!1&&e.emptyCommentErrorMessage,maxLength:{value:e.characterLimit,message:e.commentTooLongErrorMessage},pattern:{value:new RegExp(e.feedbackInputValidation),message:e.invalidInputErrorMessage}}),b=r(async n=>{let r={ALLOWED_TAGS:[]};if(s.isSupported==0){u(`serverError`,{message:`Dompurify is not supported.`});return}let i=s.sanitize(h??``,r),a=s.sanitize(g??``,r);try{await t.feedback({...n,comment:i,comment2:a,screenSize:screen.width})}catch{u(`serverError`,{message:e.responseErrorMessage})}}),x=i?1:a?2:c.serverError?3:0;return{onSubmit:b,answer:{value:m,register:v,set:e=>{d(`answer`,e),c.comment?.type===`required`&&(c.comment=null)}},comment:{value:h,register:y,error:c.comment?.message},comment2:{value:g,register:_},error:c.serverError?.message,state:x}},h={feedback:`_feedback_155922e`,feedback__fieldset:`_feedback__fieldset_a4f54f6`,feedback__legend:`_feedback__legend_6395dee`,"feedback__radio-group":`_feedback__radio-group_d7c49e1`,"feedback__radio-label":`_feedback__radio-label_dda8318`,feedback__radio:`_feedback__radio_81cfdec`,feedback__radios:`_feedback__radios_92c717e`,feedback__buttons:`_feedback__buttons_2310d6c`,"feedback__radios--send":`_feedback__radios--send_43271f6`,"feedback__buttons--send":`_feedback__buttons--send_83d0497`,feedback__button:`_feedback__button_08a7806`,feedback__answer:`_feedback__answer_73fbeca`,"feedback__comment-wrapper":`_feedback__comment-wrapper_d039a1f`,"feedback__comment-label":`_feedback__comment-label_9d4b516`,"feedback__comment-description":`_feedback__comment-description_4c85b67`,"feedback__comment-description--required":`_feedback__comment-description--required_3992946`,feedback__comment:`_feedback__comment_bc09f75`,feedback__status:`_feedback__status_640843a`,"feedback__status--error":`_feedback__status--error_181f0a6`,feedback__success:`_feedback__success_df169ff`},g=t(),_=`feedback-comment`,v=`feedback-radio`,y=`feedback-error`,b=`feedback-yes`,x=`feedback-no`,S=({model:e})=>{let{onSubmit:t,answer:n,comment:r,comment2:i,error:a,state:o}=m(e),s=(0,f.useRef)(null),c=e=>{n.set(e.currentTarget.value===`true`)},l=e.characterLimitText.replace(`{count}`,r.value?.length.toString()??`0`).replace(`{limit}`,e.characterLimit.toString()),u=o===p.Success;return(0,f.useEffect)(()=>{u&&s.current&&(s.current.innerText=e.successMessage)},[u]),o===p.Error?(0,g.jsx)(`p`,{role:`alert`,children:a}):(0,g.jsxs)(`form`,{onSubmit:t,className:(0,d.default)(h.feedback,`feedback`),children:[o!==p.Success&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`input`,{type:`hidden`,...n.register}),(0,g.jsxs)(`fieldset`,{className:h.feedback__fieldset,children:[(0,g.jsx)(`legend`,{className:h.feedback__legend,children:e.title}),(0,g.jsxs)(`div`,{className:h.feedback__radios,children:[(0,g.jsxs)(`div`,{className:h[`feedback__radio-group`],children:[(0,g.jsx)(`input`,{type:`radio`,id:b,className:h.feedback__radio,name:v,onChange:c,value:`true`,checked:n.value===!0,disabled:o!==p.Ready}),(0,g.jsx)(`label`,{htmlFor:b,className:h[`feedback__radio-label`],children:e.yesButtonText})]}),(0,g.jsxs)(`div`,{className:h[`feedback__radio-group`],children:[(0,g.jsx)(`input`,{type:`radio`,id:x,className:h.feedback__radio,name:v,onChange:c,value:`false`,checked:n.value===!1,disabled:o!==p.Ready}),(0,g.jsx)(`label`,{htmlFor:x,className:h[`feedback__radio-label`],children:e.noButtonText})]})]})]})]}),(0,g.jsx)(`div`,{"aria-live":`polite`,"data-testid":`feedback-success`,className:(0,d.default)(h.feedback__success,!u&&`visuallyhidden`),ref:s}),o!==p.Success&&(n.value===!1||n.value===!0)&&(0,g.jsxs)(`div`,{className:h[`feedback__comment-wrapper`],children:[(0,g.jsxs)(`label`,{htmlFor:_,className:h[`feedback__comment-label`],children:[(0,g.jsx)(`span`,{children:n.value===!0?e.yesCommentLabel:e.commentLabel}),(0,g.jsx)(`span`,{children:e.commentDescription}),n.value===!1&&(0,g.jsx)(`span`,{className:h[`feedback__comment-description--required`],children:e.requiredFieldText})]}),(0,g.jsx)(`textarea`,{"aria-required":!0,id:_,...r.register,"aria-invalid":r.error?`true`:`false`,"aria-describedby":y,className:h.feedback__comment,"data-testid":`feedback-comment`}),(0,g.jsxs)(`div`,{className:(0,d.default)(h.feedback__status,r.error&&h[`feedback__status--error`]),id:y,children:[(0,g.jsx)(`span`,{"aria-live":`assertive`,"data-testid":`feedback-error`,children:r.error}),(0,g.jsx)(`span`,{"aria-live":`polite`,children:l})]}),(0,g.jsx)(`label`,{htmlFor:`etyphoon`,className:`skjultfelt`,children:`Skal ikke fylles ut`}),(0,g.jsx)(`input`,{name:`etyphoon`,id:`etyphoon`,title:`Skal ikke fylles ut`,className:`skjultfelt`,...i.register}),(0,g.jsx)(`div`,{className:(0,d.default)(h.feedback__buttons,h[`feedback__buttons--send`]),children:(0,g.jsx)(`button`,{type:`submit`,disabled:o===p.Submitting,className:(0,d.default)(`btn-primary`,h.feedback__button),children:e.submitButtonText})})]})]})},C=c(u(e=>(0,g.jsx)(S,{...e})));n(i.FeedbackComponent,C);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.