6 lines
13 KiB
Plaintext
6 lines
13 KiB
Plaintext
"use strict";
|
||
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="af3a30d1-96f4-5aaf-a9d5-4dbb1ee3d1c4")}catch(e){}}();
|
||
(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[77],{1053:(e,t,s)=>{s.d(t,{ZP:()=>$});var o=s(9),n=s.n(o),i=s(180),l=s.n(i),c=s(0),r=s(10),a=s(66),d=s(399),h=s(731),p=s(746),u=s(72),g=s(99),m=s(737),_=s(397),S=s(21),C=s(15),x=s(33),N=s(17),b=s(18),f=s(729),j=s(1054),D=s(2433),P=s(825),v=s(867),y="D__v",Z="D__q",w=s(1);class T extends c.PureComponent{constructor(e){super(e),this.selectedCollectionButtonRef=void 0,this.timeShowPopover=void 0,this.onCollectionSearchUpdate=e=>{this.setState({searchInputValue:e.target.value}),this.updateSearchStringDebounced()},this.onSelectedCollectionButtonClick=()=>{const{props:{matchParams:e,queryKeyword:t,searchListingRequestId:s,trackBatchedEvent:o},state:{collectionsPopoverShow:n}}=this;if(this.setState({collectionsPopoverShow:!n}),n&&this.timeShowPopover)o({name:"filter_closed_button_tapped",properties:{context:"categories",time_on_page:Math.round(((new Date).getTime()-this.timeShowPopover)/1e3)},type:"action"});else if(!n&&e&&s){let n;this.timeShowPopover=(new Date).getTime(),t?n={browse_type:"search_results",filter_name:"categories",request_id:s,search_query:t}:e.collectionParam&&(n={browse_type:"categories",category_id:(0,N.py)(e.collectionParam),filter_name:"categories",request_id:s}),n&&o({name:"filter_bubble_tapped",properties:n,type:"action"})}},this.onPopoverHide=()=>{this.setState({collectionsPopoverShow:!1}),this.timeShowPopover&&this.props.trackBatchedEvent({name:"filter_closed_button_tapped",properties:{context:"categories",time_on_page:Math.round(((new Date).getTime()-this.timeShowPopover)/1e3)},type:"action"})},this.onSelectCollection=(e,t,s)=>{const{onSelectCollection:o,trackBatchedEvent:n,suggestedCollectionIDs:i}=this.props,{searchInputValue:l}=this.state;o({...e,isDrilldown:t?!!e.id&&!i?.includes(e.id):s,isSuggested:t},l),this.setState({collectionsPopoverShow:!1,searchInputValue:""}),this.updateSearchStringDebounced(),this.timeShowPopover&&n({name:"filter_apply_button_tapped",properties:{context:"categories",filter_applied:[{filter_name:"collection",filter_value:`${e.id}`}],time_on_page:Math.round(((new Date).getTime()-this.timeShowPopover)/1e3)},type:"action"})},this.updateSearchStringDebounced=l()(this.updateSearchString,300);const{openPopoverInitially:t,parentCollections:s}=e;this.selectedCollectionButtonRef=(0,c.createRef)(),this.state={collectionsPopoverShow:t??!1,filteredParentNodes:s,leafNodes:[],searchInputValue:"",searchString:"",suggestedNodes:[]}}componentDidMount(){this.setState({...this.getUpdatedCollectionNodes()})}componentDidUpdate(e){const{parentCollections:t,suggestedCollectionIDs:s}=this.props,{parentCollections:o,suggestedCollectionIDs:n}=e;o===t&&n===s||this.setState({...this.getUpdatedCollectionNodes()})}componentWillUnmount(){this.updateSearchStringDebounced.cancel()}render(){const{className:e="",useChip:t}=this.props;return(0,w.jsxs)("div",{className:`D__i ${e}`,children:[t?this.renderChip():this.renderSelect(),this.renderPopover()]})}renderChip(){const e=this.context,{selectedCollection:t}=this.props,{collectionsPopoverShow:s}=this.state;return(0,w.jsx)(j.Z,{icon:(0,w.jsx)(f.Z,{color:t?e.skyTeal90:e.urbanGrey90,direction:s?"up":"down",size:16,useTransition:!0}),design:"chip",onClick:this.onSelectedCollectionButtonClick,ref:this.selectedCollectionButtonRef,selected:!!t,children:t?.name??(0,w.jsx)(_.Z,{id:(0,b.ZP)("Category")})})}renderSelect(){const e=this.context,{selectedCollection:t}=this.props,{collectionsPopoverShow:s}=this.state,o=!!t&&"collection"===t.type&&t.ancestorNames.length>0;return(0,w.jsxs)("div",{className:n()("D__j",t?"D__l":"D__m",{D__k:s}),onClick:this.onSelectedCollectionButtonClick,ref:this.selectedCollectionButtonRef,children:[t?"collection"===t.type?(0,w.jsxs)("div",{children:[(0,w.jsx)(u.Z,{weight:"semibold",children:t.name}),o&&(0,w.jsx)(u.Z,{color:e.urbanGrey60,size:"s",children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("in %{ancestorNames}"),options:{ancestorNames:t.ancestorNames.join(" > ")}})})]}):(0,w.jsx)(u.Z,{weight:"semibold",children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("All Categories")})}):(0,w.jsx)(u.Z,{children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("Select a category")})}),(0,w.jsx)(f.Z,{direction:s?"up":"down",size:24,useTransition:!0})]})}renderPopover(){const{localizeText:e}=this.props,{collectionsPopoverShow:t,filteredParentNodes:s,leafNodes:o,searchInputValue:n}=this.state,i=0===o.length&&0===s.length;return(0,w.jsxs)(p.Z,{className:"D__n",container:this,onHide:this.onPopoverHide,show:t,target:this.selectedCollectionButtonRef.current,children:[(0,w.jsx)(h.Z,{autoFocus:!0,classNameInputContainer:"D__o",iconRightURL:v,onChange:this.onCollectionSearchUpdate,placeholder:e((0,b.ZP)("Search for a category...")),value:n}),i?this.renderNoResults():this.renderResults()]})}renderNoResults(){return(0,w.jsx)(u.Z,{className:"D__p",children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("No search results")})})}renderResults(){const{displayTopLevelParentImages:e=!1,showAllCategoriesOption:t,showAllSubcategoriesOption:s,useChip:o}=this.props,{filteredParentNodes:n,leafNodes:i,searchString:l,suggestedNodes:c}=this.state;return(0,w.jsxs)(w.Fragment,{children:[c.map(((t,n)=>(0,w.jsx)(A,{collection:t,displayParentImage:e&&"all"!==t.type&&0===t.ancestorNames.length,isShortcutLeafCollection:!0,onSelectCollection:e=>this.onSelectCollection(e,!0),searchString:l,showAllSubcategoriesOption:s,showSuggestedTag:!0,useChip:o},`${"collection"===t.type?t.id:""}${n}`))),t&&""===l&&(0,w.jsx)(A,{collection:{type:"all"},onSelectCollection:this.onSelectCollection,searchString:l,useChip:o},"all"),i.map(((e,t)=>(0,w.jsx)(A,{collection:e,isShortcutLeafCollection:!0,onSelectCollection:e=>this.onSelectCollection(e,!1,!0),searchString:l,useChip:o},`${"collection"===e.type?e.id:""}${t}`))),n.map(((t,n)=>(0,w.jsx)(A,{collection:t,displayParentImage:e&&"all"!==t.type&&0===t.ancestorNames.length,onSelectCollection:this.onSelectCollection,searchString:l,showAllSubcategoriesOption:s,useChip:o},`${"collection"===t.type?t.id:""}${n}`)))]})}getUpdatedCollectionNodes(){const{parentCollections:e,suggestedCollectionIDs:t}=this.props,{searchInputValue:s}=this.state,o=(0,D.c)(e,s);return{filteredParentNodes:o,leafNodes:s?(0,D.QT)(o):[],suggestedNodes:s?[]:(0,D.a3)(e,t)}}updateSearchString(){const{searchInputValue:e}=this.state;this.setState({...this.getUpdatedCollectionNodes(),searchString:e})}}T.defaultProps={className:""},T.contextType=g.WE;const $=(0,r.$j)((function(e,t){const{search:s}=(0,C.o2)(e);return{localizeText:(0,S.l$)(e),parentCollections:(0,D.ZA)(e,{sort:t.sort}),queryKeyword:s??t.matchParams?.query,searchListingRequestId:(0,P.qW)(e)}}),(function(e){return(0,a.DE)({trackBatchedEvent:x.Vh},e)}))(T);class A extends c.PureComponent{constructor(e){super(e),this.onCollectionCellClick=e=>{const{isExpanded:t}=this.state;this.setState({isExpanded:!t})},this.onSelectCollection=()=>{const{collection:e,onSelectCollection:t}=this.props;t(e)},this.state={isExpanded:!1}}render(){const{collection:e}=this.props;return"all"===e.type?(0,w.jsx)("div",{className:`${Z} ${y}`,onClick:this.onSelectCollection,children:(0,w.jsx)(u.Z,{children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("All Categories")})})}):"collection"===e.type&&e.subcollections.length>0?this.renderParentCollection():this.renderLeafCollection()}renderParentCollection(){const{collection:e,level:t,onSelectCollection:s,searchString:o,showAllSubcategoriesOption:n,useChip:i}=this.props,{isExpanded:l}=this.state;return"all"===e.type?null:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:`${Z} D__r`,onClick:this.onCollectionCellClick,children:[this.renderImageAndName(),this.renderSuggestedTagAndArrow()]}),l&&(0,w.jsxs)(w.Fragment,{children:[n&&(0,w.jsx)("div",{className:`${Z} ${y}`,onClick:this.onSelectCollection,children:(0,w.jsxs)(u.Z,{children:[(0,w.jsx)(u.Z,{inline:!0,children:`${" ".repeat(t+1)}`}),(0,w.jsx)(m.Z,{id:(0,b.ZP)("All %{collectionName}"),options:{collectionName:this.renderName(e.name)}})]})}),e.subcollections.map(((e,l)=>"collection"===e.type?(0,w.jsx)(A,{collection:e,level:t+1,onSelectCollection:s,searchString:o,showAllSubcategoriesOption:n,useChip:i},`${e.id}${l}`):null))]})]})}renderImageAndName(){const{collection:e,displayParentImage:t=!1,level:s}=this.props;return"all"===e.type?null:(0,w.jsxs)("div",{className:"D__s",children:[t&&e.image_urls.homescreen?(0,w.jsx)(d.Z,{className:"D__t",crossOrigin:!0,src:e.image_urls.homescreen}):null,(0,w.jsxs)("span",{children:[`${" ".repeat(s)}`,this.renderName(e.name)]})]})}renderSuggestedTagAndArrow(){const{isExpanded:e}=this.state;return(0,w.jsxs)("div",{className:"D__u",children:[this.renderSuggestedTag(),(0,w.jsx)(f.Z,{direction:e?"down":"right",useTransition:!0})]})}renderLeafCollection(){const{collection:e,isShortcutLeafCollection:t,level:s=0,showSuggestedTag:o,useChip:i}=this.props,l=this.context;if("all"===e.type)return null;const c=!!e&&e.ancestorNames.length>0;return(0,w.jsxs)("div",{className:n()(Z,y,{D___:!!i,D__A:!!o}),onClick:this.onSelectCollection,children:[(0,w.jsxs)("div",{className:"D__w",children:[(0,w.jsxs)("span",{className:"D__x",children:[`${" ".repeat(s)}`,this.renderName(e.name)]}),e&&t&&c&&(i?(0,w.jsx)(u.Z,{color:l.urbanGrey50,singleline:!0,size:"xs",children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("in %{ancestorName}"),options:{ancestorName:e.ancestorNames[0]}})}):(0,w.jsx)(u.Z,{color:l.urbanGrey60,size:"s",children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("in %{ancestorNames}"),options:{ancestorNames:e.ancestorNames.join(" > ")}})}))]}),this.renderSuggestedTag()]})}renderName(e){const{searchString:t}=this.props,s=e.toLowerCase().indexOf(t.toLowerCase());if(""===t||-1===s)return(0,w.jsx)(u.Z,{inline:!0,children:e});const o=e.substring(0,s),n=e.substring(s,s+t.length),i=e.substring(s+t.length);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(u.Z,{inline:!0,weight:"semibold",children:o}),(0,w.jsx)(u.Z,{inline:!0,children:n}),(0,w.jsx)(u.Z,{inline:!0,weight:"semibold",children:i})]})}renderSuggestedTag(){const{showSuggestedTag:e}=this.props;return e?(0,w.jsx)("div",{className:"D__y",children:(0,w.jsx)(u.Z,{className:"D__z",inline:!0,singleline:!0,size:"s",children:(0,w.jsx)(_.Z,{id:(0,b.ZP)("Suggested")})})}):null}}A.defaultProps={isShortcutLeafCollection:!1,level:0},A.contextType=g.WE},1054:(e,t,s)=>{s.d(t,{Z:()=>$});var o={};s.r(o),s.d(o,{containedRed:()=>d,containedTeal:()=>h,container:()=>p,iconLeft:()=>u,iconRight:()=>g,label:()=>m,selected:()=>_,text:()=>S,textWrapper:()=>C,textWrapperMaxWidth:()=>x});var n={};s.r(n),s.d(n,{containedRed:()=>N,containedTeal:()=>b,container:()=>f,iconLeft:()=>j,iconRight:()=>D,label:()=>P,selected:()=>v,text:()=>y,textWrapper:()=>Z});var i=s(9),l=s.n(i),c=s(0),r=s(40),a=s(72),d="D_abJ",h="D_abI",p="D_abA",u="D_abC",g="D_abE",m="D_abB",_="D_abK",S="D_abF",C="D_abG",x="D_abH",N="D_abT",b="D_abS",f="D_abL",j="D_abN",D="D_abO",P="D_abM",v="D_abR",y="D_abP",Z="D_abQ",w=s(1);const T=(e,t)=>{const s="chip"===e.design?o:n,i=e.type??"containedTeal",c=l()({[s.containedTeal]:"chip"===e.design&&"containedTeal"===i,[s.containedRed]:"chip"===e.design&&"containedRed"===i}),d=()=>{const t=l()({[s.iconLeft]:"left"===e.iconPosition,[s.iconRight]:"left"!==e.iconPosition});return(0,w.jsxs)(w.Fragment,{children:[e.iconSecondary?(0,w.jsx)("div",{className:t,children:e.iconSecondary}):null,e.icon?(0,w.jsx)("div",{className:t,children:e.icon}):null]})};return(0,w.jsx)("div",{ref:t,children:(0,w.jsxs)("button",{className:l()(e.className,s.container,c,{[s.selected]:!!e.selected}),onClick:e.onClick,type:"button",children:["left"===e.iconPosition&&d(),(0,w.jsxs)("div",{className:l()(s.textWrapper,{[s.textWrapperMaxWidth]:e.hasFiltersBubble}),children:[e.label?(0,w.jsx)(a.Z,{className:s.label,inline:!0,children:`${e.label}:`}):null,(0,w.jsx)(a.Z,{className:s.text,color:r.NO_COLOR,inline:!0,children:e.children})]}),"left"!==e.iconPosition&&d()]})})},$=c.forwardRef(T)},2433:(e,t,s)=>{s.d(t,{QT:()=>d,ZA:()=>l,ZE:()=>c,a3:()=>h,c:()=>a});var o=s(67),n=s(73),i=s(113);const l=(0,o.P1)([n.Z2,n.hW],((e,t)=>t.filter((e=>e!==i.HC&&e!==i.K2)).map((t=>e[`${t}`])).map((t=>r(t,e))))),c=(0,o.P1)([n.$k,n.Z2,n.v2],((e,t,s)=>s?r(s,t,e):null));function r(e,t,s=[]){const{cc_id:o,id:n,image_urls:i,is_mall_enabled:l,name:c,subcategories:a}=e,d=s.map((e=>`${e.slug}-${e.id}`));return{ancestorNames:s.map((e=>e.name)),cc_id:o,id:n,image_urls:i,is_mall_enabled:l,name:c,slug:[...d,`${e.slug}-${e.id}`].join("/"),subcollections:a.map((o=>r(t[`${o}`],t,[...s,e]))),type:"collection"}}function a(e,t){if(""===t)return e;const s=e.reduce(((e,s)=>{const o=function(e,t){if("all"===e.type)return null;const s=e.name.toLowerCase().indexOf(t.toLowerCase());if(-1!==s)return{filteredParentNode:e,order:s};const o=JSON.parse(JSON.stringify(e));return o.subcollections=a(o.subcollections,t),o.subcollections.length>0?{filteredParentNode:o,order:-1}:null}(s,t);return o?[...e,o]:e}),[]);return s.sort(((e,t)=>e.order-t.order)).map((e=>e.filteredParentNode))}function d(e){return e.reduce(((e,t)=>"all"===t.type?e:0===t.subcollections.length?0===t.ancestorNames.length?e:[...e,t]:e.concat(d(t.subcollections))),[])}function h(e,t){return null==t?[]:e.reduce(((e,s)=>"all"===s.type?e:t.includes(s.id)?[...e,s]:[...e,...h(s.subcollections,t)]),[])}}}]);
|
||
//# sourceMappingURL=https://mdev.llesuorac.com/01857052a1fbff6c7926249973b6164fd2b19d8b/7c97269d827b9c24.min.js.map
|
||
//# debugId=af3a30d1-96f4-5aaf-a9d5-4dbb1ee3d1c4
|