Build & Deploy / build (push) Successful in 18s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 lines
22 KiB
JavaScript
2 lines
22 KiB
JavaScript
(()=>{var N=Math.min,k=Math.max,H=Math.round,_=Math.floor,O=e=>({x:e,y:e});function Z(e,t,o){return k(e,N(t,o))}function j(e,t){return typeof e=="function"?e(t):e}function Y(e){return e.split("-")[0]}function ee(e){return e.split("-")[1]}function te(e){return e==="x"?"y":"x"}function re(e){return e==="y"?"height":"width"}function z(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function le(e){return te(z(e))}function Fe(e){return{top:0,right:0,bottom:0,left:0,...e}}function ce(e){return typeof e!="number"?Fe(e):{top:e,right:e,bottom:e,left:e}}function P(e){let{x:t,y:o,width:n,height:r}=e;return{width:n,height:r,top:o,left:t,right:t+n,bottom:o+r,x:t,y:o}}function ae(e,t,o){let{reference:n,floating:r}=e,l=z(t),i=le(t),s=re(i),c=Y(t),a=l==="y",d=n.x+n.width/2-r.width/2,u=n.y+n.height/2-r.height/2,h=n[s]/2-r[s]/2,f;switch(c){case"top":f={x:d,y:n.y-r.height};break;case"bottom":f={x:d,y:n.y+n.height};break;case"right":f={x:n.x+n.width,y:u};break;case"left":f={x:n.x-r.width,y:u};break;default:f={x:n.x,y:n.y}}switch(ee(t)){case"start":f[i]-=h*(o&&a?-1:1);break;case"end":f[i]+=h*(o&&a?-1:1);break}return f}async function fe(e,t){var o;t===void 0&&(t={});let{x:n,y:r,platform:l,rects:i,elements:s,strategy:c}=e,{boundary:a="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:f=0}=j(t,e),m=ce(f),w=s[h?u==="floating"?"reference":"floating":u],g=P(await l.getClippingRect({element:(o=await(l.isElement==null?void 0:l.isElement(w)))==null||o?w:w.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(s.floating)),boundary:a,rootBoundary:d,strategy:c})),x=u==="floating"?{x:n,y:r,width:i.floating.width,height:i.floating.height}:i.reference,y=await(l.getOffsetParent==null?void 0:l.getOffsetParent(s.floating)),b=await(l.isElement==null?void 0:l.isElement(y))?await(l.getScale==null?void 0:l.getScale(y))||{x:1,y:1}:{x:1,y:1},L=P(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:y,strategy:c}):x);return{top:(g.top-L.top+m.top)/b.y,bottom:(L.bottom-g.bottom+m.bottom)/b.y,left:(g.left-L.left+m.left)/b.x,right:(L.right-g.right+m.right)/b.x}}var Me=50,de=async(e,t,o)=>{let{placement:n="bottom",strategy:r="absolute",middleware:l=[],platform:i}=o,s=i.detectOverflow?i:{...i,detectOverflow:fe},c=await(i.isRTL==null?void 0:i.isRTL(t)),a=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:u}=ae(a,n,c),h=n,f=0,m={};for(let p=0;p<l.length;p++){let w=l[p];if(!w)continue;let{name:g,fn:x}=w,{x:y,y:b,data:L,reset:S}=await x({x:d,y:u,initialPlacement:n,placement:h,strategy:r,middlewareData:m,rects:a,platform:s,elements:{reference:e,floating:t}});d=y??d,u=b??u,m[g]={...m[g],...L},S&&f<Me&&(f++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(a=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):S.rects),{x:d,y:u}=ae(a,h,c)),p=-1)}return{x:d,y:u,placement:h,strategy:r,middlewareData:m}};var $e=new Set(["left","top"]);async function Ne(e,t){let{placement:o,platform:n,elements:r}=e,l=await(n.isRTL==null?void 0:n.isRTL(r.floating)),i=Y(o),s=ee(o),c=z(o)==="y",a=$e.has(i)?-1:1,d=l&&c?-1:1,u=j(t,e),{mainAxis:h,crossAxis:f,alignmentAxis:m}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&typeof m=="number"&&(f=s==="end"?m*-1:m),c?{x:f*d,y:h*a}:{x:h*a,y:f*d}}var ue=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var o,n;let{x:r,y:l,placement:i,middlewareData:s}=t,c=await Ne(t,e);return i===((o=s.offset)==null?void 0:o.placement)&&(n=s.arrow)!=null&&n.alignmentOffset?{}:{x:r+c.x,y:l+c.y,data:{...c,placement:i}}}}},he=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:o,y:n,placement:r,platform:l}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:g=>{let{x,y}=g;return{x,y}}},...a}=j(e,t),d={x:o,y:n},u=await l.detectOverflow(t,a),h=z(Y(r)),f=te(h),m=d[f],p=d[h];if(i){let g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",y=m+u[g],b=m-u[x];m=Z(y,m,b)}if(s){let g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",y=p+u[g],b=p-u[x];p=Z(y,p,b)}let w=c.fn({...t,[f]:m,[h]:p});return{...w,data:{x:w.x-o,y:w.y-n,enabled:{[f]:i,[h]:s}}}}}};function G(){return typeof window<"u"}function F(e){return ge(e)?(e.nodeName||"").toLowerCase():"#document"}function v(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function A(e){var t;return(t=(ge(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ge(e){return G()?e instanceof Node||e instanceof v(e).Node:!1}function R(e){return G()?e instanceof Element||e instanceof v(e).Element:!1}function T(e){return G()?e instanceof HTMLElement||e instanceof v(e).HTMLElement:!1}function me(e){return!G()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof v(e).ShadowRoot}function B(e){let{overflow:t,overflowX:o,overflowY:n,display:r}=C(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+o)&&r!=="inline"&&r!=="contents"}function pe(e){return/^(table|td|th)$/.test(F(e))}function I(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var Ve=/transform|translate|scale|rotate|perspective|filter/,Be=/paint|layout|strict|content/,D=e=>!!e&&e!=="none",ne;function J(e){let t=R(e)?C(e):e;return D(t.transform)||D(t.translate)||D(t.scale)||D(t.rotate)||D(t.perspective)||!K()&&(D(t.backdropFilter)||D(t.filter))||Ve.test(t.willChange||"")||Be.test(t.contain||"")}function we(e){let t=E(e);for(;T(t)&&!M(t);){if(J(t))return t;if(I(t))return null;t=E(t)}return null}function K(){return ne==null&&(ne=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ne}function M(e){return/^(html|body|#document)$/.test(F(e))}function C(e){return v(e).getComputedStyle(e)}function U(e){return R(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function E(e){if(F(e)==="html")return e;let t=e.assignedSlot||e.parentNode||me(e)&&e.host||A(e);return me(t)?t.host:t}function xe(e){let t=E(e);return M(t)?e.ownerDocument?e.ownerDocument.body:e.body:T(t)&&B(t)?t:xe(t)}function V(e,t,o){var n;t===void 0&&(t=[]),o===void 0&&(o=!0);let r=xe(e),l=r===((n=e.ownerDocument)==null?void 0:n.body),i=v(r);if(l){let s=q(i);return t.concat(i,i.visualViewport||[],B(r)?r:[],s&&o?V(s):[])}else return t.concat(r,V(r,[],o))}function q(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Re(e){let t=C(e),o=parseFloat(t.width)||0,n=parseFloat(t.height)||0,r=T(e),l=r?e.offsetWidth:o,i=r?e.offsetHeight:n,s=H(o)!==l||H(n)!==i;return s&&(o=l,n=i),{width:o,height:n,$:s}}function oe(e){return R(e)?e:e.contextElement}function W(e){let t=oe(e);if(!T(t))return O(1);let o=t.getBoundingClientRect(),{width:n,height:r,$:l}=Re(t),i=(l?H(o.width):o.width)/n,s=(l?H(o.height):o.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}var We=O(0);function Ce(e){let t=v(e);return!K()||!t.visualViewport?We:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function He(e,t,o){return t===void 0&&(t=!1),!o||t&&o!==v(e)?!1:t}function $(e,t,o,n){t===void 0&&(t=!1),o===void 0&&(o=!1);let r=e.getBoundingClientRect(),l=oe(e),i=O(1);t&&(n?R(n)&&(i=W(n)):i=W(e));let s=He(l,o,n)?Ce(l):O(0),c=(r.left+s.x)/i.x,a=(r.top+s.y)/i.y,d=r.width/i.x,u=r.height/i.y;if(l){let h=v(l),f=n&&R(n)?v(n):n,m=h,p=q(m);for(;p&&n&&f!==m;){let w=W(p),g=p.getBoundingClientRect(),x=C(p),y=g.left+(p.clientLeft+parseFloat(x.paddingLeft))*w.x,b=g.top+(p.clientTop+parseFloat(x.paddingTop))*w.y;c*=w.x,a*=w.y,d*=w.x,u*=w.y,c+=y,a+=b,m=v(p),p=q(m)}}return P({width:d,height:u,x:c,y:a})}function Q(e,t){let o=U(e).scrollLeft;return t?t.left+o:$(A(e)).left+o}function Oe(e,t){let o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-Q(e,o),r=o.top+t.scrollTop;return{x:n,y:r}}function _e(e){let{elements:t,rect:o,offsetParent:n,strategy:r}=e,l=r==="fixed",i=A(n),s=t?I(t.floating):!1;if(n===i||s&&l)return o;let c={scrollLeft:0,scrollTop:0},a=O(1),d=O(0),u=T(n);if((u||!u&&!l)&&((F(n)!=="body"||B(i))&&(c=U(n)),u)){let f=$(n);a=W(n),d.x=f.x+n.clientLeft,d.y=f.y+n.clientTop}let h=i&&!u&&!l?Oe(i,c):O(0);return{width:o.width*a.x,height:o.height*a.y,x:o.x*a.x-c.scrollLeft*a.x+d.x+h.x,y:o.y*a.y-c.scrollTop*a.y+d.y+h.y}}function ze(e){return Array.from(e.getClientRects())}function Ie(e){let t=A(e),o=U(e),n=e.ownerDocument.body,r=k(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),l=k(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight),i=-o.scrollLeft+Q(e),s=-o.scrollTop;return C(n).direction==="rtl"&&(i+=k(t.clientWidth,n.clientWidth)-r),{width:r,height:l,x:i,y:s}}var ye=25;function Ue(e,t){let o=v(e),n=A(e),r=o.visualViewport,l=n.clientWidth,i=n.clientHeight,s=0,c=0;if(r){l=r.width,i=r.height;let d=K();(!d||d&&t==="fixed")&&(s=r.offsetLeft,c=r.offsetTop)}let a=Q(n);if(a<=0){let d=n.ownerDocument,u=d.body,h=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(n.clientWidth-u.clientWidth-f);m<=ye&&(l-=m)}else a<=ye&&(l+=a);return{width:l,height:i,x:s,y:c}}function Xe(e,t){let o=$(e,!0,t==="fixed"),n=o.top+e.clientTop,r=o.left+e.clientLeft,l=T(e)?W(e):O(1),i=e.clientWidth*l.x,s=e.clientHeight*l.y,c=r*l.x,a=n*l.y;return{width:i,height:s,x:c,y:a}}function be(e,t,o){let n;if(t==="viewport")n=Ue(e,o);else if(t==="document")n=Ie(A(e));else if(R(t))n=Xe(t,o);else{let r=Ce(e);n={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return P(n)}function Ae(e,t){let o=E(e);return o===t||!R(o)||M(o)?!1:C(o).position==="fixed"||Ae(o,t)}function je(e,t){let o=t.get(e);if(o)return o;let n=V(e,[],!1).filter(s=>R(s)&&F(s)!=="body"),r=null,l=C(e).position==="fixed",i=l?E(e):e;for(;R(i)&&!M(i);){let s=C(i),c=J(i);!c&&s.position==="fixed"&&(r=null),(l?!c&&!r:!c&&s.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||B(i)&&!c&&Ae(e,i))?n=n.filter(d=>d!==i):r=s,i=E(i)}return t.set(e,n),n}function Ye(e){let{element:t,boundary:o,rootBoundary:n,strategy:r}=e,i=[...o==="clippingAncestors"?I(t)?[]:je(t,this._c):[].concat(o),n],s=be(t,i[0],r),c=s.top,a=s.right,d=s.bottom,u=s.left;for(let h=1;h<i.length;h++){let f=be(t,i[h],r);c=k(f.top,c),a=N(f.right,a),d=N(f.bottom,d),u=k(f.left,u)}return{width:a-u,height:d-c,x:u,y:c}}function Ge(e){let{width:t,height:o}=Re(e);return{width:t,height:o}}function Je(e,t,o){let n=T(t),r=A(t),l=o==="fixed",i=$(e,!0,l,t),s={scrollLeft:0,scrollTop:0},c=O(0);function a(){c.x=Q(r)}if(n||!n&&!l)if((F(t)!=="body"||B(r))&&(s=U(t)),n){let f=$(t,!0,l,t);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}else r&&a();l&&!n&&r&&a();let d=r&&!n&&!l?Oe(r,s):O(0),u=i.left+s.scrollLeft-c.x-d.x,h=i.top+s.scrollTop-c.y-d.y;return{x:u,y:h,width:i.width,height:i.height}}function ie(e){return C(e).position==="static"}function ve(e,t){if(!T(e)||C(e).position==="fixed")return null;if(t)return t(e);let o=e.offsetParent;return A(e)===o&&(o=o.ownerDocument.body),o}function Se(e,t){let o=v(e);if(I(e))return o;if(!T(e)){let r=E(e);for(;r&&!M(r);){if(R(r)&&!ie(r))return r;r=E(r)}return o}let n=ve(e,t);for(;n&&pe(n)&&ie(n);)n=ve(n,t);return n&&M(n)&&ie(n)&&!J(n)?o:n||we(e)||o}var Ke=async function(e){let t=this.getOffsetParent||Se,o=this.getDimensions,n=await o(e.floating);return{reference:Je(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function qe(e){return C(e).direction==="rtl"}var Qe={convertOffsetParentRelativeRectToViewportRelativeRect:_e,getDocumentElement:A,getClippingRect:Ye,getOffsetParent:Se,getElementRects:Ke,getClientRects:ze,getDimensions:Ge,getScale:W,isElement:R,isRTL:qe};function Te(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ze(e,t){let o=null,n,r=A(e);function l(){var s;clearTimeout(n),(s=o)==null||s.disconnect(),o=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),l();let a=e.getBoundingClientRect(),{left:d,top:u,width:h,height:f}=a;if(s||t(),!h||!f)return;let m=_(u),p=_(r.clientWidth-(d+h)),w=_(r.clientHeight-(u+f)),g=_(d),y={rootMargin:-m+"px "+-p+"px "+-w+"px "+-g+"px",threshold:k(0,N(1,c))||1},b=!0;function L(S){let X=S[0].intersectionRatio;if(X!==c){if(!b)return i();X?i(!1,X):n=setTimeout(()=>{i(!1,1e-7)},1e3)}X===1&&!Te(a,e.getBoundingClientRect())&&i(),b=!1}try{o=new IntersectionObserver(L,{...y,root:r.ownerDocument})}catch{o=new IntersectionObserver(L,y)}o.observe(e)}return i(!0),l}function Le(e,t,o,n){n===void 0&&(n={});let{ancestorScroll:r=!0,ancestorResize:l=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,a=oe(e),d=r||l?[...a?V(a):[],...t?V(t):[]]:[];d.forEach(g=>{r&&g.addEventListener("scroll",o,{passive:!0}),l&&g.addEventListener("resize",o)});let u=a&&s?Ze(a,o):null,h=-1,f=null;i&&(f=new ResizeObserver(g=>{let[x]=g;x&&x.target===a&&f&&t&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(t)})),o()}),a&&!c&&f.observe(a),t&&f.observe(t));let m,p=c?$(e):null;c&&w();function w(){let g=$(e);p&&!Te(p,g)&&o(),p=g,m=requestAnimationFrame(w)}return o(),()=>{var g;d.forEach(x=>{r&&x.removeEventListener("scroll",o),l&&x.removeEventListener("resize",o)}),u?.(),(g=f)==null||g.disconnect(),f=null,c&&cancelAnimationFrame(m)}}var ke=ue;var Ee=he;var Pe=(e,t,o)=>{let n=new Map,r={platform:Qe,...o},l={...r.platform,_c:n};return de(e,t,{...r,platform:l})};var De=({areGroupsCollapsedByDefault:e,canTrackDeselectedRecords:t,currentSelectionLivewireProperty:o,maxSelectableRecords:n,selectsCurrentPageOnly:r,$wire:l})=>({areFiltersOpen:!1,checkboxClickController:null,groupVisibility:[],isLoading:!1,selectedRecords:new Set,deselectedRecords:new Set,isTrackingDeselectedRecords:!1,shouldCheckUniqueSelection:!0,lastCheckedRecord:null,livewireId:null,entangledSelectedRecords:o?l.$entangle(o):null,cleanUpFiltersDropdown:null,unsubscribeLivewireHook:null,init(){this.livewireId=this.$root.closest("[wire\\:id]")?.attributes["wire:id"].value,l.$on("deselectAllTableRecords",()=>this.deselectAllRecords()),l.$on("scrollToTopOfTable",()=>this.$root.scrollIntoView({block:"start",inline:"nearest"})),o&&(n!==1?this.selectedRecords=new Set(this.entangledSelectedRecords):this.selectedRecords=new Set(this.entangledSelectedRecords?[this.entangledSelectedRecords]:[])),this.$nextTick(()=>this.watchForCheckboxClicks()),this.unsubscribeLivewireHook=Livewire.hook("element.init",({component:i})=>{i.id===this.livewireId&&this.watchForCheckboxClicks()})},mountAction(...i){l.set("isTrackingDeselectedTableRecords",this.isTrackingDeselectedRecords,!1),l.set("selectedTableRecords",[...this.selectedRecords],!1),l.set("deselectedTableRecords",[...this.deselectedRecords],!1),l.mountAction(...i)},toggleSelectRecordsOnPage(){let i=this.getRecordsOnPage();if(this.areRecordsSelected(i)){this.deselectRecords(i);return}this.selectRecords(i)},toggleSelectRecords(i){this.areRecordsSelected(i)?this.deselectRecords(i):this.selectRecords(i)},getSelectedRecordsCount(){return this.isTrackingDeselectedRecords?(this.$refs.allSelectableRecordsCount?.value??this.deselectedRecords.size)-this.deselectedRecords.size:this.selectedRecords.size},getRecordsOnPage(){let i=[];for(let s of this.$root?.getElementsByClassName("fi-ta-record-checkbox")??[])i.push(s.value);return i},selectRecords(i){n===1&&(this.deselectAllRecords(),i=i.slice(0,1));for(let s of i)if(!this.isRecordSelected(s)){if(this.isTrackingDeselectedRecords){this.deselectedRecords.delete(s);continue}this.selectedRecords.add(s)}this.updatedSelectedRecords()},deselectRecords(i){for(let s of i){if(this.isTrackingDeselectedRecords){this.deselectedRecords.add(s);continue}this.selectedRecords.delete(s)}this.updatedSelectedRecords()},updatedSelectedRecords(){if(n!==1){this.entangledSelectedRecords=[...this.selectedRecords];return}this.entangledSelectedRecords=[...this.selectedRecords][0]??null},toggleSelectedRecord(i){if(this.isRecordSelected(i)){this.deselectRecords([i]);return}this.selectRecords([i])},async selectAllRecords(){if(!t||r){this.isLoading=!0,this.selectedRecords=new Set(await l.getAllSelectableTableRecordKeys()),this.updatedSelectedRecords(),this.isLoading=!1;return}this.isTrackingDeselectedRecords=!0,this.selectedRecords=new Set,this.deselectedRecords=new Set,this.updatedSelectedRecords()},canSelectAllRecords(){if(r){let c=this.getRecordsOnPage();return!this.areRecordsSelected(c)&&this.areRecordsToggleable(c)}let i=parseInt(this.$refs.allSelectableRecordsCount?.value);if(!i)return!1;let s=this.getSelectedRecordsCount();return i===s?!1:n===null||i<=n},deselectAllRecords(){this.isTrackingDeselectedRecords=!1,this.selectedRecords=new Set,this.deselectedRecords=new Set,this.updatedSelectedRecords()},isRecordSelected(i){return this.isTrackingDeselectedRecords?!this.deselectedRecords.has(i):this.selectedRecords.has(i)},areRecordsSelected(i){return i.every(s=>this.isRecordSelected(s))},areRecordsPartiallySelected(i){if(i.length===0)return!1;let s=i.filter(c=>this.isRecordSelected(c)).length;return s>0&&s<i.length},areRecordsToggleable(i){if(n===null||n===1)return!0;let s=i.filter(c=>this.isRecordSelected(c));return s.length===i.length?!0:this.getSelectedRecordsCount()+(i.length-s.length)<=n},toggleCollapseGroup(i){this.isGroupCollapsed(i)?e?this.groupVisibility.push(i):this.groupVisibility.splice(this.groupVisibility.indexOf(i),1):e?this.groupVisibility.splice(this.groupVisibility.indexOf(i),1):this.groupVisibility.push(i)},isGroupCollapsed(i){return e?!this.groupVisibility.includes(i):this.groupVisibility.includes(i)},resetCollapsedGroups(){this.groupVisibility=[]},watchForCheckboxClicks(){this.checkboxClickController&&this.checkboxClickController.abort(),this.checkboxClickController=new AbortController;let{signal:i}=this.checkboxClickController;this.$root?.addEventListener("click",s=>s.target?.matches(".fi-ta-record-checkbox")&&this.handleCheckboxClick(s,s.target),{signal:i})},handleCheckboxClick(i,s){if(!this.lastChecked){this.lastChecked=s;return}if(i.shiftKey){let c=Array.from(this.$root?.getElementsByClassName("fi-ta-record-checkbox")??[]);if(!c.includes(this.lastChecked)){this.lastChecked=s;return}let a=c.indexOf(this.lastChecked),d=c.indexOf(s),u=[a,d].sort((f,m)=>f-m),h=[];for(let f=u[0];f<=u[1];f++)h.push(c[f].value);if(s.checked){if(!this.areRecordsToggleable(h)){s.checked=!1,this.deselectRecords([s.value]);return}this.selectRecords(h)}else this.deselectRecords(h)}this.lastChecked=s},toggleFiltersDropdown(){if(this.areFiltersOpen=!this.areFiltersOpen,this.areFiltersOpen){let i=Le(this.$refs.filtersTriggerActionContainer,this.$refs.filtersContentContainer,async()=>{let{x:a,y:d}=await Pe(this.$refs.filtersTriggerActionContainer,this.$refs.filtersContentContainer,{placement:"bottom-end",middleware:[ke(8),Ee({padding:8})]});Object.assign(this.$refs.filtersContentContainer.style,{left:`${a}px`,top:`${d}px`})}),s=a=>{let d=this.$refs.filtersTriggerActionContainer,u=this.$refs.filtersContentContainer;u&&u.contains(a.target)||d&&d.contains(a.target)||(this.areFiltersOpen=!1,this.cleanUpFiltersDropdown&&(this.cleanUpFiltersDropdown(),this.cleanUpFiltersDropdown=null))};document.addEventListener("mousedown",s),document.addEventListener("touchstart",s,{passive:!0});let c=a=>{a.key==="Escape"&&s(a)};document.addEventListener("keydown",c),this.cleanUpFiltersDropdown=()=>{i(),document.removeEventListener("mousedown",s),document.removeEventListener("touchstart",s,{passive:!0}),document.removeEventListener("keydown",c)}}else this.cleanUpFiltersDropdown&&(this.cleanUpFiltersDropdown(),this.cleanUpFiltersDropdown=null)},destroy(){this.unsubscribeLivewireHook?.()}});function se({columns:e,isLive:t}){return{error:void 0,isLoading:!1,deferredColumns:[],columns:e,isLive:t,hasReordered:!1,init(){if(!this.columns||this.columns.length===0){this.columns=[];return}this.deferredColumns=JSON.parse(JSON.stringify(this.columns)),this.$watch("columns",()=>{this.resetDeferredColumns()})},get groupedColumns(){let o={};return this.deferredColumns.filter(n=>n.type==="group").forEach(n=>{o[n.name]=this.calculateGroupedColumns(n)}),o},calculateGroupedColumns(o){if((o?.columns?.filter(s=>!s.isHidden)??[]).length===0)return{hidden:!0,checked:!1,disabled:!1,indeterminate:!1};let r=o.columns.filter(s=>!s.isHidden&&s.isToggleable!==!1);if(r.length===0)return{checked:!0,disabled:!0,indeterminate:!1};let l=r.filter(s=>s.isToggled).length,i=o.columns.filter(s=>!s.isHidden&&s.isToggleable===!1);return l===0&&i.length>0?{checked:!0,disabled:!1,indeterminate:!0}:l===0?{checked:!1,disabled:!1,indeterminate:!1}:l===r.length?{checked:!0,disabled:!1,indeterminate:!1}:{checked:!0,disabled:!1,indeterminate:!0}},getColumn(o,n=null){return n?this.deferredColumns.find(l=>l.type==="group"&&l.name===n)?.columns?.find(l=>l.name===o):this.deferredColumns.find(r=>r.name===o)},toggleGroup(o){let n=this.deferredColumns.find(c=>c.type==="group"&&c.name===o);if(!n?.columns)return;let r=this.calculateGroupedColumns(n);if(r.disabled)return;let i=n.columns.filter(c=>c.isToggleable!==!1).some(c=>c.isToggled),s=r.indeterminate?!0:!i;n.columns.filter(c=>c.isToggleable!==!1).forEach(c=>{c.isToggled=s}),this.deferredColumns=[...this.deferredColumns],this.isLive&&this.applyTableColumnManager()},toggleColumn(o,n=null){let r=this.getColumn(o,n);!r||r.isToggleable===!1||(r.isToggled=!r.isToggled,this.deferredColumns=[...this.deferredColumns],this.isLive&&this.applyTableColumnManager())},reorderColumns(o){let n=o.map(r=>r.split("::"));this.reorderTopLevel(n),this.hasReordered=!0,this.isLive&&this.applyTableColumnManager()},reorderGroupColumns(o,n){let r=this.deferredColumns.find(s=>s.type==="group"&&s.name===n);if(!r)return;let l=o.map(s=>s.split("::")),i=[];l.forEach(([s,c])=>{let a=r.columns.find(d=>d.name===c);a&&i.push(a)}),r.columns=i,this.deferredColumns=[...this.deferredColumns],this.hasReordered=!0,this.isLive&&this.applyTableColumnManager()},reorderTopLevel(o){let n=this.deferredColumns,r=[];o.forEach(([l,i])=>{let s=n.find(c=>l==="group"?c.type==="group"&&c.name===i:l==="column"?c.type!=="group"&&c.name===i:!1);s&&r.push(s)}),this.deferredColumns=r},async applyTableColumnManager(){this.isLoading=!0;try{this.columns=JSON.parse(JSON.stringify(this.deferredColumns)),await this.$wire.call("applyTableColumnManager",this.columns,this.hasReordered),this.hasReordered=!1,this.error=void 0}catch(o){this.error="Failed to update column visibility",console.error("Table toggle columns error:",o)}finally{this.isLoading=!1}},resetDeferredColumns(){this.deferredColumns=JSON.parse(JSON.stringify(this.columns)),this.hasReordered=!1}}}document.addEventListener("alpine:init",()=>{window.Alpine.data("filamentTable",De),window.Alpine.data("filamentTableColumnManager",se)});})();
|