PageSourceSearch

https://www.viljan.se/dist/client/assets/Filter-CetErjUl.js

js viljan.se collected 2026-10-07 02:57:44 UTC 11,044 bytes, 1 lines download raw bytes

1import{a as e,i as t,o as n,r,s as i,u as a}from"./entry-client-Bc26aKaw.js";var o=a(n()),s=e,c=()=>t();function l(e,t,n){let{isOpen:r,enabled:i=!0,stickyHeaderPx:a=89,headerThresholdPx:s=8,viewportMarginPx:c=8,autoCloseWhenHidden:l=!0,onAutoClose:u,freezeOnOpen:d=!0,minHeightPx:f=200,flipClassName:p,maxPanelHeightPx:m=500}=t,[h,g]=(0,o.useState)(void 0),[_,v]=(0,o.useState)(`bottom`),[y,b]=(0,o.useState)(!0),x=(0,o.useRef)(0),S=(0,o.useRef)(`bottom`);return(0,o.useEffect)(()=>{if(!i)return;let t=e.current;if(!t)return;let n=new IntersectionObserver(([e])=>{let t=e.isIntersecting&&e.intersectionRatio>0;b(t),r&&l&&!t&&u?.()},{root:null,threshold:[0,.01]});return n.observe(t),()=>n.disconnect()},[i,e,r,l,u]),(0,o.useEffect)(()=>{if(!i)return;if(!r){x.current=0,S.current=`bottom`,v(`bottom`),g(void 0);return}let t=a+s;(()=>{let n=e.current;if(!n)return;let r=n.getBoundingClientRect(),i=window.innerHeight,o=Math.max(0,i-r.bottom-c),s=Math.max(0,r.top-t-c),l=p&&o<f?`top`:`bottom`;S.current=l,v(l);let u;if(l===`bottom`){let e=Math.max(0,i-a-c);u=Math.min(o,e)}else u=s;let d=Math.min(u,m);x.current=d,g(d)})();let n=()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=window.innerHeight,i=Math.max(0,r-n.bottom-c),o=Math.max(0,n.top-(a+s)-c);if(!d){if(S.current===`bottom`){let e=Math.max(0,r-a-c);g(Math.min(i,e,m))}else g(Math.min(o,m));return}if(S.current===`bottom`){let e=Math.max(0,r-a-c);g(Math.min(i,e,x.current))}else g(Math.min(o,x.current))};return window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[i,r,e,a,s,c,f,p,d,m]),(0,o.useEffect)(()=>{let e=n?.current;if(!e||!i){e&&p&&e.classList.remove(p),e&&(e.style.maxHeight=``,e.style.overflowY=``);return}p&&(r&&_===`top`?e.classList.add(p):e.classList.remove(p)),!r||typeof h!=`number`?(e.style.maxHeight=``,e.style.overflowY=``):(e.style.maxHeight=`${h}px`,e.style.overflowY=`auto`)},[i,n,r,_,h,f,p]),{maxHeight:h,style:!i||!r||typeof h!=`number`?void 0:{maxHeight:`${h}px`,overflowY:`auto`},className:p&&r&&_===`top`?p:void 0,placement:_,isTriggerVisible:y}}var u=r(),d=e=>{let t=(0,o.useRef)(null),n=(0,o.useRef)([]);if((0,o.useEffect)(()=>{if(e.activeIndex!==null&&n.current[e.activeIndex]){let t=n.current[e.activeIndex];t&&t.focus()}},[e.activeIndex]),!e.suggestions||!e.suggestions.hits)return null;let r=e.suggestions.hits.filter(e=>e.type===`editorial`);return(0,u.jsx)(`div`,{className:`filter-input-autocomplete__wrapper`,ref:t,"aria-hidden":e.isOpen,children:r.map((t,r)=>(0,u.jsx)(`div`,{className:`filter-input-autocomplete__query-wrapper`,children:(0,u.jsx)(`button`,{ref:e=>{n.current[r]=e},onClick:()=>e.handleClick(t),onKeyDown:t=>e.handleKeyDown(t,r),tabIndex:r,className:`active flight-search__dropdown-button`,"aria-label":t.query,children:(0,u.jsx)(`span`,{className:`filter-input-autocomplete__query`,children:t.query})})},r))})},f=(0,o.memo)(({blockId:e,onChange:t,id:n,checked:r,label:a,name:l,type:f,value:p,placeholder:m,children:h,visible:g=!0})=>{let{blockList:_}=s(e=>e.filterlist),{settings:v,query:y,siteId:b}=(0,o.useMemo)(()=>_[(e+``).toLowerCase()],[_,e]),[x,S]=(0,o.useState)(y.term),[C,w]=(0,o.useState)(y.term),[T,E]=(0,o.useState)({hits:[]}),[D,O]=(0,o.useState)(!0),[k,A]=(0,o.useState)(null),[j,M]=(0,o.useState)(!1),N=(0,o.useRef)(null);(0,o.useEffect)(()=>{S(y.term),w(y.term)},[y.term]);let P=c(),F=async e=>{t(a,e.target.value,!!p,e.target),D&&O(!1),S(e.target.value),v.autocompleteOptions===`forThisSite`&&I(e.target.value,y.culture,b).catch(e=>{console.error(`Error:`,e,x,j)}),v.autocompleteOptions===`forAllSites`&&I(e.target.value).catch(e=>{console.error(`Error:`,e,x,j)})};async function I(e,t=null,n=null){let r={method:`GET`,headers:{"Content-Type":`application/json`}},i=``;(t||n)&&(i=`&tags=`,t&&(i+=`language:${t}`),n&&t&&(i+=`,`),n&&(i+=`siteid:${n}`));let a=`/find_v2/_autocomplete?prefix=${e}&size=10${i}`;try{E({hits:(await(await fetch(a,r)).json()).hits.map(e=>({query:e.query,type:`editorial`}))})}catch(e){throw console.error(`Error fetching autocomplete suggestions:`,e),e}}L(N);function L(e){(0,o.useEffect)(()=>
1{if(typeof window>`u`)return;function t(t){e.current&&!e.current.contains(t.target)&&O(!0)}return document.addEventListener(`mousedown`,t),()=>{typeof window>`u`||(document.removeEventListener(`mousedown`,t),O(!0))}},[e])}let R=e=>{S(e.query),O(!0),P(i.actions.setAutocompleteValue(e.query))};return(0,u.jsxs)(`div`,{className:`filter-input`,children:[(0,u.jsx)(`label`,{htmlFor:n,className:`filter-input__label`,children:a}),(0,u.jsxs)(`div`,{className:`filter-input__wrapper`,children:[(0,u.jsx)(`input`,{className:`filter-input__input`,id:n,type:f,name:l,placeholder:m,value:x,onBlur:()=>{C&&(M(!1),S(C))},defaultChecked:r,onChange:F,"aria-hidden":!g,tabIndex:g?void 0:-1}),h||null]}),(0,u.jsx)(`div`,{className:`wrapper`,ref:N,"aria-hidden":D,children:v.autocompleteOptions===`none`?null:(0,u.jsx)(d,{handleClick:R,handleKeyDown:(e,t)=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let n=e.key===`ArrowDown`?t+1:t-1,r=T?.hits.length?T?.hits.length-1:0;A(n<0?r:n%T?.hits.length)}else e.key===`Enter`&&k!==null&&R(T?.hits[k])},suggestions:T,activeIndex:k,setActiveIndex:A,isOpen:D})})]})}),p=(0,o.memo)(({facet:e,showFacetsForVisitor:t,onChange:n,onKeyDown:r,id:i,checked:a,label:o,name:s,type:c,value:l,appearance:d,visible:f=!0})=>(0,u.jsxs)(`div`,{className:`filter-option`,children:[(0,u.jsx)(`input`,{className:`filter-option__input`,id:i,type:c,name:s,value:l,checked:a,onChange:e=>{n(o,l,e.target.checked,e.target)},onKeyDown:e=>{r&&r(e,o,l,e.currentTarget)},"aria-hidden":!f,tabIndex:f?void 0:-1}),(0,u.jsxs)(`label`,{htmlFor:i,className:`filter-option__label`,children:[d===`Checkbox`?(0,u.jsx)(`svg`,{className:`filter-option__checkmark`,width:`25`,height:`25`,"aria-hidden":!a,children:(0,u.jsx)(`use`,{href:`#icon-check-mark`})}):null,(0,u.jsx)(`span`,{className:`filter-option__labeltext`,children:o}),e&&t?(0,u.jsx)(`span`,{className:`filter-option__labelfacet`,children:e}):null]})]})),m=(0,o.memo)(({blockId:e,filter:t,filters:n,facets:r,onChange:i,showAllText:a,showFacetsForVisitor:s,hideEmptyFacets:c,submitButtonText:d})=>{let[m,h]=(0,o.useState)(``),[g,_]=(0,o.useState)((t.appearance+``).toLowerCase()===`dropdown`),[v,y]=(0,o.useState)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(!1),w=(0,o.useRef)(!1),T=(t.appearance+``).toLowerCase()===`dropdown`,E=t.filterSelectionType===`SingleChoice`,D=T&&!g,O=(0,o.useCallback)((e=!1)=>{_(!0),e&&setTimeout(()=>b.current?.focus(),0)},[]);(0,o.useEffect)(()=>{if(!D||!T)return;let e=e=>{let t=e.target??null;if(t&&!b.current?.contains(t)&&!x.current?.contains(t)){if(C.current){C.current=!1;return}setTimeout(O,0)}};return document.addEventListener(`mousedown`,e,!0),document.addEventListener(`touchstart`,e,!0),()=>{document.removeEventListener(`mousedown`,e,!0),document.removeEventListener(`touchstart`,e,!0)}},[D,T,O]),(0,o.useEffect)(()=>{if(!D||!T)return;C.current=!0;let e=setTimeout(()=>{C.current=!1},0);return()=>clearTimeout(e)},[D,T]),(0,o.useEffect)(()=>{let e=S.current;if(!D||!T||!e)return;let t=t=>{let n=t.target;w.current=!!n&&e.contains(n),setTimeout(()=>w.current=!1,0)},n=t=>{let n=t.relatedTarget;n==null&&w.current||n instanceof Node&&e.contains(n)||requestAnimationFrame(()=>{let t=document.activeElement;(!t||!e.contains(t))&&O()})};return document.addEventListener(`pointerdown`,t,!0),e.addEventListener(`focusout`,n),()=>{document.removeEventListener(`pointerdown`,t,!0),e.removeEventListener(`focusout`,n)}},[D,T,O]),(0,o.useEffect)(()=>{if(!D||!T||!x.current)return;let e=x.current.querySelector(`input:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])`)??null,t=requestAnimationFrame(()=>{e?.focus()});return()=>cancelAnimationFrame(t)},[D,T]),l(b,{isOpen:D,enabled:T,headerThresholdPx:8,viewportMarginPx:8,flipClassName:`filter__dropdown-content--flipped`,autoCloseWhenHidden:!0,onAutoClose:()=>O(),freezeOnOpen:!0},T?x:void 0);let k=e=>{if(y(`keyboard`),e.key===`Escape`){e.preventDefault(),e.stopPropagation(),T&&O(!0);return}e.key===`Enter`&&T&&E&&(e.preventDefault(),e.stopPropagation(),O(!0))},A=(e,r,a)=>{let o={resetFilterButtonText:n.resetFilterButtonText,filters:JSON.parse(JSON.stringify(n.filters)).map(e=>e.key===t.key?{...e,options:e.options.map(e=>{let n={...e};return t.filterSelectionType===`Freetext`?(n.selected=!!r,n.value=r,n):(n.value===r?n.selected=a:((t.filterSelectionType===`SingleChoice`||r&&!n.value)&&(n.selected=!1),!r&&a&&n.selected&&(n.selected=!1)),n)})}:e)};JSON.stringify(n)!==JSON.stringify(o)&&i(o),T&&E&&v===`pointer`&&O(),h(e)};if(t?.options?.length===0)return(0,u.jsx)(u.Fragment,{});let j=`${t.key.replace(/[!@#$%^&*()_+{}[\]:;<>,.?~\\/\s-]/g,`-`)}-${e}`,M={className:`filter__option-container`,onPointerDown:()=>y(`pointer`)};return T&&(M.className+=` filter__dropdown-content`,M.role=`group`,M[`aria-label`]=t.name?`${t.name} options`:`Filter options`),(0,u.jsx)(`fieldset`,{className:`filter`,"data-filter-appearance":(t.appearance+``).toLowerCase()??`tag`,"data-filter-id":t.filterId,"data-filter-selectiontype":t.filterSelectionType.toLowerCase(),"aria-hidden":!t.visible,role:`group`,"aria-labelledby":`filter__content-${j}`,tabIndex:t.visible?void 0:-1,children:(0,u.jsxs)(`div`,{className:`filter__content`,children:[t.name?(0,u.jsx)(`span`,{className:`filter__label`,id:`filter__content-${j}`,children:t.name}):null,(0,u.jsxs)(`div`,{className:`filter__wrapper`,ref:T?S:void 0,children:[T?(0,u.jsx)(`button`,{ref:b,type:`button`,className:`filter__dropdown_button`,"aria-controls":`filter-options-`+t.key,"aria-expanded":!g,"aria-haspopup":`listbox`,onClick:()=>{_(!g)},onKeyDown:e=>{e.key===`Escape`&&D&&(e.preventDefault(),e.stopPropagation(),O())},"data-ariamanager-ignore":!0,children:(0,u.jsx)(`span`,{className:`filter__dropdown_button-text`,children:t.filterSelectionType===`MultipleChoice`?a:m||a})}):null,(0,u.jsxs)(`div`,{id:`filter-options-`+t.key,"aria-hidden":g,...M,ref:T?x:void 0,children:[t.filterSelectionType===`Freetext`?t.options.map((n,r)=>(0,u.jsx)(f,{blockId:e,checked:n.selected,type:`text`,id:`filter-option-${t.key}`,label:n.name,name:t.key,placeholder:n.placeholder,value:n.value,onChange:A,visible:t.visible,children:d?(0,u.jsxs)(`button`,{type:`submit`,className:`filter-input__button button button--primary`,children:[(0,u.jsx)(`svg`,{width:`24`,height:`24`,children:(0,u.jsx)(`use`,{href:`#icon-search`})}),d]}):null},n.name+r)):null,t.filterSelectionType===`SingleChoice`||t.filterSelectionType===`MultipleChoice`?t.options.map((n,i)=>{let a=t.id+n.value,o=r!==void 0&&r[a]!==void 0?r[a]:``;if(c&&r&&(!o||r[a]===0)&&t.key!==`location`)return;let l=t.filterSelectionType===`SingleChoice`?`radio`:`checkbox`;return(0,u.jsx)(p,{blockId:e,checked:n.selected,type:l,id:`filter-option-${t.key}-${n.value}`,label:n.name,showFacetsForVisitor:s,facet:o,name:t.key,value:n.value,onChange:A,onKeyDown:k,appearance:t.appearance,visible:t.visible},n.name+i)}):null]})]})]})})});export{c as n,s as r,m as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.