"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[3003],{57901:(e,t,n)=>{n.d(t,{D:()=>f,S:()=>m,a:()=>w,b:()=>v,c:()=>d,d:()=>o,e:()=>g,f:()=>u,g:()=>p,h:()=>x,i:()=>j,j:()=>L,k:()=>l,l:()=>O,n:()=>y,r:()=>c,s:()=>h});var r=n(89379);const s=e=>{let{options:t=[],state:n}=e;return t.map((e=>{const{displayAt:t}=e;return((e,t)=>{if(!e)return!0;const n=Object.keys(e);for(let r=0;re))},a=e=>{let{options:t=[],state:n}=e;return t.map((e=>{const{hiddenAt:t}=e;return((e,t)=>{if(!e)return!0;const n=Object.keys(e);for(let r=0;re))},i=e=>"&!".concat(JSON.stringify(e).replace(/"/g,'\\"')),o=e=>Object.keys(e).reduce(((t,n)=>{const s=e[n];if("string"==typeof s&&s.startsWith("&!")){const e=s.split("&!")[1];return(0,r.A)((0,r.A)({},t),JSON.parse(e.replace(/\\"/g,'"')))}return(0,r.A)((0,r.A)({},t),{},{[n]:s})}),{}),l=(e,t)=>{for(let n=0;n{if(!t)return[];const o=(e=>{var t,n;return null!==(t=e[0])&&void 0!==t&&t.level||null!==(n=e[0])&&void 0!==n&&n.tree?e.map((e=>{let t={};return e.level&&(t[e.level]=e.id),e.tree&&(t=(0,r.A)((0,r.A)({},t),e.tree)),(0,r.A)((0,r.A)({},e),{},{id:i(t)})})):e})(t),l=a({options:o,state:n});return s({options:l,state:n})},u=(e,t,n,s)=>{if(!s)return!1;if("object"!=typeof s)return s;const a=Object.keys(s).map((e=>{if("object"!=typeof s[e])return!1;if(!0===s[e][t[e]])return!0;if("object"==typeof s[e][t[e]]){const n=s[e][t[e]];return Object.keys(n).map((e=>"object"==typeof n[e]&&!!n[e][t[e]])).reduce(((e,t)=>e||t),!1)}return!1})).reduce(((e,t)=>e||t),!1);return!a&&t[e]&&n((t=>(0,r.A)((0,r.A)({},t),{},{[e]:!1}))),a},d=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(0===e.length)return!1;for(let n=0;n0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(0===e.length)return"";const n=new URLSearchParams;for(let r=0;r(null==t?void 0:t.reduce((e=>(t,n)=>{const s=e[n];return(0,r.A)((0,r.A)({},t),{},{[n]:s})})(e),{}))||null,f="selector",g="switch",m="searchbox",A={[f]:e=>{let{options:[t=null]=[]}=e;return t&&t.id},[g]:()=>!1,[m]:()=>null},S=(e,t)=>null==t?void 0:t[e],b={[f]:S,[g]:S,[m]:(e,t)=>{const n=null==t?void 0:t[e];return n?i(n):null}},v=(e,t)=>e.reduce(((e,n)=>{const{id:s,type:a}=n,i=A[a],o=b[a];if(!o)return e;const l=o(s,t)||i(n,t);return(0,r.A)((0,r.A)({},e),{},{[s]:l})}),{}),w=(e,t)=>{if(e===t)return!0;const n=Object.keys(e);for(let r=0;r{},O=e=>t=>{let{label:n}=t;return-1!==n.toLowerCase().indexOf(e.toLowerCase())},x=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const[n,r=""]=e.split("?"),s=[r,t].filter((e=>!!e));return"".concat(n,"?").concat(s.join("&"))},j=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Object.keys(e);for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:1;return e.trim().length>=t}},83003:(e,t,n)=>{n.d(t,{D:()=>w,F:()=>h,H:()=>V,a:()=>y,b:()=>O,c:()=>q,d:()=>H,e:()=>A,f:()=>g,u:()=>z});var r=n(5556),s=n(73620),a=n(89379),i=n(96540),o=n(71440),l=n(57901),c=n(80045),u=n(74848),d=n(89557);(0,r.arrayOf)((0,r.shape)({fieldName:r.string,field:(0,r.oneOf)(["switch","selector","searchbox","not supported"])})).isRequired,r.string,r.func,r.func,(0,r.shape)({}),(0,r.shape)({label:r.string,onAction:r.func}),(0,r.shape)({});const h={callToAction:null,onChange:null,onAction:null,headers:null,secondaryAction:null,initialState:null};var p=(e,t)=>{const n=(0,i.useRef)(!1);(0,i.useEffect)((()=>{n.current?e():n.current=!0}),[t])};const f="medium",g=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(0,i.useRef)(t),r=!(0,l.a)(e,n.current);return(0,i.useEffect)((()=>{n.current=e}),[e]),{changed:r}},m=e=>{let{id:t,type:n,state:r,setState:i,placeholderLabel:c,options:u,enabledAt:d,disableIfEmpty:h,searchParams:p,api:f,label:g,headers:m,dependencies:A,size:S,minSearchLength:b,components:{Dropdown:v,Searchbox:w}}=e,y=!1;const O=r[t];switch(n){case l.D:return(0,s.A)(v,{id:t,searchParams:p,placeholderLabel:c,options:(0,l.r)(t,u,r),value:O,setValue:e=>i((n=>(0,a.A)((0,a.A)({},n),{},{[t]:e}))),doApiCall:!1,api:f,headers:m,disableIfEmpty:h,size:S},t);case l.e:return y=!(0,l.f)(t,r,i,d),(0,s.A)(o.d,{className:"faceted-search-switch",label:(0,s.A)("span",{className:"faceted-search-switch__label"},void 0,g),inputProps:{name:"my-switch",autoComplete:"off",value:O,headers:m},checked:!y&&O,onChange:()=>i((e=>(0,a.A)((0,a.A)({},e),{},{[t]:!e[t]}))),disabled:y},t);case l.S:const e=!A&&!!f?w:v,n=(0,l.d)(r);return(0,s.A)(e,{id:t,value:O,setValue:e=>i((n=>(0,a.A)((0,a.A)({},n),{},{[t]:e}))),placeholderLabel:c,disabled:(0,l.c)(A,r),dependencies:(0,l.g)(r,A),withSearchBox:!0,searchParams:(0,l.s)(A,r),options:(0,l.r)(t,u,r),optionsReducer:e=>(0,l.r)(t,e,r),api:f,headers:m,disableIfEmpty:h,size:S,minSearchLength:b,searchState:n},t);default:return null}};m.defaultProps={placeholderLabel:"",options:[],enabledAt:{},disableIfEmpty:!1,searchParams:"",api:null,label:null,headers:null,dependencies:[],size:"medium",minSearchLength:1};var A=e=>{let{renderConfig:t,onChange:n,headers:r,initialState:s,components:o}=e;const[c,u]=(0,i.useState)((()=>(0,l.b)(t,s))),{changed:d}=g(c,c);(0,i.useEffect)((()=>{s&&u((0,l.b)(t,s))}),[s]),p((()=>{var e;d&&((e=n)&&"function"==typeof e)&&n(c)}),[c,n,d]);return[t.map((e=>m((0,a.A)((0,a.A)({},e),{},{headers:r,state:c,setState:u,components:o})))),c]};const S={id:r.string.isRequired,label:r.string.isRequired,hiddenAt:(0,r.shape)({})},b={disableIfEmpty:r.bool,disabled:r.bool,placeholderLabel:r.string.isRequired,setValue:r.func.isRequired,size:(0,r.oneOf)(["small",f,"large","xlarge"]),value:r.string,withSearchBox:r.bool},v={disabled:!1,disableIfEmpty:!1,size:f,value:null,withSearchBox:!1},w=(0,a.A)((0,a.A)({},b),{},{id:r.string.isRequired,searchParams:r.string,dependencies:(0,r.shape)({}),options:(0,r.arrayOf)((0,r.shape)(S)),api:r.string,optionsReducer:r.func,headers:(0,r.shape)({})}),y=(0,a.A)((0,a.A)({},v),{},{searchParams:"",dependencies:null,options:[],api:null,optionsReducer:l.n,headers:{}});(0,a.A)((0,a.A)({},b),{},{availableOptions:(0,r.arrayOf)((0,r.shape)(S)),searchTerm:r.string,setSearchTerm:r.func,setShowSuggester:r.func,showSuggester:r.bool});const O=(0,a.A)((0,a.A)({},v),{},{availableOptions:[],searchTerm:"",setSearchTerm:l.n,setShowSuggester:l.n,showSuggester:!1}),x=(e,t)=>(0,i.useMemo)((()=>""===t.trim()?e:e.filter((0,l.l)(t))),[e,t]),j=["options"],L=["options"],R=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;const[n,r]=(0,i.useState)(e);return(0,i.useEffect)((()=>{const n=setTimeout((()=>{r(e)}),t);return()=>{clearTimeout(n)}}),[e,t]),n},E=["api","dependencies","headers","id","options","optionsReducer","searchParams","minSearchLength"],T=(0,d.RestClient)({timeout:2e3}),_=e=>t=>{let{api:n,dependencies:r,headers:s,id:o,options:d,optionsReducer:h,searchParams:p,minSearchLength:f}=t,m=(0,c.A)(t,E);const[A,S]=(0,i.useState)(!1),[b,v]=(0,i.useState)(""),[w,y]=(0,i.useState)(d),{changed:O}=g(r),j=x(w,b),L=R(b),_=(0,l.h)(n,"".concat(o,"=").concat(L,"&").concat(p));return(0,i.useEffect)((()=>{const e=O&&(0,l.i)(r);e&&(v(""),y([])),(e||(0,l.j)(L,f))&&T.get(_,{withCredentials:!0,headers:s}).then((e=>{let{data:t}=e;y(h(t))})).catch(l.n)}),[O,r,_]),(0,u.jsx)(e,(0,a.A)((0,a.A)({},m),{},{id:o,showSuggester:A,setShowSuggester:S,availableOptions:j,searchTerm:b,setSearchTerm:v}))},C=["api","headers","id","options","optionsReducer","searchParams","minSearchLength","value"],P=(0,d.RestClient)({timeout:2e3}),k=e=>t=>{let{api:n,headers:r,id:s,options:o,optionsReducer:d,searchParams:h,minSearchLength:p,value:f}=t,g=(0,c.A)(t,C);const[m,A]=(0,i.useState)(!1),[S,b]=(0,i.useState)(!1),[v,w]=(0,i.useState)((e=>{const{label:t=""}=(0,l.d)({value:e});return t})(f)),[y,O]=(0,i.useState)(!0),[x,j]=(0,i.useState)(o),L=R(v),E=(0,l.j)(L,p)?(0,l.h)(n,"".concat(s,"=").concat(L,"&").concat(h)):null;return(0,i.useEffect)((()=>{E&&y&&P.get(E,{withCredentials:!0,headers:r}).then((e=>{let{data:t}=e;j(d(t))})).catch(l.n)}),[E]),(0,u.jsx)(e,(0,a.A)((0,a.A)({},g),{},{id:s,value:f,showSuggester:S&&m,setShowSuggester:b,availableOptions:x,searchTerm:v,setSearchTerm:function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];w(e),O(t),A(!0)}}))},D="client_side",B="dependency",N="server_side",I="default",q=e=>{const t={[D]:(r=e,e=>{let{options:t}=e,n=(0,c.A)(e,j);const[s,o]=(0,i.useState)(!1),[l,d]=(0,i.useState)(""),h=x(t,l);return(0,u.jsx)(r,(0,a.A)((0,a.A)({},n),{},{showSuggester:s,setShowSuggester:o,availableOptions:h,searchTerm:l,setSearchTerm:d}))}),[B]:_(e),[N]:k(e),[I]:(n=e,e=>{let{options:t}=e,r=(0,c.A)(e,L);const[s,o]=(0,i.useState)(!1);return(0,u.jsx)(n,(0,a.A)((0,a.A)({},r),{},{availableOptions:t,showSuggester:s,setShowSuggester:o}))})};var n,r;return e=>{if((e=>{let{api:t,withSearchBox:n}=e;return!t&&n})(e)){const n=t[D];return(0,u.jsx)(n,(0,a.A)({},e))}if((e=>{let{api:t,dependencies:n,withSearchBox:r}=e;return!!(t&&n&&r)})(e)){const n=t[B];return(0,u.jsx)(n,(0,a.A)({},e))}if((e=>{let{api:t,dependencies:n,withSearchBox:r}=e;return!(!t||n||!r)})(e)){const n=t[N];return(0,u.jsx)(n,(0,a.A)({},e))}const n=t[I];return(0,u.jsx)(n,(0,a.A)({},e))}},z=e=>{let{availableOptions:t,value:n,setValue:r,disabled:s}=e;(0,i.useEffect)((()=>{!n||!s&&(0,l.k)(t,n)||r(null)}),[s,t])},V=e=>{let{text:t,highlightTerm:n,testId:r}=e;const a=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=(e=>{let{text:t,highlightTerm:n}=e;const r=new RegExp("(".concat(n,")"),"i");return t.split(r).filter(Boolean)})({text:t,highlightTerm:a});return(0,s.A)("div",{"data-testid":r,className:"faceted-search-highlighted-text"},void 0,i.map((e=>(e=>{let{part:t,highlightTerm:n}=e;return t.match(new RegExp(n,"i"))?(0,s.A)("b",{"data-testid":"".concat(r,"-bold")},void 0,t):t})({part:e,highlightTerm:a}))))},H=(e,t)=>(0,i.useMemo)((()=>e),[t])}}]); //# sourceMappingURL=3003.6e0968ab.js.map