Files
streakfit-api/public/js/filament/forms/components/select.js
T
neckfireandClaude Opus 4.8 af32669931
Build & Deploy / build (push) Successful in 18s
StreakFit — API Laravel 13 OSDD + Octane/FrankenPHP
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 03:00:17 +02:00

12 lines
85 KiB
JavaScript

var Ht=Math.min,vt=Math.max,Wt=Math.round;var st=i=>({x:i,y:i}),Ji={left:"right",right:"left",bottom:"top",top:"bottom"};function Ce(i,t,e){return vt(i,Ht(t,e))}function Vt(i,t){return typeof i=="function"?i(t):i}function yt(i){return i.split("-")[0]}function zt(i){return i.split("-")[1]}function Le(i){return i==="x"?"y":"x"}function Ie(i){return i==="y"?"height":"width"}function ut(i){let t=i[0];return t==="t"||t==="b"?"y":"x"}function Te(i){return Le(ut(i))}function Ze(i,t,e){e===void 0&&(e=!1);let n=zt(i),o=Te(i),s=Ie(o),r=o==="x"?n===(e?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=Ft(r)),[r,Ft(r)]}function ti(i){let t=Ft(i);return[oe(i),t,oe(t)]}function oe(i){return i.includes("start")?i.replace("start","end"):i.replace("end","start")}var Je=["left","right"],Qe=["right","left"],Qi=["top","bottom"],Zi=["bottom","top"];function tn(i,t,e){switch(i){case"top":case"bottom":return e?t?Qe:Je:t?Je:Qe;case"left":case"right":return t?Qi:Zi;default:return[]}}function ei(i,t,e,n){let o=zt(i),s=tn(yt(i),e==="start",n);return o&&(s=s.map(r=>r+"-"+o),t&&(s=s.concat(s.map(oe)))),s}function Ft(i){let t=yt(i);return Ji[t]+i.slice(t.length)}function en(i){return{top:0,right:0,bottom:0,left:0,...i}}function ii(i){return typeof i!="number"?en(i):{top:i,right:i,bottom:i,left:i}}function Et(i){let{x:t,y:e,width:n,height:o}=i;return{width:n,height:o,top:e,left:t,right:t+n,bottom:e+o,x:t,y:e}}function ni(i,t,e){let{reference:n,floating:o}=i,s=ut(t),r=Te(t),a=Ie(r),l=yt(t),c=s==="y",h=n.x+n.width/2-o.width/2,d=n.y+n.height/2-o.height/2,f=n[a]/2-o[a]/2,p;switch(l){case"top":p={x:h,y:n.y-o.height};break;case"bottom":p={x:h,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-o.width,y:d};break;default:p={x:n.x,y:n.y}}switch(zt(t)){case"start":p[r]-=f*(e&&c?-1:1);break;case"end":p[r]+=f*(e&&c?-1:1);break}return p}async function oi(i,t){var e;t===void 0&&(t={});let{x:n,y:o,platform:s,rects:r,elements:a,strategy:l}=i,{boundary:c="clippingAncestors",rootBoundary:h="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Vt(t,i),g=ii(p),S=a[f?d==="floating"?"reference":"floating":d],D=Et(await s.getClippingRect({element:(e=await(s.isElement==null?void 0:s.isElement(S)))==null||e?S:S.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:h,strategy:l})),w=d==="floating"?{x:n,y:o,width:r.floating.width,height:r.floating.height}:r.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),O=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},_=Et(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:A,strategy:l}):w);return{top:(D.top-_.top+g.top)/O.y,bottom:(_.bottom-D.bottom+g.bottom)/O.y,left:(D.left-_.left+g.left)/O.x,right:(_.right-D.right+g.right)/O.x}}var nn=50,si=async(i,t,e)=>{let{placement:n="bottom",strategy:o="absolute",middleware:s=[],platform:r}=e,a=r.detectOverflow?r:{...r,detectOverflow:oi},l=await(r.isRTL==null?void 0:r.isRTL(t)),c=await r.getElementRects({reference:i,floating:t,strategy:o}),{x:h,y:d}=ni(c,n,l),f=n,p=0,g={};for(let m=0;m<s.length;m++){let S=s[m];if(!S)continue;let{name:D,fn:w}=S,{x:A,y:O,data:_,reset:C}=await w({x:h,y:d,initialPlacement:n,placement:f,strategy:o,middlewareData:g,rects:c,platform:a,elements:{reference:i,floating:t}});h=A??h,d=O??d,g[D]={...g[D],..._},C&&p<nn&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await r.getElementRects({reference:i,floating:t,strategy:o}):C.rects),{x:h,y:d}=ni(c,f,l)),m=-1)}return{x:h,y:d,placement:f,strategy:o,middlewareData:g}};var ri=function(i){return i===void 0&&(i={}),{name:"flip",options:i,async fn(t){var e,n;let{placement:o,middlewareData:s,rects:r,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:h=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...S}=Vt(i,t);if((e=s.arrow)!=null&&e.alignmentOffset)return{};let D=yt(o),w=ut(a),A=yt(a)===a,O=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=f||(A||!m?[Ft(a)]:ti(a)),C=g!=="none";!f&&C&&_.push(...ei(a,m,g,O));let q=[a,..._],J=await l.detectOverflow(t,S),R=[],$=((n=s.flip)==null?void 0:n.overflows)||[];if(h&&R.push(J[D]),d){let B=Ze(o,r,O);R.push(J[B[0]],J[B[1]])}if($=[...$,{placement:o,overflows:R}],!R.every(B=>B<=0)){var X,et;let B=(((X=s.flip)==null?void 0:X.index)||0)+1,Q=q[B];if(Q&&(!(d==="alignment"?w!==ut(Q):!1)||$.every(P=>ut(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:B,overflows:$},reset:{placement:Q}};let F=(et=$.filter(W=>W.overflows[0]<=0).sort((W,P)=>W.overflows[1]-P.overflows[1])[0])==null?void 0:et.placement;if(!F)switch(p){case"bestFit":{var H;let W=(H=$.filter(P=>{if(C){let V=ut(P.placement);return V===w||V==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(V=>V>0).reduce((V,ie)=>V+ie,0)]).sort((P,V)=>P[1]-V[1])[0])==null?void 0:H[0];W&&(F=W);break}case"initialPlacement":F=a;break}if(o!==F)return{reset:{placement:F}}}return{}}}};var on=new Set(["left","top"]);async function sn(i,t){let{placement:e,platform:n,elements:o}=i,s=await(n.isRTL==null?void 0:n.isRTL(o.floating)),r=yt(e),a=zt(e),l=ut(e)==="y",c=on.has(r)?-1:1,h=s&&l?-1:1,d=Vt(t,i),{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*h,y:f*c}:{x:f*c,y:p*h}}var ai=function(i){return i===void 0&&(i=0),{name:"offset",options:i,async fn(t){var e,n;let{x:o,y:s,placement:r,middlewareData:a}=t,l=await sn(t,i);return r===((e=a.offset)==null?void 0:e.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:r}}}}},li=function(i){return i===void 0&&(i={}),{name:"shift",options:i,async fn(t){let{x:e,y:n,placement:o,platform:s}=t,{mainAxis:r=!0,crossAxis:a=!1,limiter:l={fn:D=>{let{x:w,y:A}=D;return{x:w,y:A}}},...c}=Vt(i,t),h={x:e,y:n},d=await s.detectOverflow(t,c),f=ut(yt(o)),p=Le(f),g=h[p],m=h[f];if(r){let D=p==="y"?"top":"left",w=p==="y"?"bottom":"right",A=g+d[D],O=g-d[w];g=Ce(A,g,O)}if(a){let D=f==="y"?"top":"left",w=f==="y"?"bottom":"right",A=m+d[D],O=m-d[w];m=Ce(A,m,O)}let S=l.fn({...t,[p]:g,[f]:m});return{...S,data:{x:S.x-e,y:S.y-n,enabled:{[p]:r,[f]:a}}}}}};function re(){return typeof window<"u"}function Dt(i){return di(i)?(i.nodeName||"").toLowerCase():"#document"}function U(i){var t;return(i==null||(t=i.ownerDocument)==null?void 0:t.defaultView)||window}function lt(i){var t;return(t=(di(i)?i.ownerDocument:i.document)||window.document)==null?void 0:t.documentElement}function di(i){return re()?i instanceof Node||i instanceof U(i).Node:!1}function it(i){return re()?i instanceof Element||i instanceof U(i).Element:!1}function ct(i){return re()?i instanceof HTMLElement||i instanceof U(i).HTMLElement:!1}function ci(i){return!re()||typeof ShadowRoot>"u"?!1:i instanceof ShadowRoot||i instanceof U(i).ShadowRoot}function Tt(i){let{overflow:t,overflowX:e,overflowY:n,display:o}=nt(i);return/auto|scroll|overlay|hidden|clip/.test(t+n+e)&&o!=="inline"&&o!=="contents"}function hi(i){return/^(table|td|th)$/.test(Dt(i))}function $t(i){try{if(i.matches(":popover-open"))return!0}catch{}try{return i.matches(":modal")}catch{return!1}}var rn=/transform|translate|scale|rotate|perspective|filter/,an=/paint|layout|strict|content/,Ot=i=>!!i&&i!=="none",Re;function ae(i){let t=it(i)?nt(i):i;return Ot(t.transform)||Ot(t.translate)||Ot(t.scale)||Ot(t.rotate)||Ot(t.perspective)||!le()&&(Ot(t.backdropFilter)||Ot(t.filter))||rn.test(t.willChange||"")||an.test(t.contain||"")}function ui(i){let t=ft(i);for(;ct(t)&&!At(t);){if(ae(t))return t;if($t(t))return null;t=ft(t)}return null}function le(){return Re==null&&(Re=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Re}function At(i){return/^(html|body|#document)$/.test(Dt(i))}function nt(i){return U(i).getComputedStyle(i)}function Kt(i){return it(i)?{scrollLeft:i.scrollLeft,scrollTop:i.scrollTop}:{scrollLeft:i.scrollX,scrollTop:i.scrollY}}function ft(i){if(Dt(i)==="html")return i;let t=i.assignedSlot||i.parentNode||ci(i)&&i.host||lt(i);return ci(t)?t.host:t}function fi(i){let t=ft(i);return At(t)?i.ownerDocument?i.ownerDocument.body:i.body:ct(t)&&Tt(t)?t:fi(t)}function se(i,t,e){var n;t===void 0&&(t=[]),e===void 0&&(e=!0);let o=fi(i),s=o===((n=i.ownerDocument)==null?void 0:n.body),r=U(o);if(s){let a=ce(r);return t.concat(r,r.visualViewport||[],Tt(o)?o:[],a&&e?se(a):[])}else return t.concat(o,se(o,[],e))}function ce(i){return i.parent&&Object.getPrototypeOf(i.parent)?i.frameElement:null}function bi(i){let t=nt(i),e=parseFloat(t.width)||0,n=parseFloat(t.height)||0,o=ct(i),s=o?i.offsetWidth:e,r=o?i.offsetHeight:n,a=Wt(e)!==s||Wt(n)!==r;return a&&(e=s,n=r),{width:e,height:n,$:a}}function vi(i){return it(i)?i:i.contextElement}function Rt(i){let t=vi(i);if(!ct(t))return st(1);let e=t.getBoundingClientRect(),{width:n,height:o,$:s}=bi(t),r=(s?Wt(e.width):e.width)/n,a=(s?Wt(e.height):e.height)/o;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}var ln=st(0);function yi(i){let t=U(i);return!le()||!t.visualViewport?ln:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function cn(i,t,e){return t===void 0&&(t=!1),!e||t&&e!==U(i)?!1:t}function Xt(i,t,e,n){t===void 0&&(t=!1),e===void 0&&(e=!1);let o=i.getBoundingClientRect(),s=vi(i),r=st(1);t&&(n?it(n)&&(r=Rt(n)):r=Rt(i));let a=cn(s,e,n)?yi(s):st(0),l=(o.left+a.x)/r.x,c=(o.top+a.y)/r.y,h=o.width/r.x,d=o.height/r.y;if(s){let f=U(s),p=n&&it(n)?U(n):n,g=f,m=ce(g);for(;m&&n&&p!==g;){let S=Rt(m),D=m.getBoundingClientRect(),w=nt(m),A=D.left+(m.clientLeft+parseFloat(w.paddingLeft))*S.x,O=D.top+(m.clientTop+parseFloat(w.paddingTop))*S.y;l*=S.x,c*=S.y,h*=S.x,d*=S.y,l+=A,c+=O,g=U(m),m=ce(g)}}return Et({width:h,height:d,x:l,y:c})}function de(i,t){let e=Kt(i).scrollLeft;return t?t.left+e:Xt(lt(i)).left+e}function wi(i,t){let e=i.getBoundingClientRect(),n=e.left+t.scrollLeft-de(i,e),o=e.top+t.scrollTop;return{x:n,y:o}}function dn(i){let{elements:t,rect:e,offsetParent:n,strategy:o}=i,s=o==="fixed",r=lt(n),a=t?$t(t.floating):!1;if(n===r||a&&s)return e;let l={scrollLeft:0,scrollTop:0},c=st(1),h=st(0),d=ct(n);if((d||!d&&!s)&&((Dt(n)!=="body"||Tt(r))&&(l=Kt(n)),d)){let p=Xt(n);c=Rt(n),h.x=p.x+n.clientLeft,h.y=p.y+n.clientTop}let f=r&&!d&&!s?wi(r,l):st(0);return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+h.x+f.x,y:e.y*c.y-l.scrollTop*c.y+h.y+f.y}}function hn(i){return Array.from(i.getClientRects())}function un(i){let t=lt(i),e=Kt(i),n=i.ownerDocument.body,o=vt(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=vt(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight),r=-e.scrollLeft+de(i),a=-e.scrollTop;return nt(n).direction==="rtl"&&(r+=vt(t.clientWidth,n.clientWidth)-o),{width:o,height:s,x:r,y:a}}var pi=25;function fn(i,t){let e=U(i),n=lt(i),o=e.visualViewport,s=n.clientWidth,r=n.clientHeight,a=0,l=0;if(o){s=o.width,r=o.height;let h=le();(!h||h&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}let c=de(n);if(c<=0){let h=n.ownerDocument,d=h.body,f=getComputedStyle(d),p=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(n.clientWidth-d.clientWidth-p);g<=pi&&(s-=g)}else c<=pi&&(s+=c);return{width:s,height:r,x:a,y:l}}function pn(i,t){let e=Xt(i,!0,t==="fixed"),n=e.top+i.clientTop,o=e.left+i.clientLeft,s=ct(i)?Rt(i):st(1),r=i.clientWidth*s.x,a=i.clientHeight*s.y,l=o*s.x,c=n*s.y;return{width:r,height:a,x:l,y:c}}function gi(i,t,e){let n;if(t==="viewport")n=fn(i,e);else if(t==="document")n=un(lt(i));else if(it(t))n=pn(t,e);else{let o=yi(i);n={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Et(n)}function xi(i,t){let e=ft(i);return e===t||!it(e)||At(e)?!1:nt(e).position==="fixed"||xi(e,t)}function gn(i,t){let e=t.get(i);if(e)return e;let n=se(i,[],!1).filter(a=>it(a)&&Dt(a)!=="body"),o=null,s=nt(i).position==="fixed",r=s?ft(i):i;for(;it(r)&&!At(r);){let a=nt(r),l=ae(r);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Tt(r)&&!l&&xi(i,r))?n=n.filter(h=>h!==r):o=a,r=ft(r)}return t.set(i,n),n}function mn(i){let{element:t,boundary:e,rootBoundary:n,strategy:o}=i,r=[...e==="clippingAncestors"?$t(t)?[]:gn(t,this._c):[].concat(e),n],a=gi(t,r[0],o),l=a.top,c=a.right,h=a.bottom,d=a.left;for(let f=1;f<r.length;f++){let p=gi(t,r[f],o);l=vt(p.top,l),c=Ht(p.right,c),h=Ht(p.bottom,h),d=vt(p.left,d)}return{width:c-d,height:h-l,x:d,y:l}}function bn(i){let{width:t,height:e}=bi(i);return{width:t,height:e}}function vn(i,t,e){let n=ct(t),o=lt(t),s=e==="fixed",r=Xt(i,!0,s,t),a={scrollLeft:0,scrollTop:0},l=st(0);function c(){l.x=de(o)}if(n||!n&&!s)if((Dt(t)!=="body"||Tt(o))&&(a=Kt(t)),n){let p=Xt(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!n&&o&&c();let h=o&&!n&&!s?wi(o,a):st(0),d=r.left+a.scrollLeft-l.x-h.x,f=r.top+a.scrollTop-l.y-h.y;return{x:d,y:f,width:r.width,height:r.height}}function Me(i){return nt(i).position==="static"}function mi(i,t){if(!ct(i)||nt(i).position==="fixed")return null;if(t)return t(i);let e=i.offsetParent;return lt(i)===e&&(e=e.ownerDocument.body),e}function Si(i,t){let e=U(i);if($t(i))return e;if(!ct(i)){let o=ft(i);for(;o&&!At(o);){if(it(o)&&!Me(o))return o;o=ft(o)}return e}let n=mi(i,t);for(;n&&hi(n)&&Me(n);)n=mi(n,t);return n&&At(n)&&Me(n)&&!ae(n)?e:n||ui(i)||e}var yn=async function(i){let t=this.getOffsetParent||Si,e=this.getDimensions,n=await e(i.floating);return{reference:vn(i.reference,await t(i.floating),i.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function wn(i){return nt(i).direction==="rtl"}var xn={convertOffsetParentRelativeRectToViewportRelativeRect:dn,getDocumentElement:lt,getClippingRect:mn,getOffsetParent:Si,getElementRects:yn,getClientRects:hn,getDimensions:bn,getScale:Rt,isElement:it,isRTL:wn};var Ei=ai;var Oi=li,Di=ri;var Ai=(i,t,e)=>{let n=new Map,o={platform:xn,...e},s={...o.platform,_c:n};return si(i,t,{...o,platform:s})};function Sn(i,t,e){return(t=An(t))in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}function gt(){return gt=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)({}).hasOwnProperty.call(e,n)&&(i[n]=e[n])}return i},gt.apply(null,arguments)}function Ci(i,t){var e=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(i,o).enumerable})),e.push.apply(e,n)}return e}function ht(i){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ci(Object(e),!0).forEach(function(n){Sn(i,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Ci(Object(e)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(e,n))})}return i}function En(i,t){if(i==null)return{};var e,n,o=On(i,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(n=0;n<s.length;n++)e=s[n],t.indexOf(e)===-1&&{}.propertyIsEnumerable.call(i,e)&&(o[e]=i[e])}return o}function On(i,t){if(i==null)return{};var e={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(t.indexOf(n)!==-1)continue;e[n]=i[n]}return e}function Dn(i,t){if(typeof i!="object"||!i)return i;var e=i[Symbol.toPrimitive];if(e!==void 0){var n=e.call(i,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function An(i){var t=Dn(i,"string");return typeof t=="symbol"?t:t+""}function ze(i){"@babel/helpers - typeof";return ze=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ze(i)}var Cn="1.15.7";function pt(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var mt=pt(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),te=pt(/Edge/i),Li=pt(/firefox/i),Gt=pt(/safari/i)&&!pt(/chrome/i)&&!pt(/android/i),Ue=pt(/iP(ad|od|hone)/i),ki=pt(/chrome/i)&&pt(/android/i),Bi={capture:!1,passive:!1};function E(i,t,e){i.addEventListener(t,e,!mt&&Bi)}function x(i,t,e){i.removeEventListener(t,e,!mt&&Bi)}function ye(i,t){if(t){if(t[0]===">"&&(t=t.substring(1)),i)try{if(i.matches)return i.matches(t);if(i.msMatchesSelector)return i.msMatchesSelector(t);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(t)}catch{return!1}return!1}}function Fi(i){return i.host&&i!==document&&i.host.nodeType&&i.host!==i?i.host:i.parentNode}function at(i,t,e,n){if(i){e=e||document;do{if(t!=null&&(t[0]===">"?i.parentNode===e&&ye(i,t):ye(i,t))||n&&i===e)return i;if(i===e)break}while(i=Fi(i))}return null}var Ii=/\s+/g;function Z(i,t,e){if(i&&t)if(i.classList)i.classList[e?"add":"remove"](t);else{var n=(" "+i.className+" ").replace(Ii," ").replace(" "+t+" "," ");i.className=(n+(e?" "+t:"")).replace(Ii," ")}}function b(i,t,e){var n=i&&i.style;if(n){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(i,""):i.currentStyle&&(e=i.currentStyle),t===void 0?e:e[t];!(t in n)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),n[t]=e+(typeof e=="string"?"":"px")}}function kt(i,t){var e="";if(typeof i=="string")e=i;else do{var n=b(i,"transform");n&&n!=="none"&&(e=n+" "+e)}while(!t&&(i=i.parentNode));var o=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return o&&new o(e)}function Hi(i,t,e){if(i){var n=i.getElementsByTagName(t),o=0,s=n.length;if(e)for(;o<s;o++)e(n[o],o);return n}return[]}function dt(){var i=document.scrollingElement;return i||document.documentElement}function k(i,t,e,n,o){if(!(!i.getBoundingClientRect&&i!==window)){var s,r,a,l,c,h,d;if(i!==window&&i.parentNode&&i!==dt()?(s=i.getBoundingClientRect(),r=s.top,a=s.left,l=s.bottom,c=s.right,h=s.height,d=s.width):(r=0,a=0,l=window.innerHeight,c=window.innerWidth,h=window.innerHeight,d=window.innerWidth),(t||e)&&i!==window&&(o=o||i.parentNode,!mt))do if(o&&o.getBoundingClientRect&&(b(o,"transform")!=="none"||e&&b(o,"position")!=="static")){var f=o.getBoundingClientRect();r-=f.top+parseInt(b(o,"border-top-width")),a-=f.left+parseInt(b(o,"border-left-width")),l=r+s.height,c=a+s.width;break}while(o=o.parentNode);if(n&&i!==window){var p=kt(o||i),g=p&&p.a,m=p&&p.d;p&&(r/=m,a/=g,d/=g,h/=m,l=r+h,c=a+d)}return{top:r,left:a,bottom:l,right:c,width:d,height:h}}}function Ti(i,t,e){for(var n=St(i,!0),o=k(i)[t];n;){var s=k(n)[e],r=void 0;if(e==="top"||e==="left"?r=o>=s:r=o<=s,!r)return n;if(n===dt())break;n=St(n,!1)}return!1}function Bt(i,t,e,n){for(var o=0,s=0,r=i.children;s<r.length;){if(r[s].style.display!=="none"&&r[s]!==v.ghost&&(n||r[s]!==v.dragged)&&at(r[s],e.draggable,i,!1)){if(o===t)return r[s];o++}s++}return null}function je(i,t){for(var e=i.lastElementChild;e&&(e===v.ghost||b(e,"display")==="none"||t&&!ye(e,t));)e=e.previousElementSibling;return e||null}function ot(i,t){var e=0;if(!i||!i.parentNode)return-1;for(;i=i.previousElementSibling;)i.nodeName.toUpperCase()!=="TEMPLATE"&&i!==v.clone&&(!t||ye(i,t))&&e++;return e}function Ri(i){var t=0,e=0,n=dt();if(i)do{var o=kt(i),s=o.a,r=o.d;t+=i.scrollLeft*s,e+=i.scrollTop*r}while(i!==n&&(i=i.parentNode));return[t,e]}function Ln(i,t){for(var e in i)if(i.hasOwnProperty(e)){for(var n in t)if(t.hasOwnProperty(n)&&t[n]===i[e][n])return Number(e)}return-1}function St(i,t){if(!i||!i.getBoundingClientRect)return dt();var e=i,n=!1;do if(e.clientWidth<e.scrollWidth||e.clientHeight<e.scrollHeight){var o=b(e);if(e.clientWidth<e.scrollWidth&&(o.overflowX=="auto"||o.overflowX=="scroll")||e.clientHeight<e.scrollHeight&&(o.overflowY=="auto"||o.overflowY=="scroll")){if(!e.getBoundingClientRect||e===document.body)return dt();if(n||t)return e;n=!0}}while(e=e.parentNode);return dt()}function In(i,t){if(i&&t)for(var e in t)t.hasOwnProperty(e)&&(i[e]=t[e]);return i}function _e(i,t){return Math.round(i.top)===Math.round(t.top)&&Math.round(i.left)===Math.round(t.left)&&Math.round(i.height)===Math.round(t.height)&&Math.round(i.width)===Math.round(t.width)}var qt;function Wi(i,t){return function(){if(!qt){var e=arguments,n=this;e.length===1?i.call(n,e[0]):i.apply(n,e),qt=setTimeout(function(){qt=void 0},t)}}}function Tn(){clearTimeout(qt),qt=void 0}function Vi(i,t,e){i.scrollLeft+=t,i.scrollTop+=e}function zi(i){var t=window.Polymer,e=window.jQuery||window.Zepto;return t&&t.dom?t.dom(i).cloneNode(!0):e?e(i).clone(!0)[0]:i.cloneNode(!0)}function $i(i,t,e){var n={};return Array.from(i.children).forEach(function(o){var s,r,a,l;if(!(!at(o,t.draggable,i,!1)||o.animated||o===e)){var c=k(o);n.left=Math.min((s=n.left)!==null&&s!==void 0?s:1/0,c.left),n.top=Math.min((r=n.top)!==null&&r!==void 0?r:1/0,c.top),n.right=Math.max((a=n.right)!==null&&a!==void 0?a:-1/0,c.right),n.bottom=Math.max((l=n.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),n.width=n.right-n.left,n.height=n.bottom-n.top,n.x=n.left,n.y=n.top,n}var G="Sortable"+new Date().getTime();function Rn(){var i=[],t;return{captureAnimationState:function(){if(i=[],!!this.options.animation){var n=[].slice.call(this.el.children);n.forEach(function(o){if(!(b(o,"display")==="none"||o===v.ghost)){i.push({target:o,rect:k(o)});var s=ht({},i[i.length-1].rect);if(o.thisAnimationDuration){var r=kt(o,!0);r&&(s.top-=r.f,s.left-=r.e)}o.fromRect=s}})}},addAnimationState:function(n){i.push(n)},removeAnimationState:function(n){i.splice(Ln(i,{target:n}),1)},animateAll:function(n){var o=this;if(!this.options.animation){clearTimeout(t),typeof n=="function"&&n();return}var s=!1,r=0;i.forEach(function(a){var l=0,c=a.target,h=c.fromRect,d=k(c),f=c.prevFromRect,p=c.prevToRect,g=a.rect,m=kt(c,!0);m&&(d.top-=m.f,d.left-=m.e),c.toRect=d,c.thisAnimationDuration&&_e(f,d)&&!_e(h,d)&&(g.top-d.top)/(g.left-d.left)===(h.top-d.top)/(h.left-d.left)&&(l=_n(g,f,p,o.options)),_e(d,h)||(c.prevFromRect=h,c.prevToRect=d,l||(l=o.options.animation),o.animate(c,g,d,l)),l&&(s=!0,r=Math.max(r,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(t),s?t=setTimeout(function(){typeof n=="function"&&n()},r):typeof n=="function"&&n(),i=[]},animate:function(n,o,s,r){if(r){b(n,"transition",""),b(n,"transform","");var a=kt(this.el),l=a&&a.a,c=a&&a.d,h=(o.left-s.left)/(l||1),d=(o.top-s.top)/(c||1);n.animatingX=!!h,n.animatingY=!!d,b(n,"transform","translate3d("+h+"px,"+d+"px,0)"),this.forRepaintDummy=Mn(n),b(n,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:"")),b(n,"transform","translate3d(0,0,0)"),typeof n.animated=="number"&&clearTimeout(n.animated),n.animated=setTimeout(function(){b(n,"transition",""),b(n,"transform",""),n.animated=!1,n.animatingX=!1,n.animatingY=!1},r)}}}}function Mn(i){return i.offsetWidth}function _n(i,t,e,n){return Math.sqrt(Math.pow(t.top-i.top,2)+Math.pow(t.left-i.left,2))/Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))*n.animation}var Mt=[],Pe={initializeByDefault:!0},ee={mount:function(t){for(var e in Pe)Pe.hasOwnProperty(e)&&!(e in t)&&(t[e]=Pe[e]);Mt.forEach(function(n){if(n.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}),Mt.push(t)},pluginEvent:function(t,e,n){var o=this;this.eventCanceled=!1,n.cancel=function(){o.eventCanceled=!0};var s=t+"Global";Mt.forEach(function(r){e[r.pluginName]&&(e[r.pluginName][s]&&e[r.pluginName][s](ht({sortable:e},n)),e.options[r.pluginName]&&e[r.pluginName][t]&&e[r.pluginName][t](ht({sortable:e},n)))})},initializePlugins:function(t,e,n,o){Mt.forEach(function(a){var l=a.pluginName;if(!(!t.options[l]&&!a.initializeByDefault)){var c=new a(t,e,t.options);c.sortable=t,c.options=t.options,t[l]=c,gt(n,c.defaults)}});for(var s in t.options)if(t.options.hasOwnProperty(s)){var r=this.modifyOption(t,s,t.options[s]);typeof r<"u"&&(t.options[s]=r)}},getEventProperties:function(t,e){var n={};return Mt.forEach(function(o){typeof o.eventProperties=="function"&&gt(n,o.eventProperties.call(e[o.pluginName],t))}),n},modifyOption:function(t,e,n){var o;return Mt.forEach(function(s){t[s.pluginName]&&s.optionListeners&&typeof s.optionListeners[e]=="function"&&(o=s.optionListeners[e].call(t[s.pluginName],n))}),o}};function Pn(i){var t=i.sortable,e=i.rootEl,n=i.name,o=i.targetEl,s=i.cloneEl,r=i.toEl,a=i.fromEl,l=i.oldIndex,c=i.newIndex,h=i.oldDraggableIndex,d=i.newDraggableIndex,f=i.originalEvent,p=i.putSortable,g=i.extraEventProperties;if(t=t||e&&e[G],!!t){var m,S=t.options,D="on"+n.charAt(0).toUpperCase()+n.substr(1);window.CustomEvent&&!mt&&!te?m=new CustomEvent(n,{bubbles:!0,cancelable:!0}):(m=document.createEvent("Event"),m.initEvent(n,!0,!0)),m.to=r||e,m.from=a||e,m.item=o||e,m.clone=s,m.oldIndex=l,m.newIndex=c,m.oldDraggableIndex=h,m.newDraggableIndex=d,m.originalEvent=f,m.pullMode=p?p.lastPutMode:void 0;var w=ht(ht({},g),ee.getEventProperties(n,t));for(var A in w)m[A]=w[A];e&&e.dispatchEvent(m),S[D]&&S[D].call(t,m)}}var Nn=["evt"],j=function(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,s=En(n,Nn);ee.pluginEvent.bind(v)(t,e,ht({dragEl:u,parentEl:M,ghostEl:y,rootEl:L,nextEl:It,lastDownEl:ge,cloneEl:T,cloneHidden:xt,dragStarted:Yt,putSortable:z,activeSortable:v.active,originalEvent:o,oldIndex:Nt,oldDraggableIndex:Jt,newIndex:tt,newDraggableIndex:wt,hideGhostForTarget:Ui,unhideGhostForTarget:ji,cloneNowHidden:function(){xt=!0},cloneNowShown:function(){xt=!1},dispatchSortableEvent:function(a){Y({sortable:e,name:a,originalEvent:o})}},s))};function Y(i){Pn(ht({putSortable:z,cloneEl:T,targetEl:u,rootEl:L,oldIndex:Nt,oldDraggableIndex:Jt,newIndex:tt,newDraggableIndex:wt},i))}var u,M,y,L,It,ge,T,xt,Nt,tt,Jt,wt,he,z,Pt=!1,we=!1,xe=[],Ct,rt,Ne,ke,Mi,_i,Yt,_t,Qt,Zt=!1,ue=!1,me,K,Be=[],$e=!1,Se=[],Oe=typeof document<"u",fe=Ue,Pi=te||mt?"cssFloat":"float",kn=Oe&&!ki&&!Ue&&"draggable"in document.createElement("div"),Ki=(function(){if(Oe){if(mt)return!1;var i=document.createElement("x");return i.style.cssText="pointer-events:auto",i.style.pointerEvents==="auto"}})(),Xi=function(t,e){var n=b(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),s=Bt(t,0,e),r=Bt(t,1,e),a=s&&b(s),l=r&&b(r),c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+k(s).width,h=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+k(r).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(s&&a.float&&a.float!=="none"){var d=a.float==="left"?"left":"right";return r&&(l.clear==="both"||l.clear===d)?"vertical":"horizontal"}return s&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||c>=o&&n[Pi]==="none"||r&&n[Pi]==="none"&&c+h>o)?"vertical":"horizontal"},Bn=function(t,e,n){var o=n?t.left:t.top,s=n?t.right:t.bottom,r=n?t.width:t.height,a=n?e.left:e.top,l=n?e.right:e.bottom,c=n?e.width:e.height;return o===a||s===l||o+r/2===a+c/2},Fn=function(t,e){var n;return xe.some(function(o){var s=o[G].options.emptyInsertThreshold;if(!(!s||je(o))){var r=k(o),a=t>=r.left-s&&t<=r.right+s,l=e>=r.top-s&&e<=r.bottom+s;if(a&&l)return n=o}}),n},Yi=function(t){function e(s,r){return function(a,l,c,h){var d=a.options.group.name&&l.options.group.name&&a.options.group.name===l.options.group.name;if(s==null&&(r||d))return!0;if(s==null||s===!1)return!1;if(r&&s==="clone")return s;if(typeof s=="function")return e(s(a,l,c,h),r)(a,l,c,h);var f=(r?a:l).options.group.name;return s===!0||typeof s=="string"&&s===f||s.join&&s.indexOf(f)>-1}}var n={},o=t.group;(!o||ze(o)!="object")&&(o={name:o}),n.name=o.name,n.checkPull=e(o.pull,!0),n.checkPut=e(o.put),n.revertClone=o.revertClone,t.group=n},Ui=function(){!Ki&&y&&b(y,"display","none")},ji=function(){!Ki&&y&&b(y,"display","")};Oe&&!ki&&document.addEventListener("click",function(i){if(we)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),we=!1,!1},!0);var Lt=function(t){if(u){t=t.touches?t.touches[0]:t;var e=Fn(t.clientX,t.clientY);if(e){var n={};for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[G]._onDragOver(n)}}},Hn=function(t){u&&u.parentNode[G]._isOutsideThisEl(t.target)};function v(i,t){if(!(i&&i.nodeType&&i.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(i));this.el=i,this.options=t=gt({},t),i[G]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(i.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Xi(i,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(r,a){r.setData("Text",a.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:v.supportPointer!==!1&&"PointerEvent"in window&&(!Gt||Ue),emptyInsertThreshold:5};ee.initializePlugins(this,i,e);for(var n in e)!(n in t)&&(t[n]=e[n]);Yi(t);for(var o in this)o.charAt(0)==="_"&&typeof this[o]=="function"&&(this[o]=this[o].bind(this));this.nativeDraggable=t.forceFallback?!1:kn,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?E(i,"pointerdown",this._onTapStart):(E(i,"mousedown",this._onTapStart),E(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(E(i,"dragover",this),E(i,"dragenter",this)),xe.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),gt(this,Rn())}v.prototype={constructor:v,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(_t=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,u):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,o=this.options,s=o.preventOnFilter,r=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,l=(a||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,h=o.filter;if(Un(n),!u&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Gt&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=at(l,o.draggable,n,!1),!(l&&l.animated)&&ge!==l)){if(Nt=ot(l),Jt=ot(l,o.draggable),typeof h=="function"){if(h.call(this,t,l,this)){Y({sortable:e,rootEl:c,name:"filter",targetEl:l,toEl:n,fromEl:n}),j("filter",e,{evt:t}),s&&t.preventDefault();return}}else if(h&&(h=h.split(",").some(function(d){if(d=at(c,d.trim(),n,!1),d)return Y({sortable:e,rootEl:d,name:"filter",targetEl:l,fromEl:n,toEl:n}),j("filter",e,{evt:t}),!0}),h)){s&&t.preventDefault();return}o.handle&&!at(c,o.handle,n,!1)||this._prepareDragStart(t,a,l)}}},_prepareDragStart:function(t,e,n){var o=this,s=o.el,r=o.options,a=s.ownerDocument,l;if(n&&!u&&n.parentNode===s){var c=k(n);if(L=s,u=n,M=u.parentNode,It=u.nextSibling,ge=n,he=r.group,v.dragged=u,Ct={target:u,clientX:(e||t).clientX,clientY:(e||t).clientY},Mi=Ct.clientX-c.left,_i=Ct.clientY-c.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,u.style["will-change"]="all",l=function(){if(j("delayEnded",o,{evt:t}),v.eventCanceled){o._onDrop();return}o._disableDelayedDragEvents(),!Li&&o.nativeDraggable&&(u.draggable=!0),o._triggerDragStart(t,e),Y({sortable:o,name:"choose",originalEvent:t}),Z(u,r.chosenClass,!0)},r.ignore.split(",").forEach(function(h){Hi(u,h.trim(),Fe)}),E(a,"dragover",Lt),E(a,"mousemove",Lt),E(a,"touchmove",Lt),r.supportPointer?(E(a,"pointerup",o._onDrop),!this.nativeDraggable&&E(a,"pointercancel",o._onDrop)):(E(a,"mouseup",o._onDrop),E(a,"touchend",o._onDrop),E(a,"touchcancel",o._onDrop)),Li&&this.nativeDraggable&&(this.options.touchStartThreshold=4,u.draggable=!0),j("delayStart",this,{evt:t}),r.delay&&(!r.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(te||mt))){if(v.eventCanceled){this._onDrop();return}r.supportPointer?(E(a,"pointerup",o._disableDelayedDrag),E(a,"pointercancel",o._disableDelayedDrag)):(E(a,"mouseup",o._disableDelayedDrag),E(a,"touchend",o._disableDelayedDrag),E(a,"touchcancel",o._disableDelayedDrag)),E(a,"mousemove",o._delayedDragTouchMoveHandler),E(a,"touchmove",o._delayedDragTouchMoveHandler),r.supportPointer&&E(a,"pointermove",o._delayedDragTouchMoveHandler),o._dragStartTimer=setTimeout(l,r.delay)}else l()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){u&&Fe(u),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;x(t,"mouseup",this._disableDelayedDrag),x(t,"touchend",this._disableDelayedDrag),x(t,"touchcancel",this._disableDelayedDrag),x(t,"pointerup",this._disableDelayedDrag),x(t,"pointercancel",this._disableDelayedDrag),x(t,"mousemove",this._delayedDragTouchMoveHandler),x(t,"touchmove",this._delayedDragTouchMoveHandler),x(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?E(document,"pointermove",this._onTouchMove):e?E(document,"touchmove",this._onTouchMove):E(document,"mousemove",this._onTouchMove):(E(u,"dragend",this),E(L,"dragstart",this._onDragStart));try{document.selection?be(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(Pt=!1,L&&u){j("dragStarted",this,{evt:e}),this.nativeDraggable&&E(document,"dragover",Hn);var n=this.options;!t&&Z(u,n.dragClass,!1),Z(u,n.ghostClass,!0),v.active=this,t&&this._appendGhost(),Y({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(rt){this._lastX=rt.clientX,this._lastY=rt.clientY,Ui();for(var t=document.elementFromPoint(rt.clientX,rt.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(rt.clientX,rt.clientY),t!==e);)e=t;if(u.parentNode[G]._isOutsideThisEl(t),e)do{if(e[G]){var n=void 0;if(n=e[G]._onDragOver({clientX:rt.clientX,clientY:rt.clientY,target:t,rootEl:e}),n&&!this.options.dragoverBubble)break}t=e}while(e=Fi(e));ji()}},_onTouchMove:function(t){if(Ct){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,s=t.touches?t.touches[0]:t,r=y&&kt(y,!0),a=y&&r&&r.a,l=y&&r&&r.d,c=fe&&K&&Ri(K),h=(s.clientX-Ct.clientX+o.x)/(a||1)+(c?c[0]-Be[0]:0)/(a||1),d=(s.clientY-Ct.clientY+o.y)/(l||1)+(c?c[1]-Be[1]:0)/(l||1);if(!v.active&&!Pt){if(n&&Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}if(y){r?(r.e+=h-(Ne||0),r.f+=d-(ke||0)):r={a:1,b:0,c:0,d:1,e:h,f:d};var f="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");b(y,"webkitTransform",f),b(y,"mozTransform",f),b(y,"msTransform",f),b(y,"transform",f),Ne=h,ke=d,rt=s}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!y){var t=this.options.fallbackOnBody?document.body:L,e=k(u,!0,fe,!0,t),n=this.options;if(fe){for(K=t;b(K,"position")==="static"&&b(K,"transform")==="none"&&K!==document;)K=K.parentNode;K!==document.body&&K!==document.documentElement?(K===document&&(K=dt()),e.top+=K.scrollTop,e.left+=K.scrollLeft):K=dt(),Be=Ri(K)}y=u.cloneNode(!0),Z(y,n.ghostClass,!1),Z(y,n.fallbackClass,!0),Z(y,n.dragClass,!0),b(y,"transition",""),b(y,"transform",""),b(y,"box-sizing","border-box"),b(y,"margin",0),b(y,"top",e.top),b(y,"left",e.left),b(y,"width",e.width),b(y,"height",e.height),b(y,"opacity","0.8"),b(y,"position",fe?"absolute":"fixed"),b(y,"zIndex","100000"),b(y,"pointerEvents","none"),v.ghost=y,t.appendChild(y),b(y,"transform-origin",Mi/parseInt(y.style.width)*100+"% "+_i/parseInt(y.style.height)*100+"%")}},_onDragStart:function(t,e){var n=this,o=t.dataTransfer,s=n.options;if(j("dragStart",this,{evt:t}),v.eventCanceled){this._onDrop();return}j("setupClone",this),v.eventCanceled||(T=zi(u),T.removeAttribute("id"),T.draggable=!1,T.style["will-change"]="",this._hideClone(),Z(T,this.options.chosenClass,!1),v.clone=T),n.cloneId=be(function(){j("clone",n),!v.eventCanceled&&(n.options.removeCloneOnHide||L.insertBefore(T,u),n._hideClone(),Y({sortable:n,name:"clone"}))}),!e&&Z(u,s.dragClass,!0),e?(we=!0,n._loopId=setInterval(n._emulateDragOver,50)):(x(document,"mouseup",n._onDrop),x(document,"touchend",n._onDrop),x(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",s.setData&&s.setData.call(n,o,u)),E(document,"drop",n),b(u,"transform","translateZ(0)")),Pt=!0,n._dragStartId=be(n._dragStarted.bind(n,e,t)),E(document,"selectstart",n),Yt=!0,window.getSelection().removeAllRanges(),Gt&&b(document.body,"user-select","none")},_onDragOver:function(t){var e=this.el,n=t.target,o,s,r,a=this.options,l=a.group,c=v.active,h=he===l,d=a.sort,f=z||c,p,g=this,m=!1;if($e)return;function S(P,V){j(P,g,ht({evt:t,isOwner:h,axis:p?"vertical":"horizontal",revert:r,dragRect:o,targetRect:s,canSort:d,fromSortable:f,target:n,completed:w,onMove:function(ne,Ae){return pe(L,e,u,o,ne,k(ne),t,Ae)},changed:A},V))}function D(){S("dragOverAnimationCapture"),g.captureAnimationState(),g!==f&&f.captureAnimationState()}function w(P){return S("dragOverCompleted",{insertion:P}),P&&(h?c._hideClone():c._showClone(g),g!==f&&(Z(u,z?z.options.ghostClass:c.options.ghostClass,!1),Z(u,a.ghostClass,!0)),z!==g&&g!==v.active?z=g:g===v.active&&z&&(z=null),f===g&&(g._ignoreWhileAnimating=n),g.animateAll(function(){S("dragOverAnimationComplete"),g._ignoreWhileAnimating=null}),g!==f&&(f.animateAll(),f._ignoreWhileAnimating=null)),(n===u&&!u.animated||n===e&&!n.animated)&&(_t=null),!a.dragoverBubble&&!t.rootEl&&n!==document&&(u.parentNode[G]._isOutsideThisEl(t.target),!P&&Lt(t)),!a.dragoverBubble&&t.stopPropagation&&t.stopPropagation(),m=!0}function A(){tt=ot(u),wt=ot(u,a.draggable),Y({sortable:g,name:"change",toEl:e,newIndex:tt,newDraggableIndex:wt,originalEvent:t})}if(t.preventDefault!==void 0&&t.cancelable&&t.preventDefault(),n=at(n,a.draggable,e,!0),S("dragOver"),v.eventCanceled)return m;if(u.contains(t.target)||n.animated&&n.animatingX&&n.animatingY||g._ignoreWhileAnimating===n)return w(!1);if(we=!1,c&&!a.disabled&&(h?d||(r=M!==L):z===this||(this.lastPutMode=he.checkPull(this,c,u,t))&&l.checkPut(this,c,u,t))){if(p=this._getDirection(t,n)==="vertical",o=k(u),S("dragOverValid"),v.eventCanceled)return m;if(r)return M=L,D(),this._hideClone(),S("revert"),v.eventCanceled||(It?L.insertBefore(u,It):L.appendChild(u)),w(!0);var O=je(e,a.draggable);if(!O||$n(t,p,this)&&!O.animated){if(O===u)return w(!1);if(O&&e===t.target&&(n=O),n&&(s=k(n)),pe(L,e,u,o,n,s,t,!!n)!==!1)return D(),O&&O.nextSibling?e.insertBefore(u,O.nextSibling):e.appendChild(u),M=e,A(),w(!0)}else if(O&&zn(t,p,this)){var _=Bt(e,0,a,!0);if(_===u)return w(!1);if(n=_,s=k(n),pe(L,e,u,o,n,s,t,!1)!==!1)return D(),e.insertBefore(u,_),M=e,A(),w(!0)}else if(n.parentNode===e){s=k(n);var C=0,q,J=u.parentNode!==e,R=!Bn(u.animated&&u.toRect||o,n.animated&&n.toRect||s,p),$=p?"top":"left",X=Ti(n,"top","top")||Ti(u,"top","top"),et=X?X.scrollTop:void 0;_t!==n&&(q=s[$],Zt=!1,ue=!R&&a.invertSwap||J),C=Kn(t,n,s,p,R?1:a.swapThreshold,a.invertedSwapThreshold==null?a.swapThreshold:a.invertedSwapThreshold,ue,_t===n);var H;if(C!==0){var B=ot(u);do B-=C,H=M.children[B];while(H&&(b(H,"display")==="none"||H===y))}if(C===0||H===n)return w(!1);_t=n,Qt=C;var Q=n.nextElementSibling,F=!1;F=C===1;var W=pe(L,e,u,o,n,s,t,F);if(W!==!1)return(W===1||W===-1)&&(F=W===1),$e=!0,setTimeout(Vn,30),D(),F&&!Q?e.appendChild(u):n.parentNode.insertBefore(u,F?Q:n),X&&Vi(X,0,et-X.scrollTop),M=u.parentNode,q!==void 0&&!ue&&(me=Math.abs(q-k(n)[$])),A(),w(!0)}if(e.contains(u))return w(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){x(document,"mousemove",this._onTouchMove),x(document,"touchmove",this._onTouchMove),x(document,"pointermove",this._onTouchMove),x(document,"dragover",Lt),x(document,"mousemove",Lt),x(document,"touchmove",Lt)},_offUpEvents:function(){var t=this.el.ownerDocument;x(t,"mouseup",this._onDrop),x(t,"touchend",this._onDrop),x(t,"pointerup",this._onDrop),x(t,"pointercancel",this._onDrop),x(t,"touchcancel",this._onDrop),x(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;if(tt=ot(u),wt=ot(u,n.draggable),j("drop",this,{evt:t}),M=u&&u.parentNode,tt=ot(u),wt=ot(u,n.draggable),v.eventCanceled){this._nulling();return}Pt=!1,ue=!1,Zt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Ke(this.cloneId),Ke(this._dragStartId),this.nativeDraggable&&(x(document,"drop",this),x(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Gt&&b(document.body,"user-select",""),b(u,"transform",""),t&&(Yt&&(t.cancelable&&t.preventDefault(),!n.dropBubble&&t.stopPropagation()),y&&y.parentNode&&y.parentNode.removeChild(y),(L===M||z&&z.lastPutMode!=="clone")&&T&&T.parentNode&&T.parentNode.removeChild(T),u&&(this.nativeDraggable&&x(u,"dragend",this),Fe(u),u.style["will-change"]="",Yt&&!Pt&&Z(u,z?z.options.ghostClass:this.options.ghostClass,!1),Z(u,this.options.chosenClass,!1),Y({sortable:this,name:"unchoose",toEl:M,newIndex:null,newDraggableIndex:null,originalEvent:t}),L!==M?(tt>=0&&(Y({rootEl:M,name:"add",toEl:M,fromEl:L,originalEvent:t}),Y({sortable:this,name:"remove",toEl:M,originalEvent:t}),Y({rootEl:M,name:"sort",toEl:M,fromEl:L,originalEvent:t}),Y({sortable:this,name:"sort",toEl:M,originalEvent:t})),z&&z.save()):tt!==Nt&&tt>=0&&(Y({sortable:this,name:"update",toEl:M,originalEvent:t}),Y({sortable:this,name:"sort",toEl:M,originalEvent:t})),v.active&&((tt==null||tt===-1)&&(tt=Nt,wt=Jt),Y({sortable:this,name:"end",toEl:M,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){j("nulling",this),L=u=M=y=It=T=ge=xt=Ct=rt=Yt=tt=wt=Nt=Jt=_t=Qt=z=he=v.dragged=v.ghost=v.clone=v.active=null;var t=this.el;Se.forEach(function(e){t.contains(e)&&(e.checked=!0)}),Se.length=Ne=ke=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":u&&(this._onDragOver(t),Wn(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,n=this.el.children,o=0,s=n.length,r=this.options;o<s;o++)e=n[o],at(e,r.draggable,this.el,!1)&&t.push(e.getAttribute(r.dataIdAttr)||Yn(e));return t},sort:function(t,e){var n={},o=this.el;this.toArray().forEach(function(s,r){var a=o.children[r];at(a,this.options.draggable,o,!1)&&(n[s]=a)},this),e&&this.captureAnimationState(),t.forEach(function(s){n[s]&&(o.removeChild(n[s]),o.appendChild(n[s]))}),e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return at(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var n=this.options;if(e===void 0)return n[t];var o=ee.modifyOption(this,t,e);typeof o<"u"?n[t]=o:n[t]=e,t==="group"&&Yi(n)},destroy:function(){j("destroy",this);var t=this.el;t[G]=null,x(t,"mousedown",this._onTapStart),x(t,"touchstart",this._onTapStart),x(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(x(t,"dragover",this),x(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(e){e.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),xe.splice(xe.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!xt){if(j("hideClone",this),v.eventCanceled)return;b(T,"display","none"),this.options.removeCloneOnHide&&T.parentNode&&T.parentNode.removeChild(T),xt=!0}},_showClone:function(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(xt){if(j("showClone",this),v.eventCanceled)return;u.parentNode==L&&!this.options.group.revertClone?L.insertBefore(T,u):It?L.insertBefore(T,It):L.appendChild(T),this.options.group.revertClone&&this.animate(u,T),b(T,"display",""),xt=!1}}};function Wn(i){i.dataTransfer&&(i.dataTransfer.dropEffect="move"),i.cancelable&&i.preventDefault()}function pe(i,t,e,n,o,s,r,a){var l,c=i[G],h=c.options.onMove,d;return window.CustomEvent&&!mt&&!te?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=t,l.from=i,l.dragged=e,l.draggedRect=n,l.related=o||t,l.relatedRect=s||k(t),l.willInsertAfter=a,l.originalEvent=r,i.dispatchEvent(l),h&&(d=h.call(c,l,r)),d}function Fe(i){i.draggable=!1}function Vn(){$e=!1}function zn(i,t,e){var n=k(Bt(e.el,0,e.options,!0)),o=$i(e.el,e.options,y),s=10;return t?i.clientX<o.left-s||i.clientY<n.top&&i.clientX<n.right:i.clientY<o.top-s||i.clientY<n.bottom&&i.clientX<n.left}function $n(i,t,e){var n=k(je(e.el,e.options.draggable)),o=$i(e.el,e.options,y),s=10;return t?i.clientX>o.right+s||i.clientY>n.bottom&&i.clientX>n.left:i.clientY>o.bottom+s||i.clientX>n.right&&i.clientY>n.top}function Kn(i,t,e,n,o,s,r,a){var l=n?i.clientY:i.clientX,c=n?e.height:e.width,h=n?e.top:e.left,d=n?e.bottom:e.right,f=!1;if(!r){if(a&&me<c*o){if(!Zt&&(Qt===1?l>h+c*s/2:l<d-c*s/2)&&(Zt=!0),Zt)f=!0;else if(Qt===1?l<h+me:l>d-me)return-Qt}else if(l>h+c*(1-o)/2&&l<d-c*(1-o)/2)return Xn(t)}return f=f||r,f&&(l<h+c*s/2||l>d-c*s/2)?l>h+c/2?1:-1:0}function Xn(i){return ot(u)<ot(i)?1:-1}function Yn(i){for(var t=i.tagName+i.className+i.src+i.href+i.textContent,e=t.length,n=0;e--;)n+=t.charCodeAt(e);return n.toString(36)}function Un(i){Se.length=0;for(var t=i.getElementsByTagName("input"),e=t.length;e--;){var n=t[e];n.checked&&Se.push(n)}}function be(i){return setTimeout(i,0)}function Ke(i){return clearTimeout(i)}Oe&&E(document,"touchmove",function(i){(v.active||Pt)&&i.cancelable&&i.preventDefault()});v.utils={on:E,off:x,css:b,find:Hi,is:function(t,e){return!!at(t,e,t,!1)},extend:In,throttle:Wi,closest:at,toggleClass:Z,clone:zi,index:ot,nextTick:be,cancelNextTick:Ke,detectDirection:Xi,getChild:Bt,expando:G};v.get=function(i){return i[G]};v.mount=function(){for(var i=arguments.length,t=new Array(i),e=0;e<i;e++)t[e]=arguments[e];t[0].constructor===Array&&(t=t[0]),t.forEach(function(n){if(!n.prototype||!n.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));n.utils&&(v.utils=ht(ht({},v.utils),n.utils)),ee.mount(n)})};v.create=function(i,t){return new v(i,t)};v.version=Cn;var N=[],Ut,Xe,Ye=!1,He,We,Ee,jt;function jn(){function i(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var t in this)t.charAt(0)==="_"&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}return i.prototype={dragStarted:function(e){var n=e.originalEvent;this.sortable.nativeDraggable?E(document,"dragover",this._handleAutoScroll):this.options.supportPointer?E(document,"pointermove",this._handleFallbackAutoScroll):n.touches?E(document,"touchmove",this._handleFallbackAutoScroll):E(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(e){var n=e.originalEvent;!this.options.dragOverBubble&&!n.rootEl&&this._handleAutoScroll(n)},drop:function(){this.sortable.nativeDraggable?x(document,"dragover",this._handleAutoScroll):(x(document,"pointermove",this._handleFallbackAutoScroll),x(document,"touchmove",this._handleFallbackAutoScroll),x(document,"mousemove",this._handleFallbackAutoScroll)),Ni(),ve(),Tn()},nulling:function(){Ee=Xe=Ut=Ye=jt=He=We=null,N.length=0},_handleFallbackAutoScroll:function(e){this._handleAutoScroll(e,!0)},_handleAutoScroll:function(e,n){var o=this,s=(e.touches?e.touches[0]:e).clientX,r=(e.touches?e.touches[0]:e).clientY,a=document.elementFromPoint(s,r);if(Ee=e,n||this.options.forceAutoScrollFallback||te||mt||Gt){Ve(e,this.options,a,n);var l=St(a,!0);Ye&&(!jt||s!==He||r!==We)&&(jt&&Ni(),jt=setInterval(function(){var c=St(document.elementFromPoint(s,r),!0);c!==l&&(l=c,ve()),Ve(e,o.options,c,n)},10),He=s,We=r)}else{if(!this.options.bubbleScroll||St(a,!0)===dt()){ve();return}Ve(e,this.options,St(a,!1),!1)}}},gt(i,{pluginName:"scroll",initializeByDefault:!0})}function ve(){N.forEach(function(i){clearInterval(i.pid)}),N=[]}function Ni(){clearInterval(jt)}var Ve=Wi(function(i,t,e,n){if(t.scroll){var o=(i.touches?i.touches[0]:i).clientX,s=(i.touches?i.touches[0]:i).clientY,r=t.scrollSensitivity,a=t.scrollSpeed,l=dt(),c=!1,h;Xe!==e&&(Xe=e,ve(),Ut=t.scroll,h=t.scrollFn,Ut===!0&&(Ut=St(e,!0)));var d=0,f=Ut;do{var p=f,g=k(p),m=g.top,S=g.bottom,D=g.left,w=g.right,A=g.width,O=g.height,_=void 0,C=void 0,q=p.scrollWidth,J=p.scrollHeight,R=b(p),$=p.scrollLeft,X=p.scrollTop;p===l?(_=A<q&&(R.overflowX==="auto"||R.overflowX==="scroll"||R.overflowX==="visible"),C=O<J&&(R.overflowY==="auto"||R.overflowY==="scroll"||R.overflowY==="visible")):(_=A<q&&(R.overflowX==="auto"||R.overflowX==="scroll"),C=O<J&&(R.overflowY==="auto"||R.overflowY==="scroll"));var et=_&&(Math.abs(w-o)<=r&&$+A<q)-(Math.abs(D-o)<=r&&!!$),H=C&&(Math.abs(S-s)<=r&&X+O<J)-(Math.abs(m-s)<=r&&!!X);if(!N[d])for(var B=0;B<=d;B++)N[B]||(N[B]={});(N[d].vx!=et||N[d].vy!=H||N[d].el!==p)&&(N[d].el=p,N[d].vx=et,N[d].vy=H,clearInterval(N[d].pid),(et!=0||H!=0)&&(c=!0,N[d].pid=setInterval(function(){n&&this.layer===0&&v.active._onTouchMove(Ee);var Q=N[this.layer].vy?N[this.layer].vy*a:0,F=N[this.layer].vx?N[this.layer].vx*a:0;typeof h=="function"&&h.call(v.dragged.parentNode[G],F,Q,i,Ee,N[this.layer].el)!=="continue"||Vi(N[this.layer].el,F,Q)}.bind({layer:d}),24))),d++}while(t.bubbleScroll&&f!==l&&(f=St(f,!1)));Ye=c}},30),Gi=function(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,s=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var c=n||s;a();var h=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e,d=document.elementFromPoint(h.clientX,h.clientY);l(),c&&!c.el.contains(d)&&(r("spill"),this.onSpill({dragEl:o,putSortable:n}))}};function Ge(){}Ge.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,n=t.putSortable;this.sortable.captureAnimationState(),n&&n.captureAnimationState();var o=Bt(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e),this.sortable.animateAll(),n&&n.animateAll()},drop:Gi};gt(Ge,{pluginName:"revertOnSpill"});function qe(){}qe.prototype={onSpill:function(t){var e=t.dragEl,n=t.putSortable,o=n||this.sortable;o.captureAnimationState(),e.parentNode&&e.parentNode.removeChild(e),o.animateAll()},drop:Gi};gt(qe,{pluginName:"removeOnSpill"});v.mount(new jn);v.mount(qe,Ge);var qi=v;function bt(i){return i==null||i===""||typeof i=="string"&&i.trim()===""}function I(i){return!bt(i)}var De=class{constructor({ariaLabel:t=null,canOptionLabelsWrap:e=!0,canSelectPlaceholder:n=!0,element:o,getOptionLabelUsing:s=null,getOptionLabelsUsing:r=null,getOptionsUsing:a=null,getSearchResultsUsing:l=null,hasDynamicOptions:c=!1,hasDynamicSearchResults:h=!0,hasInitialNoOptionsMessage:d=!1,id:f=null,initialOptionLabel:p=null,initialOptionLabels:g=null,initialState:m=null,isAutofocused:S=!1,isDisabled:D=!1,isHtmlAllowed:w=!1,isMultiple:A=!1,isReorderable:O=!1,isSearchable:_=!1,livewireId:C=null,loadingMessage:q="Loading...",maxItems:J=null,maxItemsMessage:R="Maximum number of items selected",noOptionsMessage:$="No options available",noSearchResultsMessage:X="No results found",onStateChange:et=()=>{},options:H,optionsLimit:B=null,placeholder:Q,position:F=null,searchableOptionFields:W=["label"],searchDebounce:P=1e3,searchingMessage:V="Searching...",searchPrompt:ie="Search...",state:ne,statePath:Ae=null}){this.ariaLabel=t,this.canOptionLabelsWrap=e,this.canSelectPlaceholder=n,this.element=o,this.getOptionLabelUsing=s,this.getOptionLabelsUsing=r,this.getOptionsUsing=a,this.getSearchResultsUsing=l,this.hasDynamicOptions=c,this.hasDynamicSearchResults=h,this.hasInitialNoOptionsMessage=d,this.id=f,this.initialOptionLabel=p,this.initialOptionLabels=g,this.initialState=m,this.isAutofocused=S,this.isDisabled=D,this.isHtmlAllowed=w,this.isMultiple=A,this.isReorderable=O,this.isSearchable=_,this.livewireId=C,this.loadingMessage=q,this.maxItems=J,this.maxItemsMessage=R,this.noOptionsMessage=$,this.noSearchResultsMessage=X,this.onStateChange=et,this.options=H,this.optionsLimit=B,this.originalOptions=JSON.parse(JSON.stringify(H)),this.placeholder=Q,this.position=F,this.searchableOptionFields=Array.isArray(W)?W:["label"],this.searchDebounce=P,this.searchingMessage=V,this.searchPrompt=ie,this.state=ne,this.statePath=Ae,this.activeSearchId=0,this.labelRepository={},this.isOpen=!1,this.selectedIndex=-1,this.searchQuery="",this.searchTimeout=null,this.isSearching=!1,this.maxItemsMessageElement=null,this.selectedDisplayVersion=0,this.render(),this.setUpEventListeners(),this.isAutofocused&&this.selectButton.focus()}populateLabelRepositoryFromOptions(t){if(!(!t||!Array.isArray(t)))for(let e of t)e.options&&Array.isArray(e.options)?this.populateLabelRepositoryFromOptions(e.options):e.value!==void 0&&e.label!==void 0&&(this.labelRepository[e.value]=e.label)}render(){this.populateLabelRepositoryFromOptions(this.options),this.container=document.createElement("div"),this.container.className="fi-select-input-ctn",this.canOptionLabelsWrap||this.container.classList.add("fi-select-input-ctn-option-labels-not-wrapped"),this.selectButton=document.createElement("button"),this.selectButton.className="fi-select-input-btn",this.selectButton.type="button",this.selectButton.setAttribute("role","combobox"),this.selectButton.setAttribute("aria-haspopup","listbox"),this.selectButton.setAttribute("aria-expanded","false"),I(this.id)&&(this.selectButton.id=this.id),I(this.ariaLabel)&&this.selectButton.setAttribute("aria-label",this.ariaLabel),this.selectedDisplay=document.createElement("div"),this.selectedDisplay.className="fi-select-input-value-ctn",this.updateSelectedDisplay(),this.selectButton.appendChild(this.selectedDisplay),this.dropdown=document.createElement("div"),this.dropdown.className="fi-dropdown-panel fi-scrollable",this.dropdown.setAttribute("role","listbox"),this.dropdown.setAttribute("tabindex","-1"),this.dropdown.style.display="none",this.dropdownId=`fi-select-input-dropdown-${Math.random().toString(36).substring(2,11)}`,this.dropdown.id=this.dropdownId,this.selectButton.setAttribute("aria-controls",this.dropdownId),this.isMultiple&&this.dropdown.setAttribute("aria-multiselectable","true"),this.isSearchable&&(this.searchContainer=document.createElement("div"),this.searchContainer.className="fi-select-input-search-ctn",this.searchInput=document.createElement("input"),this.searchInput.className="fi-input",this.searchInput.type="text",this.searchInput.placeholder=this.searchPrompt,this.searchInput.setAttribute("aria-label","Search"),this.searchContainer.appendChild(this.searchInput),this.dropdown.appendChild(this.searchContainer),this.searchInput.addEventListener("input",t=>{this.isDisabled||this.handleSearch(t)}),this.searchInput.addEventListener("keydown",t=>{if(!this.isDisabled){if(t.key==="Tab"){t.preventDefault();let e=this.getVisibleOptions();if(e.length===0)return;t.shiftKey?this.selectedIndex=e.length-1:this.selectedIndex=0,e.forEach(n=>{n.classList.remove("fi-selected")}),e[this.selectedIndex].classList.add("fi-selected"),e[this.selectedIndex].focus()}else if(t.key==="ArrowDown"){if(t.preventDefault(),t.stopPropagation(),this.getVisibleOptions().length===0)return;this.selectedIndex=-1,this.searchInput.blur(),this.focusNextOption()}else if(t.key==="ArrowUp"){t.preventDefault(),t.stopPropagation();let e=this.getVisibleOptions();if(e.length===0)return;this.selectedIndex=e.length-1,this.searchInput.blur(),e[this.selectedIndex].classList.add("fi-selected"),e[this.selectedIndex].focus(),e[this.selectedIndex].id&&this.dropdown.setAttribute("aria-activedescendant",e[this.selectedIndex].id),this.scrollOptionIntoView(e[this.selectedIndex])}else if(t.key==="Enter"){if(t.preventDefault(),t.stopPropagation(),this.isSearching)return;let e=this.getVisibleOptions();if(e.length===0)return;let n=e.find(s=>{let r=s.getAttribute("aria-disabled")==="true",a=s.classList.contains("fi-disabled"),l=s.offsetParent===null;return!(r||a||l)});if(!n)return;let o=n.getAttribute("data-value");if(o===null)return;this.selectOption(o)}}})),this.optionsList=document.createElement("ul"),this.statusRegion=document.createElement("div"),this.statusRegion.className="fi-sr-only",this.statusRegion.setAttribute("role","status"),this.statusRegion.setAttribute("aria-live","polite"),this.statusRegion.setAttribute("aria-atomic","true"),this.renderOptions(),this.container.appendChild(this.selectButton),this.container.appendChild(this.dropdown),this.container.appendChild(this.statusRegion),this.element.appendChild(this.container),this.applyDisabledState()}renderOptions(){this.optionsList.innerHTML="";let t=0,e=this.options,n=0,o=!1;this.options.forEach(a=>{a.options&&Array.isArray(a.options)?(n+=a.options.length,o=!0):n++}),o?this.optionsList.className="fi-select-input-options-ctn":n>0&&(this.optionsList.className="fi-dropdown-list");let s=o?null:this.optionsList,r=0;for(let a of e){if(this.optionsLimit>0&&r>=this.optionsLimit)break;if(a.options&&Array.isArray(a.options)){let l=a.options;if(this.isMultiple&&Array.isArray(this.state)&&this.state.length>0&&(l=a.options.filter(c=>!this.state.includes(c.value))),l.length>0){if(this.optionsLimit>0){let c=this.optionsLimit-r;c<l.length&&(l=l.slice(0,c))}this.renderOptionGroup(a.label,l),r+=l.length,t+=l.length}}else{if(this.isMultiple&&Array.isArray(this.state)&&this.state.includes(a.value))continue;!s&&o&&(s=document.createElement("ul"),s.className="fi-dropdown-list",this.optionsList.appendChild(s));let l=this.createOptionElement(a.value,a);s.appendChild(l),r++,t++}}t===0?(this.searchQuery?this.showNoResultsMessage():this.hasInitialNoOptionsMessage||this.hasDynamicOptions?this.showNoOptionsMessage():this.isMultiple&&this.isOpen&&!this.isSearchable&&this.closeDropdown(),this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList)):(this.hideLoadingState(),this.optionsList.parentNode!==this.dropdown&&this.dropdown.appendChild(this.optionsList))}renderOptionGroup(t,e){if(e.length===0)return;let n=document.createElement("li");n.className="fi-select-input-option-group";let o=document.createElement("div");o.className="fi-dropdown-header",o.textContent=t;let s=document.createElement("ul");s.className="fi-dropdown-list",e.forEach(r=>{let a=this.createOptionElement(r.value,r);s.appendChild(a)}),n.appendChild(o),n.appendChild(s),this.optionsList.appendChild(n)}createOptionElement(t,e){let n=t,o=e,s=!1;typeof e=="object"&&e!==null&&"label"in e&&"value"in e&&(n=e.value,o=e.label,s=e.isDisabled||!1);let r=document.createElement("li");r.className="fi-dropdown-list-item fi-select-input-option",s&&r.classList.add("fi-disabled");let a=`fi-select-input-option-${Math.random().toString(36).substring(2,11)}`;if(r.id=a,r.setAttribute("role","option"),r.setAttribute("data-value",n),r.setAttribute("tabindex","0"),s&&r.setAttribute("aria-disabled","true"),this.isHtmlAllowed&&typeof o=="string"){let h=document.createElement("div");h.innerHTML=o;let d=h.textContent||h.innerText||o;r.setAttribute("aria-label",d)}let l=this.isMultiple?Array.isArray(this.state)&&this.state.includes(n):this.state===n;r.setAttribute("aria-selected",l?"true":"false"),l&&r.classList.add("fi-selected");let c=document.createElement("span");return this.isHtmlAllowed?c.innerHTML=o:c.textContent=o,r.appendChild(c),s||r.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),this.selectOption(n),this.isMultiple&&(this.isSearchable&&this.searchInput?setTimeout(()=>{this.searchInput.focus()},0):setTimeout(()=>{r.focus()},0))}),r}async updateSelectedDisplay(){this.selectedDisplayVersion=this.selectedDisplayVersion+1;let t=this.selectedDisplayVersion,e=document.createDocumentFragment();if(this.isMultiple){if(!Array.isArray(this.state)||this.state.length===0){let o=document.createElement("span");o.textContent=this.placeholder,o.classList.add("fi-select-input-placeholder"),e.appendChild(o)}else{let o=await this.getLabelsForMultipleSelection();if(t!==this.selectedDisplayVersion)return;this.addBadgesForSelectedOptions(o,e)}t===this.selectedDisplayVersion&&(this.selectedDisplay.replaceChildren(e),this.isOpen&&this.deferPositionDropdown());return}if(this.state===null||this.state===""){let o=document.createElement("span");if(o.textContent=this.placeholder,o.classList.add("fi-select-input-placeholder"),e.appendChild(o),t===this.selectedDisplayVersion){this.selectedDisplay.replaceChildren(e);let s=this.container.querySelector(".fi-select-input-value-remove-btn");s&&s.remove(),this.container.classList.remove("fi-select-input-ctn-clearable")}return}let n=await this.getLabelForSingleSelection();t===this.selectedDisplayVersion&&(this.addSingleSelectionDisplay(n,e),t===this.selectedDisplayVersion&&this.selectedDisplay.replaceChildren(e))}async getLabelsForMultipleSelection(){let t=this.getSelectedOptionLabels(),e=[];if(Array.isArray(this.state)){for(let o of this.state)if(!I(this.labelRepository[o])){if(I(t[o])){this.labelRepository[o]=t[o];continue}e.push(o.toString())}}if(e.length>0&&I(this.initialOptionLabels)&&JSON.stringify(this.state)===JSON.stringify(this.initialState)){if(Array.isArray(this.initialOptionLabels))for(let o of this.initialOptionLabels)I(o)&&o.value!==void 0&&o.label!==void 0&&e.includes(o.value)&&(this.labelRepository[o.value]=o.label)}else if(e.length>0&&this.getOptionLabelsUsing)try{let o=await this.getOptionLabelsUsing();for(let s of o)I(s)&&s.value!==void 0&&s.label!==void 0&&(this.labelRepository[s.value]=s.label)}catch(o){console.error("Error fetching option labels:",o)}let n=[];if(Array.isArray(this.state))for(let o of this.state)I(this.labelRepository[o])?n.push(this.labelRepository[o]):I(t[o])?n.push(t[o]):n.push(o);return n}createBadgeElement(t,e){let n=document.createElement("span");n.className="fi-badge fi-size-md fi-color fi-color-primary fi-text-color-600 dark:fi-text-color-200",I(t)&&n.setAttribute("data-value",t);let o=document.createElement("span");o.className="fi-badge-label-ctn";let s=document.createElement("span");s.className="fi-badge-label",this.canOptionLabelsWrap&&s.classList.add("fi-wrapped"),this.isHtmlAllowed?s.innerHTML=e:s.textContent=e,o.appendChild(s),n.appendChild(o);let r=this.createRemoveButton(t,e);return n.appendChild(r),n}createRemoveButton(t,e){let n=document.createElement("button");return n.type="button",n.className="fi-badge-delete-btn",n.innerHTML='<svg class="fi-icon fi-size-xs" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" data-slot="icon"><path d="M5.28 4.22a.75.75 0 0 0-1.06 1.06L6.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L8 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L9.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L8 6.94 5.28 4.22Z"></path></svg>',n.setAttribute("aria-label","Remove "+(this.isHtmlAllowed?e.replace(/<[^>]*>/g,""):e)),n.addEventListener("click",o=>{o.stopPropagation(),I(t)&&this.selectOption(t)}),n.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),o.stopPropagation(),I(t)&&this.selectOption(t))}),n}addBadgesForSelectedOptions(t,e=this.selectedDisplay){let n=document.createElement("div");n.className="fi-select-input-value-badges-ctn",t.forEach((o,s)=>{let r=Array.isArray(this.state)?this.state[s]:null,a=this.createBadgeElement(r,o);n.appendChild(a)}),e.appendChild(n),this.isReorderable&&(n.addEventListener("click",o=>{o.stopPropagation()}),n.addEventListener("mousedown",o=>{o.stopPropagation()}),new qi(n,{animation:150,onEnd:()=>{let o=[];n.querySelectorAll("[data-value]").forEach(s=>{o.push(s.getAttribute("data-value"))}),this.state=o,this.onStateChange(this.state)}}))}async getLabelForSingleSelection(){let t=this.labelRepository[this.state];if(bt(t)&&(t=this.getSelectedOptionLabel(this.state)),bt(t)&&I(this.initialOptionLabel)&&this.state===this.initialState)t=this.initialOptionLabel,I(this.state)&&(this.labelRepository[this.state]=t);else if(bt(t)&&this.getOptionLabelUsing)try{t=await this.getOptionLabelUsing(),I(t)&&I(this.state)&&(this.labelRepository[this.state]=t)}catch(e){console.error("Error fetching option label:",e),t=this.state}else bt(t)&&(t=this.state);return t}addSingleSelectionDisplay(t,e=this.selectedDisplay){let n=document.createElement("span");if(n.className="fi-select-input-value-label",this.isHtmlAllowed?n.innerHTML=t:n.textContent=t,e.appendChild(n),!this.canSelectPlaceholder||this.container.querySelector(".fi-select-input-value-remove-btn"))return;let o=document.createElement("button");o.type="button",o.className="fi-select-input-value-remove-btn",o.innerHTML='<svg class="fi-icon fi-size-sm" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" /></svg>',o.setAttribute("aria-label","Clear selection"),o.addEventListener("click",s=>{s.stopPropagation(),this.selectOption("")}),o.addEventListener("keydown",s=>{(s.key===" "||s.key==="Enter")&&(s.preventDefault(),s.stopPropagation(),this.selectOption(""))}),this.container.appendChild(o),this.container.classList.add("fi-select-input-ctn-clearable")}getSelectedOptionLabel(t){if(I(this.labelRepository[t]))return this.labelRepository[t];let e="";for(let n of this.options)if(n.options&&Array.isArray(n.options)){for(let o of n.options)if(o.value===t){e=o.label,this.labelRepository[t]=e;break}}else if(n.value===t){e=n.label,this.labelRepository[t]=e;break}return e}setUpEventListeners(){this.buttonClickListener=()=>{this.toggleDropdown()},this.documentClickListener=t=>{!this.container.contains(t.target)&&this.isOpen&&this.closeDropdown()},this.buttonKeydownListener=t=>{this.isDisabled||this.handleSelectButtonKeydown(t)},this.dropdownKeydownListener=t=>{this.isDisabled||this.isSearchable&&document.activeElement===this.searchInput&&!["Tab","Escape"].includes(t.key)||this.handleDropdownKeydown(t)},this.selectButton.addEventListener("click",this.buttonClickListener),document.addEventListener("click",this.documentClickListener),this.selectButton.addEventListener("keydown",this.buttonKeydownListener),this.dropdown.addEventListener("keydown",this.dropdownKeydownListener),!this.isMultiple&&this.livewireId&&this.statePath&&this.getOptionLabelUsing&&(this.refreshOptionLabelListener=async t=>{if(t.detail.livewireId===this.livewireId&&t.detail.statePath===this.statePath&&I(this.state))try{delete this.labelRepository[this.state];let e=await this.getOptionLabelUsing();I(e)&&(this.labelRepository[this.state]=e);let n=this.selectedDisplay.querySelector(".fi-select-input-value-label");I(n)&&(this.isHtmlAllowed?n.innerHTML=e:n.textContent=e),this.updateOptionLabelInList(this.state,e)}catch(e){console.error("Error refreshing option label:",e)}},window.addEventListener("filament-forms::select.refreshSelectedOptionLabel",this.refreshOptionLabelListener))}updateOptionLabelInList(t,e){this.labelRepository[t]=e;let n=this.getVisibleOptions();for(let o of n)if(o.getAttribute("data-value")===String(t)){if(o.innerHTML="",this.isHtmlAllowed){let s=document.createElement("span");s.innerHTML=e,o.appendChild(s)}else o.appendChild(document.createTextNode(e));break}for(let o of this.options)if(o.options&&Array.isArray(o.options)){for(let s of o.options)if(s.value===t){s.label=e;break}}else if(o.value===t){o.label=e;break}for(let o of this.originalOptions)if(o.options&&Array.isArray(o.options)){for(let s of o.options)if(s.value===t){s.label=e;break}}else if(o.value===t){o.label=e;break}}handleSelectButtonKeydown(t){switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.isOpen?this.focusNextOption():this.openDropdown();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.isOpen?this.focusPreviousOption():this.openDropdown();break;case" ":if(t.preventDefault(),this.isOpen){if(this.selectedIndex>=0){let e=this.getVisibleOptions()[this.selectedIndex];e&&e.click()}}else this.openDropdown();break;case"Enter":break;case"Escape":this.isOpen&&(t.preventDefault(),this.closeDropdown());break;case"Tab":this.isOpen&&this.closeDropdown();break;default:if(this.isSearchable&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&typeof t.key=="string"&&t.key.length===1){t.preventDefault();let e=t.key;this.isOpen||this.openDropdown(),this.searchInput&&(this.searchInput.focus(),this.searchInput.value=(this.searchInput.value||"")+e,this.searchInput.dispatchEvent(new Event("input",{bubbles:!0})))}break}}handleDropdownKeydown(t){switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation(),this.focusNextOption();break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),this.focusPreviousOption();break;case" ":if(t.preventDefault(),this.selectedIndex>=0){let e=this.getVisibleOptions()[this.selectedIndex];e&&e.click()}break;case"Enter":if(t.preventDefault(),this.selectedIndex>=0){let e=this.getVisibleOptions()[this.selectedIndex];e&&e.click()}else{let e=this.element.closest("form");e&&e.submit()}break;case"Escape":t.preventDefault(),this.closeDropdown(),this.selectButton.focus();break;case"Tab":this.closeDropdown();break;default:if(this.isSearchable&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&typeof t.key=="string"&&t.key.length===1){t.preventDefault();let e=t.key;this.searchInput&&(this.searchInput.focus(),this.searchInput.value=(this.searchInput.value||"")+e,this.searchInput.dispatchEvent(new Event("input",{bubbles:!0})))}break}}toggleDropdown(){if(!this.isDisabled){if(this.isOpen){this.closeDropdown();return}this.isMultiple&&!this.isSearchable&&!this.hasAvailableOptions()||this.openDropdown()}}hasAvailableOptions(){for(let t of this.options)if(t.options&&Array.isArray(t.options)){for(let e of t.options)if(!Array.isArray(this.state)||!this.state.includes(e.value))return!0}else if(!Array.isArray(this.state)||!this.state.includes(t.value))return!0;return!1}async openDropdown(){this.dropdown.style.display="block",this.dropdown.style.opacity="0";let t=this.selectButton.closest(".fi-fixed-positioning-context")!==null&&this.selectButton.closest(".fi-absolute-positioning-context")===null;if(this.dropdown.style.position=t?"fixed":"absolute",this.dropdown.style.width=`${this.selectButton.offsetWidth}px`,this.selectButton.setAttribute("aria-expanded","true"),this.isOpen=!0,this.positionDropdown(),this.resizeListener||(this.resizeListener=()=>{this.dropdown.style.width=`${this.selectButton.offsetWidth}px`,this.positionDropdown()},window.addEventListener("resize",this.resizeListener)),this.scrollListener||(this.scrollListener=()=>this.positionDropdown(),window.addEventListener("scroll",this.scrollListener,!0)),this.dropdown.style.opacity="1",this.isSearchable&&this.searchInput&&(this.searchInput.value="",this.searchQuery="",this.hasDynamicOptions||(this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions())),this.hasDynamicOptions&&this.getOptionsUsing){this.showLoadingState(!1);try{let e=await this.getOptionsUsing(),n=Array.isArray(e)?e:e&&Array.isArray(e.options)?e.options:[];if(this.options=n,this.originalOptions=JSON.parse(JSON.stringify(n)),this.populateLabelRepositoryFromOptions(n),this.isSearchable&&this.searchInput&&(this.searchInput.value&&this.searchInput.value.trim()!==""||this.searchQuery&&this.searchQuery.trim()!=="")){let o=(this.searchInput.value||this.searchQuery||"").trim().toLowerCase();this.hideLoadingState(),this.filterOptions(o)}else this.renderOptions()}catch(e){console.error("Error fetching options:",e),this.hideLoadingState()}}else(!this.hasInitialNoOptionsMessage||this.searchQuery)&&this.hideLoadingState();if(this.isSearchable&&this.searchInput)this.searchInput.focus();else{this.selectedIndex=-1;let e=this.getVisibleOptions();if(this.isMultiple){if(Array.isArray(this.state)&&this.state.length>0){for(let n=0;n<e.length;n++)if(this.state.includes(e[n].getAttribute("data-value"))){this.selectedIndex=n;break}}}else for(let n=0;n<e.length;n++)if(e[n].getAttribute("data-value")===this.state){this.selectedIndex=n;break}this.selectedIndex===-1&&e.length>0&&(this.selectedIndex=0),this.selectedIndex>=0&&(e[this.selectedIndex].classList.add("fi-selected"),e[this.selectedIndex].focus())}}positionDropdown(){let t=this.position==="top"?"top-start":"bottom-start",e=[Ei(4),Oi({padding:5})];this.position!=="top"&&this.position!=="bottom"&&e.push(Di());let n=this.selectButton.closest(".fi-fixed-positioning-context")!==null&&this.selectButton.closest(".fi-absolute-positioning-context")===null;Ai(this.selectButton,this.dropdown,{placement:t,middleware:e,strategy:n?"fixed":"absolute"}).then(({x:o,y:s})=>{Object.assign(this.dropdown.style,{left:`${o}px`,top:`${s}px`})})}deferPositionDropdown(){this.isOpen&&(this.positioningRequestAnimationFrame&&(cancelAnimationFrame(this.positioningRequestAnimationFrame),this.positioningRequestAnimationFrame=null),this.positioningRequestAnimationFrame=requestAnimationFrame(()=>{this.positionDropdown(),this.positioningRequestAnimationFrame=null}))}closeDropdown(){this.dropdown.style.display="none",this.selectButton.setAttribute("aria-expanded","false"),this.isOpen=!1,this.searchTimeout&&(clearTimeout(this.searchTimeout),this.searchTimeout=null),this.activeSearchId++,this.isSearching=!1,this.hideLoadingState(),this.hideMaxItemsMessage(),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener,!0),this.scrollListener=null),this.getVisibleOptions().forEach(e=>{e.classList.remove("fi-selected")}),this.dropdown.removeAttribute("aria-activedescendant")}focusNextOption(){let t=this.getVisibleOptions();if(t.length!==0){if(this.selectedIndex>=0&&this.selectedIndex<t.length&&t[this.selectedIndex].classList.remove("fi-selected"),this.selectedIndex===t.length-1&&this.isSearchable&&this.searchInput){this.selectedIndex=-1,this.searchInput.focus(),this.dropdown.removeAttribute("aria-activedescendant");return}this.selectedIndex=(this.selectedIndex+1)%t.length,t[this.selectedIndex].classList.add("fi-selected"),t[this.selectedIndex].focus(),t[this.selectedIndex].id&&this.dropdown.setAttribute("aria-activedescendant",t[this.selectedIndex].id),this.scrollOptionIntoView(t[this.selectedIndex])}}focusPreviousOption(){let t=this.getVisibleOptions();if(t.length!==0){if(this.selectedIndex>=0&&this.selectedIndex<t.length&&t[this.selectedIndex].classList.remove("fi-selected"),(this.selectedIndex===0||this.selectedIndex===-1)&&this.isSearchable&&this.searchInput){this.selectedIndex=-1,this.searchInput.focus(),this.dropdown.removeAttribute("aria-activedescendant");return}this.selectedIndex=(this.selectedIndex-1+t.length)%t.length,t[this.selectedIndex].classList.add("fi-selected"),t[this.selectedIndex].focus(),t[this.selectedIndex].id&&this.dropdown.setAttribute("aria-activedescendant",t[this.selectedIndex].id),this.scrollOptionIntoView(t[this.selectedIndex])}}scrollOptionIntoView(t){if(!t)return;let e=this.dropdown.getBoundingClientRect(),n=t.getBoundingClientRect();n.bottom>e.bottom?this.dropdown.scrollTop+=n.bottom-e.bottom:n.top<e.top&&(this.dropdown.scrollTop-=e.top-n.top)}getVisibleOptions(){let t=[];this.optionsList.classList.contains("fi-dropdown-list")?t=Array.from(this.optionsList.querySelectorAll(':scope > li[role="option"]')):t=Array.from(this.optionsList.querySelectorAll(':scope > ul.fi-dropdown-list > li[role="option"]'));let e=Array.from(this.optionsList.querySelectorAll('li.fi-select-input-option-group > ul > li[role="option"]'));return[...t,...e]}getSelectedOptionLabels(){if(!Array.isArray(this.state)||this.state.length===0)return{};let t={};for(let e of this.state){let n=!1;for(let o of this.options)if(o.options&&Array.isArray(o.options)){for(let s of o.options)if(s.value===e){t[e]=s.label,n=!0;break}if(n)break}else if(o.value===e){t[e]=o.label;break}}return t}handleSearch(t){let e=t.target.value.trim();if(this.searchQuery=e,this.searchTimeout&&clearTimeout(this.searchTimeout),e===""){this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions();return}if(!this.getSearchResultsUsing||typeof this.getSearchResultsUsing!="function"||!this.hasDynamicSearchResults){this.filterOptions(e);return}this.searchTimeout=setTimeout(async()=>{this.searchTimeout=null;let n=++this.activeSearchId;this.isSearching=!0;try{this.showLoadingState(!0);let o=await this.getSearchResultsUsing(e);if(n!==this.activeSearchId||!this.isOpen)return;let s=Array.isArray(o)?o:o&&Array.isArray(o.options)?o.options:[];this.options=s,this.populateLabelRepositoryFromOptions(s),this.hideLoadingState(),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.options.length===0&&this.showNoResultsMessage()}catch(o){n===this.activeSearchId&&(console.error("Error fetching search results:",o),this.hideLoadingState(),this.options=JSON.parse(JSON.stringify(this.originalOptions)),this.renderOptions())}finally{n===this.activeSearchId&&(this.isSearching=!1)}},this.searchDebounce)}showLoadingState(t=!1){this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList),this.hideLoadingState();let e=document.createElement("div");e.className="fi-select-input-message",e.textContent=t?this.searchingMessage:this.loadingMessage,this.dropdown.appendChild(e),this.isOpen&&(this.deferPositionDropdown(),this.statusRegion.textContent=e.textContent)}hideLoadingState(){let t=this.dropdown.querySelector(".fi-select-input-message");t&&(t.remove(),this.statusRegion.textContent="")}showNoOptionsMessage(){this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList),this.hideLoadingState();let t=document.createElement("div");t.className="fi-select-input-message",t.textContent=this.noOptionsMessage,this.dropdown.appendChild(t),this.isOpen&&(this.deferPositionDropdown(),this.statusRegion.textContent=this.noOptionsMessage)}showNoResultsMessage(){this.optionsList.parentNode===this.dropdown&&this.dropdown.removeChild(this.optionsList),this.hideLoadingState();let t=document.createElement("div");t.className="fi-select-input-message",t.textContent=this.noSearchResultsMessage,this.dropdown.appendChild(t),this.isOpen&&(this.deferPositionDropdown(),this.statusRegion.textContent=this.noSearchResultsMessage)}showMaxItemsMessage(){this.hideMaxItemsMessage(),this.maxItemsMessageElement=document.createElement("div"),this.maxItemsMessageElement.className="fi-select-input-max-items-message",this.maxItemsMessageElement.textContent=this.maxItemsMessage,this.optionsList.parentNode===this.dropdown?this.dropdown.insertBefore(this.maxItemsMessageElement,this.optionsList):this.dropdown.appendChild(this.maxItemsMessageElement),this.deferPositionDropdown(),this.statusRegion.textContent=this.maxItemsMessage}hideMaxItemsMessage(){this.maxItemsMessageElement&&(this.maxItemsMessageElement.remove(),this.maxItemsMessageElement=null,this.statusRegion.textContent===this.maxItemsMessage&&(this.statusRegion.textContent=""))}filterOptions(t){let e=this.searchableOptionFields.includes("label"),n=this.searchableOptionFields.includes("value");t=t.toLowerCase();let o=[];for(let s of this.originalOptions)if(s.options&&Array.isArray(s.options)){let r=s.options.filter(a=>e&&a.label.toLowerCase().includes(t)||n&&String(a.value).toLowerCase().includes(t));r.length>0&&o.push({label:s.label,options:r})}else(e&&s.label.toLowerCase().includes(t)||n&&String(s.value).toLowerCase().includes(t))&&o.push(s);this.options=o,this.renderOptions(),this.options.length===0&&this.showNoResultsMessage(),this.isOpen&&this.positionDropdown()}selectOption(t){if(this.isDisabled)return;if(!this.isMultiple){this.state=t,this.updateSelectedDisplay(),this.renderOptions(),this.closeDropdown(),this.selectButton.focus(),this.onStateChange(this.state);return}let e=Array.isArray(this.state)?[...this.state]:[];if(e.includes(t)){let o=this.selectedDisplay.querySelector(`[data-value="${t}"]`);if(I(o)){let s=o.parentElement;I(s)&&s.children.length===1?(e=e.filter(r=>r!==t),this.state=e,this.updateSelectedDisplay()):(o.remove(),e=e.filter(r=>r!==t),this.state=e)}else e=e.filter(s=>s!==t),this.state=e,this.updateSelectedDisplay();this.hideMaxItemsMessage(),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.maintainFocusInMultipleMode(),this.onStateChange(this.state);return}if(this.maxItems&&e.length>=this.maxItems){this.maxItemsMessage&&this.showMaxItemsMessage();return}this.hideMaxItemsMessage(),e.push(t),this.state=e;let n=this.selectedDisplay.querySelector(".fi-select-input-value-badges-ctn");bt(n)?this.updateSelectedDisplay():this.addSingleBadge(t,n),this.renderOptions(),this.isOpen&&this.deferPositionDropdown(),this.maintainFocusInMultipleMode(),this.onStateChange(this.state)}async addSingleBadge(t,e){let n=this.labelRepository[t];if(bt(n)&&(n=this.getSelectedOptionLabel(t),I(n)&&(this.labelRepository[t]=n)),bt(n)&&this.getOptionLabelsUsing)try{let s=await this.getOptionLabelsUsing();for(let r of s)if(I(r)&&r.value===t&&r.label!==void 0){n=r.label,this.labelRepository[t]=n;break}}catch(s){console.error("Error fetching option label:",s)}bt(n)&&(n=t);let o=this.createBadgeElement(t,n);e.appendChild(o)}maintainFocusInMultipleMode(){if(this.isSearchable&&this.searchInput){this.searchInput.focus();return}let t=this.getVisibleOptions();if(t.length!==0){if(this.selectedIndex=-1,Array.isArray(this.state)&&this.state.length>0){for(let e=0;e<t.length;e++)if(this.state.includes(t[e].getAttribute("data-value"))){this.selectedIndex=e;break}}this.selectedIndex===-1&&(this.selectedIndex=0),t[this.selectedIndex].classList.add("fi-selected"),t[this.selectedIndex].focus()}}disable(){this.isDisabled||(this.isDisabled=!0,this.applyDisabledState(),this.isOpen&&this.closeDropdown())}enable(){this.isDisabled&&(this.isDisabled=!1,this.applyDisabledState())}applyDisabledState(){if(this.isDisabled){if(this.selectButton.setAttribute("disabled","disabled"),this.selectButton.setAttribute("aria-disabled","true"),this.selectButton.classList.add("fi-disabled"),this.isMultiple&&this.container.querySelectorAll(".fi-select-input-badge-remove").forEach(e=>{e.setAttribute("disabled","disabled"),e.classList.add("fi-disabled")}),!this.isMultiple&&this.canSelectPlaceholder){let t=this.container.querySelector(".fi-select-input-value-remove-btn");t&&(t.setAttribute("disabled","disabled"),t.classList.add("fi-disabled"))}this.isSearchable&&this.searchInput&&(this.searchInput.setAttribute("disabled","disabled"),this.searchInput.classList.add("fi-disabled"))}else{if(this.selectButton.removeAttribute("disabled"),this.selectButton.removeAttribute("aria-disabled"),this.selectButton.classList.remove("fi-disabled"),this.isMultiple&&this.container.querySelectorAll(".fi-select-input-badge-remove").forEach(e=>{e.removeAttribute("disabled"),e.classList.remove("fi-disabled")}),!this.isMultiple&&this.canSelectPlaceholder){let t=this.container.querySelector(".fi-select-input-value-remove-btn");t&&(t.removeAttribute("disabled"),t.classList.add("fi-disabled"))}this.isSearchable&&this.searchInput&&(this.searchInput.removeAttribute("disabled"),this.searchInput.classList.remove("fi-disabled"))}}destroy(){this.selectButton&&this.buttonClickListener&&this.selectButton.removeEventListener("click",this.buttonClickListener),this.documentClickListener&&document.removeEventListener("click",this.documentClickListener),this.selectButton&&this.buttonKeydownListener&&this.selectButton.removeEventListener("keydown",this.buttonKeydownListener),this.dropdown&&this.dropdownKeydownListener&&this.dropdown.removeEventListener("keydown",this.dropdownKeydownListener),this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null),this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener,!0),this.scrollListener=null),this.refreshOptionLabelListener&&window.removeEventListener("filament-forms::select.refreshSelectedOptionLabel",this.refreshOptionLabelListener),this.isOpen&&this.closeDropdown(),this.searchTimeout&&(clearTimeout(this.searchTimeout),this.searchTimeout=null),this.container&&this.container.remove()}};function Gn({canOptionLabelsWrap:i,canSelectPlaceholder:t,getOptionLabelUsing:e,getOptionLabelsUsing:n,getOptionsUsing:o,getSearchResultsUsing:s,hasDynamicOptions:r,hasDynamicSearchResults:a,hasInitialNoOptionsMessage:l,id:c,initialOptionLabel:h,initialOptionLabels:d,initialState:f,isAutofocused:p,isDisabled:g,isHtmlAllowed:m,isMultiple:S,isReorderable:D,isSearchable:w,livewireId:A,loadingMessage:O,maxItems:_,maxItemsMessage:C,noOptionsMessage:q,noSearchResultsMessage:J,options:R,optionsLimit:$,placeholder:X,position:et,searchDebounce:H,searchingMessage:B,searchPrompt:Q,searchableOptionFields:F,state:W,statePath:P}){return{select:null,state:W,init(){this.select=new De({canOptionLabelsWrap:i,canSelectPlaceholder:t,element:this.$refs.select,getOptionLabelUsing:e,getOptionLabelsUsing:n,getOptionsUsing:o,getSearchResultsUsing:s,hasDynamicOptions:r,hasDynamicSearchResults:a,hasInitialNoOptionsMessage:l,id:c,initialOptionLabel:h,initialOptionLabels:d,initialState:f,isAutofocused:p,isDisabled:g,isHtmlAllowed:m,isMultiple:S,isReorderable:D,isSearchable:w,livewireId:A,loadingMessage:O,maxItems:_,maxItemsMessage:C,noOptionsMessage:q,noSearchResultsMessage:J,onStateChange:V=>{this.state=V},options:R,optionsLimit:$,placeholder:X,position:et,searchableOptionFields:F,searchDebounce:H,searchingMessage:B,searchPrompt:Q,state:this.state,statePath:P}),this.$watch("state",V=>{this.$nextTick(()=>{this.select&&this.select.state!==V&&(this.select.state=V,this.select.updateSelectedDisplay(),this.select.renderOptions())})})},destroy(){this.select&&(this.select.destroy(),this.select=null)}}}export{Gn as default};
/*! Bundled license information:
sortablejs/modular/sortable.esm.js:
(**!
* Sortable 1.15.7
* @author RubaXa <trash@rubaxa.org>
* @author owenm <owen23355@gmail.com>
* @license MIT
*)
*/