@lattice-php/lattice 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./chunks/subscriptions-BdHDnVA3.js","./chunks/react-SIfiwpqq.js","./chunks/jsx-runtime-CN5ucv1d.js","./chunks/use-effect-dispatcher-CiWYRvsF.js","./chunks/locale-CgtcxthU.js","./chunks/instance-t58Awajh.js","./chunks/timezone-BukvzD0d.js","./chunks/translatable-DLw4h3x8.js","./chunks/dist-DqlcM-vw.js","./chunks/chart-view-ZCTbih8A.js","./chunks/materialize-CWqnSEHR.js","./chunks/test-id-Dh3L6Gfh.js","./chunks/number-BvVKQqOG.js","./chunks/with-selector-zFUY-tQj.js","./chunks/date-picker-field-CCnkf4SC.js","./chunks/dist-CK9gk4iB.js","./chunks/time-picker-DSs9fDWe.js","./chunks/rich-editor-field-BtbU5XFS.js","./chunks/icon-button-DcP25cn4.js","./chunks/notifications-echo-uU87iJAV.js","./chunks/page-props-B4GewgLI.js","./chunks/shared-props-B_wT1GcG.js"])))=>i.map(i=>d[i]);
2
- import{i as e,t}from"./chunks/react-SIfiwpqq.js";import{a as n,n as r,o as i}from"./chunks/locale-CgtcxthU.js";import{n as a,t as o}from"./chunks/jsx-runtime-CN5ucv1d.js";import{a as s,c,d as l,f as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./chunks/use-effect-dispatcher-CiWYRvsF.js";import{n as x,t as S}from"./chunks/materialize-CWqnSEHR.js";import{a as C,o as w}from"./chunks/instance-t58Awajh.js";import{i as T,n as E,r as D}from"./chunks/timezone-BukvzD0d.js";import{t as O}from"./chunks/shared-props-B_wT1GcG.js";import{i as k,n as A,r as j,t as M}from"./chunks/test-id-Dh3L6Gfh.js";import{_ as N,b as P,g as F,h as I,i as L,n as ee,r as te,t as ne,v as R,y as re}from"./chunks/dist-CK9gk4iB.js";import{n as ie,t as z}from"./chunks/translatable-DLw4h3x8.js";import{$ as ae,A as oe,B as se,C as ce,D as le,E as ue,F as de,G as B,H as fe,I as pe,J as me,K as V,L as he,M as ge,N as _e,O as ve,P as ye,Q as be,R as xe,S as Se,T as Ce,U as H,V as we,W as Te,X as Ee,Y as De,Z as Oe,_ as ke,a as Ae,at as je,b as Me,c as Ne,ct as U,d as Pe,dt as W,et as Fe,f as Ie,g as Le,h as Re,i as ze,it as Be,j as Ve,k as He,l as Ue,lt as We,m as Ge,n as Ke,nt as qe,o as Je,ot as Ye,p as Xe,q as Ze,r as Qe,rt as $e,s as et,st as tt,t as nt,tt as rt,u as it,ut as at,v as ot,w as st,x as ct,y as lt,z as ut}from"./chunks/icon-button-DcP25cn4.js";import{a as dt,c as G,i as ft,l as pt,n as mt,o as ht,r as gt,s as _t,t as vt}from"./chunks/time-picker-DSs9fDWe.js";import{a as yt,i as bt,n as xt,o as St,r as Ct,t as wt}from"./chunks/number-BvVKQqOG.js";var Tt=`X-Lattice-Ref`,Et=new Map;function Dt(e){return Et.get(e)??e}function Ot(e,t){Et.set(e,t)}function kt(e){let t=Dt(e);return t?{[Tt]:t}:{}}function At(e=``,t={}){return{...r(),...kt(e),...t}}var jt=class extends Error{response;constructor(e){super(`HTTP ${e.status}`),this.response=e}};function Mt(){let e=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):``}var Nt=1e4,Pt=new Map,Ft=new Map;function It(e){return e===void 0||e===`GET`||e===`HEAD`?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`,"X-XSRF-TOKEN":Mt()}}var Lt=`/lattice/refs/refresh`;function Rt(e){Lt=e}var zt=new Map;async function Bt(e){let t=zt.get(e);if(t)return t;let n=Ht(Lt,{method:`POST`,body:JSON.stringify({ref:Dt(e)})}).then(t=>(Ot(e,t.ref),t.ref)).catch(()=>null).finally(()=>{zt.delete(e)});return zt.set(e,n),n}async function Vt(e,t={}){let{ref:n=``,headers:r,throwOnError:i=!0,method:a,...o}=t,s=a?.toUpperCase(),c=()=>fetch(e,{credentials:`same-origin`,...o,method:s,headers:At(n,{...It(s),...r})}),l=await c();if(n!==``&&l.status===403&&await Bt(n)!==null&&(l=await c()),i&&!l.ok)throw new jt(l);return l}async function Ht(e,t){return(await Vt(e,t)).json()}function Ut(e){return[e.source,e.audience,[...e.scopes].sort().join(` `)].join(``)}function Wt(e){Pt.delete(Ut(e))}async function Gt(e){let t=Ut(e),n=Pt.get(t);if(n&&n.expiresAt>Date.now()+Nt)return n.token;let r=Ft.get(t);if(r)return r;let i=Ht(e.tokenEndpoint,{method:`POST`,ref:e.ref,body:JSON.stringify({nodeId:e.nodeId,nodeType:e.nodeType,audience:e.audience,scopes:e.scopes})}).then(e=>(Pt.set(t,{token:e,expiresAt:Date.now()+Math.max(0,e.expiresIn)*1e3}),e)).finally(()=>{Ft.delete(t)});return Ft.set(t,i),i}function Kt(e){return e.status===401||e.status===403}async function qt(e,t,n){let{headers:i,...a}=t;return fetch(e,{...a,credentials:`omit`,headers:{Accept:`application/json`,...r(),...i,Authorization:`${n.tokenType} ${n.accessToken}`}})}async function Jt(e,t){let{remote:n,retryOnUnauthorized:r=!0,throwOnError:i=!0,...a}=t,o=await Gt(n),s=await qt(e,a,o);if(r&&Kt(s)&&(Wt(n),o=await Gt(n),s=await qt(e,a,o)),i&&!s.ok)throw new jt(s);return s}async function Yt(e,t){return(await Jt(e,t)).json()}var K=e(t(),1),Xt=`modulepreload`,Zt=function(e,t){return new URL(e,t).href},Qt={},$t=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Zt(t,n),t=s(t),t in Qt)return;Qt[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Xt,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},en=[`light`,`dark`,`system`],tn=new Set,nn=`system`;function rn(e){return en.some(t=>t===e)}var an=()=>typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches,on=(e,t,n=365)=>{if(typeof document>`u`)return;let r=n*24*60*60;document.cookie=`${e}=${t};path=/;max-age=${r};SameSite=Lax`},sn=()=>{if(typeof window>`u`)return`system`;let e=localStorage.getItem(`appearance`);return rn(e)?e:`system`},cn=e=>e===`dark`||e===`system`&&an(),ln=e=>{if(typeof document>`u`)return;let t=cn(e);document.documentElement.classList.toggle(`dark`,t),document.documentElement.style.colorScheme=t?`dark`:`light`},un=()=>tn.forEach(e=>e()),dn=()=>typeof window>`u`?null:window.matchMedia(`(prefers-color-scheme: dark)`),fn=()=>{ln(nn),un()};function pn(e){nn=e,localStorage.setItem(`appearance`,e),on(`appearance`,e),ln(e),un()}function mn(){typeof window>`u`||(localStorage.getItem(`appearance`)||(localStorage.setItem(`appearance`,`system`),on(`appearance`,`system`)),nn=sn(),ln(nn),dn()?.addEventListener(`change`,fn))}function q(e){return{component:e,mode:`eager`}}function hn(e){return e}function gn(...e){return e.reduce((e,t)=>({components:{...e.components,...t.components},columns:{...e.columns,...t.columns},effects:{...e.effects,...t.effects}}),{components:{},columns:{},effects:{}})}function _n(e,...t){let n=gn(...t);return{components:{...e.components,...n.components},columns:{...e.columns,...n.columns},effects:{...e.effects,...n.effects}}}function vn(e,t,n={}){let{enabled:r=!0}=n,i=(0,K.useRef)(t);i.current=t,(0,K.useEffect)(()=>{if(!r||typeof window>`u`)return;let t=e=>i.current(e);return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[e,r])}function yn({preserveScroll:e=!0,preserveState:t=!0}){return vn(i.localeChange,n=>{let r=n.detail?.locale;typeof r==`string`&&r!==``&&p.visit(window.location.href,{preserveScroll:e,preserveState:t})}),null}function bn(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`):[]}function xn(e,t){return e.key??e.id??`${e.type}-${t}`}var Sn=(0,K.createContext)(!1);function Cn(){return(0,K.useContext)(Sn)}var J=o();function wn(){return(0,J.jsxs)(`svg`,{"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:[(0,J.jsx)(`rect`,{height:`18`,rx:`2`,strokeDasharray:`4 3`,width:`18`,x:`3`,y:`3`}),(0,J.jsx)(`path`,{d:`M12 8v4`}),(0,J.jsx)(`path`,{d:`M12 16h.01`})]})}function Tn({node:e}){e.type;let t=`Missing component: ${e.type}`;return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 align-middle text-lt-muted-fg`,"data-lattice-missing-component":e.type,title:t,children:[(0,J.jsx)(wn,{}),(0,J.jsx)(`span`,{className:`sr-only`,children:t})]})}function Y({nodes:e}){return e.map((e,t)=>(0,J.jsx)(Dn,{node:e},xn(e,t)))}function En({node:e}){return(0,J.jsx)(Dn,{node:e})}var Dn=(0,K.memo)(function({node:e}){let t=Cn(),n=v()[e.type];if(t&&e.props?.hideWhenCollapsed===!0)return null;if(!n)return(0,J.jsx)(Tn,{node:e});let r=n.component,i=e.schema?.length?(0,J.jsx)(Y,{nodes:e.schema}):null,a=(0,J.jsx)(r,{node:e,children:i});if(n.mode===`lazy`){let t=n.fallback;return(0,J.jsx)(K.Suspense,{fallback:t?(0,J.jsx)(t,{node:e,children:null}):null,children:a})}return a}),On=[`primary`,`secondary`,`success`,`info`,`warning`,`danger`];function kn(e){return On.some(t=>t===e)}function An(e){if(typeof e!=`object`||!e)return null;let t=e,n=t.message,r=typeof n==`string`||z(n)?n:null;return r===null||r===``?null:{action:t.action??null,dismissible:t.dismissible!==!1,duration:typeof t.duration==`number`?t.duration:null,message:r,persistent:t.persistent===!0,variant:kn(t.variant)?t.variant:`success`}}function jn(e){let t=t=>{let n=An(t.detail);n&&e(n)};return window.addEventListener(i.toast,t),()=>window.removeEventListener(i.toast,t)}function Mn(e){if(typeof e!=`object`||!e)return null;let t=e,n=t.message,r=typeof n==`string`||z(n)?n:null;return r===null||r===``?null:{action:t.action??null,dismissible:t.dismissible!==!1,message:r,title:typeof t.title==`string`||z(t.title)?t.title:null,unique:typeof t.unique==`string`?t.unique:null,variant:kn(t.variant)?t.variant:`info`}}function Nn(e){let t=t=>{let n=Mn(t.detail);n&&e(n)};return window.addEventListener(i.callout,t),()=>window.removeEventListener(i.callout,t)}function Pn(e){let t=t=>{let n=t.detail?.unique;typeof n==`string`&&e(n)};return window.addEventListener(i.retractCallout,t),()=>window.removeEventListener(i.retractCallout,t)}var Fn=Object.defineProperty,X=(e,t)=>Fn(e,`name`,{value:t,configurable:!0});function In(e){let t=e+`CollectionProvider`,[n,r]=at(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=X(e=>{let{scope:t,children:n}=e,r=K.useRef(null),a=K.useRef(new Map).current;return(0,J.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=I(s),l=K.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=F(t,i.collectionRef);return(0,J.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=I(u),p=K.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=K.useRef(null),s=F(t,o),c=a(u,n);return K.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,J.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return K.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return X(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}X(In,`createCollection`);var Ln=new WeakMap,Rn=class e extends Map{static{X(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Ln.set(this,!0)}set(e,t){return Ln.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=Vn(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=zn(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=zn(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return zn(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function zn(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Bn(e,t);return n===-1?void 0:e[n]}X(zn,`at`);function Bn(e,t){let n=e.length,r=Vn(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}X(Bn,`toSafeIndex`);function Vn(e){return e!==e||e===0?0:Math.trunc(e)}X(Vn,`toSafeInteger`);function Hn(e){let t=e+`CollectionProvider`,[n,r]=at(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Rn,setItemMap:X(()=>void 0,`setItemMap`)}),o=X(({state:e,...t})=>e?(0,J.jsx)(c,{...t,state:e}):(0,J.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=X(e=>{let t=h();return(0,J.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=X(e=>{let{scope:t,children:n,state:r}=e,a=K.useRef(null),[o,s]=K.useState(null),c=F(a,s),[l,u]=r;return K.useEffect(()=>{if(!o)return;let e=Kn(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,J.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=I(l),d=K.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=F(t,i.collectionRef);return(0,J.jsx)(u,{ref:o,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=I(f),m=K.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=K.useRef(null),[s,c]=K.useState(null),l=F(t,o,c),{setItemMap:u}=a(f,n),d=K.useRef(i);Un(d.current,i)||(d.current=i);let m=d.current;return K.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Gn):(t.set(s,{...e,element:s}),t.toSorted(Gn)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Rn(e)))}},[s,m,u]),(0,J.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return K.useState(new Rn)}X(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return X(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}X(Hn,`createCollection`);function Un(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}X(Un,`shallowEqual`);function Wn(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}X(Wn,`isElementPreceding`);function Gn(e,t){return!e[1].element||!t[1].element?0:Wn(e[1].element,t[1].element)?-1:1}X(Gn,`sortByDocumentPosition`);function Kn(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}X(Kn,`getChildListObserver`);var qn=Object.defineProperty,Jn=(e,t)=>qn(e,`name`,{value:t,configurable:!0}),Yn=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Xn=K.forwardRef(Jn(function(e,t){return(0,J.jsx)(U.span,{...e,ref:t,style:{...Yn,...e.style}})},`VisuallyHidden`)),Zn=e(a(),1),Qn=Object.defineProperty,Z=(e,t)=>Qn(e,`name`,{value:t,configurable:!0}),$n=`ToastProvider`,[er,tr,nr]=In(`Toast`),[rr,ir]=at(`Toast`,[nr]),[ar,or]=rr($n),sr=Z(e=>{let{__scopeToast:t,label:n=`Notification`,duration:r=5e3,swipeDirection:i=`right`,swipeThreshold:a=50,announcerContainer:o,children:s}=e,[c,l]=K.useState(null),[u,d]=K.useState(0),f=K.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${$n}\`. Expected non-empty \`string\`.`),(0,J.jsx)(er.Provider,{scope:t,children:(0,J.jsx)(ar,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:u,viewport:c,onViewportChange:l,onToastAdd:K.useCallback(()=>d(e=>e+1),[]),onToastRemove:K.useCallback(()=>d(e=>e-1),[]),isClosePausedRef:f,announcerContainer:o,children:s})})},`ToastProvider`),cr=`ToastViewport`,lr=[`F8`],ur=`toast.viewportPause`,dr=`toast.viewportResume`,fr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,hotkey:r=lr,label:i=`Notifications ({hotkey})`,...a}=e,o=or(cr,n),s=tr(n),c=K.useRef(null),l=K.useRef(null),u=K.useRef(null),d=K.useRef(null),f=F(t,d,o.onViewportChange),p=r.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),m=o.toastCount>0;K.useEffect(()=>{let e=Z(e=>{r.length!==0&&r.every(t=>e[t]||e.code===t)&&d.current?.focus()},`handleKeyDown`);return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),K.useEffect(()=>{let e=c.current,t=d.current;if(m&&e&&t){let n=Z(()=>{if(!o.isClosePausedRef.current){let e=new CustomEvent(ur);t.dispatchEvent(e),o.isClosePausedRef.current=!0}},`handlePause`),r=Z(()=>{if(o.isClosePausedRef.current){let e=new CustomEvent(dr);t.dispatchEvent(e),o.isClosePausedRef.current=!1}},`handleResume`),i=Z(t=>{e.contains(t.relatedTarget)||r()},`handleFocusOutResume`),a=Z(()=>{e.contains(document.activeElement)||r()},`handlePointerLeaveResume`);return e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,i),e.addEventListener(`pointermove`,n),e.addEventListener(`pointerleave`,a),window.addEventListener(`blur`,n),window.addEventListener(`focus`,r),()=>{e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,i),e.removeEventListener(`pointermove`,n),e.removeEventListener(`pointerleave`,a),window.removeEventListener(`blur`,n),window.removeEventListener(`focus`,r)}}},[m,o.isClosePausedRef]);let h=K.useCallback(({tabbingDirection:e})=>{let t=s().map(t=>{let n=t.ref.current,r=[n,...Pr(n)];return e===`forwards`?r:r.reverse()});return(e===`forwards`?t.reverse():t).flat()},[s]);return K.useEffect(()=>{let e=d.current;if(e){let t=Z(t=>{let n=t.altKey||t.ctrlKey||t.metaKey;if(t.key===`Tab`&&!n){let n=document.activeElement,r=t.shiftKey;if(t.target===e&&r){l.current?.focus();return}let i=h({tabbingDirection:r?`backwards`:`forwards`}),a=i.findIndex(e=>e===n);Fr(i.slice(a+1))?t.preventDefault():r?l.current?.focus():u.current?.focus()}},`handleKeyDown`);return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}},[s,h]),(0,J.jsxs)($e,{ref:c,role:`region`,"aria-label":i.replace(`{hotkey}`,p),tabIndex:-1,style:{pointerEvents:m?void 0:`none`},children:[m&&(0,J.jsx)(mr,{ref:l,onFocusFromOutsideViewport:()=>{Fr(h({tabbingDirection:`forwards`}))}}),(0,J.jsx)(er.Slot,{scope:n,children:(0,J.jsx)(U.ol,{tabIndex:-1,...a,ref:f})}),m&&(0,J.jsx)(mr,{ref:u,onFocusFromOutsideViewport:()=>{Fr(h({tabbingDirection:`backwards`}))}})]})},`ToastViewport`)),pr=`ToastFocusProxy`,mr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,a=or(pr,n);return(0,J.jsx)(Xn,{tabIndex:0,...i,ref:t,style:{position:`fixed`},onFocus:e=>{let t=e.relatedTarget;a.viewport?.contains(t)||r()}})},`ToastFocusProxy`)),hr=`Toast`,gr=`toast.swipeStart`,_r=`toast.swipeMove`,vr=`toast.swipeCancel`,yr=`toast.swipeEnd`,br=K.forwardRef(Z(function(e,t){let{forceMount:n,open:r,defaultOpen:i,onOpenChange:a,...o}=e,[s,c]=ae({prop:r,defaultProp:i??!0,onChange:a,caller:hr});return(0,J.jsx)(Fe,{present:n||s,children:(0,J.jsx)(Cr,{open:s,...o,ref:t,onClose:()=>c(!1),onPause:tt(e.onPause),onResume:tt(e.onResume),onSwipeStart:W(e.onSwipeStart,e=>{e.currentTarget.setAttribute(`data-swipe`,`start`)}),onSwipeMove:W(e.onSwipeMove,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`move`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-y`,`${n}px`)}),onSwipeCancel:W(e.onSwipeCancel,e=>{e.currentTarget.setAttribute(`data-swipe`,`cancel`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-y`)}),onSwipeEnd:W(e.onSwipeEnd,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`end`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-y`,`${n}px`),c(!1)})})})},`Toast`)),[xr,Sr]=rr(hr,{onClose(){}}),Cr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,type:r=`foreground`,duration:i,open:a,onClose:o,onEscapeKeyDown:s,onPause:c,onResume:l,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:p,...m}=e,h=or(hr,n),g=tr(n),[_,v]=K.useState(null),y=F(t,v),b=K.useRef(null),x=K.useRef(null),S=i||h.duration,C=K.useRef(0),w=K.useRef(S),T=K.useRef(0),{onToastAdd:E,onToastRemove:D}=h,O=tt(()=>{_?.contains(document.activeElement)&&h.viewport?.focus(),o()}),k=K.useCallback(e=>{!e||e===1/0||(window.clearTimeout(T.current),C.current=new Date().getTime(),T.current=window.setTimeout(O,e))},[O]);K.useEffect(()=>{let e=h.viewport;if(e){let t=Z(()=>{k(w.current),l?.()},`handleResume`),n=Z(()=>{let e=new Date().getTime()-C.current;w.current-=e,window.clearTimeout(T.current),c?.()},`handlePause`);return e.addEventListener(ur,n),e.addEventListener(dr,t),()=>{e.removeEventListener(ur,n),e.removeEventListener(dr,t)}}},[h.viewport,S,c,l,k]),K.useEffect(()=>{a&&!h.isClosePausedRef.current&&k(S)},[a,S,h.isClosePausedRef,k]),K.useEffect(()=>()=>{window.clearTimeout(T.current)},[]),K.useEffect(()=>(E(),()=>D()),[E,D]);let A=K.useMemo(()=>_?kr(_):null,[_]);return h.viewport?(0,J.jsxs)(J.Fragment,{children:[A&&(0,J.jsx)(wr,{__scopeToast:n,role:`status`,"aria-live":r===`foreground`?`assertive`:`polite`,children:A}),(0,J.jsx)(xr,{scope:n,onClose:O,children:Zn.createPortal((0,J.jsx)(er.ItemSlot,{scope:n,children:(0,J.jsx)(je,{asChild:!0,onEscapeKeyDown:W(s,e=>{g().some(t=>t.ref.current?.contains(e.target))||O()}),children:(0,J.jsx)(U.li,{tabIndex:0,"data-state":a?`open`:`closed`,"data-swipe-direction":h.swipeDirection,...m,ref:y,style:{userSelect:`none`,touchAction:`none`,...e.style},onKeyDown:W(e.onKeyDown,e=>{e.key===`Escape`&&(s?.(e.nativeEvent),e.nativeEvent.defaultPrevented||O())}),onPointerDown:W(e.onPointerDown,e=>{e.button===0&&(b.current={x:e.clientX,y:e.clientY})}),onPointerMove:W(e.onPointerMove,e=>{if(!b.current)return;let t=e.clientX-b.current.x,n=e.clientY-b.current.y,r=!!x.current,i=[`left`,`right`].includes(h.swipeDirection),a=[`left`,`up`].includes(h.swipeDirection)?Math.min:Math.max,o=i?a(0,t):0,s=i?0:a(0,n),c=e.pointerType===`touch`?10:2,l={x:o,y:s},f={originalEvent:e,delta:l};r?(x.current=l,Ar(_r,d,f,{discrete:!1})):jr(l,h.swipeDirection,c)?(x.current=l,Ar(gr,u,f,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>c||Math.abs(n)>c)&&(b.current=null)}),onPointerUp:W(e.onPointerUp,e=>{let t=x.current,n=e.target;if(n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),x.current=null,b.current=null,t){let n=e.currentTarget,r={originalEvent:e,delta:t};jr(t,h.swipeDirection,h.swipeThreshold)?Ar(yr,p,r,{discrete:!0}):Ar(vr,f,r,{discrete:!0}),n.addEventListener(`click`,e=>e.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null},`ToastImpl`)),wr=Z(e=>{let{__scopeToast:t,children:n,...r}=e,i=or(hr,t),[a,o]=K.useState(!1),[s,c]=K.useState(!1);return Mr(()=>o(!0)),K.useEffect(()=>{let e=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(e)},[]),s?null:(0,J.jsx)(rt,{asChild:!0,container:i.announcerContainer||void 0,children:(0,J.jsx)(Xn,{...r,children:a&&(0,J.jsxs)(J.Fragment,{children:[i.label,` `,n]})})})},`ToastAnnounce`),Tr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e;return(0,J.jsx)(U.div,{...r,ref:t})},`ToastTitle`)),Er=`ToastClose`,Dr=K.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e,i=Sr(Er,n);return(0,J.jsx)(Or,{asChild:!0,children:(0,J.jsx)(U.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,i.onClose)})})},`ToastClose`)),Or=K.forwardRef(Z(function(e,t){let{__scopeToast:n,altText:r,...i}=e;return(0,J.jsx)(U.div,{"data-radix-toast-announce-exclude":``,"data-radix-toast-announce-alt":r||void 0,...i,ref:t})},`ToastAnnounceExclude`));function kr(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),Nr(e)){let n=e.ariaHidden||e.hidden||e.style.display===`none`,r=e.dataset.radixToastAnnounceExclude===``;if(!n)if(r){let n=e.dataset.radixToastAnnounceAlt;n&&t.push(n)}else t.push(...kr(e))}}),t}Z(kr,`getAnnounceTextContent`);function Ar(e,t,n,{discrete:r}){let i=n.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?We(i,a):i.dispatchEvent(a)}Z(Ar,`handleAndDispatchCustomEvent`);var jr=Z((e,t,n=0)=>{let r=Math.abs(e.x),i=Math.abs(e.y),a=r>i;return t===`left`||t===`right`?a&&r>n:!a&&i>n},`isDeltaInDirection`);function Mr(e=()=>{}){let t=tt(e);qe(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}Z(Mr,`useNextFrame`);function Nr(e){return e.nodeType===e.ELEMENT_NODE}Z(Nr,`isHTMLElement`);function Pr(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Z(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}Z(Pr,`getTabbableCandidates`);function Fr(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}Z(Fr,`focusFirst`);var Ir=sr,Lr=fr,Rr=br,zr=Tr,Br=Dr;function Vr({value:e,dateStyle:t=`medium`,timeStyle:r=`short`}){let{locale:i}=n(),{timezone:a}=E();if(e==null||e===``)return null;let o={locale:i,timeZone:a},s=D(e,{dateStyle:t,timeStyle:r},o),c=Hr(e),l=T(e,o);return(0,J.jsx)(`time`,{dateTime:c??void 0,title:l||void 0,children:s})}function Hr(e){let t=new Date(String(e));return Number.isNaN(t.getTime())?null:t.toISOString()}var Ur={primary:{accent:`border-l-lt-primary`,icon:(0,J.jsx)(R,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-primary`})},secondary:{accent:`border-l-lt-secondary`,icon:(0,J.jsx)(R,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-muted-fg`})},success:{accent:`border-l-lt-success`,icon:(0,J.jsx)(R,{name:`circle-check`,className:`size-lt-icon-lg shrink-0 text-lt-success`})},info:{accent:`border-l-lt-info`,icon:(0,J.jsx)(R,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-info`})},warning:{accent:`border-l-lt-warning`,icon:(0,J.jsx)(R,{name:`circle-alert`,className:`size-lt-icon-lg shrink-0 text-lt-warning`})},danger:{accent:`border-l-lt-danger`,icon:(0,J.jsx)(R,{name:`circle-x`,className:`size-lt-icon-lg shrink-0 text-lt-danger`})}},Wr=0;function Gr({duration:e=4e3}){let{t}=w(`lattice`),[n,r]=(0,K.useState)([]);function i(e){r(t=>t.filter(t=>t.id!==e))}return(0,K.useEffect)(()=>jn(e=>{r(t=>[...t,{...e,id:Wr++}])}),[]),(0,J.jsxs)(Ir,{duration:e,swipeDirection:`down`,children:[n.map(n=>(0,J.jsxs)(Rr,{className:P(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg shadow-lt-lg`,Ur[n.variant].accent,`data-[state=open]:animate-lt-toast-in data-[state=closed]:animate-lt-toast-out`,`data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] data-[swipe=cancel]:translate-y-0 data-[swipe=cancel]:transition-transform`),"data-test":`toast-${n.variant}`,duration:n.persistent?1/0:n.duration??e,onOpenChange:e=>{e||i(n.id)},children:[Ur[n.variant].icon,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsx)(zr,{className:`text-sm text-lt-fg`,children:ie(n.message,t)}),n.action?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,J.jsx)(En,{node:n.action})}):null]}),n.dismissible?(0,J.jsx)(Br,{"aria-label":t(`common.dismiss`,`Dismiss`),className:`shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,"data-test":`toast-dismiss`,children:(0,J.jsx)(R,{name:`x`,className:`size-lt-icon-md`})}):null]},n.id)),(0,J.jsx)(Lr,{className:`fixed inset-x-0 bottom-0 z-lt-toast mx-auto flex w-full max-w-sm flex-col gap-2 p-4 outline-none`})]})}var Kr=0,qr=()=>{let{t:e}=w(`lattice`),[t,n]=(0,K.useState)([]);(0,K.useEffect)(()=>Nn(e=>{n(t=>[...e.unique?t.filter(t=>t.unique!==e.unique):t,{...e,id:Kr++}])}),[]),(0,K.useEffect)(()=>p.on(`navigate`,()=>{n(e=>e.filter(e=>!e.unique))}),[]),(0,K.useEffect)(()=>Pn(e=>{n(t=>t.filter(t=>t.unique!==e))}),[]);function r(e){n(t=>t.filter(t=>t.id!==e))}return t.length===0?null:(0,J.jsx)(`div`,{className:`flex w-full flex-col gap-2`,children:t.map(t=>(0,J.jsxs)(`div`,{role:`status`,"data-test":`callout-${t.variant}`,className:P(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg`,Ur[t.variant].accent),children:[Ur[t.variant].icon,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[t.title?(0,J.jsx)(`p`,{className:`text-sm font-medium text-lt-fg`,children:ie(t.title,e)}):null,(0,J.jsx)(`p`,{className:`text-sm text-lt-fg`,children:ie(t.message,e)}),t.action?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,J.jsx)(En,{node:t.action})}):null]}),t.dismissible?(0,J.jsx)(`button`,{type:`button`,"aria-label":e(`common.dismiss`,`Dismiss`),"data-test":`callout-dismiss`,className:`shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,onClick:()=>r(t.id),children:(0,J.jsx)(R,{name:`x`,className:`size-lt-icon-md`})}):null]},t.id))})},Jr=({node:e})=>{let{t}=w(`lattice`),n=u().props.lattice?.breadcrumbs??[];return n.length===0?null:(0,J.jsx)(`nav`,{"aria-label":t(`common.breadcrumb`,`Breadcrumb`),"data-lattice-component":M(e),children:(0,J.jsx)(`ol`,{className:`flex items-center gap-2 text-sm text-lt-muted-fg`,children:n.map((e,t)=>{let r=t===n.length-1;return(0,J.jsxs)(K.Fragment,{children:[(0,J.jsx)(`li`,{children:r?(0,J.jsx)(`span`,{"aria-current":`page`,className:`text-lt-fg`,children:e.title}):(0,J.jsx)(b,{className:`hover:text-lt-fg`,href:e.href,children:e.title})}),r?null:(0,J.jsx)(`li`,{"aria-hidden":`true`,children:`/`})]},e.href)})})})};function Yr({align:e=`start`,children:t,className:n,placement:r=`bottom`,testId:i,trigger:a,triggerClassName:o,triggerLabel:s}){let[c,l]=(0,K.useState)(!1),d=u().url;return(0,K.useEffect)(()=>l(!1),[d]),(0,J.jsxs)(Te,{open:c,onOpenChange:l,children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(`button`,{"aria-label":s,className:P(`w-full`,o),"data-test":i,title:s,type:`button`,children:a})}),(0,J.jsx)(B,{align:e,className:P(`min-w-56 p-1`,n),role:`menu`,side:r,children:(0,J.jsx)(Sn.Provider,{value:!1,children:t})})]})}var Xr=({children:e,node:t})=>{let n=t.key??`dropdown`;return(0,J.jsx)(Yr,{placement:t.props.placement,testId:n,triggerClassName:`w-auto`,trigger:(0,J.jsx)(`span`,{className:`flex min-w-0 items-center rounded-lt-sm px-2 py-1.5 text-sm hover:bg-lt-muted`,children:t.props.trigger.map((e,t)=>(0,J.jsx)(En,{node:e},e.key??`${e.type}-${t}`))}),children:(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})})},Zr=({children:e,node:t})=>(0,J.jsx)(`nav`,{"data-lattice-component":M(t),children:(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})}),Qr=(0,K.createContext)(null),$r=`flex items-center gap-2 rounded-lt-sm px-3 py-2 text-base font-medium text-lt-fg transition-colors hover:bg-lt-muted`;function ei({affix:e,className:t}){return e.icon?(0,J.jsx)(N,{className:P(`size-lt-icon-md shrink-0`,t),icon:e.icon}):(0,J.jsx)(`span`,{className:P(`shrink-0 text-sm text-lt-muted-fg`,t),children:e.text})}function ti(e,t){return(e??[]).some(e=>e.props?.href===t||ti(e.schema,t))}var ni=({children:e,node:t})=>{let n=Cn(),{icon:r,label:i,prefix:a,suffix:o}=t.props,s=i??``,c=!!r,l=r??a?.icon??null,d=u().url.split(`?`)[0],f=A(`menu`,t),p=L(t.props),m=r?(0,J.jsx)(N,{className:`size-lt-icon-md shrink-0`,icon:r}):(0,J.jsxs)(J.Fragment,{children:[a?(0,J.jsx)(ei,{affix:a}):null,n?(0,J.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 left-full z-lt-popover ml-2 hidden -translate-y-1/2 rounded-lt-sm border border-lt-border bg-lt-popover px-2 py-1 text-sm whitespace-nowrap text-lt-popover-fg shadow-lt-md group-hover:block`,role:`tooltip`,children:s}):(0,J.jsx)(`span`,{children:s}),o?(0,J.jsx)(ei,{affix:o,className:`ml-auto`}):null]}),h=P($r,`w-full`,n&&`group relative justify-center`,c&&`justify-center`),g=({onClick:e,processing:t})=>(0,J.jsx)(`button`,{"aria-label":n||c?s:void 0,className:h,"data-test":f,disabled:t,onClick:e,type:`button`,children:m});if(p.kind===`action`)return(0,J.jsx)(`li`,{children:(0,J.jsx)(ee,{action:p.action,children:g})});if(p.kind===`effects`)return(0,J.jsx)(`li`,{children:g({onClick:p.onClick,processing:!1})});if(p.kind===`navigate`){let e=d===p.href;return(0,J.jsx)(`li`,{children:(0,J.jsx)(b,{"aria-current":e?`page`:void 0,"aria-label":n||c?s:void 0,as:p.method===`get`?void 0:`button`,className:P(h,e&&`bg-lt-muted font-medium`),"data-test":f,href:p.href,method:p.method,children:m})})}return e?n?(0,J.jsx)(ii,{icon:l,label:s,testId:f,children:e}):(0,J.jsx)(ri,{content:m,defaultOpen:ti(t.schema,d),testId:f,children:e}):n?null:(0,J.jsx)(`li`,{children:(0,J.jsx)(`span`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:m})})};function ri({children:e,content:t,defaultOpen:n,testId:r}){let[i,a]=(0,K.useState)(n);return(0,J.jsxs)(`li`,{children:[(0,J.jsxs)(`button`,{"aria-expanded":i,className:P($r,`w-full`),"data-test":r,onClick:()=>a(e=>!e),type:`button`,children:[t,(0,J.jsx)(R,{name:`chevron-right`,className:P(`ml-auto size-lt-icon-md shrink-0 transition-transform`,i&&`rotate-90`)})]}),i?(0,J.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1 pl-3`,children:e}):null]})}function ii({children:e,icon:t,label:n,testId:r}){return(0,J.jsx)(`li`,{children:(0,J.jsx)(Yr,{className:`min-w-48`,placement:`right`,testId:r,trigger:t?(0,J.jsx)(N,{className:`size-lt-icon-md shrink-0`,icon:t}):(0,J.jsx)(`span`,{children:n}),triggerClassName:P($r,`justify-center`),triggerLabel:n,children:(0,J.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`li`,{className:`px-3 py-1.5 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:n}),e]})})})}var ai=()=>(0,J.jsx)(J.Fragment,{children:(0,K.useContext)(Qr)});function oi(e,t){return typeof window>`u`||typeof window.matchMedia!=`function`?t:window.matchMedia(e).matches}function si(e,t=!1){let[n,r]=(0,K.useState)(()=>oi(e,t));return(0,K.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}function ci(e,t,n={}){let{enabled:r=!0,parse:i,serialize:a}=n,o=()=>typeof t==`function`?t():t,[s,c]=(0,K.useState)(()=>{if(!r||typeof window>`u`)return o();let t;try{t=window.localStorage.getItem(e)}catch{return o()}if(t===null)return o();try{return i?i(t):JSON.parse(t)}catch{try{window.localStorage.removeItem(e)}catch{return o()}return o()}}),l=(0,K.useRef)(s);l.current=s;let u=(0,K.useRef)({enabled:r,key:e,serialize:a});return u.current={enabled:r,key:e,serialize:a},[s,(0,K.useCallback)(e=>{let t=typeof e==`function`?e(l.current):e;l.current=t,c(t);let{enabled:n,key:r,serialize:i}=u.current;if(!(!n||typeof window>`u`))try{let e=i?i(t):JSON.stringify(t);e===null?window.localStorage.removeItem(r):window.localStorage.setItem(r,e)}catch{return}},[])]}function li(e,t,n){let[r,i]=ci(e,t,{enabled:n,parse:e=>e===`true`,serialize:String});return[r,(0,K.useCallback)(()=>i(e=>!e),[i])]}var ui=`(min-width: 768px)`;function di(e,t){let n=e.detail?.target;return n==null||n===t}var fi=hn({components:{breadcrumbs:q(Jr),callouts:q(qr),dropdown:q(Xr),menu:q(Zr),"menu-item":q(ni),outlet:q(ai),sidebar:q(({children:e,node:t})=>{let n=t.props.collapsible,r=t.props.rememberState,a=M(t),o=`lattice:sidebar:${a??`default`}`,s=si(ui,!0),[c,l]=li(o,!1,n&&r),[u,d]=(0,K.useState)(!1);vn(i.toggleSidebar,e=>{di(e,a)&&(window.matchMedia?.(ui).matches??!0?n&&l():d(e=>!e))}),(0,K.useEffect)(()=>p.on(`navigate`,()=>d(!1)),[]),vn(`keydown`,e=>{e.key===`Escape`&&d(!1)},{enabled:u});let f=n&&c&&s;return(0,J.jsxs)(Sn.Provider,{value:f,children:[u?(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`fixed inset-0 z-lt-overlay bg-lt-overlay md:hidden`,"data-test":`sidebar-backdrop`,onClick:()=>d(!1)}):null,(0,J.jsx)(`aside`,{className:P(`fixed inset-y-0 left-0 z-lt-modal flex h-svh w-72 max-w-[80vw] shrink-0 flex-col gap-4 border-r border-lt-border bg-lt-bg p-4 transition-transform`,`md:sticky md:top-0 md:z-auto md:max-w-none md:translate-x-0 md:transition-[width]`,u?`translate-x-0`:`-translate-x-full`,f?`md:w-16 md:overflow-visible`:`md:w-64 md:overflow-x-hidden md:overflow-y-auto`),"data-collapsed":f?`true`:`false`,"data-lattice-component":a,"data-test":`sidebar`,children:e})]})}),topbar:q(({children:e,node:t})=>{let n=t.props.sticky;return(0,J.jsx)(`header`,{"data-lattice-component":M(t),className:P(`flex h-14 w-full items-center gap-2 border-b border-lt-border bg-lt-bg px-4 text-lt-fg`,n&&`sticky top-0 z-lt-sticky`),children:e})})},name:`lattice/layout`});function pi({children:e}){let t=u().props.lattice.layout;return t?(0,J.jsx)(Qr.Provider,{value:e,children:(0,J.jsx)(Y,{nodes:t.schema})}):(0,J.jsx)(J.Fragment,{children:e})}var mi=(0,K.lazy)(()=>$t(()=>import(`./chunks/subscriptions-BdHDnVA3.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),hi=class extends K.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){console.warn(`[lattice] Real-time listeners are declared but Echo is unavailable. Install @laravel/echo-react and call configureEcho().`)}render(){return this.state.failed?null:this.props.children}};function gi({listeners:e}){return e.length===0?null:(0,J.jsx)(hi,{children:(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(mi,{listeners:e})})})}function _i({lattice:e}){let t=(0,J.jsx)(Y,{nodes:e.schema});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(f,{title:e.title??void 0}),(0,J.jsx)(gi,{listeners:e.listeners}),e.container===`centered`?(0,J.jsx)(`main`,{className:`min-h-svh bg-lt-bg text-lt-fg`,children:(0,J.jsx)(`div`,{"data-test":`lattice-centered-container`,className:`mx-auto flex min-h-svh w-full max-w-6xl flex-col justify-center px-6 py-12 sm:px-8 lg:px-10`,children:t})}):(0,J.jsx)(`div`,{"data-test":`lattice-default-container`,className:P(`w-full`,{"px-4 py-6":e.layout!==null}),children:t})]})}function vi(e){return t=>{if(t===`lattice/page`)return{default:_i};let n=e[`./Pages/${t}.tsx`]??e[`./pages/${t}.tsx`];if(n)return n();throw Error(`Page not found: ${t}`)}}function yi({defaultLayout:e}={}){return(t,n)=>t===`lattice/page`?n.props.lattice?.layout?pi:null:e?.(t,n)??null}function bi(e,t){return{...t,headers:At(``,t.headers)}}var xi=!1;function Si(){xi||(xi=!0,g.onRequest(e=>{let t=e.headers?.[Tt];return e.headers&&typeof t==`string`&&t!==``&&(e.headers[Tt]=Dt(t)),e}))}var Ci=Object.defineProperty,Q=(e,t)=>Ci(e,`name`,{value:t,configurable:!0}),wi=`Dialog`,[Ti,Ei]=at(wi),[Di,Oi]=Ti(wi),ki=Q(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=K.useRef(null),c=K.useRef(null),[l,u]=ae({prop:r,defaultProp:i??!1,onChange:a,caller:wi}),[d,f]=K.useState(0),[p,m]=K.useState(0);return(0,J.jsx)(Di,{scope:t,triggerRef:s,contentRef:c,contentId:Ee(),titleId:Ee(),descriptionId:Ee(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:K.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),Ai=`DialogPortal`,[ji,Mi]=Ti(Ai,{forceMount:void 0}),Ni=Q(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Oi(Ai,t);return(0,J.jsx)(ji,{scope:t,forceMount:n,children:K.Children.map(r,e=>(0,J.jsx)(Fe,{present:n||a.open,children:(0,J.jsx)(rt,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Pi=`DialogOverlay`,Fi=K.forwardRef(Q(function(e,t){let n=Mi(Pi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Oi(Pi,e.__scopeDialog);return a.modal?(0,J.jsx)(Fe,{present:r||a.open,children:(0,J.jsx)(Li,{...i,ref:t})}):null},`DialogOverlay`)),Ii=I(`DialogOverlay.RemoveScroll`),Li=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Oi(Pi,n),a=Ye(),o=F(t,a);return(0,J.jsx)(Ze,{as:Ii,allowPinchZoom:!0,shards:[i.contentRef],children:(0,J.jsx)(U.div,{"data-state":Yi(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Ri=`DialogContent`,zi=K.forwardRef(Q(function(e,t){let n=Mi(Ri,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Oi(Ri,e.__scopeDialog);return(0,J.jsx)(Fe,{present:r||a.open,children:a.modal?(0,J.jsx)(Bi,{...i,ref:t}):(0,J.jsx)(Vi,{...i,ref:t})})},`DialogContent`)),Bi=K.forwardRef(Q(function(e,t){let n=Oi(Ri,e.__scopeDialog),r=K.useRef(null),i=F(t,n.contentRef,r);return K.useEffect(()=>{let e=r.current;if(e)return me(e)},[]),(0,J.jsx)(Hi,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:W(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Vi=K.forwardRef(Q(function(e,t){let n=Oi(Ri,e.__scopeDialog),r=K.useRef(!1),i=K.useRef(!1);return(0,J.jsx)(Hi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Hi=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Oi(Ri,n);return be(),(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Oe,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,J.jsx)(Be,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Yi(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Ui=`DialogTitle`,Wi=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Oi(Ui,n),{setTitleCount:a}=i;return qe(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,J.jsx)(U.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Gi=`DialogDescription`,Ki=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Oi(Gi,n),{setDescriptionCount:a}=i;return qe(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,J.jsx)(U.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),qi=`DialogClose`,Ji=K.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Oi(qi,n);return(0,J.jsx)(U.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Yi(e){return e?`open`:`closed`}Q(Yi,`getState`);var Xi=ne(`fixed z-lt-modal w-full overflow-y-auto bg-lt-bg p-6 shadow-lt-lg`,{variants:{placement:{center:`left-1/2 top-1/2 max-h-[min(680px,calc(100vh-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-lt border border-lt-border data-[state=open]:animate-lt-dialog-in data-[state=closed]:animate-lt-dialog-out`,start:`inset-y-0 start-0 border-e border-lt-border data-[state=open]:animate-lt-sheet-in-start data-[state=closed]:animate-lt-sheet-out-start`,end:`inset-y-0 end-0 border-s border-lt-border data-[state=open]:animate-lt-sheet-in-end data-[state=closed]:animate-lt-sheet-out-end`},width:{sm:`max-w-sm`,md:`max-w-md`,lg:`max-w-lg`,xl:`max-w-xl`,"2xl":`max-w-2xl`,"3xl":`max-w-3xl`}},defaultVariants:{placement:`center`,width:`lg`}});function Zi(e){return(0,J.jsx)(ki,{"data-slot":`dialog`,...e})}function Qi(e){return(0,J.jsx)(Ji,{"data-slot":`dialog-close`,...e})}function $i({className:e,...t}){return(0,J.jsx)(Wi,{className:P(`text-lg font-semibold leading-none tracking-tight`,e),"data-slot":`dialog-title`,...t})}function ea({className:e,...t}){return(0,J.jsx)(Ki,{className:P(`text-sm text-lt-muted-fg`,e),"data-slot":`dialog-description`,...t})}function ta({children:e,className:t,placement:n=`center`,width:r=`lg`,...i}){return(0,J.jsxs)(Ni,{children:[(0,J.jsx)(Fi,{className:`fixed inset-0 z-lt-overlay bg-lt-overlay data-[state=open]:animate-lt-fade-in data-[state=closed]:animate-lt-fade-out`,"data-slot":`dialog-overlay`}),(0,J.jsx)(zi,{className:P(Xi({placement:n,width:r}),t),"data-slot":`dialog-content`,...i,children:e})]})}function na({closeLabel:e,description:t,title:n}){return(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2`,children:[(0,J.jsx)($i,{children:n}),t?(0,J.jsx)(ea,{children:t}):null]}),(0,J.jsx)(Qi,{asChild:!0,children:(0,J.jsx)(G,{"aria-label":e,"data-test":`dialog-close`,size:`icon`,emphasis:`ghost`,children:(0,J.jsx)(R,{name:`x`,"aria-hidden":`true`,className:`size-lt-icon-md`})})})]})}function ra({className:e,...t}){let{t:n}=w(`lattice`);return(0,J.jsx)(R,{name:`loader-2`,role:`status`,"aria-label":n(`common.loading`,`Loading`),"aria-hidden":!1,className:P(`animate-spin`,e),...t})}function ia({title:e,description:t,confirmLabel:n,cancelLabel:r=`Cancel`,confirmVariant:i=null,confirmEmphasis:a=null,processing:o=!1,confirmDisabled:s=!1,onConfirm:c,onCancel:l}){let u=e=>{o&&e.preventDefault()};return(0,J.jsx)(Zi,{open:!0,onOpenChange:e=>{e||l()},children:(0,J.jsxs)(ta,{...t?{}:{"aria-describedby":void 0},width:`md`,onEscapeKeyDown:u,onInteractOutside:u,children:[(0,J.jsxs)(`div`,{className:`grid gap-2`,children:[(0,J.jsx)($i,{children:e}),t&&(0,J.jsx)(ea,{children:t})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,J.jsx)(G,{type:`button`,emphasis:`outline`,"data-test":`confirm-cancel`,disabled:o,onClick:l,children:r}),(0,J.jsxs)(G,{type:`button`,emphasis:a,variant:i,"data-test":`confirm-accept`,disabled:o||s,onClick:c,children:[o&&(0,J.jsx)(ra,{}),n]})]})]})})}async function aa(e,t){try{let n=await e(),r=await n.json().catch(()=>({}));return t(_(r.effects)),n.ok}catch(e){return m(e),!1}}function oa({className:e,...t}){return(0,J.jsx)(`div`,{"aria-hidden":`true`,className:P(`animate-pulse rounded-lt-sm bg-lt-muted`,e),"data-slot":`skeleton`,...t})}var sa=(0,K.createContext)({});function ca({nodes:e,children:t}){return(0,J.jsx)(sa.Provider,{value:e,children:t})}function la(e){let t=(0,K.useContext)(sa),n=ut(e).name??``,r=st(),i=n&&r?r.errorKey(n):n;return i&&t[i]||n&&t[n]||e}function ua(e,t,n,r){return Vt(e,{method:`POST`,ref:t,signal:r,body:JSON.stringify(n),throwOnError:!1}).then(e=>e.ok?e.json():null)}function da(e){return e.templates}function fa(e,t){let n=da(e);return n?n.find(e=>e.type===t.type)?.schema??[]:e.schema??[]}function pa(e,t){return e.startsWith(`@`)?e.slice(1):t===null?e:ye(t,e)}function ma(e,t,n,r=0,i={}){let a=ut(e);if(!a.editablePrefill||!a.name)return null;let o=ue(i);return{path:t===null?a.name:ye(t,a.name),overrideKey:n===null?a.name:Ce(n,o,r,a.name),resetOn:(a.prefillResetOn??[]).map(e=>pa(e,t)),refreshOn:(a.prefillRefreshOn??[]).map(e=>pa(e,t))}}function ha(e,t){let n=[],r=(e,i=null,a=null,o=null,s=0,c={})=>{for(let l of e??[]){if(xe.has(l.type)){let e=ut(l).name;if(e){let n=ye(i,e),o=ye(a,e),s=de(t,n);(Array.isArray(s)?s:[]).forEach((e,t)=>{r(fa(l,e),ye(n,t),ye(o,ue(e)??t),o,t,e)})}continue}let e=ma(l,i,o,s,c);e&&n.push(e),r(l.schema,i,a,o,s,c)}};return r(e),n}function ga(e,t){let n=new Map(e.targets.map(e=>[e.overrideKey,e]));return t.targets.filter(r=>{let i=n.get(r.overrideKey);return r.resetOn.some((n,r)=>{let a=i?.resetOn[r]??n;return!Object.is(de(e.values,a),de(t.values,n))})}).map(e=>e.overrideKey)}function _a(e,t){return e.filter(e=>{let n=de(t,e.path);return n!=null&&n!==``}).map(e=>e.overrideKey)}function va(e,t){let n=new Set(t.map(e=>e.overrideKey));return new Set([...e].filter(e=>n.has(e)))}function ya(e,t,n){let r=Me(),i=Se(),[a,o]=(0,K.useState)({}),s=(0,K.useMemo)(()=>ha(n,r),[n,r]),c=(0,K.useRef)(new Set),l=(0,K.useRef)(new Set),u=(0,K.useRef)(r),d=(0,K.useRef)(s),f=(0,K.useRef)(s);f.current=s,(0,K.useLayoutEffect)(()=>{let e=new Set(s.map(e=>e.overrideKey));l.current=new Set([...l.current].filter(t=>e.has(t)));let t=s.filter(e=>!l.current.has(e.overrideKey));for(let e of _a(t,r))c.current.add(e);for(let e of t)l.current.add(e.overrideKey)},[s,r]);let p=(0,K.useCallback)(e=>{c.current.add(e)},[]),m=(0,K.useMemo)(()=>{let e=new Set,t=!1;return se(n,n=>{if(Array.isArray(n.dependsOnKeys))for(let t of n.dependsOnKeys)e.add(String(t));n.dependsOnAny&&(t=!0)}),{keys:[...e],any:t}},[n]),h=(0,K.useMemo)(()=>{let e=new Set(m.keys);for(let t of s){for(let n of t.resetOn)e.add(n);for(let n of t.refreshOn)e.add(n)}return[...e]},[m.keys,s]),g=m.any?r:JSON.stringify(h.map(e=>de(r,e)));return(0,K.useEffect)(()=>{if(h.length===0&&!m.any)return;let n=u.current;u.current=r;for(let e of ga({targets:d.current,values:n},{targets:f.current,values:r}))c.current.delete(e);d.current=f.current,c.current=va(c.current,f.current);let a=new AbortController,s=window.setTimeout(()=>{ua(e,t,{_sub:`resolve`,...r},a.signal).then(e=>{if(!e)return;for(let[t,n]of Object.entries(e.values??{}))i(t,n);let t=new Map(f.current.map(e=>[e.path,e]));for(let[n,r]of Object.entries(e.prefill??{})){let e=t.get(n);e&&!c.current.has(e.overrideKey)&&i(n,r)}e.fields&&o(e.fields)}).catch(()=>{})},250);return()=>{window.clearTimeout(s),a.abort()}},[g,e,t,m.any,i]),{nodes:a,markUserEdit:p}}function ba(e){let t={labels:{},values:{}};return se(e,e=>{e.name&&(e.label&&(t.labels[e.name]=e.label),e.value!==void 0&&(t.values[e.name]=e.value))}),t}function xa(e,t){return e===t||e.startsWith(`${t}.`)}function Sa(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=Array.isArray(r)?r[0]:r;return t}function Ca(e,t){let n=(0,K.useRef)(e);n.current=e;let r=(0,K.useRef)(null),i=(0,K.useCallback)(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]);return(0,K.useEffect)(()=>i,[i]),(0,K.useMemo)(()=>{let e=(...e)=>{i(),r.current=setTimeout(()=>{r.current=null,n.current(...e)},t)};return e.cancel=i,e},[i,t])}function wa(e,t,n){let[r,i]=(0,K.useState)(null);return(0,K.useEffect)(()=>{if(!n){i(null);return}let r=new AbortController;return Vt(e,{body:JSON.stringify({_sub:`schema`}),ref:t,method:`POST`,signal:r.signal,throwOnError:!1}).then(e=>e.ok?e.json():null).then(e=>i(e)).catch(()=>{}),()=>r.abort()},[n,e,t]),r}function Ta(){return(0,J.jsxs)(`div`,{className:`space-y-4`,"data-lattice-action-form-loading":!0,children:[(0,J.jsx)(oa,{className:`h-4 w-24`}),(0,J.jsx)(oa,{className:`h-10 w-full`}),(0,J.jsx)(oa,{className:`h-10 w-full`})]})}function Ea({cancelLabel:e,componentRef:t,endpoint:n,extraData:r,fieldLabels:i,formNode:a,method:o,onClose:s,onSuccess:c,precognitive:l,submitLabel:u}){let d=Me(),f=(0,K.useRef)(d);f.current=d;let p=(0,K.useRef)(r);p.current=r;let{nodes:h,markUserEdit:g}=ya(n,t,a.schema),v=y(),[b,x]=(0,K.useState)({}),[S,C]=(0,K.useState)(!1),[w,T]=(0,K.useState)(!1),E=(0,K.useCallback)(e=>Vt(n,{body:JSON.stringify({...f.current,...p.current}),method:o,ref:t,headers:e,throwOnError:!1}),[t,n,o]),D=(0,K.useCallback)(e=>{x(t=>t[e]===void 0?t:{...t,[e]:void 0})},[]),O=Ca(e=>{E({Precognition:`true`,"Precognition-Validate-Only":e}).then(async t=>{if(t.status===422){let e=await t.json();x(t=>({...t,...Sa(e.errors)}));return}D(e)}).catch(()=>{})},250),k=(0,K.useCallback)(e=>{l&&O(e)},[l,O]),A=(0,K.useCallback)(()=>{},[]),j=(0,K.useCallback)((e,t)=>{T(!0),E({Precognition:`true`,"Precognition-Validate-Only":e.join(`,`)}).then(async n=>{if(n.status===422){let e=await n.json();x(t=>({...t,...Sa(e.errors)})),t?.onValidationError?.();return}if(!n.ok){t?.onValidationError?.();return}let r=e.filter(e=>!e.includes(`*`));x(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!r.some(t=>xa(e,t))))),t?.onSuccess?.()}).catch(()=>t?.onValidationError?.()).finally(()=>T(!1))},[E]),M=(0,K.useCallback)(()=>{C(!0),E().then(async e=>{let t=await e.json().catch(()=>({}));if(v(_(t.effects)),e.status===422&&t.errors){x(Sa(t.errors));return}e.ok&&c(t)}).catch(e=>m(e)).finally(()=>C(!1))},[v,c,E]),N=(0,K.useMemo)(()=>({action:n,clearErrors:D,componentRef:t,errors:b,fieldLabels:i,precognitive:l,processing:S,touch:A,validate:k,validateFields:j,validating:w}),[D,t,n,b,i,l,S,A,k,j,w]);return(0,J.jsx)(fe,{value:N,children:(0,J.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,J.jsx)(we,{value:{markUserEdit:g},children:(0,J.jsx)(ca,{nodes:h,children:(0,J.jsx)(Y,{nodes:a.schema??[]})})}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,J.jsx)(G,{"data-test":`action-form-cancel`,disabled:S,onClick:s,type:`button`,emphasis:`ghost`,children:e}),a.props?.submitButton!==!1&&(0,J.jsxs)(G,{"data-test":`action-form-submit`,disabled:S,type:`submit`,children:[S&&(0,J.jsx)(ra,{}),u]})]})]})})}function Da({formNode:e,...t}){let n=!!e.props?.precognitive,{labels:r,values:i}=(0,K.useMemo)(()=>{let{labels:t,values:n}=ba(e.schema);return{labels:t,values:{...n,...e.props?.state}}},[e]);return(0,J.jsx)(ot,{initial:i,children:(0,J.jsx)(Ea,{fieldLabels:r,formNode:e,precognitive:n,...t})})}function Oa({description:e,formNode:t,onClose:n,placement:r,title:i,width:a,...o}){let{t:s}=w(`lattice`);return(0,J.jsx)(Zi,{open:!0,onOpenChange:e=>{e||n()},children:(0,J.jsxs)(ta,{...e?{}:{"aria-describedby":void 0},placement:r,width:a,children:[(0,J.jsx)(na,{closeLabel:s(`common.close`,`Close`),description:e,title:i}),(0,J.jsx)(`div`,{className:`mt-6`,children:t?(0,J.jsx)(Da,{formNode:t,onClose:n,...o}):(0,J.jsx)(Ta,{})})]})})}function ka(e){return e.props.label??C(`lattice`,`common.action.run`,`Run action`)}function Aa(e){let t=e.props.endpoint??``,n=e.props.ref??``,r=e.props.method??`post`,i=ka(e),{variant:a,emphasis:o}=e.props,s=e.props.confirmation,c=e.props.form,l=e.props.lazyForm===!0,u=!!c||l,[d,f]=(0,K.useState)(!1),m=y(),[h,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),b=wa(t,n,_&&l),x=l?b:c,S=async()=>{if(!t)return;if(r===`get`){p.visit(t,{headers:At(n)}),g(!1);return}f(!0);let e=await aa(()=>Vt(t,{method:r,ref:n,throwOnError:!1}),m);f(!1),e&&g(!1)},w=()=>{if(u){v(!0);return}if(s){g(!0);return}S()},T=s?.title??i,E=s?.confirmLabel??i,D=s?.cancelLabel??C(`lattice`,`common.cancel`,`Cancel`);return{processing:d,requestSubmit:w,overlays:(0,J.jsxs)(J.Fragment,{children:[h&&s&&(0,J.jsx)(ia,{title:T,description:s.description??void 0,confirmLabel:E,cancelLabel:D,confirmVariant:a,confirmEmphasis:o,processing:d,confirmDisabled:!t,onConfirm:()=>void S(),onCancel:()=>g(!1)}),_&&u&&(0,J.jsx)(Oa,{cancelLabel:D,componentRef:n,description:s?.description??void 0,endpoint:t,formNode:x,method:r,onClose:()=>v(!1),onSuccess:()=>{v(!1)},placement:e.props.modalSide??`center`,submitLabel:E,title:T,width:e.props.modalWidth??void 0})]})}}function ja({action:e,children:t}){let{processing:n,requestSubmit:r,overlays:i}=Aa(e);return(0,J.jsxs)(J.Fragment,{children:[t({onClick:r,processing:n}),i]})}function Ma({children:e}){return(0,J.jsx)(te,{render:e=>(0,J.jsx)(ja,{action:e.action,children:e.children}),children:e})}function Na(){let e=y();(0,K.useEffect)(()=>p.on(`flash`,t=>{let n=_(t.detail?.flash?.latticeEffects);n.length>0&&e(n)}),[e])}function Pa({onAppearanceChange:e,onLocaleChange:t,onToast:n}){return(0,K.useEffect)(()=>{if(n)return jn(n)},[n]),vn(i.appearanceChange,t=>{let n=t.detail?.value;rn(n)&&e?.(n)},{enabled:!!e}),vn(i.localeChange,e=>{let n=e.detail?.locale;typeof n==`string`&&n!==``&&t?.(n)},{enabled:!!t}),null}var Fa={href:``};function Ia({children:e,registry:t,sprite:n=Fa,toaster:r=!0}){return Na(),(0,J.jsx)(d.Provider,{value:t,children:(0,J.jsx)(Ma,{children:(0,J.jsxs)(re,{sprite:n,children:[e,(0,J.jsx)(Pa,{onAppearanceChange:pn}),r?(0,J.jsx)(Gr,{}):null]})})})}var La=hn({components:{action:q(({node:e})=>{let t=e.props.endpoint??``,n=e.props.icon,r=ka(e),i=Ge(),{variant:a,emphasis:o}=e.props,{processing:s,requestSubmit:c,overlays:l}=Aa(e),u=e.key??j(`action`,e.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(G,{className:i?Xe:void 0,"data-lattice-component":e.id,"data-test":u,disabled:s||!t,onClick:c,type:`button`,emphasis:i?`ghost`:o,variant:i?null:a,children:[s?(0,J.jsx)(ra,{className:i?`size-lt-icon-sm`:void 0}):n&&(0,J.jsx)(N,{className:i?`size-lt-icon-sm`:`size-lt-icon-md`,icon:n}),r]}),l]})}),"action.group":q(({children:e,node:t})=>{let{t:n}=w(`lattice`),r=t.props.label??n(`common.action-group.label`,`Actions`),i=t.props.orientation;return i?(0,J.jsx)(`div`,{"aria-label":r,className:P(`inline-flex max-w-full gap-1`,i===`vertical`?`flex-col items-stretch`:`flex-row flex-wrap items-center`),"data-lattice-component":t.id,role:`group`,children:e}):(0,J.jsx)(`div`,{className:`inline-flex`,"data-lattice-component":t.id,children:(0,J.jsxs)(Ne,{children:[(0,J.jsx)(Pe,{asChild:!0,children:(0,J.jsx)(G,{"aria-label":r,className:`size-lt-control-sm text-lt-muted-fg shadow-none hover:text-lt-fg`,"data-test":M(t),size:`icon`,type:`button`,emphasis:`ghost`,children:(0,J.jsx)(R,{name:`more-horizontal`,"aria-hidden":`true`,className:`size-lt-icon-md`})})}),(0,J.jsx)(Ue,{align:`end`,"aria-label":r,className:`min-w-44 gap-0.5 p-1.5`,sideOffset:8,children:(0,J.jsx)(Ie,{children:e})})]})})})},name:`lattice/action`});function Ra(e){try{return JSON.parse(e)}catch{return null}}async function*za({url:e,body:t,signal:n}){let r=await Vt(e,{method:`POST`,signal:n,headers:{Accept:`application/x-ndjson`},body:JSON.stringify(t),throwOnError:!1});if(!r.ok||!r.body)throw Error(`Chat stream failed (${r.status})`);yield*Va(r.body)}function Ba(e){return async function*({url:t,body:n,signal:r}){let i=await Jt(t,{remote:e,method:`POST`,signal:r,headers:{Accept:`application/x-ndjson`,"Content-Type":`application/json`},body:JSON.stringify(n),throwOnError:!1});if(!i.ok||!i.body)throw Error(`Chat stream failed (${i.status})`);yield*Va(i.body)}}async function*Va(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
3
- `);r=a.pop()??``;for(let e of a){if(e.trim()===``)continue;let t=Ra(e);t&&(yield t)}}if(r+=n.decode(),r.trim()!==``){let e=Ra(r);e&&(yield e)}}finally{await t.cancel().catch(()=>{})}}var Ha=0;function Ua(){return Ha+=1,`chat-${Ha}`}function Wa(e){return e instanceof DOMException&&e.name===`AbortError`}function Ga(e){return e instanceof Error?e.message:String(e)}function Ka(e){let t=e.at(-1);return t!==void 0&&t.role===`assistant`}function qa(e,t){if(!Ka(e))return e;let n=e.length-1,r=e[n];if(t.type===`text`){let i=[...r.parts],a=i.length-1,o=i[a];o!==void 0&&o.type===`chat.part.text`?i[a]={type:`chat.part.text`,props:{text:`${o.props.text}${t.value}`}}:i.push({type:`chat.part.text`,props:{text:t.value}});let s=[...e];return s[n]={...r,parts:i},s}if(t.type===`part`){let i=[...e];return i[n]={...r,parts:[...r.parts,t.part]},i}return e}function Ja({endpoint:e,transport:t=za,initialMessages:n=[],generateId:r=Ua}){let[i,a]=(0,K.useState)(n),[o,s]=(0,K.useState)(`idle`),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(null),d=(0,K.useRef)(null),f=(0,K.useRef)(i);f.current=i;let p=(0,K.useCallback)(e=>{f.current=e,a(e)},[]),m=(0,K.useCallback)(async(n,i)=>{u.current?.abort();let a=new AbortController;u.current=a,l(null),s(`submitted`);let o={id:r(),role:`user`,parts:[{type:`chat.part.text`,props:{text:i}}]},c={id:r(),role:`assistant`,parts:[]};p([...n,o,c]),s(`streaming`);try{for await(let n of t({url:e,body:{message:i},signal:a.signal})){if(n.type===`done`){s(`idle`);continue}if(n.type===`error`){l(n.message??`Chat failed`),s(`error`);continue}p(qa(f.current,n))}s(e=>e===`streaming`||e===`submitted`?`idle`:e)}catch(e){if(Wa(e)){s(`idle`);return}l(Ga(e)),s(`error`)}},[p,e,r,t]),h=(0,K.useCallback)(e=>{let t=e.trim();t!==``&&(d.current=t,m(f.current,t))},[m]),g=(0,K.useCallback)(()=>{u.current?.abort(),s(`idle`)},[]),_=(0,K.useCallback)(()=>{let e=d.current;if(e===null)return;let t=f.current,n=Ka(t)?t.slice(0,-2):t;m(n,e)},[m]);return(0,K.useEffect)(()=>()=>{u.current?.abort()},[]),{messages:i,status:o,error:c,sendMessage:h,setMessages:p,stop:g,regenerate:_}}function Ya({message:e}){let t=e.role===`user`;return(0,J.jsx)(`div`,{className:P(`flex flex-col gap-1`,t?`items-end`:`items-start`),"data-test":k(`chat-message-${e.role}`),children:(0,J.jsx)(`div`,{className:P(`max-w-[80%] rounded-lt px-3 py-2 text-sm`,t?`bg-lt-primary text-lt-primary-fg`:`bg-lt-muted text-lt-fg`),children:e.parts.map((e,t)=>(0,J.jsx)(En,{node:e},e.key??t))})})}function Xa({messages:e}){let t=(0,K.useRef)(null),n=e.at(-1),r=n?.parts.at(-1)===void 0?0:JSON.stringify(n.parts.at(-1)).length;return(0,K.useEffect)(()=>{t.current&&typeof t.current.scrollIntoView==`function`&&t.current.scrollIntoView({behavior:`smooth`})},[e.length,r]),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 overflow-y-auto p-3`,"data-test":k(`chat-messages`),children:[e.map(e=>(0,J.jsx)(Ya,{message:e},e.id)),(0,J.jsx)(`div`,{ref:t})]})}function Za({onSubmit:e,disabled:t=!1,placeholder:n}){let{t:r}=w(`lattice`),[i,a]=(0,K.useState)(``);function o(){let n=i.trim();n===``||t||(e(n),a(``))}function s(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),o())}return(0,J.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-lt-border p-3`,children:[(0,J.jsx)(`textarea`,{"aria-label":r(`common.chat.input-label`,`Message input`),className:P(`min-h-[2.5rem] flex-1 resize-none rounded-lt-sm border border-lt-input bg-lt-bg px-3 py-2 text-sm text-lt-fg placeholder:text-lt-muted-fg focus:outline-none focus:ring-[length:var(--lt-ring-width)] focus:ring-lt-ring/50 disabled:bg-lt-disabled disabled:text-lt-disabled-fg`),"data-test":k(`chat-input`),disabled:t,onChange:e=>a(e.target.value),onKeyDown:s,placeholder:n,rows:1,value:i}),(0,J.jsx)(G,{"data-test":k(`chat-send`),disabled:t,onClick:o,size:`sm`,type:`button`,children:r(`common.chat.send`,`Send`)})]})}var Qa=hn({name:`lattice/chat`,components:{"chat.box":q(({node:e})=>{let t=e.props,{t:n}=w(`lattice`),r=(0,K.useMemo)(()=>t.remote?Ba(t.remote):za,[t.remote]),{messages:i,status:a,error:o,sendMessage:s,setMessages:c}=Ja({endpoint:t.streamEndpoint??``,transport:r}),l=(0,K.useRef)(!1),u=(0,K.useCallback)(async()=>{if(l.current||!t.historyEndpoint)return;if(l.current=!0,t.remote){let e=await Yt(t.historyEndpoint,{remote:t.remote});c(e.messages);return}let e=await Vt(t.historyEndpoint,{throwOnError:!1});if(!e.ok)return;let n=await e.json();c(n.messages)},[t.historyEndpoint,t.remote,c]);(0,K.useEffect)(()=>{u().catch(()=>{})},[u]);let d=a===`submitted`||a===`streaming`||!t.streamEndpoint;return(0,J.jsxs)(`div`,{className:P(`flex flex-col overflow-hidden border border-lt-border bg-lt-bg`,t.fill?`sticky top-0 h-full min-h-[28rem] w-full`:`h-[28rem] w-80 rounded-lt shadow-lt-lg`),"data-test":k(`chat-box`),children:[(0,J.jsx)(`div`,{className:`flex items-center border-b border-lt-border px-3 py-2`,children:(0,J.jsx)(`span`,{className:`text-sm font-medium text-lt-fg`,children:t.title??n(`common.chat.title`,`Chat`)})}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,J.jsx)(Xa,{messages:i})}),o?(0,J.jsx)(`div`,{className:`border-t border-lt-danger/40 px-3 py-2 text-xs text-lt-danger`,children:o}):null,(0,J.jsx)(Za,{disabled:d,onSubmit:s,placeholder:t.placeholder??void 0})]})}),"chat.part.text":q(({node:e})=>(0,J.jsx)(`div`,{className:`whitespace-pre-wrap text-sm`,children:e.props.text})),"chat.part.tool-call":q(({node:e})=>(0,J.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-1 rounded-lt-sm bg-lt-muted px-2 py-0.5 font-mono text-xs text-lt-muted-fg`,"data-test":k(`chat-tool-call`),children:[`🔧 `,e.props.name,`(`,JSON.stringify(e.props.args),`)`]}))}}),$a={xs:`size-6 text-[0.5rem]`,sm:`size-8 text-xs`,md:`size-10 text-sm`,lg:`size-12 text-base`,xl:`size-16 text-lg`,"2xl":`size-20 text-xl`,"3xl":`size-24 text-2xl`,"4xl":`size-32 text-3xl`};function eo(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}function to(){return(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`size-[60%]`,children:[(0,J.jsx)(`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}),(0,J.jsx)(`circle`,{cx:`12`,cy:`7`,r:`4`})]})}var no=({node:e})=>{let{src:t,name:n,size:r}=e.props,i=n??void 0;return(0,J.jsx)(`span`,{"data-slot":`avatar`,role:t?void 0:`img`,"aria-label":t?void 0:i,className:P(`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-lt-muted font-medium text-lt-muted-fg select-none`,$a[r]),children:t?(0,J.jsx)(`img`,{src:t,alt:i??``,className:`size-full object-cover`}):n?eo(n):(0,J.jsx)(to,{})})};function ro({color:e,className:t,style:n,...r}){let i=St(Ct(e??void 0)??yt(`gray`));return(0,J.jsx)(`span`,{"data-slot":`badge`,className:P(`lt-badge`,i.className,t),style:{...i.style,...n},...r})}var io=({node:e})=>(0,J.jsx)(ro,{color:e.props.color,children:e.props.label});function ao({className:e,...t}){return(0,J.jsx)(`article`,{"data-slot":`card`,className:P(`flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-lt-gutter text-lt-surface-fg shadow-lt-sm`,e),...t})}function oo({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-header`,className:P(`flex flex-col gap-1.5 px-lt-gutter`,e),...t})}function so({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-title`,className:P(`font-semibold leading-none`,e),...t})}function co({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-description`,className:P(`text-sm text-lt-muted-fg`,e),...t})}function lo({className:e,...t}){return(0,J.jsx)(`div`,{"data-slot":`card-content`,className:P(`px-lt-gutter`,e),...t})}var uo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props;return(0,J.jsxs)(ao,{"data-lattice-component":M(t),children:[(n||r)&&(0,J.jsxs)(oo,{children:[n&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(so,{children:n}),(0,J.jsx)(et,{content:i})]}),r&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(co,{children:r}),!n&&(0,J.jsx)(et,{content:i})]})]}),e&&(0,J.jsx)(lo,{className:`flex flex-col gap-6`,children:e})]})},fo=(0,K.lazy)(()=>$t(()=>import(`./chunks/chart-view-ZCTbih8A.js`),__vite__mapDeps([9,1,4,2,10,6,11,12,13]),import.meta.url)),po=({children:e,node:t})=>(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(fo,{node:t,children:e})}),mo=({children:e,node:t})=>{let n=t.props.rememberState!==!1,r=bn(t.props.trigger),i=M(t),a=`lattice:collapsible:${i??`default`}`,o=`${i??`collapsible`}-content`,[s,c]=li(a,t.props.collapsed===!1,n);return(0,J.jsxs)(`div`,{"data-slot":`collapsible`,"data-lattice-component":i,children:[(0,J.jsxs)(`div`,{"aria-controls":o,"aria-expanded":s,"data-test":j(`collapsible-toggle`,i)??`collapsible-toggle-default`,className:`flex w-full cursor-pointer items-center justify-between gap-4 rounded-lt-sm py-2 text-left text-lt-fg transition-colors hover:bg-lt-muted`,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},role:`button`,tabIndex:0,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,J.jsx)(Y,{nodes:r}),t.props.tooltip&&(0,J.jsx)(`span`,{role:`presentation`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,J.jsx)(et,{content:t.props.tooltip})})]}),(0,J.jsx)(R,{name:`chevron-down`,className:P(`size-lt-icon-md shrink-0 text-lt-muted-fg transition-transform`,!s&&`-rotate-90`)})]}),s&&e&&(0,J.jsx)(`div`,{id:o,className:`flex flex-col gap-4 pt-2`,children:e})]})};function ho(e,t){return e===`top-start`?{left:t,top:t}:e===`top-end`?{right:t,top:t}:e===`bottom-start`?{bottom:t,left:t}:{bottom:t,right:t}}var go=({children:e,node:t})=>{let n=t.props.label??void 0,r=Math.max(0,t.props.offset??16),i=t.props.placement??`bottom-end`,a=t.props.trigger??[],[o,s]=(0,K.useState)(!1);if(a.length===0)return(0,J.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)] rounded-lt border border-lt-border bg-lt-popover p-1 text-lt-popover-fg shadow-lt-md`,"data-lattice-component":M(t),role:n?`group`:void 0,style:ho(i,r),children:e});let c=i===`bottom-start`||i===`bottom-end`,l=i===`top-start`||i===`bottom-start`;return(0,J.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)]`,"data-lattice-component":M(t),role:n?`group`:void 0,style:ho(i,r),children:(0,J.jsxs)(`div`,{className:P(`flex w-fit gap-2`,c?`flex-col-reverse`:`flex-col`),children:[(0,J.jsx)(`button`,{"aria-expanded":o,className:P(`inline-flex items-center gap-2 rounded-lt border border-lt-border bg-lt-popover px-3 py-1.5 text-sm font-medium text-lt-popover-fg shadow-lt-md hover:bg-lt-muted`,l?`self-start`:`self-end`),"data-test":t.key?`${t.key}-trigger`:void 0,onClick:()=>s(e=>!e),type:`button`,children:a.map((e,t)=>(0,J.jsx)(En,{node:e},e.key??`${e.type}-${t}`))}),(0,J.jsx)(`div`,{className:o?`block`:`hidden`,children:e})]})})},_o={lg:320,md:64,sm:40,xl:384,xs:32,"2xl":448,"3xl":512,"4xl":576},vo=({node:e})=>{let t=e.props.endpoint??``,n=e.props.lazy===!0,r=e.props.ref??``,a=_o[e.props.size],[o,s]=(0,K.useState)(()=>e.schema??[]),[c,l]=(0,K.useState)(!n),[u,d]=(0,K.useState)(n&&t!==``),f=(0,K.useCallback)(async()=>{if(t){d(!0);try{let e=await Ht(t,{ref:r});s(bn(e.schema)),l(!0)}finally{d(!1)}}},[t,r]);return(0,K.useEffect)(()=>{!n||c||f()},[c,n,f]),(0,K.useEffect)(()=>{function t(t){t.detail?.component===e.id&&f()}return window.addEventListener(i.reloadComponent,t),()=>window.removeEventListener(i.reloadComponent,t)},[f,e.id]),(0,K.useEffect)(()=>{function e(){c&&f()}return window.addEventListener(i.localeChange,e),()=>window.removeEventListener(i.localeChange,e)},[c,f]),(0,J.jsx)(`div`,{"data-lattice-fragment":e.id,style:u&&o.length===0?{minHeight:a}:void 0,children:u&&o.length===0?(0,J.jsx)(oa,{className:`w-full`,style:{height:a}}):(0,J.jsx)(Y,{nodes:o})})},yo=({children:e,node:t})=>{let n=Math.min(Math.max(t.props.columns??1,1),4);return(0,J.jsx)(`div`,{"data-slot":`grid`,"data-lattice-component":M(t),className:P(`grid gap-x-4 gap-y-6`,n>=2&&`md:grid-cols-2`,n>=3&&`lg:grid-cols-3`,n>=4&&`xl:grid-cols-4`),children:e})};async function bo(e){if(!navigator?.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function xo({value:e,label:t,testId:n,className:r}){let{t:i}=w(`lattice`),[a,o]=(0,K.useState)(!1);(0,K.useEffect)(()=>{if(!a)return;let e=window.setTimeout(()=>o(!1),1500);return()=>window.clearTimeout(e)},[a]);function s(){bo(e),o(!0)}let c=a?i(`common.copied-value`,`Copied {{label}}`,{label:t}):i(`common.copy-value`,`Copy {{label}}`,{label:t});return(0,J.jsxs)(`button`,{type:`button`,"data-test":n,className:P(`inline-flex items-center gap-1 rounded-lt-sm border border-lt-border px-2 py-1 text-xs`,r),"aria-label":c,onClick:s,children:[(0,J.jsx)(R,{name:a?`check`:`copy`,className:`size-lt-icon-xs`}),a?i(`common.copied`,`Copied`):i(`common.copy`,`Copy`)]})}function So({value:e,label:t,testId:n,children:r}){return(0,J.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[r??e,(0,J.jsx)(xo,{value:e,label:t,testId:n})]})}var Co=({node:e})=>{let{text:t,tooltip:n}=e.props,r=Math.min(Math.max(e.props.level,1),6),i=P(`max-w-3xl font-semibold tracking-normal text-balance text-lt-fg`,r===1&&`text-2xl font-bold leading-tight`,r===2&&`text-xl`,r>2&&`text-base`),a=(0,J.jsxs)(J.Fragment,{children:[t,(0,J.jsx)(et,{content:n})]}),o;switch(r){case 1:o=(0,J.jsx)(`h1`,{className:i,children:a});break;case 2:o=(0,J.jsx)(`h2`,{className:i,children:a});break;case 3:o=(0,J.jsx)(`h3`,{className:i,children:a});break;case 4:o=(0,J.jsx)(`h4`,{className:i,children:a});break;case 5:o=(0,J.jsx)(`h5`,{className:i,children:a});break;default:o=(0,J.jsx)(`h6`,{className:i,children:a})}return e.props.copyable?(0,J.jsx)(So,{value:t,label:t,children:o}):o},wo={xs:`size-lt-icon-xs`,sm:`size-lt-icon-sm`,md:`size-lt-icon-md`,lg:`size-lt-icon-lg`,xl:`size-lt-icon-xl`,"2xl":`size-lt-icon-2xl`,"3xl":`size-lt-icon-3xl`,"4xl":`size-lt-icon-4xl`},To=({node:e})=>{let{name:t,size:n,color:r,class:i}=e.props,a=(0,J.jsx)(N,{icon:t,className:P(wo[n],i)}),o=Ct(r);return o?(0,J.jsx)(`span`,{className:`contents`,style:{color:bt(o)},children:a}):a};function Eo({src:e,alt:t,previewable:n,width:r,height:i,className:a,testId:o}){let{t:s}=w(`lattice`),[c,l]=(0,K.useState)(!1),u=(0,J.jsx)(`img`,{alt:t,src:e,width:r,height:i,className:a,style:r?{width:r,height:i}:void 0});if(!n)return u;let d=s(`common.image.open-preview`,`View image`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"data-test":o,className:`cursor-zoom-in`,"aria-label":d,onClick:()=>l(!0),children:u}),(0,J.jsx)(Zi,{open:c,onOpenChange:l,children:(0,J.jsxs)(ta,{"aria-describedby":void 0,className:`max-h-[90vh] w-auto max-w-[90vw] border-none bg-transparent p-0 shadow-none`,children:[(0,J.jsx)($i,{className:`sr-only`,children:t||d}),(0,J.jsx)(`img`,{alt:t,src:e,"data-slot":`image-lightbox`,className:`max-h-[90vh] max-w-[90vw] rounded-lt object-contain`}),(0,J.jsx)(Qi,{asChild:!0,children:(0,J.jsx)(G,{icon:`x`,"aria-label":s(`common.close`,`Close`),"data-test":`lightbox-close`,size:`icon`,emphasis:`ghost`,className:`absolute top-2 right-2 bg-lt-bg/80 hover:bg-lt-bg`})})]})})]})}var Do=({node:e})=>{let{src:t,alt:n,size:r,circular:i,previewable:a}=e.props;return(0,J.jsx)(Eo,{alt:n??``,className:P(`object-cover`,i?`rounded-full`:`rounded-lt-sm`),height:r??void 0,previewable:a,src:t,testId:M(e),width:r??void 0})};function Oo(e,t){let n=e.detail?.modal;return n==null||n===t}var ko=({children:e,node:t})=>{let{t:n}=w(`lattice`),r=t.props.title??n(`common.dialog`,`Dialog`),a=t.props.description,o=t.props.closeLabel,[s,c]=(0,K.useState)(t.props.open===!0),l=(0,K.useRef)(null),u=(0,K.useRef)(s);return(0,K.useEffect)(()=>{t.props.open===!0&&c(!0)},[t.props.open]),(0,K.useEffect)(()=>{function e(e){t.id&&Oo(e,t.id)&&(l.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(!0))}function n(e){(!t.id||Oo(e,t.id))&&c(!1)}return window.addEventListener(i.openModal,e),window.addEventListener(i.closeModal,n),()=>{window.removeEventListener(i.openModal,e),window.removeEventListener(i.closeModal,n)}},[t.id]),(0,K.useEffect)(()=>{if(u.current&&!s){let e=l.current;e&&requestAnimationFrame(()=>e.focus())}u.current=s},[s]),(0,J.jsx)(Zi,{open:s,onOpenChange:c,children:(0,J.jsxs)(ta,{...a?{}:{"aria-describedby":void 0},placement:t.props.side??`center`,width:t.props.width,children:[(0,J.jsx)(na,{closeLabel:o,description:a,title:r}),(0,J.jsx)(`div`,{className:`mt-6 space-y-6`,children:e})]})})},Ao={xs:`h-1`,sm:`h-1.5`,md:`h-2.5`,lg:`h-3`,xl:`h-4`,"2xl":`h-5`,"3xl":`h-6`,"4xl":`h-8`},jo={xs:24,sm:32,md:40,lg:48,xl:64,"2xl":80,"3xl":96,"4xl":128},Mo={xs:`text-[0.5rem]`,sm:`text-[0.625rem]`,md:`text-xs`,lg:`text-sm`,xl:`text-base`,"2xl":`text-lg`,"3xl":`text-xl`,"4xl":`text-2xl`},No=({node:e})=>{let{value:t,max:r,shape:i,showValue:a,color:o,size:s}=e.props,{locale:c}=n(),l=bt(Ct(o)??yt(`primary`)),u=r>0?Math.min(Math.max(t,0),r):0,d=r>0?u/r:0,f=new Intl.NumberFormat(c,{maximumFractionDigits:0,style:`percent`}).format(d),p={"aria-valuemax":r,"aria-valuemin":0,"aria-valuenow":u,"aria-valuetext":f,role:`progressbar`};if(i===`circle`){let e=jo[s],t=Math.max(3,e/10),n=(e-t)/2,r=2*Math.PI*n;return(0,J.jsxs)(`div`,{...p,className:`relative inline-flex`,"data-lattice-progress":`circle`,children:[(0,J.jsxs)(`svg`,{className:`-rotate-90`,height:e,width:e,children:[(0,J.jsx)(`circle`,{className:`text-lt-muted`,cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeWidth:t}),(0,J.jsx)(`circle`,{cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeDasharray:r,strokeDashoffset:r*(1-d),strokeLinecap:`round`,strokeWidth:t,style:{color:l}})]}),a&&(0,J.jsx)(`span`,{className:P(`absolute inset-0 flex items-center justify-center font-medium text-lt-fg tabular-nums`,Mo[s]),children:f})]})}return(0,J.jsxs)(`div`,{className:`flex w-full items-center gap-2`,"data-lattice-progress":`bar`,children:[(0,J.jsx)(`div`,{...p,className:P(`w-full overflow-hidden rounded-full bg-lt-muted`,Ao[s]),children:(0,J.jsx)(`div`,{className:`h-full rounded-full`,style:{background:l,width:`${d*100}%`}})}),a&&(0,J.jsx)(`span`,{className:`shrink-0 text-lt-muted-fg text-sm tabular-nums`,children:f})]})},Po=({node:e})=>(0,J.jsx)(`span`,{style:{display:`contents`},dangerouslySetInnerHTML:{__html:e.props.html}}),Fo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props,a=t.props.collapsible===!0,o=t.props.rememberState!==!1,s=bn(t.props.headerActions),c=M(t),[l,u]=li(`lattice:section:${c??`default`}`,t.props.collapsed===!0,a&&o),d=a&&l,f=!!(n||r||s.length>0||a);return(0,J.jsxs)(`section`,{"data-slot":`section`,className:`flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-lt-gutter text-lt-surface-fg shadow-lt-sm`,"data-lattice-component":c,children:[f&&(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-lt-gutter`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[a&&(0,J.jsx)(`button`,{"aria-expanded":!d,"aria-label":d?`Expand section`:`Collapse section`,"data-test":j(`section-toggle`,c)??`section-toggle-default`,className:`mt-0.5 inline-flex shrink-0 items-center rounded-lt-sm p-0.5 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,onClick:u,type:`button`,children:(0,J.jsx)(R,{name:`chevron-down`,className:P(`size-lt-icon-md transition-transform`,d&&`-rotate-90`)})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[n&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(`div`,{className:`font-semibold leading-none`,children:n}),(0,J.jsx)(et,{content:i})]}),r&&(0,J.jsxs)(`div`,{className:`flex items-center`,children:[(0,J.jsx)(`div`,{className:`text-sm text-lt-muted-fg`,children:r}),!n&&(0,J.jsx)(et,{content:i})]})]})]}),s.length>0&&(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,J.jsx)(Y,{nodes:s})})]}),!d&&e&&(0,J.jsx)(`div`,{className:`flex flex-col gap-6 px-lt-gutter`,children:e})]})};function Io(e){return P(`whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors`,e?`bg-lt-bg text-lt-fg shadow-lt-xs`:`text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg`)}function Lo({ariaLabel:e,autoFocus:t=!1,disabled:n=!1,name:r,onSelect:i,options:a,tabIndex:o,value:s}){let c=(0,K.useRef)(null);return(0,K.useEffect)(()=>{if(!t)return;let e=c.current;(e?.querySelector(`button[aria-checked="true"]`)??e?.querySelector(`button`))?.focus()},[t]),(0,J.jsx)(`div`,{"aria-label":e,className:`inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1`,ref:c,role:`radiogroup`,children:a.map(e=>{let t=s===e.value;return(0,J.jsx)(`button`,{"aria-checked":t,"data-test":`${r??`segment`}-${e.value}`,className:P(Io(t),n&&`cursor-not-allowed opacity-60`),disabled:n,onClick:()=>i(e.value),role:`radio`,tabIndex:o,type:`button`,children:e.label},e.value)})})}var Ro=({node:e})=>{let{options:t,name:n,emits:r}=e.props,[i,a]=(0,K.useState)(e.props.value||t[0]?.value||``);if(t.length===0)return null;function o(e){a(e),r&&window.dispatchEvent(new CustomEvent(r,{detail:{name:n,value:e}}))}return(0,J.jsx)(Lo,{ariaLabel:e.props.label??void 0,name:n,onSelect:o,options:t,value:i})},zo=({node:e})=>{let t=e.props.orientation===`horizontal`;return(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":e.props.orientation,className:P(`shrink-0 bg-lt-border`,t?`h-px w-full`:`h-full w-px self-stretch`)})},Bo={center:`justify-items-center text-center`,start:`justify-items-start text-left`,stretch:`justify-items-stretch`},Vo={center:`items-center text-center`,start:`items-center text-left`,stretch:`items-stretch justify-stretch`},Ho={none:`gap-0`,xs:`gap-1`,lg:`gap-6`,md:`gap-4`,sm:`gap-2`,xl:`gap-8`},Uo={auto:`w-auto`,fill:`min-w-0 flex-1`,full:`w-full`,lg:`mx-auto w-full max-w-4xl`,md:`mx-auto w-full max-w-2xl`,sm:`mx-auto w-full max-w-md`},Wo={around:`justify-around`,between:`justify-between`,center:`justify-center`,end:`justify-end`,evenly:`justify-evenly`,start:`justify-start`},Go={full:`h-full`,screen:`min-h-screen`},Ko={end:`ml-auto`,start:`mr-auto`},qo=({children:e,node:t})=>{let n=t.props.align??`stretch`,r=t.props.direction??`column`,i=t.props.gap??`md`,a=t.props.width??`full`,o=t.props.justify,s=t.props.height,c=t.props.float,l=r===`row`||o!=null;return(0,J.jsx)(`div`,{"data-slot":`stack`,"data-lattice-component":M(t),className:P(l?P(`flex`,r===`row`?`flex-wrap`:`flex-col`):`grid content-start`,l?Vo[n]??Vo.stretch:Bo[n]??Bo.stretch,Ho[i]??Ho.md,Uo[a]??Uo.full,o?Wo[o]:null,s?Go[s]:null,c?Ko[c]:null),children:e})},Jo=(0,K.createContext)(null);function Yo(){return(0,K.useContext)(Jo)||{activeValue:``,setActiveValue:()=>{}}}function Xo(e){return(e.schema??[]).filter(e=>e.type===`tab`).map(e=>{let t=e.props;return{confirm:t.confirm?{required:t.confirm.required}:void 0,label:t.label,value:t.value}}).filter(e=>e.value!==``)}function Zo(e,t){if(typeof window>`u`)return null;let n=new URLSearchParams(window.location.search).get(e);return!n||!t.some(e=>e.value===n)?null:n}function Qo(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href);n.searchParams.set(e,t),window.history.replaceState(window.history.state,``,`${n.pathname}${n.search}${n.hash}`)}function $o(e,t){if(typeof window>`u`)return``;let n=new URL(window.location.href);return n.searchParams.set(e,t),`${n.pathname}${n.search}${n.hash}`}var es=({children:e,node:t})=>{let{t:n}=w(`lattice`),r=(0,K.useMemo)(()=>Xo(t),[t]),i=r[0]?.value??``,a=t.props.queryKey,o=t.props.orientation,s=o===`vertical`,c=t.props.alignment,l=!s&&c===`stretch`,u=t.props.activeValue,d=t.props.defaultValue??i,f=(0,K.useRef)(null),[m,h]=(0,K.useState)(()=>u||(Zo(a,r)??d)||i),g=(0,K.useCallback)(e=>{if(e.confirm?.required){p.visit($o(a,e.value),{preserveScroll:!0});return}h(e.value),Qo(a,e.value)},[a]),_=(0,K.useCallback)(e=>{let t=r.find(t=>t.value===e);t&&g(t)},[g,r]),v=(0,K.useMemo)(()=>({activeValue:m,setActiveValue:_}),[m,_]);function y(e){let t=s?`ArrowDown`:`ArrowRight`,n=s?`ArrowUp`:`ArrowLeft`;if(e.key!==t&&e.key!==n&&e.key!==`Home`&&e.key!==`End`)return;let r=Array.from(f.current?.querySelectorAll(`[role="tab"]`)??[]);if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement),a;if(e.key===`Home`)a=0;else if(e.key===`End`)a=r.length-1;else{let n=e.key===t?1:-1;a=((i<0?0:i)+n+r.length)%r.length}r[a]?.focus()}return(0,J.jsx)(Jo.Provider,{value:v,children:(0,J.jsxs)(`div`,{className:P(`gap-6`,s?P(`flex`,c===`end`&&`flex-row-reverse`):`grid`),"data-lattice-tabs":t.key??t.id,children:[(0,J.jsx)(`div`,{"aria-label":n(`common.tabs`,`Tabs`),"aria-orientation":o,className:P(`gap-1 rounded-lt bg-lt-muted p-1`,s&&`flex flex-col`,l&&`flex w-full`,!s&&!l&&P(`inline-flex w-fit max-w-full overflow-x-auto`,{"justify-self-center":c===`center`,"justify-self-end":c===`end`})),ref:f,role:`tablist`,children:r.map(e=>{let t=m===e.value;return(0,J.jsx)(`button`,{"aria-controls":`${e.value}-panel`,"aria-selected":t,"data-test":`tab-${e.value}`,className:P(Io(t),s&&`text-left`,l&&`flex-1`),id:`${e.value}-tab`,onClick:()=>g(e),onKeyDown:y,role:`tab`,tabIndex:t?0:-1,type:`button`,children:e.label},e.value)})}),(0,J.jsx)(`div`,{className:P(`min-w-0`,s&&`flex-1`),children:e})]})})},ts=({children:e,node:t})=>{let{activeValue:n}=Yo(),r=t.props.value,i=n===r,[a,o]=(0,K.useState)(i);return(0,K.useEffect)(()=>{i&&o(!0)},[i]),(0,J.jsx)(`section`,{"aria-labelledby":`${r}-tab`,className:P(`space-y-8`,!i&&`hidden`),hidden:!i,id:`${r}-panel`,role:`tabpanel`,tabIndex:0,children:a?e:null})},ns={center:`text-center`,left:`text-left`},rs={xs:`text-xs leading-5`,sm:`text-sm leading-6`,md:`text-base leading-7`,lg:`text-lg leading-8`,xl:`text-xl leading-8`,"2xl":`text-2xl leading-9`,"3xl":`text-3xl leading-10`,"4xl":`text-4xl leading-none`},is=hn({components:{avatar:q(no),badge:q(io),button:q(pt),card:q(uo),chart:q(po),collapsible:q(mo),"floating-panel":q(go),fragment:q(vo),grid:q(yo),heading:q(Co),icon:q(To),image:q(Do),link:q(Je),modal:q(ko),progress:q(No),"raw-block":q(Po),section:q(Fo),"segmented-control":q(Ro),separator:q(zo),stack:q(qo),tab:q(ts),tabs:q(es),text:q(({node:e})=>{let t=e.props.align??`left`,n=bt(Ct(e.props.color)??yt(`muted`)),r=(0,J.jsx)(`p`,{className:P(`m-0`,`max-w-2xl`,ns[t]??ns.left,rs[e.props.size]),style:{color:n},children:e.props.text});return e.props.copyable?(0,J.jsx)(So,{value:e.props.text,label:e.props.text,children:r}):r}),tooltip:q(({node:e})=>{let t=e.props.content,n=bn(e.props.trigger);return t?n.length===0?(0,J.jsx)(et,{content:t}):(0,J.jsxs)(Te,{children:[(0,J.jsx)(V,{type:`button`,className:`inline-flex items-center rounded-lt-sm outline-none focus-visible:ring-lt-ring/50 focus-visible:ring-[length:var(--lt-ring-width)]`,children:(0,J.jsx)(Y,{nodes:n})}),(0,J.jsx)(B,{align:`start`,className:`max-w-xs p-3 text-sm [&_a]:underline`,dangerouslySetInnerHTML:{__html:t}})]}):null})},name:`lattice/ui`});function as({addLabel:e,options:t,onSelect:n}){return(0,J.jsxs)(Ne,{children:[(0,J.jsx)(Pe,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,"data-test":`builder-add`,className:`inline-flex items-center gap-1.5 self-start rounded-lt-sm border border-lt-border px-3 py-1.5 text-sm hover:bg-lt-accent [&_svg]:size-lt-icon-sm`,children:[(0,J.jsx)(R,{name:`plus`}),e]})}),(0,J.jsx)(Ue,{align:`start`,className:`min-w-[12rem]`,children:t.map(e=>(0,J.jsx)(it,{"data-test":`builder-add-${e.type}`,onClick:()=>n(e.type),children:e.label},e.type))})]})}var os={duplicate:{key:`table.row-actions.duplicate`,fallback:`Duplicate`,icon:`copy`},remove:{key:`table.row-actions.remove`,fallback:`Remove`,icon:`trash-2`}};function ss(e,t){return(e??cs(t.removable)).map(e=>ls(e,t)).filter(e=>e!==null)}function cs(e){return e?[{type:`remove`,key:`remove`,label:null,icon:null,danger:!0}]:[]}function ls(e,t){if(e.type===`duplicate`){let n=os.duplicate;return{key:e.key,label:e.label??t.t(n.key,n.fallback),icon:e.icon??n.icon,danger:e.danger,onClick:()=>t.onDuplicate(t.index)}}if(e.type===`remove`){if(!t.removable)return null;let n=os.remove;return{key:e.key,label:e.label??t.t(n.key,n.fallback),icon:e.icon??n.icon,danger:e.danger,onClick:()=>t.onRemove(t.index)}}return null}function us(e){return e?`text-lt-danger hover:text-lt-danger [&_svg]:size-lt-icon-sm`:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm`}function ds({actions:e}){let{t}=w(`lattice`);if(e.length===0)return null;if(e.length===1){let t=e[0];return(0,J.jsx)(`button`,{type:`button`,"aria-label":t.label,"data-test":`row-action-${t.key}`,className:us(t.danger),onClick:t.onClick,children:(0,J.jsx)(R,{name:t.icon})})}return(0,J.jsxs)(Ne,{children:[(0,J.jsx)(Pe,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":t(`common.action-group.label`,`Actions`),"data-test":`row-actions-menu`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm`,children:(0,J.jsx)(R,{name:`more-horizontal`})})}),(0,J.jsx)(Ue,{align:`end`,className:`min-w-[10rem]`,children:e.map(e=>(0,J.jsx)(it,{"data-test":`row-action-${e.key}`,danger:e.danger,icon:e.icon,onClick:e.onClick,children:e.label},e.key))})]})}function fs({path:e,rows:t,rowKey:n}){return(0,J.jsx)(J.Fragment,{children:t.map((t,r)=>(0,J.jsx)(`input`,{type:`hidden`,name:he(ye(e,r,n)),value:String(t[n]??``)},String(t.rowId??r)))})}function ps({label:e,testId:t,onClick:n,children:r}){return(0,J.jsx)(`button`,{type:`button`,"aria-label":e,"data-test":t,className:`text-lt-muted-fg hover:text-lt-fg`,onClick:n,children:r})}var ms=(0,K.memo)(function({base:e,index:t,row:n,template:r,heading:i,reorderable:a,isFirst:o,isLast:s,removable:c,rowActions:l,onField:u,onRemove:d,onMove:f,onDuplicate:p}){let{t:m}=w(`lattice`);return(0,J.jsxs)(`div`,{"data-test":`repeater-${e}-row-${t}`,className:`rounded-lt border border-lt-border bg-lt-surface p-4`,children:[(0,J.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-lt-muted-fg`,children:i}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[a&&!o&&(0,J.jsx)(ps,{label:`Move up`,testId:`repeater-${e}-up-${t}`,onClick:()=>f(t,-1),children:(0,J.jsx)(R,{name:`arrow-up`})}),a&&!s&&(0,J.jsx)(ps,{label:`Move down`,testId:`repeater-${e}-down-${t}`,onClick:()=>f(t,1),children:(0,J.jsx)(R,{name:`arrow-down`})}),(0,J.jsx)(ds,{actions:ss(l,{index:t,removable:c,onRemove:d,onDuplicate:p,t:m})})]})]}),(0,J.jsx)(ce,{base:e,index:t,row:n,onChange:(e,n)=>u(t,e,n),children:(0,J.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,J.jsx)(En,{node:e},xn(e,t)))})})]})}),hs={xs:{track:`minmax(4rem, 0.35fr)`,minPx:64,defaultPx:96,maxPx:1024},sm:{track:`minmax(6rem, 0.5fr)`,minPx:96,defaultPx:128,maxPx:1024},md:{track:`minmax(8rem, 1fr)`,minPx:128,defaultPx:176,maxPx:1024},lg:{track:`minmax(12rem, 1.5fr)`,minPx:192,defaultPx:240,maxPx:1024},xl:{track:`minmax(16rem, 2fr)`,minPx:256,defaultPx:320,maxPx:1024}};function gs(e){return hs[e].track}function _s(e){return hs[e.width].minPx}function vs(e){return hs[e.width].defaultPx}function ys(e){return hs[e.width].maxPx}function bs({columns:e,leadingTracks:t=[],trailingTracks:n=[],overrides:r={}}){return[...t,...e.map(e=>{let t=r[e.key];return t===void 0?gs(e.width):`${Math.min(ys(e),Math.max(_s(e),t))}px`}),...n].join(` `)}var xs=[];function Ss({columnGapPx:e=0,columns:t,enabled:n,leadingTracks:r=xs,showIndicator:i=!1,storageKey:a,trailingTracks:o=xs}){let s=(0,K.useMemo)(()=>t.map(e=>e.key),[t]),[c,l]=(0,K.useState)(()=>ws(a,t)),u=(0,K.useRef)(c),d=(0,K.useRef)(null),f=(0,K.useRef)(null),p=(0,K.useCallback)(e=>bs({columns:t,leadingTracks:r,trailingTracks:o,overrides:n?e:{}}),[t,n,r,o]),m=(0,K.useMemo)(()=>p(c),[c,p]),h=(0,K.useCallback)(e=>{let t=f.current;t&&(t.style.gridTemplateColumns=e,t.style.setProperty(`--lattice-table-columns`,e))},[]),g=(0,K.useCallback)(e=>{u.current=e,l(e),Ts(a,s,e),h(p(e))},[h,s,a,p]),_=(0,K.useCallback)((e,t,n,r)=>({...e,[t.key]:Math.min(r??ys(t),Math.max(_s(t),n))}),[]),v=(0,K.useCallback)((e,t,n)=>{g(_(u.current,e,t,n))},[g,_]),y=(0,K.useCallback)(e=>{let t={...u.current};delete t[e.key],g(t)},[g]),b=(0,K.useCallback)(()=>{g({})},[g]),x=n&&Object.values(c).some(e=>typeof e==`number`),S=(0,K.useCallback)(e=>u.current[e.key]??vs(e),[]);return{getResizeHandleProps:(0,K.useCallback)(a=>{let s=ys(a),c=_s(a),l=S(a),m=a.label??a.key,b=i?`after:bg-lt-border`:`after:bg-transparent`,x=n=>Cs({column:a,columnGapPx:e,columns:t,grid:f.current??n.parentElement?.parentElement,leadingTracks:r,trailingTracks:o}),C=(e,t)=>v(a,l+t,x(e)),w=(e,t)=>{let n=d.current;n?.key===a.key&&(d.current=null,n.overrides!==null&&g(n.overrides),t&&e.currentTarget.releasePointerCapture?.(e.pointerId))};return{"aria-label":`Resize ${m}`,"aria-orientation":`vertical`,"aria-valuemax":s,"aria-valuemin":c,"aria-valuenow":l,className:`absolute inset-y-0 right-0 hidden w-2 cursor-col-resize touch-none items-stretch justify-center md:flex after:my-1 after:w-px ${b} hover:after:bg-lt-border focus-visible:outline-none focus-visible:after:bg-lt-ring`,onDoubleClick:()=>y(a),onKeyDown:e=>{if(!n)return;let t=e.shiftKey?32:8;if(e.key===`ArrowLeft`&&(e.preventDefault(),C(e.currentTarget,-t)),e.key===`ArrowRight`&&(e.preventDefault(),C(e.currentTarget,t)),e.key===`Home`&&(e.preventDefault(),v(a,c)),e.key===`End`){e.preventDefault();let t=x(e.currentTarget);v(a,t,t)}(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),y(a))},onPointerDown:e=>{if(!n)return;let t=e.currentTarget.parentElement?.getBoundingClientRect().width??0;d.current={key:a.key,maxWidth:x(e.currentTarget),overrides:null,startWidth:t>0?t:l,startX:e.clientX},e.currentTarget.setPointerCapture?.(e.pointerId),e.preventDefault()},onPointerMove:e=>{let t=d.current;if(!n||t?.key!==a.key)return;let r=_(u.current,a,t.startWidth+e.clientX-t.startX,t.maxWidth);t.overrides=r,u.current=r,h(p(r))},onPointerUp:e=>{w(e,!0)},onPointerCancel:e=>{w(e,!0)},onLostPointerCapture:e=>{w(e,!1)},role:`separator`,tabIndex:0}},[e,t,S,n,r,h,g,_,y,v,i,p,o]),gridTemplateColumns:m,hasOverrides:x,resizeRootRef:f,resetColumns:b,resetColumnWidth:y}}function Cs({column:e,columnGapPx:t,columns:n,grid:r,leadingTracks:i,trailingTracks:a}){let o=r?.getBoundingClientRect().width??0;if(o<=0)return ys(e);let s=[...i,...a].reduce((e,t)=>e+ks(t),0),c=n.reduce((t,n)=>n.key===e.key?t:t+_s(n),0),l=n.length+i.length+a.length,u=Math.max(0,l-1)*t,d=o-s-c-u;return Math.min(ys(e),Math.max(_s(e),d))}function ws(e,t){if(!e||typeof window>`u`)return{};try{let n=window.localStorage.getItem(e);if(n===null)return{};let r=JSON.parse(n);if(!Ds(r))return Es(e),{};let i=Os(r.overrides,t);return Object.keys(i).length===0&&Es(e),i}catch{return Es(e),{}}}function Ts(e,t,n){if(!e||typeof window>`u`)return;let r={},i=new Set(t);for(let[e,t]of Object.entries(n))i.has(e)&&typeof t==`number`&&Number.isFinite(t)&&(r[e]=t);if(Object.keys(r).length===0){Es(e);return}try{window.localStorage.setItem(e,JSON.stringify({columns:t,overrides:r}))}catch{return}}function Es(e){if(!(typeof window>`u`))try{window.localStorage.removeItem(e)}catch{return}}function Ds(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.columns)&&t.columns.every(e=>typeof e==`string`)&&typeof t.overrides==`object`&&t.overrides!==null&&!Array.isArray(t.overrides)}function Os(e,t){let n={};for(let r of t){let t=e[r.key];typeof t!=`number`||!Number.isFinite(t)||(n[r.key]=Math.min(ys(r),Math.max(_s(r),t)))}return n}function ks(e){let t=e.trim(),n=t.match(/^([0-9.]+)px$/);if(n)return Number.parseFloat(n[1]);let r=t.match(/^([0-9.]+)rem$/);return r?Number.parseFloat(r[1])*As():0}function As(){if(typeof window>`u`)return 16;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:16}var js=`3rem`,Ms=`3rem`,Ns=[js],Ps=[Ms],Fs=`(min-width: 768px)`;function Is(){return si(Fs,!0)}function Ls(e){return e.map(e=>{let t=e.props;return{name:String(t.name),label:String(t.label??t.name),columnWidth:t.columnWidth??`md`}})}var Rs=(0,K.memo)(function({base:e,index:t,row:n,template:r,span:i,isFirst:a,isLast:o,columnCount:s,flipKey:c,reorderable:l,removable:u,rowActions:d,onField:f,onMove:p,onRemove:m,onDuplicate:h,registerRow:g}){let{t:_}=w(`lattice`);return(0,J.jsxs)(`div`,{ref:e=>g?.(c,e),"data-flip-key":c,"data-test":`table-row-${e}-${t}`,className:`grid grid-cols-[var(--lattice-table-columns)] items-start gap-x-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[l&&!a&&(0,J.jsx)(ps,{label:`Move up`,testId:`table-${e}-up-${t}`,onClick:()=>p(t,-1),children:(0,J.jsx)(R,{name:`arrow-up`})}),l&&!o&&(0,J.jsx)(ps,{label:`Move down`,testId:`table-${e}-down-${t}`,onClick:()=>p(t,1),children:(0,J.jsx)(R,{name:`arrow-down`})})]}),(0,J.jsx)(ce,{base:e,index:t,row:n,onChange:(e,n)=>f(t,e,n),children:(0,J.jsx)(Re,{children:i?(0,J.jsx)(`div`,{"data-test":`table-row-${e}-${t}-span`,className:`flex flex-col gap-2`,style:{gridColumn:`span ${s}`},children:r.map((e,t)=>(0,J.jsx)(En,{node:e},xn(e,t)))}):r.map((e,t)=>(0,J.jsx)(`div`,{children:(0,J.jsx)(En,{node:e})},xn(e,t)))})}),(0,J.jsx)(`div`,{className:`flex items-center`,children:(0,J.jsx)(ds,{actions:ss(d,{index:t,removable:u,onRemove:m,onDuplicate:h,t:_})})})]})});function zs({base:e,columns:t,rows:n,reorderable:r,removable:i,rowActions:a,onField:o,onMove:s,onRemove:c,onDuplicate:l,registerRow:u,resizableColumns:d=!1,resizeIndicator:f=!1}){let{t:p}=w(`lattice`),m=Is(),h=(0,K.useMemo)(()=>t.map(e=>({key:e.name,label:e.label,width:e.columnWidth})),[t]),{getResizeHandleProps:g,gridTemplateColumns:_,hasOverrides:v,resizeRootRef:y,resetColumns:b}=Ss({columns:h,enabled:d,columnGapPx:12,leadingTracks:Ns,showIndicator:f,storageKey:d?`lattice:table-columns:form:${e}`:void 0,trailingTracks:Ps});return m?(0,J.jsxs)(`div`,{className:`relative`,children:[v&&(0,J.jsx)(`button`,{"aria-label":p(`table.reset-column-widths`,`Reset column widths`),className:`absolute right-1 top-1 z-10 hidden rounded-lt-sm p-1 text-lt-muted-fg hover:text-lt-fg md:inline-flex`,"data-test":`table-reset-columns`,onClick:b,title:p(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,J.jsx)(R,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`div`,{ref:y,className:`flex min-w-max flex-col gap-2`,style:{"--lattice-table-columns":_},children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-[var(--lattice-table-columns)] items-center gap-x-3`,children:[(0,J.jsx)(`div`,{}),t.map((e,t)=>(0,J.jsxs)(`div`,{className:`relative min-w-0 pr-3 text-xs font-medium text-lt-muted-fg`,children:[e.label,d&&(0,J.jsx)(`div`,{...g(h[t])})]},e.name)),(0,J.jsx)(`div`,{})]}),n.map(d=>(0,J.jsx)(Rs,{base:e,index:d.index,row:d.row,template:d.template,span:d.span,isFirst:d.index===0,isLast:d.index===n.length-1,columnCount:t.length,flipKey:d.key,reorderable:r,removable:i(d.index),rowActions:a,onField:o,onMove:s,onRemove:c,onDuplicate:l,registerRow:u},d.key))]})})]}):(0,J.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,J.jsx)(`div`,{ref:e=>u?.(t.key,e),"data-flip-key":t.key,children:(0,J.jsx)(ms,{base:e,index:t.index,row:t.row,template:t.template,heading:t.heading??`#${t.index+1}`,reorderable:r,isFirst:t.index===0,isLast:t.index===n.length-1,removable:i(t.index),rowActions:a,onField:o,onRemove:c,onMove:s,onDuplicate:l})},t.key))})}var Bs=180;function Vs(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Hs(e){let t=(0,K.useRef)(new Map),n=(0,K.useRef)(new Map),r=(0,K.useCallback)((e,n)=>{n?t.current.set(e,n):t.current.delete(e)},[]);return(0,K.useLayoutEffect)(()=>{let e=[],r=new Map;return t.current.forEach((e,t)=>{e.style.transition=``,e.style.transform=``,r.set(t,e.getBoundingClientRect())}),Vs()||t.current.forEach((t,i)=>{let a=n.current.get(i),o=r.get(i);if(a&&o){let n=a.top-o.top;n&&(t.style.transform=`translateY(${n}px)`,e.push(requestAnimationFrame(()=>{t.style.transition=`transform ${Bs}ms ease-out`,t.style.transform=``})))}}),n.current=r,()=>{for(let t of e)cancelAnimationFrame(t)}},[e]),r}function Us(e,t){let n=st(),r=n?n.errorKey(e):e,i=Se(),a=lt(r),o=Array.isArray(a)?a:ge(a,t),s=He(o);(0,K.useLayoutEffect)(()=>{s!==o&&i(r,s)},[o,s,i,r]);let c=(0,K.useCallback)(e=>{i(r,n=>e(Array.isArray(n)?n:ge(n,t)))},[i,r,t]);return{path:r,rows:s,onField:(0,K.useCallback)((e,t,n)=>c(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r)),[c]),onRemove:(0,K.useCallback)(e=>c(t=>Ve(t,e)),[c]),onMove:(0,K.useCallback)((e,t)=>c(n=>oe(n,e,e+t)),[c]),onDuplicate:(0,K.useCallback)(e=>c(t=>ve(t,e)),[c]),append:(0,K.useCallback)(e=>c(t=>[...t,_e(e)]),[c])}}var Ws=[],Gs=({node:e})=>{let t=e.props,n=t.name,r=da(e)??[],{errors:i}=H(),{hidden:a,required:o}=Ke(e),{path:s,rows:c,onField:l,onRemove:u,onMove:d,onDuplicate:f,append:p}=Us(n,t.defaultItems??0),{t:m}=w(`lattice`),h=Hs(c.map(e=>String(e.rowId??``)).join(`,`)),g=t.maxItems!=null&&c.length>=t.maxItems,_=t.minItems!=null&&c.length<=t.minItems,v=t.layout===`table`,y=e=>r.find(t=>t.type===e),b=r.map(e=>({type:e.type,label:e.label}));if(a)return null;let x=r[0],S=c.map((e,t)=>{let n=y(e.type),r=!!n&&!!x&&n.type===x.type;return{key:String(e.rowId??t),index:t,row:e,template:n?.schema??Ws,span:!r,heading:n?.label??`Unknown block: ${String(e.type)}`}});return(0,J.jsx)(ze,{error:i[s],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:s,required:o,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(fs,{path:s,rows:c,rowKey:le}),(0,J.jsx)(fs,{path:s,rows:c,rowKey:`type`}),v?(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(zs,{base:s,columns:Ls(x?.schema??[]),rows:S,reorderable:t.reorderable??!1,removable:()=>!_,rowActions:t.rowActions,onField:l,onMove:d,onRemove:u,onDuplicate:f,registerRow:h,resizableColumns:t.resizableColumns===!0,resizeIndicator:t.resizeIndicator===!0})}):c.map((e,r)=>{let i=y(e.type),a=String(e.rowId??r);return(0,J.jsx)(`div`,{ref:e=>h(a,e),"data-flip-key":a,children:i?(0,J.jsx)(ms,{base:s,index:r,row:e,template:i.schema??Ws,heading:i.label,reorderable:t.reorderable??!1,isFirst:r===0,isLast:r===c.length-1,removable:!_,rowActions:t.rowActions,onField:l,onRemove:u,onMove:d,onDuplicate:f}):(0,J.jsxs)(`div`,{"data-test":`repeater-${n}-row-${r}`,className:`flex items-center justify-between rounded-lt border border-dashed border-lt-border p-4 text-sm text-lt-muted-fg`,children:[(0,J.jsxs)(`span`,{children:[`Unknown block: `,String(e.type)]}),(0,J.jsx)(ds,{actions:ss(t.rowActions,{index:r,removable:!_,onRemove:u,onDuplicate:f,t:m})})]})},a)}),!g&&(0,J.jsx)(as,{addLabel:t.addLabel??`Add`,options:b,onSelect:e=>p({type:e})})]})})},Ks=Object.defineProperty,qs=(e,t)=>Ks(e,`name`,{value:t,configurable:!0}),Js=`Checkbox`,[Ys,Xs]=at(Js),[Zs,Qs]=Ys(Js);function $s(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ae({prop:n,defaultProp:i??!1,onChange:c,caller:Js}),[m,h]=K.useState(null),[g,_]=K.useState(null),v=K.useRef(!1),[y,b]=K.useReducer(e=>e+1,0),x=!m||!!o||!!m.closest(`form`),S={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:!cc(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,J.jsx)(Zs,{scope:t,...S,children:sc(d)?d(S):r})}qs($s,`CheckboxProvider`);var ec=`CheckboxTrigger`,tc=K.forwardRef(qs(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=Qs(ec,e),g=F(i,u),_=K.useRef(c);return K.useEffect(()=>{let e=a?.form;if(e){let t=qs(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,J.jsx)(U.button,{type:`button`,role:`checkbox`,"aria-checked":cc(c)?`mixed`:c,"aria-required":l,"data-state":lc(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:W(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:W(n,e=>{p(),d(e=>cc(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),nc=K.forwardRef(qs(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,J.jsx)($s,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(tc,{...d,ref:t,__scopeCheckbox:n}),e&&(0,J.jsx)(oc,{__scopeCheckbox:n})]})})},`Checkbox`)),rc=`CheckboxIndicator`,ic=K.forwardRef(qs(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=Qs(rc,n);return(0,J.jsx)(Fe,{present:r||cc(a.checked)||a.checked===!0,children:(0,J.jsx)(U.span,{"data-state":lc(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),ac=`CheckboxBubbleInput`,oc=K.forwardRef(qs(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=Qs(ac,e),g=F(r,h),_=De(i),v=K.useRef(!1),y=K.useRef(s),b=K.useRef(o);K.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=cc(s),n.call(e,!cc(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=K.useRef(!cc(s)&&s);return(0,J.jsx)(U.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:W(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function sc(e){return typeof e==`function`}qs(sc,`isFunction`);function cc(e){return e===`indeterminate`}qs(cc,`isIndeterminate`);function lc(e){return cc(e)?`indeterminate`:e?`checked`:`unchecked`}qs(lc,`getState`);function uc({className:e,...t}){return(0,J.jsx)(nc,{"data-slot":`checkbox`,className:P(`peer border-lt-input data-[state=checked]:bg-lt-primary data-[state=checked]:text-lt-primary-fg data-[state=checked]:border-lt-primary focus-visible:border-lt-ring focus-visible:ring-lt-ring/50 aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger size-4 shrink-0 rounded-lt-xs border shadow-lt-xs transition-shadow outline-none focus-visible:ring-[length:var(--lt-ring-width)] disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg disabled:data-[state=checked]:bg-lt-disabled disabled:data-[state=checked]:text-lt-disabled-fg disabled:data-[state=checked]:border-lt-disabled`,e),...t,children:(0,J.jsx)(ic,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,J.jsx)(R,{name:`check`,className:`size-lt-icon-sm`})})})}function dc(e,t){if(!t)return e;let n=e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``);return n?`${t}-${n}`:t}function fc(e,t){let n=st(),r=lt(e),i=n?n.getValue(e):r,a=Se();(0,K.useEffect)(()=>{i===void 0&&t!==void 0&&(n?n.setValue(e,t):a(e,t))},[e,t,i,a,n])}var pc=({node:e})=>{let{hidden:t,readOnly:n,disabled:r}=Ke(e),i=e.props.name,a=st(),{fieldIdPrefix:o}=H(),s=dc(a?a.scopedName(i):i,o),c=lt(i),l=a?a.getValue(i):c,{commit:u}=ke(),d=Qe(e.props.value),f=l===void 0?d:Qe(l);return fc(i,d),t?null:(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,J.jsx)(uc,{autoFocus:e.props.autoFocus??void 0,checked:f,"data-test":k(i),disabled:n||r,id:s,name:s,onCheckedChange:e=>{u(i,e===!0)},tabIndex:e.props.tabIndex??void 0}),(0,J.jsx)(Ae,{htmlFor:s,children:e.props.label})]}),e.props.helperText&&(0,J.jsx)(`p`,{className:`mt-1 pl-7 text-sm text-lt-muted-fg`,children:e.props.helperText})]})};function mc(e){let{errors:t,fieldIdPrefix:n}=H(),r=st(),i=Ke(e),a=ut(e),o=a.name??``,s=lt(o),c=r?r.getValue(o):s,l=c===void 0?a.value:c,u=typeof l==`string`||typeof l==`number`?String(l):``,d=dc(r?r.scopedName(o):o,n),f=r?r.errorKey(o):o,{commit:p,change:m,blur:h}=ke(),g=e=>p(o,e),_=e=>m(o,e),v=()=>h(o);return{...i,localName:o,name:d,testId:k(o),value:u,error:t[f],commit:g,change:_,blur:v}}var hc=({node:e})=>{let t=la(e),{localName:n,name:r,testId:i,value:a,error:o,hidden:s,required:c,readOnly:l,disabled:u,commit:d}=mc(e),f=(0,K.useMemo)(()=>t.props.options??[],[t.props]),p=f[0]?.value??``,m=a||p;return fc(n,m||void 0),s||f.length===0?null:(0,J.jsxs)(ze,{error:o,helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,name:r,required:c,children:[(0,J.jsx)(`input`,{name:r,type:`hidden`,value:m}),(0,J.jsx)(Lo,{ariaLabel:e.props.label??void 0,autoFocus:e.props.autoFocus??void 0,disabled:l||u,name:i,onSelect:d,options:f,tabIndex:e.props.tabIndex??void 0,value:m})]})};function gc(){return(gc=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function _c(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}function vc(e){var t=(0,K.useRef)(e),n=(0,K.useRef)(function(e){t.current&&t.current(e)});return t.current=e,n.current}var yc=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},bc=function(e){return`touches`in e},xc=function(e){return e&&e.ownerDocument.defaultView||self},Sc=function(e,t,n){var r=e.getBoundingClientRect(),i=bc(t)?function(e,t){for(var n=0;n<e.length;n++)if(e[n].identifier===t)return e[n];return e[0]}(t.touches,n):t;return{left:yc((i.pageX-(r.left+xc(e).pageXOffset))/r.width),top:yc((i.pageY-(r.top+xc(e).pageYOffset))/r.height)}},Cc=function(e){!bc(e)&&e.preventDefault()},wc=K.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,i=_c(e,[`onMove`,`onKey`,`onEnd`]),a=(0,K.useRef)(null),o=vc(t),s=vc(n),c=vc(r),l=(0,K.useRef)(null),u=(0,K.useRef)(!1),d=(0,K.useMemo)(function(){var e=function(e){Cc(e),(bc(e)?e.touches.length>0:e.buttons>0)&&a.current?o(Sc(a.current,e,l.current)):(n(!1),c())},t=function(){n(!1),c()};function n(n){var r=u.current,i=xc(a.current),o=n?i.addEventListener:i.removeEventListener;o(r?`touchmove`:`mousemove`,e),o(r?`touchend`:`mouseup`,t)}return[function(e){var t=e.nativeEvent,r=a.current;if(r&&(Cc(t),!function(e,t){return t&&!bc(e)}(t,u.current)&&r)){if(bc(t)){u.current=!0;var i=t.changedTouches||[];i.length&&(l.current=i[0].identifier)}r.focus(),o(Sc(r,t,l.current)),n(!0)}},function(e){var t=e.which||e.keyCode;t<37||t>40||(e.preventDefault(),s({left:t===39?.05:t===37?-.05:0,top:t===40?.05:t===38?-.05:0}))},function(e){var t=e.which||e.keyCode;t>=37&&t<=40&&c()},n]},[s,o,c]),f=d[0],p=d[1],m=d[2],h=d[3];return(0,K.useEffect)(function(){return h},[h]),K.createElement(`div`,gc({},i,{onTouchStart:f,onMouseDown:f,className:`react-colorful__interactive`,ref:a,onKeyDown:p,onKeyUp:m,tabIndex:0,role:`slider`}))}),Tc=function(e){return e.filter(Boolean).join(` `)},Ec=function(e){var t=e.color,n=e.left,r=e.top,i=r===void 0?.5:r,a=Tc([`react-colorful__pointer`,e.className]);return K.createElement(`div`,{className:a,style:{top:100*i+`%`,left:100*n+`%`}},K.createElement(`div`,{className:`react-colorful__pointer-fill`,style:{backgroundColor:t}}))},$=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n};360/(2*Math.PI);var Dc=function(e){return Fc(Oc(e))},Oc=function(e){return e[0]===`#`&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?$(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?$(parseInt(e.substring(6,8),16)/255,2):1}},kc=function(e){return Pc(Mc(e))},Ac=function(e){var t=e.s,n=e.v,r=e.a,i=(200-t)*n/100;return{h:$(e.h),s:$(i>0&&i<200?t*n/100/(i<=100?i:200-i)*100:0),l:$(i/2),a:$(r,2)}},jc=function(e){var t=Ac(e);return`hsl(`+t.h+`, `+t.s+`%, `+t.l+`%)`},Mc=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:$(255*[r,s,o,o,c,r][l]),g:$(255*[c,r,r,s,o,o][l]),b:$(255*[o,o,c,r,r,s][l]),a:$(i,2)}},Nc=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Pc=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i<1?Nc($(255*i)):``;return`#`+Nc(t)+Nc(n)+Nc(r)+a},Fc=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:$(60*(s<0?s+6:s)),s:$(a?o/a*100:0),v:$(a/255*100),a:i}},Ic=K.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,i=Tc([`react-colorful__hue`,e.className]);return K.createElement(`div`,{className:i},K.createElement(wc,{onMove:function(e){n({h:360*e.left})},onKey:function(e){n({h:yc(t+360*e.left,0,360)})},onEnd:r,"aria-label":`Hue`,"aria-valuenow":$(t),"aria-valuemax":`360`,"aria-valuemin":`0`},K.createElement(Ec,{className:`react-colorful__hue-pointer`,left:t/360,color:jc({h:t,s:100,v:100,a:1})})))}),Lc=K.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,i={backgroundColor:jc({h:t.h,s:100,v:100,a:1})};return K.createElement(`div`,{className:`react-colorful__saturation`,style:i},K.createElement(wc,{onMove:function(e){n({s:100*e.left,v:100-100*e.top})},onKey:function(e){n({s:yc(t.s+100*e.left,0,100),v:yc(t.v-100*e.top,0,100)})},onEnd:r,"aria-label":`Color`,"aria-valuetext":`Saturation `+$(t.s)+`%, Brightness `+$(t.v)+`%`},K.createElement(Ec,{className:`react-colorful__saturation-pointer`,top:1-t.v/100,left:t.s/100,color:jc(t)})))}),Rc=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0},zc=function(e,t){return e.toLowerCase()===t.toLowerCase()||Rc(Oc(e),Oc(t))};function Bc(e,t,n,r){var i=vc(n),a=vc(r),o=(0,K.useState)(function(){return e.toHsva(t)}),s=o[0],c=o[1],l=(0,K.useRef)({color:t,hsva:s}),u=(0,K.useRef)(!1);return(0,K.useEffect)(function(){if(!e.equal(t,l.current.color)){var n=e.toHsva(t);l.current={hsva:n,color:t},c(n),u.current=!1}},[t,e]),(0,K.useEffect)(function(){var t;Rc(s,l.current.hsva)||e.equal(t=e.fromHsva(s),l.current.color)||(l.current={hsva:s,color:t},i(t),u.current=!0)},[s,e,i]),[s,(0,K.useCallback)(function(e){c(function(t){return Object.assign({},t,e)})},[]),(0,K.useCallback)(function(){u.current&&(u.current=!1,a(l.current.color))},[a])]}var Vc,Hc=typeof window<`u`?K.useLayoutEffect:K.useEffect,Uc=function(){return Vc||(typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0)},Wc=new WeakMap,Gc=function(e){Hc(function(){var t=e.current;if(typeof document<`u`&&t){var n=t.getRootNode?t.getRootNode():t.ownerDocument,r=n&&(`head`in n||`host`in n)?n:t.ownerDocument;if(!Wc.has(r)){var i=`head`in r?r.head:r,a=(i.ownerDocument||document).createElement(`style`);a.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`;var o=Uc();o&&a.setAttribute(`nonce`,o),Wc.set(r,a),i.appendChild(a)}}},[])},Kc=function(e){var t=e.className,n=e.colorModel,r=e.color,i=r===void 0?n.defaultColor:r,a=e.onChange,o=e.onChangeEnd,s=_c(e,[`className`,`colorModel`,`color`,`onChange`,`onChangeEnd`]),c=(0,K.useRef)(null);Gc(c);var l=Bc(n,i,a,o),u=l[0],d=l[1],f=l[2],p=Tc([`react-colorful`,t]);return K.createElement(`div`,gc({},s,{ref:c,className:p}),K.createElement(Lc,{hsva:u,onChange:d,onChangeEnd:f}),K.createElement(Ic,{hue:u.h,onChange:d,onChangeEnd:f,className:`react-colorful__last-control`}))},qc={defaultColor:`000`,toHsva:Dc,fromHsva:function(e){return kc({h:e.h,s:e.s,v:e.v,a:1})},equal:zc},Jc=function(e){return K.createElement(Kc,gc({},e,{colorModel:qc}))};function Yc(e){let t=e.trim().replace(/^#/,``).toLowerCase();return/^[0-9a-f]{6}$/.test(t)?`#${t}`:/^[0-9a-f]{3}$/.test(t)?`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:null}function Xc({value:e,onChange:t,palette:n,hexLabel:r=`Hex color`,paletteLabel:i=`Color palette`}){let[a,o]=(0,K.useState)(null),s=Yc(e)??`#6b7280`;return(0,J.jsxs)(`div`,{className:`flex w-56 flex-col gap-3`,"data-slot":`color-picker`,children:[(0,J.jsx)(Jc,{className:`!w-full`,color:s,onChange:t}),n.length>0&&(0,J.jsx)(`div`,{"aria-label":i,className:`flex flex-wrap gap-1.5`,role:`listbox`,children:n.map(e=>{let n=Yc(e)??e;return(0,J.jsx)(`button`,{"aria-label":n,"aria-selected":n===s,className:P(`size-6 shrink-0 rounded-full border border-lt-border`,n===s&&`ring-2 ring-lt-ring ring-offset-1`),onClick:()=>t(n),role:`option`,style:{background:e},type:`button`},e)})}),(0,J.jsx)(dt,{"aria-label":r,onBlur:()=>o(null),onChange:e=>{let n=e.target.value,r=Yc(n);o(n),r!==null&&t(r)},value:a??s})]})}function Zc({node:e,label:t,children:n}){let r=mc(e);return r.hidden?null:(0,J.jsx)(ze,{error:r.error,helperText:ut(e).helperText??void 0,tooltip:ut(e).tooltip??void 0,label:t,name:r.name,required:r.required,children:n(r)})}var Qc=({node:e})=>{let t=e.props;return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,value:n,readOnly:r,disabled:i,commit:a})=>{let o=Yc(n);return(0,J.jsxs)(Te,{children:[(0,J.jsx)(`input`,{name:e,type:`hidden`,value:o??``}),(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(`button`,{className:P(_t(),`flex items-center gap-2 text-left`),"data-test":`color-picker-${e}`,disabled:i||r,id:e,type:`button`,children:o?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 shrink-0 rounded-full border border-lt-border`,style:{background:o}}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:o})]}):(0,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:t.placeholder??``})})}),(0,J.jsx)(B,{className:`p-3`,children:(0,J.jsx)(Xc,{onChange:e=>a(e),palette:t.palette,value:o??`#6b7280`})})]})}})},$c=(0,K.lazy)(async()=>{let{DatePickerField:e}=await $t(async()=>{let{DatePickerField:e}=await import(`./chunks/date-picker-field-CCnkf4SC.js`);return{DatePickerField:e}},__vite__mapDeps([14,1,4,2,15,3,11,16]),import.meta.url);return{default:e}});function el(e){return(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)($c,{...e})})}var tl=({node:e})=>{let t=e.props;return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,change:o,blur:s})=>(0,J.jsx)(el,{autoFocus:t.autoFocus??!1,disabled:a,label:t.label??t.name,max:t.max||void 0,min:t.min||void 0,mode:`date`,name:e,onBlur:s,onChange:o,readOnly:i,tabIndex:t.tabIndex??void 0,testId:n??t.name,value:r})})},nl=({node:e})=>{let t=e.props,{timezone:n}=E();return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,testId:r,value:i,readOnly:a,disabled:o,change:s,blur:c})=>(0,J.jsx)(el,{autoFocus:t.autoFocus??!1,disabled:o,label:t.label??t.name,max:t.max,min:t.min,mode:`date-time`,name:e,onBlur:c,onChange:s,readOnly:a,step:t.step,tabIndex:t.tabIndex??void 0,testId:r??t.name,timezone:n,value:i})})};function rl({url:e,method:t,body:n,headers:r,onProgress:i}){return new Promise((a,o)=>{let s=new XMLHttpRequest;s.open(t,e,!0),Object.entries(r).forEach(([e,t])=>s.setRequestHeader(e,String(t))),s.upload.onprogress=e=>{e.lengthComputable&&i?.(Math.round(e.loaded/e.total*100))},s.onload=()=>{try{a(new Response(s.responseText||null,{status:s.status||500}))}catch{o(Error(`Upload to ${e} returned an unusable response`))}},s.onerror=()=>o(Error(`Upload to ${e} failed`)),s.send(n)})}function il(e,{ref:t,target:n,filename:r,contentType:i,values:a}){return Vt(e,{method:`POST`,ref:t,body:JSON.stringify({...a,_sub:`upload`,_target:n,filename:r,contentType:i}),throwOnError:!1})}function al(e,t){return Array.isArray(t)?Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}var ol=({node:e})=>{let{t}=w(`lattice`),n=e.props,{hidden:r,required:i,readOnly:a,disabled:o}=Ke(e),{action:s,componentRef:c,errors:l}=H(),u=n.name,d=st(),f=d?d.scopedName(u):u,p=d?d.errorKey(u):u,m=p,h=Me(),g=Se(),_=(0,K.useId)(),v=(0,K.useRef)(null),y=(0,K.useRef)(new Set),b=a||o,x=n.signed,S=n.multiple,C=S?`${f}[]`:f,T=(0,K.useMemo)(()=>(n.files??[]).map(e=>({id:crypto.randomUUID(),name:e.name,size:e.size,status:`ready`,progress:100,key:e.key,url:e.url,token:e.token,existing:!0})),[n.files]),[E,D]=(0,K.useState)(T),[O,A]=(0,K.useState)([]);(0,K.useEffect)(()=>{if(!x)return;let e=E.filter(e=>!e.existing&&e.key&&e.status===`ready`).map(e=>e.key),t=S?e:e[0]??``;if(d){al(d.getValue(u),t)||d.setValue(u,t);return}g(u,t)},[E,S,u,d,g,x]),(0,K.useEffect)(()=>{!x||d||g(`${u}__removed`,O)},[u,O,d,g,x]),(0,K.useEffect)(()=>()=>{y.current.forEach(e=>URL.revokeObjectURL(e)),y.current.clear()},[]);let j=(0,K.useMemo)(()=>E.filter(e=>e.file&&!e.existing).map(e=>e.file),[E]);(0,K.useEffect)(()=>{if(x||!v.current)return;let e=new DataTransfer;j.forEach(t=>e.items.add(t)),v.current.files=e.files},[j,x]);function M(e){if(!n.image)return;let t=URL.createObjectURL(e);return y.current.add(t),t}function N(e){!e.url||!y.current.has(e.url)||(URL.revokeObjectURL(e.url),y.current.delete(e.url))}async function P(e,t){let n=()=>{D(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))},r=await il(s,{ref:c,target:m,filename:t.name,contentType:t.type,values:h});if(!r.ok){n();return}let i=await r.json();try{let n=await rl({url:i.url,method:i.method.toUpperCase(),body:t,headers:i.headers,onProgress:t=>D(n=>n.map(n=>n.id===e.id?{...n,progress:t}:n))});D(t=>t.map(t=>t.id===e.id?{...t,status:n.ok?`ready`:`error`,key:i.key,progress:100}:t))}catch{n()}}function F(e){if(!e||b)return;let t=Array.from(e),n=t.map(e=>({id:crypto.randomUUID(),name:e.name,size:e.size,status:x?`uploading`:`ready`,progress:0,file:e,url:M(e),existing:!1}));if(!S&&(E.forEach(N),!d)){let e=E.filter(e=>e.existing&&e.token).map(e=>e.token);e.length>0&&A(t=>[...t,...e])}D(e=>S?[...e,...n]:n),x&&n.forEach((e,n)=>void P(e,t[n]))}function I(e){let t=E.find(t=>t.id===e);t&&N(t),t?.existing&&t.token&&!d&&A(e=>[...e,t.token]),D(t=>t.filter(t=>t.id!==e))}return r?null:(0,J.jsx)(ze,{error:l[p],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:u,required:i,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lt-sm border border-dashed border-lt-border bg-lt-surface px-4 py-6`,"data-test":k(u),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),F(e.dataTransfer.files)},children:[(0,J.jsx)(`button`,{className:`text-sm text-lt-muted-fg`,disabled:b,onClick:()=>v.current?.click(),type:`button`,children:t(`form.file-upload.dropzone`,`Drop files here or click to browse`)}),(0,J.jsx)(`ul`,{className:n.image?`grid grid-cols-1 gap-3 sm:grid-cols-2`:`flex flex-col gap-2`,children:E.map(e=>(0,J.jsxs)(`li`,{className:n.image?`flex min-w-0 items-center gap-3 rounded-lt-sm border border-lt-border bg-lt-bg p-2 text-sm`:`flex items-center justify-between gap-3 text-sm`,children:[n.image&&e.url?(0,J.jsx)(`img`,{alt:e.name,className:`size-16 shrink-0 rounded-lt-sm border border-lt-border object-cover`,"data-test":k(`${u}-preview`),src:e.url}):null,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`block truncate`,"data-test":k(`${u}-item`),children:e.name}),e.status===`uploading`&&(0,J.jsxs)(`span`,{className:`text-xs text-lt-muted-fg`,children:[e.progress,`%`]}),e.status===`error`&&(0,J.jsx)(`span`,{className:`text-xs text-lt-danger`,children:t(`form.file-upload.failed`,`Failed`)})]}),(!e.existing||!d)&&(0,J.jsx)(nt,{size:`sm`,icon:`x`,label:t(`form.file-upload.remove`,`Remove {{name}}`,{name:e.name}),"data-test":k(e.existing?`${u}-remove-existing`:`${u}-remove`),disabled:b,onClick:()=>I(e.id)}),x&&!e.existing&&e.key&&e.status===`ready`&&(0,J.jsx)(`input`,{"data-test":k(`${u}-uploaded`),name:C,type:`hidden`,value:e.key})]},e.id))}),!d&&O.map(e=>(0,J.jsx)(`input`,{name:`${u}__removed[]`,type:`hidden`,value:e},e)),(0,J.jsx)(`input`,{accept:n.accept??void 0,"aria-label":n.label??u,className:`sr-only`,"data-test":k(`${u}-input`),id:_,multiple:S,name:x?void 0:C,onChange:e=>{F(e.target.files),x&&(e.target.value=``)},ref:v,type:`file`})]})})};function sl({label:e,summaryLabel:t,variant:n,emphasis:r}){let{componentId:i,errors:a,fieldLabels:o,processing:s}=H(),c=Object.entries(a).filter(([,e])=>!!e).map(([e,t])=>({label:o[e]??e,message:t})),l=c.length>0;return(0,J.jsxs)(`span`,{className:`group relative inline-flex flex-col`,children:[(0,J.jsxs)(G,{"data-lattice-form":i,"data-test":`form-submit`,disabled:s||l,emphasis:r,type:`submit`,variant:n,children:[s&&(0,J.jsx)(ra,{}),e]}),l&&(0,J.jsxs)(`div`,{className:`pointer-events-none absolute bottom-full left-1/2 z-lt-popover mb-2 w-max max-w-xs -translate-x-1/2 rounded-lt border border-lt-border bg-lt-surface p-3 text-left text-sm opacity-0 shadow-lt-md transition-opacity group-hover:opacity-100`,role:`tooltip`,children:[(0,J.jsx)(`p`,{className:`mb-1 font-medium text-lt-fg`,children:t}),(0,J.jsx)(`ul`,{className:`space-y-1`,children:c.map(e=>(0,J.jsxs)(`li`,{className:`text-lt-muted-fg`,children:[(0,J.jsx)(`span`,{className:`font-medium text-lt-fg`,children:e.label}),` — `,e.message]},e.label))})]})]})}var cl={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`,around:`justify-around`,evenly:`justify-evenly`};function ll({componentId:e,reset:t}){let n=ct();return vn(i.resetForm,r=>{let i=r.detail;(!i?.form||i.form===e)&&(t(),n())}),null}function ul({action:e,children:t,componentRef:n,nodes:r,shouldRenderSubmitButton:i,submitButtons:a,submitEmphasis:o,submitJustify:s,submitLabel:c,submitVariant:l,summaryLabel:u}){let{nodes:d,markUserEdit:f}=ya(e,n,r),p=(0,K.useMemo)(()=>({markUserEdit:f}),[f]);return(0,J.jsx)(we,{value:p,children:(0,J.jsx)(ca,{nodes:d,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t,i&&(0,J.jsx)(`div`,{className:`flex gap-3 ${cl[s??`end`]}`,children:a?.length?a.map((e,t)=>e.props.buttonType===`submit`?(0,J.jsx)(sl,{emphasis:e.props.emphasis??o,label:e.props.label??c,summaryLabel:u,variant:e.props.variant??l},xn(e,t)):(0,J.jsx)(En,{node:e},xn(e,t))):(0,J.jsx)(sl,{emphasis:o,label:c,summaryLabel:u,variant:l})})]})})})}function dl(e){return!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?e:void 0}var fl=({children:e,node:t})=>{let n=(0,K.useMemo)(()=>({...ba(t.schema).values,...t.props.state}),[t.schema,t.props.state]);return(0,J.jsx)(ot,{initial:n,children:(0,J.jsx)(pl,{node:t,children:e})})};function pl({children:e,node:t}){let{t:n}=w(`lattice`),r=t.props,i=r.action??`#`,a=r.errorBag,o=r.ref??``,s=r.method??`post`,l=r.precognitive,u=r.resetOnError??!1,d=r.resetOnSuccess??[],f=(0,K.useMemo)(()=>ba(t.schema).labels,[t.schema]),p=r.submitButton,m=r.submitButtons??void 0,h=r.submitJustify??void 0,g=r.submitLabel??n(`form.submit`,`Submit`),_=r.submitVariant??void 0,v=r.submitEmphasis??void 0,y=r.validationSummaryLabel,b=r.validationTimeout??void 0,x=ct(),S=e=>{let t=dl(e);t!==!1&&x(t)},C=(0,K.useRef)(null),T=(0,K.useRef)(`idle`),[E,D]=(0,K.useState)(0);return(0,K.useEffect)(()=>{E>0&&T.current===`renewing`&&C.current?.submit()},[E]),(0,J.jsx)(c,{ref:C,action:i,"data-slot":`form`,"data-lattice-component":t.id,errorBag:a,method:s,resetOnError:u,resetOnSuccess:d,validationTimeout:l?b:void 0,headers:At(o),className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,onStart:()=>{T.current=T.current===`renewing`?`retried`:`idle`},onSuccess:()=>S(d),onError:()=>S(u),onHttpException:e=>{if(e.status===403&&o!==``&&T.current!==`retried`)return T.current=`renewing`,Bt(o).finally(()=>D(e=>e+1)),!1},children:({clearErrors:n,errors:a,processing:s,reset:c,touch:u,validate:d,validating:b})=>(0,J.jsxs)(fe,{value:{action:i,clearErrors:e=>n(e),componentId:t.id,componentRef:o,errors:a,fieldLabels:f,precognitive:l,processing:s,touch:e=>u(...e),validate:e=>d(e),validateFields:(e,t)=>d({only:e,...t}),validating:b},children:[(0,J.jsx)(ll,{componentId:t.id,reset:c}),r.status&&(0,J.jsx)(`div`,{className:`text-center text-sm font-medium text-lt-success`,children:r.status}),(0,J.jsx)(ul,{action:i,componentRef:o,nodes:t.schema,shouldRenderSubmitButton:p,submitButtons:m,submitEmphasis:v,submitJustify:h,submitLabel:g,submitVariant:_,summaryLabel:y,children:e})]})})}var ml=({node:e})=>{let t=st(),n=e.props.name,r=t?t.getValue(n):e.props.value;return(0,J.jsx)(`input`,{defaultValue:typeof r==`string`?r:``,name:t?t.scopedName(n):n,type:`hidden`})};function hl({affix:e,side:t,squared:n=!1}){return(0,J.jsx)(`span`,{"data-slot":`affix-${t}`,className:P(`inline-flex h-lt-control-md shrink-0 items-center border border-lt-input bg-lt-muted px-3 text-base whitespace-nowrap text-lt-muted-fg`,`group-has-[:focus-visible]:border-lt-ring`,t===`start`?`rounded-l-lt-sm border-r-0`:`rounded-r-lt-sm border-l-0`,n&&`rounded-r-none border-r-0`),children:e.icon?(0,J.jsx)(N,{className:`size-lt-icon-md`,icon:e.icon}):e.text})}function gl({prefix:e,suffix:t,end:n,children:r}){return!e&&!t&&!n?r(``):(0,J.jsxs)(`div`,{className:`group flex w-full rounded-lt-sm transition-[color,box-shadow] has-[:focus-visible]:ring-[length:var(--lt-ring-width)] has-[:focus-visible]:ring-lt-ring/50`,"data-slot":`affix-group`,children:[e?(0,J.jsx)(hl,{affix:e,side:`start`}):null,(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:r(P(`focus-visible:ring-0`,e&&`rounded-l-none`,(t||n)&&`rounded-r-none`))}),t?(0,J.jsx)(hl,{affix:t,side:`end`,squared:!!n}):null,n]})}var _l=({node:e})=>{let t=e.props;return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>{let s=e=>o(e.target.value);return t.slider?(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`input`,{"aria-label":t.label??``,className:`h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:accent-lt-disabled`,"data-test":n,disabled:a||i,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`range`,value:r}),(0,J.jsx)(`output`,{className:`w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg`,children:r})]}):(0,J.jsx)(gl,{prefix:t.prefix,suffix:t.suffix,children:o=>(0,J.jsx)(dt,{autoFocus:t.autoFocus??!1,className:o,"data-test":n,disabled:a,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,placeholder:t.placeholder??``,readOnly:i,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`number`,value:r})})}})},vl=Object.defineProperty,yl=Object.defineProperties,bl=Object.getOwnPropertyDescriptors,xl=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,wl=(e,t,n)=>t in e?vl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tl=(e,t)=>{for(var n in t||={})Sl.call(t,n)&&wl(e,n,t[n]);if(xl)for(var n of xl(t))Cl.call(t,n)&&wl(e,n,t[n]);return e},El=(e,t)=>yl(e,bl(t)),Dl=(e,t)=>{var n={};for(var r in e)Sl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&xl)for(var r of xl(e))t.indexOf(r)<0&&Cl.call(e,r)&&(n[r]=e[r]);return n};function Ol(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function kl(e){let t=K.useRef();return K.useEffect(()=>{t.current=e}),t.current}var Al=18,jl=40,Ml=`${jl}px`,Nl=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`);function Pl({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r}){let[i,a]=K.useState(!1),[o,s]=K.useState(!1),[c,l]=K.useState(!1),u=K.useMemo(()=>n!==`none`&&(n===`increase-width`||n===`experimental-no-flickering`)&&i&&o,[i,o,n]),d=K.useCallback(()=>{let r=e.current,i=t.current;if(!r||!i||c||n===`none`)return;let o=r,s=o.getBoundingClientRect().left+o.offsetWidth,u=o.getBoundingClientRect().top+o.offsetHeight/2,d=s-Al,f=u;document.querySelectorAll(Nl).length===0&&document.elementFromPoint(d,f)===r||(a(!0),l(!0))},[e,t,c,n]);return K.useEffect(()=>{let t=e.current;if(!t||n===`none`)return;function r(){let e=window.innerWidth-t.getBoundingClientRect().right;s(e>=jl)}r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),K.useEffect(()=>{let e=r||document.activeElement===t.current;if(n===`none`||!e)return;let i=setTimeout(d,0),a=setTimeout(d,2e3),o=setTimeout(d,5e3),s=setTimeout(()=>{l(!0)},6e3);return()=>{clearTimeout(i),clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[t,r,n,d]),{hasPWMBadge:i,willPushPWMBadge:u,PWM_BADGE_SPACE_WIDTH:Ml}}var Fl=K.createContext({}),Il=K.forwardRef((e,t)=>{var n=e,{value:r,onChange:i,maxLength:a,textAlign:o=`left`,pattern:s,placeholder:c,inputMode:l=`numeric`,onComplete:u,pushPasswordManagerStrategy:d=`increase-width`,pasteTransformer:f,containerClassName:p,noScriptCSSFallback:m=Rl,render:h,children:g}=n,_=Dl(n,[`value`,`onChange`,`maxLength`,`textAlign`,`pattern`,`placeholder`,`inputMode`,`onComplete`,`pushPasswordManagerStrategy`,`pasteTransformer`,`containerClassName`,`noScriptCSSFallback`,`render`,`children`]),v;let[y,b]=K.useState(typeof _.defaultValue==`string`?_.defaultValue:``),x=r??y,S=kl(x),C=K.useCallback(e=>{i?.(e),b(e)},[i]),w=K.useMemo(()=>s?typeof s==`string`?new RegExp(s):s:null,[s]),T=K.useRef(null),E=K.useRef(null),D=K.useRef({value:x,onChange:C,isIOS:typeof window<`u`&&((v=window==null?void 0:window.CSS)?.supports)?.call(v,`-webkit-touch-callout`,`none`)}),O=K.useRef({prev:[T.current?.selectionStart,T.current?.selectionEnd,T.current?.selectionDirection]});K.useImperativeHandle(t,()=>T.current,[]),K.useEffect(()=>{let e=T.current,t=E.current;if(!e||!t)return;D.current.value!==e.value&&D.current.onChange(e.value),O.current.prev=[e.selectionStart,e.selectionEnd,e.selectionDirection];function n(){if(document.activeElement!==e){P(null),I(null);return}let t=e.selectionStart,n=e.selectionEnd,r=e.selectionDirection,i=e.maxLength,a=e.value,o=O.current.prev,s=-1,c=-1,l;if(a.length!==0&&t!==null&&n!==null){let e=t===n,r=t===a.length&&a.length<i;if(e&&!r){let e=t;if(e===0)s=0,c=1,l=`forward`;else if(e===i)s=e-1,c=e,l=`backward`;else if(i>1&&a.length>1){let t=0;if(o[0]!==null&&o[1]!==null){l=e<o[1]?`backward`:`forward`;let n=o[0]===o[1]&&o[0]<i;l===`backward`&&!n&&(t=-1)}s=t+e,c=t+e+1}}s!==-1&&c!==-1&&s!==c&&T.current.setSelectionRange(s,c,l)}let u=s===-1?t:s,d=c===-1?n:c,f=l??r;P(u),I(d),O.current.prev=[u,d,f]}if(document.addEventListener(`selectionchange`,n,{capture:!0}),n(),document.activeElement===e&&M(!0),!document.getElementById(`input-otp-style`)){let e=document.createElement(`style`);if(e.id=`input-otp-style`,document.head.appendChild(e),e.sheet){let t=`background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;`;Ll(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Ll(e.sheet,`[data-input-otp]:autofill { ${t} }`),Ll(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Ll(e.sheet,`@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`),Ll(e.sheet,`[data-input-otp] + * { pointer-events: all !important; }`)}}let r=()=>{t&&t.style.setProperty(`--root-height`,`${e.clientHeight}px`)};r();let i=new ResizeObserver(r);return i.observe(e),()=>{document.removeEventListener(`selectionchange`,n,{capture:!0}),i.disconnect()}},[]);let[k,A]=K.useState(!1),[j,M]=K.useState(!1),[N,P]=K.useState(null),[F,I]=K.useState(null);K.useEffect(()=>{Ol(()=>{var e;(e=T.current)==null||e.dispatchEvent(new Event(`input`));let t=T.current?.selectionStart,n=T.current?.selectionEnd,r=T.current?.selectionDirection;t!==null&&n!==null&&(P(t),I(n),O.current.prev=[t,n,r])})},[x,j]),K.useEffect(()=>{S!==void 0&&x!==S&&S.length<a&&x.length===a&&u?.(x)},[a,u,S,x]);let L=Pl({containerRef:E,inputRef:T,pushPasswordManagerStrategy:d,isFocused:j}),ee=K.useCallback(e=>{let t=e.currentTarget.value.slice(0,a);if(t.length>0&&w&&!w.test(t)){e.preventDefault();return}typeof S==`string`&&t.length<S.length&&document.dispatchEvent(new Event(`selectionchange`)),C(t)},[a,C,S,w]),te=K.useCallback(()=>{var e;if(T.current){let t=Math.min(T.current.value.length,a-1),n=T.current.value.length;(e=T.current)==null||e.setSelectionRange(t,n),P(t),I(n)}M(!0)},[a]),ne=K.useCallback(e=>{let t=T.current;if(!f&&(!D.current.isIOS||!e.clipboardData||!t))return;let n=e.clipboardData.getData(`text/plain`),r=f?f(n):n;e.preventDefault();let i=T.current?.selectionStart,o=T.current?.selectionEnd,s=(i===o?x.slice(0,i)+r+x.slice(i):x.slice(0,i)+r+x.slice(o)).slice(0,a);if(s.length>0&&w&&!w.test(s))return;t.value=s,C(s);let c=Math.min(s.length,a-1),l=s.length;t.setSelectionRange(c,l),P(c),I(l)},[a,C,w,x]),R=K.useMemo(()=>({position:`relative`,cursor:_.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[_.disabled]),re=K.useMemo(()=>({position:`absolute`,inset:0,width:L.willPushPWMBadge?`calc(100% + ${L.PWM_BADGE_SPACE_WIDTH})`:`100%`,clipPath:L.willPushPWMBadge?`inset(0 ${L.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:`100%`,display:`flex`,textAlign:o,opacity:`1`,color:`transparent`,pointerEvents:`all`,background:`transparent`,caretColor:`transparent`,border:`0 solid transparent`,outline:`0 solid transparent`,boxShadow:`none`,lineHeight:`1`,letterSpacing:`-.5em`,fontSize:`var(--root-height)`,fontFamily:`monospace`,fontVariantNumeric:`tabular-nums`}),[L.PWM_BADGE_SPACE_WIDTH,L.willPushPWMBadge,o]),ie=K.useMemo(()=>K.createElement(`input`,El(Tl({autoComplete:_.autoComplete||`one-time-code`},_),{"data-input-otp":!0,"data-input-otp-placeholder-shown":x.length===0||void 0,"data-input-otp-mss":N,"data-input-otp-mse":F,inputMode:l,pattern:w?.source,"aria-placeholder":c,style:re,maxLength:a,value:x,ref:T,onPaste:e=>{var t;ne(e),(t=_.onPaste)==null||t.call(_,e)},onChange:ee,onMouseOver:e=>{var t;A(!0),(t=_.onMouseOver)==null||t.call(_,e)},onMouseLeave:e=>{var t;A(!1),(t=_.onMouseLeave)==null||t.call(_,e)},onFocus:e=>{var t;te(),(t=_.onFocus)==null||t.call(_,e)},onBlur:e=>{var t;M(!1),(t=_.onBlur)==null||t.call(_,e)}})),[ee,te,ne,l,re,a,F,N,_,w?.source,x]),z=K.useMemo(()=>({slots:Array.from({length:a}).map((e,t)=>{let n=j&&N!==null&&F!==null&&(N===F&&t===N||t>=N&&t<F),r=x[t]===void 0?null:x[t];return{char:r,placeholderChar:x[0]===void 0?c?.[t]??null:null,isActive:n,hasFakeCaret:n&&r===null}}),isFocused:j,isHovering:!_.disabled&&k}),[j,k,a,F,N,_.disabled,x]),ae=K.useMemo(()=>h?h(z):K.createElement(Fl.Provider,{value:z},g),[g,z,h]);return K.createElement(K.Fragment,null,m!==null&&K.createElement(`noscript`,null,K.createElement(`style`,null,m)),K.createElement(`div`,{ref:E,"data-input-otp-container":!0,style:R,className:p},ae,K.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},ie)))});Il.displayName=`Input`;function Ll(e,t){try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}}var Rl=`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./chunks/subscriptions-HzwKFUPT.js","./chunks/react-SIfiwpqq.js","./chunks/jsx-runtime-CN5ucv1d.js","./chunks/use-effect-dispatcher-CiWYRvsF.js","./chunks/locale-CgtcxthU.js","./chunks/instance-B-C4sgf4.js","./chunks/timezone-BORzyZp2.js","./chunks/translatable-DLw4h3x8.js","./chunks/dist-DqlcM-vw.js","./chunks/chart-view-WqyMTZiX.js","./chunks/materialize-CWqnSEHR.js","./chunks/test-id-Dh3L6Gfh.js","./chunks/number-BvVKQqOG.js","./chunks/with-selector-zFUY-tQj.js","./chunks/date-picker-field-CCnkf4SC.js","./chunks/dist-CK9gk4iB.js","./chunks/time-picker-DSs9fDWe.js","./chunks/rich-editor-field-DVvEzA3W.js","./chunks/icon-button-CEwL9uXW.js","./chunks/notifications-echo-uU87iJAV.js","./chunks/page-props-nxR5n6k4.js","./chunks/shared-props-B_wT1GcG.js"])))=>i.map(i=>d[i]);
2
+ import{i as e,t}from"./chunks/react-SIfiwpqq.js";import{a as n,n as r,o as i}from"./chunks/locale-CgtcxthU.js";import{n as a,t as o}from"./chunks/jsx-runtime-CN5ucv1d.js";import{a as s,c,d as l,f as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./chunks/use-effect-dispatcher-CiWYRvsF.js";import{n as x,t as S}from"./chunks/materialize-CWqnSEHR.js";import{a as C,o as w}from"./chunks/instance-B-C4sgf4.js";import{a as T,i as E,n as D,r as O}from"./chunks/timezone-BORzyZp2.js";import{t as k}from"./chunks/shared-props-B_wT1GcG.js";import{i as A,n as j,r as M,t as N}from"./chunks/test-id-Dh3L6Gfh.js";import{_ as P,b as F,g as I,h as L,i as ee,n as te,r as ne,t as re,v as R,y as ie}from"./chunks/dist-CK9gk4iB.js";import{n as z,t as ae}from"./chunks/translatable-DLw4h3x8.js";import{$ as oe,A as se,B as ce,C as le,D as ue,E as de,F as fe,G as B,H as pe,I as me,J as he,K as V,L as ge,M as _e,N as ve,O as ye,P as be,Q as xe,R as Se,S as Ce,T as we,U as Te,V as Ee,W as De,X as Oe,Y as ke,Z as Ae,_ as je,a as Me,at as Ne,b as Pe,c as Fe,ct as H,d as Ie,dt as U,et as Le,f as Re,g as ze,h as Be,i as Ve,it as He,j as Ue,k as We,l as Ge,lt as Ke,m as qe,n as Je,nt as Ye,o as Xe,ot as Ze,p as Qe,q as $e,r as et,rt as tt,s as nt,st as rt,t as it,tt as at,u as ot,ut as st,v as ct,w as lt,x as ut,y as dt,z as ft}from"./chunks/icon-button-CEwL9uXW.js";import{a as pt,c as W,i as mt,l as ht,n as gt,o as _t,r as vt,s as yt,t as bt}from"./chunks/time-picker-DSs9fDWe.js";import{a as xt,i as St,n as Ct,o as wt,r as Tt,t as Et}from"./chunks/number-BvVKQqOG.js";var Dt=`X-Lattice-Ref`,Ot=new Map;function kt(e){return Ot.get(e)??e}function At(e,t){Ot.set(e,t)}function jt(e){let t=kt(e);return t?{[Dt]:t}:{}}function Mt(e=``,t={}){return{...r(),...jt(e),...t}}var Nt=class extends Error{response;constructor(e){super(`HTTP ${e.status}`),this.response=e}};function Pt(){let e=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):``}var Ft=1e4,It=new Map,Lt=new Map;function Rt(e){return e===void 0||e===`GET`||e===`HEAD`?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`,"X-Requested-With":`XMLHttpRequest`,"X-XSRF-TOKEN":Pt()}}var zt=`/lattice/refs/refresh`;function Bt(e){zt=e}var Vt=new Map;async function Ht(e){let t=Vt.get(e);if(t)return t;let n=Wt(zt,{method:`POST`,body:JSON.stringify({ref:kt(e)})}).then(t=>(At(e,t.ref),t.ref)).catch(()=>null).finally(()=>{Vt.delete(e)});return Vt.set(e,n),n}async function Ut(e,t={}){let{ref:n=``,headers:r,throwOnError:i=!0,method:a,...o}=t,s=a?.toUpperCase(),c=()=>fetch(e,{credentials:`same-origin`,...o,method:s,headers:Mt(n,{...Rt(s),...r})}),l=await c();if(n!==``&&l.status===403&&await Ht(n)!==null&&(l=await c()),i&&!l.ok)throw new Nt(l);return l}async function Wt(e,t){return(await Ut(e,t)).json()}function Gt(e){return[e.source,e.audience,[...e.scopes].sort().join(` `)].join(``)}function Kt(e){It.delete(Gt(e))}async function qt(e){let t=Gt(e),n=It.get(t);if(n&&n.expiresAt>Date.now()+Ft)return n.token;let r=Lt.get(t);if(r)return r;let i=Wt(e.tokenEndpoint,{method:`POST`,ref:e.ref,body:JSON.stringify({nodeId:e.nodeId,nodeType:e.nodeType,audience:e.audience,scopes:e.scopes})}).then(e=>(It.set(t,{token:e,expiresAt:Date.now()+Math.max(0,e.expiresIn)*1e3}),e)).finally(()=>{Lt.delete(t)});return Lt.set(t,i),i}function Jt(e){return e.status===401||e.status===403}async function Yt(e,t,n){let{headers:i,...a}=t;return fetch(e,{...a,credentials:`omit`,headers:{Accept:`application/json`,...r(),...i,Authorization:`${n.tokenType} ${n.accessToken}`}})}async function Xt(e,t){let{remote:n,retryOnUnauthorized:r=!0,throwOnError:i=!0,...a}=t,o=await qt(n),s=await Yt(e,a,o);if(r&&Jt(s)&&(Kt(n),o=await qt(n),s=await Yt(e,a,o)),i&&!s.ok)throw new Nt(s);return s}async function Zt(e,t){return(await Xt(e,t)).json()}var G=e(t(),1),Qt=`modulepreload`,$t=function(e,t){return new URL(e,t).href},en={},tn=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=$t(t,n),t=s(t),t in en)return;en[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Qt,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},nn=[`light`,`dark`,`system`],rn=new Set,an=`system`;function on(e){return nn.some(t=>t===e)}var sn=()=>typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches,cn=(e,t,n=365)=>{if(typeof document>`u`)return;let r=n*24*60*60;document.cookie=`${e}=${t};path=/;max-age=${r};SameSite=Lax`},ln=()=>{if(typeof window>`u`)return`system`;let e=localStorage.getItem(`appearance`);return on(e)?e:`system`},un=e=>e===`dark`||e===`system`&&sn(),dn=e=>{if(typeof document>`u`)return;let t=un(e);document.documentElement.classList.toggle(`dark`,t),document.documentElement.style.colorScheme=t?`dark`:`light`},fn=()=>rn.forEach(e=>e()),pn=()=>typeof window>`u`?null:window.matchMedia(`(prefers-color-scheme: dark)`),mn=()=>{dn(an),fn()};function hn(e){an=e,localStorage.setItem(`appearance`,e),cn(`appearance`,e),dn(e),fn()}function gn(){typeof window>`u`||(localStorage.getItem(`appearance`)||(localStorage.setItem(`appearance`,`system`),cn(`appearance`,`system`)),an=ln(),dn(an),pn()?.addEventListener(`change`,mn))}function K(e){return{component:e,mode:`eager`}}function _n(e){return e}function vn(...e){return e.reduce((e,t)=>({components:{...e.components,...t.components},columns:{...e.columns,...t.columns},effects:{...e.effects,...t.effects}}),{components:{},columns:{},effects:{}})}function yn(e,...t){let n=vn(...t);return{components:{...e.components,...n.components},columns:{...e.columns,...n.columns},effects:{...e.effects,...n.effects}}}function bn(e,t,n={}){let{enabled:r=!0}=n,i=(0,G.useRef)(t);i.current=t,(0,G.useEffect)(()=>{if(!r||typeof window>`u`)return;let t=e=>i.current(e);return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[e,r])}function xn({preserveScroll:e=!0,preserveState:t=!0}){return bn(i.localeChange,n=>{let r=n.detail?.locale;typeof r==`string`&&r!==``&&p.visit(window.location.href,{preserveScroll:e,preserveState:t})}),null}function Sn(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`):[]}function Cn(e,t){return e.key??e.id??`${e.type}-${t}`}var wn=(0,G.createContext)(!1);function Tn(){return(0,G.useContext)(wn)}var q=o();function En(){return(0,q.jsxs)(`svg`,{"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:[(0,q.jsx)(`rect`,{height:`18`,rx:`2`,strokeDasharray:`4 3`,width:`18`,x:`3`,y:`3`}),(0,q.jsx)(`path`,{d:`M12 8v4`}),(0,q.jsx)(`path`,{d:`M12 16h.01`})]})}function Dn({node:e}){e.type;let t=`Missing component: ${e.type}`;return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 align-middle text-lt-muted-fg`,"data-lattice-missing-component":e.type,title:t,children:[(0,q.jsx)(En,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]})}function J({nodes:e}){return e.map((e,t)=>(0,q.jsx)(On,{node:e},Cn(e,t)))}function Y({node:e}){return(0,q.jsx)(On,{node:e})}var On=(0,G.memo)(function({node:e}){let t=Tn(),n=v()[e.type];if(t&&e.props?.hideWhenCollapsed===!0)return null;if(!n)return(0,q.jsx)(Dn,{node:e});let r=n.component,i=e.schema?.length?(0,q.jsx)(J,{nodes:e.schema}):null,a=(0,q.jsx)(r,{node:e,children:i});if(n.mode===`lazy`){let t=n.fallback;return(0,q.jsx)(G.Suspense,{fallback:t?(0,q.jsx)(t,{node:e,children:null}):null,children:a})}return a}),kn=[`primary`,`secondary`,`success`,`info`,`warning`,`danger`];function An(e){return kn.some(t=>t===e)}function jn(e){if(typeof e!=`object`||!e)return null;let t=e,n=t.message,r=typeof n==`string`||ae(n)?n:null;return r===null||r===``?null:{action:t.action??null,dismissible:t.dismissible!==!1,duration:typeof t.duration==`number`?t.duration:null,message:r,persistent:t.persistent===!0,variant:An(t.variant)?t.variant:`success`}}function Mn(e){let t=t=>{let n=jn(t.detail);n&&e(n)};return window.addEventListener(i.toast,t),()=>window.removeEventListener(i.toast,t)}function Nn(e){if(typeof e!=`object`||!e)return null;let t=e,n=t.message,r=typeof n==`string`||ae(n)?n:null;return r===null||r===``?null:{action:t.action??null,dismissible:t.dismissible!==!1,message:r,title:typeof t.title==`string`||ae(t.title)?t.title:null,unique:typeof t.unique==`string`?t.unique:null,variant:An(t.variant)?t.variant:`info`}}function Pn(e){let t=t=>{let n=Nn(t.detail);n&&e(n)};return window.addEventListener(i.callout,t),()=>window.removeEventListener(i.callout,t)}function Fn(e){let t=t=>{let n=t.detail?.unique;typeof n==`string`&&e(n)};return window.addEventListener(i.retractCallout,t),()=>window.removeEventListener(i.retractCallout,t)}var In=Object.defineProperty,X=(e,t)=>In(e,`name`,{value:t,configurable:!0});function Ln(e){let t=e+`CollectionProvider`,[n,r]=st(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=X(e=>{let{scope:t,children:n}=e,r=G.useRef(null),a=G.useRef(new Map).current;return(0,q.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=L(s),l=G.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=I(t,i.collectionRef);return(0,q.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=L(u),p=G.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=G.useRef(null),s=I(t,o),c=a(u,n);return G.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,q.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return G.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return X(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}X(Ln,`createCollection`);var Rn=new WeakMap,zn=class e extends Map{static{X(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Rn.set(this,!0)}set(e,t){return Rn.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=Hn(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=Bn(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Bn(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Bn(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function Bn(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Vn(e,t);return n===-1?void 0:e[n]}X(Bn,`at`);function Vn(e,t){let n=e.length,r=Hn(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}X(Vn,`toSafeIndex`);function Hn(e){return e!==e||e===0?0:Math.trunc(e)}X(Hn,`toSafeInteger`);function Un(e){let t=e+`CollectionProvider`,[n,r]=st(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new zn,setItemMap:X(()=>void 0,`setItemMap`)}),o=X(({state:e,...t})=>e?(0,q.jsx)(c,{...t,state:e}):(0,q.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=X(e=>{let t=h();return(0,q.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=X(e=>{let{scope:t,children:n,state:r}=e,a=G.useRef(null),[o,s]=G.useState(null),c=I(a,s),[l,u]=r;return G.useEffect(()=>{if(!o)return;let e=qn(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,q.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=L(l),d=G.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=I(t,i.collectionRef);return(0,q.jsx)(u,{ref:o,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=L(f),m=G.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=G.useRef(null),[s,c]=G.useState(null),l=I(t,o,c),{setItemMap:u}=a(f,n),d=G.useRef(i);Wn(d.current,i)||(d.current=i);let m=d.current;return G.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Kn):(t.set(s,{...e,element:s}),t.toSorted(Kn)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new zn(e)))}},[s,m,u]),(0,q.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return G.useState(new zn)}X(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return X(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}X(Un,`createCollection`);function Wn(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}X(Wn,`shallowEqual`);function Gn(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}X(Gn,`isElementPreceding`);function Kn(e,t){return!e[1].element||!t[1].element?0:Gn(e[1].element,t[1].element)?-1:1}X(Kn,`sortByDocumentPosition`);function qn(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}X(qn,`getChildListObserver`);var Jn=Object.defineProperty,Yn=(e,t)=>Jn(e,`name`,{value:t,configurable:!0}),Xn=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Zn=G.forwardRef(Yn(function(e,t){return(0,q.jsx)(H.span,{...e,ref:t,style:{...Xn,...e.style}})},`VisuallyHidden`)),Qn=e(a(),1),$n=Object.defineProperty,Z=(e,t)=>$n(e,`name`,{value:t,configurable:!0}),er=`ToastProvider`,[tr,nr,rr]=Ln(`Toast`),[ir,ar]=st(`Toast`,[rr]),[or,sr]=ir(er),cr=Z(e=>{let{__scopeToast:t,label:n=`Notification`,duration:r=5e3,swipeDirection:i=`right`,swipeThreshold:a=50,announcerContainer:o,children:s}=e,[c,l]=G.useState(null),[u,d]=G.useState(0),f=G.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${er}\`. Expected non-empty \`string\`.`),(0,q.jsx)(tr.Provider,{scope:t,children:(0,q.jsx)(or,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:a,toastCount:u,viewport:c,onViewportChange:l,onToastAdd:G.useCallback(()=>d(e=>e+1),[]),onToastRemove:G.useCallback(()=>d(e=>e-1),[]),isClosePausedRef:f,announcerContainer:o,children:s})})},`ToastProvider`),lr=`ToastViewport`,ur=[`F8`],dr=`toast.viewportPause`,fr=`toast.viewportResume`,pr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,hotkey:r=ur,label:i=`Notifications ({hotkey})`,...a}=e,o=sr(lr,n),s=nr(n),c=G.useRef(null),l=G.useRef(null),u=G.useRef(null),d=G.useRef(null),f=I(t,d,o.onViewportChange),p=r.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),m=o.toastCount>0;G.useEffect(()=>{let e=Z(e=>{r.length!==0&&r.every(t=>e[t]||e.code===t)&&d.current?.focus()},`handleKeyDown`);return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),G.useEffect(()=>{let e=c.current,t=d.current;if(m&&e&&t){let n=Z(()=>{if(!o.isClosePausedRef.current){let e=new CustomEvent(dr);t.dispatchEvent(e),o.isClosePausedRef.current=!0}},`handlePause`),r=Z(()=>{if(o.isClosePausedRef.current){let e=new CustomEvent(fr);t.dispatchEvent(e),o.isClosePausedRef.current=!1}},`handleResume`),i=Z(t=>{e.contains(t.relatedTarget)||r()},`handleFocusOutResume`),a=Z(()=>{e.contains(document.activeElement)||r()},`handlePointerLeaveResume`);return e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,i),e.addEventListener(`pointermove`,n),e.addEventListener(`pointerleave`,a),window.addEventListener(`blur`,n),window.addEventListener(`focus`,r),()=>{e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,i),e.removeEventListener(`pointermove`,n),e.removeEventListener(`pointerleave`,a),window.removeEventListener(`blur`,n),window.removeEventListener(`focus`,r)}}},[m,o.isClosePausedRef]);let h=G.useCallback(({tabbingDirection:e})=>{let t=s().map(t=>{let n=t.ref.current,r=[n,...Fr(n)];return e===`forwards`?r:r.reverse()});return(e===`forwards`?t.reverse():t).flat()},[s]);return G.useEffect(()=>{let e=d.current;if(e){let t=Z(t=>{let n=t.altKey||t.ctrlKey||t.metaKey;if(t.key===`Tab`&&!n){let n=document.activeElement,r=t.shiftKey;if(t.target===e&&r){l.current?.focus();return}let i=h({tabbingDirection:r?`backwards`:`forwards`}),a=i.findIndex(e=>e===n);Ir(i.slice(a+1))?t.preventDefault():r?l.current?.focus():u.current?.focus()}},`handleKeyDown`);return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)}},[s,h]),(0,q.jsxs)(tt,{ref:c,role:`region`,"aria-label":i.replace(`{hotkey}`,p),tabIndex:-1,style:{pointerEvents:m?void 0:`none`},children:[m&&(0,q.jsx)(hr,{ref:l,onFocusFromOutsideViewport:()=>{Ir(h({tabbingDirection:`forwards`}))}}),(0,q.jsx)(tr.Slot,{scope:n,children:(0,q.jsx)(H.ol,{tabIndex:-1,...a,ref:f})}),m&&(0,q.jsx)(hr,{ref:u,onFocusFromOutsideViewport:()=>{Ir(h({tabbingDirection:`backwards`}))}})]})},`ToastViewport`)),mr=`ToastFocusProxy`,hr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,a=sr(mr,n);return(0,q.jsx)(Zn,{tabIndex:0,...i,ref:t,style:{position:`fixed`},onFocus:e=>{let t=e.relatedTarget;a.viewport?.contains(t)||r()}})},`ToastFocusProxy`)),gr=`Toast`,_r=`toast.swipeStart`,vr=`toast.swipeMove`,yr=`toast.swipeCancel`,br=`toast.swipeEnd`,xr=G.forwardRef(Z(function(e,t){let{forceMount:n,open:r,defaultOpen:i,onOpenChange:a,...o}=e,[s,c]=oe({prop:r,defaultProp:i??!0,onChange:a,caller:gr});return(0,q.jsx)(Le,{present:n||s,children:(0,q.jsx)(wr,{open:s,...o,ref:t,onClose:()=>c(!1),onPause:rt(e.onPause),onResume:rt(e.onResume),onSwipeStart:U(e.onSwipeStart,e=>{e.currentTarget.setAttribute(`data-swipe`,`start`)}),onSwipeMove:U(e.onSwipeMove,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`move`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-move-y`,`${n}px`)}),onSwipeCancel:U(e.onSwipeCancel,e=>{e.currentTarget.setAttribute(`data-swipe`,`cancel`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-end-y`)}),onSwipeEnd:U(e.onSwipeEnd,e=>{let{x:t,y:n}=e.detail.delta;e.currentTarget.setAttribute(`data-swipe`,`end`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-x`),e.currentTarget.style.removeProperty(`--radix-toast-swipe-move-y`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-x`,`${t}px`),e.currentTarget.style.setProperty(`--radix-toast-swipe-end-y`,`${n}px`),c(!1)})})})},`Toast`)),[Sr,Cr]=ir(gr,{onClose(){}}),wr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,type:r=`foreground`,duration:i,open:a,onClose:o,onEscapeKeyDown:s,onPause:c,onResume:l,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:p,...m}=e,h=sr(gr,n),g=nr(n),[_,v]=G.useState(null),y=I(t,v),b=G.useRef(null),x=G.useRef(null),S=i||h.duration,C=G.useRef(0),w=G.useRef(S),T=G.useRef(0),{onToastAdd:E,onToastRemove:D}=h,O=rt(()=>{_?.contains(document.activeElement)&&h.viewport?.focus(),o()}),k=G.useCallback(e=>{!e||e===1/0||(window.clearTimeout(T.current),C.current=new Date().getTime(),T.current=window.setTimeout(O,e))},[O]);G.useEffect(()=>{let e=h.viewport;if(e){let t=Z(()=>{k(w.current),l?.()},`handleResume`),n=Z(()=>{let e=new Date().getTime()-C.current;w.current-=e,window.clearTimeout(T.current),c?.()},`handlePause`);return e.addEventListener(dr,n),e.addEventListener(fr,t),()=>{e.removeEventListener(dr,n),e.removeEventListener(fr,t)}}},[h.viewport,S,c,l,k]),G.useEffect(()=>{a&&!h.isClosePausedRef.current&&k(S)},[a,S,h.isClosePausedRef,k]),G.useEffect(()=>()=>{window.clearTimeout(T.current)},[]),G.useEffect(()=>(E(),()=>D()),[E,D]);let A=G.useMemo(()=>_?Ar(_):null,[_]);return h.viewport?(0,q.jsxs)(q.Fragment,{children:[A&&(0,q.jsx)(Tr,{__scopeToast:n,role:`status`,"aria-live":r===`foreground`?`assertive`:`polite`,children:A}),(0,q.jsx)(Sr,{scope:n,onClose:O,children:Qn.createPortal((0,q.jsx)(tr.ItemSlot,{scope:n,children:(0,q.jsx)(Ne,{asChild:!0,onEscapeKeyDown:U(s,e=>{g().some(t=>t.ref.current?.contains(e.target))||O()}),children:(0,q.jsx)(H.li,{tabIndex:0,"data-state":a?`open`:`closed`,"data-swipe-direction":h.swipeDirection,...m,ref:y,style:{userSelect:`none`,touchAction:`none`,...e.style},onKeyDown:U(e.onKeyDown,e=>{e.key===`Escape`&&(s?.(e.nativeEvent),e.nativeEvent.defaultPrevented||O())}),onPointerDown:U(e.onPointerDown,e=>{e.button===0&&(b.current={x:e.clientX,y:e.clientY})}),onPointerMove:U(e.onPointerMove,e=>{if(!b.current)return;let t=e.clientX-b.current.x,n=e.clientY-b.current.y,r=!!x.current,i=[`left`,`right`].includes(h.swipeDirection),a=[`left`,`up`].includes(h.swipeDirection)?Math.min:Math.max,o=i?a(0,t):0,s=i?0:a(0,n),c=e.pointerType===`touch`?10:2,l={x:o,y:s},f={originalEvent:e,delta:l};r?(x.current=l,jr(vr,d,f,{discrete:!1})):Mr(l,h.swipeDirection,c)?(x.current=l,jr(_r,u,f,{discrete:!1}),e.target.setPointerCapture(e.pointerId)):(Math.abs(t)>c||Math.abs(n)>c)&&(b.current=null)}),onPointerUp:U(e.onPointerUp,e=>{let t=x.current,n=e.target;if(n.hasPointerCapture(e.pointerId)&&n.releasePointerCapture(e.pointerId),x.current=null,b.current=null,t){let n=e.currentTarget,r={originalEvent:e,delta:t};Mr(t,h.swipeDirection,h.swipeThreshold)?jr(br,p,r,{discrete:!0}):jr(yr,f,r,{discrete:!0}),n.addEventListener(`click`,e=>e.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null},`ToastImpl`)),Tr=Z(e=>{let{__scopeToast:t,children:n,...r}=e,i=sr(gr,t),[a,o]=G.useState(!1),[s,c]=G.useState(!1);return Nr(()=>o(!0)),G.useEffect(()=>{let e=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(e)},[]),s?null:(0,q.jsx)(at,{asChild:!0,container:i.announcerContainer||void 0,children:(0,q.jsx)(Zn,{...r,children:a&&(0,q.jsxs)(q.Fragment,{children:[i.label,` `,n]})})})},`ToastAnnounce`),Er=G.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e;return(0,q.jsx)(H.div,{...r,ref:t})},`ToastTitle`)),Dr=`ToastClose`,Or=G.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e,i=Cr(Dr,n);return(0,q.jsx)(kr,{asChild:!0,children:(0,q.jsx)(H.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,i.onClose)})})},`ToastClose`)),kr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,altText:r,...i}=e;return(0,q.jsx)(H.div,{"data-radix-toast-announce-exclude":``,"data-radix-toast-announce-alt":r||void 0,...i,ref:t})},`ToastAnnounceExclude`));function Ar(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),Pr(e)){let n=e.ariaHidden||e.hidden||e.style.display===`none`,r=e.dataset.radixToastAnnounceExclude===``;if(!n)if(r){let n=e.dataset.radixToastAnnounceAlt;n&&t.push(n)}else t.push(...Ar(e))}}),t}Z(Ar,`getAnnounceTextContent`);function jr(e,t,n,{discrete:r}){let i=n.originalEvent.currentTarget,a=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ke(i,a):i.dispatchEvent(a)}Z(jr,`handleAndDispatchCustomEvent`);var Mr=Z((e,t,n=0)=>{let r=Math.abs(e.x),i=Math.abs(e.y),a=r>i;return t===`left`||t===`right`?a&&r>n:!a&&i>n},`isDeltaInDirection`);function Nr(e=()=>{}){let t=rt(e);Ye(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}Z(Nr,`useNextFrame`);function Pr(e){return e.nodeType===e.ELEMENT_NODE}Z(Pr,`isHTMLElement`);function Fr(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Z(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}Z(Fr,`getTabbableCandidates`);function Ir(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}Z(Ir,`focusFirst`);var Lr=cr,Rr=pr,zr=xr,Br=Er,Vr=Or;function Hr({value:e,dateStyle:t=`medium`,timeStyle:r=`short`}){let{locale:i}=n(),{timezone:a}=D();if(e==null||e===``)return null;let o={locale:i,timeZone:a},s=O(e,{dateStyle:t,timeStyle:r},o),c=Ur(e),l=E(e,o);return(0,q.jsx)(`time`,{dateTime:c??void 0,title:l||void 0,children:s})}function Ur(e){return T(e)?.toISOString()??null}var Wr={primary:{accent:`border-l-lt-primary`,icon:(0,q.jsx)(R,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-primary`})},secondary:{accent:`border-l-lt-secondary`,icon:(0,q.jsx)(R,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-muted-fg`})},success:{accent:`border-l-lt-success`,icon:(0,q.jsx)(R,{name:`circle-check`,className:`size-lt-icon-lg shrink-0 text-lt-success`})},info:{accent:`border-l-lt-info`,icon:(0,q.jsx)(R,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-info`})},warning:{accent:`border-l-lt-warning`,icon:(0,q.jsx)(R,{name:`circle-alert`,className:`size-lt-icon-lg shrink-0 text-lt-warning`})},danger:{accent:`border-l-lt-danger`,icon:(0,q.jsx)(R,{name:`circle-x`,className:`size-lt-icon-lg shrink-0 text-lt-danger`})}},Gr=0;function Kr({duration:e=4e3}){let{t}=w(`lattice`),[n,r]=(0,G.useState)([]);function i(e){r(t=>t.filter(t=>t.id!==e))}return(0,G.useEffect)(()=>Mn(e=>{r(t=>[...t,{...e,id:Gr++}])}),[]),(0,q.jsxs)(Lr,{duration:e,swipeDirection:`down`,children:[n.map(n=>(0,q.jsxs)(zr,{className:F(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg shadow-lt-lg`,Wr[n.variant].accent,`data-[state=open]:animate-lt-toast-in data-[state=closed]:animate-lt-toast-out`,`data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] data-[swipe=cancel]:translate-y-0 data-[swipe=cancel]:transition-transform`),"data-test":`toast-${n.variant}`,duration:n.persistent?1/0:n.duration??e,onOpenChange:e=>{e||i(n.id)},children:[Wr[n.variant].icon,(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,q.jsx)(Br,{className:`text-sm text-lt-fg`,children:z(n.message,t)}),n.action?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(Y,{node:n.action})}):null]}),n.dismissible?(0,q.jsx)(Vr,{"aria-label":t(`common.dismiss`,`Dismiss`),className:`shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,"data-test":`toast-dismiss`,children:(0,q.jsx)(R,{name:`x`,className:`size-lt-icon-md`})}):null]},n.id)),(0,q.jsx)(Rr,{className:`fixed inset-x-0 bottom-0 z-lt-toast mx-auto flex w-full max-w-sm flex-col gap-2 p-4 outline-none`})]})}var qr=0,Jr=()=>{let{t:e}=w(`lattice`),[t,n]=(0,G.useState)([]);(0,G.useEffect)(()=>Pn(e=>{n(t=>[...e.unique?t.filter(t=>t.unique!==e.unique):t,{...e,id:qr++}])}),[]),(0,G.useEffect)(()=>p.on(`navigate`,()=>{n(e=>e.filter(e=>!e.unique))}),[]),(0,G.useEffect)(()=>Fn(e=>{n(t=>t.filter(t=>t.unique!==e))}),[]);function r(e){n(t=>t.filter(t=>t.id!==e))}return t.length===0?null:(0,q.jsx)(`div`,{className:`flex w-full flex-col gap-2`,children:t.map(t=>(0,q.jsxs)(`div`,{role:`status`,"data-test":`callout-${t.variant}`,className:F(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg`,Wr[t.variant].accent),children:[Wr[t.variant].icon,(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[t.title?(0,q.jsx)(`p`,{className:`text-sm font-medium text-lt-fg`,children:z(t.title,e)}):null,(0,q.jsx)(`p`,{className:`text-sm text-lt-fg`,children:z(t.message,e)}),t.action?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(Y,{node:t.action})}):null]}),t.dismissible?(0,q.jsx)(`button`,{type:`button`,"aria-label":e(`common.dismiss`,`Dismiss`),"data-test":`callout-dismiss`,className:`shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,onClick:()=>r(t.id),children:(0,q.jsx)(R,{name:`x`,className:`size-lt-icon-md`})}):null]},t.id))})},Yr=({node:e})=>{let{t}=w(`lattice`),n=u().props.lattice?.breadcrumbs??[];return n.length===0?null:(0,q.jsx)(`nav`,{"aria-label":t(`common.breadcrumb`,`Breadcrumb`),"data-lattice-component":N(e),children:(0,q.jsx)(`ol`,{className:`flex items-center gap-2 text-sm text-lt-muted-fg`,children:n.map((e,t)=>{let r=t===n.length-1;return(0,q.jsxs)(G.Fragment,{children:[(0,q.jsx)(`li`,{children:r?(0,q.jsx)(`span`,{"aria-current":`page`,className:`text-lt-fg`,children:e.title}):(0,q.jsx)(b,{className:`hover:text-lt-fg`,href:e.href,children:e.title})}),r?null:(0,q.jsx)(`li`,{"aria-hidden":`true`,children:`/`})]},e.href)})})})};function Xr({align:e=`start`,children:t,className:n,placement:r=`bottom`,testId:i,trigger:a,triggerClassName:o,triggerLabel:s}){let[c,l]=(0,G.useState)(!1),d=u().url;return(0,G.useEffect)(()=>l(!1),[d]),(0,q.jsxs)(De,{open:c,onOpenChange:l,children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{"aria-label":s,className:F(`w-full`,o),"data-test":i,title:s,type:`button`,children:a})}),(0,q.jsx)(B,{align:e,className:F(`min-w-56 p-1`,n),role:`menu`,side:r,children:(0,q.jsx)(wn.Provider,{value:!1,children:t})})]})}var Zr=({children:e,node:t})=>{let n=t.key??`dropdown`;return(0,q.jsx)(Xr,{placement:t.props.placement,testId:n,triggerClassName:`w-auto`,trigger:(0,q.jsx)(`span`,{className:`flex min-w-0 items-center rounded-lt-sm px-2 py-1.5 text-sm hover:bg-lt-muted`,children:t.props.trigger.map((e,t)=>(0,q.jsx)(Y,{node:e},e.key??`${e.type}-${t}`))}),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})})},Qr=({children:e,node:t})=>(0,q.jsx)(`nav`,{"data-lattice-component":N(t),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})}),$r=(0,G.createContext)(null),ei=`flex items-center gap-2 rounded-lt-sm px-3 py-2 text-base font-medium text-lt-fg transition-colors hover:bg-lt-muted`;function ti({affix:e,className:t}){return e.icon?(0,q.jsx)(P,{className:F(`size-lt-icon-md shrink-0`,t),icon:e.icon}):(0,q.jsx)(`span`,{className:F(`shrink-0 text-sm text-lt-muted-fg`,t),children:e.text})}function ni(e,t){return(e??[]).some(e=>e.props?.href===t||ni(e.schema,t))}var ri=({children:e,node:t})=>{let n=Tn(),{icon:r,label:i,prefix:a,suffix:o}=t.props,s=i??``,c=!!r,l=r??a?.icon??null,d=u().url.split(`?`)[0],f=j(`menu`,t),p=ee(t.props),m=r?(0,q.jsx)(P,{className:`size-lt-icon-md shrink-0`,icon:r}):(0,q.jsxs)(q.Fragment,{children:[a?(0,q.jsx)(ti,{affix:a}):null,n?(0,q.jsx)(`span`,{className:`pointer-events-none absolute top-1/2 left-full z-lt-popover ml-2 hidden -translate-y-1/2 rounded-lt-sm border border-lt-border bg-lt-popover px-2 py-1 text-sm whitespace-nowrap text-lt-popover-fg shadow-lt-md group-hover:block`,role:`tooltip`,children:s}):(0,q.jsx)(`span`,{children:s}),o?(0,q.jsx)(ti,{affix:o,className:`ml-auto`}):null]}),h=F(ei,`w-full`,n&&`group relative justify-center`,c&&`justify-center`),g=({onClick:e,processing:t})=>(0,q.jsx)(`button`,{"aria-label":n||c?s:void 0,className:h,"data-test":f,disabled:t,onClick:e,type:`button`,children:m});if(p.kind===`action`)return(0,q.jsx)(`li`,{children:(0,q.jsx)(te,{action:p.action,children:g})});if(p.kind===`effects`)return(0,q.jsx)(`li`,{children:g({onClick:p.onClick,processing:!1})});if(p.kind===`navigate`){let e=d===p.href;return(0,q.jsx)(`li`,{children:(0,q.jsx)(b,{"aria-current":e?`page`:void 0,"aria-label":n||c?s:void 0,as:p.method===`get`?void 0:`button`,className:F(h,e&&`bg-lt-muted font-medium`),"data-test":f,href:p.href,method:p.method,children:m})})}return e?n?(0,q.jsx)(ai,{icon:l,label:s,testId:f,children:e}):(0,q.jsx)(ii,{content:m,defaultOpen:ni(t.schema,d),testId:f,children:e}):n?null:(0,q.jsx)(`li`,{children:(0,q.jsx)(`span`,{className:`flex items-center gap-2 px-3 py-2 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:m})})};function ii({children:e,content:t,defaultOpen:n,testId:r}){let[i,a]=(0,G.useState)(n);return(0,q.jsxs)(`li`,{children:[(0,q.jsxs)(`button`,{"aria-expanded":i,className:F(ei,`w-full`),"data-test":r,onClick:()=>a(e=>!e),type:`button`,children:[t,(0,q.jsx)(R,{name:`chevron-right`,className:F(`ml-auto size-lt-icon-md shrink-0 transition-transform`,i&&`rotate-90`)})]}),i?(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1 pl-3`,children:e}):null]})}function ai({children:e,icon:t,label:n,testId:r}){return(0,q.jsx)(`li`,{children:(0,q.jsx)(Xr,{className:`min-w-48`,placement:`right`,testId:r,trigger:t?(0,q.jsx)(P,{className:`size-lt-icon-md shrink-0`,icon:t}):(0,q.jsx)(`span`,{children:n}),triggerClassName:F(ei,`justify-center`),triggerLabel:n,children:(0,q.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`li`,{className:`px-3 py-1.5 text-xs font-semibold tracking-wide text-lt-muted-fg uppercase`,children:n}),e]})})})}var oi=()=>(0,q.jsx)(q.Fragment,{children:(0,G.useContext)($r)});function si(e,t){return typeof window>`u`||typeof window.matchMedia!=`function`?t:window.matchMedia(e).matches}function ci(e,t=!1){let[n,r]=(0,G.useState)(()=>si(e,t));return(0,G.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}function li(e,t,n={}){let{enabled:r=!0,parse:i,serialize:a}=n,o=()=>typeof t==`function`?t():t,[s,c]=(0,G.useState)(()=>{if(!r||typeof window>`u`)return o();let t;try{t=window.localStorage.getItem(e)}catch{return o()}if(t===null)return o();try{return i?i(t):JSON.parse(t)}catch{try{window.localStorage.removeItem(e)}catch{return o()}return o()}}),l=(0,G.useRef)(s);l.current=s;let u=(0,G.useRef)({enabled:r,key:e,serialize:a});return u.current={enabled:r,key:e,serialize:a},[s,(0,G.useCallback)(e=>{let t=typeof e==`function`?e(l.current):e;l.current=t,c(t);let{enabled:n,key:r,serialize:i}=u.current;if(!(!n||typeof window>`u`))try{let e=i?i(t):JSON.stringify(t);e===null?window.localStorage.removeItem(r):window.localStorage.setItem(r,e)}catch{return}},[])]}function ui(e,t,n){let[r,i]=li(e,t,{enabled:n,parse:e=>e===`true`,serialize:String});return[r,(0,G.useCallback)(()=>i(e=>!e),[i])]}var di=`(min-width: 768px)`;function fi(e,t){let n=e.detail?.target;return n==null||n===t}var pi=_n({components:{breadcrumbs:K(Yr),callouts:K(Jr),dropdown:K(Zr),menu:K(Qr),"menu-item":K(ri),outlet:K(oi),sidebar:K(({children:e,node:t})=>{let n=t.props.collapsible,r=t.props.rememberState,a=N(t),o=`lattice:sidebar:${a??`default`}`,s=ci(di,!0),[c,l]=ui(o,!1,n&&r),[u,d]=(0,G.useState)(!1);bn(i.toggleSidebar,e=>{fi(e,a)&&(window.matchMedia?.(di).matches??!0?n&&l():d(e=>!e))}),(0,G.useEffect)(()=>p.on(`navigate`,()=>d(!1)),[]),bn(`keydown`,e=>{e.key===`Escape`&&d(!1)},{enabled:u});let f=n&&c&&s;return(0,q.jsxs)(wn.Provider,{value:f,children:[u?(0,q.jsx)(`div`,{"aria-hidden":`true`,className:`fixed inset-0 z-lt-overlay bg-lt-overlay md:hidden`,"data-test":`sidebar-backdrop`,onClick:()=>d(!1)}):null,(0,q.jsx)(`aside`,{className:F(`fixed inset-y-0 left-0 z-lt-modal flex h-svh w-72 max-w-[80vw] shrink-0 flex-col gap-4 border-r border-lt-border bg-lt-bg p-4 transition-transform`,`md:sticky md:top-0 md:z-auto md:max-w-none md:translate-x-0 md:transition-[width]`,u?`translate-x-0`:`-translate-x-full`,f?`md:w-16 md:overflow-visible`:`md:w-64 md:overflow-x-hidden md:overflow-y-auto`),"data-collapsed":f?`true`:`false`,"data-lattice-component":a,"data-test":`sidebar`,children:e})]})}),topbar:K(({children:e,node:t})=>{let n=t.props.sticky;return(0,q.jsx)(`header`,{"data-lattice-component":N(t),className:F(`flex h-14 w-full items-center gap-2 border-b border-lt-border bg-lt-bg px-4 text-lt-fg`,n&&`sticky top-0 z-lt-sticky`),children:e})})},name:`lattice/layout`});function mi({children:e}){let t=u().props.lattice.layout;return t?(0,q.jsx)($r.Provider,{value:e,children:(0,q.jsx)(J,{nodes:t.schema})}):(0,q.jsx)(q.Fragment,{children:e})}var hi=(0,G.lazy)(()=>tn(()=>import(`./chunks/subscriptions-HzwKFUPT.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),gi=class extends G.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){console.warn(`[lattice] Real-time listeners are declared but Echo is unavailable. Install @laravel/echo-react and call configureEcho().`)}render(){return this.state.failed?null:this.props.children}};function _i({listeners:e}){return e.length===0?null:(0,q.jsx)(gi,{children:(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(hi,{listeners:e})})})}function vi({lattice:e}){let t=(0,q.jsx)(J,{nodes:e.schema});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(f,{title:e.title??void 0}),(0,q.jsx)(_i,{listeners:e.listeners}),e.container===`centered`?(0,q.jsx)(`main`,{className:`min-h-svh bg-lt-bg text-lt-fg`,children:(0,q.jsx)(`div`,{"data-test":`lattice-centered-container`,className:`mx-auto flex min-h-svh w-full max-w-6xl flex-col justify-center px-6 py-12 sm:px-8 lg:px-10`,children:t})}):(0,q.jsx)(`div`,{"data-test":`lattice-default-container`,className:F(`w-full`,{"px-4 py-6":e.layout!==null}),children:t})]})}function yi(e){return t=>{if(t===`lattice/page`)return{default:vi};let n=e[`./Pages/${t}.tsx`]??e[`./pages/${t}.tsx`];if(n)return n();throw Error(`Page not found: ${t}`)}}function bi({defaultLayout:e}={}){return(t,n)=>t===`lattice/page`?n.props.lattice?.layout?mi:null:e?.(t,n)??null}function xi(e,t){return{...t,headers:Mt(``,t.headers)}}var Si=!1;function Ci(){Si||(Si=!0,g.onRequest(e=>{let t=e.headers?.[Dt];return e.headers&&typeof t==`string`&&t!==``&&(e.headers[Dt]=kt(t)),e}))}var wi=Object.defineProperty,Q=(e,t)=>wi(e,`name`,{value:t,configurable:!0}),Ti=`Dialog`,[Ei,Di]=st(Ti),[Oi,ki]=Ei(Ti),Ai=Q(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=G.useRef(null),c=G.useRef(null),[l,u]=oe({prop:r,defaultProp:i??!1,onChange:a,caller:Ti}),[d,f]=G.useState(0),[p,m]=G.useState(0);return(0,q.jsx)(Oi,{scope:t,triggerRef:s,contentRef:c,contentId:Oe(),titleId:Oe(),descriptionId:Oe(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:G.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),ji=`DialogPortal`,[Mi,Ni]=Ei(ji,{forceMount:void 0}),Pi=Q(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ki(ji,t);return(0,q.jsx)(Mi,{scope:t,forceMount:n,children:G.Children.map(r,e=>(0,q.jsx)(Le,{present:n||a.open,children:(0,q.jsx)(at,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Fi=`DialogOverlay`,Ii=G.forwardRef(Q(function(e,t){let n=Ni(Fi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ki(Fi,e.__scopeDialog);return a.modal?(0,q.jsx)(Le,{present:r||a.open,children:(0,q.jsx)(Ri,{...i,ref:t})}):null},`DialogOverlay`)),Li=L(`DialogOverlay.RemoveScroll`),Ri=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=ki(Fi,n),a=Ze(),o=I(t,a);return(0,q.jsx)($e,{as:Li,allowPinchZoom:!0,shards:[i.contentRef],children:(0,q.jsx)(H.div,{"data-state":Xi(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),zi=`DialogContent`,Bi=G.forwardRef(Q(function(e,t){let n=Ni(zi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ki(zi,e.__scopeDialog);return(0,q.jsx)(Le,{present:r||a.open,children:a.modal?(0,q.jsx)(Vi,{...i,ref:t}):(0,q.jsx)(Hi,{...i,ref:t})})},`DialogContent`)),Vi=G.forwardRef(Q(function(e,t){let n=ki(zi,e.__scopeDialog),r=G.useRef(null),i=I(t,n.contentRef,r);return G.useEffect(()=>{let e=r.current;if(e)return he(e)},[]),(0,q.jsx)(Ui,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:U(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:U(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:U(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Hi=G.forwardRef(Q(function(e,t){let n=ki(zi,e.__scopeDialog),r=G.useRef(!1),i=G.useRef(!1);return(0,q.jsx)(Ui,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Ui=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ki(zi,n);return xe(),(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(Ae,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,q.jsx)(He,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Xi(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Wi=`DialogTitle`,Gi=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=ki(Wi,n),{setTitleCount:a}=i;return Ye(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,q.jsx)(H.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Ki=`DialogDescription`,qi=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=ki(Ki,n),{setDescriptionCount:a}=i;return Ye(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,q.jsx)(H.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Ji=`DialogClose`,Yi=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=ki(Ji,n);return(0,q.jsx)(H.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Xi(e){return e?`open`:`closed`}Q(Xi,`getState`);var Zi=re(`fixed z-lt-modal w-full overflow-y-auto bg-lt-bg p-6 shadow-lt-lg`,{variants:{placement:{center:`left-1/2 top-1/2 max-h-[min(680px,calc(100vh-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-lt border border-lt-border data-[state=open]:animate-lt-dialog-in data-[state=closed]:animate-lt-dialog-out`,start:`inset-y-0 start-0 border-e border-lt-border data-[state=open]:animate-lt-sheet-in-start data-[state=closed]:animate-lt-sheet-out-start`,end:`inset-y-0 end-0 border-s border-lt-border data-[state=open]:animate-lt-sheet-in-end data-[state=closed]:animate-lt-sheet-out-end`},width:{sm:`max-w-sm`,md:`max-w-md`,lg:`max-w-lg`,xl:`max-w-xl`,"2xl":`max-w-2xl`,"3xl":`max-w-3xl`}},defaultVariants:{placement:`center`,width:`lg`}});function Qi(e){return(0,q.jsx)(Ai,{"data-slot":`dialog`,...e})}function $i(e){return(0,q.jsx)(Yi,{"data-slot":`dialog-close`,...e})}function ea({className:e,...t}){return(0,q.jsx)(Gi,{className:F(`text-lg font-semibold leading-none tracking-tight`,e),"data-slot":`dialog-title`,...t})}function ta({className:e,...t}){return(0,q.jsx)(qi,{className:F(`text-sm text-lt-muted-fg`,e),"data-slot":`dialog-description`,...t})}function na({children:e,className:t,placement:n=`center`,width:r=`lg`,...i}){return(0,q.jsxs)(Pi,{children:[(0,q.jsx)(Ii,{className:`fixed inset-0 z-lt-overlay bg-lt-overlay data-[state=open]:animate-lt-fade-in data-[state=closed]:animate-lt-fade-out`,"data-slot":`dialog-overlay`}),(0,q.jsx)(Bi,{className:F(Zi({placement:n,width:r}),t),"data-slot":`dialog-content`,...i,children:e})]})}function ra({closeLabel:e,description:t,title:n}){return(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(ea,{children:n}),t?(0,q.jsx)(ta,{children:t}):null]}),(0,q.jsx)($i,{asChild:!0,children:(0,q.jsx)(W,{"aria-label":e,"data-test":`dialog-close`,size:`icon`,emphasis:`ghost`,children:(0,q.jsx)(R,{name:`x`,"aria-hidden":`true`,className:`size-lt-icon-md`})})})]})}function ia({className:e,...t}){let{t:n}=w(`lattice`);return(0,q.jsx)(R,{name:`loader-2`,role:`status`,"aria-label":n(`common.loading`,`Loading`),"aria-hidden":!1,className:F(`animate-spin`,e),...t})}function aa({title:e,description:t,confirmLabel:n,cancelLabel:r=`Cancel`,confirmVariant:i=null,confirmEmphasis:a=null,processing:o=!1,confirmDisabled:s=!1,onConfirm:c,onCancel:l}){let u=e=>{o&&e.preventDefault()};return(0,q.jsx)(Qi,{open:!0,onOpenChange:e=>{e||l()},children:(0,q.jsxs)(na,{...t?{}:{"aria-describedby":void 0},width:`md`,onEscapeKeyDown:u,onInteractOutside:u,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(ea,{children:e}),t&&(0,q.jsx)(ta,{children:t})]}),(0,q.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,q.jsx)(W,{type:`button`,emphasis:`outline`,"data-test":`confirm-cancel`,disabled:o,onClick:l,children:r}),(0,q.jsxs)(W,{type:`button`,emphasis:a,variant:i,"data-test":`confirm-accept`,disabled:o||s,onClick:c,children:[o&&(0,q.jsx)(ia,{}),n]})]})]})})}async function oa(e,t){try{let n=await e(),r=await n.json().catch(()=>({}));return t(_(r.effects)),n.ok}catch(e){return m(e),!1}}function sa({className:e,...t}){return(0,q.jsx)(`div`,{"aria-hidden":`true`,className:F(`animate-pulse rounded-lt-sm bg-lt-muted`,e),"data-slot":`skeleton`,...t})}var ca=(0,G.createContext)({});function la({nodes:e,children:t}){return(0,q.jsx)(ca.Provider,{value:e,children:t})}function ua(e){let t=(0,G.useContext)(ca),n=ft(e).name??``,r=lt(),i=n&&r?r.errorKey(n):n;return i&&t[i]||n&&t[n]||e}function da(e,t,n,r){return Ut(e,{method:`POST`,ref:t,signal:r,body:JSON.stringify(n),throwOnError:!1}).then(e=>e.ok?e.json():null)}function fa(e){return e.templates}function pa(e,t){let n=fa(e);return n?n.find(e=>e.type===t.type)?.schema??[]:e.schema??[]}function ma(e,t){return e.startsWith(`@`)?e.slice(1):t===null?e:be(t,e)}function ha(e,t,n,r=0,i={}){let a=ft(e);if(!a.editablePrefill||!a.name)return null;let o=de(i);return{path:t===null?a.name:be(t,a.name),overrideKey:n===null?a.name:we(n,o,r,a.name),resetOn:(a.prefillResetOn??[]).map(e=>ma(e,t)),refreshOn:(a.prefillRefreshOn??[]).map(e=>ma(e,t))}}function ga(e,t){let n=[],r=(e,i=null,a=null,o=null,s=0,c={})=>{for(let l of e??[]){if(Se.has(l.type)){let e=ft(l).name;if(e){let n=be(i,e),o=be(a,e),s=fe(t,n);(Array.isArray(s)?s:[]).forEach((e,t)=>{r(pa(l,e),be(n,t),be(o,de(e)??t),o,t,e)})}continue}let e=ha(l,i,o,s,c);e&&n.push(e),r(l.schema,i,a,o,s,c)}};return r(e),n}function _a(e,t){let n=new Map(e.targets.map(e=>[e.overrideKey,e]));return t.targets.filter(r=>{let i=n.get(r.overrideKey);return r.resetOn.some((n,r)=>{let a=i?.resetOn[r]??n;return!Object.is(fe(e.values,a),fe(t.values,n))})}).map(e=>e.overrideKey)}function va(e,t){return e.filter(e=>{let n=fe(t,e.path);return n!=null&&n!==``}).map(e=>e.overrideKey)}function ya(e,t){let n=new Set(t.map(e=>e.overrideKey));return new Set([...e].filter(e=>n.has(e)))}function ba(e,t,n){let r=Pe(),i=Ce(),[a,o]=(0,G.useState)({}),s=(0,G.useMemo)(()=>ga(n,r),[n,r]),c=(0,G.useRef)(new Set),l=(0,G.useRef)(new Set),u=(0,G.useRef)(r),d=(0,G.useRef)(s),f=(0,G.useRef)(s);f.current=s,(0,G.useLayoutEffect)(()=>{let e=new Set(s.map(e=>e.overrideKey));l.current=new Set([...l.current].filter(t=>e.has(t)));let t=s.filter(e=>!l.current.has(e.overrideKey));for(let e of va(t,r))c.current.add(e);for(let e of t)l.current.add(e.overrideKey)},[s,r]);let p=(0,G.useCallback)(e=>{c.current.add(e)},[]),m=(0,G.useMemo)(()=>{let e=new Set,t=!1;return ce(n,n=>{if(Array.isArray(n.dependsOnKeys))for(let t of n.dependsOnKeys)e.add(String(t));n.dependsOnAny&&(t=!0)}),{keys:[...e],any:t}},[n]),h=(0,G.useMemo)(()=>{let e=new Set(m.keys);for(let t of s){for(let n of t.resetOn)e.add(n);for(let n of t.refreshOn)e.add(n)}return[...e]},[m.keys,s]),g=m.any?r:JSON.stringify(h.map(e=>fe(r,e)));return(0,G.useEffect)(()=>{if(h.length===0&&!m.any)return;let n=u.current;u.current=r;for(let e of _a({targets:d.current,values:n},{targets:f.current,values:r}))c.current.delete(e);d.current=f.current,c.current=ya(c.current,f.current);let a=new AbortController,s=window.setTimeout(()=>{da(e,t,{_sub:`resolve`,...r},a.signal).then(e=>{if(!e)return;for(let[t,n]of Object.entries(e.values??{}))i(t,n);let t=new Map(f.current.map(e=>[e.path,e]));for(let[n,r]of Object.entries(e.prefill??{})){let e=t.get(n);e&&!c.current.has(e.overrideKey)&&i(n,r)}e.fields&&o(e.fields)}).catch(()=>{})},250);return()=>{window.clearTimeout(s),a.abort()}},[g,e,t,m.any,i]),{nodes:a,markUserEdit:p}}function xa(e){let t={labels:{},values:{}};return ce(e,e=>{e.name&&(e.label&&(t.labels[e.name]=e.label),e.value!==void 0&&(t.values[e.name]=e.value))}),t}function Sa(e,t){return e===t||e.startsWith(`${t}.`)}function Ca(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=Array.isArray(r)?r[0]:r;return t}function wa(e,t){let n=(0,G.useRef)(e);n.current=e;let r=(0,G.useRef)(null),i=(0,G.useCallback)(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]);return(0,G.useEffect)(()=>i,[i]),(0,G.useMemo)(()=>{let e=(...e)=>{i(),r.current=setTimeout(()=>{r.current=null,n.current(...e)},t)};return e.cancel=i,e},[i,t])}function Ta(e,t,n){let[r,i]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!n){i(null);return}let r=new AbortController;return Ut(e,{body:JSON.stringify({_sub:`schema`}),ref:t,method:`POST`,signal:r.signal,throwOnError:!1}).then(e=>e.ok?e.json():null).then(e=>i(e)).catch(()=>{}),()=>r.abort()},[n,e,t]),r}function Ea(){return(0,q.jsxs)(`div`,{className:`space-y-4`,"data-lattice-action-form-loading":!0,children:[(0,q.jsx)(sa,{className:`h-4 w-24`}),(0,q.jsx)(sa,{className:`h-10 w-full`}),(0,q.jsx)(sa,{className:`h-10 w-full`})]})}function Da({cancelLabel:e,componentRef:t,endpoint:n,extraData:r,fieldLabels:i,formNode:a,method:o,onClose:s,onSuccess:c,precognitive:l,submitLabel:u}){let d=Pe(),f=(0,G.useRef)(d);f.current=d;let p=(0,G.useRef)(r);p.current=r;let{nodes:h,markUserEdit:g}=ba(n,t,a.schema),v=y(),[b,x]=(0,G.useState)({}),[S,C]=(0,G.useState)(!1),[w,T]=(0,G.useState)(!1),E=(0,G.useCallback)(e=>Ut(n,{body:JSON.stringify({...f.current,...p.current}),method:o,ref:t,headers:e,throwOnError:!1}),[t,n,o]),D=(0,G.useCallback)(e=>{x(t=>t[e]===void 0?t:{...t,[e]:void 0})},[]),O=wa(e=>{E({Precognition:`true`,"Precognition-Validate-Only":e}).then(async t=>{if(t.status===422){let e=await t.json();x(t=>({...t,...Ca(e.errors)}));return}D(e)}).catch(()=>{})},250),k=(0,G.useCallback)(e=>{l&&O(e)},[l,O]),A=(0,G.useCallback)(()=>{},[]),j=(0,G.useCallback)((e,t)=>{T(!0),E({Precognition:`true`,"Precognition-Validate-Only":e.join(`,`)}).then(async n=>{if(n.status===422){let e=await n.json();x(t=>({...t,...Ca(e.errors)})),t?.onValidationError?.();return}if(!n.ok){t?.onValidationError?.();return}let r=e.filter(e=>!e.includes(`*`));x(e=>Object.fromEntries(Object.entries(e).filter(([e])=>!r.some(t=>Sa(e,t))))),t?.onSuccess?.()}).catch(()=>t?.onValidationError?.()).finally(()=>T(!1))},[E]),M=(0,G.useCallback)(()=>{C(!0),E().then(async e=>{let t=await e.json().catch(()=>({}));if(v(_(t.effects)),e.status===422&&t.errors){x(Ca(t.errors));return}e.ok&&c(t)}).catch(e=>m(e)).finally(()=>C(!1))},[v,c,E]),N=(0,G.useMemo)(()=>({action:n,clearErrors:D,componentRef:t,errors:b,fieldLabels:i,precognitive:l,processing:S,touch:A,validate:k,validateFields:j,validating:w}),[D,t,n,b,i,l,S,A,k,j,w]);return(0,q.jsx)(pe,{value:N,children:(0,q.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,q.jsx)(Ee,{value:{markUserEdit:g},children:(0,q.jsx)(la,{nodes:h,children:(0,q.jsx)(J,{nodes:a.schema??[]})})}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,q.jsx)(W,{"data-test":`action-form-cancel`,disabled:S,onClick:s,type:`button`,emphasis:`ghost`,children:e}),a.props?.submitButton!==!1&&(0,q.jsxs)(W,{"data-test":`action-form-submit`,disabled:S,type:`submit`,children:[S&&(0,q.jsx)(ia,{}),u]})]})]})})}function Oa({formNode:e,...t}){let n=!!e.props?.precognitive,{labels:r,values:i}=(0,G.useMemo)(()=>{let{labels:t,values:n}=xa(e.schema);return{labels:t,values:{...n,...e.props?.state}}},[e]);return(0,q.jsx)(ct,{initial:i,children:(0,q.jsx)(Da,{fieldLabels:r,formNode:e,precognitive:n,...t})})}function ka({description:e,formNode:t,onClose:n,placement:r,title:i,width:a,...o}){let{t:s}=w(`lattice`);return(0,q.jsx)(Qi,{open:!0,onOpenChange:e=>{e||n()},children:(0,q.jsxs)(na,{...e?{}:{"aria-describedby":void 0},placement:r,width:a,children:[(0,q.jsx)(ra,{closeLabel:s(`common.close`,`Close`),description:e,title:i}),(0,q.jsx)(`div`,{className:`mt-6`,children:t?(0,q.jsx)(Oa,{formNode:t,onClose:n,...o}):(0,q.jsx)(Ea,{})})]})})}function Aa(e){return e.props.label??C(`lattice`,`common.action.run`,`Run action`)}function ja(e){let t=e.props.endpoint??``,n=e.props.ref??``,r=e.props.method??`post`,i=Aa(e),{variant:a,emphasis:o}=e.props,s=e.props.confirmation,c=e.props.form,l=e.props.lazyForm===!0,u=!!c||l,[d,f]=(0,G.useState)(!1),m=y(),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),b=Ta(t,n,_&&l),x=l?b:c,S=async()=>{if(!t)return;if(r===`get`){p.visit(t,{headers:Mt(n)}),g(!1);return}f(!0);let e=await oa(()=>Ut(t,{method:r,ref:n,throwOnError:!1}),m);f(!1),e&&g(!1)},w=()=>{if(u){v(!0);return}if(s){g(!0);return}S()},T=s?.title??i,E=s?.confirmLabel??i,D=s?.cancelLabel??C(`lattice`,`common.cancel`,`Cancel`);return{processing:d,requestSubmit:w,overlays:(0,q.jsxs)(q.Fragment,{children:[h&&s&&(0,q.jsx)(aa,{title:T,description:s.description??void 0,confirmLabel:E,cancelLabel:D,confirmVariant:a,confirmEmphasis:o,processing:d,confirmDisabled:!t,onConfirm:()=>void S(),onCancel:()=>g(!1)}),_&&u&&(0,q.jsx)(ka,{cancelLabel:D,componentRef:n,description:s?.description??void 0,endpoint:t,formNode:x,method:r,onClose:()=>v(!1),onSuccess:()=>{v(!1)},placement:e.props.modalSide??`center`,submitLabel:E,title:T,width:e.props.modalWidth??void 0})]})}}function Ma({action:e,children:t}){let{processing:n,requestSubmit:r,overlays:i}=ja(e);return(0,q.jsxs)(q.Fragment,{children:[t({onClick:r,processing:n}),i]})}function Na({children:e}){return(0,q.jsx)(ne,{render:e=>(0,q.jsx)(Ma,{action:e.action,children:e.children}),children:e})}function Pa(){let e=y();(0,G.useEffect)(()=>p.on(`flash`,t=>{let n=_(t.detail?.flash?.latticeEffects);n.length>0&&e(n)}),[e])}function Fa({onAppearanceChange:e,onLocaleChange:t,onToast:n}){return(0,G.useEffect)(()=>{if(n)return Mn(n)},[n]),bn(i.appearanceChange,t=>{let n=t.detail?.value;on(n)&&e?.(n)},{enabled:!!e}),bn(i.localeChange,e=>{let n=e.detail?.locale;typeof n==`string`&&n!==``&&t?.(n)},{enabled:!!t}),null}var Ia={href:``};function La({children:e,registry:t,sprite:n=Ia,toaster:r=!0}){return Pa(),(0,q.jsx)(d.Provider,{value:t,children:(0,q.jsx)(Na,{children:(0,q.jsxs)(ie,{sprite:n,children:[e,(0,q.jsx)(Fa,{onAppearanceChange:hn}),r?(0,q.jsx)(Kr,{}):null]})})})}var Ra=_n({components:{action:K(({node:e})=>{let t=e.props.endpoint??``,n=e.props.icon,r=Aa(e),i=qe(),{variant:a,emphasis:o}=e.props,{processing:s,requestSubmit:c,overlays:l}=ja(e),u=e.key??M(`action`,e.id);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(W,{className:i?Qe:void 0,"data-lattice-component":e.id,"data-test":u,disabled:s||!t,onClick:c,type:`button`,emphasis:i?`ghost`:o,variant:i?null:a,children:[s?(0,q.jsx)(ia,{className:i?`size-lt-icon-sm`:void 0}):n&&(0,q.jsx)(P,{className:i?`size-lt-icon-sm`:`size-lt-icon-md`,icon:n}),r]}),l]})}),"action.group":K(({children:e,node:t})=>{let{t:n}=w(`lattice`),r=t.props.label??n(`common.action-group.label`,`Actions`),i=t.props.orientation;return i?(0,q.jsx)(`div`,{"aria-label":r,className:F(`inline-flex max-w-full gap-1`,i===`vertical`?`flex-col items-stretch`:`flex-row flex-wrap items-center`),"data-lattice-component":t.id,role:`group`,children:e}):(0,q.jsx)(`div`,{className:`inline-flex`,"data-lattice-component":t.id,children:(0,q.jsxs)(Fe,{children:[(0,q.jsx)(Ie,{asChild:!0,children:(0,q.jsx)(W,{"aria-label":r,className:`size-lt-control-sm text-lt-muted-fg shadow-none hover:text-lt-fg`,"data-test":N(t),size:`icon`,type:`button`,emphasis:`ghost`,children:(0,q.jsx)(R,{name:`more-horizontal`,"aria-hidden":`true`,className:`size-lt-icon-md`})})}),(0,q.jsx)(Ge,{align:`end`,"aria-label":r,className:`min-w-44 gap-0.5 p-1.5`,sideOffset:8,children:(0,q.jsx)(Re,{children:e})})]})})})},name:`lattice/action`});function za(e){try{return JSON.parse(e)}catch{return null}}async function*Ba({url:e,body:t,signal:n}){let r=await Ut(e,{method:`POST`,signal:n,headers:{Accept:`application/x-ndjson`},body:JSON.stringify(t),throwOnError:!1});if(!r.ok||!r.body)throw Error(`Chat stream failed (${r.status})`);yield*Ha(r.body)}function Va(e){return async function*({url:t,body:n,signal:r}){let i=await Xt(t,{remote:e,method:`POST`,signal:r,headers:{Accept:`application/x-ndjson`,"Content-Type":`application/json`},body:JSON.stringify(n),throwOnError:!1});if(!i.ok||!i.body)throw Error(`Chat stream failed (${i.status})`);yield*Ha(i.body)}}async function*Ha(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
3
+ `);r=a.pop()??``;for(let e of a){if(e.trim()===``)continue;let t=za(e);t&&(yield t)}}if(r+=n.decode(),r.trim()!==``){let e=za(r);e&&(yield e)}}finally{await t.cancel().catch(()=>{})}}var Ua=0;function Wa(){return Ua+=1,`chat-${Ua}`}function Ga(e){return e instanceof DOMException&&e.name===`AbortError`}function Ka(e){return e instanceof Error?e.message:String(e)}function qa(e){let t=e.at(-1);return t!==void 0&&t.role===`assistant`}function Ja(e,t){if(!qa(e))return e;let n=e.length-1,r=e[n];if(t.type===`text`){let i=[...r.parts],a=i.length-1,o=i[a];o!==void 0&&o.type===`chat.part.text`?i[a]={type:`chat.part.text`,props:{text:`${o.props.text}${t.value}`}}:i.push({type:`chat.part.text`,props:{text:t.value}});let s=[...e];return s[n]={...r,parts:i},s}if(t.type===`part`){let i=[...e];return i[n]={...r,parts:[...r.parts,t.part]},i}return e}function Ya({endpoint:e,transport:t=Ba,initialMessages:n=[],generateId:r=Wa}){let[i,a]=(0,G.useState)(n),[o,s]=(0,G.useState)(`idle`),[c,l]=(0,G.useState)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(null),f=(0,G.useRef)(i);f.current=i;let p=(0,G.useCallback)(e=>{f.current=e,a(e)},[]),m=(0,G.useCallback)(async(n,i)=>{u.current?.abort();let a=new AbortController;u.current=a,l(null),s(`submitted`);let o={id:r(),role:`user`,parts:[{type:`chat.part.text`,props:{text:i}}]},c={id:r(),role:`assistant`,parts:[]};p([...n,o,c]),s(`streaming`);try{for await(let n of t({url:e,body:{message:i},signal:a.signal})){if(n.type===`done`){s(`idle`);continue}if(n.type===`error`){l(n.message??`Chat failed`),s(`error`);continue}p(Ja(f.current,n))}s(e=>e===`streaming`||e===`submitted`?`idle`:e)}catch(e){if(Ga(e)){s(`idle`);return}l(Ka(e)),s(`error`)}},[p,e,r,t]),h=(0,G.useCallback)(e=>{let t=e.trim();t!==``&&(d.current=t,m(f.current,t))},[m]),g=(0,G.useCallback)(()=>{u.current?.abort(),s(`idle`)},[]),_=(0,G.useCallback)(()=>{let e=d.current;if(e===null)return;let t=f.current,n=qa(t)?t.slice(0,-2):t;m(n,e)},[m]);return(0,G.useEffect)(()=>()=>{u.current?.abort()},[]),{messages:i,status:o,error:c,sendMessage:h,setMessages:p,stop:g,regenerate:_}}function Xa({message:e}){let t=e.role===`user`;return(0,q.jsx)(`div`,{className:F(`flex flex-col gap-1`,t?`items-end`:`items-start`),"data-test":A(`chat-message-${e.role}`),children:(0,q.jsx)(`div`,{className:F(`max-w-[80%] rounded-lt px-3 py-2 text-sm`,t?`bg-lt-primary text-lt-primary-fg`:`bg-lt-muted text-lt-fg`),children:e.parts.map((e,t)=>(0,q.jsx)(Y,{node:e},e.key??t))})})}function Za({messages:e}){let t=(0,G.useRef)(null),n=e.at(-1),r=n?.parts.at(-1)===void 0?0:JSON.stringify(n.parts.at(-1)).length;return(0,G.useEffect)(()=>{t.current&&typeof t.current.scrollIntoView==`function`&&t.current.scrollIntoView({behavior:`smooth`})},[e.length,r]),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 overflow-y-auto p-3`,"data-test":A(`chat-messages`),children:[e.map(e=>(0,q.jsx)(Xa,{message:e},e.id)),(0,q.jsx)(`div`,{ref:t})]})}function Qa({onSubmit:e,disabled:t=!1,placeholder:n}){let{t:r}=w(`lattice`),[i,a]=(0,G.useState)(``);function o(){let n=i.trim();n===``||t||(e(n),a(``))}function s(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),o())}return(0,q.jsxs)(`div`,{className:`flex items-end gap-2 border-t border-lt-border p-3`,children:[(0,q.jsx)(`textarea`,{"aria-label":r(`common.chat.input-label`,`Message input`),className:F(`min-h-[2.5rem] flex-1 resize-none rounded-lt-sm border border-lt-input bg-lt-bg px-3 py-2 text-sm text-lt-fg placeholder:text-lt-muted-fg focus:outline-none focus:ring-[length:var(--lt-ring-width)] focus:ring-lt-ring/50 disabled:bg-lt-disabled disabled:text-lt-disabled-fg`),"data-test":A(`chat-input`),disabled:t,onChange:e=>a(e.target.value),onKeyDown:s,placeholder:n,rows:1,value:i}),(0,q.jsx)(W,{"data-test":A(`chat-send`),disabled:t,onClick:o,size:`sm`,type:`button`,children:r(`common.chat.send`,`Send`)})]})}var $a=_n({name:`lattice/chat`,components:{"chat.box":K(({node:e})=>{let t=e.props,{t:n}=w(`lattice`),r=(0,G.useMemo)(()=>t.remote?Va(t.remote):Ba,[t.remote]),{messages:i,status:a,error:o,sendMessage:s,setMessages:c}=Ya({endpoint:t.streamEndpoint??``,transport:r}),l=(0,G.useRef)(!1),u=(0,G.useCallback)(async()=>{if(l.current||!t.historyEndpoint)return;if(l.current=!0,t.remote){let e=await Zt(t.historyEndpoint,{remote:t.remote});c(e.messages);return}let e=await Ut(t.historyEndpoint,{throwOnError:!1});if(!e.ok)return;let n=await e.json();c(n.messages)},[t.historyEndpoint,t.remote,c]);(0,G.useEffect)(()=>{u().catch(()=>{})},[u]);let d=a===`submitted`||a===`streaming`||!t.streamEndpoint;return(0,q.jsxs)(`div`,{className:F(`flex flex-col overflow-hidden border border-lt-border bg-lt-bg`,t.fill?`sticky top-0 h-full min-h-[28rem] w-full`:`h-[28rem] w-80 rounded-lt shadow-lt-lg`),"data-test":A(`chat-box`),children:[(0,q.jsx)(`div`,{className:`flex items-center border-b border-lt-border px-3 py-2`,children:(0,q.jsx)(`span`,{className:`text-sm font-medium text-lt-fg`,children:t.title??n(`common.chat.title`,`Chat`)})}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,q.jsx)(Za,{messages:i})}),o?(0,q.jsx)(`div`,{className:`border-t border-lt-danger/40 px-3 py-2 text-xs text-lt-danger`,children:o}):null,(0,q.jsx)(Qa,{disabled:d,onSubmit:s,placeholder:t.placeholder??void 0})]})}),"chat.part.text":K(({node:e})=>(0,q.jsx)(`div`,{className:`whitespace-pre-wrap text-sm`,children:e.props.text})),"chat.part.tool-call":K(({node:e})=>(0,q.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-1 rounded-lt-sm bg-lt-muted px-2 py-0.5 font-mono text-xs text-lt-muted-fg`,"data-test":A(`chat-tool-call`),children:[`🔧 `,e.props.name,`(`,JSON.stringify(e.props.args),`)`]}))}}),eo={xs:`size-6 text-[0.5rem]`,sm:`size-8 text-xs`,md:`size-10 text-sm`,lg:`size-12 text-base`,xl:`size-16 text-lg`,"2xl":`size-20 text-xl`,"3xl":`size-24 text-2xl`,"4xl":`size-32 text-3xl`};function to(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}function no(){return(0,q.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`size-[60%]`,children:[(0,q.jsx)(`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`}),(0,q.jsx)(`circle`,{cx:`12`,cy:`7`,r:`4`})]})}var ro=({node:e})=>{let{src:t,name:n,size:r}=e.props,i=n??void 0;return(0,q.jsx)(`span`,{"data-slot":`avatar`,role:t?void 0:`img`,"aria-label":t?void 0:i,className:F(`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-lt-muted font-medium text-lt-muted-fg select-none`,eo[r]),children:t?(0,q.jsx)(`img`,{src:t,alt:i??``,className:`size-full object-cover`}):n?to(n):(0,q.jsx)(no,{})})};function io({color:e,className:t,style:n,...r}){let i=wt(Tt(e??void 0)??xt(`gray`));return(0,q.jsx)(`span`,{"data-slot":`badge`,className:F(`lt-badge`,i.className,t),style:{...i.style,...n},...r})}var ao=({node:e})=>(0,q.jsx)(io,{color:e.props.color,children:e.props.label});function oo({className:e,...t}){return(0,q.jsx)(`article`,{"data-slot":`card`,className:F(`flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-lt-gutter text-lt-surface-fg shadow-lt-sm`,e),...t})}function so({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-header`,className:F(`flex flex-col gap-1.5 px-lt-gutter`,e),...t})}function co({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-title`,className:F(`font-semibold leading-none`,e),...t})}function lo({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-description`,className:F(`text-sm text-lt-muted-fg`,e),...t})}function uo({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-content`,className:F(`px-lt-gutter`,e),...t})}var fo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props;return(0,q.jsxs)(oo,{"data-lattice-component":N(t),children:[(n||r)&&(0,q.jsxs)(so,{children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(co,{children:n}),(0,q.jsx)(nt,{content:i})]}),r&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(lo,{children:r}),!n&&(0,q.jsx)(nt,{content:i})]})]}),e&&(0,q.jsx)(uo,{className:`flex flex-col gap-6`,children:e})]})},po=(0,G.lazy)(()=>tn(()=>import(`./chunks/chart-view-WqyMTZiX.js`),__vite__mapDeps([9,1,4,2,10,6,11,12,13]),import.meta.url)),mo=({children:e,node:t})=>(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(po,{node:t,children:e})}),ho=({children:e,node:t})=>{let n=t.props.rememberState!==!1,r=Sn(t.props.trigger),i=N(t),a=`lattice:collapsible:${i??`default`}`,o=`${i??`collapsible`}-content`,[s,c]=ui(a,t.props.collapsed===!1,n);return(0,q.jsxs)(`div`,{"data-slot":`collapsible`,"data-lattice-component":i,children:[(0,q.jsxs)(`div`,{"aria-controls":o,"aria-expanded":s,"data-test":M(`collapsible-toggle`,i)??`collapsible-toggle-default`,className:`flex w-full cursor-pointer items-center justify-between gap-4 rounded-lt-sm py-2 text-left text-lt-fg transition-colors hover:bg-lt-muted`,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},role:`button`,tabIndex:0,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,q.jsx)(J,{nodes:r}),t.props.tooltip&&(0,q.jsx)(`span`,{role:`presentation`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,q.jsx)(nt,{content:t.props.tooltip})})]}),(0,q.jsx)(R,{name:`chevron-down`,className:F(`size-lt-icon-md shrink-0 text-lt-muted-fg transition-transform`,!s&&`-rotate-90`)})]}),s&&e&&(0,q.jsx)(`div`,{id:o,className:`flex flex-col gap-4 pt-2`,children:e})]})};function go(e,t){return e===`top-start`?{left:t,top:t}:e===`top-end`?{right:t,top:t}:e===`bottom-start`?{bottom:t,left:t}:{bottom:t,right:t}}var _o=({children:e,node:t})=>{let n=t.props.label??void 0,r=Math.max(0,t.props.offset??16),i=t.props.placement??`bottom-end`,a=t.props.trigger??[],[o,s]=(0,G.useState)(!1);if(a.length===0)return(0,q.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)] rounded-lt border border-lt-border bg-lt-popover p-1 text-lt-popover-fg shadow-lt-md`,"data-lattice-component":N(t),role:n?`group`:void 0,style:go(i,r),children:e});let c=i===`bottom-start`||i===`bottom-end`,l=i===`top-start`||i===`bottom-start`;return(0,q.jsx)(`div`,{"aria-label":n,className:`fixed z-lt-popover max-w-[calc(100vw-2rem)]`,"data-lattice-component":N(t),role:n?`group`:void 0,style:go(i,r),children:(0,q.jsxs)(`div`,{className:F(`flex w-fit gap-2`,c?`flex-col-reverse`:`flex-col`),children:[(0,q.jsx)(`button`,{"aria-expanded":o,className:F(`inline-flex items-center gap-2 rounded-lt border border-lt-border bg-lt-popover px-3 py-1.5 text-sm font-medium text-lt-popover-fg shadow-lt-md hover:bg-lt-muted`,l?`self-start`:`self-end`),"data-test":t.key?`${t.key}-trigger`:void 0,onClick:()=>s(e=>!e),type:`button`,children:a.map((e,t)=>(0,q.jsx)(Y,{node:e},e.key??`${e.type}-${t}`))}),(0,q.jsx)(`div`,{className:o?`block`:`hidden`,children:e})]})})},vo={lg:320,md:64,sm:40,xl:384,xs:32,"2xl":448,"3xl":512,"4xl":576},yo=({node:e})=>{let t=e.props.endpoint??``,n=e.props.lazy===!0,r=e.props.ref??``,a=vo[e.props.size],[o,s]=(0,G.useState)(()=>e.schema??[]),[c,l]=(0,G.useState)(!n),[u,d]=(0,G.useState)(n&&t!==``),f=(0,G.useCallback)(async()=>{if(t){d(!0);try{let e=await Wt(t,{ref:r});s(Sn(e.schema)),l(!0)}finally{d(!1)}}},[t,r]);return(0,G.useEffect)(()=>{!n||c||f()},[c,n,f]),(0,G.useEffect)(()=>{function t(t){t.detail?.component===e.id&&f()}return window.addEventListener(i.reloadComponent,t),()=>window.removeEventListener(i.reloadComponent,t)},[f,e.id]),(0,G.useEffect)(()=>{function e(){c&&f()}return window.addEventListener(i.localeChange,e),()=>window.removeEventListener(i.localeChange,e)},[c,f]),(0,q.jsx)(`div`,{"data-lattice-fragment":e.id,style:u&&o.length===0?{minHeight:a}:void 0,children:u&&o.length===0?(0,q.jsx)(sa,{className:`w-full`,style:{height:a}}):(0,q.jsx)(J,{nodes:o})})},bo=({children:e,node:t})=>{let n=Math.min(Math.max(t.props.columns??1,1),4);return(0,q.jsx)(`div`,{"data-slot":`grid`,"data-lattice-component":N(t),className:F(`grid gap-x-4 gap-y-6`,n>=2&&`md:grid-cols-2`,n>=3&&`lg:grid-cols-3`,n>=4&&`xl:grid-cols-4`),children:e})};async function xo(e){if(!navigator?.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function So({value:e,label:t,testId:n,className:r}){let{t:i}=w(`lattice`),[a,o]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!a)return;let e=window.setTimeout(()=>o(!1),1500);return()=>window.clearTimeout(e)},[a]);function s(){xo(e),o(!0)}let c=a?i(`common.copied-value`,`Copied {{label}}`,{label:t}):i(`common.copy-value`,`Copy {{label}}`,{label:t});return(0,q.jsxs)(`button`,{type:`button`,"data-test":n,className:F(`inline-flex items-center gap-1 rounded-lt-sm border border-lt-border px-2 py-1 text-xs`,r),"aria-label":c,onClick:s,children:[(0,q.jsx)(R,{name:a?`check`:`copy`,className:`size-lt-icon-xs`}),a?i(`common.copied`,`Copied`):i(`common.copy`,`Copy`)]})}function Co({value:e,label:t,testId:n,children:r}){return(0,q.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[r??e,(0,q.jsx)(So,{value:e,label:t,testId:n})]})}var wo=({node:e})=>{let{text:t,tooltip:n}=e.props,r=Math.min(Math.max(e.props.level,1),6),i=F(`max-w-3xl font-semibold tracking-normal text-balance text-lt-fg`,r===1&&`text-2xl font-bold leading-tight`,r===2&&`text-xl`,r>2&&`text-base`),a=(0,q.jsxs)(q.Fragment,{children:[t,(0,q.jsx)(nt,{content:n})]}),o;switch(r){case 1:o=(0,q.jsx)(`h1`,{className:i,children:a});break;case 2:o=(0,q.jsx)(`h2`,{className:i,children:a});break;case 3:o=(0,q.jsx)(`h3`,{className:i,children:a});break;case 4:o=(0,q.jsx)(`h4`,{className:i,children:a});break;case 5:o=(0,q.jsx)(`h5`,{className:i,children:a});break;default:o=(0,q.jsx)(`h6`,{className:i,children:a})}return e.props.copyable?(0,q.jsx)(Co,{value:t,label:t,children:o}):o},To={xs:`size-lt-icon-xs`,sm:`size-lt-icon-sm`,md:`size-lt-icon-md`,lg:`size-lt-icon-lg`,xl:`size-lt-icon-xl`,"2xl":`size-lt-icon-2xl`,"3xl":`size-lt-icon-3xl`,"4xl":`size-lt-icon-4xl`},Eo=({node:e})=>{let{name:t,size:n,color:r,class:i}=e.props,a=(0,q.jsx)(P,{icon:t,className:F(To[n],i)}),o=Tt(r);return o?(0,q.jsx)(`span`,{className:`contents`,style:{color:St(o)},children:a}):a};function Do({src:e,alt:t,previewable:n,width:r,height:i,className:a,testId:o}){let{t:s}=w(`lattice`),[c,l]=(0,G.useState)(!1),u=(0,q.jsx)(`img`,{alt:t,src:e,width:r,height:i,className:a,style:r?{width:r,height:i}:void 0});if(!n)return u;let d=s(`common.image.open-preview`,`View image`);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"data-test":o,className:`cursor-zoom-in`,"aria-label":d,onClick:()=>l(!0),children:u}),(0,q.jsx)(Qi,{open:c,onOpenChange:l,children:(0,q.jsxs)(na,{"aria-describedby":void 0,className:`max-h-[90vh] w-auto max-w-[90vw] border-none bg-transparent p-0 shadow-none`,children:[(0,q.jsx)(ea,{className:`sr-only`,children:t||d}),(0,q.jsx)(`img`,{alt:t,src:e,"data-slot":`image-lightbox`,className:`max-h-[90vh] max-w-[90vw] rounded-lt object-contain`}),(0,q.jsx)($i,{asChild:!0,children:(0,q.jsx)(W,{icon:`x`,"aria-label":s(`common.close`,`Close`),"data-test":`lightbox-close`,size:`icon`,emphasis:`ghost`,className:`absolute top-2 right-2 bg-lt-bg/80 hover:bg-lt-bg`})})]})})]})}var Oo=({node:e})=>{let{src:t,alt:n,size:r,circular:i,previewable:a}=e.props;return(0,q.jsx)(Do,{alt:n??``,className:F(`object-cover`,i?`rounded-full`:`rounded-lt-sm`),height:r??void 0,previewable:a,src:t,testId:N(e),width:r??void 0})};function ko(e,t){let n=e.detail?.modal;return n==null||n===t}var Ao=({children:e,node:t})=>{let{t:n}=w(`lattice`),r=t.props.title??n(`common.dialog`,`Dialog`),a=t.props.description,o=t.props.closeLabel,[s,c]=(0,G.useState)(t.props.open===!0),l=(0,G.useRef)(null),u=(0,G.useRef)(s);return(0,G.useEffect)(()=>{t.props.open===!0&&c(!0)},[t.props.open]),(0,G.useEffect)(()=>{function e(e){t.id&&ko(e,t.id)&&(l.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(!0))}function n(e){(!t.id||ko(e,t.id))&&c(!1)}return window.addEventListener(i.openModal,e),window.addEventListener(i.closeModal,n),()=>{window.removeEventListener(i.openModal,e),window.removeEventListener(i.closeModal,n)}},[t.id]),(0,G.useEffect)(()=>{if(u.current&&!s){let e=l.current;e&&requestAnimationFrame(()=>e.focus())}u.current=s},[s]),(0,q.jsx)(Qi,{open:s,onOpenChange:c,children:(0,q.jsxs)(na,{...a?{}:{"aria-describedby":void 0},placement:t.props.side??`center`,width:t.props.width,children:[(0,q.jsx)(ra,{closeLabel:o,description:a,title:r}),(0,q.jsx)(`div`,{className:`mt-6 space-y-6`,children:e})]})})},jo={xs:`h-1`,sm:`h-1.5`,md:`h-2.5`,lg:`h-3`,xl:`h-4`,"2xl":`h-5`,"3xl":`h-6`,"4xl":`h-8`},Mo={xs:24,sm:32,md:40,lg:48,xl:64,"2xl":80,"3xl":96,"4xl":128},No={xs:`text-[0.5rem]`,sm:`text-[0.625rem]`,md:`text-xs`,lg:`text-sm`,xl:`text-base`,"2xl":`text-lg`,"3xl":`text-xl`,"4xl":`text-2xl`},Po=({node:e})=>{let{value:t,max:r,shape:i,showValue:a,color:o,size:s}=e.props,{locale:c}=n(),l=St(Tt(o)??xt(`primary`)),u=r>0?Math.min(Math.max(t,0),r):0,d=r>0?u/r:0,f=new Intl.NumberFormat(c,{maximumFractionDigits:0,style:`percent`}).format(d),p={"aria-valuemax":r,"aria-valuemin":0,"aria-valuenow":u,"aria-valuetext":f,role:`progressbar`};if(i===`circle`){let e=Mo[s],t=Math.max(3,e/10),n=(e-t)/2,r=2*Math.PI*n;return(0,q.jsxs)(`div`,{...p,className:`relative inline-flex`,"data-lattice-progress":`circle`,children:[(0,q.jsxs)(`svg`,{className:`-rotate-90`,height:e,width:e,children:[(0,q.jsx)(`circle`,{className:`text-lt-muted`,cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeWidth:t}),(0,q.jsx)(`circle`,{cx:e/2,cy:e/2,fill:`none`,r:n,stroke:`currentColor`,strokeDasharray:r,strokeDashoffset:r*(1-d),strokeLinecap:`round`,strokeWidth:t,style:{color:l}})]}),a&&(0,q.jsx)(`span`,{className:F(`absolute inset-0 flex items-center justify-center font-medium text-lt-fg tabular-nums`,No[s]),children:f})]})}return(0,q.jsxs)(`div`,{className:`flex w-full items-center gap-2`,"data-lattice-progress":`bar`,children:[(0,q.jsx)(`div`,{...p,className:F(`w-full overflow-hidden rounded-full bg-lt-muted`,jo[s]),children:(0,q.jsx)(`div`,{className:`h-full rounded-full`,style:{background:l,width:`${d*100}%`}})}),a&&(0,q.jsx)(`span`,{className:`shrink-0 text-lt-muted-fg text-sm tabular-nums`,children:f})]})},Fo=({node:e})=>(0,q.jsx)(`span`,{style:{display:`contents`},dangerouslySetInnerHTML:{__html:e.props.html}}),Io=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props,a=t.props.collapsible===!0,o=t.props.rememberState!==!1,s=Sn(t.props.headerActions),c=N(t),[l,u]=ui(`lattice:section:${c??`default`}`,t.props.collapsed===!0,a&&o),d=a&&l,f=!!(n||r||s.length>0||a);return(0,q.jsxs)(`section`,{"data-slot":`section`,className:`flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-lt-gutter text-lt-surface-fg shadow-lt-sm`,"data-lattice-component":c,children:[f&&(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-lt-gutter`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[a&&(0,q.jsx)(`button`,{"aria-expanded":!d,"aria-label":d?`Expand section`:`Collapse section`,"data-test":M(`section-toggle`,c)??`section-toggle-default`,className:`mt-0.5 inline-flex shrink-0 items-center rounded-lt-sm p-0.5 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg`,onClick:u,type:`button`,children:(0,q.jsx)(R,{name:`chevron-down`,className:F(`size-lt-icon-md transition-transform`,d&&`-rotate-90`)})}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(`div`,{className:`font-semibold leading-none`,children:n}),(0,q.jsx)(nt,{content:i})]}),r&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(`div`,{className:`text-sm text-lt-muted-fg`,children:r}),!n&&(0,q.jsx)(nt,{content:i})]})]})]}),s.length>0&&(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,q.jsx)(J,{nodes:s})})]}),!d&&e&&(0,q.jsx)(`div`,{className:`flex flex-col gap-6 px-lt-gutter`,children:e})]})};function Lo(e){return F(`whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors`,e?`bg-lt-bg text-lt-fg shadow-lt-xs`:`text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg`)}function Ro({ariaLabel:e,autoFocus:t=!1,disabled:n=!1,name:r,onSelect:i,options:a,tabIndex:o,value:s}){let c=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!t)return;let e=c.current;(e?.querySelector(`button[aria-checked="true"]`)??e?.querySelector(`button`))?.focus()},[t]),(0,q.jsx)(`div`,{"aria-label":e,className:`inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1`,ref:c,role:`radiogroup`,children:a.map(e=>{let t=s===e.value;return(0,q.jsx)(`button`,{"aria-checked":t,"data-test":`${r??`segment`}-${e.value}`,className:F(Lo(t),n&&`cursor-not-allowed opacity-60`),disabled:n,onClick:()=>i(e.value),role:`radio`,tabIndex:o,type:`button`,children:e.label},e.value)})})}var zo=({node:e})=>{let{options:t,name:n,emits:r}=e.props,[i,a]=(0,G.useState)(e.props.value||t[0]?.value||``);if(t.length===0)return null;function o(e){a(e),r&&window.dispatchEvent(new CustomEvent(r,{detail:{name:n,value:e}}))}return(0,q.jsx)(Ro,{ariaLabel:e.props.label??void 0,name:n,onSelect:o,options:t,value:i})},Bo=({node:e})=>{let t=e.props.orientation===`horizontal`;return(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":e.props.orientation,className:F(`shrink-0 bg-lt-border`,t?`h-px w-full`:`h-full w-px self-stretch`)})},Vo={center:`justify-items-center text-center`,start:`justify-items-start text-left`,stretch:`justify-items-stretch`},Ho={center:`items-center text-center`,start:`items-center text-left`,stretch:`items-stretch justify-stretch`},Uo={none:`gap-0`,xs:`gap-1`,lg:`gap-6`,md:`gap-4`,sm:`gap-2`,xl:`gap-8`},Wo={auto:`w-auto`,fill:`min-w-0 flex-1`,full:`w-full`,lg:`mx-auto w-full max-w-4xl`,md:`mx-auto w-full max-w-2xl`,sm:`mx-auto w-full max-w-md`},Go={around:`justify-around`,between:`justify-between`,center:`justify-center`,end:`justify-end`,evenly:`justify-evenly`,start:`justify-start`},Ko={full:`h-full`,screen:`min-h-screen`},qo={end:`ml-auto`,start:`mr-auto`},Jo=({children:e,node:t})=>{let n=t.props.align??`stretch`,r=t.props.direction??`column`,i=t.props.gap??`md`,a=t.props.width??`full`,o=t.props.justify,s=t.props.height,c=t.props.float,l=r===`row`||o!=null;return(0,q.jsx)(`div`,{"data-slot":`stack`,"data-lattice-component":N(t),className:F(l?F(`flex`,r===`row`?`flex-wrap`:`flex-col`):`grid content-start`,l?Ho[n]??Ho.stretch:Vo[n]??Vo.stretch,Uo[i]??Uo.md,Wo[a]??Wo.full,o?Go[o]:null,s?Ko[s]:null,c?qo[c]:null),children:e})},Yo=(0,G.createContext)(null);function Xo(){return(0,G.useContext)(Yo)||{activeValue:``,setActiveValue:()=>{}}}function Zo(e){return(e.schema??[]).filter(e=>e.type===`tab`).map(e=>{let t=e.props;return{confirm:t.confirm?{required:t.confirm.required}:void 0,label:t.label,value:t.value}}).filter(e=>e.value!==``)}function Qo(e,t){if(typeof window>`u`)return null;let n=new URLSearchParams(window.location.search).get(e);return!n||!t.some(e=>e.value===n)?null:n}function $o(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href);n.searchParams.set(e,t),window.history.replaceState(window.history.state,``,`${n.pathname}${n.search}${n.hash}`)}function es(e,t){if(typeof window>`u`)return``;let n=new URL(window.location.href);return n.searchParams.set(e,t),`${n.pathname}${n.search}${n.hash}`}var ts=({children:e,node:t})=>{let{t:n}=w(`lattice`),r=(0,G.useMemo)(()=>Zo(t),[t]),i=r[0]?.value??``,a=t.props.queryKey,o=t.props.orientation,s=o===`vertical`,c=t.props.alignment,l=!s&&c===`stretch`,u=t.props.activeValue,d=t.props.defaultValue??i,f=(0,G.useRef)(null),[m,h]=(0,G.useState)(()=>u||(Qo(a,r)??d)||i),g=(0,G.useCallback)(e=>{if(e.confirm?.required){p.visit(es(a,e.value),{preserveScroll:!0});return}h(e.value),$o(a,e.value)},[a]),_=(0,G.useCallback)(e=>{let t=r.find(t=>t.value===e);t&&g(t)},[g,r]),v=(0,G.useMemo)(()=>({activeValue:m,setActiveValue:_}),[m,_]);function y(e){let t=s?`ArrowDown`:`ArrowRight`,n=s?`ArrowUp`:`ArrowLeft`;if(e.key!==t&&e.key!==n&&e.key!==`Home`&&e.key!==`End`)return;let r=Array.from(f.current?.querySelectorAll(`[role="tab"]`)??[]);if(r.length===0)return;e.preventDefault();let i=r.indexOf(document.activeElement),a;if(e.key===`Home`)a=0;else if(e.key===`End`)a=r.length-1;else{let n=e.key===t?1:-1;a=((i<0?0:i)+n+r.length)%r.length}r[a]?.focus()}return(0,q.jsx)(Yo.Provider,{value:v,children:(0,q.jsxs)(`div`,{className:F(`gap-6`,s?F(`flex`,c===`end`&&`flex-row-reverse`):`grid`),"data-lattice-tabs":t.key??t.id,children:[(0,q.jsx)(`div`,{"aria-label":n(`common.tabs`,`Tabs`),"aria-orientation":o,className:F(`gap-1 rounded-lt bg-lt-muted p-1`,s&&`flex flex-col`,l&&`flex w-full`,!s&&!l&&F(`inline-flex w-fit max-w-full overflow-x-auto`,{"justify-self-center":c===`center`,"justify-self-end":c===`end`})),ref:f,role:`tablist`,children:r.map(e=>{let t=m===e.value;return(0,q.jsx)(`button`,{"aria-controls":`${e.value}-panel`,"aria-selected":t,"data-test":`tab-${e.value}`,className:F(Lo(t),s&&`text-left`,l&&`flex-1`),id:`${e.value}-tab`,onClick:()=>g(e),onKeyDown:y,role:`tab`,tabIndex:t?0:-1,type:`button`,children:e.label},e.value)})}),(0,q.jsx)(`div`,{className:F(`min-w-0`,s&&`flex-1`),children:e})]})})},ns=({children:e,node:t})=>{let{activeValue:n}=Xo(),r=t.props.value,i=n===r,[a,o]=(0,G.useState)(i);return(0,G.useEffect)(()=>{i&&o(!0)},[i]),(0,q.jsx)(`section`,{"aria-labelledby":`${r}-tab`,className:F(`space-y-8`,!i&&`hidden`),hidden:!i,id:`${r}-panel`,role:`tabpanel`,tabIndex:0,children:a?e:null})},rs={center:`text-center`,left:`text-left`},is={xs:`text-xs leading-5`,sm:`text-sm leading-6`,md:`text-base leading-7`,lg:`text-lg leading-8`,xl:`text-xl leading-8`,"2xl":`text-2xl leading-9`,"3xl":`text-3xl leading-10`,"4xl":`text-4xl leading-none`},as=_n({components:{avatar:K(ro),badge:K(ao),button:K(ht),card:K(fo),chart:K(mo),collapsible:K(ho),"floating-panel":K(_o),fragment:K(yo),grid:K(bo),heading:K(wo),icon:K(Eo),image:K(Oo),link:K(Xe),modal:K(Ao),progress:K(Po),"raw-block":K(Fo),section:K(Io),"segmented-control":K(zo),separator:K(Bo),stack:K(Jo),tab:K(ns),tabs:K(ts),text:K(({node:e})=>{let t=e.props.align??`left`,n=St(Tt(e.props.color)??xt(`muted`)),r=(0,q.jsx)(`p`,{className:F(`m-0`,`max-w-2xl`,rs[t]??rs.left,is[e.props.size]),style:{color:n},children:e.props.text});return e.props.copyable?(0,q.jsx)(Co,{value:e.props.text,label:e.props.text,children:r}):r}),tooltip:K(({node:e})=>{let t=e.props.content,n=Sn(e.props.trigger);return t?n.length===0?(0,q.jsx)(nt,{content:t}):(0,q.jsxs)(De,{children:[(0,q.jsx)(V,{type:`button`,className:`inline-flex items-center rounded-lt-sm outline-none focus-visible:ring-lt-ring/50 focus-visible:ring-[length:var(--lt-ring-width)]`,children:(0,q.jsx)(J,{nodes:n})}),(0,q.jsx)(B,{align:`start`,className:`max-w-xs p-3 text-sm [&_a]:underline`,dangerouslySetInnerHTML:{__html:t}})]}):null})},name:`lattice/ui`});function os({addLabel:e,options:t,onSelect:n}){return(0,q.jsxs)(Fe,{children:[(0,q.jsx)(Ie,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,"data-test":`builder-add`,className:`inline-flex items-center gap-1.5 self-start rounded-lt-sm border border-lt-border px-3 py-1.5 text-sm hover:bg-lt-accent [&_svg]:size-lt-icon-sm`,children:[(0,q.jsx)(R,{name:`plus`}),e]})}),(0,q.jsx)(Ge,{align:`start`,className:`min-w-[12rem]`,children:t.map(e=>(0,q.jsx)(ot,{"data-test":`builder-add-${e.type}`,onClick:()=>n(e.type),children:e.label},e.type))})]})}var ss={duplicate:{key:`table.row-actions.duplicate`,fallback:`Duplicate`,icon:`copy`},remove:{key:`table.row-actions.remove`,fallback:`Remove`,icon:`trash-2`}};function cs(e,t){return(e??ls(t.removable)).map(e=>us(e,t)).filter(e=>e!==null)}function ls(e){return e?[{type:`remove`,key:`remove`,label:null,icon:null,danger:!0}]:[]}function us(e,t){if(e.type===`duplicate`){let n=ss.duplicate;return{key:e.key,label:e.label??t.t(n.key,n.fallback),icon:e.icon??n.icon,danger:e.danger,onClick:()=>t.onDuplicate(t.index)}}if(e.type===`remove`){if(!t.removable)return null;let n=ss.remove;return{key:e.key,label:e.label??t.t(n.key,n.fallback),icon:e.icon??n.icon,danger:e.danger,onClick:()=>t.onRemove(t.index)}}return null}function ds(e){return e?`text-lt-danger hover:text-lt-danger [&_svg]:size-lt-icon-sm`:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm`}function fs({actions:e}){let{t}=w(`lattice`);if(e.length===0)return null;if(e.length===1){let t=e[0];return(0,q.jsx)(`button`,{type:`button`,"aria-label":t.label,"data-test":`row-action-${t.key}`,className:ds(t.danger),onClick:t.onClick,children:(0,q.jsx)(R,{name:t.icon})})}return(0,q.jsxs)(Fe,{children:[(0,q.jsx)(Ie,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,"aria-label":t(`common.action-group.label`,`Actions`),"data-test":`row-actions-menu`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm`,children:(0,q.jsx)(R,{name:`more-horizontal`})})}),(0,q.jsx)(Ge,{align:`end`,className:`min-w-[10rem]`,children:e.map(e=>(0,q.jsx)(ot,{"data-test":`row-action-${e.key}`,danger:e.danger,icon:e.icon,onClick:e.onClick,children:e.label},e.key))})]})}function ps({path:e,rows:t,rowKey:n}){return(0,q.jsx)(q.Fragment,{children:t.map((t,r)=>(0,q.jsx)(`input`,{type:`hidden`,name:ge(be(e,r,n)),value:String(t[n]??``)},String(t.rowId??r)))})}function ms({label:e,testId:t,onClick:n,children:r}){return(0,q.jsx)(`button`,{type:`button`,"aria-label":e,"data-test":t,className:`text-lt-muted-fg hover:text-lt-fg`,onClick:n,children:r})}var hs=(0,G.memo)(function({base:e,index:t,row:n,template:r,heading:i,reorderable:a,isFirst:o,isLast:s,removable:c,rowActions:l,onField:u,onRemove:d,onMove:f,onDuplicate:p}){let{t:m}=w(`lattice`);return(0,q.jsxs)(`div`,{"data-test":`repeater-${e}-row-${t}`,className:`rounded-lt border border-lt-border bg-lt-surface p-4`,children:[(0,q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium text-lt-muted-fg`,children:i}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[a&&!o&&(0,q.jsx)(ms,{label:`Move up`,testId:`repeater-${e}-up-${t}`,onClick:()=>f(t,-1),children:(0,q.jsx)(R,{name:`arrow-up`})}),a&&!s&&(0,q.jsx)(ms,{label:`Move down`,testId:`repeater-${e}-down-${t}`,onClick:()=>f(t,1),children:(0,q.jsx)(R,{name:`arrow-down`})}),(0,q.jsx)(fs,{actions:cs(l,{index:t,removable:c,onRemove:d,onDuplicate:p,t:m})})]})]}),(0,q.jsx)(le,{base:e,index:t,row:n,onChange:(e,n)=>u(t,e,n),children:(0,q.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,q.jsx)(Y,{node:e},Cn(e,t)))})})]})}),gs={xs:{track:`minmax(4rem, 0.35fr)`,minPx:64,defaultPx:96,maxPx:1024},sm:{track:`minmax(6rem, 0.5fr)`,minPx:96,defaultPx:128,maxPx:1024},md:{track:`minmax(8rem, 1fr)`,minPx:128,defaultPx:176,maxPx:1024},lg:{track:`minmax(12rem, 1.5fr)`,minPx:192,defaultPx:240,maxPx:1024},xl:{track:`minmax(16rem, 2fr)`,minPx:256,defaultPx:320,maxPx:1024}};function _s(e){return gs[e].track}function vs(e){return gs[e.width].minPx}function ys(e){return gs[e.width].defaultPx}function bs(e){return gs[e.width].maxPx}function xs({columns:e,leadingTracks:t=[],trailingTracks:n=[],overrides:r={}}){return[...t,...e.map(e=>{let t=r[e.key];return t===void 0?_s(e.width):`${Math.min(bs(e),Math.max(vs(e),t))}px`}),...n].join(` `)}var Ss=[];function Cs({columnGapPx:e=0,columns:t,enabled:n,leadingTracks:r=Ss,showIndicator:i=!1,storageKey:a,trailingTracks:o=Ss}){let s=(0,G.useMemo)(()=>t.map(e=>e.key),[t]),[c,l]=(0,G.useState)(()=>Ts(a,t)),u=(0,G.useRef)(c),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useCallback)(e=>xs({columns:t,leadingTracks:r,trailingTracks:o,overrides:n?e:{}}),[t,n,r,o]),m=(0,G.useMemo)(()=>p(c),[c,p]),h=(0,G.useCallback)(e=>{let t=f.current;t&&(t.style.gridTemplateColumns=e,t.style.setProperty(`--lattice-table-columns`,e))},[]),g=(0,G.useCallback)(e=>{u.current=e,l(e),Es(a,s,e),h(p(e))},[h,s,a,p]),_=(0,G.useCallback)((e,t,n,r)=>({...e,[t.key]:Math.min(r??bs(t),Math.max(vs(t),n))}),[]),v=(0,G.useCallback)((e,t,n)=>{g(_(u.current,e,t,n))},[g,_]),y=(0,G.useCallback)(e=>{let t={...u.current};delete t[e.key],g(t)},[g]),b=(0,G.useCallback)(()=>{g({})},[g]),x=n&&Object.values(c).some(e=>typeof e==`number`),S=(0,G.useCallback)(e=>u.current[e.key]??ys(e),[]);return{getResizeHandleProps:(0,G.useCallback)(a=>{let s=bs(a),c=vs(a),l=S(a),m=a.label??a.key,b=i?`after:bg-lt-border`:`after:bg-transparent`,x=n=>ws({column:a,columnGapPx:e,columns:t,grid:f.current??n.parentElement?.parentElement,leadingTracks:r,trailingTracks:o}),C=(e,t)=>v(a,l+t,x(e)),w=(e,t)=>{let n=d.current;n?.key===a.key&&(d.current=null,n.overrides!==null&&g(n.overrides),t&&e.currentTarget.releasePointerCapture?.(e.pointerId))};return{"aria-label":`Resize ${m}`,"aria-orientation":`vertical`,"aria-valuemax":s,"aria-valuemin":c,"aria-valuenow":l,className:`absolute inset-y-0 right-0 hidden w-2 cursor-col-resize touch-none items-stretch justify-center md:flex after:my-1 after:w-px ${b} hover:after:bg-lt-border focus-visible:outline-none focus-visible:after:bg-lt-ring`,onDoubleClick:()=>y(a),onKeyDown:e=>{if(!n)return;let t=e.shiftKey?32:8;if(e.key===`ArrowLeft`&&(e.preventDefault(),C(e.currentTarget,-t)),e.key===`ArrowRight`&&(e.preventDefault(),C(e.currentTarget,t)),e.key===`Home`&&(e.preventDefault(),v(a,c)),e.key===`End`){e.preventDefault();let t=x(e.currentTarget);v(a,t,t)}(e.key===`Enter`||e.key===`Escape`)&&(e.preventDefault(),y(a))},onPointerDown:e=>{if(!n)return;let t=e.currentTarget.parentElement?.getBoundingClientRect().width??0;d.current={key:a.key,maxWidth:x(e.currentTarget),overrides:null,startWidth:t>0?t:l,startX:e.clientX},e.currentTarget.setPointerCapture?.(e.pointerId),e.preventDefault()},onPointerMove:e=>{let t=d.current;if(!n||t?.key!==a.key)return;let r=_(u.current,a,t.startWidth+e.clientX-t.startX,t.maxWidth);t.overrides=r,u.current=r,h(p(r))},onPointerUp:e=>{w(e,!0)},onPointerCancel:e=>{w(e,!0)},onLostPointerCapture:e=>{w(e,!1)},role:`separator`,tabIndex:0}},[e,t,S,n,r,h,g,_,y,v,i,p,o]),gridTemplateColumns:m,hasOverrides:x,resizeRootRef:f,resetColumns:b,resetColumnWidth:y}}function ws({column:e,columnGapPx:t,columns:n,grid:r,leadingTracks:i,trailingTracks:a}){let o=r?.getBoundingClientRect().width??0;if(o<=0)return bs(e);let s=[...i,...a].reduce((e,t)=>e+As(t),0),c=n.reduce((t,n)=>n.key===e.key?t:t+vs(n),0),l=n.length+i.length+a.length,u=Math.max(0,l-1)*t,d=o-s-c-u;return Math.min(bs(e),Math.max(vs(e),d))}function Ts(e,t){if(!e||typeof window>`u`)return{};try{let n=window.localStorage.getItem(e);if(n===null)return{};let r=JSON.parse(n);if(!Os(r))return Ds(e),{};let i=ks(r.overrides,t);return Object.keys(i).length===0&&Ds(e),i}catch{return Ds(e),{}}}function Es(e,t,n){if(!e||typeof window>`u`)return;let r={},i=new Set(t);for(let[e,t]of Object.entries(n))i.has(e)&&typeof t==`number`&&Number.isFinite(t)&&(r[e]=t);if(Object.keys(r).length===0){Ds(e);return}try{window.localStorage.setItem(e,JSON.stringify({columns:t,overrides:r}))}catch{return}}function Ds(e){if(!(typeof window>`u`))try{window.localStorage.removeItem(e)}catch{return}}function Os(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.columns)&&t.columns.every(e=>typeof e==`string`)&&typeof t.overrides==`object`&&t.overrides!==null&&!Array.isArray(t.overrides)}function ks(e,t){let n={};for(let r of t){let t=e[r.key];typeof t!=`number`||!Number.isFinite(t)||(n[r.key]=Math.min(bs(r),Math.max(vs(r),t)))}return n}function As(e){let t=e.trim(),n=t.match(/^([0-9.]+)px$/);if(n)return Number.parseFloat(n[1]);let r=t.match(/^([0-9.]+)rem$/);return r?Number.parseFloat(r[1])*js():0}function js(){if(typeof window>`u`)return 16;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:16}var Ms=`3rem`,Ns=`3rem`,Ps=[Ms],Fs=[Ns],Is=`(min-width: 768px)`;function Ls(){return ci(Is,!0)}function Rs(e){return e.map(e=>{let t=e.props;return{name:String(t.name),label:String(t.label??t.name),columnWidth:t.columnWidth??`md`}})}var zs=(0,G.memo)(function({base:e,index:t,row:n,template:r,span:i,isFirst:a,isLast:o,columnCount:s,flipKey:c,reorderable:l,removable:u,rowActions:d,onField:f,onMove:p,onRemove:m,onDuplicate:h,registerRow:g}){let{t:_}=w(`lattice`);return(0,q.jsxs)(`div`,{ref:e=>g?.(c,e),"data-flip-key":c,"data-test":`table-row-${e}-${t}`,className:`grid grid-cols-[var(--lattice-table-columns)] items-start gap-x-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 [&_svg]:size-lt-icon-sm`,children:[l&&!a&&(0,q.jsx)(ms,{label:`Move up`,testId:`table-${e}-up-${t}`,onClick:()=>p(t,-1),children:(0,q.jsx)(R,{name:`arrow-up`})}),l&&!o&&(0,q.jsx)(ms,{label:`Move down`,testId:`table-${e}-down-${t}`,onClick:()=>p(t,1),children:(0,q.jsx)(R,{name:`arrow-down`})})]}),(0,q.jsx)(le,{base:e,index:t,row:n,onChange:(e,n)=>f(t,e,n),children:(0,q.jsx)(Be,{children:i?(0,q.jsx)(`div`,{"data-test":`table-row-${e}-${t}-span`,className:`flex flex-col gap-2`,style:{gridColumn:`span ${s}`},children:r.map((e,t)=>(0,q.jsx)(Y,{node:e},Cn(e,t)))}):r.map((e,t)=>(0,q.jsx)(`div`,{children:(0,q.jsx)(Y,{node:e})},Cn(e,t)))})}),(0,q.jsx)(`div`,{className:`flex items-center`,children:(0,q.jsx)(fs,{actions:cs(d,{index:t,removable:u,onRemove:m,onDuplicate:h,t:_})})})]})});function Bs({base:e,columns:t,rows:n,reorderable:r,removable:i,rowActions:a,onField:o,onMove:s,onRemove:c,onDuplicate:l,registerRow:u,resizableColumns:d=!1,resizeIndicator:f=!1}){let{t:p}=w(`lattice`),m=Ls(),h=(0,G.useMemo)(()=>t.map(e=>({key:e.name,label:e.label,width:e.columnWidth})),[t]),{getResizeHandleProps:g,gridTemplateColumns:_,hasOverrides:v,resizeRootRef:y,resetColumns:b}=Cs({columns:h,enabled:d,columnGapPx:12,leadingTracks:Ps,showIndicator:f,storageKey:d?`lattice:table-columns:form:${e}`:void 0,trailingTracks:Fs});return m?(0,q.jsxs)(`div`,{className:`relative`,children:[v&&(0,q.jsx)(`button`,{"aria-label":p(`table.reset-column-widths`,`Reset column widths`),className:`absolute right-1 top-1 z-10 hidden rounded-lt-sm p-1 text-lt-muted-fg hover:text-lt-fg md:inline-flex`,"data-test":`table-reset-columns`,onClick:b,title:p(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,q.jsx)(R,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`div`,{ref:y,className:`flex min-w-max flex-col gap-2`,style:{"--lattice-table-columns":_},children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-[var(--lattice-table-columns)] items-center gap-x-3`,children:[(0,q.jsx)(`div`,{}),t.map((e,t)=>(0,q.jsxs)(`div`,{className:`relative min-w-0 pr-3 text-xs font-medium text-lt-muted-fg`,children:[e.label,d&&(0,q.jsx)(`div`,{...g(h[t])})]},e.name)),(0,q.jsx)(`div`,{})]}),n.map(d=>(0,q.jsx)(zs,{base:e,index:d.index,row:d.row,template:d.template,span:d.span,isFirst:d.index===0,isLast:d.index===n.length-1,columnCount:t.length,flipKey:d.key,reorderable:r,removable:i(d.index),rowActions:a,onField:o,onMove:s,onRemove:c,onDuplicate:l,registerRow:u},d.key))]})})]}):(0,q.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(t=>(0,q.jsx)(`div`,{ref:e=>u?.(t.key,e),"data-flip-key":t.key,children:(0,q.jsx)(hs,{base:e,index:t.index,row:t.row,template:t.template,heading:t.heading??`#${t.index+1}`,reorderable:r,isFirst:t.index===0,isLast:t.index===n.length-1,removable:i(t.index),rowActions:a,onField:o,onRemove:c,onMove:s,onDuplicate:l})},t.key))})}var Vs=180;function Hs(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Us(e){let t=(0,G.useRef)(new Map),n=(0,G.useRef)(new Map),r=(0,G.useCallback)((e,n)=>{n?t.current.set(e,n):t.current.delete(e)},[]);return(0,G.useLayoutEffect)(()=>{let e=[],r=new Map;return t.current.forEach((e,t)=>{e.style.transition=``,e.style.transform=``,r.set(t,e.getBoundingClientRect())}),Hs()||t.current.forEach((t,i)=>{let a=n.current.get(i),o=r.get(i);if(a&&o){let n=a.top-o.top;n&&(t.style.transform=`translateY(${n}px)`,e.push(requestAnimationFrame(()=>{t.style.transition=`transform ${Vs}ms ease-out`,t.style.transform=``})))}}),n.current=r,()=>{for(let t of e)cancelAnimationFrame(t)}},[e]),r}function Ws(e,t){let n=lt(),r=n?n.errorKey(e):e,i=Ce(),a=dt(r),o=Array.isArray(a)?a:_e(a,t),s=We(o);(0,G.useLayoutEffect)(()=>{s!==o&&i(r,s)},[o,s,i,r]);let c=(0,G.useCallback)(e=>{i(r,n=>e(Array.isArray(n)?n:_e(n,t)))},[i,r,t]);return{path:r,rows:s,onField:(0,G.useCallback)((e,t,n)=>c(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r)),[c]),onRemove:(0,G.useCallback)(e=>c(t=>Ue(t,e)),[c]),onMove:(0,G.useCallback)((e,t)=>c(n=>se(n,e,e+t)),[c]),onDuplicate:(0,G.useCallback)(e=>c(t=>ye(t,e)),[c]),append:(0,G.useCallback)(e=>c(t=>[...t,ve(e)]),[c])}}var Gs=[],Ks=({node:e})=>{let t=e.props,n=t.name,r=fa(e)??[],{errors:i}=Te(),{hidden:a,required:o}=Je(e),{path:s,rows:c,onField:l,onRemove:u,onMove:d,onDuplicate:f,append:p}=Ws(n,t.defaultItems??0),{t:m}=w(`lattice`),h=Us(c.map(e=>String(e.rowId??``)).join(`,`)),g=t.maxItems!=null&&c.length>=t.maxItems,_=t.minItems!=null&&c.length<=t.minItems,v=t.layout===`table`,y=e=>r.find(t=>t.type===e),b=r.map(e=>({type:e.type,label:e.label}));if(a)return null;let x=r[0],S=c.map((e,t)=>{let n=y(e.type),r=!!n&&!!x&&n.type===x.type;return{key:String(e.rowId??t),index:t,row:e,template:n?.schema??Gs,span:!r,heading:n?.label??`Unknown block: ${String(e.type)}`}});return(0,q.jsx)(Ve,{error:i[s],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:s,required:o,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(ps,{path:s,rows:c,rowKey:ue}),(0,q.jsx)(ps,{path:s,rows:c,rowKey:`type`}),v?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(Bs,{base:s,columns:Rs(x?.schema??[]),rows:S,reorderable:t.reorderable??!1,removable:()=>!_,rowActions:t.rowActions,onField:l,onMove:d,onRemove:u,onDuplicate:f,registerRow:h,resizableColumns:t.resizableColumns===!0,resizeIndicator:t.resizeIndicator===!0})}):c.map((e,r)=>{let i=y(e.type),a=String(e.rowId??r);return(0,q.jsx)(`div`,{ref:e=>h(a,e),"data-flip-key":a,children:i?(0,q.jsx)(hs,{base:s,index:r,row:e,template:i.schema??Gs,heading:i.label,reorderable:t.reorderable??!1,isFirst:r===0,isLast:r===c.length-1,removable:!_,rowActions:t.rowActions,onField:l,onRemove:u,onMove:d,onDuplicate:f}):(0,q.jsxs)(`div`,{"data-test":`repeater-${n}-row-${r}`,className:`flex items-center justify-between rounded-lt border border-dashed border-lt-border p-4 text-sm text-lt-muted-fg`,children:[(0,q.jsxs)(`span`,{children:[`Unknown block: `,String(e.type)]}),(0,q.jsx)(fs,{actions:cs(t.rowActions,{index:r,removable:!_,onRemove:u,onDuplicate:f,t:m})})]})},a)}),!g&&(0,q.jsx)(os,{addLabel:t.addLabel??`Add`,options:b,onSelect:e=>p({type:e})})]})})},qs=Object.defineProperty,Js=(e,t)=>qs(e,`name`,{value:t,configurable:!0}),Ys=`Checkbox`,[Xs,Zs]=st(Ys),[Qs,$s]=Xs(Ys);function ec(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=oe({prop:n,defaultProp:i??!1,onChange:c,caller:Ys}),[m,h]=G.useState(null),[g,_]=G.useState(null),v=G.useRef(!1),[y,b]=G.useReducer(e=>e+1,0),x=!m||!!o||!!m.closest(`form`),S={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:b,required:l,defaultChecked:!lc(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,q.jsx)(Qs,{scope:t,...S,children:cc(d)?d(S):r})}Js(ec,`CheckboxProvider`);var tc=`CheckboxTrigger`,nc=G.forwardRef(Js(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=$s(tc,e),g=I(i,u),_=G.useRef(c);return G.useEffect(()=>{let e=a?.form;if(e){let t=Js(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,q.jsx)(H.button,{type:`button`,role:`checkbox`,"aria-checked":lc(c)?`mixed`:c,"aria-required":l,"data-state":uc(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:U(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:U(n,e=>{p(),d(e=>lc(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),rc=G.forwardRef(Js(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,q.jsx)(ec,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(nc,{...d,ref:t,__scopeCheckbox:n}),e&&(0,q.jsx)(sc,{__scopeCheckbox:n})]})})},`Checkbox`)),ic=`CheckboxIndicator`,ac=G.forwardRef(Js(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=$s(ic,n);return(0,q.jsx)(Le,{present:r||lc(a.checked)||a.checked===!0,children:(0,q.jsx)(H.span,{"data-state":uc(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),oc=`CheckboxBubbleInput`,sc=G.forwardRef(Js(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=$s(oc,e),g=I(r,h),_=ke(i),v=G.useRef(!1),y=G.useRef(s),b=G.useRef(o);G.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==b.current;b.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=lc(s),n.call(e,!lc(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=G.useRef(!lc(s)&&s);return(0,q.jsx)(H.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??x.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:U(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function cc(e){return typeof e==`function`}Js(cc,`isFunction`);function lc(e){return e===`indeterminate`}Js(lc,`isIndeterminate`);function uc(e){return lc(e)?`indeterminate`:e?`checked`:`unchecked`}Js(uc,`getState`);function dc({className:e,...t}){return(0,q.jsx)(rc,{"data-slot":`checkbox`,className:F(`peer border-lt-input data-[state=checked]:bg-lt-primary data-[state=checked]:text-lt-primary-fg data-[state=checked]:border-lt-primary focus-visible:border-lt-ring focus-visible:ring-lt-ring/50 aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger size-4 shrink-0 rounded-lt-xs border shadow-lt-xs transition-shadow outline-none focus-visible:ring-[length:var(--lt-ring-width)] disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg disabled:data-[state=checked]:bg-lt-disabled disabled:data-[state=checked]:text-lt-disabled-fg disabled:data-[state=checked]:border-lt-disabled`,e),...t,children:(0,q.jsx)(ac,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,q.jsx)(R,{name:`check`,className:`size-lt-icon-sm`})})})}function fc(e,t){if(!t)return e;let n=e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``);return n?`${t}-${n}`:t}function pc(e,t){let n=lt(),r=dt(e),i=n?n.getValue(e):r,a=Ce();(0,G.useEffect)(()=>{i===void 0&&t!==void 0&&(n?n.setValue(e,t):a(e,t))},[e,t,i,a,n])}var mc=({node:e})=>{let{hidden:t,readOnly:n,disabled:r}=Je(e),i=e.props.name,a=lt(),{fieldIdPrefix:o}=Te(),s=fc(a?a.scopedName(i):i,o),c=dt(i),l=a?a.getValue(i):c,{commit:u}=je(),d=et(e.props.value),f=l===void 0?d:et(l);return pc(i,d),t?null:(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,q.jsx)(dc,{autoFocus:e.props.autoFocus??void 0,checked:f,"data-test":A(i),disabled:n||r,id:s,name:s,onCheckedChange:e=>{u(i,e===!0)},tabIndex:e.props.tabIndex??void 0}),(0,q.jsx)(Me,{htmlFor:s,children:e.props.label})]}),e.props.helperText&&(0,q.jsx)(`p`,{className:`mt-1 pl-7 text-sm text-lt-muted-fg`,children:e.props.helperText})]})};function hc(e){let{errors:t,fieldIdPrefix:n}=Te(),r=lt(),i=Je(e),a=ft(e),o=a.name??``,s=dt(o),c=r?r.getValue(o):s,l=c===void 0?a.value:c,u=typeof l==`string`||typeof l==`number`?String(l):``,d=fc(r?r.scopedName(o):o,n),f=r?r.errorKey(o):o,{commit:p,change:m,blur:h}=je(),g=e=>p(o,e),_=e=>m(o,e),v=()=>h(o);return{...i,localName:o,name:d,testId:A(o),value:u,error:t[f],commit:g,change:_,blur:v}}var gc=({node:e})=>{let t=ua(e),{localName:n,name:r,testId:i,value:a,error:o,hidden:s,required:c,readOnly:l,disabled:u,commit:d}=hc(e),f=(0,G.useMemo)(()=>t.props.options??[],[t.props]),p=f[0]?.value??``,m=a||p;return pc(n,m||void 0),s||f.length===0?null:(0,q.jsxs)(Ve,{error:o,helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,name:r,required:c,children:[(0,q.jsx)(`input`,{name:r,type:`hidden`,value:m}),(0,q.jsx)(Ro,{ariaLabel:e.props.label??void 0,autoFocus:e.props.autoFocus??void 0,disabled:l||u,name:i,onSelect:d,options:f,tabIndex:e.props.tabIndex??void 0,value:m})]})};function _c(){return(_c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function vc(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}function yc(e){var t=(0,G.useRef)(e),n=(0,G.useRef)(function(e){t.current&&t.current(e)});return t.current=e,n.current}var bc=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},xc=function(e){return`touches`in e},Sc=function(e){return e&&e.ownerDocument.defaultView||self},Cc=function(e,t,n){var r=e.getBoundingClientRect(),i=xc(t)?function(e,t){for(var n=0;n<e.length;n++)if(e[n].identifier===t)return e[n];return e[0]}(t.touches,n):t;return{left:bc((i.pageX-(r.left+Sc(e).pageXOffset))/r.width),top:bc((i.pageY-(r.top+Sc(e).pageYOffset))/r.height)}},wc=function(e){!xc(e)&&e.preventDefault()},Tc=G.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,i=vc(e,[`onMove`,`onKey`,`onEnd`]),a=(0,G.useRef)(null),o=yc(t),s=yc(n),c=yc(r),l=(0,G.useRef)(null),u=(0,G.useRef)(!1),d=(0,G.useMemo)(function(){var e=function(e){wc(e),(xc(e)?e.touches.length>0:e.buttons>0)&&a.current?o(Cc(a.current,e,l.current)):(n(!1),c())},t=function(){n(!1),c()};function n(n){var r=u.current,i=Sc(a.current),o=n?i.addEventListener:i.removeEventListener;o(r?`touchmove`:`mousemove`,e),o(r?`touchend`:`mouseup`,t)}return[function(e){var t=e.nativeEvent,r=a.current;if(r&&(wc(t),!function(e,t){return t&&!xc(e)}(t,u.current)&&r)){if(xc(t)){u.current=!0;var i=t.changedTouches||[];i.length&&(l.current=i[0].identifier)}r.focus(),o(Cc(r,t,l.current)),n(!0)}},function(e){var t=e.which||e.keyCode;t<37||t>40||(e.preventDefault(),s({left:t===39?.05:t===37?-.05:0,top:t===40?.05:t===38?-.05:0}))},function(e){var t=e.which||e.keyCode;t>=37&&t<=40&&c()},n]},[s,o,c]),f=d[0],p=d[1],m=d[2],h=d[3];return(0,G.useEffect)(function(){return h},[h]),G.createElement(`div`,_c({},i,{onTouchStart:f,onMouseDown:f,className:`react-colorful__interactive`,ref:a,onKeyDown:p,onKeyUp:m,tabIndex:0,role:`slider`}))}),Ec=function(e){return e.filter(Boolean).join(` `)},Dc=function(e){var t=e.color,n=e.left,r=e.top,i=r===void 0?.5:r,a=Ec([`react-colorful__pointer`,e.className]);return G.createElement(`div`,{className:a,style:{top:100*i+`%`,left:100*n+`%`}},G.createElement(`div`,{className:`react-colorful__pointer-fill`,style:{backgroundColor:t}}))},$=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=10**t),Math.round(n*e)/n};360/(2*Math.PI);var Oc=function(e){return Ic(kc(e))},kc=function(e){return e[0]===`#`&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?$(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:e.length===8?$(parseInt(e.substring(6,8),16)/255,2):1}},Ac=function(e){return Fc(Nc(e))},jc=function(e){var t=e.s,n=e.v,r=e.a,i=(200-t)*n/100;return{h:$(e.h),s:$(i>0&&i<200?t*n/100/(i<=100?i:200-i)*100:0),l:$(i/2),a:$(r,2)}},Mc=function(e){var t=jc(e);return`hsl(`+t.h+`, `+t.s+`%, `+t.l+`%)`},Nc=function(e){var t=e.h,n=e.s,r=e.v,i=e.a;t=t/360*6,n/=100,r/=100;var a=Math.floor(t),o=r*(1-n),s=r*(1-(t-a)*n),c=r*(1-(1-t+a)*n),l=a%6;return{r:$(255*[r,s,o,o,c,r][l]),g:$(255*[c,r,r,s,o,o][l]),b:$(255*[o,o,c,r,r,s][l]),a:$(i,2)}},Pc=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Fc=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i<1?Pc($(255*i)):``;return`#`+Pc(t)+Pc(n)+Pc(r)+a},Ic=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=Math.max(t,n,r),o=a-Math.min(t,n,r),s=o?a===t?(n-r)/o:a===n?2+(r-t)/o:4+(t-n)/o:0;return{h:$(60*(s<0?s+6:s)),s:$(a?o/a*100:0),v:$(a/255*100),a:i}},Lc=G.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,i=Ec([`react-colorful__hue`,e.className]);return G.createElement(`div`,{className:i},G.createElement(Tc,{onMove:function(e){n({h:360*e.left})},onKey:function(e){n({h:bc(t+360*e.left,0,360)})},onEnd:r,"aria-label":`Hue`,"aria-valuenow":$(t),"aria-valuemax":`360`,"aria-valuemin":`0`},G.createElement(Dc,{className:`react-colorful__hue-pointer`,left:t/360,color:Mc({h:t,s:100,v:100,a:1})})))}),Rc=G.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,i={backgroundColor:Mc({h:t.h,s:100,v:100,a:1})};return G.createElement(`div`,{className:`react-colorful__saturation`,style:i},G.createElement(Tc,{onMove:function(e){n({s:100*e.left,v:100-100*e.top})},onKey:function(e){n({s:bc(t.s+100*e.left,0,100),v:bc(t.v-100*e.top,0,100)})},onEnd:r,"aria-label":`Color`,"aria-valuetext":`Saturation `+$(t.s)+`%, Brightness `+$(t.v)+`%`},G.createElement(Dc,{className:`react-colorful__saturation-pointer`,top:1-t.v/100,left:t.s/100,color:Mc(t)})))}),zc=function(e,t){if(e===t)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0},Bc=function(e,t){return e.toLowerCase()===t.toLowerCase()||zc(kc(e),kc(t))};function Vc(e,t,n,r){var i=yc(n),a=yc(r),o=(0,G.useState)(function(){return e.toHsva(t)}),s=o[0],c=o[1],l=(0,G.useRef)({color:t,hsva:s}),u=(0,G.useRef)(!1);return(0,G.useEffect)(function(){if(!e.equal(t,l.current.color)){var n=e.toHsva(t);l.current={hsva:n,color:t},c(n),u.current=!1}},[t,e]),(0,G.useEffect)(function(){var t;zc(s,l.current.hsva)||e.equal(t=e.fromHsva(s),l.current.color)||(l.current={hsva:s,color:t},i(t),u.current=!0)},[s,e,i]),[s,(0,G.useCallback)(function(e){c(function(t){return Object.assign({},t,e)})},[]),(0,G.useCallback)(function(){u.current&&(u.current=!1,a(l.current.color))},[a])]}var Hc,Uc=typeof window<`u`?G.useLayoutEffect:G.useEffect,Wc=function(){return Hc||(typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0)},Gc=new WeakMap,Kc=function(e){Uc(function(){var t=e.current;if(typeof document<`u`&&t){var n=t.getRootNode?t.getRootNode():t.ownerDocument,r=n&&(`head`in n||`host`in n)?n:t.ownerDocument;if(!Gc.has(r)){var i=`head`in r?r.head:r,a=(i.ownerDocument||document).createElement(`style`);a.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`;var o=Wc();o&&a.setAttribute(`nonce`,o),Gc.set(r,a),i.appendChild(a)}}},[])},qc=function(e){var t=e.className,n=e.colorModel,r=e.color,i=r===void 0?n.defaultColor:r,a=e.onChange,o=e.onChangeEnd,s=vc(e,[`className`,`colorModel`,`color`,`onChange`,`onChangeEnd`]),c=(0,G.useRef)(null);Kc(c);var l=Vc(n,i,a,o),u=l[0],d=l[1],f=l[2],p=Ec([`react-colorful`,t]);return G.createElement(`div`,_c({},s,{ref:c,className:p}),G.createElement(Rc,{hsva:u,onChange:d,onChangeEnd:f}),G.createElement(Lc,{hue:u.h,onChange:d,onChangeEnd:f,className:`react-colorful__last-control`}))},Jc={defaultColor:`000`,toHsva:Oc,fromHsva:function(e){return Ac({h:e.h,s:e.s,v:e.v,a:1})},equal:Bc},Yc=function(e){return G.createElement(qc,_c({},e,{colorModel:Jc}))};function Xc(e){let t=e.trim().replace(/^#/,``).toLowerCase();return/^[0-9a-f]{6}$/.test(t)?`#${t}`:/^[0-9a-f]{3}$/.test(t)?`#${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`:null}function Zc({value:e,onChange:t,palette:n,hexLabel:r=`Hex color`,paletteLabel:i=`Color palette`}){let[a,o]=(0,G.useState)(null),s=Xc(e)??`#6b7280`;return(0,q.jsxs)(`div`,{className:`flex w-56 flex-col gap-3`,"data-slot":`color-picker`,children:[(0,q.jsx)(Yc,{className:`!w-full`,color:s,onChange:t}),n.length>0&&(0,q.jsx)(`div`,{"aria-label":i,className:`flex flex-wrap gap-1.5`,role:`listbox`,children:n.map(e=>{let n=Xc(e)??e;return(0,q.jsx)(`button`,{"aria-label":n,"aria-selected":n===s,className:F(`size-6 shrink-0 rounded-full border border-lt-border`,n===s&&`ring-2 ring-lt-ring ring-offset-1`),onClick:()=>t(n),role:`option`,style:{background:e},type:`button`},e)})}),(0,q.jsx)(pt,{"aria-label":r,onBlur:()=>o(null),onChange:e=>{let n=e.target.value,r=Xc(n);o(n),r!==null&&t(r)},value:a??s})]})}function Qc({node:e,label:t,children:n}){let r=hc(e);return r.hidden?null:(0,q.jsx)(Ve,{error:r.error,helperText:ft(e).helperText??void 0,tooltip:ft(e).tooltip??void 0,label:t,name:r.name,required:r.required,children:n(r)})}var $c=({node:e})=>{let t=e.props;return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,value:n,readOnly:r,disabled:i,commit:a})=>{let o=Xc(n);return(0,q.jsxs)(De,{children:[(0,q.jsx)(`input`,{name:e,type:`hidden`,value:o??``}),(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{className:F(yt(),`flex items-center gap-2 text-left`),"data-test":`color-picker-${e}`,disabled:i||r,id:e,type:`button`,children:o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 shrink-0 rounded-full border border-lt-border`,style:{background:o}}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:o})]}):(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:t.placeholder??``})})}),(0,q.jsx)(B,{className:`p-3`,children:(0,q.jsx)(Zc,{onChange:e=>a(e),palette:t.palette,value:o??`#6b7280`})})]})}})},el=(0,G.lazy)(async()=>{let{DatePickerField:e}=await tn(async()=>{let{DatePickerField:e}=await import(`./chunks/date-picker-field-CCnkf4SC.js`);return{DatePickerField:e}},__vite__mapDeps([14,1,4,2,15,3,11,16]),import.meta.url);return{default:e}});function tl(e){return(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(el,{...e})})}var nl=({node:e})=>{let t=e.props;return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,change:o,blur:s})=>(0,q.jsx)(tl,{autoFocus:t.autoFocus??!1,disabled:a,label:t.label??t.name,max:t.max||void 0,min:t.min||void 0,mode:`date`,name:e,onBlur:s,onChange:o,readOnly:i,tabIndex:t.tabIndex??void 0,testId:n??t.name,value:r})})},rl=({node:e})=>{let t=e.props,{timezone:n}=D();return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,testId:r,value:i,readOnly:a,disabled:o,change:s,blur:c})=>(0,q.jsx)(tl,{autoFocus:t.autoFocus??!1,disabled:o,label:t.label??t.name,max:t.max,min:t.min,mode:`date-time`,name:e,onBlur:c,onChange:s,readOnly:a,step:t.step,tabIndex:t.tabIndex??void 0,testId:r??t.name,timezone:n,value:i})})};function il({url:e,method:t,body:n,headers:r,onProgress:i}){return new Promise((a,o)=>{let s=new XMLHttpRequest;s.open(t,e,!0),Object.entries(r).forEach(([e,t])=>s.setRequestHeader(e,String(t))),s.upload.onprogress=e=>{e.lengthComputable&&i?.(Math.round(e.loaded/e.total*100))},s.onload=()=>{try{a(new Response(s.responseText||null,{status:s.status||500}))}catch{o(Error(`Upload to ${e} returned an unusable response`))}},s.onerror=()=>o(Error(`Upload to ${e} failed`)),s.send(n)})}function al(e,{ref:t,target:n,filename:r,contentType:i,values:a}){return Ut(e,{method:`POST`,ref:t,body:JSON.stringify({...a,_sub:`upload`,_target:n,filename:r,contentType:i}),throwOnError:!1})}function ol(e,t){return Array.isArray(t)?Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}var sl=({node:e})=>{let{t}=w(`lattice`),n=e.props,{hidden:r,required:i,readOnly:a,disabled:o}=Je(e),{action:s,componentRef:c,errors:l}=Te(),u=n.name,d=lt(),f=d?d.scopedName(u):u,p=d?d.errorKey(u):u,m=p,h=Pe(),g=Ce(),_=(0,G.useId)(),v=(0,G.useRef)(null),y=(0,G.useRef)(new Set),b=a||o,x=n.signed,S=n.multiple,C=S?`${f}[]`:f,T=(0,G.useMemo)(()=>(n.files??[]).map(e=>({id:crypto.randomUUID(),name:e.name,size:e.size,status:`ready`,progress:100,key:e.key,url:e.url,token:e.token,existing:!0})),[n.files]),[E,D]=(0,G.useState)(T),[O,k]=(0,G.useState)([]);(0,G.useEffect)(()=>{if(!x)return;let e=E.filter(e=>!e.existing&&e.key&&e.status===`ready`).map(e=>e.key),t=S?e:e[0]??``;if(d){ol(d.getValue(u),t)||d.setValue(u,t);return}g(u,t)},[E,S,u,d,g,x]),(0,G.useEffect)(()=>{!x||d||g(`${u}__removed`,O)},[u,O,d,g,x]),(0,G.useEffect)(()=>()=>{y.current.forEach(e=>URL.revokeObjectURL(e)),y.current.clear()},[]);let j=(0,G.useMemo)(()=>E.filter(e=>e.file&&!e.existing).map(e=>e.file),[E]);(0,G.useEffect)(()=>{if(x||!v.current)return;let e=new DataTransfer;j.forEach(t=>e.items.add(t)),v.current.files=e.files},[j,x]);function M(e){if(!n.image)return;let t=URL.createObjectURL(e);return y.current.add(t),t}function N(e){!e.url||!y.current.has(e.url)||(URL.revokeObjectURL(e.url),y.current.delete(e.url))}async function P(e,t){let n=()=>{D(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))},r=await al(s,{ref:c,target:m,filename:t.name,contentType:t.type,values:h});if(!r.ok){n();return}let i=await r.json();try{let n=await il({url:i.url,method:i.method.toUpperCase(),body:t,headers:i.headers,onProgress:t=>D(n=>n.map(n=>n.id===e.id?{...n,progress:t}:n))});D(t=>t.map(t=>t.id===e.id?{...t,status:n.ok?`ready`:`error`,key:i.key,progress:100}:t))}catch{n()}}function F(e){if(!e||b)return;let t=Array.from(e),n=t.map(e=>({id:crypto.randomUUID(),name:e.name,size:e.size,status:x?`uploading`:`ready`,progress:0,file:e,url:M(e),existing:!1}));if(!S&&(E.forEach(N),!d)){let e=E.filter(e=>e.existing&&e.token).map(e=>e.token);e.length>0&&k(t=>[...t,...e])}D(e=>S?[...e,...n]:n),x&&n.forEach((e,n)=>void P(e,t[n]))}function I(e){let t=E.find(t=>t.id===e);t&&N(t),t?.existing&&t.token&&!d&&k(e=>[...e,t.token]),D(t=>t.filter(t=>t.id!==e))}return r?null:(0,q.jsx)(Ve,{error:l[p],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:u,required:i,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lt-sm border border-dashed border-lt-border bg-lt-surface px-4 py-6`,"data-test":A(u),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),F(e.dataTransfer.files)},children:[(0,q.jsx)(`button`,{className:`text-sm text-lt-muted-fg`,disabled:b,onClick:()=>v.current?.click(),type:`button`,children:t(`form.file-upload.dropzone`,`Drop files here or click to browse`)}),(0,q.jsx)(`ul`,{className:n.image?`grid grid-cols-1 gap-3 sm:grid-cols-2`:`flex flex-col gap-2`,children:E.map(e=>(0,q.jsxs)(`li`,{className:n.image?`flex min-w-0 items-center gap-3 rounded-lt-sm border border-lt-border bg-lt-bg p-2 text-sm`:`flex items-center justify-between gap-3 text-sm`,children:[n.image&&e.url?(0,q.jsx)(`img`,{alt:e.name,className:`size-16 shrink-0 rounded-lt-sm border border-lt-border object-cover`,"data-test":A(`${u}-preview`),src:e.url}):null,(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate`,"data-test":A(`${u}-item`),children:e.name}),e.status===`uploading`&&(0,q.jsxs)(`span`,{className:`text-xs text-lt-muted-fg`,children:[e.progress,`%`]}),e.status===`error`&&(0,q.jsx)(`span`,{className:`text-xs text-lt-danger`,children:t(`form.file-upload.failed`,`Failed`)})]}),(!e.existing||!d)&&(0,q.jsx)(it,{size:`sm`,icon:`x`,label:t(`form.file-upload.remove`,`Remove {{name}}`,{name:e.name}),"data-test":A(e.existing?`${u}-remove-existing`:`${u}-remove`),disabled:b,onClick:()=>I(e.id)}),x&&!e.existing&&e.key&&e.status===`ready`&&(0,q.jsx)(`input`,{"data-test":A(`${u}-uploaded`),name:C,type:`hidden`,value:e.key})]},e.id))}),!d&&O.map(e=>(0,q.jsx)(`input`,{name:`${u}__removed[]`,type:`hidden`,value:e},e)),(0,q.jsx)(`input`,{accept:n.accept??void 0,"aria-label":n.label??u,className:`sr-only`,"data-test":A(`${u}-input`),id:_,multiple:S,name:x?void 0:C,onChange:e=>{F(e.target.files),x&&(e.target.value=``)},ref:v,type:`file`})]})})};function cl({label:e,summaryLabel:t,variant:n,emphasis:r}){let{componentId:i,errors:a,fieldLabels:o,processing:s}=Te(),c=Object.entries(a).filter(([,e])=>!!e).map(([e,t])=>({label:o[e]??e,message:t})),l=c.length>0;return(0,q.jsxs)(`span`,{className:`group relative inline-flex flex-col`,children:[(0,q.jsxs)(W,{"data-lattice-form":i,"data-test":`form-submit`,disabled:s||l,emphasis:r,type:`submit`,variant:n,children:[s&&(0,q.jsx)(ia,{}),e]}),l&&(0,q.jsxs)(`div`,{className:`pointer-events-none absolute bottom-full left-1/2 z-lt-popover mb-2 w-max max-w-xs -translate-x-1/2 rounded-lt border border-lt-border bg-lt-surface p-3 text-left text-sm opacity-0 shadow-lt-md transition-opacity group-hover:opacity-100`,role:`tooltip`,children:[(0,q.jsx)(`p`,{className:`mb-1 font-medium text-lt-fg`,children:t}),(0,q.jsx)(`ul`,{className:`space-y-1`,children:c.map(e=>(0,q.jsxs)(`li`,{className:`text-lt-muted-fg`,children:[(0,q.jsx)(`span`,{className:`font-medium text-lt-fg`,children:e.label}),` — `,e.message]},e.label))})]})]})}var ll={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`,around:`justify-around`,evenly:`justify-evenly`};function ul({componentId:e,reset:t}){let n=ut();return bn(i.resetForm,r=>{let i=r.detail;(!i?.form||i.form===e)&&(t(),n())}),null}function dl({action:e,children:t,componentRef:n,nodes:r,shouldRenderSubmitButton:i,submitButtons:a,submitEmphasis:o,submitJustify:s,submitLabel:c,submitVariant:l,summaryLabel:u}){let{nodes:d,markUserEdit:f}=ba(e,n,r),p=(0,G.useMemo)(()=>({markUserEdit:f}),[f]);return(0,q.jsx)(Ee,{value:p,children:(0,q.jsx)(la,{nodes:d,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t,i&&(0,q.jsx)(`div`,{className:`flex gap-3 ${ll[s??`end`]}`,children:a?.length?a.map((e,t)=>e.props.buttonType===`submit`?(0,q.jsx)(cl,{emphasis:e.props.emphasis??o,label:e.props.label??c,summaryLabel:u,variant:e.props.variant??l},Cn(e,t)):(0,q.jsx)(Y,{node:e},Cn(e,t))):(0,q.jsx)(cl,{emphasis:o,label:c,summaryLabel:u,variant:l})})]})})})}function fl(e){return!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?e:void 0}var pl=({children:e,node:t})=>{let n=(0,G.useMemo)(()=>({...xa(t.schema).values,...t.props.state}),[t.schema,t.props.state]);return(0,q.jsx)(ct,{initial:n,children:(0,q.jsx)(ml,{node:t,children:e})})};function ml({children:e,node:t}){let{t:n}=w(`lattice`),r=t.props,i=r.action??`#`,a=r.errorBag,o=r.ref??``,s=r.method??`post`,l=r.precognitive,u=r.resetOnError??!1,d=r.resetOnSuccess??[],f=(0,G.useMemo)(()=>xa(t.schema).labels,[t.schema]),p=r.submitButton,m=r.submitButtons??void 0,h=r.submitJustify??void 0,g=r.submitLabel??n(`form.submit`,`Submit`),_=r.submitVariant??void 0,v=r.submitEmphasis??void 0,y=r.validationSummaryLabel,b=r.validationTimeout??void 0,x=ut(),S=e=>{let t=fl(e);t!==!1&&x(t)},C=(0,G.useRef)(null),T=(0,G.useRef)(`idle`),[E,D]=(0,G.useState)(0);return(0,G.useEffect)(()=>{E>0&&T.current===`renewing`&&C.current?.submit()},[E]),(0,q.jsx)(c,{ref:C,action:i,"data-slot":`form`,"data-lattice-component":t.id,errorBag:a,method:s,resetOnError:u,resetOnSuccess:d,validationTimeout:l?b:void 0,headers:Mt(o),className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,onStart:()=>{T.current=T.current===`renewing`?`retried`:`idle`},onSuccess:()=>S(d),onError:()=>S(u),onHttpException:e=>{if(e.status===403&&o!==``&&T.current!==`retried`)return T.current=`renewing`,Ht(o).finally(()=>D(e=>e+1)),!1},children:({clearErrors:n,errors:a,processing:s,reset:c,touch:u,validate:d,validating:b})=>(0,q.jsxs)(pe,{value:{action:i,clearErrors:e=>n(e),componentId:t.id,componentRef:o,errors:a,fieldLabels:f,precognitive:l,processing:s,touch:e=>u(...e),validate:e=>d(e),validateFields:(e,t)=>d({only:e,...t}),validating:b},children:[(0,q.jsx)(ul,{componentId:t.id,reset:c}),r.status&&(0,q.jsx)(`div`,{className:`text-center text-sm font-medium text-lt-success`,children:r.status}),(0,q.jsx)(dl,{action:i,componentRef:o,nodes:t.schema,shouldRenderSubmitButton:p,submitButtons:m,submitEmphasis:v,submitJustify:h,submitLabel:g,submitVariant:_,summaryLabel:y,children:e})]})})}var hl=({node:e})=>{let t=lt(),n=e.props.name,r=t?t.getValue(n):e.props.value;return(0,q.jsx)(`input`,{defaultValue:typeof r==`string`?r:``,name:t?t.scopedName(n):n,type:`hidden`})};function gl({affix:e,side:t,squared:n=!1}){return(0,q.jsx)(`span`,{"data-slot":`affix-${t}`,className:F(`inline-flex h-lt-control-md shrink-0 items-center border border-lt-input bg-lt-muted px-3 text-base whitespace-nowrap text-lt-muted-fg`,`group-has-[:focus-visible]:border-lt-ring`,t===`start`?`rounded-l-lt-sm border-r-0`:`rounded-r-lt-sm border-l-0`,n&&`rounded-r-none border-r-0`),children:e.icon?(0,q.jsx)(P,{className:`size-lt-icon-md`,icon:e.icon}):e.text})}function _l({prefix:e,suffix:t,end:n,children:r}){return!e&&!t&&!n?r(``):(0,q.jsxs)(`div`,{className:`group flex w-full rounded-lt-sm transition-[color,box-shadow] has-[:focus-visible]:ring-[length:var(--lt-ring-width)] has-[:focus-visible]:ring-lt-ring/50`,"data-slot":`affix-group`,children:[e?(0,q.jsx)(gl,{affix:e,side:`start`}):null,(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:r(F(`focus-visible:ring-0`,e&&`rounded-l-none`,(t||n)&&`rounded-r-none`))}),t?(0,q.jsx)(gl,{affix:t,side:`end`,squared:!!n}):null,n]})}var vl=({node:e})=>{let t=e.props;return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>{let s=e=>o(e.target.value);return t.slider?(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`input`,{"aria-label":t.label??``,className:`h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:accent-lt-disabled`,"data-test":n,disabled:a||i,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`range`,value:r}),(0,q.jsx)(`output`,{className:`w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg`,children:r})]}):(0,q.jsx)(_l,{prefix:t.prefix,suffix:t.suffix,children:o=>(0,q.jsx)(pt,{autoFocus:t.autoFocus??!1,className:o,"data-test":n,disabled:a,id:e,max:t.max??void 0,min:t.min??void 0,name:e,onChange:s,placeholder:t.placeholder??``,readOnly:i,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`number`,value:r})})}})},yl=Object.defineProperty,bl=Object.defineProperties,xl=Object.getOwnPropertyDescriptors,Sl=Object.getOwnPropertySymbols,Cl=Object.prototype.hasOwnProperty,wl=Object.prototype.propertyIsEnumerable,Tl=(e,t,n)=>t in e?yl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,El=(e,t)=>{for(var n in t||={})Cl.call(t,n)&&Tl(e,n,t[n]);if(Sl)for(var n of Sl(t))wl.call(t,n)&&Tl(e,n,t[n]);return e},Dl=(e,t)=>bl(e,xl(t)),Ol=(e,t)=>{var n={};for(var r in e)Cl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Sl)for(var r of Sl(e))t.indexOf(r)<0&&wl.call(e,r)&&(n[r]=e[r]);return n};function kl(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function Al(e){let t=G.useRef();return G.useEffect(()=>{t.current=e}),t.current}var jl=18,Ml=40,Nl=`${Ml}px`,Pl=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`);function Fl({containerRef:e,inputRef:t,pushPasswordManagerStrategy:n,isFocused:r}){let[i,a]=G.useState(!1),[o,s]=G.useState(!1),[c,l]=G.useState(!1),u=G.useMemo(()=>n!==`none`&&(n===`increase-width`||n===`experimental-no-flickering`)&&i&&o,[i,o,n]),d=G.useCallback(()=>{let r=e.current,i=t.current;if(!r||!i||c||n===`none`)return;let o=r,s=o.getBoundingClientRect().left+o.offsetWidth,u=o.getBoundingClientRect().top+o.offsetHeight/2,d=s-jl,f=u;document.querySelectorAll(Pl).length===0&&document.elementFromPoint(d,f)===r||(a(!0),l(!0))},[e,t,c,n]);return G.useEffect(()=>{let t=e.current;if(!t||n===`none`)return;function r(){let e=window.innerWidth-t.getBoundingClientRect().right;s(e>=Ml)}r();let i=setInterval(r,1e3);return()=>{clearInterval(i)}},[e,n]),G.useEffect(()=>{let e=r||document.activeElement===t.current;if(n===`none`||!e)return;let i=setTimeout(d,0),a=setTimeout(d,2e3),o=setTimeout(d,5e3),s=setTimeout(()=>{l(!0)},6e3);return()=>{clearTimeout(i),clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[t,r,n,d]),{hasPWMBadge:i,willPushPWMBadge:u,PWM_BADGE_SPACE_WIDTH:Nl}}var Il=G.createContext({}),Ll=G.forwardRef((e,t)=>{var n=e,{value:r,onChange:i,maxLength:a,textAlign:o=`left`,pattern:s,placeholder:c,inputMode:l=`numeric`,onComplete:u,pushPasswordManagerStrategy:d=`increase-width`,pasteTransformer:f,containerClassName:p,noScriptCSSFallback:m=zl,render:h,children:g}=n,_=Ol(n,[`value`,`onChange`,`maxLength`,`textAlign`,`pattern`,`placeholder`,`inputMode`,`onComplete`,`pushPasswordManagerStrategy`,`pasteTransformer`,`containerClassName`,`noScriptCSSFallback`,`render`,`children`]),v;let[y,b]=G.useState(typeof _.defaultValue==`string`?_.defaultValue:``),x=r??y,S=Al(x),C=G.useCallback(e=>{i?.(e),b(e)},[i]),w=G.useMemo(()=>s?typeof s==`string`?new RegExp(s):s:null,[s]),T=G.useRef(null),E=G.useRef(null),D=G.useRef({value:x,onChange:C,isIOS:typeof window<`u`&&((v=window==null?void 0:window.CSS)?.supports)?.call(v,`-webkit-touch-callout`,`none`)}),O=G.useRef({prev:[T.current?.selectionStart,T.current?.selectionEnd,T.current?.selectionDirection]});G.useImperativeHandle(t,()=>T.current,[]),G.useEffect(()=>{let e=T.current,t=E.current;if(!e||!t)return;D.current.value!==e.value&&D.current.onChange(e.value),O.current.prev=[e.selectionStart,e.selectionEnd,e.selectionDirection];function n(){if(document.activeElement!==e){P(null),I(null);return}let t=e.selectionStart,n=e.selectionEnd,r=e.selectionDirection,i=e.maxLength,a=e.value,o=O.current.prev,s=-1,c=-1,l;if(a.length!==0&&t!==null&&n!==null){let e=t===n,r=t===a.length&&a.length<i;if(e&&!r){let e=t;if(e===0)s=0,c=1,l=`forward`;else if(e===i)s=e-1,c=e,l=`backward`;else if(i>1&&a.length>1){let t=0;if(o[0]!==null&&o[1]!==null){l=e<o[1]?`backward`:`forward`;let n=o[0]===o[1]&&o[0]<i;l===`backward`&&!n&&(t=-1)}s=t+e,c=t+e+1}}s!==-1&&c!==-1&&s!==c&&T.current.setSelectionRange(s,c,l)}let u=s===-1?t:s,d=c===-1?n:c,f=l??r;P(u),I(d),O.current.prev=[u,d,f]}if(document.addEventListener(`selectionchange`,n,{capture:!0}),n(),document.activeElement===e&&M(!0),!document.getElementById(`input-otp-style`)){let e=document.createElement(`style`);if(e.id=`input-otp-style`,document.head.appendChild(e),e.sheet){let t=`background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;`;Rl(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Rl(e.sheet,`[data-input-otp]:autofill { ${t} }`),Rl(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Rl(e.sheet,`@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }`),Rl(e.sheet,`[data-input-otp] + * { pointer-events: all !important; }`)}}let r=()=>{t&&t.style.setProperty(`--root-height`,`${e.clientHeight}px`)};r();let i=new ResizeObserver(r);return i.observe(e),()=>{document.removeEventListener(`selectionchange`,n,{capture:!0}),i.disconnect()}},[]);let[k,A]=G.useState(!1),[j,M]=G.useState(!1),[N,P]=G.useState(null),[F,I]=G.useState(null);G.useEffect(()=>{kl(()=>{var e;(e=T.current)==null||e.dispatchEvent(new Event(`input`));let t=T.current?.selectionStart,n=T.current?.selectionEnd,r=T.current?.selectionDirection;t!==null&&n!==null&&(P(t),I(n),O.current.prev=[t,n,r])})},[x,j]),G.useEffect(()=>{S!==void 0&&x!==S&&S.length<a&&x.length===a&&u?.(x)},[a,u,S,x]);let L=Fl({containerRef:E,inputRef:T,pushPasswordManagerStrategy:d,isFocused:j}),ee=G.useCallback(e=>{let t=e.currentTarget.value.slice(0,a);if(t.length>0&&w&&!w.test(t)){e.preventDefault();return}typeof S==`string`&&t.length<S.length&&document.dispatchEvent(new Event(`selectionchange`)),C(t)},[a,C,S,w]),te=G.useCallback(()=>{var e;if(T.current){let t=Math.min(T.current.value.length,a-1),n=T.current.value.length;(e=T.current)==null||e.setSelectionRange(t,n),P(t),I(n)}M(!0)},[a]),ne=G.useCallback(e=>{let t=T.current;if(!f&&(!D.current.isIOS||!e.clipboardData||!t))return;let n=e.clipboardData.getData(`text/plain`),r=f?f(n):n;e.preventDefault();let i=T.current?.selectionStart,o=T.current?.selectionEnd,s=(i===o?x.slice(0,i)+r+x.slice(i):x.slice(0,i)+r+x.slice(o)).slice(0,a);if(s.length>0&&w&&!w.test(s))return;t.value=s,C(s);let c=Math.min(s.length,a-1),l=s.length;t.setSelectionRange(c,l),P(c),I(l)},[a,C,w,x]),re=G.useMemo(()=>({position:`relative`,cursor:_.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[_.disabled]),R=G.useMemo(()=>({position:`absolute`,inset:0,width:L.willPushPWMBadge?`calc(100% + ${L.PWM_BADGE_SPACE_WIDTH})`:`100%`,clipPath:L.willPushPWMBadge?`inset(0 ${L.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:`100%`,display:`flex`,textAlign:o,opacity:`1`,color:`transparent`,pointerEvents:`all`,background:`transparent`,caretColor:`transparent`,border:`0 solid transparent`,outline:`0 solid transparent`,boxShadow:`none`,lineHeight:`1`,letterSpacing:`-.5em`,fontSize:`var(--root-height)`,fontFamily:`monospace`,fontVariantNumeric:`tabular-nums`}),[L.PWM_BADGE_SPACE_WIDTH,L.willPushPWMBadge,o]),ie=G.useMemo(()=>G.createElement(`input`,Dl(El({autoComplete:_.autoComplete||`one-time-code`},_),{"data-input-otp":!0,"data-input-otp-placeholder-shown":x.length===0||void 0,"data-input-otp-mss":N,"data-input-otp-mse":F,inputMode:l,pattern:w?.source,"aria-placeholder":c,style:R,maxLength:a,value:x,ref:T,onPaste:e=>{var t;ne(e),(t=_.onPaste)==null||t.call(_,e)},onChange:ee,onMouseOver:e=>{var t;A(!0),(t=_.onMouseOver)==null||t.call(_,e)},onMouseLeave:e=>{var t;A(!1),(t=_.onMouseLeave)==null||t.call(_,e)},onFocus:e=>{var t;te(),(t=_.onFocus)==null||t.call(_,e)},onBlur:e=>{var t;M(!1),(t=_.onBlur)==null||t.call(_,e)}})),[ee,te,ne,l,R,a,F,N,_,w?.source,x]),z=G.useMemo(()=>({slots:Array.from({length:a}).map((e,t)=>{let n=j&&N!==null&&F!==null&&(N===F&&t===N||t>=N&&t<F),r=x[t]===void 0?null:x[t];return{char:r,placeholderChar:x[0]===void 0?c?.[t]??null:null,isActive:n,hasFakeCaret:n&&r===null}}),isFocused:j,isHovering:!_.disabled&&k}),[j,k,a,F,N,_.disabled,x]),ae=G.useMemo(()=>h?h(z):G.createElement(Il.Provider,{value:z},g),[g,z,h]);return G.createElement(G.Fragment,null,m!==null&&G.createElement(`noscript`,null,G.createElement(`style`,null,m)),G.createElement(`div`,{ref:E,"data-input-otp-container":!0,style:re,className:p},ae,G.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},ie)))});Ll.displayName=`Input`;function Rl(e,t){try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}}var zl=`
4
4
  [data-input-otp] {
5
5
  --nojs-bg: white !important;
6
6
  --nojs-fg: black !important;
@@ -19,4 +19,4 @@ import{i as e,t}from"./chunks/react-SIfiwpqq.js";import{a as n,n as r,o as i}fro
19
19
  --nojs-bg: black !important;
20
20
  --nojs-fg: white !important;
21
21
  }
22
- }`,zl=`^\\d+$`;function Bl({char:e,hasFakeCaret:t,isActive:n}){return(0,J.jsxs)(`div`,{className:P(`relative flex h-lt-control-md w-10 items-center justify-center border-y border-r border-lt-input text-base shadow-lt-xs transition-all first:rounded-l-lt-sm first:border-l last:rounded-r-lt-sm`,n&&`z-10 border-lt-ring ring-lt-ring/50 ring-[length:var(--lt-ring-width)]`),children:[e,t?(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(`div`,{className:`bg-lt-fg h-5 w-px animate-pulse`})}):null]})}function Vl({length:e,containerClassName:t,pattern:n=zl,...r}){return(0,J.jsx)(Il,{maxLength:e,pattern:n,containerClassName:P(`flex items-center gap-2 has-[:disabled]:opacity-50`,t),render:({slots:e})=>(0,J.jsx)(`div`,{className:`flex items-center`,children:e.map((e,t)=>(0,J.jsx)(Bl,{...e},t))}),...r})}var Hl=({node:e})=>{let t=e.props;return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,J.jsx)(Vl,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a||i,id:e,length:t.length,name:e,onChange:e=>o(e),value:r})})};function Ul({className:e,ref:t,...n}){let[r,i]=(0,K.useState)(!1);return(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(dt,{type:r?`text`:`password`,className:P(`pr-10`,e),ref:t,...n}),(0,J.jsx)(`button`,{type:`button`,"data-test":typeof n.name==`string`?`${n.name}-visibility`:`password-visibility`,onClick:()=>i(e=>!e),className:`absolute inset-y-0 right-0 flex items-center rounded-r-lt-sm px-3 text-lt-muted-fg hover:text-lt-fg focus-visible:ring-[length:var(--lt-ring-width)] focus-visible:ring-lt-ring/50 focus-visible:outline-none`,"aria-label":r?`Hide password`:`Show password`,tabIndex:-1,children:r?(0,J.jsx)(R,{name:`eye-off`,className:`size-lt-icon-md`}):(0,J.jsx)(R,{name:`eye`,className:`size-lt-icon-md`})})]})}var Wl=({node:e})=>{let t=e.props,{errors:n}=H(),r=mc(e),{commit:i}=ke(),a=st(),o=t.confirmation,s=o?.name??`${r.localName}_confirmation`,c=a?a.scopedName(s):s,l=a?a.errorKey(s):s,u=(t.passwordRules??``)||void 0;return r.hidden?null:(0,J.jsxs)(`div`,{className:`grid gap-6`,children:[(0,J.jsx)(ze,{error:r.error,helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,labelAction:t.labelAction??void 0,name:r.name,required:r.required,children:(0,J.jsx)(gl,{prefix:t.prefix,suffix:t.suffix,children:e=>(0,J.jsx)(Ul,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:e,"data-test":r.testId,disabled:r.disabled,id:r.name,name:r.name,onChange:e=>{r.commit(e.target.value)},placeholder:t.placeholder??``,passwordrules:u,readOnly:r.readOnly,tabIndex:t.tabIndex??void 0,value:r.value})})}),o&&(0,J.jsx)(ze,{error:n[l],label:o.label??`Confirm password`,name:c,required:r.required,children:(0,J.jsx)(Ul,{autoComplete:`new-password`,"data-test":k(s),disabled:r.disabled,id:c,name:c,onChange:e=>{i(s,e.target.value)},placeholder:o.placeholder??o.label??`Confirm password`,passwordrules:u,readOnly:r.readOnly,tabIndex:t.tabIndex??void 0})})]})},Gl=[],Kl=({node:e})=>{let t=e.props,n=t.name,{errors:r}=H(),{hidden:i,required:a}=Ke(e),{path:o,rows:s,onField:c,onRemove:l,onMove:u,onDuplicate:d,append:f}=Us(n,t.defaultItems??1),p=e.schema??Gl,m=Hs(s.map(e=>String(e.rowId??``)).join(`,`)),h=t.maxItems!=null&&s.length>=t.maxItems,g=t.minItems!=null&&s.length<=t.minItems,_=t.layout===`table`,v=t.itemLabels,y=e=>{let n=v?.[e];return typeof n==`string`&&n!==``?n:t.itemLabel?`${t.itemLabel} ${e+1}`:`#${e+1}`};if(i)return null;let b=s.map((e,t)=>({key:String(e.rowId??t),index:t,row:e,template:p,span:!1,heading:y(t)}));return(0,J.jsx)(ze,{error:r[o],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:o,required:a,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(fs,{path:o,rows:s,rowKey:le}),_?(0,J.jsx)(zs,{base:o,columns:Ls(p),rows:b,reorderable:t.reorderable??!1,removable:()=>!g,rowActions:t.rowActions,onField:c,onMove:u,onRemove:l,onDuplicate:d,registerRow:m,resizableColumns:t.resizableColumns===!0,resizeIndicator:t.resizeIndicator===!0}):s.map((e,n)=>{let r=String(e.rowId??n);return(0,J.jsx)(`div`,{ref:e=>m(r,e),"data-flip-key":r,children:(0,J.jsx)(ms,{base:o,index:n,row:e,template:p,heading:y(n),reorderable:t.reorderable??!1,isFirst:n===0,isLast:n===s.length-1,removable:!g,rowActions:t.rowActions,onField:c,onRemove:l,onMove:u,onDuplicate:d})},r)}),!h&&(0,J.jsxs)(`button`,{type:`button`,"data-test":`repeater-${n}-add`,className:`inline-flex items-center gap-1.5 self-start rounded-lt-sm border border-lt-border px-3 py-1.5 text-sm hover:bg-lt-accent [&_svg]:size-lt-icon-sm`,onClick:()=>f({}),children:[(0,J.jsx)(R,{name:`plus`}),t.addLabel??`Add`]})]})})},ql=250;function Jl({contentClassName:e,creatable:t=!1,emptyLabel:n,loading:r=!1,multiple:i=!1,onCommit:a,onCreate:o,onSearch:s,onSelect:c,open:l,onOpenChange:u,options:d,renderOption:f,searchLabel:p,searchPlaceholder:m,selected:h,showSearch:g=!0,testId:_,trigger:v,triggerClassName:y,triggerProps:b}){let{t:x}=w(`lattice`),[S,C]=(0,K.useState)(``);function T(e){let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of t){let t=d.find(t=>t.label.toLowerCase()===e.toLowerCase());t?(a??c)(t.value):o?.(e)}i?C(``):k()}let E=d.some(e=>e.label.toLowerCase()===S.trim().toLowerCase()),D=Ca(e=>s?.(e),ql);(0,K.useEffect)(()=>{if(!(!s||!l))return D(S),()=>D.cancel()},[S,s,l,D]);let O=s?d:d.filter(e=>e.label.toLowerCase().includes(S.toLowerCase()));function k(){C(``),u(!1)}function A(e){c(e),i||k()}return(0,J.jsxs)(Te,{open:l,onOpenChange:e=>e?u(!0):k(),children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:y,...b,children:v})}),(0,J.jsxs)(B,{align:`start`,className:P(`w-[var(--radix-popover-trigger-width)] overflow-hidden p-0`,e),children:[g&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-lt-border px-3 py-2`,children:[(0,J.jsx)(`input`,{"aria-label":p??x(`form.search-options`,`Search options`),"data-slot":`combobox-search`,"data-test":_?`${_}-search`:void 0,className:`w-full bg-transparent text-sm outline-none placeholder:text-lt-muted-fg`,onChange:e=>{let n=e.target.value;if(t&&n.includes(`,`)){T(n);return}C(n)},onKeyDown:e=>{t&&e.key===`Enter`&&S.trim()!==``&&(e.preventDefault(),T(S))},placeholder:m,value:S}),r&&(0,J.jsx)(R,{name:`loader-2`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0 animate-spin text-lt-muted-fg`})]}),(0,J.jsxs)(`div`,{className:`max-h-60 overflow-y-auto p-1`,role:`listbox`,children:[t&&S.trim()!==``&&!E&&(0,J.jsxs)(`button`,{className:`flex w-full items-center gap-2 rounded-lt-sm px-3 py-1.5 text-left text-sm transition-colors hover:bg-lt-accent hover:text-lt-accent-fg`,"data-test":_?`${_}-create`:void 0,onClick:()=>T(S),type:`button`,children:[(0,J.jsx)(R,{name:`plus`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`}),x(`form.create-option`,`Create "{{label}}"`,{label:S.trim()})]}),O.length===0&&!(t&&S.trim()!==``&&!E)?(0,J.jsx)(`p`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:n}):O.map(e=>{let t=h.includes(e.value);return(0,J.jsxs)(`button`,{"aria-label":f?e.label:void 0,"aria-selected":t,className:P(`flex w-full items-center justify-between gap-2 rounded-lt-sm px-3 py-1.5 text-left text-sm transition-colors hover:bg-lt-accent hover:text-lt-accent-fg`,t&&`bg-lt-accent/60`),"data-slot":`combobox-option`,"data-test":_?`${_}-option-${e.value}`:void 0,"data-value":e.value,onClick:()=>A(e.value),role:`option`,type:`button`,children:[f?(0,J.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:f(e)}):e.label,t&&(0,J.jsx)(R,{name:`check`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`})]},e.value)})]})]})]})}function Yl(e,t){let n=e??t;return Array.isArray(n)?n.map(String):n==null||n===``?[]:[String(n)]}var Xl=({node:e})=>{let{t}=w(`lattice`),n=e.props,{action:r,componentRef:i,errors:a,fieldIdPrefix:o,searchOptions:s}=H(),{hidden:c,required:l,readOnly:u,disabled:d}=Ke(e),{change:f,blur:p}=ke(),m=la(e),h=n.name,g=st(),_=dc(g?g.scopedName(h):h,o),v=g?g.errorKey(h):h,y=v,b=n.placeholder||`Select…`,S=n.multiple,C=n.searchable,T=n.creatable,E=(0,K.useMemo)(()=>m.props.options??[],[m.props]),D=m.props.optionSchema,O=lt(h),k=Me(),A=(0,K.useRef)(k);A.current=k;let j=g?g.getValue(h):O,M=(0,K.useMemo)(()=>Yl(j,n.value),[j,n.value]),N=(0,K.useRef)(M);N.current=M;let[F,I]=(0,K.useState)(!1),[L,ee]=(0,K.useState)(null),[te,ne]=(0,K.useState)(!1),re=(0,K.useRef)(null),ie=(0,K.useMemo)(()=>{let e=new Map;for(let t of[...E,...L??[]])e.set(t.value,t);return e},[E,L]),z=e=>ie.get(e)?.label??e,ae=e=>Ct(ie.get(e)?.data?.color),oe=u||d,se=(0,K.useCallback)(e=>{if(re.current?.abort(),e.trim()===``){ee(null),ne(!1);return}let t=new AbortController;if(re.current=t,ne(!0),s){s(y,e,A.current,t.signal).then(e=>{ee(e),ne(!1)}).catch(()=>{});return}ua(r,i,{...A.current,_sub:`search`,_target:y,_q:e},t.signal).then(e=>{ee(e?.options??[]),ne(!1)}).catch(()=>{})},[r,i,y,s]);function ce(e){f(h,S?e:e[0]??``)}function le(e){if(S){let t=N.current.includes(e)?N.current.filter(t=>t!==e):[...N.current,e];N.current=t,ce(t);return}N.current=[e],ce([e])}function ue(e){ce(M.filter(t=>t!==e))}function de(e){if(!S){N.current=[e],ce([e]);return}if(!N.current.includes(e)){let t=[...N.current,e];N.current=t,ce(t)}}if(c)return null;let B=C?L??E:E,fe=D?.length?e=>(0,J.jsx)(Y,{nodes:x(D,{...e.data,label:e.label,value:e.value})}):void 0;return(0,J.jsxs)(ze,{error:a[v],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:_,required:l,children:[S?M.map(e=>(0,J.jsx)(`input`,{name:`${_}[]`,type:`hidden`,value:e},e)):(0,J.jsx)(`input`,{name:_,type:`hidden`,value:M[0]??``}),(0,J.jsxs)(`div`,{children:[S&&M.length>0&&(0,J.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1`,children:M.map(e=>{let n=ae(e);return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-lt-sm bg-lt-muted px-2 py-0.5 text-xs`,children:[n&&(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full`,style:{background:bt(n)}}),z(e),!oe&&(0,J.jsx)(`button`,{"aria-label":t(`form.remove-option`,`Remove {{label}}`,{label:z(e)}),"data-test":`select-${h}-remove-${e}`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-xs`,onClick:()=>ue(e),type:`button`,children:(0,J.jsx)(R,{name:`x`})})]},e)})}),(0,J.jsx)(Jl,{creatable:T,emptyLabel:n.emptyLabel??void 0,loading:te,multiple:S,onCommit:de,onCreate:de,onSearch:C?se:void 0,onSelect:le,open:F&&!oe,onOpenChange:e=>{I(e),e||p(h)},options:B,renderOption:fe,searchPlaceholder:n.searchPlaceholder??void 0,showSearch:!!(C||T),selected:M,testId:`select-${h}`,trigger:(0,J.jsxs)(J.Fragment,{children:[!S&&M.length>0?(0,J.jsx)(`span`,{children:z(M[0])}):(0,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:b}),(0,J.jsx)(R,{name:`chevrons-up-down`,className:`size-lt-icon-md shrink-0 text-lt-muted-fg`})]}),triggerClassName:P(_t(),`flex items-center justify-between gap-2 text-left`,oe&&`cursor-not-allowed opacity-60`),triggerProps:{"aria-haspopup":`listbox`,autoFocus:n.autoFocus??void 0,"data-test":`select-${h}`,disabled:oe,id:_,tabIndex:n.tabIndex??void 0}})]})]})};function Zl({className:e,...t}){return(0,J.jsx)(`textarea`,{"data-slot":`textarea`,className:P(`border-lt-input placeholder:text-lt-muted-fg flex field-sizing-content min-h-16 w-full rounded-lt-sm border bg-transparent px-3 py-2 text-base shadow-lt-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg`,ht,`aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger`,e),...t})}var Ql=({node:e})=>{let t=e.props;return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,J.jsx)(Zl,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a,id:e,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,rows:t.rows??void 0,tabIndex:t.tabIndex??void 0,value:r})})},$l=({node:e})=>{let t=e.props;return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,J.jsx)(gl,{prefix:t.prefix,suffix:t.suffix,end:t.copyable?(0,J.jsx)(xo,{className:`h-lt-control-md gap-1.5 rounded-l-none rounded-r-lt-sm border-l-0 border-lt-input px-3 group-has-[:focus-visible]:border-lt-ring`,label:t.label??e,testId:`${n}-copy`,value:r}):null,children:s=>(0,J.jsx)(dt,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:s,"data-test":n,disabled:a,id:e,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,tabIndex:t.tabIndex??void 0,type:t.type??`text`,value:r})})})},eu=({node:e})=>{let t=e.props,n=ft(t.step),r=t.label??t.name;return(0,J.jsx)(Zc,{node:e,label:t.label??``,children:({name:e,testId:i,value:a,readOnly:o,disabled:s,commit:c,blur:l})=>(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(dt,{"aria-label":r,autoFocus:t.autoFocus??!1,"data-test":i,disabled:s,id:e,name:e,onBlur:()=>{let e=gt(a);e&&c(mt(e,n)),l()},onChange:e=>c(e.target.value),readOnly:o,tabIndex:t.tabIndex??void 0,type:`text`,value:a}),(0,J.jsxs)(Te,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(G,{"aria-label":`Open ${r} time picker`,disabled:s||o,size:`icon`,type:`button`,variant:`secondary`,children:(0,J.jsx)(R,{name:`clock`,className:`size-lt-icon-md`,"aria-hidden":`true`})})}),(0,J.jsx)(B,{className:`p-2`,children:(0,J.jsx)(vt,{value:gt(a),onChange:e=>c(mt(e,n)),step:t.step,min:t.min,max:t.max,disabled:s,readOnly:o,testId:`${i}-picker`})})]})]})})},tu=({node:e})=>{let{hidden:t,required:n,readOnly:r,disabled:i}=Ke(e),a=e.props,o=a.name,s=st(),{errors:c,fieldIdPrefix:l}=H(),u=dc(s?s.scopedName(o):o,l),d=s?s.errorKey(o):o,f=lt(o),p=s?s.getValue(o):f,m=Qe(a.value),h=p===void 0?m:Qe(p),g=r||i,{commit:_}=ke();return fc(o,m),t?null:(0,J.jsxs)(ze,{error:c[d],helperText:a.helperText??void 0,tooltip:a.tooltip??void 0,label:a.label??``,name:u,required:n,children:[(0,J.jsx)(`input`,{disabled:g,name:u,type:`hidden`,value:h?`1`:`0`}),(0,J.jsx)(`button`,{"aria-checked":h,"aria-label":a.label??o,autoFocus:a.autoFocus??!1,className:P(`inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-lt-muted p-0.5 shadow-lt-xs transition-colors outline-none focus-visible:border-lt-ring focus-visible:ring-[length:var(--lt-ring-width)] focus-visible:ring-lt-ring/50 disabled:cursor-not-allowed disabled:bg-lt-disabled data-[state=checked]:bg-lt-primary disabled:data-[state=checked]:bg-lt-disabled`),"data-state":h?`checked`:`unchecked`,"data-test":k(o),disabled:g,id:u,name:u,onClick:()=>_(o,!h),role:`switch`,tabIndex:a.tabIndex??void 0,type:`button`,children:(0,J.jsx)(`span`,{className:`size-5 rounded-full bg-lt-bg shadow-lt-sm transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`,"data-state":h?`checked`:`unchecked`})})]})};function nu(e){let t=[],n=e=>{let r=ut(e).name;if(r&&t.push(r),!(r&&xe.has(e.type)))for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function ru(e){let t=[],n=e=>{let r=ut(e).name;if(r&&t.push(r,`${r}.*`),r&&xe.has(e.type)){for(let n of nu(e))t.push(`${r}.*.${n}`);return}for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function iu(e,t){let n=Object.keys(t).filter(e=>!!t[e]),r=new Set;return e.forEach((e,t)=>{n.some(t=>e.some(e=>xa(t,e)))&&r.add(t)}),r}function au(e,t){let n=iu(e,t);return n.size>0?Math.min(...n):null}var ou=(0,K.createContext)({activeName:``});function su(e){let t=(e.schema??[]).filter(e=>e.type===`wizard-step`);return{items:t.map(e=>e.props),nodes:t}}var cu=({children:e,node:t})=>{let{t:n}=w(`lattice`),{errors:r,processing:i,touch:a,validateFields:o,validating:s}=H(),{items:c,nodes:l}=(0,K.useMemo)(()=>su(t),[t]),u=(0,K.useMemo)(()=>l.map(e=>nu(e)),[l]),d=t.props.orientation===`vertical`,[f,p]=(0,K.useState)(0),[m,h]=(0,K.useState)(()=>new Set([0])),[g,_]=(0,K.useState)(()=>new Set),v=(0,K.useMemo)(()=>iu(u,r),[u,r]),y=f===c.length-1,b=e=>{p(e),h(t=>new Set(t).add(e))},x=()=>{_(e=>new Set(e).add(f)),y||b(f+1)},S=()=>{let e=l[f],t=e?ru(e):[];if(t.length===0){x();return}a(t),o(t,{onSuccess:x})},C=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(C.current&&!i){let e=au(u,r);e!==null&&e!==f&&b(e)}C.current=i},[i,r,u,f]);let T=(0,K.useMemo)(()=>({activeName:c[f]?.name??``}),[c,f]);return(0,J.jsx)(ou.Provider,{value:T,children:(0,J.jsxs)(`div`,{className:P(`gap-6`,d?`flex`:`grid`),"data-slot":`wizard`,children:[(0,J.jsx)(`ol`,{"aria-label":n(`form.wizard.steps`,`Steps`),className:P(`gap-1`,d?`flex w-56 shrink-0 flex-col`:`flex flex-wrap`),children:c.map((e,t)=>{let n=t===f,r=g.has(t),i=v.has(t);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{"aria-current":n?`step`:void 0,className:P(`flex w-full items-center gap-2 rounded-lt px-3 py-2 text-left text-sm`,n?`bg-lt-muted font-medium text-lt-fg`:`text-lt-muted-fg`,!m.has(t)&&`cursor-not-allowed opacity-60`),"data-error":i||void 0,"data-test":`wizard-rail-${e.name}`,disabled:!m.has(t),id:`wizard-step-${e.name}-trigger`,onClick:()=>b(t),type:`button`,children:[(0,J.jsx)(`span`,{className:P(`flex size-5 shrink-0 items-center justify-center rounded-full border text-xs`,i?`border-lt-danger text-lt-danger`:r?`border-lt-primary bg-lt-primary text-lt-primary-fg`:`border-lt-border`),children:r&&!i?(0,J.jsx)(R,{className:`size-lt-icon-sm`,name:`check`}):t+1}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block truncate`,children:e.label}),d&&e.description&&(0,J.jsx)(`span`,{className:`block truncate text-xs text-lt-muted-fg`,children:e.description})]})]})},e.name)})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-6`,children:[e,(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(G,{"data-test":`wizard-back`,disabled:f===0||i,onClick:()=>b(f-1),type:`button`,emphasis:`outline`,children:n(`form.wizard.back`,`Back`)}),y?(0,J.jsxs)(G,{"data-test":`wizard-finish`,disabled:i,type:`submit`,children:[i&&(0,J.jsx)(ra,{}),n(`form.wizard.finish`,`Finish`)]}):(0,J.jsxs)(G,{"data-test":`wizard-next`,disabled:i||s,onClick:S,type:`button`,children:[s&&(0,J.jsx)(ra,{}),n(`form.wizard.next`,`Next`)]})]})]})]})})},lu=({children:e,node:t})=>{let{activeName:n}=(0,K.useContext)(ou),r=t.props.name,i=n===r,[a,o]=(0,K.useState)(i);return(0,K.useEffect)(()=>{i&&o(!0)},[i]),(0,J.jsx)(`section`,{"aria-labelledby":`wizard-step-${r}-trigger`,className:P(`space-y-8`,!i&&`hidden`),hidden:!i,id:`wizard-step-${r}-panel`,children:a?e:null})},uu=(0,K.lazy)(()=>$t(()=>import(`./chunks/rich-editor-field-BtbU5XFS.js`),__vite__mapDeps([17,1,2,5,4,6,15,3,11,18,13]),import.meta.url)),du=hn({components:{form:q(fl),"field.builder":q(Gs),"field.checkbox":q(pc),"field.choice":q(hc),"field.color-picker":q(Qc),"field.date-input":q(tl),"field.date-time-input":q(nl),"field.file-upload":q(ol),"field.hidden-input":q(ml),"field.number-input":q(_l),"field.otp":q(Hl),"field.password-input":q(Wl),"field.repeater":q(Kl),"field.rich-editor":q(({children:e,node:t})=>(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(uu,{node:t,children:e})})),"field.select":q(Xl),"field.textarea":q(Ql),"field.text-input":q($l),"field.time-input":q(eu),"field.toggle":q(tu),wizard:q(cu),"wizard-step":q(lu)},name:`lattice/form`});function fu(e,t=1){return Ht(`${e}?page=${t}`)}function pu(e,t){return Ht(`${e}/${t}/read`,{method:`PATCH`})}function mu(e){return Ht(`${e}/read-all`,{method:`POST`})}function hu(e,t){return Ht(`${e}/${t}`,{method:`DELETE`})}function gu(e){return Ht(e,{method:`DELETE`})}function _u(e,t){return e.some(e=>e.id===t.id)?e:[t,...e]}function vu(e,t){return e.map(e=>e.id===t?{...e,isRead:!0}:e)}function yu(e,t){return e.filter(e=>e.id!==t)}function bu({endpoint:e,pollingInterval:t}){let[n,r]=(0,K.useState)([]),[i,a]=(0,K.useState)(0),[o,s]=(0,K.useState)(`loading`),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(!1),f=(0,K.useRef)(1),p=(0,K.useRef)(c);p.current=c;let m=(0,K.useRef)(!1),h=(0,K.useCallback)(async()=>{try{let t=await fu(e,1);f.current=1,r(t.notifications),a(t.unreadCount),l(t.hasMore),s(`idle`)}catch{s(`error`)}},[e]);return(0,K.useEffect)(()=>{h()},[h]),(0,K.useEffect)(()=>{if(!t||t<=0)return;let e=setInterval(()=>void h(),t*1e3);return()=>clearInterval(e)},[h,t]),{notifications:n,unreadCount:i,status:o,hasMore:c,open:u,setOpen:d,loadMore:(0,K.useCallback)(()=>{if(m.current||!p.current)return;m.current=!0;let t=f.current+1;fu(e,t).then(e=>{f.current=t,r(t=>[...t,...e.notifications]),l(e.hasMore)}).catch(()=>void h()).finally(()=>{m.current=!1})},[e,h]),markRead:(0,K.useCallback)(t=>{r(e=>vu(e,t)),a(e=>Math.max(0,e-1)),pu(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),markAllRead:(0,K.useCallback)(()=>{r(e=>e.map(e=>({...e,isRead:!0}))),a(0),mu(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),dismiss:(0,K.useCallback)(t=>{r(e=>yu(e,t)),hu(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),clearAll:(0,K.useCallback)(()=>{r([]),a(0),gu(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),receive:(0,K.useCallback)(e=>{r(t=>{let n=_u(t,e);return n!==t&&a(e=>e+1),n})},[])}}function xu(){let{t:e}=w(`lattice`);return(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-lt-muted-fg`,children:[(0,J.jsx)(R,{name:`bell`,className:`size-lt-icon-lg`}),(0,J.jsx)(`p`,{className:`text-sm`,children:e(`notifications.empty`,`No notifications yet`)})]})}var Su={primary:`text-lt-primary`,secondary:`text-lt-muted-fg`,success:`text-lt-success`,info:`text-lt-info`,warning:`text-lt-warning`,danger:`text-lt-danger`};function Cu({notification:e,onMarkRead:t,onDismiss:n}){let{t:r}=w(`lattice`),i=ie(e.title,r),a=ie(e.body,r),o=(0,J.jsxs)(J.Fragment,{children:[i?(0,J.jsx)(`p`,{className:`truncate text-sm font-medium text-lt-fg`,children:i}):null,a?(0,J.jsx)(`p`,{className:`text-sm text-lt-muted-fg`,children:a}):null]});return(0,J.jsxs)(`li`,{className:P(`flex gap-3 px-3 py-3`,!e.isRead&&`bg-lt-muted/40`),"data-test":`notification`,children:[e.icon?(0,J.jsx)(N,{icon:e.icon,className:P(`mt-0.5 size-lt-icon-md`,e.variant?Su[e.variant]:void 0)}):null,(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e.href?(0,J.jsx)(b,{href:e.href,className:`block`,"data-test":`notification-link`,onClick:()=>t(e.id),children:o}):o,e.actions.length>0?(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.actions.map((e,t)=>(0,J.jsx)(En,{node:e},e.key??e.id??`action-${t}`))}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[e.isRead?null:(0,J.jsx)(`button`,{type:`button`,className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:()=>t(e.id),children:r(`notifications.mark-read`,`Mark read`)}),(0,J.jsx)(`button`,{type:`button`,"aria-label":r(`notifications.dismiss`,`Dismiss`),className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:()=>n(e.id),children:r(`notifications.dismiss`,`Dismiss`)})]})]})}function wu({notifications:e,status:t,hasMore:n,onMarkRead:r,onDismiss:i,onLoadMore:a}){let{t:o}=w(`lattice`);return t===`loading`&&e.length===0?(0,J.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,J.jsx)(oa,{className:`h-12 w-full`}),(0,J.jsx)(oa,{className:`h-12 w-full`}),(0,J.jsx)(oa,{className:`h-12 w-full`})]}):e.length===0?(0,J.jsx)(xu,{}):(0,J.jsxs)(`div`,{className:`max-h-96 overflow-y-auto`,children:[(0,J.jsx)(`ul`,{className:`divide-y divide-lt-border`,children:e.map(e=>(0,J.jsx)(Cu,{notification:e,onMarkRead:r,onDismiss:i},e.id))}),n?(0,J.jsx)(`button`,{type:`button`,className:`w-full py-2 text-sm text-lt-muted-fg hover:text-lt-fg`,onClick:a,children:o(`notifications.load-more`,`Load more`)}):null]})}var Tu=(0,K.lazy)(()=>$t(()=>import(`./chunks/notifications-echo-uU87iJAV.js`).then(e=>({default:e.NotificationsEcho})),__vite__mapDeps([19,8,1]),import.meta.url)),Eu=class extends K.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){console.warn(`[lattice] The notifications bell declares a realtime channel but Echo is unavailable. Install @laravel/echo-react and call configureEcho().`)}render(){return this.state.failed?null:this.props.children}},Du=hn({name:`lattice/notifications`,components:{notifications:q(({node:e})=>{let{t}=w(`lattice`),n=bu({endpoint:e.props.endpoint,pollingInterval:e.props.pollingInterval}),r=t(`notifications.label`,`Notifications`),i=(0,J.jsxs)(`span`,{className:`relative inline-flex items-center justify-center rounded-lt-sm p-2 hover:bg-lt-muted`,children:[(0,J.jsx)(R,{name:`bell`,className:`size-lt-icon-md`}),n.unreadCount>0?(0,J.jsx)(`span`,{"data-test":`notifications-badge`,className:`absolute -right-0.5 -top-0.5 inline-flex min-w-4 items-center justify-center rounded-lt-full bg-lt-danger px-1 py-0 text-[10px] font-medium text-lt-danger-fg`,children:n.unreadCount}):null]}),a=(0,J.jsxs)(`div`,{className:`w-80`,"data-test":`notifications-panel`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-lt-border px-3 py-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:t(`notifications.heading`,`Notifications`)}),n.unreadCount>0?(0,J.jsx)(`button`,{type:`button`,className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:n.markAllRead,children:t(`notifications.mark-all-read`,`Mark all read`)}):null]}),(0,J.jsx)(wu,{notifications:n.notifications,status:n.status,hasMore:n.hasMore,onMarkRead:n.markRead,onDismiss:n.dismiss,onLoadMore:n.loadMore})]});return(0,J.jsxs)(J.Fragment,{children:[e.props.channel?(0,J.jsx)(Eu,{children:(0,J.jsx)(K.Suspense,{fallback:null,children:(0,J.jsx)(Tu,{channel:e.props.channel,onReceive:e=>n.receive(e)})})}):null,e.props.slideOut?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,onClick:()=>n.setOpen(!0),children:i}),(0,J.jsx)(Zi,{open:n.open,onOpenChange:n.setOpen,children:(0,J.jsxs)(ta,{"aria-describedby":void 0,className:`p-0`,placement:`end`,width:`sm`,children:[(0,J.jsx)($i,{className:`sr-only`,children:r}),a]})})]}):(0,J.jsxs)(Te,{open:n.open,onOpenChange:n.setOpen,children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,children:i})}),(0,J.jsx)(B,{align:`end`,className:`p-0`,children:a})]})]})})}});function Ou(e){return e==null?``:String(e)}function ku({props:e}){let{t}=w(`lattice`),[n,r]=(0,K.useState)([]),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{if(!e.remote||!e.dataEndpoint){r([]),s(!1);return}let t=!1;return a(null),s(!0),Yt(e.dataEndpoint,{remote:e.remote}).then(e=>{t||r(e.data??[])}).catch(e=>{t||a(e instanceof Error?e.message:String(e))}).finally(()=>{t||s(!1)}),()=>{t=!0}},[e.dataEndpoint,e.remote]),i?(0,J.jsx)(`div`,{className:`rounded-lt border border-lt-danger/40 p-3 text-sm`,children:i}):o||!e.remote?(0,J.jsx)(`div`,{className:`rounded-lt border border-lt-border p-3 text-sm`,children:t(`common.remote.data-list.loading`,`Loading...`)}):(0,J.jsxs)(`div`,{className:`rounded-lt border border-lt-border bg-lt-bg`,children:[(0,J.jsx)(`div`,{className:`border-b border-lt-border px-3 py-2 text-sm font-medium`,children:t(`common.remote.data-list.title`,`Remote data`)}),(0,J.jsxs)(`div`,{className:`divide-y divide-lt-border`,children:[n.map((t,n)=>(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(Y,{nodes:x(e.schema,t)})},Ou(t.id)||n)),n.length===0?(0,J.jsx)(`div`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:e.emptyLabel??t(`common.remote.data-list.empty`,`No data`)}):null]})]})}var Au=hn({components:{"remote.data-list":q(({node:e})=>(0,J.jsx)(ku,{props:{...e.props,schema:e.schema}}))},name:`lattice/remote`});function ju({columns:e,storageKey:t}){let n=(0,K.useMemo)(()=>e.filter(e=>e.props.toggleable),[e]),r=(0,K.useMemo)(()=>n.map(e=>e.key),[n]),[i,a]=ci(t??``,{},{enabled:!!t,parse:e=>Nu(e,r),serialize:e=>Pu(e,r)}),o=(0,K.useCallback)(e=>e.props.toggleable?i[e.key]??!e.props.hiddenByDefault:!0,[i]),s=(0,K.useMemo)(()=>e.filter(e=>o(e)),[e,o]),c=(0,K.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[a]),l=(0,K.useCallback)(()=>a({}),[a]),u=n.length>0;return{hasHidden:n.some(e=>!o(e)),hasToggleableColumns:u,isVisible:o,resetVisibility:l,setColumnVisible:c,toggleableColumns:n,visibleColumns:s}}function Mu(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))n.has(t)&&typeof i==`boolean`&&(r[t]=i);return r}function Nu(e,t){let n=JSON.parse(e);if(!Fu(n))throw Error(`unexpected stored column visibility shape`);return Mu(n.overrides,t)}function Pu(e,t){let n=Mu(e,t);return Object.keys(n).length===0?null:JSON.stringify({columns:t,overrides:n})}function Fu(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.columns)&&t.columns.every(e=>typeof e==`string`)&&typeof t.overrides==`object`&&t.overrides!==null&&!Array.isArray(t.overrides)}function Iu(){let[e,t]=(0,K.useState)(()=>new Set);return{isExpanded:(0,K.useCallback)(t=>e.has(t),[e]),toggle:(0,K.useCallback)(e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[])}}var Lu={start:`text-start`,center:`text-center`,end:`text-end`},Ru={start:`justify-start`,center:`justify-center`,end:`justify-end`},zu={start:`justify-items-start`,center:`justify-items-center`,end:`justify-items-end`},Bu=e=>Lu[e],Vu=e=>Ru[e],Hu=e=>zu[e];function Uu(e){return(e??[]).flatMap(e=>{if(e.type===`action.group`)return[];let t=e.props;return t.endpoint?[{id:e.id??``,label:ka(e),method:t.method??`post`,endpoint:t.endpoint,ref:t.ref??``,variant:t.variant,emphasis:t.emphasis,confirmation:t.confirmation,form:t.form,modalSide:t.modalSide,modalWidth:t.modalWidth}]:[]})}function Wu(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.field==`string`&&typeof e.operator==`string`&&typeof e.value==`string`):[]}function Gu(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`key`in e&&`props`in e&&typeof e.key==`string`&&typeof e.props==`object`&&e.props!==null&&typeof e.props.label==`string`):[]}function Ku(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)):[]}var qu={mode:`none`,currentPage:null,lastPage:null,perPage:null,total:null,from:null,to:null,hasMore:!1,nextPage:null};function Ju(e){return typeof e!=`object`||!e||Array.isArray(e)?qu:e}function Yu(e){if(typeof e!=`object`||!e||Array.isArray(e))return{filters:[],sorts:[],page:1,perPage:25,tableFilters:{},tableFilterIndicators:[],search:``,mode:null};let t=e;return{filters:Wu(t.filters),sorts:Array.isArray(t.sorts)?t.sorts:[],page:typeof t.page==`number`?t.page:1,perPage:typeof t.perPage==`number`?t.perPage:25,tableFilters:$u(t.tableFilters),tableFilterIndicators:ed(t.tableFilterIndicators),search:typeof t.search==`string`?t.search:``,mode:Zu(t.mode)}}var Xu=new Set([`none`,`simple`,`table`,`infinite`]);function Zu(e){return typeof e==`string`&&Xu.has(e)?e:null}function Qu(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`||e===`infinite`):[]}function $u(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`object`&&e[1]!==null&&!Array.isArray(e[1])))}function ed(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.filter==`string`&&typeof e.label==`string`&&typeof e.value==`string`):[]}function td(e,t){let n=e.id??e.uuid??e.key??t;return String(n)}function nd(e){return Array.isArray(e.actions)?e.actions:[]}function rd(e){let t=e.detail;return typeof t==`object`&&t&&!Array.isArray(t)?t:null}function id(e){return e==null||e===``}function ad(e){return id(e)?!0:Array.isArray(e)?e.every(ad):typeof e==`object`&&e?Object.values(e).every(ad):!1}function od(e){return!ad(e)}function sd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cd(e){return sd(e)?e:{}}function ld(e,t){return e.sorts.find(e=>e.key===t.key)}function ud(e){if(e?.direction===`asc`)return`ascending`;if(e?.direction===`desc`)return`descending`}function dd(e,t){let n=new URL(e,window.location.origin);return t.filters.length>0&&n.searchParams.set(`filter`,vd(t)),t.sorts.length>0&&n.searchParams.set(`sort`,yd(t)),t.search!==``&&n.searchParams.set(`q`,t.search),fd(n,t.tableFilters),n.searchParams.set(`page`,String(t.page)),n.searchParams.set(`per_page`,String(t.perPage)),t.mode!=null&&n.searchParams.set(`mode`,t.mode),`${n.pathname}${n.search}`}function fd(e,t){for(let[n,r]of Object.entries(pd(t)))gd(e,`tf[${n}]`,r)}function pd(e){let t={};for(let[n,r]of Object.entries(e)){let e=md(r);e!==void 0&&(t[n]=e)}return t}function md(e){if(id(e)||Array.isArray(e)||typeof e!=`object`)return;let t=Object.entries(e).map(([e,t])=>[e,hd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}function hd(e){if(!id(e)){if(Array.isArray(e)){let t=e.map(hd).filter(e=>e!==void 0);return t.length>0?t:void 0}if(typeof e==`object`){if(e===null)return;let t=Object.entries(e).map(([e,t])=>[e,hd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}return String(e)}}function gd(e,t,n){if(Array.isArray(n)){for(let r of n)gd(e,`${t}[]`,r);return}if(typeof n==`object`&&n){for(let[r,i]of Object.entries(n))gd(e,`${t}[${r}]`,i);return}e.searchParams.append(t,String(n))}function _d(e){let t={};e.filters.length>0&&(t.filter=vd(e)),e.sorts.length>0&&(t.sort=yd(e));let n=pd(e.tableFilters);return Object.keys(n).length>0&&(t.tf=n),e.search!==``&&(t.q=e.search),t}function vd(e){return e.filters.map(e=>`${e.field}:${e.operator}:${encodeURIComponent(e.value)}`).join(`,`)}function yd(e){return e.sorts.map(e=>e.direction===`desc`?`-${e.key}`:e.key).join(`,`)}var bd={contains:`contains`,starts_with:`starts with`,ends_with:`ends with`,eq:`equals`,neq:`not equals`,gt:`>`,gte:`≥`,lt:`<`,lte:`≤`,in:`in`,not_in:`not in`,before:`before`,after:`after`,empty:`is empty`,filled:`is not empty`},xd=new Set([`empty`,`filled`]);function Sd(e){return C(`lattice`,`table.operators.${e}`,bd[e]??e)}function Cd(e){return e===`desc`?`descending`:`ascending`}function wd(e,t){if(!t.props.sortable)return e;let n=e.find(e=>e.key===t.key),r=e.filter(e=>e.key!==t.key);return n?n.direction===`asc`?[...r,{key:t.key,direction:`desc`}]:r:[...e,{key:t.key,direction:`asc`}]}function Td(e,t){if(t<=5)return Array.from({length:t},(e,t)=>t+1);let n=Math.max(1,Math.min(e-2,t-4));return Array.from({length:5},(e,t)=>n+t)}function Ed(e){return e.map(e=>({key:e.key,label:e.props.label,width:Dd(e)}))}function Dd(e){return e.props.width??`md`}function Od(e,t,n=!1){return{leadingTracks:[...n?[`2.5rem`]:[],...t?[`3rem`]:[]],trailingTracks:e?[`10rem`]:[]}}function kd(e){let t=(0,K.useMemo)(()=>Gu(e.props?.columns),[e.props?.columns]),n=typeof e.props?.endpoint==`string`?e.props.endpoint:null,r=typeof e.props?.ref==`string`?e.props.ref:``,a=e.props?.lazy===!0,o=(0,K.useMemo)(()=>Yu(e.props?.query),[e.props?.query]),s=(0,K.useMemo)(()=>Ku(e.props?.data),[e.props?.data]),c=(0,K.useMemo)(()=>Ju(e.props?.pagination),[e.props?.pagination]),[l,u]=(0,K.useState)(s),[d,f]=(0,K.useState)(c),[p,m]=(0,K.useState)(o),[h,g]=(0,K.useState)(a),[_,v]=(0,K.useState)(!a),y=(0,K.useRef)(null),b=d.currentPage??p.page,x=(d.mode??`table`)===`infinite`,S=(0,K.useCallback)(async(e,t=!1)=>{if(n){g(!0);try{let i=await Ht(dd(n,e),{ref:r}),a=Yu(i.query),o=Ku(i.data);u(e=>t?[...e,...o]:o),f(Ju(i.pagination)),m(a),v(!0)}finally{g(!1)}}},[n,r]);function C(e){S({...p,page:1,sorts:wd(p.sorts,e)})}function w(e){S({...p,page:1,sorts:p.sorts.filter(t=>t.key!==e.key)})}function T(e){let t={...p,filters:e,page:1};m(t),S(t)}function E(e){T([...p.filters,e])}function D(e,t){T(p.filters.map((n,r)=>r===e?t:n))}function O(e){T(p.filters.filter((t,n)=>n!==e))}function k(e,t){T([...p.filters.filter(t=>t.field!==e),...t])}function A(e,t){let n={...p.tableFilters};ad(t)||!sd(t)?delete n[e]:n[e]=t;let r={...p,tableFilters:n,tableFilterIndicators:p.tableFilterIndicators.filter(t=>t.filter!==e),page:1};m(r),S(r)}function j(){let e={...p,filters:[],tableFilters:{},tableFilterIndicators:[],search:``,page:1};m(e),S(e)}function M(e){let t={...p,search:e,page:1};m(t),S(t)}let N=(0,K.useCallback)(async(e,t,i)=>{if(!n)return[];let a=new URL(n,window.location.origin);a.searchParams.set(`_sub`,`search`),a.searchParams.set(`_target`,e),a.searchParams.set(`_q`,t);let o=await Vt(`${a.pathname}${a.search}`,{ref:r,signal:i,throwOnError:!1});return o.ok?(await o.json()).options??[]:[]},[n,r]);function P(e){S({...p,page:e})}function F(e){let t=c.mode??`table`,n={...p,perPage:e===`infinite`?p.perPage:e,mode:e===`infinite`?`infinite`:t===`infinite`?`table`:null,page:1};m(n),S(n)}let I=(0,K.useCallback)(()=>{h||!d.hasMore||S({...p,page:d.nextPage??b+1},!0)},[b,S,d.hasMore,d.nextPage,h,p]);return(0,K.useEffect)(()=>{u(s),f(c),m(o),g(a),v(!a)},[s,c,o,a]),(0,K.useEffect)(()=>{!a||_||S(p)},[_,a,S,p]),vn(i.reloadComponent,t=>{t.detail?.component===e.id&&S(p)}),(0,K.useEffect)(()=>{if(!x||!d.hasMore||h||!y.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&I()},{rootMargin:`240px`});return e.observe(y.current),()=>e.disconnect()},[x,I,d.hasMore,h]),{columns:t,rows:l,pagination:d,query:p,filters:p.filters,tableFilters:p.tableFilters,search:p.search,addFilter:E,updateFilter:D,removeFilter:O,replaceColumnFilters:k,setTableFilter:A,resetFilters:j,setSearch:M,searchFilterOptions:N,processing:h,hasLoaded:_,infiniteLoaderRef:y,sort:C,clearSort:w,goToPage:P,setPerPage:F,loadMore:I}}function Ad(e){let[t,n]=(0,K.useState)(()=>new Set),[r,i]=(0,K.useState)(!1),a=e.join(` `);(0,K.useEffect)(()=>{n(new Set),i(!1)},[a]);let o=(0,K.useCallback)(e=>{i(!1),n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=(0,K.useCallback)(()=>{i(!1),n(t=>t.size===e.length?new Set:new Set(e))},[e]),c=(0,K.useCallback)(()=>i(!0),[]),l=(0,K.useCallback)(()=>{i(!1),n(new Set)},[]),u=e.filter(e=>t.has(e)),d=e.length>0&&u.length===e.length;return{selectedKeys:u,allMatching:r,allVisibleSelected:d,allSelected:r||d,active:r||u.length>0,isSelected:e=>r||t.has(e),toggle:o,toggleAll:s,selectAllMatching:c,clear:l}}function jd({actions:e,selectedKeys:t,allMatching:n,total:r,query:i,canSelectAllMatching:a,onSelectAllMatching:o,onCompleted:s}){let{t:c}=w(`lattice`),[l,u]=(0,K.useState)(!1),d=y(),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(null),g=()=>n?{allMatching:!0,...i}:{selected:t};async function _(e){u(!0);let t=await aa(()=>Vt(e.endpoint,{method:e.method,ref:e.ref,body:JSON.stringify(g()),throwOnError:!1}),d);u(!1),t&&(p(null),s())}function v(e){if(e.form){h(e);return}if(e.confirmation){p(e);return}_(e)}let b=n?r??t.length:t.length;return(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-lt-border bg-lt-muted/50 p-4 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:n?c(`table.bulk.all-selected`,`All {{count}} selected`,{count:b}):c(`table.bulk.selected`,`{{count}} selected`,{count:b})}),a&&(0,J.jsx)(`button`,{type:`button`,"data-test":`bulk-select-all-matching`,className:`font-medium text-lt-primary underline underline-offset-2`,onClick:o,children:c(`table.bulk.select-all-matching`,`Select all {{total}} matching`,{total:r})}),(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>(0,J.jsxs)(G,{type:`button`,"data-test":j(`bulk-action`,e.id),variant:e.variant,emphasis:e.emphasis,disabled:l,onClick:()=>v(e),children:[l&&(0,J.jsx)(ra,{}),e.label]},e.id))}),f?.confirmation&&(0,J.jsx)(ia,{title:f.confirmation.title??f.label,description:f.confirmation.description??void 0,confirmLabel:f.confirmation.confirmLabel??f.label,cancelLabel:f.confirmation.cancelLabel??c(`common.cancel`,`Cancel`),confirmVariant:f.variant,confirmEmphasis:f.emphasis,processing:l,onConfirm:()=>void _(f),onCancel:()=>p(null)}),m?.form&&(0,J.jsx)(Oa,{cancelLabel:m.confirmation?.cancelLabel??c(`common.cancel`,`Cancel`),componentRef:m.ref,description:m.confirmation?.description??void 0,endpoint:m.endpoint,extraData:g(),formNode:m.form,method:m.method,onClose:()=>h(null),onSuccess:()=>{h(null),s()},placement:m.modalSide??`center`,submitLabel:m.confirmation?.confirmLabel??m.label,title:m.confirmation?.title??m.label,width:m.modalWidth??void 0})]})}function Md({className:e,density:t,children:n,ref:r,...i}){return(0,J.jsx)(`select`,{ref:r,"data-slot":`native-select`,className:P(_t({density:t}),`cursor-pointer`,e),...i,children:n})}function Nd(e){return e===!0||e===1||e===`1`||e===`true`}function Pd({filter:e,value:t,processing:n,bare:r=!1,onChange:i,onSearch:a}){let{t:o}=w(`lattice`),s=e.schema??[];return s.length===0?(0,J.jsx)(Ld,{filter:e,value:t,processing:n,onChange:i}):(0,J.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(Fd,{filter:e,schema:s,value:t,processing:n,bare:r,onChange:i,onSearch:a})}),od(t)&&(0,J.jsx)(nt,{size:`md`,icon:`x`,label:o(`table.filter.clear`,`Clear {{label}} filter`,{label:e.props.label??``}),disabled:n,onClick:()=>i(void 0)})]})}function Fd({filter:e,schema:t,value:n,processing:r,bare:i,onChange:a,onSearch:o}){let s=(0,K.useMemo)(()=>cd(n),[n]),c=(0,K.useMemo)(()=>({action:`#`,clearErrors:()=>{},componentId:`table-filter-${e.key}`,componentRef:``,errors:{},fieldIdPrefix:`table-filter-${e.key}`,fieldLabels:{},precognitive:!1,processing:r,searchOptions:(e,t,n,r)=>o?o(e,t,r):Promise.resolve([]),touch:()=>{},validate:()=>{},validateFields:()=>{},validating:!1}),[e.key,o,r]),l=(0,J.jsx)(`div`,{"aria-disabled":r,className:P(`grid gap-3`,r&&`pointer-events-none opacity-60`),children:(0,J.jsx)(Y,{nodes:t})});return(0,J.jsx)(fe,{value:c,children:(0,J.jsx)(we,{value:{markUserEdit:()=>{}},children:(0,J.jsx)(ca,{nodes:{},children:(0,J.jsx)(ot,{initial:s,children:(0,J.jsx)(Id,{onChange:a,children:i?(0,J.jsx)(Re,{children:l}):l})})})})})}function Id({children:e,onChange:t}){let n=Me(),r=Se(),i=(0,K.useRef)(n);i.current=n;let a=(0,K.useCallback)((e,n)=>{let a=typeof n==`function`?n(de(i.current,e)):n,o=pe(i.current,e,a);i.current=o,r(e,a),t(o)},[t,r]),o=(0,K.useMemo)(()=>({blur:()=>{},change:a,commit:a}),[a]);return(0,J.jsx)(Le,{value:o,children:e})}function Ld({filter:e,value:t,processing:n,onChange:r}){let i=Nd(cd(t).value);return(0,J.jsxs)(`label`,{className:`flex h-lt-control-md cursor-pointer items-center gap-2 text-sm`,children:[(0,J.jsx)(uc,{"aria-label":e.props.label??void 0,"data-test":`table-filter-${e.key}`,checked:i,disabled:n,onCheckedChange:e=>r(e===!0?{value:`1`}:void 0)}),(0,J.jsx)(`span`,{children:e.props.label})]})}function Rd({type:e,label:t,value:n,processing:r,withSearchIcon:i=!1,grouped:a=!1,ariaLabel:o,testId:s,onCommit:c,onClear:l}){let{t:u}=w(`lattice`),[d,f]=(0,K.useState)(n),p=o??u(`table.filter.filter-by`,`Filter {{label}}`,{label:t}),m=a?`rounded-r-none`:``;return(0,K.useEffect)(()=>{f(n)},[n]),e===`boolean`?(0,J.jsxs)(Md,{density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:n,onChange:e=>c(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:u(`table.filter.all`,`All`)}),(0,J.jsx)(`option`,{value:`true`,children:u(`table.filter.true`,`True`)}),(0,J.jsx)(`option`,{value:`false`,children:u(`table.filter.false`,`False`)})]}):e===`date`?(0,J.jsx)(dt,{type:`date`,density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:d,onChange:e=>{f(e.target.value),c(e.target.value)}}):(0,J.jsxs)(`div`,{className:`relative flex w-full min-w-0 items-center`,children:[i&&(0,J.jsx)(R,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2 size-lt-icon-md text-lt-muted-fg`}),(0,J.jsx)(dt,{type:e===`number`?`number`:`text`,density:`compact`,"aria-label":p,"data-test":s,className:P(m,i&&`pl-8`,l&&`pr-8`),disabled:r,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c(d)},onBlur:()=>{d!==n&&c(d)}}),l&&d!==``&&(0,J.jsx)(nt,{size:`xs`,icon:`x`,label:u(`table.filter.clear`,`Clear {{label}} filter`,{label:t}),"data-test":s?`${s}-clear`:void 0,className:`absolute right-1 size-6`,disabled:r,onClick:l})]})}function zd({column:e,clauses:t,processing:n,onAdd:r,onUpdate:i,onRemove:a,onReplace:o,onSearch:s}){let{t:c}=w(`lattice`),{filter:l,label:u}=e.props,d=u??e.key;if(!l)return null;if(l.control===`filter.select`)return(0,J.jsx)(Vd,{column:e,clauses:t,processing:n,onReplace:o,onSearch:s});let f=l.type??`text`,p=l.operators??[],m=l.defaultOperator??p[0]??`eq`,h=t.find(e=>e.clause.operator===m)??t[0];function g(t){if(t===``){h&&a(h.index);return}h?i(h.index,{...h.clause,value:t}):r({field:e.key,operator:m,value:t})}return(0,J.jsxs)(`div`,{className:`flex min-w-0 max-w-80 items-stretch`,children:[(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(Rd,{type:f,label:d,value:h?.clause.value??``,processing:n,withSearchIcon:f===`text`||f===`number`,grouped:!0,testId:`filter-${e.key}-value`,onCommit:g,onClear:h?()=>a(h.index):void 0})}),(0,J.jsxs)(Te,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(nt,{emphasis:`segmented`,size:`md`,icon:`filter`,label:c(`table.filter.column-filters`,`{{label}} filters`,{label:d}),"data-test":`filter-${e.key}`,disabled:n,children:t.length>0&&(0,J.jsx)(`span`,{className:`absolute -right-1.5 -top-1.5 inline-flex size-4 items-center justify-center rounded-full bg-lt-primary text-xs font-medium text-lt-primary-fg`,children:t.length})})}),(0,J.jsx)(B,{align:`start`,className:`w-80 p-4`,children:(0,J.jsx)(Gd,{column:e,clauses:t,operators:p,defaultOperator:m,processing:n,onAdd:r,onUpdate:i,onRemove:a})})]})]})}function Bd(e){return Array.isArray(e)?e.join(`,`):typeof e==`string`?e:``}function Vd({column:e,clauses:t,processing:n,onReplace:r,onSearch:i}){let{filter:a,label:o}=e.props;if(!a)return null;let s=a.multiple,c=a.defaultOperator,l=a.clauseOptions??[],u=Ud(t.map(e=>e.clause),l),d=t.find(e=>e.clause.operator===c)??t[0],f=u?u.value:s?d?.clause.value?d.clause.value.split(`,`):[]:d?.clause.value??``,p={key:e.key,type:`filter.select`,props:{label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null},schema:[{type:`field.select`,key:e.key,props:{name:`value`,label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null}}]};function m(t){let n=Bd(cd(t).value);if(n===``){r(e.key,[]);return}let i=l.find(e=>e.value===n);if(i){r(e.key,Hd(e.key,i));return}r(e.key,[{field:e.key,operator:c,value:n}])}return(0,J.jsx)(Pd,{filter:p,value:{value:f},processing:n,bare:!0,onChange:m,onSearch:i?(e,t,n)=>i(t,n):void 0})}function Hd(e,t){return t.clauses.map(t=>({field:e,operator:t.operator,value:t.value}))}function Ud(e,t){return t.find(t=>Wd(e,Hd(``,t)))}function Wd(e,t){return e.length===t.length&&t.every(t=>e.some(e=>e.operator===t.operator&&e.value===t.value))}function Gd({column:e,clauses:t,operators:n,defaultOperator:r,processing:i,onAdd:a,onUpdate:o,onRemove:s}){let{t:c}=w(`lattice`),l=e.props.filter?.type??`text`,[u,d]=(0,K.useState)(r),[f,p]=(0,K.useState)(t.length===0);return(0,J.jsxs)(`div`,{className:`grid gap-3`,children:[t.map(t=>(0,J.jsx)(Kd,{column:e,type:l,operators:n,clause:t.clause,processing:i,onOperator:e=>o(t.index,{...t.clause,operator:e}),onValue:e=>e===``?s(t.index):o(t.index,{...t.clause,value:e}),onRemove:()=>s(t.index)},t.index)),f&&(0,J.jsx)(Kd,{column:e,type:l,operators:n,clause:{field:e.key,operator:u,value:``},processing:i,onOperator:t=>{if(xd.has(t)){a({field:e.key,operator:t,value:``}),d(r),p(!1);return}d(t)},onValue:t=>{t!==``&&(a({field:e.key,operator:u,value:t}),d(r),p(!1))},onRemove:()=>p(!1)}),(0,J.jsx)(`div`,{className:`border-t border-lt-border pt-3`,children:(0,J.jsx)(G,{variant:`secondary`,icon:`plus`,"data-test":`filter-${e.key}-add`,className:`w-full`,disabled:i,onClick:()=>p(!0),children:c(`table.filter.add`,`Add filter`)})})]})}function Kd({column:e,type:t,operators:n,clause:r,processing:i,onOperator:a,onValue:o,onRemove:s}){let{t:c}=w(`lattice`),l=e.props.label??e.key,u=xd.has(r.operator);return(0,J.jsxs)(`div`,{className:`grid gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.length>1?(0,J.jsx)(Md,{density:`compact`,"aria-label":c(`table.filter.operator`,`{{label}} operator`,{label:l}),"data-test":`filter-${e.key}-operator`,className:`flex-1`,disabled:i,value:r.operator,onChange:e=>a(e.target.value),children:n.map(e=>(0,J.jsx)(`option`,{value:e,children:Sd(e)},e))}):(0,J.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:Sd(r.operator)}),(0,J.jsx)(G,{emphasis:`outline`,size:`icon`,icon:`trash-2`,"aria-label":c(`table.filter.remove`,`Remove {{label}} filter`,{label:l}),"data-test":`filter-${e.key}-remove`,disabled:i,onClick:s})]}),!u&&(0,J.jsx)(Rd,{type:t,label:l,ariaLabel:c(`table.filter.value`,`{{label}} filter value`,{label:l}),value:r.value,processing:i,onCommit:o,onClear:()=>o(``)})]})}function qd({sort:e}){return e?.direction===`asc`?(0,J.jsx)(R,{name:`arrow-up`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):e?.direction===`desc`?(0,J.jsx)(R,{name:`arrow-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):(0,J.jsx)(R,{name:`chevrons-up-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0 opacity-50`})}function Jd({column:e,processing:t,resizeHandleProps:n,sort:r,query:i}){let a=ld(i,e),{t:o}=w(`lattice`),{align:s,label:c,sortable:l}=e.props;return(0,J.jsxs)(`div`,{"aria-sort":ud(a),className:P(`relative min-w-0 px-4 py-3 pr-5 align-middle font-semibold text-lt-fg`,Bu(s)),role:`columnheader`,children:[l?(0,J.jsxs)(`button`,{type:`button`,"aria-label":o(`table.sort.column`,`Sort {{label}}`,{label:c}),className:P(`flex w-full items-center gap-1.5 font-semibold`,Vu(s)),"data-test":`sort-${e.key}`,disabled:t,onClick:()=>r(e),children:[(0,J.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate`,Bu(s)),children:c}),(0,J.jsx)(qd,{sort:a})]}):(0,J.jsx)(`span`,{className:P(`block truncate`,Bu(s)),children:c}),n&&(0,J.jsx)(`div`,{...n})]})}function Yd({columns:e,hasHidden:t,isVisible:n,onReset:r,onToggle:i,processing:a,visibleColumnCount:o}){let{t:s}=w(`lattice`),c=s(`table.columns.label`,`Columns`);return(0,J.jsxs)(Te,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(nt,{size:`sm`,icon:`columns-3`,label:c,"data-test":`table-columns-menu`,disabled:a})}),(0,J.jsx)(B,{align:`end`,className:`w-64 p-4`,children:(0,J.jsxs)(`div`,{className:`grid gap-3`,children:[e.map(e=>{let t=n(e),r=t&&o<=1;return(0,J.jsxs)(`label`,{className:`flex items-center gap-2 text-base text-lt-fg`,children:[(0,J.jsx)(uc,{"data-test":`table-column-toggle-${e.key}`,checked:t,disabled:r,onCheckedChange:t=>i(e.key,t===!0)}),(0,J.jsx)(`span`,{children:e.props.label??e.key})]},e.key)}),t&&(0,J.jsx)(`button`,{type:`button`,"data-test":`table-columns-reset`,className:`mt-1 justify-self-start text-sm text-lt-muted-fg hover:text-lt-fg`,onClick:r,children:s(`table.columns.reset`,`Reset`)})]})})]})}function Xd({clauses:e,columnsByKey:t,indicators:n,processing:r,onRemoveClause:i,onChange:a,onReset:o}){let{t:s}=w(`lattice`);return e.length===0&&n.length===0?null:(0,J.jsx)(`div`,{className:`border-b border-lt-border px-4 py-3`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[e.map((e,n)=>{let a=t.get(e.field)?.props.label??e.field,o=xd.has(e.operator);return(0,J.jsx)(Zd,{label:`${a} ${Sd(e.operator)}`,value:o?``:e.value,removeTestId:`filter-chip-${e.field}-remove`,removeLabel:s(`table.filter.remove`,`Remove {{label}} filter`,{label:a}),processing:r,onRemove:()=>i(n)},`${e.field}-${e.operator}-${n}`)}),n.map(e=>(0,J.jsx)(Zd,{label:e.label,value:e.value,removeTestId:`table-filter-chip-${e.filter}-remove`,removeLabel:s(`table.filter.remove`,`Remove {{label}} filter`,{label:e.label}),processing:r,onRemove:()=>a(e.filter,void 0)},`${e.filter}:${e.label}:${e.value}`)),(0,J.jsx)(`button`,{type:`button`,"data-test":`table-filters-reset`,className:`text-lt-muted-fg underline-offset-2 hover:underline disabled:text-lt-disabled-fg`,disabled:r,onClick:o,children:s(`table.filter.reset-all`,`Reset all`)})]})})}function Zd({label:e,value:t,removeTestId:n,removeLabel:r,processing:i,onRemove:a}){return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lt-sm bg-lt-muted px-2 py-1`,children:[(0,J.jsx)(`span`,{children:t===``?(0,J.jsx)(`span`,{className:`font-semibold`,children:e}):(0,J.jsxs)(J.Fragment,{children:[`${e}: `,(0,J.jsx)(`span`,{className:`font-semibold`,children:t})]})}),(0,J.jsx)(nt,{size:`xs`,icon:`x`,label:r,"data-test":n,disabled:i,onClick:a})]})}function Qd({filters:e,values:t,processing:n,onChange:r,onSearch:i}){let{t:a}=w(`lattice`),o=e.filter(e=>od(t[e.key])),s=a(`table.filter.filters`,`Filters`);return(0,J.jsxs)(Te,{children:[(0,J.jsx)(V,{asChild:!0,children:(0,J.jsx)(nt,{size:`sm`,icon:`filter`,label:s,"data-test":`table-filters-menu`,disabled:n,children:o.length>0&&(0,J.jsx)(`span`,{className:`absolute -right-1 -top-1 inline-flex size-3.5 items-center justify-center rounded-full bg-lt-primary text-[10px] font-medium leading-none text-lt-primary-fg`,children:o.length})})}),(0,J.jsx)(B,{align:`end`,className:`w-80 p-4`,children:(0,J.jsx)(`div`,{className:`grid gap-3`,children:e.map(e=>(0,J.jsx)(`div`,{className:`grid gap-1`,children:(0,J.jsx)(Pd,{filter:e,value:t[e.key],processing:n,onChange:t=>r(e.key,t),onSearch:i?(t,n,r)=>i(`filter:${e.key}.${t}`,n,r):void 0})},e.key))})})]})}function $d({pagination:e,currentPage:t,processing:n,mode:r,hasNextPage:i,visiblePages:a,infiniteLoaderRef:o,perPageOptions:s,perPageValue:c,onPerPage:l,onPage:u,onLoadMore:d}){let{t:f}=w(`lattice`);return(0,J.jsxs)(`div`,{"data-slot":`table-pagination`,className:`flex items-center justify-between gap-3 border-t border-lt-border p-4 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsx)(`span`,{children:e.total==null?f(`table.pagination.page`,`Page {{page}}`,{page:t}):f(`table.pagination.showing`,`Showing {{from}}-{{to}} of {{total}}`,{from:e.from??0,to:e.to??0,total:e.total})}),s.length>0&&r!==`none`&&(0,J.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.per-page`,`Rows per page`)}),(0,J.jsx)(Md,{"data-test":`pagination-per-page`,disabled:n,value:String(c),onChange:e=>l(e.target.value===`infinite`?`infinite`:Number(e.target.value)),children:s.map(e=>(0,J.jsx)(`option`,{value:String(e),children:e===`infinite`?f(`table.pagination.infinite`,`Infinite`):e},String(e)))})]})]}),r===`infinite`?(0,J.jsx)(`div`,{ref:o,className:`flex items-center gap-2`,children:e.hasMore?(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-load-more`,disabled:n,onClick:d,children:n?f(`table.pagination.loading`,`Loading...`):f(`table.pagination.load-more`,`Load more`)}):(0,J.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.all-loaded`,`All rows loaded`)})}):r===`simple`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):r===`table`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),a.map(e=>(0,J.jsx)(G,{emphasis:`outline`,size:`icon`,"data-test":`pagination-page-${e}`,disabled:n||e===t,"aria-current":e===t?`page`:void 0,"aria-label":f(`table.pagination.page`,`Page {{page}}`,{page:e}),onClick:()=>u(e),children:e},e)),(0,J.jsx)(G,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):null]})}function ef({columnsByKey:e,query:t,processing:n,onClear:r}){let{t:i}=w(`lattice`);return(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 border-b border-lt-border px-4 py-2.5 text-sm`,children:t.sorts.map((t,a)=>{let o=e.get(t.key)?.props.label??t.key,s=t.direction===`desc`?`arrow-down`:`arrow-up`;return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`${a+1}. ${o}`}),(0,J.jsx)(R,{name:s,role:`img`,"aria-hidden":!1,"aria-label":Cd(t.direction),className:`size-lt-icon-sm text-lt-muted-fg`}),(0,J.jsx)(nt,{size:`xs`,icon:`x`,label:i(`table.sort.clear`,`Clear {{label}} sort`,{label:o}),"data-test":`clear-${t.key}-sort`,disabled:n,onClick:()=>r(t)})]},t.key)})})}var tf=300;function nf({value:e,onSearch:t}){let{t:n}=w(`lattice`),[r,i]=(0,K.useState)(e),a=(0,K.useRef)(e);(0,K.useEffect)(()=>{e!==a.current&&(a.current=e,i(e))},[e]);function o(e){a.current=e,t(e)}let s=Ca(o,tf);function c(e){i(e),s(e)}function l(){s.cancel(),i(``),o(``)}let u=n(`table.search.placeholder`,`Search`);return(0,J.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,J.jsx)(R,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 size-lt-icon-sm -translate-y-1/2 text-lt-muted-fg`}),(0,J.jsx)(dt,{type:`search`,"data-test":`table-search`,value:r,placeholder:u,"aria-label":u,onChange:e=>c(e.target.value),className:P(`px-8`,`[&::-webkit-search-cancel-button]:hidden`)}),r!==``&&(0,J.jsx)(nt,{size:`xs`,icon:`x`,label:n(`table.search.clear`,`Clear search`),"data-test":`table-search-clear`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,onClick:l})]})}function rf(e){return e}function af(e,t,n){if(e==null)return``;let r=t?.props?.date;return r?D(e,r,n):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function of(e,t,n){let r=e.props.link;if(!r)return null;let i=r.href??String(n??``);return i===``?null:i.replace(/\{([^}]+)\}/g,(e,r)=>encodeURIComponent(String(r===`value`?n??``:t[r]??``)))}var sf=({column:e,props:t,value:n})=>{let r=af(n,e);return r===``?null:(0,J.jsx)(ro,{color:t.colors?.[String(n)],children:r})},cf=({value:e})=>{let{t}=w(`lattice`),n=Nd(e);return(0,J.jsx)(`span`,{"aria-label":n?t(`common.yes`,`Yes`):t(`common.no`,`No`),role:`img`,children:(0,J.jsx)(R,{name:n?`check`:`x`,className:P(`size-lt-icon-md`,n?`text-lt-success`:`text-lt-muted-fg`)})})},lf=({props:e,value:t})=>{let n=e.icons?.[String(t)]??e.icon??void 0;if(!n)return null;let r=Ct(e.colors?.[String(t)]),i=r?St(r):void 0;return(0,J.jsx)(`span`,{"aria-label":String(t),className:P(`lt-cell-icon`,i?.className),style:i?.style,children:(0,J.jsx)(N,{className:`size-lt-icon-md`,icon:n})})},uf=({column:e,props:t,value:n})=>{let r=typeof n==`string`?n:``;if(r===``)return null;let i=t.size??32;return(0,J.jsx)(Eo,{alt:e.props.label??``,className:P(`object-cover`,t.circular?`rounded-full`:`rounded-lt-sm`),height:i,previewable:t.previewable,src:r,testId:`preview-${e.key}`,width:i})};function df({children:e,column:t,copyable:n,value:r}){return n?(0,J.jsx)(So,{value:r,label:t.props.label??t.key,testId:`copy-${t.key}`,children:e}):e}function ff({column:e,copyable:t,format:r,value:i}){let{locale:a}=n();return xt(i)===null?(0,J.jsx)(`span`,{children:af(i,e)}):(0,J.jsx)(df,{column:e,copyable:t,value:String(i),children:(0,J.jsx)(`span`,{className:`tabular-nums`,children:wt(i,r,a)})})}var pf=({column:e,props:t,row:n,value:r})=>{let i=t.currencyField?n[t.currencyField]:void 0,a=t.currency??(typeof i==`string`?i:null);return(0,J.jsx)(ff,{column:e,copyable:t.copyable,value:r,format:{kind:`number`,notation:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:a,unit:null}})},mf=({column:e,props:t,value:n})=>(0,J.jsx)(ff,{column:e,copyable:t.copyable,value:n,format:{kind:`number`,notation:t.compact?`compact`:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:null,unit:t.unit}}),hf=({column:e,row:t})=>(0,J.jsx)(`div`,{className:`grid gap-1`,children:(0,J.jsx)(Y,{nodes:x(e.schema,t)})}),gf=e=>e.props.multiple?(0,J.jsx)(vf,{...e}):e.props.badge?(0,J.jsx)(yf,{...e}):(0,J.jsx)(bf,{...e});function _f({label:e,color:t}){return e===``?null:(0,J.jsx)(ro,{color:t,children:e})}function vf({column:e,props:t,value:n}){let r=Array.isArray(n)?n:[];return r.length===0?null:t.badge?(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map((t,n)=>{let r=t;return(0,J.jsx)(_f,{label:af(r.value,e),color:r.color},n)})}):(0,J.jsx)(`span`,{children:r.map(t=>af(t,e)).join(`, `)})}function yf({column:e,props:t,row:n,value:r}){let i=t.badge.colorKey;return(0,J.jsx)(_f,{label:af(r,e),color:String(n[i]??``)})}function bf({column:e,props:t,row:n,value:r}){let i=e.props.date,a=of(e,n,r),o=af(r,e),s=a?(0,J.jsx)(`a`,{className:`underline underline-offset-2`,href:a,rel:t.link?.external?`noreferrer`:void 0,target:t.link?.external?`_blank`:void 0,children:o}):o;return i&&!a&&!t.copyable&&r!=null?(0,J.jsx)(Vr,{value:r,dateStyle:i.dateStyle,timeStyle:i.timeStyle}):(0,J.jsx)(df,{column:e,copyable:t.copyable,value:o,children:s})}var xf={"column.badge":rf(sf),"column.boolean":rf(cf),"column.icon":rf(lf),"column.image":rf(uf),"column.money":rf(pf),"column.number":rf(mf),"column.stack":rf(hf),"column.text":rf(gf)};function Sf({column:e,row:t}){let n=h()[e.type]??xf[e.type]??xf[`column.text`];return(0,J.jsx)(n,{column:e,props:e.props,row:t,value:t[e.key]})}var Cf=gn(is,La,du,fi,hn({components:{table:q(({node:e})=>{let{t}=w(`lattice`),{columns:n,rows:r,pagination:i,query:a,filters:o,tableFilters:s,search:c,addFilter:l,updateFilter:u,removeFilter:d,replaceColumnFilters:f,setTableFilter:p,resetFilters:m,setSearch:h,searchFilterOptions:g,processing:_,hasLoaded:v,infiniteLoaderRef:y,sort:b,clearSort:x,goToPage:S,setPerPage:C,loadMore:T}=kd(e),E=(0,K.useMemo)(()=>Uu(e.props?.bulkActions),[e.props?.bulkActions]),D=E.length>0,O=(0,K.useMemo)(()=>r.map((e,t)=>({row:e,actions:nd(e),detail:rd(e),key:td(e,t)})),[r]),k=Ad(O.map(e=>e.key)),{isExpanded:A,toggle:j}=Iu(),N=O.some(e=>e.detail!=null),F=(0,K.useMemo)(()=>new Map(n.map(e=>[e.key,e])),[n]),I=M(e),{hasToggleableColumns:L,hasHidden:ee,isVisible:te,resetVisibility:ne,setColumnVisible:re,toggleableColumns:ie,visibleColumns:z}=ju({columns:n,storageKey:I?`lattice:table-column-visibility:${I}`:void 0}),ae=i.currentPage??a.page,oe=i.lastPage??ae,se=i.mode??`table`,ce=(0,K.useMemo)(()=>Qu(e.props?.perPageOptions),[e.props?.perPageOptions]),le=Td(ae,oe),ue=i.hasMore??ae<oe,de=O.some(e=>e.actions.length>0),B=e.props?.striped===!0,fe=z.some(e=>e.props.filter!=null),pe=o.map((e,t)=>({clause:e,index:t})),me=(0,K.useMemo)(()=>Array.isArray(e.props?.filters)?e.props.filters:[],[e.props?.filters]),V=me.length>0,he=de||V||L,ge=(0,K.useMemo)(()=>Ed(z),[z]),_e=(0,K.useMemo)(()=>Od(he,D,N),[he,D,N]),ve=e.props?.resizableColumns===!0,ye=M(e),{getResizeHandleProps:be,gridTemplateColumns:xe,hasOverrides:Se,resizeRootRef:Ce,resetColumns:H}=Ss({columns:ge,enabled:ve,leadingTracks:_e.leadingTracks,showIndicator:e.props?.resizeIndicator===!0,storageKey:ve&&ye?`lattice:table-columns:${ye}`:void 0,trailingTracks:_e.trailingTracks});return(0,J.jsxs)(`div`,{"data-slot":`table`,"data-lattice-component":e.id,className:`relative`,children:[Se&&(0,J.jsx)(`button`,{"aria-label":t(`table.reset-column-widths`,`Reset column widths`),className:`absolute right-1 top-1 z-10 hidden rounded-lt-sm p-1 text-lt-muted-fg hover:text-lt-fg md:inline-flex`,"data-test":`table-reset-columns`,onClick:H,title:t(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,J.jsx)(R,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,J.jsxs)(`div`,{"data-slot":`table-scroll`,className:`overflow-x-auto rounded-lt-sm border border-lt-border`,children:[e.props?.searchable&&(0,J.jsx)(`div`,{"data-slot":`table-toolbar`,className:`flex items-center gap-2 border-b border-lt-border px-4 py-2`,children:(0,J.jsx)(nf,{value:c,onSearch:h})}),(0,J.jsx)(Xd,{clauses:o,columnsByKey:F,indicators:a.tableFilterIndicators,processing:_,onRemoveClause:d,onChange:p,onReset:m}),D&&k.active&&(0,J.jsx)(jd,{actions:E,selectedKeys:k.selectedKeys,allMatching:k.allMatching,total:i.total??void 0,query:_d(a),canSelectAllMatching:k.allVisibleSelected&&!k.allMatching&&i.total!=null&&i.total>k.selectedKeys.length,onSelectAllMatching:k.selectAllMatching,onCompleted:k.clear}),a.sorts.length>0&&(0,J.jsx)(ef,{columnsByKey:F,query:a,processing:_,onClear:x}),(0,J.jsxs)(`div`,{ref:Ce,className:`min-w-full text-base`,role:`table`,style:{"--lattice-table-columns":xe},children:[(0,J.jsxs)(`div`,{"data-slot":`table-header`,className:`border-b border-lt-border bg-lt-muted/50`,role:`rowgroup`,children:[(0,J.jsxs)(`div`,{className:`hidden min-w-full md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[N&&(0,J.jsx)(`div`,{className:`px-2 py-3`,role:`columnheader`,"aria-hidden":`true`}),D&&(0,J.jsx)(`div`,{className:`flex items-center px-4 py-3`,role:`columnheader`,children:(0,J.jsx)(uc,{"aria-label":t(`table.select-all-rows`,`Select all rows`),"data-test":`select-all`,checked:k.allSelected,onCheckedChange:()=>k.toggleAll()})}),z.map((e,t)=>(0,J.jsx)(Jd,{column:e,processing:_,resizeHandleProps:ve?be(ge[t]):void 0,sort:b,query:a},e.key)),he&&(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2 align-middle font-semibold text-lt-fg`,role:`columnheader`,children:[V&&(0,J.jsx)(Qd,{filters:me,values:s,processing:_,onChange:p,onSearch:g}),L&&(0,J.jsx)(Yd,{columns:ie,isVisible:te,visibleColumnCount:z.length,hasHidden:ee,onToggle:re,onReset:ne,processing:_}),de&&(0,J.jsx)(`span`,{className:`sr-only`,children:e.props?.actionsLabel??t(`table.actions`,`Actions`)})]})]}),fe&&(0,J.jsxs)(`div`,{className:`hidden min-w-full border-t border-lt-border md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[N&&(0,J.jsx)(`div`,{className:`px-2 py-2`,role:`cell`}),D&&(0,J.jsx)(`div`,{className:`px-4 py-2`,role:`cell`}),z.map(e=>(0,J.jsx)(`div`,{className:`min-w-0 px-2 py-2`,role:`cell`,children:e.props.filter!=null&&(0,J.jsx)(zd,{column:e,clauses:pe.filter(t=>t.clause.field===e.key),processing:_,onAdd:l,onUpdate:u,onRemove:d,onReplace:f,onSearch:(t,n)=>g(`column:${e.key}`,t,n)})},e.key)),he&&(0,J.jsx)(`div`,{className:`px-4 py-2`,role:`cell`})]})]}),(0,J.jsx)(`div`,{role:`rowgroup`,children:v?O.length===0?(0,J.jsx)(`div`,{"data-slot":`table-empty`,className:`p-8 text-center text-lt-muted-fg`,role:`row`,children:(0,J.jsx)(`div`,{role:`cell`,children:e.props?.emptyLabel??t(`table.empty`,`No results`)})}):O.map(({row:n,actions:r,detail:i,key:a})=>{let o=i!=null&&A(a),s=`${M(e)??`table`}-row-detail-${a}`;return(0,J.jsxs)(K.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`table-row`,className:`grid grid-cols-1 border-b border-lt-border last:border-b-0 md:grid-cols-[var(--lattice-table-columns)] ${B?`odd:bg-lt-muted/30`:``}`,role:`row`,children:[N&&(0,J.jsx)(`div`,{className:`flex items-center px-2 py-lt-cell-y`,role:`cell`,children:i&&(0,J.jsx)(`button`,{type:`button`,"data-test":`row-expand-${a}`,"aria-expanded":o,"aria-controls":s,"aria-label":t(`table.row-detail.toggle`,`Toggle detail`),className:`inline-flex size-6 items-center justify-center rounded-lt-sm text-lt-muted-fg hover:bg-lt-muted hover:text-lt-fg`,onClick:()=>j(a),children:(0,J.jsx)(R,{name:`chevron-down`,"aria-hidden":`true`,className:P(`size-lt-icon-md transition-transform`,!o&&`-rotate-90`)})})}),D&&(0,J.jsx)(`div`,{className:`flex items-center px-lt-cell-x py-lt-cell-y`,role:`cell`,children:(0,J.jsx)(uc,{"aria-label":t(`table.select-row`,`Select row {{key}}`,{key:a}),"data-test":`select-row-${a}`,checked:k.isSelected(a),onCheckedChange:()=>k.toggle(a)})}),z.map(e=>(0,J.jsxs)(`div`,{"data-slot":`table-cell`,className:P(`grid min-w-0 gap-1 overflow-hidden px-lt-cell-x py-lt-cell-y align-middle`,Bu(e.props.align),Hu(e.props.align)),role:`cell`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium text-lt-muted-fg md:hidden`,children:e.props.label}),(0,J.jsx)(`div`,{"data-slot":`table-cell-content`,className:`min-w-0 max-w-full overflow-hidden truncate`,children:(0,J.jsx)(Sf,{column:e,row:n})})]},e.key)),he&&(0,J.jsx)(`div`,{className:P(`items-center justify-start gap-2 px-lt-cell-x py-lt-cell-y md:justify-end`,r.length>0?`flex`:`hidden md:flex`),role:`cell`,children:r.map((e,t)=>(0,J.jsx)(En,{node:e},e.key??e.id??t))})]}),o&&i&&(0,J.jsx)(`div`,{id:s,role:`region`,"data-slot":`table-row-detail`,className:`border-b border-lt-border bg-lt-muted/20 px-lt-cell-x py-lt-cell-y`,children:(0,J.jsx)(Y,{nodes:[i]})})]},a)}):(0,J.jsx)(`div`,{className:`p-4 text-lt-muted-fg`,role:`row`,children:(0,J.jsx)(`div`,{role:`cell`,children:t(`table.loading`,`Loading rows...`)})})})]}),v&&(0,J.jsx)($d,{pagination:i,currentPage:ae,processing:_,mode:se,hasNextPage:ue,visiblePages:le,infiniteLoaderRef:y,perPageOptions:ce,perPageValue:se===`infinite`?`infinite`:a.perPage,onPerPage:C,onPage:S,onLoadMore:T})]})]})})},name:`lattice/table`}),Qa,Du,Au);function wf(e,t){if(t.length===0)return e;let n=new Set([...e.namespaces??[`lattice`],...t.map(e=>e.namespace)]);return{...e,namespaces:[...n]}}function Tf({ready:e,children:t}){let[n,r]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let t=!0,n=()=>{t&&r(!0)};return e.then(n,n),()=>{t=!1}},[e]),n?t:null}function Ef({registry:e,plugins:t,sprite:n,pages:r={},defaultLayout:i,strictMode:a=!0,i18n:o,boot:c,wrap:u,...d}={}){let f=e??Cf,p=t&&t.length>0?_n(f,...t):f;s(p),Si();let m=o!==!1,h=t?.flatMap(e=>e.i18n?[e.i18n]:[])??[],g=m?wf(o??{},h):{},_=d.defaults?.visitOptions,v=m?{...d.defaults,visitOptions:(e,t)=>bi(e,_?.(e,t)??t)}:d.defaults,y=l({...d,defaults:v,strictMode:a,resolve:vi(r),layout:yi({defaultLayout:i}),withApp:(e,{ssr:t,page:r})=>{let i=[];if(!t){let e=r.props.lattice;S(e)&&S(e.urls)&&typeof e.urls.refreshRef==`string`&&Rt(e.urls.refreshRef),m&&O(r.props)!==void 0&&i.push($t(()=>import(`./chunks/page-props-B4GewgLI.js`).then(e=>e.configureI18nFromPageProps(r.props,g)),__vite__mapDeps([20,4,1,5,6,21,10]),import.meta.url));let t=c?.({page:r});t&&i.push(t)}let a=(0,J.jsxs)(J.Fragment,{children:[e,m?(0,J.jsx)(yn,{}):null]}),o=(0,J.jsx)(Ia,{registry:p,sprite:n,children:u?u(a):a});return i.length>0?(0,J.jsx)(Tf,{ready:Promise.all(i),children:o}):o}});return mn(),y}function Df(){return console.warn(`[lattice] The data-lattice-config script holds invalid JSON; booting with defaults.`),{}}function Of(e){let t=e.querySelector(`script[data-lattice-config]`);if(!t?.textContent)return{};try{let e=JSON.parse(t.textContent);return typeof e!=`object`||!e||Array.isArray(e)?Df():e}catch{return Df()}}var kf=Of(document);async function Af(){if(kf.refreshRefUrl&&Rt(kf.refreshRefUrl),kf.echo)try{let{configureEcho:e}=await $t(async()=>{let{configureEcho:e}=await import(`./chunks/dist-DqlcM-vw.js`);return{configureEcho:e}},__vite__mapDeps([8,1]),import.meta.url);e(kf.echo)}catch(e){console.warn(`[lattice] Failed to load the realtime chunk; continuing without Echo.`,e)}Ef({...kf.spriteUrl?{sprite:{href:kf.spriteUrl}}:{},defaults:{visitOptions:bi}})}Af();
22
+ }`,Bl=`^\\d+$`;function Vl({char:e,hasFakeCaret:t,isActive:n}){return(0,q.jsxs)(`div`,{className:F(`relative flex h-lt-control-md w-10 items-center justify-center border-y border-r border-lt-input text-base shadow-lt-xs transition-all first:rounded-l-lt-sm first:border-l last:rounded-r-lt-sm`,n&&`z-10 border-lt-ring ring-lt-ring/50 ring-[length:var(--lt-ring-width)]`),children:[e,t?(0,q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:(0,q.jsx)(`div`,{className:`bg-lt-fg h-5 w-px animate-pulse`})}):null]})}function Hl({length:e,containerClassName:t,pattern:n=Bl,...r}){return(0,q.jsx)(Ll,{maxLength:e,pattern:n,containerClassName:F(`flex items-center gap-2 has-[:disabled]:opacity-50`,t),render:({slots:e})=>(0,q.jsx)(`div`,{className:`flex items-center`,children:e.map((e,t)=>(0,q.jsx)(Vl,{...e},t))}),...r})}var Ul=({node:e})=>{let t=e.props;return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,q.jsx)(Hl,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a||i,id:e,length:t.length,name:e,onChange:e=>o(e),value:r})})};function Wl({className:e,ref:t,...n}){let[r,i]=(0,G.useState)(!1);return(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(pt,{type:r?`text`:`password`,className:F(`pr-10`,e),ref:t,...n}),(0,q.jsx)(`button`,{type:`button`,"data-test":typeof n.name==`string`?`${n.name}-visibility`:`password-visibility`,onClick:()=>i(e=>!e),className:`absolute inset-y-0 right-0 flex items-center rounded-r-lt-sm px-3 text-lt-muted-fg hover:text-lt-fg focus-visible:ring-[length:var(--lt-ring-width)] focus-visible:ring-lt-ring/50 focus-visible:outline-none`,"aria-label":r?`Hide password`:`Show password`,tabIndex:-1,children:r?(0,q.jsx)(R,{name:`eye-off`,className:`size-lt-icon-md`}):(0,q.jsx)(R,{name:`eye`,className:`size-lt-icon-md`})})]})}var Gl=({node:e})=>{let t=e.props,{errors:n}=Te(),r=hc(e),{commit:i}=je(),a=lt(),o=t.confirmation,s=o?.name??`${r.localName}_confirmation`,c=a?a.scopedName(s):s,l=a?a.errorKey(s):s,u=(t.passwordRules??``)||void 0;return r.hidden?null:(0,q.jsxs)(`div`,{className:`grid gap-6`,children:[(0,q.jsx)(Ve,{error:r.error,helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,labelAction:t.labelAction??void 0,name:r.name,required:r.required,children:(0,q.jsx)(_l,{prefix:t.prefix,suffix:t.suffix,children:e=>(0,q.jsx)(Wl,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:e,"data-test":r.testId,disabled:r.disabled,id:r.name,name:r.name,onChange:e=>{r.commit(e.target.value)},placeholder:t.placeholder??``,passwordrules:u,readOnly:r.readOnly,tabIndex:t.tabIndex??void 0,value:r.value})})}),o&&(0,q.jsx)(Ve,{error:n[l],label:o.label??`Confirm password`,name:c,required:r.required,children:(0,q.jsx)(Wl,{autoComplete:`new-password`,"data-test":A(s),disabled:r.disabled,id:c,name:c,onChange:e=>{i(s,e.target.value)},placeholder:o.placeholder??o.label??`Confirm password`,passwordrules:u,readOnly:r.readOnly,tabIndex:t.tabIndex??void 0})})]})},Kl=[],ql=({node:e})=>{let t=e.props,n=t.name,{errors:r}=Te(),{hidden:i,required:a}=Je(e),{path:o,rows:s,onField:c,onRemove:l,onMove:u,onDuplicate:d,append:f}=Ws(n,t.defaultItems??1),p=e.schema??Kl,m=Us(s.map(e=>String(e.rowId??``)).join(`,`)),h=t.maxItems!=null&&s.length>=t.maxItems,g=t.minItems!=null&&s.length<=t.minItems,_=t.layout===`table`,v=t.itemLabels,y=e=>{let n=v?.[e];return typeof n==`string`&&n!==``?n:t.itemLabel?`${t.itemLabel} ${e+1}`:`#${e+1}`};if(i)return null;let b=s.map((e,t)=>({key:String(e.rowId??t),index:t,row:e,template:p,span:!1,heading:y(t)}));return(0,q.jsx)(Ve,{error:r[o],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,name:o,required:a,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,q.jsx)(ps,{path:o,rows:s,rowKey:ue}),_?(0,q.jsx)(Bs,{base:o,columns:Rs(p),rows:b,reorderable:t.reorderable??!1,removable:()=>!g,rowActions:t.rowActions,onField:c,onMove:u,onRemove:l,onDuplicate:d,registerRow:m,resizableColumns:t.resizableColumns===!0,resizeIndicator:t.resizeIndicator===!0}):s.map((e,n)=>{let r=String(e.rowId??n);return(0,q.jsx)(`div`,{ref:e=>m(r,e),"data-flip-key":r,children:(0,q.jsx)(hs,{base:o,index:n,row:e,template:p,heading:y(n),reorderable:t.reorderable??!1,isFirst:n===0,isLast:n===s.length-1,removable:!g,rowActions:t.rowActions,onField:c,onRemove:l,onMove:u,onDuplicate:d})},r)}),!h&&(0,q.jsxs)(`button`,{type:`button`,"data-test":`repeater-${n}-add`,className:`inline-flex items-center gap-1.5 self-start rounded-lt-sm border border-lt-border px-3 py-1.5 text-sm hover:bg-lt-accent [&_svg]:size-lt-icon-sm`,onClick:()=>f({}),children:[(0,q.jsx)(R,{name:`plus`}),t.addLabel??`Add`]})]})})},Jl=250;function Yl({contentClassName:e,creatable:t=!1,emptyLabel:n,loading:r=!1,multiple:i=!1,onCommit:a,onCreate:o,onSearch:s,onSelect:c,open:l,onOpenChange:u,options:d,renderOption:f,searchLabel:p,searchPlaceholder:m,selected:h,showSearch:g=!0,testId:_,trigger:v,triggerClassName:y,triggerProps:b}){let{t:x}=w(`lattice`),[S,C]=(0,G.useState)(``);function T(e){let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of t){let t=d.find(t=>t.label.toLowerCase()===e.toLowerCase());t?(a??c)(t.value):o?.(e)}i?C(``):k()}let E=d.some(e=>e.label.toLowerCase()===S.trim().toLowerCase()),D=wa(e=>s?.(e),Jl);(0,G.useEffect)(()=>{if(!(!s||!l))return D(S),()=>D.cancel()},[S,s,l,D]);let O=s?d:d.filter(e=>e.label.toLowerCase().includes(S.toLowerCase()));function k(){C(``),u(!1)}function A(e){c(e),i||k()}return(0,q.jsxs)(De,{open:l,onOpenChange:e=>e?u(!0):k(),children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:y,...b,children:v})}),(0,q.jsxs)(B,{align:`start`,className:F(`w-[var(--radix-popover-trigger-width)] overflow-hidden p-0`,e),children:[g&&(0,q.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-lt-border px-3 py-2`,children:[(0,q.jsx)(`input`,{"aria-label":p??x(`form.search-options`,`Search options`),"data-slot":`combobox-search`,"data-test":_?`${_}-search`:void 0,className:`w-full bg-transparent text-sm outline-none placeholder:text-lt-muted-fg`,onChange:e=>{let n=e.target.value;if(t&&n.includes(`,`)){T(n);return}C(n)},onKeyDown:e=>{t&&e.key===`Enter`&&S.trim()!==``&&(e.preventDefault(),T(S))},placeholder:m,value:S}),r&&(0,q.jsx)(R,{name:`loader-2`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0 animate-spin text-lt-muted-fg`})]}),(0,q.jsxs)(`div`,{className:`max-h-60 overflow-y-auto p-1`,role:`listbox`,children:[t&&S.trim()!==``&&!E&&(0,q.jsxs)(`button`,{className:`flex w-full items-center gap-2 rounded-lt-sm px-3 py-1.5 text-left text-sm transition-colors hover:bg-lt-accent hover:text-lt-accent-fg`,"data-test":_?`${_}-create`:void 0,onClick:()=>T(S),type:`button`,children:[(0,q.jsx)(R,{name:`plus`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`}),x(`form.create-option`,`Create "{{label}}"`,{label:S.trim()})]}),O.length===0&&!(t&&S.trim()!==``&&!E)?(0,q.jsx)(`p`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:n}):O.map(e=>{let t=h.includes(e.value);return(0,q.jsxs)(`button`,{"aria-label":f?e.label:void 0,"aria-selected":t,className:F(`flex w-full items-center justify-between gap-2 rounded-lt-sm px-3 py-1.5 text-left text-sm transition-colors hover:bg-lt-accent hover:text-lt-accent-fg`,t&&`bg-lt-accent/60`),"data-slot":`combobox-option`,"data-test":_?`${_}-option-${e.value}`:void 0,"data-value":e.value,onClick:()=>A(e.value),role:`option`,type:`button`,children:[f?(0,q.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:f(e)}):e.label,t&&(0,q.jsx)(R,{name:`check`,"aria-hidden":`true`,className:`size-lt-icon-md shrink-0`})]},e.value)})]})]})]})}function Xl(e,t){let n=e??t;return Array.isArray(n)?n.map(String):n==null||n===``?[]:[String(n)]}var Zl=({node:e})=>{let{t}=w(`lattice`),n=e.props,{action:r,componentRef:i,errors:a,fieldIdPrefix:o,searchOptions:s}=Te(),{hidden:c,required:l,readOnly:u,disabled:d}=Je(e),{change:f,blur:p}=je(),m=ua(e),h=n.name,g=lt(),_=fc(g?g.scopedName(h):h,o),v=g?g.errorKey(h):h,y=v,b=n.placeholder||`Select…`,S=n.multiple,C=n.searchable,T=n.creatable,E=(0,G.useMemo)(()=>m.props.options??[],[m.props]),D=m.props.optionSchema,O=dt(h),k=Pe(),A=(0,G.useRef)(k);A.current=k;let j=g?g.getValue(h):O,M=(0,G.useMemo)(()=>Xl(j,n.value),[j,n.value]),N=(0,G.useRef)(M);N.current=M;let[P,I]=(0,G.useState)(!1),[L,ee]=(0,G.useState)(null),[te,ne]=(0,G.useState)(!1),re=(0,G.useRef)(null),ie=(0,G.useMemo)(()=>{let e=new Map;for(let t of[...E,...L??[]])e.set(t.value,t);return e},[E,L]),z=e=>ie.get(e)?.label??e,ae=e=>Tt(ie.get(e)?.data?.color),oe=u||d,se=(0,G.useCallback)(e=>{if(re.current?.abort(),e.trim()===``){ee(null),ne(!1);return}let t=new AbortController;if(re.current=t,ne(!0),s){s(y,e,A.current,t.signal).then(e=>{ee(e),ne(!1)}).catch(()=>{});return}da(r,i,{...A.current,_sub:`search`,_target:y,_q:e},t.signal).then(e=>{ee(e?.options??[]),ne(!1)}).catch(()=>{})},[r,i,y,s]);function ce(e){f(h,S?e:e[0]??``)}function le(e){if(S){let t=N.current.includes(e)?N.current.filter(t=>t!==e):[...N.current,e];N.current=t,ce(t);return}N.current=[e],ce([e])}function ue(e){ce(M.filter(t=>t!==e))}function de(e){if(!S){N.current=[e],ce([e]);return}if(!N.current.includes(e)){let t=[...N.current,e];N.current=t,ce(t)}}if(c)return null;let fe=C?L??E:E,B=D?.length?e=>(0,q.jsx)(J,{nodes:x(D,{...e.data,label:e.label,value:e.value})}):void 0;return(0,q.jsxs)(Ve,{error:a[v],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,name:_,required:l,children:[S?M.map(e=>(0,q.jsx)(`input`,{name:`${_}[]`,type:`hidden`,value:e},e)):(0,q.jsx)(`input`,{name:_,type:`hidden`,value:M[0]??``}),(0,q.jsxs)(`div`,{children:[S&&M.length>0&&(0,q.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-1`,children:M.map(e=>{let n=ae(e);return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-lt-sm bg-lt-muted px-2 py-0.5 text-xs`,children:[n&&(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-full`,style:{background:St(n)}}),z(e),!oe&&(0,q.jsx)(`button`,{"aria-label":t(`form.remove-option`,`Remove {{label}}`,{label:z(e)}),"data-test":`select-${h}-remove-${e}`,className:`text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-xs`,onClick:()=>ue(e),type:`button`,children:(0,q.jsx)(R,{name:`x`})})]},e)})}),(0,q.jsx)(Yl,{creatable:T,emptyLabel:n.emptyLabel??void 0,loading:te,multiple:S,onCommit:de,onCreate:de,onSearch:C?se:void 0,onSelect:le,open:P&&!oe,onOpenChange:e=>{I(e),e||p(h)},options:fe,renderOption:B,searchPlaceholder:n.searchPlaceholder??void 0,showSearch:!!(C||T),selected:M,testId:`select-${h}`,trigger:(0,q.jsxs)(q.Fragment,{children:[!S&&M.length>0?(0,q.jsx)(`span`,{children:z(M[0])}):(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:b}),(0,q.jsx)(R,{name:`chevrons-up-down`,className:`size-lt-icon-md shrink-0 text-lt-muted-fg`})]}),triggerClassName:F(yt(),`flex items-center justify-between gap-2 text-left`,oe&&`cursor-not-allowed opacity-60`),triggerProps:{"aria-haspopup":`listbox`,autoFocus:n.autoFocus??void 0,"data-test":`select-${h}`,disabled:oe,id:_,tabIndex:n.tabIndex??void 0}})]})]})};function Ql({className:e,...t}){return(0,q.jsx)(`textarea`,{"data-slot":`textarea`,className:F(`border-lt-input placeholder:text-lt-muted-fg flex field-sizing-content min-h-16 w-full rounded-lt-sm border bg-transparent px-3 py-2 text-base shadow-lt-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg`,_t,`aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger`,e),...t})}var $l=({node:e})=>{let t=e.props;return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,q.jsx)(Ql,{autoFocus:t.autoFocus??!1,"data-test":n,disabled:a,id:e,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,rows:t.rows??void 0,tabIndex:t.tabIndex??void 0,value:r})})},eu=({node:e})=>{let t=e.props;return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o})=>(0,q.jsx)(_l,{prefix:t.prefix,suffix:t.suffix,end:t.copyable?(0,q.jsx)(So,{className:`h-lt-control-md gap-1.5 rounded-l-none rounded-r-lt-sm border-l-0 border-lt-input px-3 group-has-[:focus-visible]:border-lt-ring`,label:t.label??e,testId:`${n}-copy`,value:r}):null,children:s=>(0,q.jsx)(pt,{autoComplete:t.autoComplete??``,autoFocus:t.autoFocus??!1,className:s,"data-test":n,disabled:a,id:e,name:e,onChange:e=>o(e.target.value),placeholder:t.placeholder??``,readOnly:i,tabIndex:t.tabIndex??void 0,type:t.type??`text`,value:r})})})},tu=({node:e})=>{let t=e.props,n=mt(t.step),r=t.label??t.name;return(0,q.jsx)(Qc,{node:e,label:t.label??``,children:({name:e,testId:i,value:a,readOnly:o,disabled:s,commit:c,blur:l})=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(pt,{"aria-label":r,autoFocus:t.autoFocus??!1,"data-test":i,disabled:s,id:e,name:e,onBlur:()=>{let e=vt(a);e&&c(gt(e,n)),l()},onChange:e=>c(e.target.value),readOnly:o,tabIndex:t.tabIndex??void 0,type:`text`,value:a}),(0,q.jsxs)(De,{children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(W,{"aria-label":`Open ${r} time picker`,disabled:s||o,size:`icon`,type:`button`,variant:`secondary`,children:(0,q.jsx)(R,{name:`clock`,className:`size-lt-icon-md`,"aria-hidden":`true`})})}),(0,q.jsx)(B,{className:`p-2`,children:(0,q.jsx)(bt,{value:vt(a),onChange:e=>c(gt(e,n)),step:t.step,min:t.min,max:t.max,disabled:s,readOnly:o,testId:`${i}-picker`})})]})]})})},nu=({node:e})=>{let{hidden:t,required:n,readOnly:r,disabled:i}=Je(e),a=e.props,o=a.name,s=lt(),{errors:c,fieldIdPrefix:l}=Te(),u=fc(s?s.scopedName(o):o,l),d=s?s.errorKey(o):o,f=dt(o),p=s?s.getValue(o):f,m=et(a.value),h=p===void 0?m:et(p),g=r||i,{commit:_}=je();return pc(o,m),t?null:(0,q.jsxs)(Ve,{error:c[d],helperText:a.helperText??void 0,tooltip:a.tooltip??void 0,label:a.label??``,name:u,required:n,children:[(0,q.jsx)(`input`,{disabled:g,name:u,type:`hidden`,value:h?`1`:`0`}),(0,q.jsx)(`button`,{"aria-checked":h,"aria-label":a.label??o,autoFocus:a.autoFocus??!1,className:F(`inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-transparent bg-lt-muted p-0.5 shadow-lt-xs transition-colors outline-none focus-visible:border-lt-ring focus-visible:ring-[length:var(--lt-ring-width)] focus-visible:ring-lt-ring/50 disabled:cursor-not-allowed disabled:bg-lt-disabled data-[state=checked]:bg-lt-primary disabled:data-[state=checked]:bg-lt-disabled`),"data-state":h?`checked`:`unchecked`,"data-test":A(o),disabled:g,id:u,name:u,onClick:()=>_(o,!h),role:`switch`,tabIndex:a.tabIndex??void 0,type:`button`,children:(0,q.jsx)(`span`,{className:`size-5 rounded-full bg-lt-bg shadow-lt-sm transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`,"data-state":h?`checked`:`unchecked`})})]})};function ru(e){let t=[],n=e=>{let r=ft(e).name;if(r&&t.push(r),!(r&&Se.has(e.type)))for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function iu(e){let t=[],n=e=>{let r=ft(e).name;if(r&&t.push(r,`${r}.*`),r&&Se.has(e.type)){for(let n of ru(e))t.push(`${r}.*.${n}`);return}for(let t of e.schema??[])n(t)};for(let t of e.schema??[])n(t);return t}function au(e,t){let n=Object.keys(t).filter(e=>!!t[e]),r=new Set;return e.forEach((e,t)=>{n.some(t=>e.some(e=>Sa(t,e)))&&r.add(t)}),r}function ou(e,t){let n=au(e,t);return n.size>0?Math.min(...n):null}var su=(0,G.createContext)({activeName:``});function cu(e){let t=(e.schema??[]).filter(e=>e.type===`wizard-step`);return{items:t.map(e=>e.props),nodes:t}}var lu=({children:e,node:t})=>{let{t:n}=w(`lattice`),{errors:r,processing:i,touch:a,validateFields:o,validating:s}=Te(),{items:c,nodes:l}=(0,G.useMemo)(()=>cu(t),[t]),u=(0,G.useMemo)(()=>l.map(e=>ru(e)),[l]),d=t.props.orientation===`vertical`,[f,p]=(0,G.useState)(0),[m,h]=(0,G.useState)(()=>new Set([0])),[g,_]=(0,G.useState)(()=>new Set),v=(0,G.useMemo)(()=>au(u,r),[u,r]),y=f===c.length-1,b=e=>{p(e),h(t=>new Set(t).add(e))},x=()=>{_(e=>new Set(e).add(f)),y||b(f+1)},S=()=>{let e=l[f],t=e?iu(e):[];if(t.length===0){x();return}a(t),o(t,{onSuccess:x})},C=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(C.current&&!i){let e=ou(u,r);e!==null&&e!==f&&b(e)}C.current=i},[i,r,u,f]);let T=(0,G.useMemo)(()=>({activeName:c[f]?.name??``}),[c,f]);return(0,q.jsx)(su.Provider,{value:T,children:(0,q.jsxs)(`div`,{className:F(`gap-6`,d?`flex`:`grid`),"data-slot":`wizard`,children:[(0,q.jsx)(`ol`,{"aria-label":n(`form.wizard.steps`,`Steps`),className:F(`gap-1`,d?`flex w-56 shrink-0 flex-col`:`flex flex-wrap`),children:c.map((e,t)=>{let n=t===f,r=g.has(t),i=v.has(t);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{"aria-current":n?`step`:void 0,className:F(`flex w-full items-center gap-2 rounded-lt px-3 py-2 text-left text-sm`,n?`bg-lt-muted font-medium text-lt-fg`:`text-lt-muted-fg`,!m.has(t)&&`cursor-not-allowed opacity-60`),"data-error":i||void 0,"data-test":`wizard-rail-${e.name}`,disabled:!m.has(t),id:`wizard-step-${e.name}-trigger`,onClick:()=>b(t),type:`button`,children:[(0,q.jsx)(`span`,{className:F(`flex size-5 shrink-0 items-center justify-center rounded-full border text-xs`,i?`border-lt-danger text-lt-danger`:r?`border-lt-primary bg-lt-primary text-lt-primary-fg`:`border-lt-border`),children:r&&!i?(0,q.jsx)(R,{className:`size-lt-icon-sm`,name:`check`}):t+1}),(0,q.jsxs)(`span`,{className:`min-w-0`,children:[(0,q.jsx)(`span`,{className:`block truncate`,children:e.label}),d&&e.description&&(0,q.jsx)(`span`,{className:`block truncate text-xs text-lt-muted-fg`,children:e.description})]})]})},e.name)})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-6`,children:[e,(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(W,{"data-test":`wizard-back`,disabled:f===0||i,onClick:()=>b(f-1),type:`button`,emphasis:`outline`,children:n(`form.wizard.back`,`Back`)}),y?(0,q.jsxs)(W,{"data-test":`wizard-finish`,disabled:i,type:`submit`,children:[i&&(0,q.jsx)(ia,{}),n(`form.wizard.finish`,`Finish`)]}):(0,q.jsxs)(W,{"data-test":`wizard-next`,disabled:i||s,onClick:S,type:`button`,children:[s&&(0,q.jsx)(ia,{}),n(`form.wizard.next`,`Next`)]})]})]})]})})},uu=({children:e,node:t})=>{let{activeName:n}=(0,G.useContext)(su),r=t.props.name,i=n===r,[a,o]=(0,G.useState)(i);return(0,G.useEffect)(()=>{i&&o(!0)},[i]),(0,q.jsx)(`section`,{"aria-labelledby":`wizard-step-${r}-trigger`,className:F(`space-y-8`,!i&&`hidden`),hidden:!i,id:`wizard-step-${r}-panel`,children:a?e:null})},du=(0,G.lazy)(()=>tn(()=>import(`./chunks/rich-editor-field-DVvEzA3W.js`),__vite__mapDeps([17,1,2,5,4,6,15,3,11,18,13]),import.meta.url)),fu=_n({components:{form:K(pl),"field.builder":K(Ks),"field.checkbox":K(mc),"field.choice":K(gc),"field.color-picker":K($c),"field.date-input":K(nl),"field.date-time-input":K(rl),"field.file-upload":K(sl),"field.hidden-input":K(hl),"field.number-input":K(vl),"field.otp":K(Ul),"field.password-input":K(Gl),"field.repeater":K(ql),"field.rich-editor":K(({children:e,node:t})=>(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(du,{node:t,children:e})})),"field.select":K(Zl),"field.textarea":K($l),"field.text-input":K(eu),"field.time-input":K(tu),"field.toggle":K(nu),wizard:K(lu),"wizard-step":K(uu)},name:`lattice/form`});function pu(e,t=1){return Wt(`${e}?page=${t}`)}function mu(e,t){return Wt(`${e}/${t}/read`,{method:`PATCH`})}function hu(e){return Wt(`${e}/read-all`,{method:`POST`})}function gu(e,t){return Wt(`${e}/${t}`,{method:`DELETE`})}function _u(e){return Wt(e,{method:`DELETE`})}function vu(e,t){return e.some(e=>e.id===t.id)?e:[t,...e]}function yu(e,t){return e.map(e=>e.id===t?{...e,isRead:!0}:e)}function bu(e,t){return e.filter(e=>e.id!==t)}function xu({endpoint:e,pollingInterval:t}){let[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(0),[o,s]=(0,G.useState)(`loading`),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(1),p=(0,G.useRef)(c);p.current=c;let m=(0,G.useRef)(!1),h=(0,G.useCallback)(async()=>{try{let t=await pu(e,1);f.current=1,r(t.notifications),a(t.unreadCount),l(t.hasMore),s(`idle`)}catch{s(`error`)}},[e]);return(0,G.useEffect)(()=>{h()},[h]),(0,G.useEffect)(()=>{if(!t||t<=0)return;let e=setInterval(()=>void h(),t*1e3);return()=>clearInterval(e)},[h,t]),{notifications:n,unreadCount:i,status:o,hasMore:c,open:u,setOpen:d,loadMore:(0,G.useCallback)(()=>{if(m.current||!p.current)return;m.current=!0;let t=f.current+1;pu(e,t).then(e=>{f.current=t,r(t=>[...t,...e.notifications]),l(e.hasMore)}).catch(()=>void h()).finally(()=>{m.current=!1})},[e,h]),markRead:(0,G.useCallback)(t=>{r(e=>yu(e,t)),a(e=>Math.max(0,e-1)),mu(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),markAllRead:(0,G.useCallback)(()=>{r(e=>e.map(e=>({...e,isRead:!0}))),a(0),hu(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),dismiss:(0,G.useCallback)(t=>{r(e=>bu(e,t)),gu(e,t).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),clearAll:(0,G.useCallback)(()=>{r([]),a(0),_u(e).then(e=>a(e.unreadCount)).catch(()=>void h())},[e,h]),receive:(0,G.useCallback)(e=>{r(t=>{let n=vu(t,e);return n!==t&&a(e=>e+1),n})},[])}}function Su(){let{t:e}=w(`lattice`);return(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-10 text-lt-muted-fg`,children:[(0,q.jsx)(R,{name:`bell`,className:`size-lt-icon-lg`}),(0,q.jsx)(`p`,{className:`text-sm`,children:e(`notifications.empty`,`No notifications yet`)})]})}var Cu={primary:`text-lt-primary`,secondary:`text-lt-muted-fg`,success:`text-lt-success`,info:`text-lt-info`,warning:`text-lt-warning`,danger:`text-lt-danger`};function wu({notification:e,onMarkRead:t,onDismiss:n}){let{t:r}=w(`lattice`),i=z(e.title,r),a=z(e.body,r),o=(0,q.jsxs)(q.Fragment,{children:[i?(0,q.jsx)(`p`,{className:`truncate text-sm font-medium text-lt-fg`,children:i}):null,a?(0,q.jsx)(`p`,{className:`text-sm text-lt-muted-fg`,children:a}):null]});return(0,q.jsxs)(`li`,{className:F(`flex gap-3 px-3 py-3`,!e.isRead&&`bg-lt-muted/40`),"data-test":`notification`,children:[e.icon?(0,q.jsx)(P,{icon:e.icon,className:F(`mt-0.5 size-lt-icon-md`,e.variant?Cu[e.variant]:void 0)}):null,(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e.href?(0,q.jsx)(b,{href:e.href,className:`block`,"data-test":`notification-link`,onClick:()=>t(e.id),children:o}):o,e.actions.length>0?(0,q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.actions.map((e,t)=>(0,q.jsx)(Y,{node:e},e.key??e.id??`action-${t}`))}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[e.isRead?null:(0,q.jsx)(`button`,{type:`button`,className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:()=>t(e.id),children:r(`notifications.mark-read`,`Mark read`)}),(0,q.jsx)(`button`,{type:`button`,"aria-label":r(`notifications.dismiss`,`Dismiss`),className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:()=>n(e.id),children:r(`notifications.dismiss`,`Dismiss`)})]})]})}function Tu({notifications:e,status:t,hasMore:n,onMarkRead:r,onDismiss:i,onLoadMore:a}){let{t:o}=w(`lattice`);return t===`loading`&&e.length===0?(0,q.jsxs)(`div`,{className:`space-y-2 p-3`,children:[(0,q.jsx)(sa,{className:`h-12 w-full`}),(0,q.jsx)(sa,{className:`h-12 w-full`}),(0,q.jsx)(sa,{className:`h-12 w-full`})]}):e.length===0?(0,q.jsx)(Su,{}):(0,q.jsxs)(`div`,{className:`max-h-96 overflow-y-auto`,children:[(0,q.jsx)(`ul`,{className:`divide-y divide-lt-border`,children:e.map(e=>(0,q.jsx)(wu,{notification:e,onMarkRead:r,onDismiss:i},e.id))}),n?(0,q.jsx)(`button`,{type:`button`,className:`w-full py-2 text-sm text-lt-muted-fg hover:text-lt-fg`,onClick:a,children:o(`notifications.load-more`,`Load more`)}):null]})}var Eu=(0,G.lazy)(()=>tn(()=>import(`./chunks/notifications-echo-uU87iJAV.js`).then(e=>({default:e.NotificationsEcho})),__vite__mapDeps([19,8,1]),import.meta.url)),Du=class extends G.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){console.warn(`[lattice] The notifications bell declares a realtime channel but Echo is unavailable. Install @laravel/echo-react and call configureEcho().`)}render(){return this.state.failed?null:this.props.children}},Ou=_n({name:`lattice/notifications`,components:{notifications:K(({node:e})=>{let{t}=w(`lattice`),n=xu({endpoint:e.props.endpoint,pollingInterval:e.props.pollingInterval}),r=t(`notifications.label`,`Notifications`),i=(0,q.jsxs)(`span`,{className:`relative inline-flex items-center justify-center rounded-lt-sm p-2 hover:bg-lt-muted`,children:[(0,q.jsx)(R,{name:`bell`,className:`size-lt-icon-md`}),n.unreadCount>0?(0,q.jsx)(`span`,{"data-test":`notifications-badge`,className:`absolute -right-0.5 -top-0.5 inline-flex min-w-4 items-center justify-center rounded-lt-full bg-lt-danger px-1 py-0 text-[10px] font-medium text-lt-danger-fg`,children:n.unreadCount}):null]}),a=(0,q.jsxs)(`div`,{className:`w-80`,"data-test":`notifications-panel`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-lt-border px-3 py-2`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:t(`notifications.heading`,`Notifications`)}),n.unreadCount>0?(0,q.jsx)(`button`,{type:`button`,className:`text-xs text-lt-muted-fg hover:text-lt-fg`,onClick:n.markAllRead,children:t(`notifications.mark-all-read`,`Mark all read`)}):null]}),(0,q.jsx)(Tu,{notifications:n.notifications,status:n.status,hasMore:n.hasMore,onMarkRead:n.markRead,onDismiss:n.dismiss,onLoadMore:n.loadMore})]});return(0,q.jsxs)(q.Fragment,{children:[e.props.channel?(0,q.jsx)(Du,{children:(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(Eu,{channel:e.props.channel,onReceive:e=>n.receive(e)})})}):null,e.props.slideOut?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,onClick:()=>n.setOpen(!0),children:i}),(0,q.jsx)(Qi,{open:n.open,onOpenChange:n.setOpen,children:(0,q.jsxs)(na,{"aria-describedby":void 0,className:`p-0`,placement:`end`,width:`sm`,children:[(0,q.jsx)(ea,{className:`sr-only`,children:r}),a]})})]}):(0,q.jsxs)(De,{open:n.open,onOpenChange:n.setOpen,children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,"aria-label":r,"data-test":`notifications-trigger`,children:i})}),(0,q.jsx)(B,{align:`end`,className:`p-0`,children:a})]})]})})}});function ku(e){return e==null?``:String(e)}function Au({props:e}){let{t}=w(`lattice`),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(!e.remote||!e.dataEndpoint){r([]),s(!1);return}let t=!1;return a(null),s(!0),Zt(e.dataEndpoint,{remote:e.remote}).then(e=>{t||r(e.data??[])}).catch(e=>{t||a(e instanceof Error?e.message:String(e))}).finally(()=>{t||s(!1)}),()=>{t=!0}},[e.dataEndpoint,e.remote]),i?(0,q.jsx)(`div`,{className:`rounded-lt border border-lt-danger/40 p-3 text-sm`,children:i}):o||!e.remote?(0,q.jsx)(`div`,{className:`rounded-lt border border-lt-border p-3 text-sm`,children:t(`common.remote.data-list.loading`,`Loading...`)}):(0,q.jsxs)(`div`,{className:`rounded-lt border border-lt-border bg-lt-bg`,children:[(0,q.jsx)(`div`,{className:`border-b border-lt-border px-3 py-2 text-sm font-medium`,children:t(`common.remote.data-list.title`,`Remote data`)}),(0,q.jsxs)(`div`,{className:`divide-y divide-lt-border`,children:[n.map((t,n)=>(0,q.jsx)(`div`,{className:`px-3 py-2`,children:(0,q.jsx)(J,{nodes:x(e.schema,t)})},ku(t.id)||n)),n.length===0?(0,q.jsx)(`div`,{className:`px-3 py-2 text-sm text-lt-muted-fg`,children:e.emptyLabel??t(`common.remote.data-list.empty`,`No data`)}):null]})]})}var ju=_n({components:{"remote.data-list":K(({node:e})=>(0,q.jsx)(Au,{props:{...e.props,schema:e.schema}}))},name:`lattice/remote`});function Mu({columns:e,storageKey:t}){let n=(0,G.useMemo)(()=>e.filter(e=>e.props.toggleable),[e]),r=(0,G.useMemo)(()=>n.map(e=>e.key),[n]),[i,a]=li(t??``,{},{enabled:!!t,parse:e=>Pu(e,r),serialize:e=>Fu(e,r)}),o=(0,G.useCallback)(e=>e.props.toggleable?i[e.key]??!e.props.hiddenByDefault:!0,[i]),s=(0,G.useMemo)(()=>e.filter(e=>o(e)),[e,o]),c=(0,G.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[a]),l=(0,G.useCallback)(()=>a({}),[a]),u=n.length>0;return{hasHidden:n.some(e=>!o(e)),hasToggleableColumns:u,isVisible:o,resetVisibility:l,setColumnVisible:c,toggleableColumns:n,visibleColumns:s}}function Nu(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))n.has(t)&&typeof i==`boolean`&&(r[t]=i);return r}function Pu(e,t){let n=JSON.parse(e);if(!Iu(n))throw Error(`unexpected stored column visibility shape`);return Nu(n.overrides,t)}function Fu(e,t){let n=Nu(e,t);return Object.keys(n).length===0?null:JSON.stringify({columns:t,overrides:n})}function Iu(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.columns)&&t.columns.every(e=>typeof e==`string`)&&typeof t.overrides==`object`&&t.overrides!==null&&!Array.isArray(t.overrides)}function Lu(){let[e,t]=(0,G.useState)(()=>new Set);return{isExpanded:(0,G.useCallback)(t=>e.has(t),[e]),toggle:(0,G.useCallback)(e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[])}}var Ru={start:`text-start`,center:`text-center`,end:`text-end`},zu={start:`justify-start`,center:`justify-center`,end:`justify-end`},Bu={start:`justify-items-start`,center:`justify-items-center`,end:`justify-items-end`},Vu=e=>Ru[e],Hu=e=>zu[e],Uu=e=>Bu[e];function Wu(e){return(e??[]).flatMap(e=>{if(e.type===`action.group`)return[];let t=e.props;return t.endpoint?[{id:e.id??``,label:Aa(e),method:t.method??`post`,endpoint:t.endpoint,ref:t.ref??``,variant:t.variant,emphasis:t.emphasis,confirmation:t.confirmation,form:t.form,modalSide:t.modalSide,modalWidth:t.modalWidth}]:[]})}function Gu(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.field==`string`&&typeof e.operator==`string`&&typeof e.value==`string`):[]}function Ku(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`key`in e&&`props`in e&&typeof e.key==`string`&&typeof e.props==`object`&&e.props!==null&&typeof e.props.label==`string`):[]}function qu(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)):[]}var Ju={mode:`none`,currentPage:null,lastPage:null,perPage:null,total:null,from:null,to:null,hasMore:!1,nextPage:null};function Yu(e){return typeof e!=`object`||!e||Array.isArray(e)?Ju:e}function Xu(e){if(typeof e!=`object`||!e||Array.isArray(e))return{filters:[],sorts:[],page:1,perPage:25,tableFilters:{},tableFilterIndicators:[],search:``,mode:null};let t=e;return{filters:Gu(t.filters),sorts:Array.isArray(t.sorts)?t.sorts:[],page:typeof t.page==`number`?t.page:1,perPage:typeof t.perPage==`number`?t.perPage:25,tableFilters:ed(t.tableFilters),tableFilterIndicators:td(t.tableFilterIndicators),search:typeof t.search==`string`?t.search:``,mode:Qu(t.mode)}}var Zu=new Set([`none`,`simple`,`table`,`infinite`]);function Qu(e){return typeof e==`string`&&Zu.has(e)?e:null}function $u(e){return Array.isArray(e)?e.filter(e=>typeof e==`number`||e===`infinite`):[]}function ed(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`object`&&e[1]!==null&&!Array.isArray(e[1])))}function td(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.filter==`string`&&typeof e.label==`string`&&typeof e.value==`string`):[]}function nd(e,t){let n=e.id??e.uuid??e.key??t;return String(n)}function rd(e){return Array.isArray(e.actions)?e.actions:[]}function id(e){let t=e.detail;return typeof t==`object`&&t&&!Array.isArray(t)?t:null}function ad(e){return e==null||e===``}function od(e){return ad(e)?!0:Array.isArray(e)?e.every(od):typeof e==`object`&&e?Object.values(e).every(od):!1}function sd(e){return!od(e)}function cd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ld(e){return cd(e)?e:{}}function ud(e,t){return e.sorts.find(e=>e.key===t.key)}function dd(e){if(e?.direction===`asc`)return`ascending`;if(e?.direction===`desc`)return`descending`}function fd(e,t){let n=new URL(e,window.location.origin);return t.filters.length>0&&n.searchParams.set(`filter`,yd(t)),t.sorts.length>0&&n.searchParams.set(`sort`,bd(t)),t.search!==``&&n.searchParams.set(`q`,t.search),pd(n,t.tableFilters),n.searchParams.set(`page`,String(t.page)),n.searchParams.set(`per_page`,String(t.perPage)),t.mode!=null&&n.searchParams.set(`mode`,t.mode),`${n.pathname}${n.search}`}function pd(e,t){for(let[n,r]of Object.entries(md(t)))_d(e,`tf[${n}]`,r)}function md(e){let t={};for(let[n,r]of Object.entries(e)){let e=hd(r);e!==void 0&&(t[n]=e)}return t}function hd(e){if(ad(e)||Array.isArray(e)||typeof e!=`object`)return;let t=Object.entries(e).map(([e,t])=>[e,gd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}function gd(e){if(!ad(e)){if(Array.isArray(e)){let t=e.map(gd).filter(e=>e!==void 0);return t.length>0?t:void 0}if(typeof e==`object`){if(e===null)return;let t=Object.entries(e).map(([e,t])=>[e,gd(t)]).filter(e=>e[1]!==void 0);return t.length>0?Object.fromEntries(t):void 0}return String(e)}}function _d(e,t,n){if(Array.isArray(n)){for(let r of n)_d(e,`${t}[]`,r);return}if(typeof n==`object`&&n){for(let[r,i]of Object.entries(n))_d(e,`${t}[${r}]`,i);return}e.searchParams.append(t,String(n))}function vd(e){let t={};e.filters.length>0&&(t.filter=yd(e)),e.sorts.length>0&&(t.sort=bd(e));let n=md(e.tableFilters);return Object.keys(n).length>0&&(t.tf=n),e.search!==``&&(t.q=e.search),t}function yd(e){return e.filters.map(e=>`${e.field}:${e.operator}:${encodeURIComponent(e.value)}`).join(`,`)}function bd(e){return e.sorts.map(e=>e.direction===`desc`?`-${e.key}`:e.key).join(`,`)}var xd={contains:`contains`,starts_with:`starts with`,ends_with:`ends with`,eq:`equals`,neq:`not equals`,gt:`>`,gte:`≥`,lt:`<`,lte:`≤`,in:`in`,not_in:`not in`,before:`before`,after:`after`,empty:`is empty`,filled:`is not empty`},Sd=new Set([`empty`,`filled`]);function Cd(e){return C(`lattice`,`table.operators.${e}`,xd[e]??e)}function wd(e){return e===`desc`?`descending`:`ascending`}function Td(e,t){if(!t.props.sortable)return e;let n=e.find(e=>e.key===t.key),r=e.filter(e=>e.key!==t.key);return n?n.direction===`asc`?[...r,{key:t.key,direction:`desc`}]:r:[...e,{key:t.key,direction:`asc`}]}function Ed(e,t){if(t<=5)return Array.from({length:t},(e,t)=>t+1);let n=Math.max(1,Math.min(e-2,t-4));return Array.from({length:5},(e,t)=>n+t)}function Dd(e){return e.map(e=>({key:e.key,label:e.props.label,width:Od(e)}))}function Od(e){return e.props.width??`md`}function kd(e,t,n=!1){return{leadingTracks:[...n?[`2.5rem`]:[],...t?[`3rem`]:[]],trailingTracks:e?[`10rem`]:[]}}function Ad(e){let t=(0,G.useMemo)(()=>Ku(e.props?.columns),[e.props?.columns]),n=typeof e.props?.endpoint==`string`?e.props.endpoint:null,r=typeof e.props?.ref==`string`?e.props.ref:``,a=e.props?.lazy===!0,o=(0,G.useMemo)(()=>Xu(e.props?.query),[e.props?.query]),s=(0,G.useMemo)(()=>qu(e.props?.data),[e.props?.data]),c=(0,G.useMemo)(()=>Yu(e.props?.pagination),[e.props?.pagination]),[l,u]=(0,G.useState)(s),[d,f]=(0,G.useState)(c),[p,m]=(0,G.useState)(o),[h,g]=(0,G.useState)(a),[_,v]=(0,G.useState)(!a),y=(0,G.useRef)(null),b=d.currentPage??p.page,x=(d.mode??`table`)===`infinite`,S=(0,G.useCallback)(async(e,t=!1)=>{if(n){g(!0);try{let i=await Wt(fd(n,e),{ref:r}),a=Xu(i.query),o=qu(i.data);u(e=>t?[...e,...o]:o),f(Yu(i.pagination)),m(a),v(!0)}finally{g(!1)}}},[n,r]);function C(e){S({...p,page:1,sorts:Td(p.sorts,e)})}function w(e){S({...p,page:1,sorts:p.sorts.filter(t=>t.key!==e.key)})}function T(e){let t={...p,filters:e,page:1};m(t),S(t)}function E(e){T([...p.filters,e])}function D(e,t){T(p.filters.map((n,r)=>r===e?t:n))}function O(e){T(p.filters.filter((t,n)=>n!==e))}function k(e,t){T([...p.filters.filter(t=>t.field!==e),...t])}function A(e,t){let n={...p.tableFilters};od(t)||!cd(t)?delete n[e]:n[e]=t;let r={...p,tableFilters:n,tableFilterIndicators:p.tableFilterIndicators.filter(t=>t.filter!==e),page:1};m(r),S(r)}function j(){let e={...p,filters:[],tableFilters:{},tableFilterIndicators:[],search:``,page:1};m(e),S(e)}function M(e){let t={...p,search:e,page:1};m(t),S(t)}let N=(0,G.useCallback)(async(e,t,i)=>{if(!n)return[];let a=new URL(n,window.location.origin);a.searchParams.set(`_sub`,`search`),a.searchParams.set(`_target`,e),a.searchParams.set(`_q`,t);let o=await Ut(`${a.pathname}${a.search}`,{ref:r,signal:i,throwOnError:!1});return o.ok?(await o.json()).options??[]:[]},[n,r]);function P(e){S({...p,page:e})}function F(e){let t=c.mode??`table`,n={...p,perPage:e===`infinite`?p.perPage:e,mode:e===`infinite`?`infinite`:t===`infinite`?`table`:null,page:1};m(n),S(n)}let I=(0,G.useCallback)(()=>{h||!d.hasMore||S({...p,page:d.nextPage??b+1},!0)},[b,S,d.hasMore,d.nextPage,h,p]);return(0,G.useEffect)(()=>{u(s),f(c),m(o),g(a),v(!a)},[s,c,o,a]),(0,G.useEffect)(()=>{!a||_||S(p)},[_,a,S,p]),bn(i.reloadComponent,t=>{t.detail?.component===e.id&&S(p)}),(0,G.useEffect)(()=>{if(!x||!d.hasMore||h||!y.current||typeof IntersectionObserver>`u`)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&I()},{rootMargin:`240px`});return e.observe(y.current),()=>e.disconnect()},[x,I,d.hasMore,h]),{columns:t,rows:l,pagination:d,query:p,filters:p.filters,tableFilters:p.tableFilters,search:p.search,addFilter:E,updateFilter:D,removeFilter:O,replaceColumnFilters:k,setTableFilter:A,resetFilters:j,setSearch:M,searchFilterOptions:N,processing:h,hasLoaded:_,infiniteLoaderRef:y,sort:C,clearSort:w,goToPage:P,setPerPage:F,loadMore:I}}function jd(e){let[t,n]=(0,G.useState)(()=>new Set),[r,i]=(0,G.useState)(!1),a=e.join(` `);(0,G.useEffect)(()=>{n(new Set),i(!1)},[a]);let o=(0,G.useCallback)(e=>{i(!1),n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),s=(0,G.useCallback)(()=>{i(!1),n(t=>t.size===e.length?new Set:new Set(e))},[e]),c=(0,G.useCallback)(()=>i(!0),[]),l=(0,G.useCallback)(()=>{i(!1),n(new Set)},[]),u=e.filter(e=>t.has(e)),d=e.length>0&&u.length===e.length;return{selectedKeys:u,allMatching:r,allVisibleSelected:d,allSelected:r||d,active:r||u.length>0,isSelected:e=>r||t.has(e),toggle:o,toggleAll:s,selectAllMatching:c,clear:l}}function Md({actions:e,selectedKeys:t,allMatching:n,total:r,query:i,canSelectAllMatching:a,onSelectAllMatching:o,onCompleted:s}){let{t:c}=w(`lattice`),[l,u]=(0,G.useState)(!1),d=y(),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),g=()=>n?{allMatching:!0,...i}:{selected:t};async function _(e){u(!0);let t=await oa(()=>Ut(e.endpoint,{method:e.method,ref:e.ref,body:JSON.stringify(g()),throwOnError:!1}),d);u(!1),t&&(p(null),s())}function v(e){if(e.form){h(e);return}if(e.confirmation){p(e);return}_(e)}let b=n?r??t.length:t.length;return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-lt-border bg-lt-muted/50 p-4 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:n?c(`table.bulk.all-selected`,`All {{count}} selected`,{count:b}):c(`table.bulk.selected`,`{{count}} selected`,{count:b})}),a&&(0,q.jsx)(`button`,{type:`button`,"data-test":`bulk-select-all-matching`,className:`font-medium text-lt-primary underline underline-offset-2`,onClick:o,children:c(`table.bulk.select-all-matching`,`Select all {{total}} matching`,{total:r})}),(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.map(e=>(0,q.jsxs)(W,{type:`button`,"data-test":M(`bulk-action`,e.id),variant:e.variant,emphasis:e.emphasis,disabled:l,onClick:()=>v(e),children:[l&&(0,q.jsx)(ia,{}),e.label]},e.id))}),f?.confirmation&&(0,q.jsx)(aa,{title:f.confirmation.title??f.label,description:f.confirmation.description??void 0,confirmLabel:f.confirmation.confirmLabel??f.label,cancelLabel:f.confirmation.cancelLabel??c(`common.cancel`,`Cancel`),confirmVariant:f.variant,confirmEmphasis:f.emphasis,processing:l,onConfirm:()=>void _(f),onCancel:()=>p(null)}),m?.form&&(0,q.jsx)(ka,{cancelLabel:m.confirmation?.cancelLabel??c(`common.cancel`,`Cancel`),componentRef:m.ref,description:m.confirmation?.description??void 0,endpoint:m.endpoint,extraData:g(),formNode:m.form,method:m.method,onClose:()=>h(null),onSuccess:()=>{h(null),s()},placement:m.modalSide??`center`,submitLabel:m.confirmation?.confirmLabel??m.label,title:m.confirmation?.title??m.label,width:m.modalWidth??void 0})]})}function Nd({className:e,density:t,children:n,ref:r,...i}){return(0,q.jsx)(`select`,{ref:r,"data-slot":`native-select`,className:F(yt({density:t}),`cursor-pointer`,e),...i,children:n})}function Pd(e){return e===!0||e===1||e===`1`||e===`true`}function Fd({filter:e,value:t,processing:n,bare:r=!1,onChange:i,onSearch:a}){let{t:o}=w(`lattice`),s=e.schema??[];return s.length===0?(0,q.jsx)(Rd,{filter:e,value:t,processing:n,onChange:i}):(0,q.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(Id,{filter:e,schema:s,value:t,processing:n,bare:r,onChange:i,onSearch:a})}),sd(t)&&(0,q.jsx)(it,{size:`md`,icon:`x`,label:o(`table.filter.clear`,`Clear {{label}} filter`,{label:e.props.label??``}),disabled:n,onClick:()=>i(void 0)})]})}function Id({filter:e,schema:t,value:n,processing:r,bare:i,onChange:a,onSearch:o}){let s=(0,G.useMemo)(()=>ld(n),[n]),c=(0,G.useMemo)(()=>({action:`#`,clearErrors:()=>{},componentId:`table-filter-${e.key}`,componentRef:``,errors:{},fieldIdPrefix:`table-filter-${e.key}`,fieldLabels:{},precognitive:!1,processing:r,searchOptions:(e,t,n,r)=>o?o(e,t,r):Promise.resolve([]),touch:()=>{},validate:()=>{},validateFields:()=>{},validating:!1}),[e.key,o,r]),l=(0,q.jsx)(`div`,{"aria-disabled":r,className:F(`grid gap-3`,r&&`pointer-events-none opacity-60`),children:(0,q.jsx)(J,{nodes:t})});return(0,q.jsx)(pe,{value:c,children:(0,q.jsx)(Ee,{value:{markUserEdit:()=>{}},children:(0,q.jsx)(la,{nodes:{},children:(0,q.jsx)(ct,{initial:s,children:(0,q.jsx)(Ld,{onChange:a,children:i?(0,q.jsx)(Be,{children:l}):l})})})})})}function Ld({children:e,onChange:t}){let n=Pe(),r=Ce(),i=(0,G.useRef)(n);i.current=n;let a=(0,G.useCallback)((e,n)=>{let a=typeof n==`function`?n(fe(i.current,e)):n,o=me(i.current,e,a);i.current=o,r(e,a),t(o)},[t,r]),o=(0,G.useMemo)(()=>({blur:()=>{},change:a,commit:a}),[a]);return(0,q.jsx)(ze,{value:o,children:e})}function Rd({filter:e,value:t,processing:n,onChange:r}){let i=Pd(ld(t).value);return(0,q.jsxs)(`label`,{className:`flex h-lt-control-md cursor-pointer items-center gap-2 text-sm`,children:[(0,q.jsx)(dc,{"aria-label":e.props.label??void 0,"data-test":`table-filter-${e.key}`,checked:i,disabled:n,onCheckedChange:e=>r(e===!0?{value:`1`}:void 0)}),(0,q.jsx)(`span`,{children:e.props.label})]})}function zd({type:e,label:t,value:n,processing:r,withSearchIcon:i=!1,grouped:a=!1,ariaLabel:o,testId:s,onCommit:c,onClear:l}){let{t:u}=w(`lattice`),[d,f]=(0,G.useState)(n),p=o??u(`table.filter.filter-by`,`Filter {{label}}`,{label:t}),m=a?`rounded-r-none`:``;return(0,G.useEffect)(()=>{f(n)},[n]),e===`boolean`?(0,q.jsxs)(Nd,{density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:n,onChange:e=>c(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:u(`table.filter.all`,`All`)}),(0,q.jsx)(`option`,{value:`true`,children:u(`table.filter.true`,`True`)}),(0,q.jsx)(`option`,{value:`false`,children:u(`table.filter.false`,`False`)})]}):e===`date`?(0,q.jsx)(pt,{type:`date`,density:`compact`,"aria-label":p,"data-test":s,className:m,disabled:r,value:d,onChange:e=>{f(e.target.value),c(e.target.value)}}):(0,q.jsxs)(`div`,{className:`relative flex w-full min-w-0 items-center`,children:[i&&(0,q.jsx)(R,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2 size-lt-icon-md text-lt-muted-fg`}),(0,q.jsx)(pt,{type:e===`number`?`number`:`text`,density:`compact`,"aria-label":p,"data-test":s,className:F(m,i&&`pl-8`,l&&`pr-8`),disabled:r,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&c(d)},onBlur:()=>{d!==n&&c(d)}}),l&&d!==``&&(0,q.jsx)(it,{size:`xs`,icon:`x`,label:u(`table.filter.clear`,`Clear {{label}} filter`,{label:t}),"data-test":s?`${s}-clear`:void 0,className:`absolute right-1 size-6`,disabled:r,onClick:l})]})}function Bd({column:e,clauses:t,processing:n,onAdd:r,onUpdate:i,onRemove:a,onReplace:o,onSearch:s}){let{t:c}=w(`lattice`),{filter:l,label:u}=e.props,d=u??e.key;if(!l)return null;if(l.control===`filter.select`)return(0,q.jsx)(Hd,{column:e,clauses:t,processing:n,onReplace:o,onSearch:s});let f=l.type??`text`,p=l.operators??[],m=l.defaultOperator??p[0]??`eq`,h=t.find(e=>e.clause.operator===m)??t[0];function g(t){if(t===``){h&&a(h.index);return}h?i(h.index,{...h.clause,value:t}):r({field:e.key,operator:m,value:t})}return(0,q.jsxs)(`div`,{className:`flex min-w-0 max-w-80 items-stretch`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(zd,{type:f,label:d,value:h?.clause.value??``,processing:n,withSearchIcon:f===`text`||f===`number`,grouped:!0,testId:`filter-${e.key}-value`,onCommit:g,onClear:h?()=>a(h.index):void 0})}),(0,q.jsxs)(De,{children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(it,{emphasis:`segmented`,size:`md`,icon:`filter`,label:c(`table.filter.column-filters`,`{{label}} filters`,{label:d}),"data-test":`filter-${e.key}`,disabled:n,children:t.length>0&&(0,q.jsx)(`span`,{className:`absolute -right-1.5 -top-1.5 inline-flex size-4 items-center justify-center rounded-full bg-lt-primary text-xs font-medium text-lt-primary-fg`,children:t.length})})}),(0,q.jsx)(B,{align:`start`,className:`w-80 p-4`,children:(0,q.jsx)(Kd,{column:e,clauses:t,operators:p,defaultOperator:m,processing:n,onAdd:r,onUpdate:i,onRemove:a})})]})]})}function Vd(e){return Array.isArray(e)?e.join(`,`):typeof e==`string`?e:``}function Hd({column:e,clauses:t,processing:n,onReplace:r,onSearch:i}){let{filter:a,label:o}=e.props;if(!a)return null;let s=a.multiple,c=a.defaultOperator,l=a.clauseOptions??[],u=Wd(t.map(e=>e.clause),l),d=t.find(e=>e.clause.operator===c)??t[0],f=u?u.value:s?d?.clause.value?d.clause.value.split(`,`):[]:d?.clause.value??``,p={key:e.key,type:`filter.select`,props:{label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null},schema:[{type:`field.select`,key:e.key,props:{name:`value`,label:o,options:a.options,multiple:s,searchable:a.searchable,placeholder:null}}]};function m(t){let n=Vd(ld(t).value);if(n===``){r(e.key,[]);return}let i=l.find(e=>e.value===n);if(i){r(e.key,Ud(e.key,i));return}r(e.key,[{field:e.key,operator:c,value:n}])}return(0,q.jsx)(Fd,{filter:p,value:{value:f},processing:n,bare:!0,onChange:m,onSearch:i?(e,t,n)=>i(t,n):void 0})}function Ud(e,t){return t.clauses.map(t=>({field:e,operator:t.operator,value:t.value}))}function Wd(e,t){return t.find(t=>Gd(e,Ud(``,t)))}function Gd(e,t){return e.length===t.length&&t.every(t=>e.some(e=>e.operator===t.operator&&e.value===t.value))}function Kd({column:e,clauses:t,operators:n,defaultOperator:r,processing:i,onAdd:a,onUpdate:o,onRemove:s}){let{t:c}=w(`lattice`),l=e.props.filter?.type??`text`,[u,d]=(0,G.useState)(r),[f,p]=(0,G.useState)(t.length===0);return(0,q.jsxs)(`div`,{className:`grid gap-3`,children:[t.map(t=>(0,q.jsx)(qd,{column:e,type:l,operators:n,clause:t.clause,processing:i,onOperator:e=>o(t.index,{...t.clause,operator:e}),onValue:e=>e===``?s(t.index):o(t.index,{...t.clause,value:e}),onRemove:()=>s(t.index)},t.index)),f&&(0,q.jsx)(qd,{column:e,type:l,operators:n,clause:{field:e.key,operator:u,value:``},processing:i,onOperator:t=>{if(Sd.has(t)){a({field:e.key,operator:t,value:``}),d(r),p(!1);return}d(t)},onValue:t=>{t!==``&&(a({field:e.key,operator:u,value:t}),d(r),p(!1))},onRemove:()=>p(!1)}),(0,q.jsx)(`div`,{className:`border-t border-lt-border pt-3`,children:(0,q.jsx)(W,{variant:`secondary`,icon:`plus`,"data-test":`filter-${e.key}-add`,className:`w-full`,disabled:i,onClick:()=>p(!0),children:c(`table.filter.add`,`Add filter`)})})]})}function qd({column:e,type:t,operators:n,clause:r,processing:i,onOperator:a,onValue:o,onRemove:s}){let{t:c}=w(`lattice`),l=e.props.label??e.key,u=Sd.has(r.operator);return(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.length>1?(0,q.jsx)(Nd,{density:`compact`,"aria-label":c(`table.filter.operator`,`{{label}} operator`,{label:l}),"data-test":`filter-${e.key}-operator`,className:`flex-1`,disabled:i,value:r.operator,onChange:e=>a(e.target.value),children:n.map(e=>(0,q.jsx)(`option`,{value:e,children:Cd(e)},e))}):(0,q.jsx)(`span`,{className:`flex-1 text-sm font-medium`,children:Cd(r.operator)}),(0,q.jsx)(W,{emphasis:`outline`,size:`icon`,icon:`trash-2`,"aria-label":c(`table.filter.remove`,`Remove {{label}} filter`,{label:l}),"data-test":`filter-${e.key}-remove`,disabled:i,onClick:s})]}),!u&&(0,q.jsx)(zd,{type:t,label:l,ariaLabel:c(`table.filter.value`,`{{label}} filter value`,{label:l}),value:r.value,processing:i,onCommit:o,onClear:()=>o(``)})]})}function Jd({sort:e}){return e?.direction===`asc`?(0,q.jsx)(R,{name:`arrow-up`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):e?.direction===`desc`?(0,q.jsx)(R,{name:`arrow-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0`}):(0,q.jsx)(R,{name:`chevrons-up-down`,"aria-hidden":`true`,className:`size-lt-icon-sm shrink-0 opacity-50`})}function Yd({column:e,processing:t,resizeHandleProps:n,sort:r,query:i}){let a=ud(i,e),{t:o}=w(`lattice`),{align:s,label:c,sortable:l}=e.props;return(0,q.jsxs)(`div`,{"aria-sort":dd(a),className:F(`relative min-w-0 px-4 py-3 pr-5 align-middle font-semibold text-lt-fg`,Vu(s)),role:`columnheader`,children:[l?(0,q.jsxs)(`button`,{type:`button`,"aria-label":o(`table.sort.column`,`Sort {{label}}`,{label:c}),className:F(`flex w-full items-center gap-1.5 font-semibold`,Hu(s)),"data-test":`sort-${e.key}`,disabled:t,onClick:()=>r(e),children:[(0,q.jsx)(`span`,{className:F(`min-w-0 flex-1 truncate`,Vu(s)),children:c}),(0,q.jsx)(Jd,{sort:a})]}):(0,q.jsx)(`span`,{className:F(`block truncate`,Vu(s)),children:c}),n&&(0,q.jsx)(`div`,{...n})]})}function Xd({columns:e,hasHidden:t,isVisible:n,onReset:r,onToggle:i,processing:a,visibleColumnCount:o}){let{t:s}=w(`lattice`),c=s(`table.columns.label`,`Columns`);return(0,q.jsxs)(De,{children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(it,{size:`sm`,icon:`columns-3`,label:c,"data-test":`table-columns-menu`,disabled:a})}),(0,q.jsx)(B,{align:`end`,className:`w-64 p-4`,children:(0,q.jsxs)(`div`,{className:`grid gap-3`,children:[e.map(e=>{let t=n(e),r=t&&o<=1;return(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-base text-lt-fg`,children:[(0,q.jsx)(dc,{"data-test":`table-column-toggle-${e.key}`,checked:t,disabled:r,onCheckedChange:t=>i(e.key,t===!0)}),(0,q.jsx)(`span`,{children:e.props.label??e.key})]},e.key)}),t&&(0,q.jsx)(`button`,{type:`button`,"data-test":`table-columns-reset`,className:`mt-1 justify-self-start text-sm text-lt-muted-fg hover:text-lt-fg`,onClick:r,children:s(`table.columns.reset`,`Reset`)})]})})]})}function Zd({clauses:e,columnsByKey:t,indicators:n,processing:r,onRemoveClause:i,onChange:a,onReset:o}){let{t:s}=w(`lattice`);return e.length===0&&n.length===0?null:(0,q.jsx)(`div`,{className:`border-b border-lt-border px-4 py-3`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[e.map((e,n)=>{let a=t.get(e.field)?.props.label??e.field,o=Sd.has(e.operator);return(0,q.jsx)(Qd,{label:`${a} ${Cd(e.operator)}`,value:o?``:e.value,removeTestId:`filter-chip-${e.field}-remove`,removeLabel:s(`table.filter.remove`,`Remove {{label}} filter`,{label:a}),processing:r,onRemove:()=>i(n)},`${e.field}-${e.operator}-${n}`)}),n.map(e=>(0,q.jsx)(Qd,{label:e.label,value:e.value,removeTestId:`table-filter-chip-${e.filter}-remove`,removeLabel:s(`table.filter.remove`,`Remove {{label}} filter`,{label:e.label}),processing:r,onRemove:()=>a(e.filter,void 0)},`${e.filter}:${e.label}:${e.value}`)),(0,q.jsx)(`button`,{type:`button`,"data-test":`table-filters-reset`,className:`text-lt-muted-fg underline-offset-2 hover:underline disabled:text-lt-disabled-fg`,disabled:r,onClick:o,children:s(`table.filter.reset-all`,`Reset all`)})]})})}function Qd({label:e,value:t,removeTestId:n,removeLabel:r,processing:i,onRemove:a}){return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lt-sm bg-lt-muted px-2 py-1`,children:[(0,q.jsx)(`span`,{children:t===``?(0,q.jsx)(`span`,{className:`font-semibold`,children:e}):(0,q.jsxs)(q.Fragment,{children:[`${e}: `,(0,q.jsx)(`span`,{className:`font-semibold`,children:t})]})}),(0,q.jsx)(it,{size:`xs`,icon:`x`,label:r,"data-test":n,disabled:i,onClick:a})]})}function $d({filters:e,values:t,processing:n,onChange:r,onSearch:i}){let{t:a}=w(`lattice`),o=e.filter(e=>sd(t[e.key])),s=a(`table.filter.filters`,`Filters`);return(0,q.jsxs)(De,{children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(it,{size:`sm`,icon:`filter`,label:s,"data-test":`table-filters-menu`,disabled:n,children:o.length>0&&(0,q.jsx)(`span`,{className:`absolute -right-1 -top-1 inline-flex size-3.5 items-center justify-center rounded-full bg-lt-primary text-[10px] font-medium leading-none text-lt-primary-fg`,children:o.length})})}),(0,q.jsx)(B,{align:`end`,className:`w-80 p-4`,children:(0,q.jsx)(`div`,{className:`grid gap-3`,children:e.map(e=>(0,q.jsx)(`div`,{className:`grid gap-1`,children:(0,q.jsx)(Fd,{filter:e,value:t[e.key],processing:n,onChange:t=>r(e.key,t),onSearch:i?(t,n,r)=>i(`filter:${e.key}.${t}`,n,r):void 0})},e.key))})})]})}function ef({pagination:e,currentPage:t,processing:n,mode:r,hasNextPage:i,visiblePages:a,infiniteLoaderRef:o,perPageOptions:s,perPageValue:c,onPerPage:l,onPage:u,onLoadMore:d}){let{t:f}=w(`lattice`);return(0,q.jsxs)(`div`,{"data-slot":`table-pagination`,className:`flex items-center justify-between gap-3 border-t border-lt-border p-4 text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,q.jsx)(`span`,{children:e.total==null?f(`table.pagination.page`,`Page {{page}}`,{page:t}):f(`table.pagination.showing`,`Showing {{from}}-{{to}} of {{total}}`,{from:e.from??0,to:e.to??0,total:e.total})}),s.length>0&&r!==`none`&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.per-page`,`Rows per page`)}),(0,q.jsx)(Nd,{"data-test":`pagination-per-page`,disabled:n,value:String(c),onChange:e=>l(e.target.value===`infinite`?`infinite`:Number(e.target.value)),children:s.map(e=>(0,q.jsx)(`option`,{value:String(e),children:e===`infinite`?f(`table.pagination.infinite`,`Infinite`):e},String(e)))})]})]}),r===`infinite`?(0,q.jsx)(`div`,{ref:o,className:`flex items-center gap-2`,children:e.hasMore?(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-load-more`,disabled:n,onClick:d,children:n?f(`table.pagination.loading`,`Loading...`):f(`table.pagination.load-more`,`Load more`)}):(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:f(`table.pagination.all-loaded`,`All rows loaded`)})}):r===`simple`?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):r===`table`?(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-previous`,disabled:n||t<=1,onClick:()=>u(t-1),children:f(`table.pagination.previous`,`Previous`)}),a.map(e=>(0,q.jsx)(W,{emphasis:`outline`,size:`icon`,"data-test":`pagination-page-${e}`,disabled:n||e===t,"aria-current":e===t?`page`:void 0,"aria-label":f(`table.pagination.page`,`Page {{page}}`,{page:e}),onClick:()=>u(e),children:e},e)),(0,q.jsx)(W,{emphasis:`outline`,"data-test":`pagination-next`,disabled:n||!i,onClick:()=>u(t+1),children:f(`table.pagination.next`,`Next`)})]}):null]})}function tf({columnsByKey:e,query:t,processing:n,onClear:r}){let{t:i}=w(`lattice`);return(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 border-b border-lt-border px-4 py-2.5 text-sm`,children:t.sorts.map((t,a)=>{let o=e.get(t.key)?.props.label??t.key,s=t.direction===`desc`?`arrow-down`:`arrow-up`;return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`${a+1}. ${o}`}),(0,q.jsx)(R,{name:s,role:`img`,"aria-hidden":!1,"aria-label":wd(t.direction),className:`size-lt-icon-sm text-lt-muted-fg`}),(0,q.jsx)(it,{size:`xs`,icon:`x`,label:i(`table.sort.clear`,`Clear {{label}} sort`,{label:o}),"data-test":`clear-${t.key}-sort`,disabled:n,onClick:()=>r(t)})]},t.key)})})}var nf=300;function rf({value:e,onSearch:t}){let{t:n}=w(`lattice`),[r,i]=(0,G.useState)(e),a=(0,G.useRef)(e);(0,G.useEffect)(()=>{e!==a.current&&(a.current=e,i(e))},[e]);function o(e){a.current=e,t(e)}let s=wa(o,nf);function c(e){i(e),s(e)}function l(){s.cancel(),i(``),o(``)}let u=n(`table.search.placeholder`,`Search`);return(0,q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,q.jsx)(R,{name:`search`,"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 size-lt-icon-sm -translate-y-1/2 text-lt-muted-fg`}),(0,q.jsx)(pt,{type:`search`,"data-test":`table-search`,value:r,placeholder:u,"aria-label":u,onChange:e=>c(e.target.value),className:F(`px-8`,`[&::-webkit-search-cancel-button]:hidden`)}),r!==``&&(0,q.jsx)(it,{size:`xs`,icon:`x`,label:n(`table.search.clear`,`Clear search`),"data-test":`table-search-clear`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,onClick:l})]})}function af(e){return e}function of(e,t,n){if(e==null)return``;let r=t?.props?.date;return r?O(e,r,n):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function sf(e,t,n){let r=e.props.link;if(!r)return null;let i=r.href??String(n??``);return i===``?null:i.replace(/\{([^}]+)\}/g,(e,r)=>encodeURIComponent(String(r===`value`?n??``:t[r]??``)))}var cf=({column:e,props:t,value:n})=>{let r=of(n,e);return r===``?null:(0,q.jsx)(io,{color:t.colors?.[String(n)],children:r})},lf=({value:e})=>{let{t}=w(`lattice`),n=Pd(e);return(0,q.jsx)(`span`,{"aria-label":n?t(`common.yes`,`Yes`):t(`common.no`,`No`),role:`img`,children:(0,q.jsx)(R,{name:n?`check`:`x`,className:F(`size-lt-icon-md`,n?`text-lt-success`:`text-lt-muted-fg`)})})},uf=({props:e,value:t})=>{let n=e.icons?.[String(t)]??e.icon??void 0;if(!n)return null;let r=Tt(e.colors?.[String(t)]),i=r?wt(r):void 0;return(0,q.jsx)(`span`,{"aria-label":String(t),className:F(`lt-cell-icon`,i?.className),style:i?.style,children:(0,q.jsx)(P,{className:`size-lt-icon-md`,icon:n})})},df=({column:e,props:t,value:n})=>{let r=typeof n==`string`?n:``;if(r===``)return null;let i=t.size??32;return(0,q.jsx)(Do,{alt:e.props.label??``,className:F(`object-cover`,t.circular?`rounded-full`:`rounded-lt-sm`),height:i,previewable:t.previewable,src:r,testId:`preview-${e.key}`,width:i})};function ff({children:e,column:t,copyable:n,value:r}){return n?(0,q.jsx)(Co,{value:r,label:t.props.label??t.key,testId:`copy-${t.key}`,children:e}):e}function pf({column:e,copyable:t,format:r,value:i}){let{locale:a}=n();return Ct(i)===null?(0,q.jsx)(`span`,{children:of(i,e)}):(0,q.jsx)(ff,{column:e,copyable:t,value:String(i),children:(0,q.jsx)(`span`,{className:`tabular-nums`,children:Et(i,r,a)})})}var mf=({column:e,props:t,row:n,value:r})=>{let i=t.currencyField?n[t.currencyField]:void 0,a=t.currency??(typeof i==`string`?i:null);return(0,q.jsx)(pf,{column:e,copyable:t.copyable,value:r,format:{kind:`number`,notation:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:a,unit:null}})},hf=({column:e,props:t,value:n})=>(0,q.jsx)(pf,{column:e,copyable:t.copyable,value:n,format:{kind:`number`,notation:t.compact?`compact`:`standard`,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,currency:null,unit:t.unit}}),gf=({column:e,row:t})=>(0,q.jsx)(`div`,{className:`grid gap-1`,children:(0,q.jsx)(J,{nodes:x(e.schema,t)})}),_f=e=>e.props.multiple?(0,q.jsx)(yf,{...e}):e.props.badge?(0,q.jsx)(bf,{...e}):(0,q.jsx)(xf,{...e});function vf({label:e,color:t}){return e===``?null:(0,q.jsx)(io,{color:t,children:e})}function yf({column:e,props:t,value:n}){let r=Array.isArray(n)?n:[];return r.length===0?null:t.badge?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map((t,n)=>{let r=t;return(0,q.jsx)(vf,{label:of(r.value,e),color:r.color},n)})}):(0,q.jsx)(`span`,{children:r.map(t=>of(t,e)).join(`, `)})}function bf({column:e,props:t,row:n,value:r}){let i=t.badge.colorKey;return(0,q.jsx)(vf,{label:of(r,e),color:String(n[i]??``)})}function xf({column:e,props:t,row:n,value:r}){let i=e.props.date,a=sf(e,n,r),o=of(r,e),s=a?(0,q.jsx)(`a`,{className:`underline underline-offset-2`,href:a,rel:t.link?.external?`noreferrer`:void 0,target:t.link?.external?`_blank`:void 0,children:o}):o;return i&&!a&&!t.copyable&&r!=null?(0,q.jsx)(Hr,{value:r,dateStyle:i.dateStyle,timeStyle:i.timeStyle}):(0,q.jsx)(ff,{column:e,copyable:t.copyable,value:o,children:s})}var Sf={"column.badge":af(cf),"column.boolean":af(lf),"column.icon":af(uf),"column.image":af(df),"column.money":af(mf),"column.number":af(hf),"column.stack":af(gf),"column.text":af(_f)};function Cf({column:e,row:t}){let n=h()[e.type]??Sf[e.type]??Sf[`column.text`];return(0,q.jsx)(n,{column:e,props:e.props,row:t,value:t[e.key]})}var wf=vn(as,Ra,fu,pi,_n({components:{table:K(({node:e})=>{let{t}=w(`lattice`),{columns:n,rows:r,pagination:i,query:a,filters:o,tableFilters:s,search:c,addFilter:l,updateFilter:u,removeFilter:d,replaceColumnFilters:f,setTableFilter:p,resetFilters:m,setSearch:h,searchFilterOptions:g,processing:_,hasLoaded:v,infiniteLoaderRef:y,sort:b,clearSort:x,goToPage:S,setPerPage:C,loadMore:T}=Ad(e),E=(0,G.useMemo)(()=>Wu(e.props?.bulkActions),[e.props?.bulkActions]),D=E.length>0,O=(0,G.useMemo)(()=>r.map((e,t)=>({row:e,actions:rd(e),detail:id(e),key:nd(e,t)})),[r]),k=jd(O.map(e=>e.key)),{isExpanded:A,toggle:j}=Lu(),M=O.some(e=>e.detail!=null),P=(0,G.useMemo)(()=>new Map(n.map(e=>[e.key,e])),[n]),I=N(e),{hasToggleableColumns:L,hasHidden:ee,isVisible:te,resetVisibility:ne,setColumnVisible:re,toggleableColumns:ie,visibleColumns:z}=Mu({columns:n,storageKey:I?`lattice:table-column-visibility:${I}`:void 0}),ae=i.currentPage??a.page,oe=i.lastPage??ae,se=i.mode??`table`,ce=(0,G.useMemo)(()=>$u(e.props?.perPageOptions),[e.props?.perPageOptions]),le=Ed(ae,oe),ue=i.hasMore??ae<oe,de=O.some(e=>e.actions.length>0),fe=e.props?.striped===!0,B=z.some(e=>e.props.filter!=null),pe=o.map((e,t)=>({clause:e,index:t})),me=(0,G.useMemo)(()=>Array.isArray(e.props?.filters)?e.props.filters:[],[e.props?.filters]),he=me.length>0,V=de||he||L,ge=(0,G.useMemo)(()=>Dd(z),[z]),_e=(0,G.useMemo)(()=>kd(V,D,M),[V,D,M]),ve=e.props?.resizableColumns===!0,ye=N(e),{getResizeHandleProps:be,gridTemplateColumns:xe,hasOverrides:Se,resizeRootRef:Ce,resetColumns:we}=Cs({columns:ge,enabled:ve,leadingTracks:_e.leadingTracks,showIndicator:e.props?.resizeIndicator===!0,storageKey:ve&&ye?`lattice:table-columns:${ye}`:void 0,trailingTracks:_e.trailingTracks});return(0,q.jsxs)(`div`,{"data-slot":`table`,"data-lattice-component":e.id,className:`relative`,children:[Se&&(0,q.jsx)(`button`,{"aria-label":t(`table.reset-column-widths`,`Reset column widths`),className:`absolute right-1 top-1 z-10 hidden rounded-lt-sm p-1 text-lt-muted-fg hover:text-lt-fg md:inline-flex`,"data-test":`table-reset-columns`,onClick:we,title:t(`table.reset-column-widths`,`Reset column widths`),type:`button`,children:(0,q.jsx)(R,{name:`rotate-ccw`,className:`size-lt-icon-sm`})}),(0,q.jsxs)(`div`,{"data-slot":`table-scroll`,className:`overflow-x-auto rounded-lt-sm border border-lt-border`,children:[e.props?.searchable&&(0,q.jsx)(`div`,{"data-slot":`table-toolbar`,className:`flex items-center gap-2 border-b border-lt-border px-4 py-2`,children:(0,q.jsx)(rf,{value:c,onSearch:h})}),(0,q.jsx)(Zd,{clauses:o,columnsByKey:P,indicators:a.tableFilterIndicators,processing:_,onRemoveClause:d,onChange:p,onReset:m}),D&&k.active&&(0,q.jsx)(Md,{actions:E,selectedKeys:k.selectedKeys,allMatching:k.allMatching,total:i.total??void 0,query:vd(a),canSelectAllMatching:k.allVisibleSelected&&!k.allMatching&&i.total!=null&&i.total>k.selectedKeys.length,onSelectAllMatching:k.selectAllMatching,onCompleted:k.clear}),a.sorts.length>0&&(0,q.jsx)(tf,{columnsByKey:P,query:a,processing:_,onClear:x}),(0,q.jsxs)(`div`,{ref:Ce,className:`min-w-full text-base`,role:`table`,style:{"--lattice-table-columns":xe},children:[(0,q.jsxs)(`div`,{"data-slot":`table-header`,className:`border-b border-lt-border bg-lt-muted/50`,role:`rowgroup`,children:[(0,q.jsxs)(`div`,{className:`hidden min-w-full md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[M&&(0,q.jsx)(`div`,{className:`px-2 py-3`,role:`columnheader`,"aria-hidden":`true`}),D&&(0,q.jsx)(`div`,{className:`flex items-center px-4 py-3`,role:`columnheader`,children:(0,q.jsx)(dc,{"aria-label":t(`table.select-all-rows`,`Select all rows`),"data-test":`select-all`,checked:k.allSelected,onCheckedChange:()=>k.toggleAll()})}),z.map((e,t)=>(0,q.jsx)(Yd,{column:e,processing:_,resizeHandleProps:ve?be(ge[t]):void 0,sort:b,query:a},e.key)),V&&(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 py-2 align-middle font-semibold text-lt-fg`,role:`columnheader`,children:[he&&(0,q.jsx)($d,{filters:me,values:s,processing:_,onChange:p,onSearch:g}),L&&(0,q.jsx)(Xd,{columns:ie,isVisible:te,visibleColumnCount:z.length,hasHidden:ee,onToggle:re,onReset:ne,processing:_}),de&&(0,q.jsx)(`span`,{className:`sr-only`,children:e.props?.actionsLabel??t(`table.actions`,`Actions`)})]})]}),B&&(0,q.jsxs)(`div`,{className:`hidden min-w-full border-t border-lt-border md:grid md:grid-cols-[var(--lattice-table-columns)]`,role:`row`,children:[M&&(0,q.jsx)(`div`,{className:`px-2 py-2`,role:`cell`}),D&&(0,q.jsx)(`div`,{className:`px-4 py-2`,role:`cell`}),z.map(e=>(0,q.jsx)(`div`,{className:`min-w-0 px-2 py-2`,role:`cell`,children:e.props.filter!=null&&(0,q.jsx)(Bd,{column:e,clauses:pe.filter(t=>t.clause.field===e.key),processing:_,onAdd:l,onUpdate:u,onRemove:d,onReplace:f,onSearch:(t,n)=>g(`column:${e.key}`,t,n)})},e.key)),V&&(0,q.jsx)(`div`,{className:`px-4 py-2`,role:`cell`})]})]}),(0,q.jsx)(`div`,{role:`rowgroup`,children:v?O.length===0?(0,q.jsx)(`div`,{"data-slot":`table-empty`,className:`p-8 text-center text-lt-muted-fg`,role:`row`,children:(0,q.jsx)(`div`,{role:`cell`,children:e.props?.emptyLabel??t(`table.empty`,`No results`)})}):O.map(({row:n,actions:r,detail:i,key:a})=>{let o=i!=null&&A(a),s=`${N(e)??`table`}-row-detail-${a}`;return(0,q.jsxs)(G.Fragment,{children:[(0,q.jsxs)(`div`,{"data-slot":`table-row`,className:`grid grid-cols-1 border-b border-lt-border last:border-b-0 md:grid-cols-[var(--lattice-table-columns)] ${fe?`odd:bg-lt-muted/30`:``}`,role:`row`,children:[M&&(0,q.jsx)(`div`,{className:`flex items-center px-2 py-lt-cell-y`,role:`cell`,children:i&&(0,q.jsx)(`button`,{type:`button`,"data-test":`row-expand-${a}`,"aria-expanded":o,"aria-controls":s,"aria-label":t(`table.row-detail.toggle`,`Toggle detail`),className:`inline-flex size-6 items-center justify-center rounded-lt-sm text-lt-muted-fg hover:bg-lt-muted hover:text-lt-fg`,onClick:()=>j(a),children:(0,q.jsx)(R,{name:`chevron-down`,"aria-hidden":`true`,className:F(`size-lt-icon-md transition-transform`,!o&&`-rotate-90`)})})}),D&&(0,q.jsx)(`div`,{className:`flex items-center px-lt-cell-x py-lt-cell-y`,role:`cell`,children:(0,q.jsx)(dc,{"aria-label":t(`table.select-row`,`Select row {{key}}`,{key:a}),"data-test":`select-row-${a}`,checked:k.isSelected(a),onCheckedChange:()=>k.toggle(a)})}),z.map(e=>(0,q.jsxs)(`div`,{"data-slot":`table-cell`,className:F(`grid min-w-0 gap-1 overflow-hidden px-lt-cell-x py-lt-cell-y align-middle`,Vu(e.props.align),Uu(e.props.align)),role:`cell`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs font-medium text-lt-muted-fg md:hidden`,children:e.props.label}),(0,q.jsx)(`div`,{"data-slot":`table-cell-content`,className:`min-w-0 max-w-full overflow-hidden truncate`,children:(0,q.jsx)(Cf,{column:e,row:n})})]},e.key)),V&&(0,q.jsx)(`div`,{className:F(`items-center justify-start gap-2 px-lt-cell-x py-lt-cell-y md:justify-end`,r.length>0?`flex`:`hidden md:flex`),role:`cell`,children:r.map((e,t)=>(0,q.jsx)(Y,{node:e},e.key??e.id??t))})]}),o&&i&&(0,q.jsx)(`div`,{id:s,role:`region`,"data-slot":`table-row-detail`,className:`border-b border-lt-border bg-lt-muted/20 px-lt-cell-x py-lt-cell-y`,children:(0,q.jsx)(J,{nodes:[i]})})]},a)}):(0,q.jsx)(`div`,{className:`p-4 text-lt-muted-fg`,role:`row`,children:(0,q.jsx)(`div`,{role:`cell`,children:t(`table.loading`,`Loading rows...`)})})})]}),v&&(0,q.jsx)(ef,{pagination:i,currentPage:ae,processing:_,mode:se,hasNextPage:ue,visiblePages:le,infiniteLoaderRef:y,perPageOptions:ce,perPageValue:se===`infinite`?`infinite`:a.perPage,onPerPage:C,onPage:S,onLoadMore:T})]})]})})},name:`lattice/table`}),$a,Ou,ju);function Tf(e,t){if(t.length===0)return e;let n=new Set([...e.namespaces??[`lattice`],...t.map(e=>e.namespace)]);return{...e,namespaces:[...n]}}function Ef({ready:e,children:t}){let[n,r]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{let t=!0,n=()=>{t&&r(!0)};return e.then(n,n),()=>{t=!1}},[e]),n?t:null}function Df({registry:e,plugins:t,sprite:n,pages:r={},defaultLayout:i,strictMode:a=!0,i18n:o,boot:c,wrap:u,...d}={}){let f=e??wf,p=t&&t.length>0?yn(f,...t):f;s(p),Ci();let m=o!==!1,h=t?.flatMap(e=>e.i18n?[e.i18n]:[])??[],g=m?Tf(o??{},h):{},_=d.defaults?.visitOptions,v=m?{...d.defaults,visitOptions:(e,t)=>xi(e,_?.(e,t)??t)}:d.defaults,y=l({...d,defaults:v,strictMode:a,resolve:yi(r),layout:bi({defaultLayout:i}),withApp:(e,{ssr:t,page:r})=>{let i=[];if(!t){let e=r.props.lattice;S(e)&&S(e.urls)&&typeof e.urls.refreshRef==`string`&&Bt(e.urls.refreshRef),m&&k(r.props)!==void 0&&i.push(tn(()=>import(`./chunks/page-props-nxR5n6k4.js`).then(e=>e.configureI18nFromPageProps(r.props,g)),__vite__mapDeps([20,4,1,5,6,21,10]),import.meta.url));let t=c?.({page:r});t&&i.push(t)}let a=(0,q.jsxs)(q.Fragment,{children:[e,m?(0,q.jsx)(xn,{}):null]}),o=(0,q.jsx)(La,{registry:p,sprite:n,children:u?u(a):a});return i.length>0?(0,q.jsx)(Ef,{ready:Promise.all(i),children:o}):o}});return gn(),y}function Of(){return console.warn(`[lattice] The data-lattice-config script holds invalid JSON; booting with defaults.`),{}}function kf(e){let t=e.querySelector(`script[data-lattice-config]`);if(!t?.textContent)return{};try{let e=JSON.parse(t.textContent);return typeof e!=`object`||!e||Array.isArray(e)?Of():e}catch{return Of()}}var Af=kf(document);async function jf(){if(Af.refreshRefUrl&&Bt(Af.refreshRefUrl),Af.echo)try{let{configureEcho:e}=await tn(async()=>{let{configureEcho:e}=await import(`./chunks/dist-DqlcM-vw.js`);return{configureEcho:e}},__vite__mapDeps([8,1]),import.meta.url);e(Af.echo)}catch(e){console.warn(`[lattice] Failed to load the realtime chunk; continuing without Echo.`,e)}Df({...Af.spriteUrl?{sprite:{href:Af.spriteUrl}}:{},defaults:{visitOptions:xi}})}jf();