(self.webpackChunk_vtex_sales_app=self.webpackChunk_vtex_sales_app||[]).push([[209],{13374:function(e,t,n){"use strict";n.r(t),n.d(t,{SearchScreen:function(){return s}});var a=n(2784),r=n(96304),l=n(79325),c=n(12915),o=n(99654),u=n(5493),i=n(14822),s=function(){var e=(0,o.Gcp)().breakpoint,t=["mobile","tablet"].includes(e);return a.createElement(a.Fragment,null,!t&&a.createElement(u.$,null,a.createElement(c.Z,null)),a.createElement(u.cl,null,a.createElement("div",{className:(0,o.oBM)({display:"flex",justifyContent:"flex-end"})},a.createElement(i.P,{color:"black"}))),t&&a.createElement(u.nS,null,a.createElement("div",{className:(0,o.oBM)({paddingX:"$space-4"})},a.createElement(c.Z,null))),a.createElement(l.Z,null,a.createElement(r.c.SearchPageContainer,null)))}},77658:function(e,t,n){"use strict";n.r(t),n.d(t,{SearchScreen:function(){return x}});var a=n(2784),r=n(99654),l=n(30467),c=n(28264),o=n(22594),u=n(78053),i=n(24922),s=n(78970),m=n(92125),d=n(19745),f=n(42982),E=n(31720),p=n(91294),v=n(13661),h=function(){var e,t,n=(0,l.TH)(),h=(0,l.k6)(),b=(0,o.useDispatch)(),k=(0,E.F)().isNativeDevice,g=(0,p.G)(),B=g.barcode,x=g.openBarcodeReader,N=(0,a.useRef)(null),C=function(e){var t=(0,f.useQueryParams)(),n=(0,a.useState)(""),r=n[0],l=n[1];return(0,a.useEffect)((function(){var e,n=null!==(e=t.get("term"))&&void 0!==e?e:"";l(n)}),[t,e]),[r,l]}(n.hash.includes("#/search-mobile-modal")),y=C[0],$=C[1],w=(0,r.X9F)({open:n.hash.includes("#/search-mobile-modal")}),M=(0,d.R)(),S=M.search.recentTerms,P=M.addRecentTerm;(0,a.useEffect)((function(){var e;w.open&&(null===(e=N.current)||void 0===e||e.focus())}),[w]);var z=function(e){if(e||y&&""!==y.trim())return h.replace({pathname:"/new-search",search:"term="+(null!=e?e:y.trim()),state:{forceUpdate:(new Date).getTime()}})},R=function(e){(e||y&&""!==y.trim())&&(b(P({term:null!=e?e:y.trim(),productName:"",picture:""})),z(e))};(0,a.useEffect)((function(){B&&($(B),R(B))}),[B]);var T=function(e){e.preventDefault(),x()};return a.createElement(u.e,{state:w},a.createElement("div",{"data-testid":"search-modal-mobile"},a.createElement("div",{className:(0,r.oBM)({position:"sticky",top:0,backgroundColor:"white",zIndex:99999})},a.createElement(i.W,null,a.createElement(r.Kqy,{direction:"row",space:"$space-2"},a.createElement(r.zxk,{"data-testid":"search-modal-back-button",variant:"tertiary",icon:a.createElement(r.W3O,{color:"black"}),onClick:function(){$(""),h.goBack()},className:(0,r.oBM)((e={},e[(0,r.PB$)("size","normal")]={padding:0},e))}),a.createElement(s.M,{ref:N,value:y,onChange:function(e){return t=e.target.value,void $(t);var t},onSubmit:function(){return R()},onClear:function(){var e;$(""),null==N||null===(e=N.current)||void 0===e||e.focus()},className:(0,r.oBM)({flex:1}),handleScanClick:T})))),a.createElement("div",{className:(0,r.oBM)({overflowY:"auto",maxHeight:"40%",paddingX:"$space-5",paddingBottom:"$space-16"})},a.createElement(m.cN,null,null==S?void 0:S.map((function(e,t){var n=e.term,l=e.productName,c=e.picture;return a.createElement(m.HZ,{key:"RecentSearch-"+t,onPress:function(){return e=n,null==N||null===(t=N.current)||void 0===t||t.focus(),$(e),void z(e);var e,t}},a.createElement(r.kCb,{justify:"space-between"},c&&a.createElement(v.B,{name:l,picture:c}),a.createElement(m.lS,{name:l||n})),a.createElement(m.iV,null))})))),k&&a.createElement("div",{className:(0,r.oBM)({position:"fixed",bottom:"$space-4",backgroundColor:"$white",width:"full",paddingTop:"$space-2"})},a.createElement(r.zxk,{"data-testid":"search-modal-scan-button",variant:"tertiary",onClick:T,className:(0,r.oBM)((t={border:"$neutral",borderRadius:"2rem",width:"90%"},t[(0,r.PB$)("size","normal")]={marginX:"$space-5"},t))},a.createElement(c.Z,{id:"search.scan-button"})))))},b=n(59572),k=n(51826),g=n(33514),B=n(91689),x=function(){return a.createElement(g.Ee,null,a.createElement(b.T,{className:(0,r.oBM)({display:"flex",flex:1,"> div":{display:"flex",flex:1}})},a.createElement(k.NE,null),a.createElement(k.fz,null,a.createElement(k.x,null,a.createElement(B.ChunkLoadErrorBoundary,null,a.createElement(r.kCb,{className:(0,r.oBM)({flex:1})},a.createElement(k.X0,null),a.createElement(k.Uc,{itemsPerPage:12}))))),a.createElement(h,null)))}}}]);
//# sourceMappingURL=SearchScreen-68760a84c8354930a437.js.map