"use strict";(self.webpackChunkweb_toolbox=self.webpackChunkweb_toolbox||[]).push([[255],{32376:(e,t,a)=>{a.d(t,{A:()=>s});var n=a(9950),r=a(69935),l=a(10226),o=a(67243),i=a.n(o),c=a(77671);const s=e=>{let{data:t,isDisabled:a,hoverMessage:o,feedbackMessage:s,Icon:m=r.A,...d}=e;const{setToasterState:u}=(0,c.dq)();return n.createElement(l.A,Object.assign({disabled:!t||a,title:null!==o&&void 0!==o?o:"Copy to clipboard",variant:"contained","data-testid":"copy-to-clipboard",color:"primary"},d,{onClick:()=>{if(!t)return;const e=null!==s&&void 0!==s?s:"Content copied into clipboard: ".concat(t.substring(0,25)," \u2026");i()(t,{format:"text/plain"}),u({open:!0,message:e,type:"success",autoHideDuration:2e3})}}),n.createElement(m,null))}},50057:(e,t,a)=>{a.d(t,{n:()=>c});var n=a(9950),r=a(25131),l=a(72772),o=a(73931);const i=(0,r.A)((e=>({root:{margin:e.spacing(1)}}))),c=e=>{let{title:t,iconType:a,children:r}=e;const c=i();return n.createElement(n.Fragment,null,n.createElement(l.m,{titleTemplate:"Web Toolbox - %s",defaultTitle:"Web Toolbox",title:t}),n.createElement("div",{className:c.root},n.createElement(o.A,{iconType:a,title:t}),r))}},73931:(e,t,a)=>{a.d(t,{A:()=>o});var n=a(9950),r=a(82053);const l=(0,a(25131).A)((e=>({title:{wordBreak:"break-word"},titleWithIcon:{display:"flex",justifyContent:"center",alignItems:"center",marginBottom:e.spacing(1)},icon:{height:"40px",width:"40px",marginRight:e.spacing(1)}}))),o=e=>{let{title:t,iconType:a}=e;const o=l();return n.createElement("div",{className:o.titleWithIcon},n.createElement(a,{className:o.icon}),n.createElement(r.A,{variant:"h5",className:o.title},t))}},38033:(e,t,a)=>{a.d(t,{y:()=>s});var n=a(9950),r=a(25131),l=a(20516),o=a(53702),i=a.n(o);const c=(0,r.A)((()=>({root:{"& .spinner_overlay":{background:"rgba(0, 0, 0, 0.3)"}}}))),s=e=>{let{active:t,children:a}=e;const r=c();return n.createElement(l.A,{classNamePrefix:"spinner_",className:r.root,active:t,spinner:n.createElement(i(),{color:"#bf3a2b"})},a)}},67255:(e,t,a)=>{a.r(t),a.d(t,{default:()=>R});var n=a(93325),r=a(9950),l=a(35607),o=a(13004),i=a(57669),c=a(25979),s=a(8145),m=a(23266),d=a(48089),u=a(16491),g=a(82053),p=a(50704),f=a(66699),v=a(83239),E=a(10226),b=a(27847),A=a(32376),h=a(50057),y=a(38033),x=a(77671),w=a(1810);const C={workerId:"",jobId:"",status:"",progress:0};var k=a(90797),I=a.n(k);var T=a(25131);const N={marginTop:10,display:"flex",alignItems:"center",justifyContent:"center",border:"solid 1px blue"},D=(0,T.A)((e=>({root:{margin:e.spacing(1)},form:{marginTop:e.spacing(2)},formControl:{margin:e.spacing(1),minWidth:120},image:{width:"100%"},imageSelector:{margin:e.spacing(2),textAlign:"center"},toolbar:{margin:0,padding:0,"& > *":{marginLeft:e.spacing(1)}},formatted:{padding:e.spacing(1),border:"1px solid grey",wordWrap:"break-word",height:116}}))),R=()=>{const e=D(),t=(0,w.Pb)("md"),{setToasterState:a}=(0,x.dq)(),[k,T]=r.useState("eng"),[R,S]=r.useState(C),[W,F]=r.useState(""),[j,P]=r.useState("");function L(e){S(e),P("Processing the image\n\t \u2192 ".concat(e.status,"\u2026"))}function _(e){!function(e,t){if(e)for(let a=0;a<e.length;a++){const n=e[a];if(n.type.startsWith("image")){const e=new FileReader;e.onload=t,e.readAsDataURL(n.getAsFile());break}}}((e.clipboardData||e.originalEvent.clipboardData||e.originalEvent.clipboard).items,(e=>{var t;return F(null===(t=e.target)||void 0===t?void 0:t.result)}))}return r.useEffect((()=>(document.onpaste=_,()=>document.removeEventListener("onpaste",_))),[]),r.createElement(h.n,{iconType:i.A,title:"Image OCR (text extraction)"},r.createElement("form",{noValidate:!0,autoComplete:"off",className:e.form},r.createElement(c.A,{className:e.formControl},r.createElement(s.A,{select:!0,label:"Image language",id:"language",style:{width:160},value:k,autoFocus:t,onChange:e=>T(e.target.value)},r.createElement(m.A,{value:"eng"},"English"),r.createElement(m.A,{value:"fra"},"French")))),r.createElement(d.A,null,r.createElement(u.A,{component:"div",alignItems:"center",justifyContent:"center",className:e.imageSelector},!W&&r.createElement("div",null,r.createElement(g.A,null,"paste image from clipboard"),r.createElement(g.A,null,"or select a file"),r.createElement("input",{type:"file",color:"primary",accept:"image/*",onChange:e=>{var t;return function(e){if(!e)return;const t=new FileReader;t.onload=e=>{var t;return F(null===(t=e.target)||void 0===t?void 0:t.result)},t.readAsDataURL(e)}(null===(t=e.target.files)||void 0===t?void 0:t[0])},id:"files-selector-action",style:{display:"none"}}),r.createElement("label",{htmlFor:"files-selector-action"},r.createElement(E.A,{variant:"contained",component:"span",color:"primary"},r.createElement(o.A,null)))),W&&r.createElement(b.c,{style:N,defaultSize:{width:300,height:"100%"}},r.createElement("img",{src:W,alt:"Clipboard content",className:e.image}))),W&&r.createElement(u.A,{component:"div",alignItems:"center",justifyContent:"center"},r.createElement(E.A,{endIcon:r.createElement(l.A,null),variant:"contained",color:"primary",onClick:function(e){e.preventDefault(),S(C),F(""),P("")}},"Clear")),r.createElement(p.A,null,r.createElement(y.y,{active:j.startsWith("Processing")},r.createElement(s.A,{label:"Extracted text",fullWidth:!0,value:j,margin:"normal",variant:"outlined",multiline:!0,minRows:"8"})),r.createElement(f.A,{variant:"determinate",value:100*R.progress}),r.createElement(v.A,{className:e.toolbar},r.createElement(u.A,{component:"div",flexGrow:1}),r.createElement(A.A,{data:j,sx:{mr:1}}),r.createElement(E.A,{variant:"contained",title:"Run optical caracters recognition process to extract text",color:"primary",onClick:function(e){if(e.preventDefault(),!W)return void a({open:!0,message:"There is no image to process",type:"error",autoHideDuration:2e3});P("Processing the image, please wait\u2026");const t=n.Buffer.from(W.split(",")[1],"base64");(async function(e,t,a,n){n((await I().recognize(t,e,{logger:a})).data.text)})(k,t,L,P).then()},disabled:!W,endIcon:r.createElement(i.A,null)},"Run")))))}}}]);