@lattice-php/lattice 0.37.0 → 0.38.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,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./chunks/subscriptions-4IpkpPX3.js","./chunks/react-SIfiwpqq.js","./chunks/use-effect-dispatcher-BMWOfaFE.js","./chunks/locale-GyqtaX1O.js","./chunks/react-dom-DJCfT20h.js","./chunks/instance-C4O1XWa6.js","./chunks/timezone-CyoBch3a.js","./chunks/jsx-runtime-0vZSBttN.js","./chunks/translatable-DLw4h3x8.js","./chunks/dist-DqlcM-vw.js","./chunks/chart-view-CFV7BU_D.js","./chunks/materialize-CWqnSEHR.js","./chunks/test-id-Dh3L6Gfh.js","./chunks/number-BvVKQqOG.js","./chunks/with-selector-zFUY-tQj.js","./chunks/code-block-view-D464jtHN.js","./chunks/w3c-keyname-BOAvb0qz.js","./chunks/date-picker-field-DepKtR_m.js","./chunks/dist-BtOmkEqQ.js","./chunks/time-picker-DUjYyeeP.js","./chunks/rich-editor-field-BZQIPOLc.js","./chunks/use-dependent-field-DvH7mUyx.js","./chunks/notifications-echo-uU87iJAV.js","./chunks/page-props-BHNNVkgJ.js","./chunks/shared-props-B_wT1GcG.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./chunks/subscriptions-4IpkpPX3.js","./chunks/react-SIfiwpqq.js","./chunks/use-effect-dispatcher-BMWOfaFE.js","./chunks/locale-GyqtaX1O.js","./chunks/react-dom-DJCfT20h.js","./chunks/instance-C4O1XWa6.js","./chunks/timezone-CyoBch3a.js","./chunks/jsx-runtime-0vZSBttN.js","./chunks/translatable-DLw4h3x8.js","./chunks/dist-DqlcM-vw.js","./chunks/chart-view-CFV7BU_D.js","./chunks/materialize-CWqnSEHR.js","./chunks/test-id-Dh3L6Gfh.js","./chunks/number-BvVKQqOG.js","./chunks/with-selector-zFUY-tQj.js","./chunks/code-block-view-fzD5e55N.js","./chunks/w3c-keyname-BOAvb0qz.js","./chunks/date-picker-field-DepKtR_m.js","./chunks/dist-BtOmkEqQ.js","./chunks/time-picker-DUjYyeeP.js","./chunks/rich-editor-field-BZQIPOLc.js","./chunks/use-dependent-field-DvH7mUyx.js","./chunks/notifications-echo-uU87iJAV.js","./chunks/page-props-BHNNVkgJ.js","./chunks/shared-props-B_wT1GcG.js"])))=>i.map(i=>d[i]);
2
2
  import{i as e,t}from"./chunks/react-SIfiwpqq.js";import{a as n,n as r,o as i,s as a}from"./chunks/locale-GyqtaX1O.js";import{t as o}from"./chunks/react-dom-DJCfT20h.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-BMWOfaFE.js";import{n as x,t as S}from"./chunks/materialize-CWqnSEHR.js";import{o as C,r as w,s as T}from"./chunks/instance-C4O1XWa6.js";import{a as E,i as D,n as O,r as k}from"./chunks/timezone-CyoBch3a.js";import{t as A}from"./chunks/shared-props-B_wT1GcG.js";import{i as j,n as M,r as N,t as P}from"./chunks/test-id-Dh3L6Gfh.js";import{_ as F,b as I,g as L,h as R,i as ee,n as te,r as ne,t as re,v as z,y as B}from"./chunks/dist-BtOmkEqQ.js";import{t as ie}from"./chunks/jsx-runtime-0vZSBttN.js";import{n as V,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 pe,H as me,I as he,J as ge,K as _e,L as ve,M as ye,N as be,O as xe,P as Se,Q as Ce,R as we,S as Te,T as Ee,U as De,V as Oe,W as ke,X as Ae,Y as je,Z as Me,_ as Ne,a as Pe,at as Fe,b as Ie,c as Le,ct as H,d as Re,dt as U,et as ze,f as Be,g as Ve,h as He,i as Ue,it as We,j as Ge,k as Ke,l as qe,lt as Je,m as Ye,n as Xe,nt as Ze,o as Qe,ot as $e,p as et,q as tt,r as nt,rt,s as it,st as at,t as ot,tt as st,u as ct,ut as lt,v as ut,w as dt,x as ft,y as pt,z as mt}from"./chunks/use-dependent-field-DvH7mUyx.js";import{a as ht,c as W,i as gt,l as _t,n as vt,o as yt,r as bt,s as xt,t as St}from"./chunks/time-picker-DUjYyeeP.js";import{a as Ct,i as wt,n as Tt,o as Et,r as Dt,t as Ot}from"./chunks/number-BvVKQqOG.js";var kt=`X-Lattice-Ref`,At=new Map;function jt(e){return At.get(e)??e}function Mt(e,t){At.set(e,t)}function Nt(e){let t=jt(e);return t?{[kt]:t}:{}}function Pt(e=``,t={}){return{...r(),...Nt(e),...t}}var Ft=class extends Error{response;constructor(e){super(`HTTP ${e.status}`),this.response=e}};function It(){let e=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return e?decodeURIComponent(e[1]):``}var Lt=1e4,Rt=new Map,zt=new Map;function Bt(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":It()}}var Vt=`/lattice/refs/refresh`;function Ht(e){Vt=e}var Ut=new Map;async function Wt(e){let t=Ut.get(e);if(t)return t;let n=Kt(Vt,{method:`POST`,body:JSON.stringify({ref:jt(e)})}).then(t=>(Mt(e,t.ref),t.ref)).catch(()=>null).finally(()=>{Ut.delete(e)});return Ut.set(e,n),n}async function Gt(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:Pt(n,{...Bt(s),...r})}),l=await c();if(n!==``&&l.status===403&&await Wt(n)!==null&&(l=await c()),i&&!l.ok)throw new Ft(l);return l}async function Kt(e,t){return(await Gt(e,t)).json()}function qt(e){return[e.source,e.audience,[...e.scopes].sort().join(` `)].join(``)}function Jt(e){Rt.delete(qt(e))}async function Yt(e){let t=qt(e),n=Rt.get(t);if(n&&n.expiresAt>Date.now()+Lt)return n.token;let r=zt.get(t);if(r)return r;let i=Kt(e.tokenEndpoint,{method:`POST`,ref:e.ref,body:JSON.stringify({nodeId:e.nodeId,nodeType:e.nodeType,audience:e.audience,scopes:e.scopes})}).then(e=>(Rt.set(t,{token:e,expiresAt:Date.now()+Math.max(0,e.expiresIn)*1e3}),e)).finally(()=>{zt.delete(t)});return zt.set(t,i),i}function Xt(e){return e.status===401||e.status===403}async function Zt(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 Qt(e,t){let{remote:n,throwOnError:r=!0,...i}=t,a=await Yt(n),o=await Zt(e,i,a);if(Xt(o)&&(Jt(n),a=await Yt(n),o=await Zt(e,i,a)),r&&!o.ok)throw new Ft(o);return o}async function $t(e,t){return(await Qt(e,t)).json()}var G=e(t(),1),en=`modulepreload`,tn=function(e,t){return new URL(e,t).href},nn={},rn=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=tn(t,n),t=s(t),t in nn)return;nn[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`:en,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)})},an=[`light`,`dark`,`system`],{subscribe:on,notify:sn}=i(),cn=`system`;function ln(e){un(e)}function un(e){return an.some(t=>t===e)}var dn=()=>typeof window>`u`?!1:window.matchMedia(`(prefers-color-scheme: dark)`).matches,fn=(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`},pn=()=>{if(typeof window>`u`)return`system`;let e=localStorage.getItem(`appearance`);return un(e)?e:`system`},mn=e=>e===`dark`||e===`system`&&dn(),hn=e=>{if(typeof document>`u`)return;let t=mn(e);document.documentElement.classList.toggle(`dark`,t),document.documentElement.style.colorScheme=t?`dark`:`light`},gn=()=>typeof window>`u`?null:window.matchMedia(`(prefers-color-scheme: dark)`),_n=()=>{hn(cn),sn()};function vn(e){cn=e,localStorage.setItem(`appearance`,e),fn(`appearance`,e),hn(e),sn()}function yn(){typeof window>`u`||(localStorage.getItem(`appearance`)||(localStorage.setItem(`appearance`,`system`),fn(`appearance`,`system`)),cn=pn(),hn(cn),gn()?.addEventListener(`change`,_n))}function K(e){return{component:e,mode:`eager`}}function bn(e){return e}function xn(...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 Sn(e,...t){let n=xn(...t);return{components:{...e.components,...n.components},columns:{...e.columns,...n.columns},effects:{...e.effects,...n.effects}}}function Cn(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 wn({preserveScroll:e=!0,preserveState:t=!0}){return Cn(a.localeChange,n=>{let r=n.detail?.locale;typeof r==`string`&&r!==``&&p.visit(window.location.href,{preserveScroll:e,preserveState:t})}),null}function Tn(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`):[]}function En(e,t){return e.key??e.id??`${e.type}-${t}`}var Dn=(0,G.createContext)(!1);function On(){return(0,G.useContext)(Dn)}var q=ie();function kn(){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 An({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)(kn,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]})}function J({nodes:e}){return e.map((e,t)=>(0,q.jsx)(jn,{node:e},En(e,t)))}function Y({node:e}){return(0,q.jsx)(jn,{node:e})}var jn=(0,G.memo)(function({node:e}){let t=On(),n=v()[e.type];if(t&&e.props?.hideWhenCollapsed===!0)return null;if(!n)return(0,q.jsx)(An,{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});return n.mode===`lazy`?(0,q.jsx)(G.Suspense,{fallback:null,children:a}):a}),Mn=[`primary`,`secondary`,`success`,`info`,`warning`,`danger`];function Nn(e){return Mn.some(t=>t===e)}function Pn(e){let t=typeof e==`string`||ae(e)?e:null;return t===``?null:t}function Fn(e,t,n){let r=e=>{let r=t(e.detail);r!==null&&n(r)};return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}function In(e){if(typeof e!=`object`||!e)return null;let t=e,n=Pn(t.message);return n===null?null:{action:t.action??null,dismissible:t.dismissible!==!1,duration:typeof t.duration==`number`?t.duration:null,message:n,persistent:t.persistent===!0,variant:Nn(t.variant)?t.variant:`success`}}function Ln(e){return Fn(a.toast,In,e)}function Rn(e){if(typeof e!=`object`||!e)return null;let t=e,n=Pn(t.message);return n===null?null:{action:t.action??null,dismissible:t.dismissible!==!1,message:n,title:typeof t.title==`string`||ae(t.title)?t.title:null,unique:typeof t.unique==`string`?t.unique:null,variant:Nn(t.variant)?t.variant:`info`}}function zn(e){return Fn(a.callout,Rn,e)}function Bn(e){return Fn(a.retractCallout,e=>{let t=e?.unique;return typeof t==`string`?t:null},e)}var Vn=Object.defineProperty,X=(e,t)=>Vn(e,`name`,{value:t,configurable:!0});function Hn(e){let t=e+`CollectionProvider`,[n,r]=lt(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=R(s),l=G.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=L(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=R(u),p=G.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=G.useRef(null),s=L(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(Hn,`createCollection`);var Un=new WeakMap,Wn=class e extends Map{static{X(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Un.set(this,!0)}set(e,t){return Un.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=qn(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=Gn(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Gn(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Gn(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 Gn(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Kn(e,t);return n===-1?void 0:e[n]}X(Gn,`at`);function Kn(e,t){let n=e.length,r=qn(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}X(Kn,`toSafeIndex`);function qn(e){return e!==e||e===0?0:Math.trunc(e)}X(qn,`toSafeInteger`);function Jn(e){let t=e+`CollectionProvider`,[n,r]=lt(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Wn,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=L(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=R(l),d=G.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=L(t,i.collectionRef);return(0,q.jsx)(u,{ref:o,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=R(f),m=G.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=G.useRef(null),[s,c]=G.useState(null),l=L(t,o,c),{setItemMap:u}=a(f,n),d=G.useRef(i);Yn(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(Zn):(t.set(s,{...e,element:s}),t.toSorted(Zn)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Wn(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 Wn)}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(Jn,`createCollection`);function Yn(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(Yn,`shallowEqual`);function Xn(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}X(Xn,`isElementPreceding`);function Zn(e,t){return!e[1].element||!t[1].element?0:Xn(e[1].element,t[1].element)?-1:1}X(Zn,`sortByDocumentPosition`);function Qn(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}X(Qn,`getChildListObserver`);var $n=Object.defineProperty,er=(e,t)=>$n(e,`name`,{value:t,configurable:!0}),tr=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`}),nr=G.forwardRef(er(function(e,t){return(0,q.jsx)(H.span,{...e,ref:t,style:{...tr,...e.style}})},`VisuallyHidden`)),rr=e(o(),1),ir=Object.defineProperty,Z=(e,t)=>ir(e,`name`,{value:t,configurable:!0}),ar=`ToastProvider`,[or,sr,cr]=Hn(`Toast`),[lr,ur]=lt(`Toast`,[cr]),[dr,fr]=lr(ar),pr=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 \`${ar}\`. Expected non-empty \`string\`.`),(0,q.jsx)(or.Provider,{scope:t,children:(0,q.jsx)(dr,{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`),mr=`ToastViewport`,hr=[`F8`],gr=`toast.viewportPause`,_r=`toast.viewportResume`,vr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,hotkey:r=hr,label:i=`Notifications ({hotkey})`,...a}=e,o=fr(mr,n),s=sr(n),c=G.useRef(null),l=G.useRef(null),u=G.useRef(null),d=G.useRef(null),f=L(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(gr);t.dispatchEvent(e),o.isClosePausedRef.current=!0}},`handlePause`),r=Z(()=>{if(o.isClosePausedRef.current){let e=new CustomEvent(_r);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,...Br(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);Vr(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)(rt,{ref:c,role:`region`,"aria-label":i.replace(`{hotkey}`,p),tabIndex:-1,style:{pointerEvents:m?void 0:`none`},children:[m&&(0,q.jsx)(br,{ref:l,onFocusFromOutsideViewport:()=>{Vr(h({tabbingDirection:`forwards`}))}}),(0,q.jsx)(or.Slot,{scope:n,children:(0,q.jsx)(H.ol,{tabIndex:-1,...a,ref:f})}),m&&(0,q.jsx)(br,{ref:u,onFocusFromOutsideViewport:()=>{Vr(h({tabbingDirection:`backwards`}))}})]})},`ToastViewport`)),yr=`ToastFocusProxy`,br=G.forwardRef(Z(function(e,t){let{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,a=fr(yr,n);return(0,q.jsx)(nr,{tabIndex:0,...i,ref:t,style:{position:`fixed`},onFocus:e=>{let t=e.relatedTarget;a.viewport?.contains(t)||r()}})},`ToastFocusProxy`)),xr=`Toast`,Sr=`toast.swipeStart`,Cr=`toast.swipeMove`,wr=`toast.swipeCancel`,Tr=`toast.swipeEnd`,Er=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:xr});return(0,q.jsx)(ze,{present:n||s,children:(0,q.jsx)(kr,{open:s,...o,ref:t,onClose:()=>c(!1),onPause:at(e.onPause),onResume:at(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`)),[Dr,Or]=lr(xr,{onClose(){}}),kr=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=fr(xr,n),g=sr(n),[_,v]=G.useState(null),y=L(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=at(()=>{_?.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(gr,n),e.addEventListener(_r,t),()=>{e.removeEventListener(gr,n),e.removeEventListener(_r,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(()=>_?Fr(_):null,[_]);return h.viewport?(0,q.jsxs)(q.Fragment,{children:[A&&(0,q.jsx)(Ar,{__scopeToast:n,role:`status`,"aria-live":r===`foreground`?`assertive`:`polite`,children:A}),(0,q.jsx)(Dr,{scope:n,onClose:O,children:rr.createPortal((0,q.jsx)(or.ItemSlot,{scope:n,children:(0,q.jsx)(Fe,{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,Ir(Cr,d,f,{discrete:!1})):Lr(l,h.swipeDirection,c)?(x.current=l,Ir(Sr,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};Lr(t,h.swipeDirection,h.swipeThreshold)?Ir(Tr,p,r,{discrete:!0}):Ir(wr,f,r,{discrete:!0}),n.addEventListener(`click`,e=>e.preventDefault(),{once:!0})}})})})}),h.viewport)})]}):null},`ToastImpl`)),Ar=Z(e=>{let{__scopeToast:t,children:n,...r}=e,i=fr(xr,t),[a,o]=G.useState(!1),[s,c]=G.useState(!1);return Rr(()=>o(!0)),G.useEffect(()=>{let e=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(e)},[]),s?null:(0,q.jsx)(st,{asChild:!0,container:i.announcerContainer||void 0,children:(0,q.jsx)(nr,{...r,children:a&&(0,q.jsxs)(q.Fragment,{children:[i.label,` `,n]})})})},`ToastAnnounce`),jr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e;return(0,q.jsx)(H.div,{...r,ref:t})},`ToastTitle`)),Mr=`ToastClose`,Nr=G.forwardRef(Z(function(e,t){let{__scopeToast:n,...r}=e,i=Or(Mr,n);return(0,q.jsx)(Pr,{asChild:!0,children:(0,q.jsx)(H.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,i.onClose)})})},`ToastClose`)),Pr=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 Fr(e){let t=[];return Array.from(e.childNodes).forEach(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent&&t.push(e.textContent),zr(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(...Fr(e))}}),t}Z(Fr,`getAnnounceTextContent`);function Ir(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?Je(i,a):i.dispatchEvent(a)}Z(Ir,`handleAndDispatchCustomEvent`);var Lr=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 Rr(e=()=>{}){let t=at(e);Ze(()=>{let e=0,n=0;return e=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(e),window.cancelAnimationFrame(n)}},[t])}Z(Rr,`useNextFrame`);function zr(e){return e.nodeType===e.ELEMENT_NODE}Z(zr,`isHTMLElement`);function Br(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(Br,`getTabbableCandidates`);function Vr(e){let t=document.activeElement;return e.some(e=>e===t||(e.focus(),document.activeElement!==t))}Z(Vr,`focusFirst`);var Hr=pr,Ur=vr,Wr=Er,Gr=jr,Kr=Nr;function qr({value:e,dateStyle:t=`medium`,timeStyle:r=`short`}){let{locale:i}=n(),{timezone:a}=O();if(e==null||e===``)return null;let o={locale:i,timeZone:a},s=k(e,{dateStyle:t,timeStyle:r},o),c=Jr(e),l=D(e,o);return(0,q.jsx)(`time`,{dateTime:c??void 0,title:l||void 0,children:s})}function Jr(e){return E(e)?.toISOString()??null}var Yr={primary:{accent:`border-l-lt-primary`,icon:(0,q.jsx)(z,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-primary`})},secondary:{accent:`border-l-lt-secondary`,icon:(0,q.jsx)(z,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-muted-fg`})},success:{accent:`border-l-lt-success`,icon:(0,q.jsx)(z,{name:`circle-check`,className:`size-lt-icon-lg shrink-0 text-lt-success`})},info:{accent:`border-l-lt-info`,icon:(0,q.jsx)(z,{name:`info`,className:`size-lt-icon-lg shrink-0 text-lt-info`})},warning:{accent:`border-l-lt-warning`,icon:(0,q.jsx)(z,{name:`circle-alert`,className:`size-lt-icon-lg shrink-0 text-lt-warning`})},danger:{accent:`border-l-lt-danger`,icon:(0,q.jsx)(z,{name:`circle-x`,className:`size-lt-icon-lg shrink-0 text-lt-danger`})}},Xr=0;function Zr({duration:e=4e3}){let{t}=T(`lattice`),[n,r]=(0,G.useState)([]);function i(e){r(t=>t.filter(t=>t.id!==e))}return(0,G.useEffect)(()=>Ln(e=>{r(t=>[...t,{...e,id:Xr++}])}),[]),(0,q.jsxs)(Hr,{duration:e,swipeDirection:`down`,children:[n.map(n=>(0,q.jsxs)(Wr,{className:I(`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`,Yr[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:[Yr[n.variant].icon,(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,q.jsx)(Gr,{className:`text-sm text-lt-fg`,children:V(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)(Kr,{"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)(z,{name:`x`,className:`size-lt-icon-md`})}):null]},n.id)),(0,q.jsx)(Ur,{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,$r=()=>{let{t:e}=T(`lattice`),[t,n]=(0,G.useState)([]);(0,G.useEffect)(()=>zn(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)(()=>Bn(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:I(`flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg`,Yr[t.variant].accent),children:[Yr[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:V(t.title,e)}):null,(0,q.jsx)(`p`,{className:`text-sm text-lt-fg`,children:V(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)(z,{name:`x`,className:`size-lt-icon-md`})}):null]},t.id))})},ei=({node:e})=>{let{t}=T(`lattice`),n=u().props.lattice?.breadcrumbs??[];return n.length===0?null:(0,q.jsx)(`nav`,{"aria-label":t(`common.breadcrumb`,`Breadcrumb`),"data-lattice-component":P(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 ti({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)(ke,{open:c,onOpenChange:l,children:[(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(`button`,{"aria-label":s,className:I(`w-full`,o),"data-test":i,title:s,type:`button`,children:a})}),(0,q.jsx)(pe,{align:e,className:I(`min-w-56 p-1`,n),role:`menu`,side:r,children:(0,q.jsx)(Dn.Provider,{value:!1,children:t})})]})}var ni=({children:e,node:t})=>{let n=t.key??`dropdown`;return(0,q.jsx)(ti,{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})})},ri=({children:e,node:t})=>(0,q.jsx)(`nav`,{"data-lattice-component":P(t),children:(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e})}),ii=(0,G.createContext)(null),ai=`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 oi({affix:e,className:t}){return e.icon?(0,q.jsx)(F,{className:I(`size-lt-icon-md shrink-0`,t),icon:e.icon}):(0,q.jsx)(`span`,{className:I(`shrink-0 text-sm text-lt-muted-fg`,t),children:e.text})}function si(e,t){return(e??[]).some(e=>e.props?.href===t||si(e.schema,t))}var ci=({children:e,node:t})=>{let n=On(),{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=M(`menu`,t),p=ee(t.props),m=r?(0,q.jsx)(F,{className:`size-lt-icon-md shrink-0`,icon:r}):(0,q.jsxs)(q.Fragment,{children:[a?(0,q.jsx)(oi,{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)(oi,{affix:o,className:`ml-auto`}):null]}),h=I(ai,`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:I(h,e&&`bg-lt-muted font-medium`),"data-test":f,href:p.href,method:p.method,children:m})})}return e?n?(0,q.jsx)(ui,{icon:l,label:s,testId:f,children:e}):(0,q.jsx)(li,{content:m,defaultOpen:si(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 li({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:I(ai,`w-full`),"data-test":r,onClick:()=>a(e=>!e),type:`button`,children:[t,(0,q.jsx)(z,{name:`chevron-right`,className:I(`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 ui({children:e,icon:t,label:n,testId:r}){return(0,q.jsx)(`li`,{children:(0,q.jsx)(ti,{className:`min-w-48`,placement:`right`,testId:r,trigger:t?(0,q.jsx)(F,{className:`size-lt-icon-md shrink-0`,icon:t}):(0,q.jsx)(`span`,{children:n}),triggerClassName:I(ai,`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 di=()=>(0,q.jsx)(q.Fragment,{children:(0,G.useContext)(ii)});function fi(e,t){return typeof window>`u`||typeof window.matchMedia!=`function`?t:window.matchMedia(e).matches}function pi(e,t=!1){let[n,r]=(0,G.useState)(()=>fi(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 mi(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 hi(e,t,n){let[r,i]=mi(e,t,{enabled:n,parse:e=>e===`true`,serialize:String});return[r,(0,G.useCallback)(()=>i(e=>!e),[i])]}var gi=`(min-width: 768px)`;function _i(e,t){let n=e.detail?.target;return n==null||n===t}var vi=bn({components:{breadcrumbs:K(ei),callouts:K($r),dropdown:K(ni),menu:K(ri),"menu-item":K(ci),outlet:K(di),sidebar:K(({children:e,node:t})=>{let n=t.props.collapsible,r=t.props.rememberState,i=P(t),o=`lattice:sidebar:${i??`default`}`,s=pi(gi,!0),[c,l]=hi(o,!1,n&&r),[u,d]=(0,G.useState)(!1);Cn(a.toggleSidebar,e=>{_i(e,i)&&(window.matchMedia?.(gi).matches??!0?n&&l():d(e=>!e))}),(0,G.useEffect)(()=>p.on(`navigate`,()=>d(!1)),[]),Cn(`keydown`,e=>{e.key===`Escape`&&d(!1)},{enabled:u});let f=n&&c&&s;return(0,q.jsxs)(Dn.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:I(`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":i,"data-test":`sidebar`,children:e})]})}),topbar:K(({children:e,node:t})=>{let n=t.props.sticky;return(0,q.jsx)(`header`,{"data-lattice-component":P(t),className:I(`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 yi({children:e}){let t=u().props.lattice.layout;return t?(0,q.jsx)(ii.Provider,{value:e,children:(0,q.jsx)(J,{nodes:t.schema})}):(0,q.jsx)(q.Fragment,{children:e})}var bi=(0,G.lazy)(()=>rn(()=>import(`./chunks/subscriptions-4IpkpPX3.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url)),xi=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 Si({listeners:e}){return e.length===0?null:(0,q.jsx)(xi,{children:(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(bi,{listeners:e})})})}function Ci({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)(Si,{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:I(`w-full`,{"px-4 py-6":e.layout!==null}),children:t})]})}function wi(e){return t=>{if(t===`lattice/page`)return{default:Ci};let n=e[`./Pages/${t}.tsx`]??e[`./pages/${t}.tsx`];if(n)return n();throw Error(`Page not found: ${t}`)}}function Ti({defaultLayout:e}={}){return(t,n)=>t===`lattice/page`?n.props.lattice?.layout?yi:null:e?.(t,n)??null}function Ei(e,t){return{...t,headers:Pt(``,t.headers)}}var Di=!1;function Oi(){Di||(Di=!0,g.onRequest(e=>{let t=e.headers?.[kt];return e.headers&&typeof t==`string`&&t!==``&&(e.headers[kt]=jt(t)),e}))}var ki=Object.defineProperty,Q=(e,t)=>ki(e,`name`,{value:t,configurable:!0}),Ai=`Dialog`,[ji,Mi]=lt(Ai),[Ni,Pi]=ji(Ai),Fi=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:Ai}),[d,f]=G.useState(0),[p,m]=G.useState(0);return(0,q.jsx)(Ni,{scope:t,triggerRef:s,contentRef:c,contentId:Ae(),titleId:Ae(),descriptionId:Ae(),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`),Ii=`DialogPortal`,[Li,Ri]=ji(Ii,{forceMount:void 0}),zi=Q(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Pi(Ii,t);return(0,q.jsx)(Li,{scope:t,forceMount:n,children:G.Children.map(r,e=>(0,q.jsx)(ze,{present:n||a.open,children:(0,q.jsx)(st,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Bi=`DialogOverlay`,Vi=G.forwardRef(Q(function(e,t){let n=Ri(Bi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Pi(Bi,e.__scopeDialog);return a.modal?(0,q.jsx)(ze,{present:r||a.open,children:(0,q.jsx)(Ui,{...i,ref:t})}):null},`DialogOverlay`)),Hi=R(`DialogOverlay.RemoveScroll`),Ui=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Bi,n),a=$e(),o=L(t,a);return(0,q.jsx)(tt,{as:Hi,allowPinchZoom:!0,shards:[i.contentRef],children:(0,q.jsx)(H.div,{"data-state":ta(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Wi=`DialogContent`,Gi=G.forwardRef(Q(function(e,t){let n=Ri(Wi,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Pi(Wi,e.__scopeDialog);return(0,q.jsx)(ze,{present:r||a.open,children:a.modal?(0,q.jsx)(Ki,{...i,ref:t}):(0,q.jsx)(qi,{...i,ref:t})})},`DialogContent`)),Ki=G.forwardRef(Q(function(e,t){let n=Pi(Wi,e.__scopeDialog),r=G.useRef(null),i=L(t,n.contentRef,r);return G.useEffect(()=>{let e=r.current;if(e)return ge(e)},[]),(0,q.jsx)(Ji,{...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`)),qi=G.forwardRef(Q(function(e,t){let n=Pi(Wi,e.__scopeDialog),r=G.useRef(!1),i=G.useRef(!1);return(0,q.jsx)(Ji,{...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`)),Ji=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=Pi(Wi,n);return Ce(),(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(Me,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,q.jsx)(We,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":ta(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Yi=`DialogTitle`,Xi=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Yi,n),{setTitleCount:a}=i;return Ze(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,q.jsx)(H.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Zi=`DialogDescription`,Qi=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi(Zi,n),{setDescriptionCount:a}=i;return Ze(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,q.jsx)(H.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),$i=`DialogClose`,ea=G.forwardRef(Q(function(e,t){let{__scopeDialog:n,...r}=e,i=Pi($i,n);return(0,q.jsx)(H.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function ta(e){return e?`open`:`closed`}Q(ta,`getState`);var na=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 ra(e){return(0,q.jsx)(Fi,{"data-slot":`dialog`,...e})}function ia(e){return(0,q.jsx)(ea,{"data-slot":`dialog-close`,...e})}function aa({className:e,...t}){return(0,q.jsx)(Xi,{className:I(`text-lg font-semibold leading-none tracking-tight`,e),"data-slot":`dialog-title`,...t})}function oa({className:e,...t}){return(0,q.jsx)(Qi,{className:I(`text-sm text-lt-muted-fg`,e),"data-slot":`dialog-description`,...t})}function sa({children:e,className:t,placement:n=`center`,width:r=`lg`,...i}){return(0,q.jsxs)(zi,{children:[(0,q.jsx)(Vi,{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)(Gi,{className:I(na({placement:n,width:r}),t),"data-slot":`dialog-content`,...i,children:e})]})}function ca({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)(aa,{children:n}),t?(0,q.jsx)(oa,{children:t}):null]}),(0,q.jsx)(ia,{asChild:!0,children:(0,q.jsx)(W,{"aria-label":e,"data-test":`dialog-close`,size:`icon`,emphasis:`ghost`,children:(0,q.jsx)(z,{name:`x`,"aria-hidden":`true`,className:`size-lt-icon-md`})})})]})}function la({className:e,...t}){let{t:n}=T(`lattice`);return(0,q.jsx)(z,{name:`loader-2`,role:`status`,"aria-label":n(`common.loading`,`Loading`),"aria-hidden":!1,className:I(`animate-spin`,e),...t})}function ua({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)(ra,{open:!0,onOpenChange:e=>{e||l()},children:(0,q.jsxs)(sa,{...t?{}:{"aria-describedby":void 0},width:`md`,onEscapeKeyDown:u,onInteractOutside:u,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(aa,{children:e}),t&&(0,q.jsx)(oa,{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)(la,{}),n]})]})]})})}async function da(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 fa({className:e,...t}){return(0,q.jsx)(`div`,{"aria-hidden":`true`,className:I(`animate-pulse rounded-lt-sm bg-lt-muted`,e),"data-slot":`skeleton`,...t})}var pa=(0,G.createContext)({});function ma({nodes:e,children:t}){return(0,q.jsx)(pa.Provider,{value:e,children:t})}function ha(e){let t=(0,G.useContext)(pa),n=mt(e).name??``,r=dt(),i=n&&r?r.errorKey(n):n;return i&&t[i]||n&&t[n]||e}var ga=typeof window>`u`?G.useEffect:G.useLayoutEffect;function _a(e,t,n,r){return Gt(e,{method:`POST`,ref:t,signal:r,body:JSON.stringify(n),throwOnError:!1}).then(e=>e.ok?e.json():null)}function va(e){return e.templates}function ya(e,t){let n=va(e);return n?n.find(e=>e.type===t.type)?.schema??[]:e.schema??[]}function ba(e,t){return e.startsWith(`@`)?e.slice(1):t===null?e:Se(t,e)}function xa(e,t,n,r=0,i={}){let a=mt(e);if(!a.editablePrefill||!a.name)return null;let o=de(i);return{path:t===null?a.name:Se(t,a.name),overrideKey:n===null?a.name:Ee(n,o,r,a.name),resetOn:(a.prefillResetOn??[]).map(e=>ba(e,t)),refreshOn:(a.prefillRefreshOn??[]).map(e=>ba(e,t))}}function Sa(e,t){let n=[],r=(e,i=null,a=null,o=null,s=0,c={})=>{for(let l of e??[]){if(we.has(l.type)){let e=mt(l).name;if(e){let n=Se(i,e),o=Se(a,e),s=fe(t,n);(Array.isArray(s)?s:[]).forEach((e,t)=>{r(ya(l,e),Se(n,t),Se(o,de(e)??t),o,t,e)})}continue}let e=xa(l,i,o,s,c);e&&n.push(e),r(l.schema,i,a,o,s,c)}};return r(e),n}function Ca(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 wa(e,t){return e.filter(e=>{let n=fe(t,e.path);return n!=null&&n!==``}).map(e=>e.overrideKey)}function Ta(e,t){let n=new Set(t.map(e=>e.overrideKey));return new Set([...e].filter(e=>n.has(e)))}function Ea(e,t,n){let r=Ie(),i=Te(),[a,o]=(0,G.useState)({}),s=(0,G.useMemo)(()=>Sa(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,ga(()=>{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 wa(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 Ca({targets:d.current,values:n},{targets:f.current,values:r}))c.current.delete(e);d.current=f.current,c.current=Ta(c.current,f.current);let a=new AbortController,s=window.setTimeout(()=>{_a(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 Da(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 Oa(e,t){return e===t||e.startsWith(`${t}.`)}function ka(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=Array.isArray(r)?r[0]:r;return t}function Aa(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 ja(e,t,n){let[r,i]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!n){i(null);return}let r=new AbortController;return Gt(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 Ma(){return(0,q.jsxs)(`div`,{className:`space-y-4`,"data-lattice-action-form-loading":!0,children:[(0,q.jsx)(fa,{className:`h-4 w-24`}),(0,q.jsx)(fa,{className:`h-10 w-full`}),(0,q.jsx)(fa,{className:`h-10 w-full`})]})}function Na({cancelLabel:e,componentRef:t,endpoint:n,extraData:r,fieldLabels:i,formNode:a,method:o,onClose:s,onSuccess:c,precognitive:l,submitLabel:u}){let d=Ie(),f=(0,G.useRef)(d);f.current=d;let p=(0,G.useRef)(r);p.current=r;let{nodes:h,markUserEdit:g}=Ea(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=>Gt(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=Aa(e=>{E({Precognition:`true`,"Precognition-Validate-Only":e}).then(async t=>{if(t.status===422){let e=await t.json();x(t=>({...t,...ka(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,...ka(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=>Oa(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(ka(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)(me,{value:N,children:(0,q.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,q.jsx)(Oe,{value:{markUserEdit:g},children:(0,q.jsx)(ma,{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)(la,{}),u]})]})]})})}function Pa({formNode:e,...t}){let n=!!e.props?.precognitive,{labels:r,values:i}=(0,G.useMemo)(()=>{let{labels:t,values:n}=Da(e.schema);return{labels:t,values:{...n,...e.props?.state}}},[e]);return(0,q.jsx)(ut,{initial:i,children:(0,q.jsx)(Na,{fieldLabels:r,formNode:e,precognitive:n,...t})})}function Fa({description:e,formNode:t,onClose:n,placement:r,title:i,width:a,...o}){let{t:s}=T(`lattice`);return(0,q.jsx)(ra,{open:!0,onOpenChange:e=>{e||n()},children:(0,q.jsxs)(sa,{...e?{}:{"aria-describedby":void 0},placement:r,width:a,children:[(0,q.jsx)(ca,{closeLabel:s(`common.close`,`Close`),description:e,title:i}),(0,q.jsx)(`div`,{className:`mt-6`,children:t?(0,q.jsx)(Pa,{formNode:t,onClose:n,...o}):(0,q.jsx)(Ma,{})})]})})}function Ia(e){return e.props.label??C(`lattice`,`common.action.run`,`Run action`)}function La(e){let t=e.props.endpoint??``,n=e.props.ref??``,r=e.props.method??`post`,i=Ia(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=ja(t,n,_&&l),x=l?b:c,S=async()=>{if(!t)return;if(r===`get`){p.visit(t,{headers:Pt(n)}),g(!1);return}f(!0);let e=await da(()=>Gt(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)(ua,{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)(Fa,{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 Ra({action:e,children:t}){let{processing:n,requestSubmit:r,overlays:i}=La(e);return(0,q.jsxs)(q.Fragment,{children:[t({onClick:r,processing:n}),i]})}function za({children:e}){return(0,q.jsx)(ne,{render:e=>(0,q.jsx)(Ra,{action:e.action,children:e.children}),children:e})}function Ba(){let e=y();(0,G.useEffect)(()=>p.on(`flash`,t=>{let n=_(t.detail?.flash?.latticeEffects);n.length>0&&e(n)}),[e])}function Va({onAppearanceChange:e}){return Cn(a.appearanceChange,t=>{let n=t.detail?.value;un(n)&&e?.(n)},{enabled:!!e}),null}var Ha={href:``};function Ua({children:e,registry:t,sprite:n=Ha,toaster:r=!0}){return Ba(),(0,q.jsx)(d.Provider,{value:t,children:(0,q.jsx)(za,{children:(0,q.jsxs)(B,{sprite:n,children:[e,(0,q.jsx)(Va,{onAppearanceChange:vn}),r?(0,q.jsx)(Zr,{}):null]})})})}var Wa=bn({components:{action:K(({node:e})=>{let t=e.props.endpoint??``,n=e.props.icon,r=Ia(e),i=Ye(),{variant:a,emphasis:o}=e.props,{processing:s,requestSubmit:c,overlays:l}=La(e),u=e.key??N(`action`,e.id);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(W,{className:i?et: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)(la,{className:i?`size-lt-icon-sm`:void 0}):n&&(0,q.jsx)(F,{className:i?`size-lt-icon-sm`:`size-lt-icon-md`,icon:n}),r]}),l]})}),"action.group":K(({children:e,node:t})=>{let{t:n}=T(`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:I(`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)(Le,{children:[(0,q.jsx)(Re,{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":P(t),size:`icon`,type:`button`,emphasis:`ghost`,children:(0,q.jsx)(z,{name:`more-horizontal`,"aria-hidden":`true`,className:`size-lt-icon-md`})})}),(0,q.jsx)(qe,{align:`end`,"aria-label":r,className:`min-w-44 gap-0.5 p-1.5`,sideOffset:8,children:(0,q.jsx)(Be,{children:e})})]})})})},name:`lattice/action`});function Ga(e){try{return JSON.parse(e)}catch{return null}}function Ka(e){return async function*(t){let n=await e(t);if(!n.ok||!n.body)throw Error(`Chat stream failed (${n.status})`);yield*Ya(n.body)}}var qa=Ka(({url:e,body:t,signal:n})=>Gt(e,{method:`POST`,signal:n,headers:{Accept:`application/x-ndjson`},body:JSON.stringify(t),throwOnError:!1}));function Ja(e){return Ka(({url:t,body:n,signal:r})=>Qt(t,{remote:e,method:`POST`,signal:r,headers:{Accept:`application/x-ndjson`,"Content-Type":`application/json`},body:JSON.stringify(n),throwOnError:!1}))}async function*Ya(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=Ga(e);t&&(yield t)}}if(r+=n.decode(),r.trim()!==``){let e=Ga(r);e&&(yield e)}}finally{await t.cancel().catch(()=>{})}}var Xa=0;function Za(){return Xa+=1,`chat-${Xa}`}function Qa(e){return e instanceof DOMException&&e.name===`AbortError`}function $a(e){return e instanceof Error?e.message:String(e)}function eo(e){let t=e.at(-1);return t!==void 0&&t.role===`assistant`}function to(e,t){if(!eo(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 no({endpoint:e,transport:t=qa,initialMessages:n=[],generateId:r=Za}){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(to(f.current,n))}s(e=>e===`streaming`||e===`submitted`?`idle`:e)}catch(e){if(Qa(e)){s(`idle`);return}l($a(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=eo(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 ro({message:e}){let t=e.role===`user`;return(0,q.jsx)(`div`,{className:I(`flex flex-col gap-1`,t?`items-end`:`items-start`),"data-test":j(`chat-message-${e.role}`),children:(0,q.jsx)(`div`,{className:I(`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 io({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":j(`chat-messages`),children:[e.map(e=>(0,q.jsx)(ro,{message:e},e.id)),(0,q.jsx)(`div`,{ref:t})]})}function ao({onSubmit:e,disabled:t=!1,placeholder:n}){let{t:r}=T(`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:I(`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-slot":`prompt-input`,"data-test":j(`chat-input`),disabled:t,onChange:e=>a(e.target.value),onKeyDown:s,placeholder:n,rows:1,value:i}),(0,q.jsx)(W,{"data-test":j(`chat-send`),disabled:t,onClick:o,size:`sm`,type:`button`,children:r(`common.chat.send`,`Send`)})]})}var oo=bn({name:`lattice/chat`,components:{"chat.box":K(({node:e})=>{let t=e.props,{t:n}=T(`lattice`),r=(0,G.useMemo)(()=>t.remote?Ja(t.remote):qa,[t.remote]),{messages:i,status:a,error:o,sendMessage:s,setMessages:c}=no({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 $t(t.historyEndpoint,{remote:t.remote});c(e.messages);return}let e=await Gt(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:I(`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":j(`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)(io,{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)(ao,{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":j(`chat-tool-call`),children:[`🔧 `,e.props.name,`(`,JSON.stringify(e.props.args),`)`]}))}}),so={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 co(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}function lo(){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 uo=({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:I(`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-lt-muted font-medium text-lt-muted-fg select-none`,so[r]),children:t?(0,q.jsx)(`img`,{src:t,alt:i??``,className:`size-full object-cover`}):n?co(n):(0,q.jsx)(lo,{})})};function fo({color:e,className:t,style:n,...r}){let i=Et(Dt(e??void 0)??Ct(`gray`));return(0,q.jsx)(`span`,{"data-slot":`badge`,className:I(`lt-badge`,i.className,t),style:{...i.style,...n},...r})}var po=({node:e})=>(0,q.jsx)(fo,{color:e.props.color,children:e.props.label});function mo({className:e,...t}){return(0,q.jsx)(`article`,{"data-slot":`card`,className:I(`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 ho({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-header`,className:I(`flex flex-col gap-1.5 px-lt-gutter`,e),...t})}function go({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-title`,className:I(`font-semibold leading-none`,e),...t})}function _o({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-description`,className:I(`text-sm text-lt-muted-fg`,e),...t})}function vo({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-content`,className:I(`px-lt-gutter`,e),...t})}var yo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props;return(0,q.jsxs)(mo,{"data-lattice-component":P(t),children:[(n||r)&&(0,q.jsxs)(ho,{children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(go,{children:n}),(0,q.jsx)(it,{content:i})]}),r&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(_o,{children:r}),!n&&(0,q.jsx)(it,{content:i})]})]}),e&&(0,q.jsx)(vo,{className:`flex flex-col gap-6`,children:e})]})},bo=(0,G.lazy)(()=>rn(()=>import(`./chunks/chart-view-CFV7BU_D.js`),__vite__mapDeps([10,1,3,4,11,6,12,7,13,14]),import.meta.url)),xo=({children:e,node:t})=>(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(bo,{node:t,children:e})});async function So(e){if(!navigator?.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function Co({value:e,label:t,testId:n,className:r,iconOnly:i=!1,children:a}){let{t:o}=T(`lattice`),[s,c]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!s)return;let e=window.setTimeout(()=>c(!1),1500);return()=>window.clearTimeout(e)},[s]);async function l(){await So(e)&&c(!0)}let u=s?o(`common.copied-value`,`Copied {{label}}`,{label:t}):o(`common.copy-value`,`Copy {{label}}`,{label:t});return i?(0,q.jsx)(Qe,{icon:s?`check`:`copy`,label:u,"data-test":n,className:r,onClick:()=>void l()}):(0,q.jsx)(W,{type:`button`,size:`sm`,emphasis:`outline`,icon:s?`check`:`copy`,"data-test":n,className:r,"aria-label":u,onClick:()=>void l(),children:s?o(`common.copied`,`Copied`):a??o(`common.copy`,`Copy`)})}function wo({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)(Co,{value:e,label:t,testId:n})]})}var To=(0,G.lazy)(()=>rn(()=>import(`./chunks/code-block-view-D464jtHN.js`),__vite__mapDeps([15,1,7,16]),import.meta.url));function Eo({"aria-label":e,children:t,className:n,copyable:r=!1,language:i=`text`,role:a=e?`region`:void 0,wrap:o=!1,...s}){let c=(0,q.jsx)(`pre`,{className:I(`max-w-full overflow-x-auto p-3 font-lt-mono text-xs`,o&&`whitespace-pre-wrap wrap-anywhere`,r&&`pt-11`),children:t});return(0,q.jsxs)(`div`,{"data-slot":`code-block`,"aria-label":e,role:a,...s,className:I(`relative max-w-full overflow-hidden rounded-lt-sm bg-lt-muted text-lt-fg`,n),children:[r?(0,q.jsx)(Co,{value:t,label:e??`code`,iconOnly:!0,className:`absolute top-2 right-2 z-10 bg-lt-bg/80 hover:bg-lt-bg`}):null,(0,q.jsx)(G.Suspense,{fallback:c,children:(0,q.jsx)(To,{copyable:r,language:i,wrap:o,children:t})})]})}var Do=({node:e})=>(0,q.jsx)(Eo,{copyable:e.props.copyable,language:e.props.language,wrap:e.props.wrap,children:e.props.code}),Oo=({children:e,node:t})=>{let n=t.props.rememberState!==!1,r=Tn(t.props.trigger),i=P(t),a=`lattice:collapsible:${i??`default`}`,o=`${i??`collapsible`}-content`,[s,c]=hi(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":N(`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)(it,{content:t.props.tooltip})})]}),(0,q.jsx)(z,{name:`chevron-down`,className:I(`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 ko(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 Ao=({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":P(t),role:n?`group`:void 0,style:ko(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":P(t),role:n?`group`:void 0,style:ko(i,r),children:(0,q.jsxs)(`div`,{className:I(`flex w-fit gap-2`,c?`flex-col-reverse`:`flex-col`),children:[(0,q.jsx)(`button`,{"aria-expanded":o,className:I(`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})]})})},jo={lg:320,md:64,sm:40,xl:384,xs:32,"2xl":448,"3xl":512,"4xl":576},Mo=({node:e})=>{let t=e.props.endpoint??``,n=e.props.lazy===!0,r=e.props.ref??``,i=jo[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 Kt(t,{ref:r});s(Tn(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(a.reloadComponent,t),()=>window.removeEventListener(a.reloadComponent,t)},[f,e.id]),(0,G.useEffect)(()=>{function e(){c&&f()}return window.addEventListener(a.localeChange,e),()=>window.removeEventListener(a.localeChange,e)},[c,f]),(0,q.jsx)(`div`,{"data-lattice-fragment":e.id,style:u&&o.length===0?{minHeight:i}:void 0,children:u&&o.length===0?(0,q.jsx)(fa,{className:`w-full`,style:{height:i}}):(0,q.jsx)(J,{nodes:o})})};function No(e,t,n){let r=Object.entries(e??{});if(r.length!==0)return Object.fromEntries(r.map(([e,r])=>[`${t}-${e}`,n(r)]))}var Po=e=>typeof e==`number`?`repeat(${e}, minmax(0, 1fr))`:e,Fo=e=>e===`full`?`1 / -1`:`span ${e} / span ${e}`,Io=({node:e})=>(0,q.jsx)(`div`,{"data-slot":`grid`,"data-lattice-component":P(e),className:`lt-grid grid gap-x-4 gap-y-6`,style:No(e.props.columns,`--lt-grid-cols`,Po),children:(e.schema??[]).map((e,t)=>(0,q.jsx)(`div`,{"data-slot":`grid-item`,style:No(e.props?.columnSpan,`--lt-col-span`,Fo),children:(0,q.jsx)(Y,{node:e})},En(e,t)))}),Lo=({node:e})=>{let{text:t,tooltip:n}=e.props,r=Math.min(Math.max(e.props.level,1),6),i=I(`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)(it,{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)(wo,{value:t,label:t,children:o}):o},Ro={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`},zo=({node:e})=>{let{name:t,size:n,color:r,class:i}=e.props,a=(0,q.jsx)(F,{icon:t,className:I(Ro[n],i)}),o=Dt(r);return o?(0,q.jsx)(`span`,{className:`contents`,style:{color:wt(o)},children:a}):a};function Bo({src:e,alt:t,previewable:n,width:r,height:i,className:a,testId:o}){let{t:s}=T(`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)(ra,{open:c,onOpenChange:l,children:(0,q.jsxs)(sa,{"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)(aa,{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)(ia,{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 Vo=({node:e})=>{let{src:t,alt:n,size:r,circular:i,previewable:a}=e.props;return(0,q.jsx)(Bo,{alt:n??``,className:I(`object-cover`,i?`rounded-full`:`rounded-lt-sm`),height:r??void 0,previewable:a,src:t,testId:P(e),width:r??void 0})};function Ho(e,t){let n=e.detail?.modal;return n==null||n===t}var Uo=({children:e,node:t})=>{let{t:n}=T(`lattice`),r=t.props.title??n(`common.dialog`,`Dialog`),i=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&&Ho(e,t.id)&&(l.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(!0))}function n(e){(!t.id||Ho(e,t.id))&&c(!1)}return window.addEventListener(a.openModal,e),window.addEventListener(a.closeModal,n),()=>{window.removeEventListener(a.openModal,e),window.removeEventListener(a.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)(ra,{open:s,onOpenChange:c,children:(0,q.jsxs)(sa,{...i?{}:{"aria-describedby":void 0},placement:t.props.side??`center`,width:t.props.width,children:[(0,q.jsx)(ca,{closeLabel:o,description:i,title:r}),(0,q.jsx)(`div`,{className:`mt-6 space-y-6`,children:e})]})})},Wo={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`},Go={xs:24,sm:32,md:40,lg:48,xl:64,"2xl":80,"3xl":96,"4xl":128},Ko={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`},qo=({node:e})=>{let{value:t,max:r,shape:i,showValue:a,color:o,size:s}=e.props,{locale:c}=n(),l=wt(Dt(o)??Ct(`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=Go[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:I(`absolute inset-0 flex items-center justify-center font-medium text-lt-fg tabular-nums`,Ko[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:I(`w-full overflow-hidden rounded-full bg-lt-muted`,Wo[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})]})},Jo=({node:e})=>(0,q.jsx)(`span`,{style:{display:`contents`},dangerouslySetInnerHTML:{__html:e.props.html}}),Yo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props,a=t.props.collapsible===!0,o=t.props.rememberState!==!1,s=Tn(t.props.headerActions),c=P(t),[l,u]=hi(`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":N(`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)(z,{name:`chevron-down`,className:I(`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)(it,{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)(it,{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 Xo(e){return I(`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 Zo({ariaLabel:e,autoFocus:t=!1,className:n,disabled:r=!1,name:i,onSelect:a,options:o,tabIndex:s,value:c,...l}){let u=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!t)return;let e=u.current;(e?.querySelector(`button[aria-checked="true"]`)??e?.querySelector(`button`))?.focus()},[t]),(0,q.jsx)(`div`,{...l,"aria-label":e,className:I(`inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1`,n),ref:u,role:`radiogroup`,children:o.map(e=>{let t=c===e.value;return(0,q.jsx)(`button`,{"aria-checked":t,"data-test":`${i}-${e.value}`,className:I(Xo(t),r&&`cursor-not-allowed opacity-60`),disabled:r,onClick:()=>a(e.value),role:`radio`,tabIndex:s,type:`button`,children:e.label},e.value)})})}var Qo=({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)(Zo,{ariaLabel:e.props.label??void 0,name:n,onSelect:o,options:t,value:i})},$o=({node:e})=>{let t=e.props.orientation===`horizontal`;return(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":e.props.orientation,className:I(`shrink-0 bg-lt-border`,t?`h-px w-full`:`h-full w-px self-stretch`)})},es={center:`justify-items-center text-center`,start:`justify-items-start text-left`,stretch:`justify-items-stretch`},ts={center:`items-center text-center`,start:`items-center text-left`,stretch:`items-stretch justify-stretch`},ns={none:`gap-0`,xs:`gap-1`,lg:`gap-6`,md:`gap-4`,sm:`gap-2`,xl:`gap-8`},rs={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`},is={around:`justify-around`,between:`justify-between`,center:`justify-center`,end:`justify-end`,evenly:`justify-evenly`,start:`justify-start`},as={full:`h-full`,screen:`min-h-screen`},os={end:`ml-auto`,start:`mr-auto`},ss=({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":P(t),className:I(l?I(`flex`,r===`row`?`flex-wrap`:`flex-col`):`grid content-start`,l?ts[n]??ts.stretch:es[n]??es.stretch,ns[i]??ns.md,rs[a]??rs.full,o?is[o]:null,s?as[s]:null,c?os[c]:null),children:e})},cs=(0,G.createContext)(null);function ls(){return(0,G.useContext)(cs)||{activeValue:``,setActiveValue:()=>{}}}function us(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 ds(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 fs(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 ps(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 ms=({children:e,node:t})=>{let{t:n}=T(`lattice`),r=(0,G.useMemo)(()=>us(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||(ds(a,r)??d)||i),g=(0,G.useCallback)(e=>{if(e.confirm?.required){p.visit(ps(a,e.value),{preserveScroll:!0});return}h(e.value),fs(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)(cs.Provider,{value:v,children:(0,q.jsxs)(`div`,{className:I(`gap-6`,s?I(`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:I(`gap-1 rounded-lt bg-lt-muted p-1`,s&&`flex flex-col`,l&&`flex w-full`,!s&&!l&&I(`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:I(Xo(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:I(`min-w-0`,s&&`flex-1`),children:e})]})})},hs=({children:e,node:t})=>{let{activeValue:n}=ls(),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:I(`space-y-8`,!i&&`hidden`),hidden:!i,id:`${r}-panel`,role:`tabpanel`,tabIndex:0,children:a?e:null})},gs={center:`text-center`,left:`text-left`},_s={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`},vs=bn({components:{avatar:K(uo),badge:K(po),button:K(_t),card:K(yo),chart:K(xo),"code-block":K(Do),collapsible:K(Oo),"floating-panel":K(Ao),fragment:K(Mo),grid:K(Io),heading:K(Lo),icon:K(zo),image:K(Vo),link:K(Pe),modal:K(Uo),progress:K(qo),"raw-block":K(Jo),section:K(Yo),"segmented-control":K(Qo),separator:K($o),stack:K(ss),tab:K(hs),tabs:K(ms),text:K(({node:e})=>{let t=e.props.align??`left`,n=wt(Dt(e.props.color)??Ct(`muted`)),r=(0,q.jsx)(`p`,{className:I(`m-0`,`max-w-2xl`,gs[t]??gs.left,_s[e.props.size]),style:{color:n},children:e.props.text});return e.props.copyable?(0,q.jsx)(wo,{value:e.props.text,label:e.props.text,children:r}):r}),tooltip:K(({node:e})=>{let t=e.props.content,n=Tn(e.props.trigger);return t?n.length===0?(0,q.jsx)(it,{content:t}):(0,q.jsxs)(ke,{children:[(0,q.jsx)(_e,{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)(pe,{align:`start`,className:`max-w-xs p-3 text-sm [&_a]:underline`,dangerouslySetInnerHTML:{__html:t}})]}):null})},name:`lattice/ui`});function ys({addLabel:e,options:t,onSelect:n}){return(0,q.jsxs)(Le,{children:[(0,q.jsx)(Re,{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)(z,{name:`plus`}),e]})}),(0,q.jsx)(qe,{align:`start`,className:`min-w-[12rem]`,children:t.map(e=>(0,q.jsx)(ct,{"data-test":`builder-add-${e.type}`,onClick:()=>n(e.type),children:e.label},e.type))})]})}var bs={duplicate:{key:`table.row-actions.duplicate`,fallback:`Duplicate`,icon:`copy`},remove:{key:`table.row-actions.remove`,fallback:`Remove`,icon:`trash-2`}};function xs(e,t){return(e??Ss(t.removable)).map(e=>Cs(e,t)).filter(e=>e!==null)}function Ss(e){return e?[{type:`remove`,key:`remove`,label:null,icon:null,danger:!0}]:[]}function Cs(e,t){if(e.type===`duplicate`){let n=bs.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=bs.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 ws(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 Ts({actions:e}){let{t}=T(`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:ws(t.danger),onClick:t.onClick,children:(0,q.jsx)(z,{name:t.icon})})}return(0,q.jsxs)(Le,{children:[(0,q.jsx)(Re,{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)(z,{name:`more-horizontal`})})}),(0,q.jsx)(qe,{align:`end`,className:`min-w-[10rem]`,children:e.map(e=>(0,q.jsx)(ct,{"data-test":`row-action-${e.key}`,danger:e.danger,icon:e.icon,onClick:e.onClick,children:e.label},e.key))})]})}function Es({path:e,rows:t,rowKey:n}){return(0,q.jsx)(q.Fragment,{children:t.map((t,r)=>(0,q.jsx)(`input`,{type:`hidden`,name:ve(Se(e,r,n)),value:String(t[n]??``)},String(t.rowId??r)))})}function Ds({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 Os=(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}=T(`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)(Ds,{label:`Move up`,testId:`repeater-${e}-up-${t}`,onClick:()=>f(t,-1),children:(0,q.jsx)(z,{name:`arrow-up`})}),a&&!s&&(0,q.jsx)(Ds,{label:`Move down`,testId:`repeater-${e}-down-${t}`,onClick:()=>f(t,1),children:(0,q.jsx)(z,{name:`arrow-down`})}),(0,q.jsx)(Ts,{actions:xs(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},En(e,t)))})})]})}),ks={xs:{track:`minmax(4rem, 0.35fr)`,minPx:64,defaultPx:96},sm:{track:`minmax(6rem, 0.5fr)`,minPx:96,defaultPx:128},md:{track:`minmax(8rem, 1fr)`,minPx:128,defaultPx:176},lg:{track:`minmax(12rem, 1.5fr)`,minPx:192,defaultPx:240},xl:{track:`minmax(16rem, 2fr)`,minPx:256,defaultPx:320}},As=1024;function js(e){return ks[e].track}function Ms(e){return ks[e.width].minPx}function Ns(e){return ks[e.width].defaultPx}function Ps({columns:e,leadingTracks:t=[],trailingTracks:n=[],overrides:r={}}){return[...t,...e.map(e=>{let t=r[e.key];return t===void 0?js(e.width):`${Math.min(As,Math.max(Ms(e),t))}px`}),...n].join(` `)}var Fs=[];function Is({columnGapPx:e=0,columns:t,enabled:n,leadingTracks:r=Fs,showIndicator:i=!1,storageKey:a,trailingTracks:o=Fs}){let s=(0,G.useMemo)(()=>t.map(e=>e.key),[t]),[c,l]=mi(a??``,{},{enabled:!!a,parse:e=>Rs(e,t),serialize:e=>zs(e,s)}),u=(0,G.useRef)(c),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useCallback)(e=>Ps({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),h(p(e))},[h,l,p]),_=(0,G.useCallback)((e,t,n,r)=>({...e,[t.key]:Math.min(r??1024,Math.max(Ms(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]??Ns(e),[]);return{getResizeHandleProps:(0,G.useCallback)(a=>{let s=As,c=Ms(a),l=S(a),m=a.label??a.key,b=i?`after:bg-lt-border`:`after:bg-transparent`,x=n=>Ls({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 Ls({column:e,columnGapPx:t,columns:n,grid:r,leadingTracks:i,trailingTracks:a}){let o=r?.getBoundingClientRect().width??0;if(o<=0)return As;let s=[...i,...a].reduce((e,t)=>e+Vs(t),0),c=n.reduce((t,n)=>n.key===e.key?t:t+Ms(n),0),l=n.length+i.length+a.length,u=Math.max(0,l-1)*t,d=o-s-c-u;return Math.min(As,Math.max(Ms(e),d))}function Rs(e,t){let n=JSON.parse(e)?.overrides;if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`unexpected stored column widths shape`);let r=Bs(n,t);if(Object.keys(r).length===0)throw Error(`stored column widths hold no usable overrides`);return r}function zs(e,t){let n={},r=new Set(t);for(let[t,i]of Object.entries(e))r.has(t)&&typeof i==`number`&&Number.isFinite(i)&&(n[t]=i);return Object.keys(n).length===0?null:JSON.stringify({overrides:n})}function Bs(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(As,Math.max(Ms(r),t)))}return n}function Vs(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])*Hs():0}function Hs(){if(typeof window>`u`)return 16;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:16}var Us=`3rem`,Ws=`3rem`,Gs=[Us],Ks=[Ws],qs=`(min-width: 768px)`;function Js(){return pi(qs,!0)}function Ys(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 Xs=(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:_}=T(`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)(Ds,{label:`Move up`,testId:`table-${e}-up-${t}`,onClick:()=>p(t,-1),children:(0,q.jsx)(z,{name:`arrow-up`})}),l&&!o&&(0,q.jsx)(Ds,{label:`Move down`,testId:`table-${e}-down-${t}`,onClick:()=>p(t,1),children:(0,q.jsx)(z,{name:`arrow-down`})})]}),(0,q.jsx)(le,{base:e,index:t,row:n,onChange:(e,n)=>f(t,e,n),children:(0,q.jsx)(He,{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},En(e,t)))}):r.map((e,t)=>(0,q.jsx)(`div`,{children:(0,q.jsx)(Y,{node:e})},En(e,t)))})}),(0,q.jsx)(`div`,{className:`flex items-center`,children:(0,q.jsx)(Ts,{actions:xs(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}=T(`lattice`),m=Js(),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}=Is({columns:h,enabled:d,columnGapPx:12,leadingTracks:Gs,showIndicator:f,storageKey:d?`lattice:table-columns:form:${e}`:void 0,trailingTracks:Ks});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)(z,{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)(Xs,{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)(Os,{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 Qs=180;function $s(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function ec(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 ga(()=>{let e=[],r=new Map;return t.current.forEach((e,t)=>{e.style.transition=``,e.style.transform=``,r.set(t,e.getBoundingClientRect())}),$s()||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 ${Qs}ms ease-out`,t.style.transform=``})))}}),n.current=r,()=>{for(let t of e)cancelAnimationFrame(t)}},[e]),r}function tc(e,t){let n=dt(),r=n?n.errorKey(e):e,i=Te(),a=pt(r),o=Array.isArray(a)?a:ye(a,t),s=Ke(o);ga(()=>{s!==o&&i(r,s)},[o,s,i,r]);let c=(0,G.useCallback)(e=>{i(r,n=>e(Array.isArray(n)?n:ye(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=>Ge(t,e)),[c]),onMove:(0,G.useCallback)((e,t)=>c(n=>se(n,e,e+t)),[c]),onDuplicate:(0,G.useCallback)(e=>c(t=>xe(t,e)),[c]),append:(0,G.useCallback)(e=>c(t=>[...t,be(e)]),[c])}}var nc=[],rc=({node:e})=>{let t=e.props,n=t.name,r=va(e)??[],{errors:i}=De(),{hidden:a,required:o}=ot(e),{path:s,rows:c,onField:l,onRemove:u,onMove:d,onDuplicate:f,append:p}=tc(n,t.defaultItems??0),{t:m}=T(`lattice`),h=ec(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??nc,span:!r,heading:n?.label??`Unknown block: ${String(e.type)}`}});return(0,q.jsx)(nt,{error:i[s],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,id:s,required:o,children:e=>(0,q.jsxs)(`div`,{...e,className:`flex flex-col gap-3`,role:`group`,children:[(0,q.jsx)(Es,{path:s,rows:c,rowKey:ue}),(0,q.jsx)(Es,{path:s,rows:c,rowKey:`type`}),v?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(Zs,{base:s,columns:Ys(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)(Os,{base:s,index:r,row:e,template:i.schema??nc,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)(Ts,{actions:xs(t.rowActions,{index:r,removable:!_,onRemove:u,onDuplicate:f,t:m})})]})},a)}),!g&&(0,q.jsx)(ys,{addLabel:t.addLabel??`Add`,options:b,onSelect:e=>p({type:e})})]})})},ic=Object.defineProperty,ac=(e,t)=>ic(e,`name`,{value:t,configurable:!0}),oc=`Checkbox`,[sc,cc]=lt(oc),[lc,uc]=sc(oc);function dc(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:oc}),[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:!bc(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,q.jsx)(lc,{scope:t,...S,children:yc(d)?d(S):r})}ac(dc,`CheckboxProvider`);var fc=`CheckboxTrigger`,pc=G.forwardRef(ac(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}=uc(fc,e),g=L(i,u),_=G.useRef(c);return G.useEffect(()=>{let e=a?.form;if(e){let t=ac(()=>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":bc(c)?`mixed`:c,"aria-required":l,"data-state":xc(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=>bc(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),mc=G.forwardRef(ac(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)(dc,{__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)(pc,{...d,ref:t,__scopeCheckbox:n}),e&&(0,q.jsx)(vc,{__scopeCheckbox:n})]})})},`Checkbox`)),hc=`CheckboxIndicator`,gc=G.forwardRef(ac(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=uc(hc,n);return(0,q.jsx)(ze,{present:r||bc(a.checked)||a.checked===!0,children:(0,q.jsx)(H.span,{"data-state":xc(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),_c=`CheckboxBubbleInput`,vc=G.forwardRef(ac(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}=uc(_c,e),g=L(r,h),_=je(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=bc(s),n.call(e,!bc(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=G.useRef(!bc(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 yc(e){return typeof e==`function`}ac(yc,`isFunction`);function bc(e){return e===`indeterminate`}ac(bc,`isIndeterminate`);function xc(e){return bc(e)?`indeterminate`:e?`checked`:`unchecked`}ac(xc,`getState`);function Sc({className:e,...t}){return(0,q.jsx)(mc,{"data-slot":`checkbox`,className:I(`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)(gc,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,q.jsx)(z,{name:`check`,className:`size-lt-icon-sm`})})})}function Cc(e,t){if(!t)return e;let n=e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``);return n?`${t}-${n}`:t}function wc(e,t){let n=dt(),r=pt(e),i=n?n.getValue(e):r,a=Te();(0,G.useEffect)(()=>{i===void 0&&t!==void 0&&(n?n.setValue(e,t):a(e,t))},[e,t,i,a,n])}var Tc=({node:e})=>{let{hidden:t,readOnly:n,disabled:r}=ot(e),i=e.props.name,a=dt(),{fieldIdPrefix:o}=De(),s=Cc(a?a.scopedName(i):i,o),c=pt(i),l=a?a.getValue(i):c,{commit:u}=Ne(),d=Xe(e.props.value),f=l===void 0?d:Xe(l);return wc(i,d),t?null:(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,q.jsx)(Sc,{autoFocus:e.props.autoFocus??void 0,checked:f,"data-test":j(i),disabled:n||r,id:s,name:s,onCheckedChange:e=>{u(i,e===!0)},tabIndex:e.props.tabIndex??void 0}),(0,q.jsx)(Ue,{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 Ec(e){let{errors:t,fieldIdPrefix:n}=De(),r=dt(),i=ot(e),a=mt(e),o=a.name??``,s=pt(o),c=r?r.getValue(o):s,l=c===void 0?a.value:c,u=typeof l==`string`||typeof l==`number`?String(l):``,d=Cc(r?r.scopedName(o):o,n),f=r?r.errorKey(o):o,{commit:p,change:m,blur:h}=Ne(),g=e=>p(o,e),_=e=>m(o,e),v=()=>h(o);return{...i,localName:o,name:d,testId:j(o),value:u,error:t[f],commit:g,change:_,blur:v}}var Dc=({node:e})=>{let t=ha(e),{localName:n,name:r,testId:i,value:a,error:o,hidden:s,required:c,readOnly:l,disabled:u,commit:d}=Ec(e),f=(0,G.useMemo)(()=>t.props.options??[],[t.props]),p=f[0]?.value??``,m=a||p;return wc(n,m||void 0),s||f.length===0?null:(0,q.jsx)(nt,{error:o,helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,id:r,required:c,children:t=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`input`,{name:r,type:`hidden`,value:m}),(0,q.jsx)(Zo,{...t,ariaLabel:e.props.label??void 0,autoFocus:e.props.autoFocus??void 0,disabled:l||u,name:i??`segment`,onSelect:d,options:f,tabIndex:e.props.tabIndex??void 0,value:m})]})})};function Oc(){return(Oc=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 kc(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 Ac(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 jc=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},Mc=function(e){return`touches`in e},Nc=function(e){return e&&e.ownerDocument.defaultView||self},Pc=function(e,t,n){var r=e.getBoundingClientRect(),i=Mc(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:jc((i.pageX-(r.left+Nc(e).pageXOffset))/r.width),top:jc((i.pageY-(r.top+Nc(e).pageYOffset))/r.height)}},Fc=function(e){!Mc(e)&&e.preventDefault()},Ic=G.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,i=kc(e,[`onMove`,`onKey`,`onEnd`]),a=(0,G.useRef)(null),o=Ac(t),s=Ac(n),c=Ac(r),l=(0,G.useRef)(null),u=(0,G.useRef)(!1),d=(0,G.useMemo)(function(){var e=function(e){Fc(e),(Mc(e)?e.touches.length>0:e.buttons>0)&&a.current?o(Pc(a.current,e,l.current)):(n(!1),c())},t=function(){n(!1),c()};function n(n){var r=u.current,i=Nc(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&&(Fc(t),!function(e,t){return t&&!Mc(e)}(t,u.current)&&r)){if(Mc(t)){u.current=!0;var i=t.changedTouches||[];i.length&&(l.current=i[0].identifier)}r.focus(),o(Pc(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`,Oc({},i,{onTouchStart:f,onMouseDown:f,className:`react-colorful__interactive`,ref:a,onKeyDown:p,onKeyUp:m,tabIndex:0,role:`slider`}))}),Lc=function(e){return e.filter(Boolean).join(` `)},Rc=function(e){var t=e.color,n=e.left,r=e.top,i=r===void 0?.5:r,a=Lc([`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 zc=function(e){return qc(Bc(e))},Bc=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}},Vc=function(e){return Kc(Wc(e))},Hc=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)}},Uc=function(e){var t=Hc(e);return`hsl(`+t.h+`, `+t.s+`%, `+t.l+`%)`},Wc=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)}},Gc=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Kc=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i<1?Gc($(255*i)):``;return`#`+Gc(t)+Gc(n)+Gc(r)+a},qc=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}},Jc=G.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,i=Lc([`react-colorful__hue`,e.className]);return G.createElement(`div`,{className:i},G.createElement(Ic,{onMove:function(e){n({h:360*e.left})},onKey:function(e){n({h:jc(t+360*e.left,0,360)})},onEnd:r,"aria-label":`Hue`,"aria-valuenow":$(t),"aria-valuemax":`360`,"aria-valuemin":`0`},G.createElement(Rc,{className:`react-colorful__hue-pointer`,left:t/360,color:Uc({h:t,s:100,v:100,a:1})})))}),Yc=G.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,i={backgroundColor:Uc({h:t.h,s:100,v:100,a:1})};return G.createElement(`div`,{className:`react-colorful__saturation`,style:i},G.createElement(Ic,{onMove:function(e){n({s:100*e.left,v:100-100*e.top})},onKey:function(e){n({s:jc(t.s+100*e.left,0,100),v:jc(t.v-100*e.top,0,100)})},onEnd:r,"aria-label":`Color`,"aria-valuetext":`Saturation `+$(t.s)+`%, Brightness `+$(t.v)+`%`},G.createElement(Rc,{className:`react-colorful__saturation-pointer`,top:1-t.v/100,left:t.s/100,color:Uc(t)})))}),Xc=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()||Xc(Bc(e),Bc(t))};function Qc(e,t,n,r){var i=Ac(n),a=Ac(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;Xc(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 $c,el=typeof window<`u`?G.useLayoutEffect:G.useEffect,tl=function(){return $c||(typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0)},nl=new WeakMap,rl=function(e){el(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(!nl.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=tl();o&&a.setAttribute(`nonce`,o),nl.set(r,a),i.appendChild(a)}}},[])},il=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=kc(e,[`className`,`colorModel`,`color`,`onChange`,`onChangeEnd`]),c=(0,G.useRef)(null);rl(c);var l=Qc(n,i,a,o),u=l[0],d=l[1],f=l[2],p=Lc([`react-colorful`,t]);return G.createElement(`div`,Oc({},s,{ref:c,className:p}),G.createElement(Yc,{hsva:u,onChange:d,onChangeEnd:f}),G.createElement(Jc,{hue:u.h,onChange:d,onChangeEnd:f,className:`react-colorful__last-control`}))},al={defaultColor:`000`,toHsva:zc,fromHsva:function(e){return Vc({h:e.h,s:e.s,v:e.v,a:1})},equal:Zc},ol=function(e){return G.createElement(il,Oc({},e,{colorModel:al}))};function sl(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 cl({value:e,onChange:t,palette:n,hexLabel:r=`Hex color`,paletteLabel:i=`Color palette`}){let[a,o]=(0,G.useState)(null),s=sl(e)??`#6b7280`;return(0,q.jsxs)(`div`,{className:`flex w-56 flex-col gap-3`,"data-slot":`color-picker`,children:[(0,q.jsx)(ol,{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=sl(e)??e;return(0,q.jsx)(`button`,{"aria-label":n,"aria-selected":n===s,className:I(`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)(ht,{"aria-label":r,onBlur:()=>o(null),onChange:e=>{let n=e.target.value,r=sl(n);o(n),r!==null&&t(r)},value:a??s})]})}function ll({node:e,label:t,children:n}){let r=Ec(e);return r.hidden?null:(0,q.jsx)(nt,{error:r.error,helperText:mt(e).helperText??void 0,tooltip:mt(e).tooltip??void 0,label:t,id:r.name,required:r.required,children:e=>n(r,e)})}var ul=({node:e})=>{let t=e.props;return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,value:n,readOnly:r,disabled:i,commit:a},o)=>{let s=sl(n);return(0,q.jsxs)(ke,{children:[(0,q.jsx)(`input`,{name:e,type:`hidden`,value:s??``}),(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(`button`,{...o,className:I(xt(),`flex items-center gap-2 text-left`),"data-test":`color-picker-${e}`,disabled:i||r,type:`button`,children:s?(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:s}}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:s})]}):(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:t.placeholder??``})})}),(0,q.jsx)(pe,{className:`p-3`,children:(0,q.jsx)(cl,{onChange:e=>a(e),palette:t.palette,value:s??`#6b7280`})})]})}})},dl=(0,G.lazy)(async()=>{let{DatePickerField:e}=await rn(async()=>{let{DatePickerField:e}=await import(`./chunks/date-picker-field-DepKtR_m.js`);return{DatePickerField:e}},__vite__mapDeps([17,1,3,4,18,2,12,7,19]),import.meta.url);return{default:e}});function fl(e){return(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(dl,{...e})})}var pl=({node:e})=>{let t=e.props;return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,change:o,blur:s},c)=>(0,q.jsx)(fl,{controlProps:c,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})})},ml=({node:e})=>{let t=e.props,{timezone:n}=O();return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,testId:r,value:i,readOnly:a,disabled:o,change:s,blur:c},l)=>(0,q.jsx)(fl,{controlProps:l,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 hl({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 gl(e,{ref:t,target:n,filename:r,contentType:i,values:a}){return Gt(e,{method:`POST`,ref:t,body:JSON.stringify({...a,_sub:`upload`,_target:n,filename:r,contentType:i}),throwOnError:!1})}function _l(e,t){return Array.isArray(t)?Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}var vl=({node:e})=>{let{t}=T(`lattice`),n=e.props,{hidden:r,required:i,readOnly:a,disabled:o}=ot(e),{action:s,componentRef:c,errors:l}=De(),u=n.name,d=dt(),f=d?d.scopedName(u):u,p=d?d.errorKey(u):u,m=p,h=Ie(),g=Te(),_=(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,w=(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)(w),[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){_l(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 A=(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;A.forEach(t=>e.items.add(t)),v.current.files=e.files},[A,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 gl(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 hl({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)(nt,{error:l[p],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,id:_,required:i,children:e=>(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":j(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":j(`${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":j(`${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)(Qe,{size:`sm`,icon:`x`,label:t(`form.file-upload.remove`,`Remove {{name}}`,{name:e.name}),"data-test":j(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":j(`${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`,{...e,accept:n.accept??void 0,"aria-label":n.label??u,className:`sr-only`,"data-test":j(`${u}-input`),multiple:S,name:x?void 0:C,onChange:e=>{F(e.target.files),x&&(e.target.value=``)},ref:v,type:`file`})]})})};function yl({label:e,summaryLabel:t,variant:n,emphasis:r}){let{componentId:i,errors:a,fieldLabels:o,processing:s}=De(),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)(la,{}),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 bl={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`,around:`justify-around`,evenly:`justify-evenly`};function xl({componentId:e,reset:t}){let n=ft();return Cn(a.resetForm,r=>{let i=r.detail;(!i?.form||i.form===e)&&(t(),n())}),null}function Sl({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}=Ea(e,n,r),p=(0,G.useMemo)(()=>({markUserEdit:f}),[f]);return(0,q.jsx)(Oe,{value:p,children:(0,q.jsx)(ma,{nodes:d,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t,i&&(0,q.jsx)(`div`,{className:`flex gap-3 ${bl[s??`end`]}`,children:a?.length?a.map((e,t)=>e.props.buttonType===`submit`?(0,q.jsx)(yl,{emphasis:e.props.emphasis??o,label:e.props.label??c,summaryLabel:u,variant:e.props.variant??l},En(e,t)):(0,q.jsx)(Y,{node:e},En(e,t))):(0,q.jsx)(yl,{emphasis:o,label:c,summaryLabel:u,variant:l})})]})})})}function Cl(e){return!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?e:void 0}var wl=({children:e,node:t})=>{let n=(0,G.useMemo)(()=>({...Da(t.schema).values,...t.props.state}),[t.schema,t.props.state]);return(0,q.jsx)(ut,{initial:n,children:(0,q.jsx)(Tl,{node:t,children:e})})};function Tl({children:e,node:t}){let{t:n}=T(`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)(()=>Da(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=ft(),S=e=>{let t=Cl(e);t!==!1&&x(t)},C=(0,G.useRef)(null),w=(0,G.useRef)(`idle`),[E,D]=(0,G.useState)(0);return(0,G.useEffect)(()=>{E>0&&w.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:Pt(o),className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,onStart:()=>{w.current=w.current===`renewing`?`retried`:`idle`},onSuccess:()=>S(d),onError:()=>S(u),onHttpException:e=>{if(e.status===403&&o!==``&&w.current!==`retried`)return w.current=`renewing`,Wt(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)(me,{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)(xl,{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)(Sl,{action:i,componentRef:o,nodes:t.schema,shouldRenderSubmitButton:p,submitButtons:m,submitEmphasis:v,submitJustify:h,submitLabel:g,submitVariant:_,summaryLabel:y,children:e})]})})}var El=({node:e})=>{let t=dt(),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 Dl({affix:e,side:t,squared:n=!1}){return(0,q.jsx)(`span`,{"data-slot":`affix-${t}`,className:I(`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)(F,{className:`size-lt-icon-md`,icon:e.icon}):e.text})}function Ol({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)(Dl,{affix:e,side:`start`}):null,(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:r(I(`focus-visible:ring-0`,e&&`rounded-l-none`,(t||n)&&`rounded-r-none`))}),t?(0,q.jsx)(Dl,{affix:t,side:`end`,squared:!!n}):null,n]})}var kl=({node:e})=>{let t=e.props;return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o},s)=>{let c=e=>o(e.target.value);return t.slider?(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`input`,{...s,"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,max:t.max??void 0,min:t.min??void 0,name:e,onChange:c,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)(Ol,{prefix:t.prefix,suffix:t.suffix,children:o=>(0,q.jsx)(ht,{...s,autoFocus:t.autoFocus??!1,className:o,"data-test":n,disabled:a,max:t.max??void 0,min:t.min??void 0,name:e,onChange:c,placeholder:t.placeholder??``,readOnly:i,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`number`,value:r})})}})},Al=Object.defineProperty,jl=Object.defineProperties,Ml=Object.getOwnPropertyDescriptors,Nl=Object.getOwnPropertySymbols,Pl=Object.prototype.hasOwnProperty,Fl=Object.prototype.propertyIsEnumerable,Il=(e,t,n)=>t in e?Al(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ll=(e,t)=>{for(var n in t||={})Pl.call(t,n)&&Il(e,n,t[n]);if(Nl)for(var n of Nl(t))Fl.call(t,n)&&Il(e,n,t[n]);return e},Rl=(e,t)=>jl(e,Ml(t)),zl=(e,t)=>{var n={};for(var r in e)Pl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Nl)for(var r of Nl(e))t.indexOf(r)<0&&Fl.call(e,r)&&(n[r]=e[r]);return n};function Bl(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function Vl(e){let t=G.useRef();return G.useEffect(()=>{t.current=e}),t.current}var Hl=18,Ul=40,Wl=`${Ul}px`,Gl=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`);function Kl({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-Hl,f=u;document.querySelectorAll(Gl).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>=Ul)}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:Wl}}var ql=G.createContext({}),Jl=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=Xl,render:h,children:g}=n,_=zl(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=Vl(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;`;Yl(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Yl(e.sheet,`[data-input-otp]:autofill { ${t} }`),Yl(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Yl(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; } }`),Yl(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(()=>{Bl(()=>{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=Kl({containerRef:E,inputRef:T,pushPasswordManagerStrategy:d,isFocused:j}),R=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]),ee=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]),te=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]),ne=G.useMemo(()=>({position:`relative`,cursor:_.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[_.disabled]),re=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]),z=G.useMemo(()=>G.createElement(`input`,Rl(Ll({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;te(e),(t=_.onPaste)==null||t.call(_,e)},onChange:R,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;ee(),(t=_.onFocus)==null||t.call(_,e)},onBlur:e=>{var t;M(!1),(t=_.onBlur)==null||t.call(_,e)}})),[R,ee,te,l,re,a,F,N,_,w?.source,x]),B=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]),ie=G.useMemo(()=>h?h(B):G.createElement(ql.Provider,{value:B},g),[g,B,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:ne,className:p},ie,G.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},z)))});Jl.displayName=`Input`;function Yl(e,t){try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}}var Xl=`
3
+ `);r=a.pop()??``;for(let e of a){if(e.trim()===``)continue;let t=Ga(e);t&&(yield t)}}if(r+=n.decode(),r.trim()!==``){let e=Ga(r);e&&(yield e)}}finally{await t.cancel().catch(()=>{})}}var Xa=0;function Za(){return Xa+=1,`chat-${Xa}`}function Qa(e){return e instanceof DOMException&&e.name===`AbortError`}function $a(e){return e instanceof Error?e.message:String(e)}function eo(e){let t=e.at(-1);return t!==void 0&&t.role===`assistant`}function to(e,t){if(!eo(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 no({endpoint:e,transport:t=qa,initialMessages:n=[],generateId:r=Za}){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(to(f.current,n))}s(e=>e===`streaming`||e===`submitted`?`idle`:e)}catch(e){if(Qa(e)){s(`idle`);return}l($a(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=eo(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 ro({message:e}){let t=e.role===`user`;return(0,q.jsx)(`div`,{className:I(`flex flex-col gap-1`,t?`items-end`:`items-start`),"data-test":j(`chat-message-${e.role}`),children:(0,q.jsx)(`div`,{className:I(`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 io({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":j(`chat-messages`),children:[e.map(e=>(0,q.jsx)(ro,{message:e},e.id)),(0,q.jsx)(`div`,{ref:t})]})}function ao({onSubmit:e,disabled:t=!1,placeholder:n}){let{t:r}=T(`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:I(`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-slot":`prompt-input`,"data-test":j(`chat-input`),disabled:t,onChange:e=>a(e.target.value),onKeyDown:s,placeholder:n,rows:1,value:i}),(0,q.jsx)(W,{"data-test":j(`chat-send`),disabled:t,onClick:o,size:`sm`,type:`button`,children:r(`common.chat.send`,`Send`)})]})}var oo=bn({name:`lattice/chat`,components:{"chat.box":K(({node:e})=>{let t=e.props,{t:n}=T(`lattice`),r=(0,G.useMemo)(()=>t.remote?Ja(t.remote):qa,[t.remote]),{messages:i,status:a,error:o,sendMessage:s,setMessages:c}=no({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 $t(t.historyEndpoint,{remote:t.remote});c(e.messages);return}let e=await Gt(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:I(`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":j(`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)(io,{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)(ao,{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":j(`chat-tool-call`),children:[`🔧 `,e.props.name,`(`,JSON.stringify(e.props.args),`)`]}))}}),so={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 co(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(``)}function lo(){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 uo=({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:I(`inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-lt-muted font-medium text-lt-muted-fg select-none`,so[r]),children:t?(0,q.jsx)(`img`,{src:t,alt:i??``,className:`size-full object-cover`}):n?co(n):(0,q.jsx)(lo,{})})};function fo({color:e,className:t,style:n,...r}){let i=Et(Dt(e??void 0)??Ct(`gray`));return(0,q.jsx)(`span`,{"data-slot":`badge`,className:I(`lt-badge`,i.className,t),style:{...i.style,...n},...r})}var po=({node:e})=>(0,q.jsx)(fo,{color:e.props.color,children:e.props.label});function mo({className:e,...t}){return(0,q.jsx)(`article`,{"data-slot":`card`,className:I(`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 ho({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-header`,className:I(`flex flex-col gap-1.5 px-lt-gutter`,e),...t})}function go({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-title`,className:I(`font-semibold leading-none`,e),...t})}function _o({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-description`,className:I(`text-sm text-lt-muted-fg`,e),...t})}function vo({className:e,...t}){return(0,q.jsx)(`div`,{"data-slot":`card-content`,className:I(`px-lt-gutter`,e),...t})}var yo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props;return(0,q.jsxs)(mo,{"data-lattice-component":P(t),children:[(n||r)&&(0,q.jsxs)(ho,{children:[n&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(go,{children:n}),(0,q.jsx)(it,{content:i})]}),r&&(0,q.jsxs)(`div`,{className:`flex items-center`,children:[(0,q.jsx)(_o,{children:r}),!n&&(0,q.jsx)(it,{content:i})]})]}),e&&(0,q.jsx)(vo,{className:`flex flex-col gap-6`,children:e})]})},bo=(0,G.lazy)(()=>rn(()=>import(`./chunks/chart-view-CFV7BU_D.js`),__vite__mapDeps([10,1,3,4,11,6,12,7,13,14]),import.meta.url)),xo=({children:e,node:t})=>(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(bo,{node:t,children:e})});async function So(e){if(!navigator?.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function Co({value:e,label:t,testId:n,className:r,iconOnly:i=!1,children:a}){let{t:o}=T(`lattice`),[s,c]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!s)return;let e=window.setTimeout(()=>c(!1),1500);return()=>window.clearTimeout(e)},[s]);async function l(){await So(e)&&c(!0)}let u=s?o(`common.copied-value`,`Copied {{label}}`,{label:t}):o(`common.copy-value`,`Copy {{label}}`,{label:t});return i?(0,q.jsx)(Qe,{icon:s?`check`:`copy`,label:u,"data-test":n,className:r,onClick:()=>void l()}):(0,q.jsx)(W,{type:`button`,size:`sm`,emphasis:`outline`,icon:s?`check`:`copy`,"data-test":n,className:r,"aria-label":u,onClick:()=>void l(),children:s?o(`common.copied`,`Copied`):a??o(`common.copy`,`Copy`)})}function wo({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)(Co,{value:e,label:t,testId:n})]})}var To=(0,G.lazy)(()=>rn(()=>import(`./chunks/code-block-view-fzD5e55N.js`),__vite__mapDeps([15,1,7,16]),import.meta.url));function Eo({"aria-label":e,children:t,className:n,copyable:r=!1,language:i=`text`,lineNumbers:a=!1,maxHeight:o=null,role:s=e?`region`:void 0,wrap:c=!1,...l}){let u=(0,q.jsx)(`pre`,{className:I(`max-w-full overflow-auto p-3 font-lt-mono text-xs`,c&&`whitespace-pre-wrap wrap-anywhere`),style:{maxHeight:o??void 0},children:a?(0,q.jsx)(`code`,{className:`grid grid-cols-[auto_1fr]`,children:t.split(`
4
+ `).map((e,t)=>(0,q.jsxs)(G.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`mr-3 border-r border-lt-border pr-3 text-right text-lt-muted-fg select-none`,children:t+1}),(0,q.jsx)(`span`,{children:e||`​`})]},t))}):t});return(0,q.jsxs)(`div`,{"data-slot":`code-block`,"aria-label":e,role:s,...l,className:I(`relative max-w-full overflow-hidden rounded-lt-sm bg-lt-muted text-lt-fg`,n),children:[r?(0,q.jsx)(Co,{value:t,label:e??`code`,iconOnly:!0,className:`absolute top-3 right-6 z-10 bg-lt-bg/80 hover:bg-lt-bg`}):null,(0,q.jsx)(G.Suspense,{fallback:u,children:(0,q.jsx)(To,{language:i,lineNumbers:a,maxHeight:o,wrap:c,children:t})})]})}var Do=({node:e})=>(0,q.jsx)(Eo,{copyable:e.props.copyable,language:e.props.language,lineNumbers:e.props.lineNumbers,maxHeight:e.props.maxHeight,wrap:e.props.wrap,children:e.props.code}),Oo=({children:e,node:t})=>{let n=t.props.rememberState!==!1,r=Tn(t.props.trigger),i=P(t),a=`lattice:collapsible:${i??`default`}`,o=`${i??`collapsible`}-content`,[s,c]=hi(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":N(`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)(it,{content:t.props.tooltip})})]}),(0,q.jsx)(z,{name:`chevron-down`,className:I(`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 ko(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 Ao=({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":P(t),role:n?`group`:void 0,style:ko(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":P(t),role:n?`group`:void 0,style:ko(i,r),children:(0,q.jsxs)(`div`,{className:I(`flex w-fit gap-2`,c?`flex-col-reverse`:`flex-col`),children:[(0,q.jsx)(`button`,{"aria-expanded":o,className:I(`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})]})})},jo={lg:320,md:64,sm:40,xl:384,xs:32,"2xl":448,"3xl":512,"4xl":576},Mo=({node:e})=>{let t=e.props.endpoint??``,n=e.props.lazy===!0,r=e.props.ref??``,i=jo[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 Kt(t,{ref:r});s(Tn(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(a.reloadComponent,t),()=>window.removeEventListener(a.reloadComponent,t)},[f,e.id]),(0,G.useEffect)(()=>{function e(){c&&f()}return window.addEventListener(a.localeChange,e),()=>window.removeEventListener(a.localeChange,e)},[c,f]),(0,q.jsx)(`div`,{"data-lattice-fragment":e.id,style:u&&o.length===0?{minHeight:i}:void 0,children:u&&o.length===0?(0,q.jsx)(fa,{className:`w-full`,style:{height:i}}):(0,q.jsx)(J,{nodes:o})})};function No(e,t,n){let r=Object.entries(e??{});if(r.length!==0)return Object.fromEntries(r.map(([e,r])=>[`${t}-${e}`,n(r)]))}var Po=e=>typeof e==`number`?`repeat(${e}, minmax(0, 1fr))`:e,Fo=e=>e===`full`?`1 / -1`:`span ${e} / span ${e}`,Io=({node:e})=>(0,q.jsx)(`div`,{"data-slot":`grid`,"data-lattice-component":P(e),className:`lt-grid grid gap-x-4 gap-y-6`,style:No(e.props.columns,`--lt-grid-cols`,Po),children:(e.schema??[]).map((e,t)=>(0,q.jsx)(`div`,{"data-slot":`grid-item`,style:No(e.props?.columnSpan,`--lt-col-span`,Fo),children:(0,q.jsx)(Y,{node:e})},En(e,t)))}),Lo=({node:e})=>{let{text:t,tooltip:n}=e.props,r=Math.min(Math.max(e.props.level,1),6),i=I(`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)(it,{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)(wo,{value:t,label:t,children:o}):o},Ro={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`},zo=({node:e})=>{let{name:t,size:n,color:r,class:i}=e.props,a=(0,q.jsx)(F,{icon:t,className:I(Ro[n],i)}),o=Dt(r);return o?(0,q.jsx)(`span`,{className:`contents`,style:{color:wt(o)},children:a}):a};function Bo({src:e,alt:t,previewable:n,width:r,height:i,className:a,testId:o}){let{t:s}=T(`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)(ra,{open:c,onOpenChange:l,children:(0,q.jsxs)(sa,{"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)(aa,{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)(ia,{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 Vo=({node:e})=>{let{src:t,alt:n,size:r,circular:i,previewable:a}=e.props;return(0,q.jsx)(Bo,{alt:n??``,className:I(`object-cover`,i?`rounded-full`:`rounded-lt-sm`),height:r??void 0,previewable:a,src:t,testId:P(e),width:r??void 0})};function Ho(e,t){let n=e.detail?.modal;return n==null||n===t}var Uo=({children:e,node:t})=>{let{t:n}=T(`lattice`),r=t.props.title??n(`common.dialog`,`Dialog`),i=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&&Ho(e,t.id)&&(l.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(!0))}function n(e){(!t.id||Ho(e,t.id))&&c(!1)}return window.addEventListener(a.openModal,e),window.addEventListener(a.closeModal,n),()=>{window.removeEventListener(a.openModal,e),window.removeEventListener(a.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)(ra,{open:s,onOpenChange:c,children:(0,q.jsxs)(sa,{...i?{}:{"aria-describedby":void 0},placement:t.props.side??`center`,width:t.props.width,children:[(0,q.jsx)(ca,{closeLabel:o,description:i,title:r}),(0,q.jsx)(`div`,{className:`mt-6 space-y-6`,children:e})]})})},Wo={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`},Go={xs:24,sm:32,md:40,lg:48,xl:64,"2xl":80,"3xl":96,"4xl":128},Ko={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`},qo=({node:e})=>{let{value:t,max:r,shape:i,showValue:a,color:o,size:s}=e.props,{locale:c}=n(),l=wt(Dt(o)??Ct(`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=Go[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:I(`absolute inset-0 flex items-center justify-center font-medium text-lt-fg tabular-nums`,Ko[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:I(`w-full overflow-hidden rounded-full bg-lt-muted`,Wo[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})]})},Jo=({node:e})=>(0,q.jsx)(`span`,{style:{display:`contents`},dangerouslySetInnerHTML:{__html:e.props.html}}),Yo=({children:e,node:t})=>{let{title:n,description:r,tooltip:i}=t.props,a=t.props.collapsible===!0,o=t.props.rememberState!==!1,s=Tn(t.props.headerActions),c=P(t),[l,u]=hi(`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":N(`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)(z,{name:`chevron-down`,className:I(`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)(it,{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)(it,{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 Xo(e){return I(`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 Zo({ariaLabel:e,autoFocus:t=!1,className:n,disabled:r=!1,name:i,onSelect:a,options:o,tabIndex:s,value:c,...l}){let u=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!t)return;let e=u.current;(e?.querySelector(`button[aria-checked="true"]`)??e?.querySelector(`button`))?.focus()},[t]),(0,q.jsx)(`div`,{...l,"aria-label":e,className:I(`inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1`,n),ref:u,role:`radiogroup`,children:o.map(e=>{let t=c===e.value;return(0,q.jsx)(`button`,{"aria-checked":t,"data-test":`${i}-${e.value}`,className:I(Xo(t),r&&`cursor-not-allowed opacity-60`),disabled:r,onClick:()=>a(e.value),role:`radio`,tabIndex:s,type:`button`,children:e.label},e.value)})})}var Qo=({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)(Zo,{ariaLabel:e.props.label??void 0,name:n,onSelect:o,options:t,value:i})},$o=({node:e})=>{let t=e.props.orientation===`horizontal`;return(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":e.props.orientation,className:I(`shrink-0 bg-lt-border`,t?`h-px w-full`:`h-full w-px self-stretch`)})},es={center:`justify-items-center text-center`,start:`justify-items-start text-left`,stretch:`justify-items-stretch`},ts={center:`items-center text-center`,start:`items-center text-left`,stretch:`items-stretch justify-stretch`},ns={none:`gap-0`,xs:`gap-1`,lg:`gap-6`,md:`gap-4`,sm:`gap-2`,xl:`gap-8`},rs={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`},is={around:`justify-around`,between:`justify-between`,center:`justify-center`,end:`justify-end`,evenly:`justify-evenly`,start:`justify-start`},as={full:`h-full`,screen:`min-h-screen`},os={end:`ml-auto`,start:`mr-auto`},ss=({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":P(t),className:I(l?I(`flex`,r===`row`?`flex-wrap`:`flex-col`):`grid content-start`,l?ts[n]??ts.stretch:es[n]??es.stretch,ns[i]??ns.md,rs[a]??rs.full,o?is[o]:null,s?as[s]:null,c?os[c]:null),children:e})},cs=(0,G.createContext)(null);function ls(){return(0,G.useContext)(cs)||{activeValue:``,setActiveValue:()=>{}}}function us(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 ds(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 fs(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 ps(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 ms=({children:e,node:t})=>{let{t:n}=T(`lattice`),r=(0,G.useMemo)(()=>us(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||(ds(a,r)??d)||i),g=(0,G.useCallback)(e=>{if(e.confirm?.required){p.visit(ps(a,e.value),{preserveScroll:!0});return}h(e.value),fs(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)(cs.Provider,{value:v,children:(0,q.jsxs)(`div`,{className:I(`gap-6`,s?I(`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:I(`gap-1 rounded-lt bg-lt-muted p-1`,s&&`flex flex-col`,l&&`flex w-full`,!s&&!l&&I(`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:I(Xo(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:I(`min-w-0`,s&&`flex-1`),children:e})]})})},hs=({children:e,node:t})=>{let{activeValue:n}=ls(),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:I(`space-y-8`,!i&&`hidden`),hidden:!i,id:`${r}-panel`,role:`tabpanel`,tabIndex:0,children:a?e:null})},gs={center:`text-center`,left:`text-left`},_s={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`},vs=bn({components:{avatar:K(uo),badge:K(po),button:K(_t),card:K(yo),chart:K(xo),"code-block":K(Do),collapsible:K(Oo),"floating-panel":K(Ao),fragment:K(Mo),grid:K(Io),heading:K(Lo),icon:K(zo),image:K(Vo),link:K(Pe),modal:K(Uo),progress:K(qo),"raw-block":K(Jo),section:K(Yo),"segmented-control":K(Qo),separator:K($o),stack:K(ss),tab:K(hs),tabs:K(ms),text:K(({node:e})=>{let t=e.props.align??`left`,n=wt(Dt(e.props.color)??Ct(`muted`)),r=(0,q.jsx)(`p`,{className:I(`m-0`,`max-w-2xl`,gs[t]??gs.left,_s[e.props.size]),style:{color:n},children:e.props.text});return e.props.copyable?(0,q.jsx)(wo,{value:e.props.text,label:e.props.text,children:r}):r}),tooltip:K(({node:e})=>{let t=e.props.content,n=Tn(e.props.trigger);return t?n.length===0?(0,q.jsx)(it,{content:t}):(0,q.jsxs)(ke,{children:[(0,q.jsx)(_e,{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)(pe,{align:`start`,className:`max-w-xs p-3 text-sm [&_a]:underline`,dangerouslySetInnerHTML:{__html:t}})]}):null})},name:`lattice/ui`});function ys({addLabel:e,options:t,onSelect:n}){return(0,q.jsxs)(Le,{children:[(0,q.jsx)(Re,{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)(z,{name:`plus`}),e]})}),(0,q.jsx)(qe,{align:`start`,className:`min-w-[12rem]`,children:t.map(e=>(0,q.jsx)(ct,{"data-test":`builder-add-${e.type}`,onClick:()=>n(e.type),children:e.label},e.type))})]})}var bs={duplicate:{key:`table.row-actions.duplicate`,fallback:`Duplicate`,icon:`copy`},remove:{key:`table.row-actions.remove`,fallback:`Remove`,icon:`trash-2`}};function xs(e,t){return(e??Ss(t.removable)).map(e=>Cs(e,t)).filter(e=>e!==null)}function Ss(e){return e?[{type:`remove`,key:`remove`,label:null,icon:null,danger:!0}]:[]}function Cs(e,t){if(e.type===`duplicate`){let n=bs.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=bs.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 ws(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 Ts({actions:e}){let{t}=T(`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:ws(t.danger),onClick:t.onClick,children:(0,q.jsx)(z,{name:t.icon})})}return(0,q.jsxs)(Le,{children:[(0,q.jsx)(Re,{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)(z,{name:`more-horizontal`})})}),(0,q.jsx)(qe,{align:`end`,className:`min-w-[10rem]`,children:e.map(e=>(0,q.jsx)(ct,{"data-test":`row-action-${e.key}`,danger:e.danger,icon:e.icon,onClick:e.onClick,children:e.label},e.key))})]})}function Es({path:e,rows:t,rowKey:n}){return(0,q.jsx)(q.Fragment,{children:t.map((t,r)=>(0,q.jsx)(`input`,{type:`hidden`,name:ve(Se(e,r,n)),value:String(t[n]??``)},String(t.rowId??r)))})}function Ds({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 Os=(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}=T(`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)(Ds,{label:`Move up`,testId:`repeater-${e}-up-${t}`,onClick:()=>f(t,-1),children:(0,q.jsx)(z,{name:`arrow-up`})}),a&&!s&&(0,q.jsx)(Ds,{label:`Move down`,testId:`repeater-${e}-down-${t}`,onClick:()=>f(t,1),children:(0,q.jsx)(z,{name:`arrow-down`})}),(0,q.jsx)(Ts,{actions:xs(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},En(e,t)))})})]})}),ks={xs:{track:`minmax(4rem, 0.35fr)`,minPx:64,defaultPx:96},sm:{track:`minmax(6rem, 0.5fr)`,minPx:96,defaultPx:128},md:{track:`minmax(8rem, 1fr)`,minPx:128,defaultPx:176},lg:{track:`minmax(12rem, 1.5fr)`,minPx:192,defaultPx:240},xl:{track:`minmax(16rem, 2fr)`,minPx:256,defaultPx:320}},As=1024;function js(e){return ks[e].track}function Ms(e){return ks[e.width].minPx}function Ns(e){return ks[e.width].defaultPx}function Ps({columns:e,leadingTracks:t=[],trailingTracks:n=[],overrides:r={}}){return[...t,...e.map(e=>{let t=r[e.key];return t===void 0?js(e.width):`${Math.min(As,Math.max(Ms(e),t))}px`}),...n].join(` `)}var Fs=[];function Is({columnGapPx:e=0,columns:t,enabled:n,leadingTracks:r=Fs,showIndicator:i=!1,storageKey:a,trailingTracks:o=Fs}){let s=(0,G.useMemo)(()=>t.map(e=>e.key),[t]),[c,l]=mi(a??``,{},{enabled:!!a,parse:e=>Rs(e,t),serialize:e=>zs(e,s)}),u=(0,G.useRef)(c),d=(0,G.useRef)(null),f=(0,G.useRef)(null),p=(0,G.useCallback)(e=>Ps({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),h(p(e))},[h,l,p]),_=(0,G.useCallback)((e,t,n,r)=>({...e,[t.key]:Math.min(r??1024,Math.max(Ms(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]??Ns(e),[]);return{getResizeHandleProps:(0,G.useCallback)(a=>{let s=As,c=Ms(a),l=S(a),m=a.label??a.key,b=i?`after:bg-lt-border`:`after:bg-transparent`,x=n=>Ls({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 Ls({column:e,columnGapPx:t,columns:n,grid:r,leadingTracks:i,trailingTracks:a}){let o=r?.getBoundingClientRect().width??0;if(o<=0)return As;let s=[...i,...a].reduce((e,t)=>e+Vs(t),0),c=n.reduce((t,n)=>n.key===e.key?t:t+Ms(n),0),l=n.length+i.length+a.length,u=Math.max(0,l-1)*t,d=o-s-c-u;return Math.min(As,Math.max(Ms(e),d))}function Rs(e,t){let n=JSON.parse(e)?.overrides;if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`unexpected stored column widths shape`);let r=Bs(n,t);if(Object.keys(r).length===0)throw Error(`stored column widths hold no usable overrides`);return r}function zs(e,t){let n={},r=new Set(t);for(let[t,i]of Object.entries(e))r.has(t)&&typeof i==`number`&&Number.isFinite(i)&&(n[t]=i);return Object.keys(n).length===0?null:JSON.stringify({overrides:n})}function Bs(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(As,Math.max(Ms(r),t)))}return n}function Vs(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])*Hs():0}function Hs(){if(typeof window>`u`)return 16;let e=Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize);return Number.isFinite(e)&&e>0?e:16}var Us=`3rem`,Ws=`3rem`,Gs=[Us],Ks=[Ws],qs=`(min-width: 768px)`;function Js(){return pi(qs,!0)}function Ys(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 Xs=(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:_}=T(`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)(Ds,{label:`Move up`,testId:`table-${e}-up-${t}`,onClick:()=>p(t,-1),children:(0,q.jsx)(z,{name:`arrow-up`})}),l&&!o&&(0,q.jsx)(Ds,{label:`Move down`,testId:`table-${e}-down-${t}`,onClick:()=>p(t,1),children:(0,q.jsx)(z,{name:`arrow-down`})})]}),(0,q.jsx)(le,{base:e,index:t,row:n,onChange:(e,n)=>f(t,e,n),children:(0,q.jsx)(He,{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},En(e,t)))}):r.map((e,t)=>(0,q.jsx)(`div`,{children:(0,q.jsx)(Y,{node:e})},En(e,t)))})}),(0,q.jsx)(`div`,{className:`flex items-center`,children:(0,q.jsx)(Ts,{actions:xs(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}=T(`lattice`),m=Js(),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}=Is({columns:h,enabled:d,columnGapPx:12,leadingTracks:Gs,showIndicator:f,storageKey:d?`lattice:table-columns:form:${e}`:void 0,trailingTracks:Ks});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)(z,{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)(Xs,{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)(Os,{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 Qs=180;function $s(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function ec(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 ga(()=>{let e=[],r=new Map;return t.current.forEach((e,t)=>{e.style.transition=``,e.style.transform=``,r.set(t,e.getBoundingClientRect())}),$s()||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 ${Qs}ms ease-out`,t.style.transform=``})))}}),n.current=r,()=>{for(let t of e)cancelAnimationFrame(t)}},[e]),r}function tc(e,t){let n=dt(),r=n?n.errorKey(e):e,i=Te(),a=pt(r),o=Array.isArray(a)?a:ye(a,t),s=Ke(o);ga(()=>{s!==o&&i(r,s)},[o,s,i,r]);let c=(0,G.useCallback)(e=>{i(r,n=>e(Array.isArray(n)?n:ye(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=>Ge(t,e)),[c]),onMove:(0,G.useCallback)((e,t)=>c(n=>se(n,e,e+t)),[c]),onDuplicate:(0,G.useCallback)(e=>c(t=>xe(t,e)),[c]),append:(0,G.useCallback)(e=>c(t=>[...t,be(e)]),[c])}}var nc=[],rc=({node:e})=>{let t=e.props,n=t.name,r=va(e)??[],{errors:i}=De(),{hidden:a,required:o}=ot(e),{path:s,rows:c,onField:l,onRemove:u,onMove:d,onDuplicate:f,append:p}=tc(n,t.defaultItems??0),{t:m}=T(`lattice`),h=ec(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??nc,span:!r,heading:n?.label??`Unknown block: ${String(e.type)}`}});return(0,q.jsx)(nt,{error:i[s],helperText:t.helperText??void 0,tooltip:t.tooltip??void 0,label:t.label??``,id:s,required:o,children:e=>(0,q.jsxs)(`div`,{...e,className:`flex flex-col gap-3`,role:`group`,children:[(0,q.jsx)(Es,{path:s,rows:c,rowKey:ue}),(0,q.jsx)(Es,{path:s,rows:c,rowKey:`type`}),v?(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(Zs,{base:s,columns:Ys(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)(Os,{base:s,index:r,row:e,template:i.schema??nc,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)(Ts,{actions:xs(t.rowActions,{index:r,removable:!_,onRemove:u,onDuplicate:f,t:m})})]})},a)}),!g&&(0,q.jsx)(ys,{addLabel:t.addLabel??`Add`,options:b,onSelect:e=>p({type:e})})]})})},ic=Object.defineProperty,ac=(e,t)=>ic(e,`name`,{value:t,configurable:!0}),oc=`Checkbox`,[sc,cc]=lt(oc),[lc,uc]=sc(oc);function dc(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:oc}),[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:!bc(i)&&i,isFormControl:x,bubbleInput:g,setBubbleInput:_};return(0,q.jsx)(lc,{scope:t,...S,children:yc(d)?d(S):r})}ac(dc,`CheckboxProvider`);var fc=`CheckboxTrigger`,pc=G.forwardRef(ac(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}=uc(fc,e),g=L(i,u),_=G.useRef(c);return G.useEffect(()=>{let e=a?.form;if(e){let t=ac(()=>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":bc(c)?`mixed`:c,"aria-required":l,"data-state":xc(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=>bc(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),mc=G.forwardRef(ac(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)(dc,{__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)(pc,{...d,ref:t,__scopeCheckbox:n}),e&&(0,q.jsx)(vc,{__scopeCheckbox:n})]})})},`Checkbox`)),hc=`CheckboxIndicator`,gc=G.forwardRef(ac(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=uc(hc,n);return(0,q.jsx)(ze,{present:r||bc(a.checked)||a.checked===!0,children:(0,q.jsx)(H.span,{"data-state":xc(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),_c=`CheckboxBubbleInput`,vc=G.forwardRef(ac(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}=uc(_c,e),g=L(r,h),_=je(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=bc(s),n.call(e,!bc(s)&&s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let x=G.useRef(!bc(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 yc(e){return typeof e==`function`}ac(yc,`isFunction`);function bc(e){return e===`indeterminate`}ac(bc,`isIndeterminate`);function xc(e){return bc(e)?`indeterminate`:e?`checked`:`unchecked`}ac(xc,`getState`);function Sc({className:e,...t}){return(0,q.jsx)(mc,{"data-slot":`checkbox`,className:I(`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)(gc,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,q.jsx)(z,{name:`check`,className:`size-lt-icon-sm`})})})}function Cc(e,t){if(!t)return e;let n=e.replace(/[^A-Za-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``);return n?`${t}-${n}`:t}function wc(e,t){let n=dt(),r=pt(e),i=n?n.getValue(e):r,a=Te();(0,G.useEffect)(()=>{i===void 0&&t!==void 0&&(n?n.setValue(e,t):a(e,t))},[e,t,i,a,n])}var Tc=({node:e})=>{let{hidden:t,readOnly:n,disabled:r}=ot(e),i=e.props.name,a=dt(),{fieldIdPrefix:o}=De(),s=Cc(a?a.scopedName(i):i,o),c=pt(i),l=a?a.getValue(i):c,{commit:u}=Ne(),d=Xe(e.props.value),f=l===void 0?d:Xe(l);return wc(i,d),t?null:(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,q.jsx)(Sc,{autoFocus:e.props.autoFocus??void 0,checked:f,"data-test":j(i),disabled:n||r,id:s,name:s,onCheckedChange:e=>{u(i,e===!0)},tabIndex:e.props.tabIndex??void 0}),(0,q.jsx)(Ue,{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 Ec(e){let{errors:t,fieldIdPrefix:n}=De(),r=dt(),i=ot(e),a=mt(e),o=a.name??``,s=pt(o),c=r?r.getValue(o):s,l=c===void 0?a.value:c,u=typeof l==`string`||typeof l==`number`?String(l):``,d=Cc(r?r.scopedName(o):o,n),f=r?r.errorKey(o):o,{commit:p,change:m,blur:h}=Ne(),g=e=>p(o,e),_=e=>m(o,e),v=()=>h(o);return{...i,localName:o,name:d,testId:j(o),value:u,error:t[f],commit:g,change:_,blur:v}}var Dc=({node:e})=>{let t=ha(e),{localName:n,name:r,testId:i,value:a,error:o,hidden:s,required:c,readOnly:l,disabled:u,commit:d}=Ec(e),f=(0,G.useMemo)(()=>t.props.options??[],[t.props]),p=f[0]?.value??``,m=a||p;return wc(n,m||void 0),s||f.length===0?null:(0,q.jsx)(nt,{error:o,helperText:e.props.helperText??void 0,tooltip:e.props.tooltip??void 0,label:e.props.label??``,id:r,required:c,children:t=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`input`,{name:r,type:`hidden`,value:m}),(0,q.jsx)(Zo,{...t,ariaLabel:e.props.label??void 0,autoFocus:e.props.autoFocus??void 0,disabled:l||u,name:i??`segment`,onSelect:d,options:f,tabIndex:e.props.tabIndex??void 0,value:m})]})})};function Oc(){return(Oc=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 kc(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 Ac(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 jc=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e<t?t:e},Mc=function(e){return`touches`in e},Nc=function(e){return e&&e.ownerDocument.defaultView||self},Pc=function(e,t,n){var r=e.getBoundingClientRect(),i=Mc(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:jc((i.pageX-(r.left+Nc(e).pageXOffset))/r.width),top:jc((i.pageY-(r.top+Nc(e).pageYOffset))/r.height)}},Fc=function(e){!Mc(e)&&e.preventDefault()},Ic=G.memo(function(e){var t=e.onMove,n=e.onKey,r=e.onEnd,i=kc(e,[`onMove`,`onKey`,`onEnd`]),a=(0,G.useRef)(null),o=Ac(t),s=Ac(n),c=Ac(r),l=(0,G.useRef)(null),u=(0,G.useRef)(!1),d=(0,G.useMemo)(function(){var e=function(e){Fc(e),(Mc(e)?e.touches.length>0:e.buttons>0)&&a.current?o(Pc(a.current,e,l.current)):(n(!1),c())},t=function(){n(!1),c()};function n(n){var r=u.current,i=Nc(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&&(Fc(t),!function(e,t){return t&&!Mc(e)}(t,u.current)&&r)){if(Mc(t)){u.current=!0;var i=t.changedTouches||[];i.length&&(l.current=i[0].identifier)}r.focus(),o(Pc(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`,Oc({},i,{onTouchStart:f,onMouseDown:f,className:`react-colorful__interactive`,ref:a,onKeyDown:p,onKeyUp:m,tabIndex:0,role:`slider`}))}),Lc=function(e){return e.filter(Boolean).join(` `)},Rc=function(e){var t=e.color,n=e.left,r=e.top,i=r===void 0?.5:r,a=Lc([`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 zc=function(e){return qc(Bc(e))},Bc=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}},Vc=function(e){return Kc(Wc(e))},Hc=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)}},Uc=function(e){var t=Hc(e);return`hsl(`+t.h+`, `+t.s+`%, `+t.l+`%)`},Wc=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)}},Gc=function(e){var t=e.toString(16);return t.length<2?`0`+t:t},Kc=function(e){var t=e.r,n=e.g,r=e.b,i=e.a,a=i<1?Gc($(255*i)):``;return`#`+Gc(t)+Gc(n)+Gc(r)+a},qc=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}},Jc=G.memo(function(e){var t=e.hue,n=e.onChange,r=e.onChangeEnd,i=Lc([`react-colorful__hue`,e.className]);return G.createElement(`div`,{className:i},G.createElement(Ic,{onMove:function(e){n({h:360*e.left})},onKey:function(e){n({h:jc(t+360*e.left,0,360)})},onEnd:r,"aria-label":`Hue`,"aria-valuenow":$(t),"aria-valuemax":`360`,"aria-valuemin":`0`},G.createElement(Rc,{className:`react-colorful__hue-pointer`,left:t/360,color:Uc({h:t,s:100,v:100,a:1})})))}),Yc=G.memo(function(e){var t=e.hsva,n=e.onChange,r=e.onChangeEnd,i={backgroundColor:Uc({h:t.h,s:100,v:100,a:1})};return G.createElement(`div`,{className:`react-colorful__saturation`,style:i},G.createElement(Ic,{onMove:function(e){n({s:100*e.left,v:100-100*e.top})},onKey:function(e){n({s:jc(t.s+100*e.left,0,100),v:jc(t.v-100*e.top,0,100)})},onEnd:r,"aria-label":`Color`,"aria-valuetext":`Saturation `+$(t.s)+`%, Brightness `+$(t.v)+`%`},G.createElement(Rc,{className:`react-colorful__saturation-pointer`,top:1-t.v/100,left:t.s/100,color:Uc(t)})))}),Xc=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()||Xc(Bc(e),Bc(t))};function Qc(e,t,n,r){var i=Ac(n),a=Ac(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;Xc(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 $c,el=typeof window<`u`?G.useLayoutEffect:G.useEffect,tl=function(){return $c||(typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0)},nl=new WeakMap,rl=function(e){el(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(!nl.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=tl();o&&a.setAttribute(`nonce`,o),nl.set(r,a),i.appendChild(a)}}},[])},il=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=kc(e,[`className`,`colorModel`,`color`,`onChange`,`onChangeEnd`]),c=(0,G.useRef)(null);rl(c);var l=Qc(n,i,a,o),u=l[0],d=l[1],f=l[2],p=Lc([`react-colorful`,t]);return G.createElement(`div`,Oc({},s,{ref:c,className:p}),G.createElement(Yc,{hsva:u,onChange:d,onChangeEnd:f}),G.createElement(Jc,{hue:u.h,onChange:d,onChangeEnd:f,className:`react-colorful__last-control`}))},al={defaultColor:`000`,toHsva:zc,fromHsva:function(e){return Vc({h:e.h,s:e.s,v:e.v,a:1})},equal:Zc},ol=function(e){return G.createElement(il,Oc({},e,{colorModel:al}))};function sl(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 cl({value:e,onChange:t,palette:n,hexLabel:r=`Hex color`,paletteLabel:i=`Color palette`}){let[a,o]=(0,G.useState)(null),s=sl(e)??`#6b7280`;return(0,q.jsxs)(`div`,{className:`flex w-56 flex-col gap-3`,"data-slot":`color-picker`,children:[(0,q.jsx)(ol,{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=sl(e)??e;return(0,q.jsx)(`button`,{"aria-label":n,"aria-selected":n===s,className:I(`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)(ht,{"aria-label":r,onBlur:()=>o(null),onChange:e=>{let n=e.target.value,r=sl(n);o(n),r!==null&&t(r)},value:a??s})]})}function ll({node:e,label:t,children:n}){let r=Ec(e);return r.hidden?null:(0,q.jsx)(nt,{error:r.error,helperText:mt(e).helperText??void 0,tooltip:mt(e).tooltip??void 0,label:t,id:r.name,required:r.required,children:e=>n(r,e)})}var ul=({node:e})=>{let t=e.props;return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,value:n,readOnly:r,disabled:i,commit:a},o)=>{let s=sl(n);return(0,q.jsxs)(ke,{children:[(0,q.jsx)(`input`,{name:e,type:`hidden`,value:s??``}),(0,q.jsx)(_e,{asChild:!0,children:(0,q.jsx)(`button`,{...o,className:I(xt(),`flex items-center gap-2 text-left`),"data-test":`color-picker-${e}`,disabled:i||r,type:`button`,children:s?(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:s}}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:s})]}):(0,q.jsx)(`span`,{className:`text-lt-muted-fg`,children:t.placeholder??``})})}),(0,q.jsx)(pe,{className:`p-3`,children:(0,q.jsx)(cl,{onChange:e=>a(e),palette:t.palette,value:s??`#6b7280`})})]})}})},dl=(0,G.lazy)(async()=>{let{DatePickerField:e}=await rn(async()=>{let{DatePickerField:e}=await import(`./chunks/date-picker-field-DepKtR_m.js`);return{DatePickerField:e}},__vite__mapDeps([17,1,3,4,18,2,12,7,19]),import.meta.url);return{default:e}});function fl(e){return(0,q.jsx)(G.Suspense,{fallback:null,children:(0,q.jsx)(dl,{...e})})}var pl=({node:e})=>{let t=e.props;return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,change:o,blur:s},c)=>(0,q.jsx)(fl,{controlProps:c,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})})},ml=({node:e})=>{let t=e.props,{timezone:n}=O();return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,testId:r,value:i,readOnly:a,disabled:o,change:s,blur:c},l)=>(0,q.jsx)(fl,{controlProps:l,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 hl({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 gl(e,{ref:t,target:n,filename:r,contentType:i,values:a}){return Gt(e,{method:`POST`,ref:t,body:JSON.stringify({...a,_sub:`upload`,_target:n,filename:r,contentType:i}),throwOnError:!1})}function _l(e,t){return Array.isArray(t)?Array.isArray(e)&&e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}var vl=({node:e})=>{let{t}=T(`lattice`),n=e.props,{hidden:r,required:i,readOnly:a,disabled:o}=ot(e),{action:s,componentRef:c,errors:l}=De(),u=n.name,d=dt(),f=d?d.scopedName(u):u,p=d?d.errorKey(u):u,m=p,h=Ie(),g=Te(),_=(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,w=(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)(w),[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){_l(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 A=(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;A.forEach(t=>e.items.add(t)),v.current.files=e.files},[A,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 gl(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 hl({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)(nt,{error:l[p],helperText:n.helperText??void 0,tooltip:n.tooltip??void 0,label:n.label??``,id:_,required:i,children:e=>(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":j(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":j(`${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":j(`${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)(Qe,{size:`sm`,icon:`x`,label:t(`form.file-upload.remove`,`Remove {{name}}`,{name:e.name}),"data-test":j(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":j(`${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`,{...e,accept:n.accept??void 0,"aria-label":n.label??u,className:`sr-only`,"data-test":j(`${u}-input`),multiple:S,name:x?void 0:C,onChange:e=>{F(e.target.files),x&&(e.target.value=``)},ref:v,type:`file`})]})})};function yl({label:e,summaryLabel:t,variant:n,emphasis:r}){let{componentId:i,errors:a,fieldLabels:o,processing:s}=De(),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)(la,{}),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 bl={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`,around:`justify-around`,evenly:`justify-evenly`};function xl({componentId:e,reset:t}){let n=ft();return Cn(a.resetForm,r=>{let i=r.detail;(!i?.form||i.form===e)&&(t(),n())}),null}function Sl({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}=Ea(e,n,r),p=(0,G.useMemo)(()=>({markUserEdit:f}),[f]);return(0,q.jsx)(Oe,{value:p,children:(0,q.jsx)(ma,{nodes:d,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[t,i&&(0,q.jsx)(`div`,{className:`flex gap-3 ${bl[s??`end`]}`,children:a?.length?a.map((e,t)=>e.props.buttonType===`submit`?(0,q.jsx)(yl,{emphasis:e.props.emphasis??o,label:e.props.label??c,summaryLabel:u,variant:e.props.variant??l},En(e,t)):(0,q.jsx)(Y,{node:e},En(e,t))):(0,q.jsx)(yl,{emphasis:o,label:c,summaryLabel:u,variant:l})})]})})})}function Cl(e){return!e||Array.isArray(e)&&e.length===0?!1:Array.isArray(e)?e:void 0}var wl=({children:e,node:t})=>{let n=(0,G.useMemo)(()=>({...Da(t.schema).values,...t.props.state}),[t.schema,t.props.state]);return(0,q.jsx)(ut,{initial:n,children:(0,q.jsx)(Tl,{node:t,children:e})})};function Tl({children:e,node:t}){let{t:n}=T(`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)(()=>Da(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=ft(),S=e=>{let t=Cl(e);t!==!1&&x(t)},C=(0,G.useRef)(null),w=(0,G.useRef)(`idle`),[E,D]=(0,G.useState)(0);return(0,G.useEffect)(()=>{E>0&&w.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:Pt(o),className:`mx-auto flex w-full max-w-2xl flex-col gap-6`,onStart:()=>{w.current=w.current===`renewing`?`retried`:`idle`},onSuccess:()=>S(d),onError:()=>S(u),onHttpException:e=>{if(e.status===403&&o!==``&&w.current!==`retried`)return w.current=`renewing`,Wt(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)(me,{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)(xl,{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)(Sl,{action:i,componentRef:o,nodes:t.schema,shouldRenderSubmitButton:p,submitButtons:m,submitEmphasis:v,submitJustify:h,submitLabel:g,submitVariant:_,summaryLabel:y,children:e})]})})}var El=({node:e})=>{let t=dt(),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 Dl({affix:e,side:t,squared:n=!1}){return(0,q.jsx)(`span`,{"data-slot":`affix-${t}`,className:I(`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)(F,{className:`size-lt-icon-md`,icon:e.icon}):e.text})}function Ol({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)(Dl,{affix:e,side:`start`}):null,(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:r(I(`focus-visible:ring-0`,e&&`rounded-l-none`,(t||n)&&`rounded-r-none`))}),t?(0,q.jsx)(Dl,{affix:t,side:`end`,squared:!!n}):null,n]})}var kl=({node:e})=>{let t=e.props;return(0,q.jsx)(ll,{node:e,label:t.label??``,children:({name:e,testId:n,value:r,readOnly:i,disabled:a,commit:o},s)=>{let c=e=>o(e.target.value);return t.slider?(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`input`,{...s,"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,max:t.max??void 0,min:t.min??void 0,name:e,onChange:c,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)(Ol,{prefix:t.prefix,suffix:t.suffix,children:o=>(0,q.jsx)(ht,{...s,autoFocus:t.autoFocus??!1,className:o,"data-test":n,disabled:a,max:t.max??void 0,min:t.min??void 0,name:e,onChange:c,placeholder:t.placeholder??``,readOnly:i,step:t.step??void 0,tabIndex:t.tabIndex??void 0,type:`number`,value:r})})}})},Al=Object.defineProperty,jl=Object.defineProperties,Ml=Object.getOwnPropertyDescriptors,Nl=Object.getOwnPropertySymbols,Pl=Object.prototype.hasOwnProperty,Fl=Object.prototype.propertyIsEnumerable,Il=(e,t,n)=>t in e?Al(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ll=(e,t)=>{for(var n in t||={})Pl.call(t,n)&&Il(e,n,t[n]);if(Nl)for(var n of Nl(t))Fl.call(t,n)&&Il(e,n,t[n]);return e},Rl=(e,t)=>jl(e,Ml(t)),zl=(e,t)=>{var n={};for(var r in e)Pl.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Nl)for(var r of Nl(e))t.indexOf(r)<0&&Fl.call(e,r)&&(n[r]=e[r]);return n};function Bl(e){return[setTimeout(e,0),setTimeout(e,10),setTimeout(e,50)]}function Vl(e){let t=G.useRef();return G.useEffect(()=>{t.current=e}),t.current}var Hl=18,Ul=40,Wl=`${Ul}px`,Gl=[`[data-lastpass-icon-root]`,`com-1password-button`,`[data-dashlanecreated]`,`[style$="2147483647 !important;"]`].join(`,`);function Kl({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-Hl,f=u;document.querySelectorAll(Gl).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>=Ul)}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:Wl}}var ql=G.createContext({}),Jl=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=Xl,render:h,children:g}=n,_=zl(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=Vl(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;`;Yl(e.sheet,`[data-input-otp]::selection { background: transparent !important; color: transparent !important; }`),Yl(e.sheet,`[data-input-otp]:autofill { ${t} }`),Yl(e.sheet,`[data-input-otp]:-webkit-autofill { ${t} }`),Yl(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; } }`),Yl(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(()=>{Bl(()=>{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=Kl({containerRef:E,inputRef:T,pushPasswordManagerStrategy:d,isFocused:j}),R=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]),ee=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]),te=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]),ne=G.useMemo(()=>({position:`relative`,cursor:_.disabled?`default`:`text`,userSelect:`none`,WebkitUserSelect:`none`,pointerEvents:`none`}),[_.disabled]),re=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]),z=G.useMemo(()=>G.createElement(`input`,Rl(Ll({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;te(e),(t=_.onPaste)==null||t.call(_,e)},onChange:R,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;ee(),(t=_.onFocus)==null||t.call(_,e)},onBlur:e=>{var t;M(!1),(t=_.onBlur)==null||t.call(_,e)}})),[R,ee,te,l,re,a,F,N,_,w?.source,x]),B=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]),ie=G.useMemo(()=>h?h(B):G.createElement(ql.Provider,{value:B},g),[g,B,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:ne,className:p},ie,G.createElement(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`}},z)))});Jl.displayName=`Input`;function Yl(e,t){try{e.insertRule(t)}catch{console.error(`input-otp could not insert CSS rule:`,t)}}var Xl=`
4
5
  [data-input-otp] {
5
6
  --nojs-bg: white !important;
6
7
  --nojs-fg: black !important;
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.37.0"
2
+ "version": "0.38.0"
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lattice-php/lattice",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "Server-driven React components for Laravel and Inertia.",
5
5
  "license": "MIT",
6
6
  "author": "Manuel Christlieb <manuel@christlieb.eu>",