"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[2980,17,8414,5207,5228],{50599:(e,t,a)=>{a.r(t),a.d(t,{default:()=>u});var l=a(86087),n=a(5207),c=a(27723),o=a(32636),r=a(4219),i=a(45111),s=a(90017),d=a(59387),m=a(25228);const u=(0,l.memo)((({label:e,field:t})=>{const{fields:a,fileName:u,fetching:p,loadingFields:g,updating:_,regions:f,documentsLoaded:b,resetEditDocumentId:h,savedDocument:E,fetchData:z,fetchFields:y,updateField:v,save:w,editDocumentId:N,region:k,setRegion:C}=(0,n.default)(),[F,D]=(0,l.useState)(!0),[A,L]=(0,l.useState)(!1),[S,R]=(0,l.useState)(0),{allRequiredFieldsCompleted:I,fetchAllFieldsCompleted:q,fieldsLoaded:T,showSavedSettingsNotice:x}=(0,r.default)();let U=React.createRef();(0,l.useEffect)((()=>{N&&R(0),N&&U.current&&U.current.scrollIntoView({behavior:"smooth",block:"start"})}),[N]),(0,l.useEffect)((()=>{!b&&cmplz_settings.is_premium&&z()}),[b]),(0,l.useEffect)((()=>{q()}),[T]),(0,l.useEffect)((()=>{D(""===k)}),[k,p,N]);const j=async()=>{if(""!==E.downloadUrl){L(!0);const e=E.download_url;try{let t=new XMLHttpRequest;t.responseType="blob",t.open("get",e,!0),t.send(),t.onreadystatechange=function(){if(4===this.readyState&&200===this.status){let e=window.URL.createObjectURL(this.response),t=window.document.createElement("a");t.setAttribute("href",e),t.setAttribute("download",E.title),window.document.body.appendChild(t),t.click(),L(!1),setTimeout((function(){window.URL.revokeObjectURL(e)}),6e4)}}}catch(e){console.error(e),L(!1)}}},H=async()=>{await w(k),x()};(0,l.useEffect)((()=>{""===k||p||D(!1)}),[k,p]);let M=a.filter((e=>void 0===e.conditionallyDisabled||!1===e.conditionallyDisabled)),O=Math.ceil(M.length/5),P=(e=>{const t=5*(S-1),a=t+5;return e.slice(t,a)})(a);return(0,l.createElement)(l.Fragment,null,!I&&(0,l.createElement)("div",{className:"cmplz-locked"},(0,l.createElement)("div",{className:"cmplz-locked-overlay"},(0,l.createElement)("span",{className:"cmplz-task-status cmplz-warning"},(0,c.__)("Incomplete","complianz-gdpr")),(0,l.createElement)("span",null,(0,c.__)("The wizard has not been completed yet, but this field requires information from the wizard. Please complete the wizard first.","complianz-gdpr")))),0===S&&(0,l.createElement)(l.Fragment,null,N&&(0,l.createElement)("div",{className:"cmplz-selected-document"},u),(0,l.createElement)(d.default,{id:"region_for_databreaches",label:(0,c.__)("Region","complianz-gdpr"),required:!0,type:"select"}),(0,l.createElement)(m.default,{innerRef:U,disabled:_,onChange:e=>C(e),options:f,value:k,required:!0}),(0,l.createElement)("div",{className:"cmplz-table-header"},(0,l.createElement)(d.default,{id:"region_for_databreaches",label:(0,c.__)("Create Data Breach report","complianz-gdpr"),type:"button"}),(0,l.createElement)("div",{className:"cmplz-table-header-controls"},N&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("button",{disabled:_,className:"button button-default",onClick:()=>{h(),R(0)}},(0,c.__)("Cancel","complianz-gdpr")),(0,l.createElement)("button",{disabled:_,className:"button button-primary",onClick:()=>R(S+1)},(0,c.__)("Next","complianz-gdpr")),(0,l.createElement)("button",{disabled:_,className:"button button-primary",onClick:()=>H()},(0,c.__)("Save","complianz-gdpr"))),!N&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("button",{disabled:F||g,className:"button button-primary",onClick:()=>(async()=>{await y(k),R(1)})()},(0,c.__)("Create","complianz-gdpr"),g&&(0,l.createElement)(i.default,{name:"loading",color:"grey"})))))),S>0&&(0,l.createElement)(l.Fragment,null,S<=O&&P.map(((e,t)=>(0,l.createElement)(o.default,{key:t,index:t,field:e,isCustomField:!0,customChangeHandler:(e,t)=>((e,t)=>{v(e,t)})(e,t)}))),S>O&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(s.default,null)),(0,l.createElement)("div",{className:"cmplz-table-header"},(0,l.createElement)("div",{className:"cmplz-table-header-controls"},(0,l.createElement)("button",{disabled:_,className:"button button-default",onClick:()=>{h(),R(0)}},S<=O&&(0,c.__)("Cancel","complianz-gdpr"),S>O&&(0,c.__)("Exit","complianz-gdpr")),S<=O&&(0,l.createElement)("button",{className:"button button-default",onClick:()=>R(S-1)},(0,c.__)("Previous","complianz-gdpr")),S<O&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("button",{className:"button button-primary",onClick:()=>R(S+1)},(0,c.__)("Next","complianz-gdpr"))),S===O&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("button",{className:"button button-primary",onClick:()=>(async()=>{await w(k),x(),R(S+1)})()},(0,c.__)("Finish","complianz-gdpr"),_&&(0,l.createElement)(i.default,{name:"loading",color:"grey"}))),S>O&&E&&E.has_to_be_reported&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("button",{disabled:A,className:"button button-primary",onClick:()=>j()},(0,c.__)("Download","complianz-gdpr"))),N&&S<O&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("button",{disabled:_,className:"button button-primary",onClick:()=>H()},(0,c.__)("Save","complianz-gdpr")))))))}))},90017:(e,t,a)=>{a.r(t),a.d(t,{default:()=>i});var l=a(86087),n=a(5207),c=a(27723),o=a(4219),r=a(38414);const i=(0,l.memo)((()=>{const{savedDocument:e,conclusions:t}=(0,n.default)(),{addHelpNotice:a}=(0,o.default)();return(0,l.useEffect)((()=>{e.has_to_be_reported&&a("create-data-breach-reports","warning",(0,c.__)("This wizard is intended to provide a general guide to a possible data breach.","complianz-gdpr")+" "+(0,c.__)("Specialist legal advice should be sought about your specific circumstances.","complianz-gdpr"),(0,c.__)("Specialist legal advice required","complianz-gdpr"),!1)}),[e]),(0,l.createElement)(l.Fragment,null,(0,l.createElement)("div",{id:"cmplz-conclusion"},(0,l.createElement)("h3",null,(0,c.__)("Your dataleak report:","complianz-gdpr")),(0,l.createElement)("ul",{className:"cmplz-conclusion__list"},t.length>0&&t.map(((e,t)=>(0,l.createElement)(r.default,{conclusion:e,key:t,delay:1e3*t}))))))}))},38414:(e,t,a)=>{a.r(t),a.d(t,{default:()=>r});var l=a(86087),n=a(45111),c=a(42838),o=a.n(c);const r=(0,l.memo)((({conclusion:e,delay:t})=>{const[a,c]=(0,l.useState)(!0);(0,l.useEffect)((()=>{setTimeout((()=>{r()}),t)}));const r=()=>{c(!1)};let i="green";return"warning"===e.report_status&&(i="orange"),"error"===e.report_status&&(i="red"),(0,l.createElement)(l.Fragment,null,a&&(0,l.createElement)("li",{className:"cmplz-conclusion__check icon-loading"},(0,l.createElement)(n.default,{name:"loading",color:"grey"}),(0,l.createElement)("div",{className:"cmplz-conclusion__check--report-text"}," ",e.check_text," ")),!a&&(0,l.createElement)("li",{className:"cmplz-conclusion__check icon-"+e.report_status},(0,l.createElement)(n.default,{name:e.report_status,color:i}),(0,l.createElement)("div",{className:"cmplz-conclusion__check--report-text",dangerouslySetInnerHTML:{__html:o().sanitize(e.report_text)}}," ")))}))},5207:(e,t,a)=>{a.r(t),a.d(t,{default:()=>r});var l=a(81621),n=a(16535),c=a(9588),o=a(73710);const r=(0,l.vt)(((e,t)=>({documentsLoaded:!1,savedDocument:{},conclusions:[],region:"",fileName:"",fetching:!1,updating:!1,loadingFields:!1,documents:[],regions:[],fields:[],editDocumentId:!1,resetEditDocumentId:t=>{e({editDocumentId:!1,region:""})},editDocument:async t=>{e({updating:!0}),await c.doAction("load_databreach_report",{id:t}).then((t=>{e({fields:t.fields,region:t.region,updating:!1,fileName:t.file_name})})).catch((e=>{console.error(e)})),e({editDocumentId:t})},setRegion:t=>{e({region:t})},updateField:(a,l)=>{let c=!1,r=!1;e((0,n.Ay)((e=>{e.fields.forEach((function(e,t){e.id===a&&(r=t,c=!0)})),!1!==r&&(e.fields[r].value=l)})));let i=(0,o.updateFieldsListWithConditions)(t().fields);e({fields:i})},save:async a=>{e({updating:!0});let l=t().editDocumentId,n=0;await c.doAction("save_databreach_report",{fields:t().fields,region:a,post_id:l}).then((t=>(n=t.post_id,e({updating:!1,conclusions:t.conclusions}),t))).catch((e=>{console.error(e)})),await t().fetchData();let o=t().documents.filter((e=>e.id===n));o.length>0&&e({savedDocument:o[0]})},deleteDocuments:async a=>{let l=t().documents.filter((e=>a.includes(e.id)));e((e=>({documents:e.documents.filter((e=>!a.includes(e.id)))})));let n={};n.documents=l,await c.doAction("delete_databreach_report",n).then((e=>e)).catch((e=>{console.error(e)}))},fetchData:async()=>{if(t().fetching)return;e({fetching:!0});const{documents:a,regions:l}=await c.doAction("get_databreach_reports",{}).then((e=>e)).catch((e=>{console.error(e)}));e((e=>({documentsLoaded:!0,documents:a,regions:l,fetching:!1})))},fetchFields:async t=>{let a={region:t};e({loadingFields:!0});const{fields:l}=await c.doAction("get_databreach_report_fields",a).then((e=>e)).catch((e=>{console.error(e)}));let n=(0,o.updateFieldsListWithConditions)(l);e((e=>({fields:n,loadingFields:!1})))}})))},25228:(e,t,a)=>{a.r(t),a.d(t,{default:()=>r});var l=a(86087),n=a(45296),c=a(45111),o=a(27723);const r=(0,l.memo)((({value:e=!1,onChange:t,required:a,defaultValue:r,disabled:i,options:s={},canBeEmpty:d=!0,label:m})=>{if(Array.isArray(s)){let e={};s.map((t=>{e[t.value]=t.label})),s=e}return d?(""===e||!1===e||0===e)&&(e="0",s={0:(0,o.__)("Select an option","complianz-gdpr"),...s}):e||(e=Object.keys(s)[0]),(0,l.createElement)("div",{className:"cmplz-input-group cmplz-select-group",key:m},(0,l.createElement)(n.bL,{value:e,defaultValue:r,onValueChange:t,required:a,disabled:i&&!Array.isArray(i)},(0,l.createElement)(n.l9,{className:"cmplz-select-group__trigger"},(0,l.createElement)(n.WT,null),(0,l.createElement)(c.default,{name:"chevron-down"})),(0,l.createElement)(n.UC,{className:"cmplz-select-group__content",position:"popper"},(0,l.createElement)(n.PP,{className:"cmplz-select-group__scroll-button"},(0,l.createElement)(c.default,{name:"chevron-up"})),(0,l.createElement)(n.LM,{className:"cmplz-select-group__viewport"},(0,l.createElement)(n.YJ,null,Object.entries(s).map((([e,t])=>(0,l.createElement)(n.q7,{disabled:Array.isArray(i)&&i.includes(e),className:"cmplz-select-group__item",key:e,value:e},(0,l.createElement)(n.p4,null,t)))))),(0,l.createElement)(n.wn,{className:"cmplz-select-group__scroll-button"},(0,l.createElement)(c.default,{name:"chevron-down"})))))}))}}]);