You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdf-webseite/pagefind/pagefind-ui.js

3 lines
71 KiB

(()=>{var Es=Object.defineProperty;var S=(n,e)=>{for(var t in e)Es(n,t,{get:e[t],enumerable:!0})};function j(){}function _t(n){return n()}function un(){return Object.create(null)}function G(n){n.forEach(_t)}function xe(n){return typeof n=="function"}function K(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}var Xe;function ie(n,e){return Xe||(Xe=document.createElement("a")),Xe.href=e,n===Xe.href}function cn(n){return Object.keys(n).length===0}var _n=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global,de=class{constructor(e){this.options=e,this._listeners="WeakMap"in _n?new WeakMap:void 0}observe(e,t){return this._listeners.set(e,t),this._getObserver().observe(e,this.options),()=>{this._listeners.delete(e),this._observer.unobserve(e)}}_getObserver(){var e;return(e=this._observer)!==null&&e!==void 0?e:this._observer=new ResizeObserver(t=>{var s;for(let l of t)de.entries.set(l.target,l),(s=this._listeners.get(l.target))===null||s===void 0||s(l)})}};de.entries="WeakMap"in _n?new WeakMap:void 0;var fn=!1;function Rs(){fn=!0}function bs(){fn=!1}function b(n,e){n.appendChild(e)}function y(n,e,t){n.insertBefore(e,t||null)}function k(n){n.parentNode&&n.parentNode.removeChild(n)}function Q(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function C(n){return document.createElement(n)}function Ts(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function w(n){return document.createTextNode(n)}function A(){return w(" ")}function x(){return w("")}function J(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function E(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Cs(n){return Array.from(n.childNodes)}function N(n,e){e=""+e,n.data!==e&&(n.data=e)}function ft(n,e){n.value=e??""}function B(n,e,t){n.classList[t?"add":"remove"](e)}var $e=class{constructor(e=!1){this.is_svg=!1,this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,s=null){this.e||(this.is_svg?this.e=Ts(t.nodeName):this.e=C(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(s)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t<this.n.length;t+=1)y(this.t,this.n[t],e)}p(e){this.d(),this.h(e),this.i(this.a)}d(){this.n.forEach(k)}};var he;function fe(n){he=n}function dn(){if(!he)throw new Error("Function called outside component initialization");return he}function dt(n){dn().$$.on_mount.push(n)}function ht(n){dn().$$.on_destroy.push(n)}var se=[];var re=[],le=[],ot=[],ks=Promise.resolve(),ut=!1;function ys(){ut||(ut=!0,ks.then(mn))}function ct(n){le.push(n)}function hn(n){ot.push(n)}var at=new Set,ne=0;function mn(){if(ne!==0)return;let n=he;do{try{for(;ne<se.length;){let e=se[ne];ne++,fe(e),Ss(e.$$)}}catch(e){throw se.length=0,ne=0,e}for(fe(null),se.length=0,ne=0;re.length;)re.pop()();for(let e=0;e<le.length;e+=1){let t=le[e];at.has(t)||(at.add(t),t())}le.length=0}while(se.length);for(;ot.length;)ot.pop()();ut=!1,at.clear(),fe(n)}function Ss(n){if(n.fragment!==null){n.update(),G(n.before_update);let e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(ct)}}function Ms(n){let e=[],t=[];le.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),le=e}var Qe=new Set,ee;function ae(){ee={r:0,c:[],p:ee}}function oe(){ee.r||G(ee.c),ee=ee.p}function D(n,e){n&&n.i&&(Qe.delete(n),n.i(e))}function P(n,e,t,s){if(n&&n.o){if(Qe.has(n))return;Qe.add(n),ee.c.push(()=>{Qe.delete(n),s&&(t&&n.d(1),s())}),n.o(e)}else s&&s()}function pn(n,e){P(n,1,1,()=>{e.delete(n.key)})}function gn(n,e,t,s,l,r,i,a,o,h,c,m){let p=n.length,d=r.length,_=p,u={};for(;_--;)u[n[_].key]=_;let f=[],T=new Map,R=new Map,M=[];for(_=d;_--;){let v=m(l,r,_),F=t(v),O=i.get(F);O?s&&M.push(()=>O.p(v,e)):(O=h(F,v),O.c()),T.set(F,f[_]=O),F in u&&R.set(F,Math.abs(_-u[F]))}let U=new Set,X=new Set;function W(v){D(v,1),v.m(a,c),i.set(v.key,v),c=v.first,d--}for(;p&&d;){let v=f[d-1],F=n[p-1],O=v.key,V=F.key;v===F?(c=v.first,p--,d--):T.has(V)?!i.has(O)
`))}c||t(24,c=h?12:30);let H={...f||{},excerptLength:c};await g.options(H);for(let z of T){if(!z.bundlePath)throw new Error("mergeIndex requires a bundlePath parameter");let L=z.bundlePath;delete z.bundlePath,await g.mergeIndex(L,z)}F=g,is()}},is=async()=>{F&&(ln=await F.filters(),(!ce||!Object.keys(ce).length)&&t(18,ce=ln))},as=g=>{let H={};return Object.entries(g).filter(([,z])=>z).forEach(([z])=>{let[L,te]=z.split(/:(.*)$/);H[L]=H[L]||[],H[L].push(te)}),H},_e,os=async(g,H)=>{if(!g){t(15,rt=!1),_e&&clearTimeout(_e);return}let z=as(H),L=()=>us(g,z);u>0&&g?(_e&&clearTimeout(_e),_e=setTimeout(L,u),await on(),F.preload(g,{filters:z})):L(),cs()},on=async()=>{for(;!F;)an(),await new Promise(g=>setTimeout(g,50))},us=async(g,H)=>{t(16,sn=g||""),typeof p=="function"&&(g=p(g)),t(14,lt=!0),t(15,rt=!0),await on();let z=++nn,L={filters:H};X&&typeof X=="object"&&(L.sort=X);let te=await F.search(g,L);nn===z&&(te.filters&&Object.keys(te.filters)?.length&&t(18,ce=te.filters),t(13,tn=te),t(14,lt=!1),t(17,it=i))},cs=()=>{let g=V.offsetWidth;g!=ls&&t(10,O.style.paddingRight=`${g+2}px`,O)},_s=g=>{g?.preventDefault(),t(17,it+=i)},fs=g=>{g.key==="Escape"&&(t(9,v=""),O.blur()),g.key==="Enter"&&g.preventDefault()};function ds(){v=this.value,t(9,v),t(23,R)}function hs(g){re[g?"unshift":"push"](()=>{O=g,t(10,O)})}function ms(g){re[g?"unshift":"push"](()=>{V=g,t(11,V)})}let ps=()=>{t(9,v=""),O.blur()};function gs(g){W=g,t(0,W)}return n.$$set=g=>{"base_path"in g&&t(25,r=g.base_path),"page_size"in g&&t(26,i=g.page_size),"reset_styles"in g&&t(1,a=g.reset_styles),"show_images"in g&&t(2,o=g.show_images),"show_sub_results"in g&&t(3,h=g.show_sub_results),"excerpt_length"in g&&t(24,c=g.excerpt_length),"process_result"in g&&t(4,m=g.process_result),"process_term"in g&&t(27,p=g.process_term),"show_empty_filters"in g&&t(5,d=g.show_empty_filters),"open_filters"in g&&t(6,_=g.open_filters),"debounce_timeout_ms"in g&&t(28,u=g.debounce_timeout_ms),"pagefind_options"in g&&t(29,f=g.pagefind_options),"merge_index"in g&&t(30,T=g.merge_index),"trigger_search_term"in g&&t(23,R=g.trigger_search_term),"translations"in g&&t(7,M=g.translations),"autofocus"in g&&t(8,U=g.autofocus),"sort"in g&&t(31,X=g.sort),"selected_filters"in g&&t(0,W=g.selected_filters)},n.$$.update=()=>{if(n.$$.dirty[0]&8388608)e:R&&(t(9,v=R),t(23,R=""));if(n.$$.dirty[0]&513)e:os(v,W)},[W,a,o,h,m,d,_,M,U,v,O,V,st,tn,lt,rt,sn,it,ce,rn,rs,an,_s,R,c,r,i,p,u,f,T,X,fs,ds,hs,ms,ps,gs]}var $t=class extends q{constructor(e){super(),Y(this,e,ia,la,K,{base_path:25,page_size:26,reset_styles:1,show_images:2,show_sub_results:3,excerpt_length:24,process_result:4,process_term:27,show_empty_filters:5,open_filters:6,debounce_timeout_ms:28,pagefind_options:29,merge_index:30,trigger_search_term:23,translations:7,autofocus:8,sort:31,selected_filters:0},null,[-1,-1])}},ss=$t;var en;try{en=new URL(document.currentScript.src).pathname.match(/^(.*\/)(?:pagefind-)?ui.js.*$/)[1]}catch{en="/pagefind/"}var nt=class{constructor(e){this._pfs=null;let t=e.element??"[data-pagefind-ui]",s=e.bundlePath??en,l=e.pageSize??5,r=e.resetStyles??!0,i=e.showImages??!0,a=e.showSubResults??!1,o=e.excerptLength??0,h=e.processResult??null,c=e.processTerm??null,m=e.showEmptyFilters??!0,p=e.openFilters??[],d=e.debounceTimeoutMs??300,_=e.mergeIndex??[],u=e.translations??[],f=e.autofocus??!1,T=e.sort??null;delete e.element,delete e.bundlePath,delete e.pageSize,delete e.resetStyles,delete e.showImages,delete e.showSubResults,delete e.excerptLength,delete e.processResult,delete e.processTerm,delete e.showEmptyFilters,delete e.openFilters,delete e.debounceTimeoutMs,delete e.mergeIndex,delete e.translations,delete e.autofocus,delete e.sort;let R=t instanceof HTMLElement?t:document.querySelector(t);R?this._pfs=new ss({target:R,props:{base_path:s,page_size:l,reset_styles:r,show_images:i,show_sub_results:a,excerpt_length:o,process_result:h,process_term:c,show_empty_filters:m,open_filters:p,debounce_timeout_ms:d,merge_index:_,translations:u,autofocus:f,sort:T,pagefind_options:e}}):console.error(`Pagefind UI couldn't find the selector ${t}`)}triggerSearch(e){t