- compaction automatique du contexte LLM quand la taille atteint le seuil (contexte max - taille de réponse max), par résumé de l'historique ancien - filtre textuel (?q=) et pagination (20/page) de l'historique des conversations - correctif ORM : offset de pagination en base 0 - suppression d'une conversation : messages associés supprimés, session en cours annulée, popup de confirmation (ConfirmDialog) - titres de conversation nettoyés du markdown - styles des listes markdown, variante danger du bouton - go.mod/go.sum : dépendances go-rod et stealth manquantes du commit précédent
6 lines
31 KiB
JavaScript
6 lines
31 KiB
JavaScript
import{$ as e,A as t,B as n,D as r,E as i,F as a,H as o,I as s,K as c,L as l,M as u,N as d,P as f,Q as p,R as m,T as h,U as g,X as _,Z as v,_ as y,a as b,at as x,b as ee,c as te,dt as ne,et as S,f as re,ft as ie,h as ae,it as oe,j as C,k as w,m as se,n as ce,nt as T,p as le,q as E,r as ue,u as de,v as fe,vt as D}from"./DGrvnoUE.js";import"./Soo4K-rz.js";import"./xihTtKlq.js";import"./B6JECYQD.js";var pe=Math.min,O=Math.max,me=Math.round,he=Math.floor,k=e=>({x:e,y:e}),A={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function j(e,t,n){return O(e,pe(t,n))}function ge(e,t){return typeof e==`function`?e(t):e}function M(e){return e.split(`-`)[0]}function N(e){return e.split(`-`)[1]}function P(e){return e===`x`?`y`:`x`}function F(e){return e===`y`?`height`:`width`}function I(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function _e(e){return P(I(e))}function ve(e,t,n){n===void 0&&(n=!1);let r=N(e),i=_e(e),a=F(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Ee(o)),[o,Ee(o)]}function ye(e){let t=Ee(e);return[be(e),t,be(t)]}function be(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var xe=[`left`,`right`],Se=[`right`,`left`],Ce=[`top`,`bottom`],L=[`bottom`,`top`];function we(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Se:xe:t?xe:Se;case`left`:case`right`:return t?Ce:L;default:return[]}}function Te(e,t,n,r){let i=N(e),a=we(M(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(be)))),a}function Ee(e){let t=M(e);return A[t]+e.slice(t.length)}function De(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Oe(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:De(e)}function ke(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Ae(e,t,n){let{reference:r,floating:i}=e,a=I(t),o=_e(t),s=F(o),c=M(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=N(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function je(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=ge(t,e),p=Oe(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ke(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=ke(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Me=50,Ne=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:je},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Ae(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Me&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Ae(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Pe=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=ge(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=M(r),_=I(o),v=M(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Ee(o)]:ye(o)),x=p!==`none`;!d&&x&&b.push(...Te(o,m,p,y));let ee=[o,...b],te=await s.detectOverflow(t,h),ne=[],S=i.flip?.overflows||[];if(l&&ne.push(te[g]),u){let e=ve(r,a,y);ne.push(te[e[0]],te[e[1]])}if(S=[...S,{placement:r,overflows:ne}],!ne.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=ee[e];if(t&&(u!==`alignment`||_===I(t)||S.every(e=>I(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:S},reset:{placement:t}};let n=S.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=S.filter(e=>{if(x){let t=I(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},Fe=new Set([`left`,`top`]);async function R(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=M(n),s=N(n),c=I(n)===`y`,l=Fe.has(o)?-1:1,u=a&&c?-1:1,d=ge(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Ie=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await R(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Le=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=ge(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=I(i),p=P(f),m=u[p],h=u[f],g=(e,t)=>j(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}};function Re(){return typeof window<`u`}function z(e){return ze(e)?(e.nodeName||``).toLowerCase():`#document`}function B(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function V(e){return((ze(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ze(e){return Re()?e instanceof Node||e instanceof B(e).Node:!1}function H(e){return Re()?e instanceof Element||e instanceof B(e).Element:!1}function U(e){return Re()?e instanceof HTMLElement||e instanceof B(e).HTMLElement:!1}function Be(e){return!Re()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof B(e).ShadowRoot}function Ve(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function He(e){return/^(table|td|th)$/.test(z(e))}function Ue(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var We=/transform|translate|scale|rotate|perspective|filter/,W=/paint|layout|strict|content/,G=e=>!!e&&e!==`none`,Ge;function Ke(e){let t=H(e)?J(e):e;return G(t.transform)||G(t.translate)||G(t.scale)||G(t.rotate)||G(t.perspective)||!K()&&(G(t.backdropFilter)||G(t.filter))||We.test(t.willChange||``)||W.test(t.contain||``)}function qe(e){let t=Je(e);for(;U(t)&&!q(t);){if(Ke(t))return t;if(Ue(t))return null;t=Je(t)}return null}function K(){return Ge??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ge}function q(e){return/^(html|body|#document)$/.test(z(e))}function J(e){return B(e).getComputedStyle(e)}function Y(e){return H(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Je(e){if(z(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Be(e)&&e.host||V(e);return Be(t)?t.host:t}function Ye(e){let t=Je(e);return q(t)?(e.ownerDocument||e).body:U(t)&&Ve(t)?t:Ye(t)}function Xe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ye(e),i=r===e.ownerDocument?.body,a=B(r);if(i){let e=Ze(a);return t.concat(a,a.visualViewport||[],Ve(r)?r:[],e&&n?Xe(e):[])}return t.concat(r,Xe(r,[],n))}function Ze(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qe(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=U(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=me(n)!==a||me(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function $e(e){return H(e)?e:e.contextElement}function et(e){let t=$e(e);if(!U(t))return k(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Qe(t),o=(a?me(n.width):n.width)/r,s=(a?me(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var tt=k(0);function nt(e){let t=B(e);return!K()||!t.visualViewport?tt:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function rt(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===B(e)}function X(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=$e(e),o=k(1);t&&(r?H(r)&&(o=et(r)):o=et(e));let s=rt(a,n,r)?nt(a):k(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=B(a),t=H(r)?B(r):r,n=e,i=Ze(n);for(;i&&t!==n;){let e=et(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=B(i),i=Ze(n)}}return ke({width:u,height:d,x:c,y:l})}function it(e,t){let n=Y(e).scrollLeft;return t?t.left+n:X(V(e)).left+n}function at(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-it(e,n),y:n.top+t.scrollTop}}function ot(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=V(r),s=t?Ue(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=k(1),u=k(0),d=U(r);if((d||!a)&&((z(r)!==`body`||Ve(o))&&(c=Y(r)),d)){let e=X(r);l=et(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?at(o,c):k(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function st(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ct(e){let t=Y(e),n=e.ownerDocument.body,r=O(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=O(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+it(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=O(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var lt=25;function Z(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=B(e),a=V(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!K()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(it(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=lt&&(s-=o)}return{width:s,height:c,x:l,y:u}}function ut(e,t){let n=X(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=et(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function dt(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Z(e,n,t);else if(t===`document`)r=ct(V(e));else if(H(t))r=ut(t,n);else{let n=nt(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ke(r)}function ft(e,t){let n=t.get(e);if(n)return n;let r=Xe(e,[],!1).filter(e=>H(e)&&z(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Je(e):e;for(;H(o)&&!q(o);){let e=J(o),t=Ke(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Je(o)}return t.set(e,r),r}function pt(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ue(t)?[]:ft(t,this._c):[].concat(n),r],o=dt(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=dt(t,a[e],i);s=O(n.top,s),c=pe(n.right,c),l=pe(n.bottom,l),u=O(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function mt(e){let{width:t,height:n}=Qe(e);return{width:t,height:n}}function ht(e,t,n){let r=U(t),i=V(t),a=n===`fixed`,o=X(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=k(0);if((r||!a)&&((z(t)!==`body`||Ve(i))&&(s=Y(t)),r)){let e=X(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=it(i));let l=i&&!r&&!a?at(i,s):k(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function gt(e){return J(e).position===`static`}function _t(e,t){if(!U(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return V(e)===n&&(n=n.ownerDocument.body),n}function vt(e,t){let n=B(e);if(Ue(e))return n;if(!U(e)){let t=Je(e);for(;t&&!q(t);){if(H(t)&&!gt(t))return t;t=Je(t)}return n}let r=_t(e,t);for(;r&&He(r)&>(r);)r=_t(r,t);return r&&q(r)&>(r)&&!Ke(r)?n:r||qe(e)||n}var yt=async function(e){let t=this.getOffsetParent||vt,n=this.getDimensions,r=await n(e.floating);return{reference:ht(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function bt(e){return J(e).direction===`rtl`}var xt={convertOffsetParentRelativeRectToViewportRelativeRect:ot,getDocumentElement:V,getClippingRect:pt,getOffsetParent:vt,getElementRects:yt,getClientRects:st,getDimensions:mt,getScale:et,isElement:H,isRTL:bt};function St(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ct(e,t,n){let r=null,i,a=V(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=he(d),h=he(a.clientWidth-(u+f)),g=he(a.clientHeight-(d+p)),_=he(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:O(0,pe(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!St(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=B(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function wt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=$e(e),u=i||a?[...l?Xe(l):[],...t?Xe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ct(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?X(e):null;c&&g();function g(){let t=X(e);h&&!St(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Tt=Ie,Et=Le,Dt=Pe,Ot=(e,t,n)=>{let r=new Map,i=n??{},a={...xt,...i.platform,_c:r};return Ne(e,t,{...i,platform:a})};function kt(e){let t,n,r={autoUpdate:!0},i=e,a=t=>({...r,...e||{},...t||{}}),s=e=>{t&&n&&(i=a(e),Ot(t,n,i).then(e=>{Object.assign(n.style,{position:e.strategy,left:`${e.x}px`,top:`${e.y}px`}),i?.onComputed&&i.onComputed(e)}))},c=e=>{if(`subscribe`in e)return u(e),{};t=e,s()},l=(e,r)=>{let c;n=e,i=a(r),setTimeout(()=>s(r),0),s(r);let l=()=>{c&&=(c(),void 0)},u=({autoUpdate:e}=i||{})=>{l(),e!==!1&&o().then(()=>wt(t,n,()=>s(i),e===!0?{}:e))};return c=u(),{update(e){s(e),c=u(e)},destroy(){l()}}},u=e=>{let n=e.subscribe(e=>{t===void 0?(t=e,s()):(Object.assign(t,e),s())});ce(n)};return[c,l,s]}function At({loadOptions:e,filterText:t,items:n,multiple:r,value:i,itemId:a,groupBy:o,filterSelectedItems:s,itemFilter:c,convertStringItemsToObjects:l,filterGroupedItems:u,label:d}){if(n&&e)return n;if(!n)return[];n&&n.length>0&&typeof n[0]!=`object`&&(n=l(n));let f=n.filter(e=>{let n=c(e[d],t,e);return n&&r&&Array.isArray(i)&&i.length&&(n=!i.some(t=>{let n=typeof t==`object`&&t?t[a]:t;return s?n===e[a]:!1})),n});return o&&(f=u(f)),f}async function jt({onerror:e,onloaded:t,loadOptions:n,convertStringItemsToObjects:r,filterText:i}){let a=await n(i).catch(t=>{console.warn(`svelte-select loadOptions error :>> `,t),e?.({type:`loadOptions`,details:t})});if(a&&!a.cancelled)return a?(a&&a.length>0&&typeof a[0]!=`object`&&(a=r(a)),t?.({items:a})):a=[],{filteredItems:a,loading:!1,focused:!0,listOpen:!0}}var Mt=f(`<svg width="100%" height="100%" viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path fill="currentColor" d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747
|
|
3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0
|
|
1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502
|
|
0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0
|
|
0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"></path></svg>`);function Nt(e){var t=Mt();C(e,t)}var Q=f(`<svg width="100%" height="100%" viewBox="-2 -2 50 50" focusable="false" aria-hidden="true" role="presentation"><path fill="currentColor" d="M34.923,37.251L24,26.328L13.077,37.251L9.436,33.61l10.923-10.923L9.436,11.765l3.641-3.641L24,19.047L34.923,8.124
|
|
l3.641,3.641L27.641,22.688L38.564,33.61L34.923,37.251z"></path></svg>`);function Pt(e){var t=Q();C(e,t)}var Ft=f(`<svg class="loading" viewBox="25 25 50 50"><circle class="circle_path" cx="50" cy="50" r="20" fill="none" stroke="currentColor" stroke-width="5" stroke-miterlimit="10"></circle></svg>`);function It(e){var t=Ft();C(e,t)}var Lt=d(`<div class="list-item" tabindex="-1" role="none"><div><!></div></div>`),Rt=d(`<div class="empty">No options</div>`),zt=d(`<div role="none"><!> <!> <!></div>`),Bt=d(`<span id="aria-selection"> </span> <span id="aria-context"> </span>`,1),Vt=d(`<div class="multi-item-clear"><!></div>`),Ht=d(`<div role="none"><span class="multi-item-text"><!></span> <!></div>`),Ut=d(`<div><!></div>`),Wt=d(`<div class="icon loading" aria-hidden="true"><!></div>`),Gt=d(`<button type="button" class="icon clear-select"><!></button>`),Kt=d(`<div class="icon chevron" aria-hidden="true"><!></div>`),qt=d(`<input type="hidden"/>`),Jt=d(`<select class="required" required="" tabindex="-1" aria-hidden="true"></select>`),Yt=d(`<div role="none"><!> <span aria-live="polite" aria-atomic="false" aria-relevant="additions text" class="a11y-text"><!></span> <div class="prepend"><!></div> <div class="value-container"><!> <input/></div> <div class="indicators"><!> <!> <!></div> <!> <!></div>`);function Xt(o,s){ie(s,!0);let d,f=b(s,`valueMode`,3,`item`),pe=b(s,`filter`,3,At),O=b(s,`getItems`,3,jt),me=b(s,`id`,3,null),he=b(s,`name`,3,null),k=b(s,`container`,15,null),A=b(s,`input`,15,null),j=b(s,`multiple`,3,!1),ge=b(s,`multiFullItemClearable`,3,!1),M=b(s,`disabled`,3,!1),N=b(s,`focused`,15,!1),P=b(s,`value`,15),F=b(s,`filterText`,15,``),I=b(s,`placeholder`,3,`Please select`),_e=b(s,`placeholderAlwaysShow`,3,!1),ve=b(s,`items`,31,()=>S([])),ye=b(s,`label`,3,`label`),be=b(s,`itemFilter`,3,(e,t,n)=>`${e}`.toLowerCase().includes(t.toLowerCase())),xe=b(s,`groupBy`,3,void 0),Se=b(s,`groupFilter`,3,e=>e),Ce=b(s,`groupHeaderSelectable`,3,!1),L=b(s,`itemId`,3,`value`),we=b(s,`loadOptions`,3,void 0),Te=b(s,`containerStyles`,3,``),Ee=b(s,`hasError`,3,!1),De=b(s,`filterSelectedItems`,3,!0),Oe=b(s,`required`,3,!1),ke=b(s,`closeListOnChange`,3,!0),Ae=b(s,`clearFilterTextOnBlur`,3,!0),je=b(s,`createGroupHeaderItem`,3,(e,t)=>({value:e,[ye()]:e})),Me=b(s,`searchable`,3,!0),Ne=b(s,`inputStyles`,3,``),Pe=b(s,`clearable`,3,!0),Fe=b(s,`loading`,15,!1),R=b(s,`listOpen`,15,!1),Ie=b(s,`debounce`,3,(e,t=1)=>{clearTimeout(d),d=setTimeout(e,t)}),Le=b(s,`debounceWait`,3,300),Re=b(s,`hideEmptyState`,3,!1),z=b(s,`inputAttributes`,19,()=>({})),B=b(s,`listAutoWidth`,3,!0),V=b(s,`showChevron`,3,!1),ze=b(s,`listOffset`,3,5),H=b(s,`hoverItemIndex`,15,0),U=b(s,`floatingConfig`,19,()=>({})),Be=b(s,`class`,3,``),Ve=b(s,`ariaValues`,3,e=>`Option ${e}, selected.`),He=b(s,`ariaListOpen`,3,(e,t)=>`You are currently focused on option ${e}. There are ${t} results available.`),Ue=b(s,`ariaFocused`,3,()=>`Select is focused, type to refine list, press down to open the menu.`);function We(){return n(Z)}let W=oe(void 0),G,Ge,Ke,qe,K=oe(null),q={},J=x(()=>{if(z()||!Me()){let e=Object.assign({autocapitalize:`none`,autocomplete:`off`,autocorrect:`off`,spellcheck:!1,tabindex:0,type:`text`,"aria-autocomplete":`list`},z());me()&&(e.id=me()),Me()||(e.readonly=!0),JSON.stringify(e)!==JSON.stringify(q)&&(q=e)}return q});function Y(e){return e==null?e:typeof e==`object`?e[L()]:e}function Je(e){return Array.isArray(e)&&e.length>0&&typeof e[0]!=`object`}let Ye=x(()=>f()===`id`||Je(ve()));function Xe(e){return n(Ye)?Y(e):e}function Ze(e){if(e==null)return e;if(typeof e==`object`)return e[ye()];let t=ve()?.find(t=>t[L()]===e);return t?t[ye()]:e}function Qe(){return P()==null?null:n(Ye)?j()&&Array.isArray(P())?JSON.stringify(P()):`${P()}`:JSON.stringify(P())}function $e(e){return e.map((e,t)=>({index:t,value:e,label:`${e}`}))}function et(e){if(!xe())return e;let t=[],n={};e.forEach(e=>{let r=xe()(e)??``;t.includes(r)||(t.push(r),n[r]=[],r&&n[r].push(Object.assign(je()(r,e),{id:r,groupHeader:!0,selectable:Ce()}))),n[r].push(Object.assign({groupItem:!!r},e))});let r=[];return Se()(t).forEach(e=>{n[e]&&r.push(...n[e])}),r}function tt(){if(j()){JSON.stringify(P())!==JSON.stringify(G)&&(!P()||_t())&&s.oninput?.(P());return}P()?(!G||JSON.stringify(Y(P()))!==JSON.stringify(Y(G)))&&s.oninput?.(P()):G&&s.oninput?.(P())}function nt(){Ke=!0,P()&&(Array.isArray(P())||P([P()]))}function rt(){Ke=!1,P()&&P(void 0)}function X(){it(n(Z).findIndex(e=>e[L()]===Y(P())),!0)}function it(e=0,t){let r=e<0?0:e;H()!==r&&H(r),!t&&xe()&&n(Z)[H()]&&!n(Z)[H()].selectable&&tn(1)}function at(){!we()&&F().length===0||(we()?Ie()(async function(){Fe(!0);let e=await O()({onerror:s.onerror,onloaded:s.onloaded,loadOptions:we(),convertStringItemsToObjects:$e,filterText:F()});e?(Fe(e.loading),R(R()?e.listOpen:F().length>0),N(R()&&e.focused),ve(xe()?et(e.filteredItems):e.filteredItems)):(Fe(!1),N(!0),R(!0))},Le()):(R()||R(!0),j()&&T(W,void 0)))}let ot=x(()=>j()?Array.isArray(P())&&P().length>0:!!P()),st=x(()=>n(ot)&&F().length>0),ct=x(()=>n(ot)&&Pe()&&!M()&&!Fe()),lt=x(()=>_e()&&j()||j()&&Array.isArray(P())&&P().length===0?I():P()?``:I()),Z=x(()=>pe()({loadOptions:we(),filterText:F(),items:ve(),multiple:j(),value:P(),itemId:L(),groupBy:xe(),label:ye(),filterSelectedItems:De(),itemFilter:be(),convertStringItemsToObjects:$e,filterGroupedItems:et})),ut=x(()=>!!n(K)),dt=x(H);function ft(e){let t;return e&&Array.isArray(P())&&P().length>0?t=P().map(e=>Ze(e)).join(`, `):!Array.isArray(P())&&P()&&(t=Ze(P())),Ve()(t)}function pt(){if(!n(Z)||n(Z).length===0)return``;let e=n(Z)[H()];if(R()&&e){let t=n(Z)?n(Z).length:0;return He()(e[ye()],t)}return Ue()()}let mt=x(()=>P()?ft(j()):``),ht=x(pt),gt=!1;E(()=>{j()&&g(nt)}),E(()=>{!j()&&Ke&&g(rt)}),E(()=>{j()&&P()&&P().length>1&&g(_t)}),E(()=>{let e=ve();g(()=>yt(e))}),E(()=>{P(),g(tt)}),E(()=>{qe&&!N()&&A()&&g(Q)}),E(()=>{F()!==Ge&&g(at)}),E(()=>{!j()&&R()&&P()&&n(Z)&&g(X)}),E(()=>{s.onhoverItem?.(H())}),E(()=>{R()&&n(Z)&&!j()&&!P()&&g(it)}),E(()=>{R()&&s.onfilter?.(n(Z))}),E(()=>{R()&&j()&&!gt&&H(0),gt=R()}),E(()=>{A()&&R()&&!N()&&g(St)}),E(()=>{F()!==Ge&&F()&&g(it)}),E(()=>{R()&&k()&&n(K)&&g(ln)}),E(()=>{k()&&U()?.autoUpdate===void 0&&(un.autoUpdate=!0),k()&&U()&&pn(Object.assign(un,U()))}),E(()=>{hn(n(K),R())}),E(()=>{G=P(),Ge=F(),Ke=j(),qe=N()});function _t(){let e=!0;if(P()&&Array.isArray(P())){let t=[],n=[];P().forEach(r=>{t.includes(Y(r))?e=!1:(t.push(Y(r)),n.push(r))}),e||P(n)}return e}function vt(e){let t=Y(e||P());return ve()?.find(e=>e[L()]===t)}function yt(e){if(f()===`item`&&!(!e||e.length===0||e.some(e=>typeof e!=`object`))&&!(!P()||(j()?!Array.isArray(P())||P().some(e=>!e||typeof e!=`object`):typeof P()!=`object`)))if(Array.isArray(P())){let e=P().map(e=>vt(e)||e);JSON.stringify(e)!==JSON.stringify(P())&&P(e)}else{let e=vt()||P();JSON.stringify(e)!==JSON.stringify(P())&&P(e)}}async function bt(e){if(!Array.isArray(P()))return;let t=P()[e];P().length===1?P(void 0):P(P().filter(e=>e!==t)),s.onclear?.(t)}function xt(e){if(N())switch(e.stopPropagation(),e.key){case`Escape`:e.preventDefault(),Q();break;case`Enter`:if(e.preventDefault(),R()){if(n(Z).length===0)break;let e=n(Z)[H()];if(P()&&!j()&&Y(P())===e[L()]){Q();break}Qt(n(Z)[H()])}break;case`ArrowDown`:e.preventDefault(),R()?tn(1):(R(!0),T(W,void 0));break;case`ArrowUp`:e.preventDefault(),R()?tn(-1):(R(!0),T(W,void 0));break;case`Tab`:if(R()&&N()){if(n(Z).length===0||P()&&Y(P())===n(Z)[H()][L()])return Q();e.preventDefault(),Qt(n(Z)[H()]),Q()}break;case`Backspace`:if(!j()||F().length>0)return;if(j()&&P()&&P().length>0){if(bt(n(W)===void 0?P().length-1:n(W)),n(W)===0||n(W)===void 0)break;T(W,P().length>n(W)?n(W)-1:void 0,!0)}break;case`ArrowLeft`:if(!P()||!j()||F().length>0)return;n(W)===void 0?T(W,P().length-1):P().length>n(W)&&n(W)!==0&&T(W,n(W)-1);break;case`ArrowRight`:if(!P()||!j()||F().length>0||n(W)===void 0)return;n(W)===P().length-1?T(W,void 0):n(W)<P().length-1&&T(W,n(W)+1)}}function St(e){N()&&A()===document?.activeElement||(e&&s.onfocus?.(e),A()?.focus(),N(!0))}async function Ct(e){Zt||(R()||N())&&(e&&s.onblur?.(e),Q(),N(!1),T(W,void 0),A()?.blur())}function wt(){if(!M()){if(F().length>0)return R(!0);R(!R())}}function Ot(){s.onclear?.(P()),P(void 0),Q(),St()}ue(()=>{R()&&N(!0),N()&&A()&&A().focus()});function Mt(e){if(e){F(``);let t=Object.assign({},e);if(t.groupHeader&&!t.selectable)return;let n=Xe(e);P(j()?P()?P().concat([n]):[n]:n),setTimeout(()=>{ke()&&Q(),T(W,void 0),s.onchange?.(P()),s.onselect?.(e)})}}function Q(){Ae()&&F()!==``&&F(``),R()&&R(!1)}let Ft;function Xt(){clearTimeout(Ft),Ft=setTimeout(()=>{Zt=!1},100)}ce(()=>{n(K)?.remove()});let Zt=!1;function Qt(e){!e||e.selectable===!1||Mt(e)}function $t(e){Zt||H(e)}function en(e){let{item:t,i:n}=e;if(t?.selectable!==!1){if(P()&&!j()&&Y(P())===t[L()])return Q();an(t)&&(H(n),Qt(t))}}function tn(e){if(n(Z).filter(e=>!Object.hasOwn(e,`selectable`)||e.selectable===!0).length===0)return H(0);e>0&&H()===n(Z).length-1?H(0):e<0&&H()===0?H(n(Z).length-1):H(H()+e);let t=n(Z)[H()];if(t&&t.selectable===!1){(e===1||e===-1)&&tn(e);return}}function nn(e,t,n){if(!j())return t&&Y(t)===e[n]}function rn(e){return e===0}function an(e){return e.groupHeader&&e.selectable||e.selectable||!e.hasOwnProperty(`selectable`)}let on=e=>({update(t){t.scroll&&(Xt(),e.scrollIntoView({behavior:`auto`,block:`nearest`}))}}),sn=on,cn=on;function ln(){if(!k()||!n(K))return;let{width:e}=k().getBoundingClientRect();n(K).style.width=B()?e+`px`:`auto`}let un={strategy:`absolute`,placement:`bottom-start`,middleware:[Tt(ze()),Dt(),Et()],autoUpdate:!1},[dn,fn,pn]=kt(un),mn=oe(!0);function hn(e,t){if(!e||!t)return T(mn,!0);setTimeout(()=>{T(mn,!1)},0)}function gn(e){e.preventDefault(),wt()}function _n(e){e.preventDefault(),e.stopPropagation()}function vn(e){e.stopPropagation()}function yn(e){e.preventDefault()}var bn={getFilteredItems:We,handleClear:Ot},$=Yt();m(`keydown`,_,xt);let xn;var Sn=v($),Cn=o=>{var d=zt();let f;var g=v(d),_=e=>{var t=u(),n=p(t);h(n,()=>s.listPrepend),C(e,t)};w(g,e=>{s.listPrepend&&e(_)});var y=e(g,2),b=e=>{var t=u(),r=p(t);h(r,()=>s.list,()=>({filteredItems:n(Z)})),C(e,t)},x=e=>{var o=u(),d=p(o);i(d,17,()=>n(Z),r,(e,r,i)=>{var o=Lt(),d=v(o);let f;var g=v(d),_=e=>{var t=u(),a=p(t);h(a,()=>s.item,()=>({item:n(r),index:i})),C(e,t)},y=e=>{var i=a();c(()=>t(i,n(r)?.[ye()])),C(e,i)};w(g,e=>{s.item?e(_):e(y,-1)}),D(d),ee(d,(e,t)=>sn?.(e,t),()=>({scroll:nn(n(r),P(),L()),listDom:n(ut)})),ee(d,(e,t)=>cn?.(e,t),()=>({scroll:n(dt)===i,listDom:n(ut)})),D(o),c(e=>f=fe(d,1,`item`,null,f,e),[()=>({"list-group-title":n(r).groupHeader,active:nn(n(r),P(),L()),first:rn(i),hover:H()===i,"group-item":n(r).groupItem,"not-selectable":n(r)?.selectable===!1})]),l(`mouseover`,o,()=>$t(i)),m(`focus`,o,()=>$t(i)),l(`click`,o,e=>{vn(e),en({item:n(r),i})}),l(`keydown`,o,_n),C(e,o)}),C(e,o)},ne=e=>{var t=u(),n=p(t),r=e=>{var t=u(),n=p(t);h(n,()=>s.empty),C(e,t)},i=e=>{var t=Rt();C(e,t)};w(n,e=>{s.empty?e(r):e(i,-1)}),C(e,t)};w(y,e=>{s.list?e(b):n(Z).length>0?e(x,1):Re()||e(ne,2)});var S=e(y,2),re=e=>{var t=u(),n=p(t);h(n,()=>s.listAppend),C(e,t)};w(S,e=>{s.listAppend&&e(re)}),D(d),ee(d,e=>fn?.(e)),te(d,e=>T(K,e),()=>n(K)),c(()=>f=fe(d,1,`svelte-select-list`,null,f,{prefloat:n(mn)})),m(`scroll`,d,Xt),l(`pointerup`,d,_n),l(`mousedown`,d,_n),C(o,d)};w(Sn,e=>{R()&&e(Cn)});var wn=e(Sn,2),Tn=v(wn),En=r=>{var i=Bt(),a=p(i),o=v(a,!0);D(a);var s=e(a,2),l=v(s,!0);D(s),c(()=>{t(o,n(mt)),t(l,n(ht))}),C(r,i)};w(Tn,e=>{N()&&e(En)}),D(wn);var Dn=e(wn,2),On=v(Dn),kn=e=>{var t=u(),n=p(t);h(n,()=>s.prepend),C(e,t)};w(On,e=>{s.prepend&&e(kn)}),D(Dn);var An=e(Dn,2),jn=v(An),Mn=o=>{var d=u(),f=p(d),m=o=>{var d=u(),f=p(d);i(f,17,P,r,(r,i,o)=>{var d=Ht();let f;var m=v(d),g=v(m),_=e=>{var t=u(),r=p(t);h(r,()=>s.selection,()=>({selection:n(i),index:o})),C(e,t)},y=e=>{var r=a();c(e=>t(r,e),[()=>Ze(n(i))]),C(e,r)};w(g,e=>{s.selection?e(_):e(y,-1)}),D(m);var b=e(m,2),x=e=>{var t=Vt(),n=v(t),r=e=>{var t=u(),n=p(t);h(n,()=>s.multiClearIcon),C(e,t)},i=e=>{Pt(e,{})};w(n,e=>{s.multiClearIcon?e(r):e(i,-1)}),D(t),l(`pointerup`,t,e=>{_n(e),bt(o)}),C(e,t)};w(b,e=>{!M()&&!ge()&&Pt&&e(x)}),D(d),c(()=>f=fe(d,1,`multi-item`,null,f,{active:n(W)===o,disabled:M()})),l(`click`,d,e=>{yn(e),ge()&&bt(o)}),l(`keydown`,d,_n),C(r,d)}),C(o,d)},g=e=>{var r=Ut();let i;var o=v(r),l=e=>{var t=u(),n=p(t);h(n,()=>s.selection,()=>({selection:P()})),C(e,t)},d=e=>{var n=a();c(e=>t(n,e),[()=>Ze(P())]),C(e,n)};w(o,e=>{s.selection?e(l):e(d,-1)}),D(r),c(()=>i=fe(r,1,`selected-item`,null,i,{"hide-selected-item":n(st)})),C(e,r)};w(f,e=>{j()?e(m):e(g,-1)}),C(o,d)};w(jn,e=>{n(ot)&&e(Mn)});var Nn=e(jn,2);re(Nn,()=>({onkeydown:xt,onblur:Ct,onfocus:St,readOnly:!Me(),...n(J),placeholder:n(lt),style:Ne(),disabled:M()}),void 0,void 0,void 0,void 0,!0),te(Nn,e=>A(e),()=>A()),D(An);var Pn=e(An,2),Fn=v(Pn),In=e=>{var t=Wt(),n=v(t),r=e=>{var t=u(),n=p(t);h(n,()=>s.loadingIcon),C(e,t)},i=e=>{It(e,{})};w(n,e=>{s.loadingIcon?e(r):e(i,-1)}),D(t),C(e,t)};w(Fn,e=>{Fe()&&e(In)});var Ln=e(Fn,2),Rn=e=>{var t=Gt(),n=v(t),r=e=>{var t=u(),n=p(t);h(n,()=>s.clearIcon),C(e,t)},i=e=>{Pt(e,{})};w(n,e=>{s.clearIcon?e(r):e(i,-1)}),D(t),l(`click`,t,Ot),C(e,t)};w(Ln,e=>{n(ct)&&e(Rn)});var zn=e(Ln,2),Bn=e=>{var t=Kt(),n=v(t),r=e=>{var t=u(),n=p(t);h(n,()=>s.chevronIcon,()=>({listOpen:R()})),C(e,t)},i=e=>{Nt(e,{})};w(n,e=>{s.chevronIcon?e(r):e(i,-1)}),D(t),C(e,t)};w(zn,e=>{V()&&e(Bn)}),D(Pn);var Vn=e(Pn,2),Hn=e=>{var t=u(),n=p(t);h(n,()=>s.inputHidden,()=>({value:P()})),C(e,t)},Un=e=>{var t=qt();le(t),c(e=>{se(t,`name`,he()),ae(t,e)},[()=>Qe()]),C(e,t)};w(Vn,e=>{s.inputHidden?e(Hn):e(Un,-1)});var Wn=e(Vn,2),Gn=e=>{var t=u(),n=p(t),r=e=>{var t=u(),n=p(t);h(n,()=>s.requiredIndicator,()=>({value:P()})),C(e,t)},i=e=>{var t=Jt();C(e,t)};w(n,e=>{s.requiredIndicator?e(r):e(i,-1)}),C(e,t)},Kn=x(()=>Oe()&&(!P()||(Array.isArray(P())?P().length===0:!1)));return w(Wn,e=>{n(Kn)&&e(Gn)}),D($),te($,e=>k(e),()=>k()),ee($,e=>dn?.(e)),c(()=>{xn=fe($,1,`svelte-select ${Be()??``}`,null,xn,{multi:j(),disabled:M(),focused:N(),"list-open":R(),"show-chevron":V(),error:Ee()}),y($,Te())}),l(`pointerup`,$,gn),de(Nn,F),C(o,$),ne(bn)}s([`pointerup`,`mousedown`,`mouseover`,`click`,`keydown`]);export{Xt as t}; |