foss-design 0.9.11 → 0.9.12

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.
@@ -54,7 +54,7 @@ Error generating stack: `+e.message+`
54
54
  `},Th=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Eh=function(){v.useEffect(function(){return document.body.setAttribute(Ch,(Th()+1).toString()),function(){var e=Th()-1;e<=0?document.body.removeAttribute(Ch):document.body.setAttribute(Ch,e.toString())}},[])},Dh=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Eh();var a=v.useMemo(function(){return xh(i)},[i]);return v.createElement(Sh,{styles:wh(a,!t,i,n?``:`!important`)})},Oh=!1;if(typeof window<`u`)try{var kh=Object.defineProperty({},"passive",{get:function(){return Oh=!0,!0}});window.addEventListener(`test`,kh,kh),window.removeEventListener(`test`,kh,kh)}catch{Oh=!1}var Ah=Oh?{passive:!1}:!1,jh=function(e){return e.tagName===`TEXTAREA`},Mh=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!jh(e)&&n[t]===`visible`)},Nh=function(e){return Mh(e,`overflowY`)},Ph=function(e){return Mh(e,`overflowX`)},Fh=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Rh(e,r)){var i=zh(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Ih=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Lh=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Rh=function(e,t){return e===`v`?Nh(t):Ph(t)},zh=function(e,t){return e===`v`?Ih(t):Lh(t)},Bh=function(e,t){return e===`h`&&t===`rtl`?-1:1},Vh=function(e,t,n,r,i){var a=Bh(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=zh(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Rh(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Hh=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Uh=function(e){return[e.deltaX,e.deltaY]},Wh=function(e){return e&&`current`in e?e.current:e},Gh=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Kh=function(e){return`
55
55
  .block-interactivity-${e} {pointer-events: none;}
56
56
  .allow-interactivity-${e} {pointer-events: all;}
57
- `},qh=0,Jh=[];function Yh(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),i=v.useState(qh++)[0],a=v.useState(_h)[0],o=v.useRef(e);v.useEffect(function(){o.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=qm([e.lockRef.current],(e.shards||[]).map(Wh),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=v.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Hh(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Fh(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Fh(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Vh(h,t,e,h===`h`?s:c,!0)},[]),c=v.useCallback(function(e){var n=e;if(Jh.length&&Jh[Jh.length-1]===a){var r=`deltaY`in n?Uh(n):Hh(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Gh(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Wh).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=v.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Xh(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=v.useCallback(function(e){n.current=Hh(e),r.current=void 0},[]),d=v.useCallback(function(t){l(t.type,Uh(t),t.target,s(t,e.lockRef.current))},[]),f=v.useCallback(function(t){l(t.type,Hh(t),t.target,s(t,e.lockRef.current))},[]);v.useEffect(function(){return Jh.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ah),document.addEventListener(`touchmove`,c,Ah),document.addEventListener(`touchstart`,u,Ah),function(){Jh=Jh.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ah),document.removeEventListener(`touchmove`,c,Ah),document.removeEventListener(`touchstart`,u,Ah)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(a,{styles:Kh(i)}):null,p?v.createElement(Dh,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xh(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Zh=sh(ch,Yh),Qh=v.forwardRef(function(e,t){return v.createElement(uh,Gm({},e,{ref:t,sideCar:Zh}))});Qh.classNames=uh.classNames;var $h=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},eg=new WeakMap,tg=new WeakMap,ng={},rg=0,ig=function(e){return e&&(e.host||ig(e.parentNode))},ag=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ig(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},og=function(e,t,n,r){var i=ag(t,Array.isArray(e)?e:[e]);ng[n]||(ng[n]=new WeakMap);var a=ng[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(eg.get(e)||0)+1,l=(a.get(e)||0)+1;eg.set(e,c),a.set(e,l),o.push(e),c===1&&i&&tg.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),rg++,function(){o.forEach(function(e){var t=eg.get(e)-1,i=a.get(e)-1;eg.set(e,t),a.set(e,i),t||(tg.has(e)||e.removeAttribute(r),tg.delete(e)),i||e.removeAttribute(n)}),rg--,rg||(eg=new WeakMap,eg=new WeakMap,tg=new WeakMap,ng={})}},sg=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||$h(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),og(r,i,n,`aria-hidden`)):function(){return null}},cg=Object.defineProperty,lg=(e,t)=>cg(e,`name`,{value:t,configurable:!0}),ug=`Dialog`,[dg,fg]=op(ug),[pg,mg]=dg(ug),hg=lg(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=v.useRef(null),c=v.useRef(null),[l,u]=Sp({prop:r,defaultProp:i??!1,onChange:a,caller:ug}),[d,f]=v.useState(0),[p,m]=v.useState(0);return(0,R.jsx)(pg,{scope:t,triggerRef:s,contentRef:c,contentId:pp(),titleId:pp(),descriptionId:pp(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:v.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),gg=`DialogPortal`,[_g,vg]=dg(gg,{forceMount:void 0}),yg=lg(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=mg(gg,t);return(0,R.jsx)(_g,{scope:t,forceMount:n,children:v.Children.map(r,e=>(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),bg=`DialogOverlay`,xg=v.forwardRef(lg(function(e,t){let n=vg(bg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mg(bg,e.__scopeDialog);return a.modal?(0,R.jsx)(Mm,{present:r||a.open,children:(0,R.jsx)(Cg,{...i,ref:t})}):null},`DialogOverlay`)),Sg=Ap(`DialogOverlay.RemoveScroll`),Cg=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,...r}=e,i=mg(bg,n),a=np(t,im());return(0,R.jsx)(Qh,{as:Sg,allowPinchZoom:!0,shards:[i.contentRef],children:(0,R.jsx)(Gp.div,{"data-state":Ng(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),wg=`DialogContent`,Tg=v.forwardRef(lg(function(e,t){let n=vg(wg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mg(wg,e.__scopeDialog);return(0,R.jsx)(Mm,{present:r||a.open,children:a.modal?(0,R.jsx)(Eg,{...i,ref:t}):(0,R.jsx)(Dg,{...i,ref:t})})},`DialogContent`)),Eg=v.forwardRef(lg(function(e,t){let n=mg(wg,e.__scopeDialog),r=v.useRef(null),i=np(t,n.contentRef,r);return v.useEffect(()=>{let e=r.current;if(e)return sg(e)},[]),(0,R.jsx)(Og,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Dg=v.forwardRef(lg(function(e,t){let n=mg(wg,e.__scopeDialog),r=v.useRef(!1),i=v.useRef(!1);return(0,R.jsx)(Og,{...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`)),Og=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=mg(wg,n);return Um(),(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(hm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(rm,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Ng(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),kg=`DialogTitle`,Ag=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,...r}=e,i=mg(kg,n),{setTitleCount:a}=i;return cp(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Gp.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),jg=`DialogClose`,Mg=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,...r}=e,i=mg(jg,n);return(0,R.jsx)(Gp.button,{type:`button`,...r,ref:t,onClick:J(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Ng(e){return e?`open`:`closed`}lg(Ng,`getState`);var Pg=window.__DESIGN_STATIC__===!0,Fg=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function Ig(e,t){let n=await fetch(e,{cache:t});if(!n.ok){let e=`${n.status} ${n.statusText}`;try{let t=await n.json();t.error&&(e=t.error)}catch{}throw new Fg(n.status,e)}return await n.json()}async function Lg(e){try{return await e}catch(e){if(e instanceof Fg&&e.status===404)return null;throw e}}var Rg=``;function zg(e){return Rg!==e.version&&(Rg=e.version,console.info(`foss-design ${e.version}${Pg?` (static build)`:``}`)),e}var Bg={live:!0,project:()=>Ig(`/api/project`,`no-store`).then(zg),canvas:async e=>({doc:await Ig(`/api/canvas/${encodeURIComponent(e)}`,`no-store`),base:``}),system:async()=>{let e=await Lg(Ig(`/api/system`,`no-store`));return e?{doc:e,base:``}:null},async source(e){let t=await fetch(`/api/source?path=${encodeURIComponent(e)}`,{cache:`no-store`});if(!t.ok)throw new Fg(t.status,`Could not read ${e}`);return t.text()},async setIcon(e){let t=await fetch(`/api/icon`,{method:e?`PUT`:`DELETE`,headers:e?{"content-type":e.type||`application/octet-stream`}:void 0,body:e});if(!t.ok){let e=await t.json().catch(()=>({}));throw new Fg(t.status,e.error??`${t.status} ${t.statusText}`)}}},Vg=null,Hg={live:!1,project:()=>Ig(`api/project.json`,`default`).then(zg),canvas:async e=>({doc:await Ig(`api/canvas/${encodeURIComponent(e)}.json`,`default`),base:``}),system:async()=>{let e=await Lg(Ig(`api/system.json`,`default`));return e?{doc:e,base:``}:null},async source(e){Vg??=Ig(`api/sources.json`,`default`).catch(()=>({}));let t=(await Vg)[e];if(t===void 0)throw new Fg(404,`${e} is not in this build`);return t}};function Ug(e,t){try{let n=typeof document>`u`?`http://localhost/`:document.baseURI;if(!t){let t=new URL(e,n);return t.protocol===`http:`||t.protocol===`https:`?e:``}let r=new URL(t.endsWith(`/`)?t:`${t}/`,n),i=new URL(e,r);return i.origin===r.origin&&i.href.startsWith(r.href)?i.href:``}catch{return``}}function Wg(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:``}catch{return``}}function Gg(e,t){let n=e=>Ug(e,t);return{...e,pages:e.pages.map(e=>({...e,sections:e.sections.map(e=>({...e,items:e.items.map(e=>{if(e.kind===`screen`){let t=e=>e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t&&n(t)]).filter(([,e])=>e)):void 0,r=n(e.url);return{...e,url:r,missing:e.missing||!r,snapshots:t(e.snapshots),thumbs:t(e.thumbs)}}return e.kind===`image`?{...e,url:n(e.url)}:e.kind===`url`?{...e,url:Wg(e.url)}:e})}))}))}}function Kg(e,t){let n=e=>Ug(e,t);return{...e,components:e.components.map(e=>({...e,url:n(e.url)})),assets:e.assets.map(e=>({...e,url:n(e.url)})),typographyUrl:e.typographyUrl&&n(e.typographyUrl)}}function qg(e){return{all:[`design`,e],project:[`design`,e,`project`],canvas:t=>[`design`,e,`canvas`,t],system:[`design`,e,`system`],sources:[`design`,e,`source`],source:(t,n)=>[`design`,e,`source`,t,n]}}var Jg=`clipboard-read; clipboard-write; fullscreen`,Yg=new WeakMap,Xg=0;function Zg(e){let t=Yg.get(e);return t||(Xg+=1,t=String(Xg),Yg.set(e,t)),t}var Qg=(0,v.createContext)(null);function $g(){let e=(0,v.useContext)(Qg);if(!e)throw Error(`foss-design: this component renders inside <DesignViewer>`);return e}function e_(e,t){if(e===t)return!0;try{return decodeURIComponent(e)===t}catch{return!1}}function t_(e){return new zt({defaultOptions:{queries:{staleTime:e?0:1/0,retry:1,refetchOnWindowFocus:!1}}})}function n_(){let{source:e,keys:t,scope:n}=$g();return Zt({queryKey:t.project,queryFn:()=>e.project(),enabled:!n})}function r_(e,t=!0){let{source:n,keys:r}=$g();return Zt({queryKey:r.canvas(e),queryFn:async()=>{let{doc:t,base:r}=await n.canvas(e);return Gg(t,r)},placeholderData:e=>e,enabled:t})}function i_(e=!0){let{source:t,keys:n}=$g();return Zt({queryKey:n.system,queryFn:async()=>{let e=await t.system();return e?Kg(e.doc,e.base):null},enabled:e})}function a_(e,t=`system`){let{source:n,keys:r}=$g();return Zt({queryKey:r.source(t,e??``),queryFn:()=>n.source(e,t),enabled:!!e})}function o_(e,t){let n=null,r=!1;return n=new EventSource(`/api/events`),n.onopen=()=>{r&&(r=!1,e.invalidateQueries({queryKey:t.all}))},n.onerror=()=>{r=!0},n.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}if(r.type===`project`)e.invalidateQueries({queryKey:t.project});else if(r.type===`system`)e.invalidateQueries({queryKey:t.system}),e.invalidateQueries({queryKey:t.sources});else if(r.type===`canvas`||r.type===`snapshot`){let n=r.type===`canvas`?r.id:r.canvas;e.invalidateQueries({queryKey:t.canvas(n)}),r.type===`snapshot`&&e.invalidateQueries({queryKey:t.project})}},()=>n?.close()}function Y(...e){return e.filter(Boolean).join(` `)}var s_=null;function c_(e,t){s_={canvas:e,item:t},window.dispatchEvent(new CustomEvent(`design:focus`,{detail:s_}))}function l_(e){if(!s_||s_.canvas!==e)return null;let t=s_.item;return s_=null,t}var u_=class{value;listeners=new Set;constructor(e){this.value=e}get=()=>this.value;set=e=>{let t=typeof e==`function`?e(this.value):e;if(!Object.is(t,this.value)){this.value=t;for(let e of this.listeners)e()}};subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)})};function d_(e,t=e=>e){return(0,v.useSyncExternalStore)(e.subscribe,()=>t(e.get()),()=>t(e.get()))}var f_=`foss-design.theme`;function p_(){try{let e=localStorage.getItem(f_);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var m_=new u_(p_()),h_=window.matchMedia(`(prefers-color-scheme: dark)`);function g_(e){return e===`system`?h_.matches?`dark`:`light`:e}function __(){document.documentElement.dataset.theme=g_(m_.get())}h_.addEventListener(`change`,__),m_.subscribe(__),__();function v_(e){try{localStorage.setItem(f_,e)}catch{}m_.set(e)}function y_(){return d_(m_)}function b_(){let e=d_(m_),t=(0,v.useSyncExternalStore)(e=>(h_.addEventListener(`change`,e),()=>h_.removeEventListener(`change`,e)),()=>h_.matches);return e===`system`?t?`dark`:`light`:e}var x_={plus:`<path d="M5 12h14"/><path d="M12 5v14"/>`,check:`<path d="M20 6 9 17l-5-5"/>`,x:`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`,"chevron-down":`<path d="m6 9 6 6 6-6"/>`,"chevron-up":`<path d="m18 15-6-6-6 6"/>`,"chevron-right":`<path d="m9 18 6-6-6-6"/>`,"arrow-right":`<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>`,chevrons:`<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>`,copy:`<rect width="14" height="14" x="8" y="8" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>`,search:`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>`,bell:`<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>`,refresh:`<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>`,"up-right":`<path d="M7 7h10v10"/><path d="M7 17 17 7"/>`,"down-left":`<path d="M17 7 7 17"/><path d="M17 17H7V7"/>`,external:`<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>`,"user-plus":`<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M19 8v6"/><path d="M22 11h-6"/>`,user:`<circle cx="12" cy="8" r="5"/><path d="M20 21a8 8 0 0 0-16 0"/>`,trash:`<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>`,more:`<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>`,alert:`<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>`,info:`<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>`,upload:`<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m17 8-5-5-5 5"/><path d="M12 3v12"/>`,download:`<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/>`,shield:`<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/><path d="m9 12 2 2 4-4"/>`,logout:`<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="m16 17 5-5-5-5"/><path d="M21 12H9"/>`,loader:`<path d="M21 12a9 9 0 1 1-6.219-8.56"/>`,"circle-check":`<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>`,"circle-dashed":`<circle cx="12" cy="12" r="9" stroke-dasharray="3 3"/>`,clock:`<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>`,mail:`<rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>`,send:`<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>`,chat:`<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/>`,wallet:`<path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"/><path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"/>`,"file-code":`<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/>`,ban:`<circle cx="12" cy="12" r="10"/><path d="m4.9 4.9 14.2 14.2"/>`,code:`<path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/>`,"chevron-left":`<path d="m15 18-6-6 6-6"/>`,bluetooth:`<path d="m7 7 10 10-5 5V2l5 5L7 17"/>`,face:`<path d="M3 7V5a2 2 0 0 1 2-2h2"/><path d="M17 3h2a2 2 0 0 1 2 2v2"/><path d="M21 17v2a2 2 0 0 1-2 2h-2"/><path d="M7 21H5a2 2 0 0 1-2-2v-2"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01"/><path d="M15 9h.01"/>`,eye:`<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>`,clipboard:`<rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/>`,grip:`<circle cx="9" cy="5" r="1"/><circle cx="9" cy="12" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="19" r="1"/>`,list:`<path d="M3 12h.01"/><path d="M3 18h.01"/><path d="M3 6h.01"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M8 6h13"/>`,lock:`<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>`,hw:`<rect width="20" height="10" x="2" y="7" rx="2"/><path d="M15 7v10"/><circle cx="8" cy="12" r="1.5"/>`,link:`<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>`,signal:`<path d="M2 20h.01"/><path d="M7 20v-4"/><path d="M12 20v-8"/><path d="M17 20V8"/>`,grid:`<rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/>`,coins:`<circle cx="8" cy="8" r="6"/><path d="M18.09 10.37A6 6 0 1 1 10.34 18"/><path d="M7 6h1v4"/><path d="m16.71 13.88.7.71-2.82 2.82"/>`,arrows:`<path d="M8 3 4 7l4 4"/><path d="M4 7h16"/><path d="m16 21 4-4-4-4"/><path d="M20 17H4"/>`,key:`<path d="m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4"/><path d="m21 2-9.6 9.6"/><circle cx="7.5" cy="15.5" r="5.5"/>`,blocks:`<rect width="7" height="7" x="14" y="3" rx="1"/><path d="M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3"/>`,settings:`<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>`,qr:`<rect width="5" height="5" x="3" y="3" rx="1"/><rect width="5" height="5" x="16" y="3" rx="1"/><rect width="5" height="5" x="3" y="16" rx="1"/><path d="M21 16h-3a2 2 0 0 0-2 2v3"/><path d="M21 21v.01"/><path d="M12 7v3a2 2 0 0 1-2 2H7"/><path d="M3 12h.01"/><path d="M12 3h.01"/><path d="M12 16v.01"/><path d="M16 12h1"/><path d="M21 12v.01"/><path d="M12 21v-1"/>`,edit:`<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/>`,star:`<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"/>`,home:`<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>`,moon:`<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>`,sun:`<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>`,languages:`<path d="m5 8 6 6"/><path d="m4 14 6-6 2-3"/><path d="M2 5h12"/><path d="M7 2h1"/><path d="m22 22-5-10-5 10"/><path d="M14 18h6"/>`,"arrow-left":`<path d="m12 19-7-7 7-7"/><path d="M19 12H5"/>`,play:`<polygon points="6 3 20 12 6 21 6 3"/>`,"zoom-in":`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/><path d="M11 8v6"/><path d="M8 11h6"/>`,"zoom-out":`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/><path d="M8 11h6"/>`,fit:`<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>`,"panel-left":`<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/>`,layers:`<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>`,file:`<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>`,palette:`<circle cx="13.5" cy="6.5" r="1"/><circle cx="17.5" cy="10.5" r="1"/><circle cx="8.5" cy="7.5" r="1"/><circle cx="6.5" cy="12.5" r="1"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.93 0 1.65-.75 1.65-1.69 0-.44-.18-.84-.44-1.13-.29-.29-.44-.65-.44-1.13a1.64 1.64 0 0 1 1.67-1.67h2c3.05 0 5.55-2.5 5.55-5.55C21.96 6.01 17.46 2 12 2z"/>`,type:`<path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/>`,shape:`<path d="M5 3a2 2 0 0 0-2 2"/><path d="M19 3a2 2 0 0 1 2 2"/><path d="M21 19a2 2 0 0 1-2 2"/><path d="M5 21a2 2 0 0 1-2-2"/><path d="M9 3h1"/><path d="M9 21h1"/><path d="M14 3h1"/><path d="M14 21h1"/><path d="M3 9v1"/><path d="M21 9v1"/><path d="M3 14v1"/><path d="M21 14v1"/>`,motion:`<path d="M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/><path d="M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/><path d="M2 6c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/>`,book:`<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/>`,image:`<rect width="18" height="18" x="3" y="3" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.09-3.09a2 2 0 0 0-2.82 0L6 21"/>`,monitor:`<rect width="20" height="14" x="2" y="3" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/>`,smartphone:`<rect width="14" height="20" x="5" y="2" rx="2"/><path d="M12 18h.01"/>`,tablet:`<rect width="16" height="20" x="4" y="2" rx="2"/><path d="M12 18h.01"/>`,note:`<path d="M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z"/><path d="M15 3v4a2 2 0 0 0 2 2h4"/>`,globe:`<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>`,pointer:`<path d="M4.04 4.69a.5.5 0 0 1 .65-.65l16 6.5a.5.5 0 0 1-.06.95l-6.12 1.58a2 2 0 0 0-1.44 1.44l-1.58 6.12a.5.5 0 0 1-.95.06z"/>`,component:`<path d="M5.5 8.5 9 12l-3.5 3.5L2 12l3.5-3.5Z"/><path d="m12 2 3.5 3.5L12 9 8.5 5.5 12 2Z"/><path d="M18.5 8.5 22 12l-3.5 3.5L15 12l3.5-3.5Z"/><path d="m12 15 3.5 3.5L12 22l-3.5-3.5L12 15Z"/>`,keyboard:`<rect width="20" height="16" x="2" y="4" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M8 12h.01"/><path d="M12 12h.01"/><path d="M16 12h.01"/><path d="M7 16h10"/>`,folder:`<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>`,canvas:`<rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/>`};function X({name:e,size:t=16,strokeWidth:n=1.75,className:r}){return(0,R.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:n,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`shrink-0 ${e===`loader`?`animate-spin`:``} ${r??``}`,dangerouslySetInnerHTML:{__html:x_[e]}})}function Z({children:e,size:t=12.5,className:n,title:r,wrap:i}){return(0,R.jsx)(`span`,{title:r,className:Y(i?`break-all`:`whitespace-nowrap`,`font-mono`,n),style:{fontSize:t},children:e})}function S_({children:e}){return(0,R.jsx)(`kbd`,{className:`rounded-[4px] border border-rule bg-surface px-[5px] py-px font-mono text-[11px] text-ink2`,children:e})}function C_({top:e,bottom:t,weight:n=500}){return(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,R.jsx)(`span`,{className:`truncate leading-[1.35]`,style:{fontWeight:n},children:e}),t?(0,R.jsx)(`span`,{className:`flex min-w-0 items-center gap-2.5 overflow-hidden whitespace-nowrap text-[12.5px] leading-[1.35] text-muted`,children:t}):null]})}var w_={canvas:`This canvas`,canvases:`Canvases`,system:`Design system`,actions:`Actions`};function T_(e){let t=/^\/c\/([^/]+)/.exec(e);return t?decodeURIComponent(t[1]):null}function E_({onClose:e}){let[t,n]=I(),r=$g().scope,i=n_().data,a=r?.canvas??T_(t),o=r_(a??``,!!a).data,s=i_(!!i?.system).data,[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(0),f=t=>()=>{e(),t()},p=[];if(o)for(let e of o.pages){p.push({id:`page:${e.id}`,group:`canvas`,label:e.title,icon:`file`,hint:`Page`,run:f(()=>n(`/c/${encodeURIComponent(o.id)}/p/${encodeURIComponent(e.id)}`))});for(let t of e.sections)for(let r of t.items)(r.kind===`screen`||r.kind===`url`)&&p.push({id:`item:${e.id}:${r.id}`,group:`canvas`,label:r.title,icon:r.kind===`url`?`globe`:`monitor`,hint:t.title?`${e.title} · ${t.title}`:e.title,keywords:`${r.id} ${t.title??``}`,searchOnly:!0,run:f(()=>{n(`/c/${encodeURIComponent(o.id)}/p/${encodeURIComponent(e.id)}`),c_(o.id,r.id)})})}for(let e of i?.canvases??[])e.id!==a&&p.push({id:`canvas:${e.id}`,group:`canvases`,label:e.title,icon:`canvas`,hint:`${e.screens} screens`,keywords:e.id,run:f(()=>n(`/c/${encodeURIComponent(e.id)}`))});if(i?.system){for(let[e,t,r]of[[`Overview`,`/system`,`book`],[`Colors`,`/system/colors`,`palette`],[`Typography`,`/system/typography`,`type`],[`Spacing & shape`,`/system/shape`,`shape`]])p.push({id:`sys:${t}`,group:`system`,label:e,icon:r,run:f(()=>n(t))});for(let e of s?.components??[])p.push({id:`component:${e.id}`,group:`system`,label:e.title,icon:`component`,hint:e.group,searchOnly:!0,run:f(()=>n(`/system/components/${encodeURIComponent(e.id)}`))});for(let e of s?.guidelines??[])p.push({id:`guide:${e.slug}`,group:`system`,label:e.title,icon:`book`,hint:`Guideline`,searchOnly:!0,run:f(()=>n(`/system/guidelines/${encodeURIComponent(e.slug)}`))})}r||p.push({id:`home`,group:`actions`,label:`All canvases`,icon:`home`,run:f(()=>n(`/`))}),p.push({id:`light`,group:`actions`,label:`Light appearance`,icon:`sun`,searchOnly:!0,run:f(()=>v_(`light`))},{id:`dark`,group:`actions`,label:`Dark appearance`,icon:`moon`,searchOnly:!0,run:f(()=>v_(`dark`))},{id:`system-theme`,group:`actions`,label:`System appearance`,icon:`monitor`,searchOnly:!0,run:f(()=>v_(`system`))});let m=c.trim().toLowerCase(),h=p.filter(e=>m?`${e.label} ${e.keywords??``} ${typeof e.hint==`string`?e.hint:``}`.toLowerCase().includes(m):!e.searchOnly),g=[`canvas`,`canvases`,`system`,`actions`].map(e=>({group:e,items:h.filter(t=>t.group===e)})).filter(e=>e.items.length),_=g.flatMap(e=>e.items),y=Math.min(u,Math.max(_.length-1,0)),b=-1;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Ag,{className:`sr-only`,children:`Search and jump`}),(0,R.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2.5 border-b border-rule px-4`,children:[(0,R.jsx)(X,{name:`search`,size:16,className:`text-muted`}),(0,R.jsx)(`input`,{value:c,onChange:e=>{l(e.target.value),d(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),d((y+1)%Math.max(_.length,1))):e.key===`ArrowUp`?(e.preventDefault(),d((y-1+_.length)%Math.max(_.length,1))):e.key===`Enter`&&(e.preventDefault(),_[y]?.run())},placeholder:`Canvases, screens, components…`,"aria-label":`Search and jump`,role:`combobox`,"aria-expanded":`true`,"aria-controls":`palette-list`,autoComplete:`off`,spellCheck:!1,className:`h-full min-w-0 grow border-0 bg-transparent text-[15px] text-ink outline-none placeholder:text-muted`}),(0,R.jsx)(S_,{children:`esc`})]}),(0,R.jsx)(`div`,{id:`palette-list`,role:`listbox`,className:`min-h-0 grow overflow-y-auto py-1.5`,children:g.length?g.map(({group:e,items:t})=>(0,R.jsxs)(`div`,{role:`presentation`,children:[(0,R.jsx)(`div`,{className:`px-4 pt-2.5 pb-1 text-[12px] text-muted`,children:w_[e]}),t.map(e=>{b+=1;let t=b,n=t===y;return(0,R.jsxs)(`button`,{type:`button`,role:`option`,tabIndex:-1,"aria-selected":n,ref:n?e=>e?.scrollIntoView({block:`nearest`}):void 0,onMouseMove:()=>n?void 0:d(t),onClick:e.run,className:Y(`flex h-10 w-full cursor-pointer items-center gap-3 border-0 px-4 text-left text-[13.5px] text-ink`,n?`bg-soft`:`bg-transparent`),children:[(0,R.jsx)(`span`,{className:`flex w-5 shrink-0 justify-center text-ink2`,children:(0,R.jsx)(X,{name:e.icon,size:16})}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`flex shrink-0 items-center text-[12.5px] text-muted`,children:e.hint}):null]},e.id)})]},e)):(0,R.jsx)(`div`,{className:`px-6 py-10 text-center text-[13px] text-muted`,children:`Nothing matches.`})}),(0,R.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-4 border-t border-rule bg-soft px-4 text-[12px] text-muted`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(S_,{children:`↑`}),(0,R.jsx)(S_,{children:`↓`}),`move`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(S_,{children:`↵`}),`open`]})]})]})}function D_(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=()=>t(e=>!e),n=t=>{(t.metaKey||t.ctrlKey)&&t.key.toLowerCase()===`k`&&(t.preventDefault(),e())};return window.addEventListener(`keydown`,n),window.addEventListener(`design:palette`,e),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`design:palette`,e)}},[]),(0,R.jsx)(hg,{open:e,onOpenChange:t,children:(0,R.jsx)(ed,{children:e?(0,R.jsx)(yg,{forceMount:!0,children:(0,R.jsx)(xg,{asChild:!0,forceMount:!0,children:(0,R.jsx)(Gf.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.14},className:`fixed inset-0 z-50 flex items-start justify-center bg-overlay p-6 pt-[12vh]`,children:(0,R.jsx)(Tg,{asChild:!0,forceMount:!0,"aria-describedby":void 0,children:(0,R.jsx)(Gf.div,{initial:{opacity:0,scale:.98,y:-6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,transition:{duration:.1}},transition:{type:`spring`,stiffness:560,damping:40},className:`flex max-h-[min(560px,76vh)] w-[560px] max-w-full flex-col overflow-hidden rounded-[12px] border border-rule bg-surface shadow-pop outline-none`,children:(0,R.jsx)(E_,{onClose:()=>t(!1)})})})})})}):null})})}var O_={primary:`border border-primary bg-primary text-primary-ink hover:opacity-90`,secondary:`border border-rule-strong bg-surface text-ink hover:bg-soft`,ghost:`border border-transparent bg-transparent text-ink2 hover:bg-soft2`,dashed:`border border-dashed border-rule-strong bg-transparent text-ink2 hover:bg-soft`,danger:`border border-danger bg-danger text-on-danger hover:opacity-90`},k_=(e=`secondary`,t)=>Y(`inline-flex h-ctrl shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-[6px] px-ctrl text-ctrl font-medium leading-none no-underline transition-[background-color,opacity,scale] duration-100 active:not-disabled:scale-[0.97]`,`disabled:cursor-not-allowed disabled:opacity-45 aria-disabled:cursor-not-allowed aria-disabled:opacity-45`,O_[e],t),A_=(0,v.forwardRef)(function({kind:e=`secondary`,icon:t,loading:n,disabled:r,className:i,children:a,type:o=`button`,...s},c){return(0,R.jsxs)(`button`,{ref:c,type:o,disabled:r||n,"aria-busy":n||void 0,className:k_(e,i),...s,children:[n?(0,R.jsx)(X,{name:`loader`,size:15,className:`animate-spin`}):t?(0,R.jsx)(X,{name:t,size:15}):null,a]})}),j_={ghost:`border border-transparent bg-transparent text-muted hover:bg-soft2 hover:text-ink2`,secondary:`border border-rule-strong bg-surface text-ink2 hover:bg-soft`},M_=(e=`ghost`,t)=>Y(`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] p-0 transition-[color,background-color,scale] duration-100 active:not-disabled:scale-[0.94] disabled:cursor-not-allowed disabled:opacity-45`,j_[e],t),N_=(0,v.forwardRef)(function({icon:e,label:t,kind:n=`ghost`,size:r=16,className:i,type:a=`button`,...o},s){return(0,R.jsx)(`button`,{ref:s,type:a,"aria-label":t,title:t,className:M_(n,i),...o,children:(0,R.jsx)(X,{name:e,size:r})})});function P_({to:e,kind:t=`secondary`,icon:n,className:r,children:i}){return(0,R.jsxs)(ye,{href:e,className:k_(t,r),children:[n?(0,R.jsx)(X,{name:n,size:15}):null,i]})}function F_({kind:e=`secondary`,icon:t,className:n,children:r,...i}){return(0,R.jsxs)(`a`,{className:k_(e,n),...i,children:[t?(0,R.jsx)(X,{name:t,size:15}):null,r]})}var I_={neutral:`bg-soft2 text-ink2`,action:`bg-action-soft text-action`,ok:`bg-ok-soft text-ok-text`,danger:`bg-danger-soft text-danger-text`};function L_({tone:e=`neutral`,children:t,className:n}){return(0,R.jsx)(`span`,{className:Y(`inline-flex h-[22px] shrink-0 items-center gap-1 whitespace-nowrap rounded-[6px] px-2 text-[12px] font-medium`,I_[e],n),children:t})}function R_({value:e,tone:t=`neutral`}){return(0,R.jsx)(`span`,{className:Y(`inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-[4px] px-[5px] text-[11.5px] font-semibold tabular`,t===`action`?`bg-action-soft text-action`:t===`danger`?`bg-danger-soft text-danger-text`:`bg-soft2 text-ink2`),children:e})}function z_({children:e,className:t,style:n}){return(0,R.jsx)(`section`,{className:Y(`min-w-0 shrink-0 overflow-hidden rounded-[10px] border border-rule bg-surface`,t),style:n,children:e})}function B_({title:e,count:t,sub:n,right:r,as:i=`h2`}){return(0,R.jsxs)(`div`,{className:`flex min-h-[46px] items-center justify-between gap-3 px-4`,children:[(0,R.jsxs)(i,{className:`m-0 flex min-w-0 items-center gap-2 whitespace-nowrap text-[14px] font-semibold`,children:[e,t===void 0?null:(0,R.jsx)(R_,{value:t}),n?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] font-normal text-muted`,children:n}):null]}),r?(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:r}):null]})}function V_({items:e,value:t,onChange:n,right:r}){let i=(0,v.useId)();return(0,R.jsxs)(`div`,{className:`flex h-[46px] items-center justify-between gap-3 px-4`,children:[(0,R.jsx)(`div`,{role:`tablist`,className:`flex gap-5`,children:e.map(e=>{let r=e.value===t;return(0,R.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.value),className:Y(`relative flex h-[46px] cursor-pointer items-center gap-1.5 border-0 bg-transparent px-0.5 text-[14px] transition-colors`,r?`font-semibold text-ink`:`font-medium text-ink2 hover:text-ink`),children:[e.label,e.count===void 0?null:(0,R.jsx)(R_,{value:e.count}),r?(0,R.jsx)(Gf.span,{layoutId:i,className:`absolute inset-x-0 bottom-0 h-[2px] bg-ink`,transition:{type:`spring`,stiffness:520,damping:42}}):null]},e.value)})}),r?(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:r}):null]})}function H_({align:e,children:t}){return(0,R.jsx)(`div`,{className:Y(`flex min-w-0 items-center gap-2`,e===`r`&&`justify-end text-right`,e===`c`&&`justify-center`),children:t})}function U_(e,t){return v.Children.toArray(e).map((e,n)=>(0,R.jsx)(H_,{align:t?.[n]??`l`,children:e},n))}function W_({cols:e,align:t,labels:n}){return(0,R.jsx)(`div`,{className:`grid h-8 items-center gap-x-4 border-t border-rule bg-soft px-4 text-[12.5px] text-muted`,style:{gridTemplateColumns:e},children:n.map((e,n)=>(0,R.jsx)(H_,{align:t?.[n]??`l`,children:(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:e})},n))})}var G_=(e,t,n)=>Y(`grid items-center gap-x-4 border-rule`,!e&&`border-t`,t&&`cursor-pointer transition-colors hover:bg-soft`,n);function K_({cols:e,align:t,minH:n=44,pad:r=`10px 16px`,children:i,first:a,className:o,onClick:s,title:c}){return(0,R.jsx)(`div`,{className:G_(a,!!s,o),style:{gridTemplateColumns:e,minHeight:n,padding:r},onClick:s,title:c,children:U_(i,t)})}function q_({to:e,cols:t,align:n,minH:r=44,pad:i=`10px 16px`,first:a,className:o,children:s}){return(0,R.jsx)(ye,{href:e,className:Y(G_(a,!0,o),`text-inherit no-underline`),style:{gridTemplateColumns:t,minHeight:r,padding:i},children:U_(s,n)})}function J_({label:e,children:t,labelWidth:n=180,minH:r=40,end:i=!1}){return(0,R.jsxs)(`div`,{className:`grid content-center items-baseline gap-x-4 border-t border-rule px-4 py-2`,style:{gridTemplateColumns:`min(${n}px, 42%) minmax(0, 1fr)`,minHeight:r},children:[(0,R.jsx)(`span`,{className:`text-[13px] text-muted`,children:e}),(0,R.jsx)(`div`,{className:Y(`flex min-w-0 flex-wrap items-center gap-2`,i&&`justify-end`),children:t})]})}function Y_({children:e,pad:t=`16px`,gap:n=16,top:r=!0,className:i}){return(0,R.jsx)(`div`,{className:Y(`flex flex-col`,r&&`border-t border-rule`,i),style:{padding:t,gap:n},children:e})}function X_({children:e,className:t,gap:n=20,wide:r=!1}){return(0,R.jsx)(`main`,{className:Y(`mx-auto flex w-full min-h-0 grow flex-col px-8 pt-6 pb-7 animate-[q-fade-in_160ms_ease-out] max-md:px-4 max-md:pt-4`,r?`max-w-[1440px]`:`max-w-[1200px]`,t),style:{gap:n},children:e})}function Z_({title:e,sub:t,right:n,badge:r,crumbs:i}){return(0,R.jsxs)(`div`,{className:`flex shrink-0 items-end justify-between gap-6 max-md:flex-col max-md:items-stretch max-md:gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[i?(0,R.jsx)(`div`,{className:`flex items-center gap-1.5 text-[13px] text-muted`,children:i}):null,(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`h1`,{className:`m-0 text-[22px] font-semibold tracking-[-0.01em]`,children:e}),r]}),t?(0,R.jsx)(`div`,{className:`text-[13px] [overflow-wrap:anywhere] text-muted`,children:t}):null]}),n?(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n}):null]})}function Q_({items:e,label:t}){let[n]=I();return(0,R.jsx)(`nav`,{"aria-label":t,className:`flex flex-col gap-0.5`,children:e.map(e=>{let t=n===e.to;return(0,R.jsxs)(ye,{href:e.to,"aria-current":t?`page`:void 0,className:Y(`relative flex h-8 items-center gap-2 whitespace-nowrap rounded-[6px] px-3 text-[13.5px] no-underline transition-colors focus-visible:outline-offset-[-2px]`,t?`font-medium text-ink`:`text-ink2 hover:bg-soft2`),children:[t?(0,R.jsx)(Gf.span,{layoutId:`sub-nav-active`,"aria-hidden":!0,className:`absolute inset-0 z-0 rounded-[6px] bg-soft2`,transition:{type:`spring`,stiffness:520,damping:42}}):null,(0,R.jsx)(`span`,{className:`relative z-[1] min-w-0 truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`relative z-[1] ml-auto text-[12px] font-normal text-muted`,children:e.hint}):null]},e.to)})})}function $_({children:e}){return(0,R.jsx)(`div`,{className:`px-3 pt-4 pb-1 text-[12px] text-muted`,children:e})}function ev({title:e,text:t,action:n}){return(0,R.jsxs)(z_,{className:`flex w-[480px] max-w-full flex-col items-center gap-2 px-6 py-8 text-center`,children:[(0,R.jsx)(`h1`,{className:`m-0 text-[16px] font-semibold`,children:e}),t?(0,R.jsx)(`div`,{className:`m-0 max-w-[400px] text-[14px] text-ink2`,children:t}):null,n?(0,R.jsx)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2`,children:n}):null]})}function tv(e){return(0,R.jsx)(`div`,{className:`flex min-h-[50vh] grow items-center justify-center p-6 max-md:px-4`,children:(0,R.jsx)(ev,{...e})})}function nv({error:e}){let t=!!$g().scope;return(0,R.jsx)(tv,{title:`This page failed to show`,text:(0,R.jsx)(`span`,{className:`font-mono text-[12.5px] break-words`,children:e.message.slice(0,500)}),action:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A_,{onClick:()=>window.location.reload(),children:`Reload`}),t?null:(0,R.jsx)(P_,{to:`/`,children:`All canvases`})]})})}var rv=class extends v.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){console.error(`[design] a page failed to render`,e,t.componentStack)}componentDidUpdate(e){this.state.error&&e.at!==this.props.at&&this.setState({error:null})}render(){return this.state.error?(0,R.jsx)(nv,{error:this.state.error}):this.props.children}};function iv({children:e}){let[t]=I();return(0,R.jsx)(rv,{at:t,children:e})}var av=/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`,ov=[`top`,`right`,`bottom`,`left`],sv=Math.min,cv=Math.max,lv=Math.round,uv=Math.floor,dv=e=>({x:e,y:e}),fv={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function pv(e,t,n){return cv(e,sv(t,n))}function mv(e,t){return typeof e==`function`?e(t):e}function hv(e){return e.split(`-`)[0]}function gv(e){return e.split(`-`)[1]}function _v(e){return e===`x`?`y`:`x`}function vv(e){return e===`y`?`height`:`width`}function yv(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function bv(e){return _v(yv(e))}function xv(e,t,n){n===void 0&&(n=!1);let r=gv(e),i=bv(e),a=vv(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Av(o)),[o,Av(o)]}function Sv(e){let t=Av(e);return[Cv(e),t,Cv(t)]}function Cv(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var wv=[`left`,`right`],Tv=[`right`,`left`],Ev=[`top`,`bottom`],Dv=[`bottom`,`top`];function Ov(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Tv:wv:t?wv:Tv;case`left`:case`right`:return t?Ev:Dv;default:return[]}}function kv(e,t,n,r){let i=gv(e),a=Ov(hv(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Cv)))),a}function Av(e){let t=hv(e);return fv[t]+e.slice(t.length)}function jv(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Mv(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:jv(e)}function Nv(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Pv(e,t,n){let{reference:r,floating:i}=e,a=yv(t),o=bv(t),s=vv(o),c=hv(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=gv(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Fv(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=mv(t,e),p=Mv(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Nv(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Nv(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Iv=50,Lv=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Fv},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Pv(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Iv&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Pv(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Rv=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=mv(e,t)||{};if(l==null)return{};let d=Mv(u),f={x:n,y:r},p=bv(i),m=vv(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=sv(d[_],T),D=sv(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=pv(E,k,O),j=!c.arrow&&gv(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),zv=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=mv(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=hv(r),_=yv(o),v=hv(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Av(o)]:Sv(o)),x=p!==`none`;!d&&x&&b.push(...kv(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=xv(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===yv(t)||T.every(e=>yv(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=yv(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Bv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Vv(e){return ov.some(t=>e[t]>=0)}var Hv=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=mv(e,t);switch(i){case`referenceHidden`:{let e=Bv(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Vv(e)}}}case`escaped`:{let e=Bv(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Vv(e)}}}default:return{}}}}},Uv=new Set([`left`,`top`]);async function Wv(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=hv(n),s=gv(n),c=yv(n)===`y`,l=Uv.has(o)?-1:1,u=a&&c?-1:1,d=mv(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Gv=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Wv(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Kv=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=mv(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=yv(i),p=_v(f),m=u[p],h=u[f],g=(e,t)=>pv(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},qv=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=mv(e,t),u={x:n,y:r},d=yv(i),f=_v(d),p=u[f],m=u[d],h=mv(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Uv.has(hv(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Jv=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=mv(e,t),c=await i.detectOverflow(t,s),l=hv(n),u=gv(n),d=yv(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=sv(p-c[m],g),y=sv(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*cv(c.left,c.right):S=p-2*cv(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Yv(){return typeof window<`u`}function Xv(e){return $v(e)?(e.nodeName||``).toLowerCase():`#document`}function Zv(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Qv(e){return(($v(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function $v(e){return Yv()?e instanceof Node||e instanceof Zv(e).Node:!1}function ey(e){return Yv()?e instanceof Element||e instanceof Zv(e).Element:!1}function ty(e){return Yv()?e instanceof HTMLElement||e instanceof Zv(e).HTMLElement:!1}function ny(e){return!Yv()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Zv(e).ShadowRoot}function ry(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=my(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function iy(e){return/^(table|td|th)$/.test(Xv(e))}function ay(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var oy=/transform|translate|scale|rotate|perspective|filter/,sy=/paint|layout|strict|content/,cy=e=>!!e&&e!==`none`,ly;function uy(e){let t=ey(e)?my(e):e;return cy(t.transform)||cy(t.translate)||cy(t.scale)||cy(t.rotate)||cy(t.perspective)||!fy()&&(cy(t.backdropFilter)||cy(t.filter))||oy.test(t.willChange||``)||sy.test(t.contain||``)}function dy(e){let t=gy(e);for(;ty(t)&&!py(t);){if(uy(t))return t;if(ay(t))return null;t=gy(t)}return null}function fy(){return ly??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ly}function py(e){return/^(html|body|#document)$/.test(Xv(e))}function my(e){return Zv(e).getComputedStyle(e)}function hy(e){return ey(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function gy(e){if(Xv(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ny(e)&&e.host||Qv(e);return ny(t)?t.host:t}function _y(e){let t=gy(e);return py(t)?(e.ownerDocument||e).body:ty(t)&&ry(t)?t:_y(t)}function vy(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=_y(e),i=r===e.ownerDocument?.body,a=Zv(r);if(i){let e=yy(a);return t.concat(a,a.visualViewport||[],ry(r)?r:[],e&&n?vy(e):[])}return t.concat(r,vy(r,[],n))}function yy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function by(e){let t=my(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ty(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=lv(n)!==a||lv(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function xy(e){return ey(e)?e:e.contextElement}function Sy(e){let t=xy(e);if(!ty(t))return dv(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=by(t),o=(a?lv(n.width):n.width)/r,s=(a?lv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Cy=dv(0);function wy(e){let t=Zv(e);return!fy()||!t.visualViewport?Cy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ty(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Zv(e)}function Ey(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=xy(e),o=dv(1);t&&(r?ey(r)&&(o=Sy(r)):o=Sy(e));let s=Ty(a,n,r)?wy(a):dv(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Zv(a),t=ey(r)?Zv(r):r,n=e,i=yy(n);for(;i&&t!==n;){let e=Sy(i),t=i.getBoundingClientRect(),r=my(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Zv(i),i=yy(n)}}return Nv({width:u,height:d,x:c,y:l})}function Dy(e,t){let n=hy(e).scrollLeft;return t?t.left+n:Ey(Qv(e)).left+n}function Oy(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Dy(e,n),y:n.top+t.scrollTop}}function ky(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Qv(r),s=t?ay(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=dv(1),u=dv(0),d=ty(r);if((d||!a)&&((Xv(r)!==`body`||ry(o))&&(c=hy(r)),d)){let e=Ey(r);l=Sy(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Oy(o,c):dv(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ay(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function jy(e){let t=hy(e),n=e.ownerDocument.body,r=cv(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=cv(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Dy(e),o=-t.scrollTop;return my(n).direction===`rtl`&&(a+=cv(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var My=25;function Ny(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Zv(e),a=Qv(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!fy()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Dy(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=My&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Py(e,t){let n=Ey(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Sy(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Fy(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ny(e,n,t);else if(t===`document`)r=jy(Qv(e));else if(ey(t))r=Py(t,n);else{let n=wy(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Nv(r)}function Iy(e,t){let n=t.get(e);if(n)return n;let r=vy(e,[],!1).filter(e=>ey(e)&&Xv(e)!==`body`),i=null,a=my(e).position===`fixed`,o=a?gy(e):e;for(;ey(o)&&!py(o);){let e=my(o),t=uy(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=gy(o)}return t.set(e,r),r}function Ly(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?ay(t)?[]:Iy(t,this._c):[].concat(n),r],o=Fy(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Fy(t,a[e],i);s=cv(n.top,s),c=sv(n.right,c),l=sv(n.bottom,l),u=cv(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ry(e){let{width:t,height:n}=by(e);return{width:t,height:n}}function zy(e,t,n){let r=ty(t),i=Qv(t),a=n===`fixed`,o=Ey(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=dv(0);if((r||!a)&&((Xv(t)!==`body`||ry(i))&&(s=hy(t)),r)){let e=Ey(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Dy(i));let l=i&&!r&&!a?Oy(i,s):dv(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function By(e){return my(e).position===`static`}function Vy(e,t){if(!ty(e)||my(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Qv(e)===n&&(n=n.ownerDocument.body),n}function Hy(e,t){let n=Zv(e);if(ay(e))return n;if(!ty(e)){let t=gy(e);for(;t&&!py(t);){if(ey(t)&&!By(t))return t;t=gy(t)}return n}let r=Vy(e,t);for(;r&&iy(r)&&By(r);)r=Vy(r,t);return r&&py(r)&&By(r)&&!uy(r)?n:r||dy(e)||n}var Uy=async function(e){let t=this.getOffsetParent||Hy,n=this.getDimensions,r=await n(e.floating);return{reference:zy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Wy(e){return my(e).direction===`rtl`}var Gy={convertOffsetParentRelativeRectToViewportRelativeRect:ky,getDocumentElement:Qv,getClippingRect:Ly,getOffsetParent:Hy,getElementRects:Uy,getClientRects:Ay,getDimensions:Ry,getScale:Sy,isElement:ey,isRTL:Wy};function Ky(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qy(e,t,n){let r=null,i,a=Qv(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=uv(d),h=uv(a.clientWidth-(u+f)),g=uv(a.clientHeight-(d+p)),_=uv(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:cv(0,sv(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Ky(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Zv(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Jy(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=xy(e),u=i||a?[...l?vy(l):[],...t?vy(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?qy(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Ey(e):null;c&&g();function g(){let t=Ey(e);h&&!Ky(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Yy=Gv,Xy=Kv,Zy=zv,Qy=Jv,$y=Hv,eb=Rv,tb=qv,nb=(e,t,n)=>{let r=new Map,i=n??{},a={...Gy,...i.platform,_c:r};return Lv(e,t,{...i,platform:a})},rb=typeof document<`u`?v.useLayoutEffect:function(){};function ib(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ib(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ib(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ab(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ob(e,t){let n=ab(e);return Math.round(t*n)/n}function sb(e){let t=v.useRef(e);return rb(()=>{t.current=e}),t}function cb(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=v.useState(r);ib(f,r)||p(r);let[m,h]=v.useState(null),[g,_]=v.useState(null),y=v.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=v.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=v.useRef(null),w=v.useRef(null),T=v.useRef(u),E=c!=null,D=sb(c),O=sb(i),k=sb(l),A=v.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),nb(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!ib(T.current,t)&&(T.current=t,Dp.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);rb(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=v.useRef(!1);rb(()=>(j.current=!0,()=>{j.current=!1}),[]),rb(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=v.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),ee=v.useMemo(()=>({reference:x,floating:S}),[x,S]),N=v.useMemo(()=>{let e={position:n,left:0,top:0};if(!ee.floating)return e;let t=ob(ee.floating,u.x),r=ob(ee.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ab(ee.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,ee.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:A,refs:M,elements:ee,floatingStyles:N}),[u,A,M,ee,N])}var lb=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:eb({element:r.current,padding:i}).fn(n):r?eb({element:r,padding:i}).fn(n):{}}}},ub=(e,t)=>{let n=Yy(e);return{name:n.name,fn:n.fn,options:[e,t]}},db=(e,t)=>{let n=Xy(e);return{name:n.name,fn:n.fn,options:[e,t]}},fb=(e,t)=>({fn:tb(e).fn,options:[e,t]}),pb=(e,t)=>{let n=Zy(e);return{name:n.name,fn:n.fn,options:[e,t]}},mb=(e,t)=>{let n=Qy(e);return{name:n.name,fn:n.fn,options:[e,t]}},hb=(e,t)=>{let n=$y(e);return{name:n.name,fn:n.fn,options:[e,t]}},gb=(e,t)=>{let n=lb(e);return{name:n.name,fn:n.fn,options:[e,t]}},_b=Object.defineProperty,vb=(e,t)=>_b(e,`name`,{value:t,configurable:!0});function yb(e){let[t,n]=v.useState(void 0);return cp(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}vb(yb,`useSize`);var bb=Object.defineProperty,xb=(e,t)=>bb(e,`name`,{value:t,configurable:!0}),Sb=`Popper`,[Cb,wb]=op(Sb),[Tb,Eb]=Cb(Sb),Db=xb(e=>{let{__scopePopper:t,children:n}=e,[r,i]=v.useState(null),[a,o]=v.useState(void 0);return(0,R.jsx)(Tb,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Ob=`PopperAnchor`,kb=v.forwardRef(xb(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Eb(Ob,n),o=v.useRef(null),s=a.onAnchorChange,c=np(t,v.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=v.useRef(null);v.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Ib(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,R.jsx)(Gp.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),Ab=`PopperContent`,[jb,Mb]=Cb(Ab),Nb=v.forwardRef(xb(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=Eb(Ab,n),[_,y]=v.useState(null),b=np(t,y),[x,S]=v.useState(null),C=yb(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(Pb),altBoundary:k},{refs:j,floatingStyles:M,placement:ee,isPositioned:N,middlewareData:P}=cb({strategy:`fixed`,placement:E,whileElementsMounted:xb((...e)=>Jy(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[ub({mainAxis:i+T,alignmentAxis:o}),c&&db({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?fb():void 0,...A}),c&&pb({...A}),mb({...A,apply:xb(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&gb({element:x,padding:s}),Fb({arrowWidth:w,arrowHeight:T}),f&&hb({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),te=g.setPlacementState;cp(()=>(te(ee),()=>{te(void 0)}),[ee,te]);let[ne,F]=Ib(ee),re=Yp(m);cp(()=>{N&&re?.()},[N,re]);let ie=P.arrow?.x,ae=P.arrow?.y,oe=P.arrow?.centerOffset!==0,[se,ce]=v.useState();return cp(()=>{_&&ce(window.getComputedStyle(_).zIndex)},[_]),(0,R.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:N?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,R.jsx)(jb,{scope:n,placedSide:ne,placedAlign:F,onArrowChange:S,arrowX:ie,arrowY:ae,shouldHideArrow:oe,children:(0,R.jsx)(Gp.div,{"data-side":ne,"data-align":F,...h,ref:b,style:{...h.style,animation:N?h.style?.animation:`none`}})})})},`PopperContent`));function Pb(e){return e!==null}xb(Pb,`isNotNull`);var Fb=xb(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Ib(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Ib(e){let[t,n=`center`]=e.split(`-`);return[t,n]}xb(Ib,`getSideAndAlignFromPlacement`);var Lb=Db,Rb=kb,zb=Nb,Bb=Object.defineProperty,Vb=(e,t)=>Bb(e,`name`,{value:t,configurable:!0}),Hb=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`}),Ub=v.forwardRef(Vb(function(e,t){return(0,R.jsx)(Gp.span,{...e,ref:t,style:{...Hb,...e.style}})},`VisuallyHidden`)),Wb=Object.defineProperty,Gb=(e,t)=>Wb(e,`name`,{value:t,configurable:!0}),[Kb,qb]=op(`Tooltip`,[wb]),Jb=wb(),Yb=`TooltipProvider`,Xb=700,Zb=`tooltip.open`,[Qb,$b]=Kb(Yb),ex=Gb(e=>{let{__scopeTooltip:t,delayDuration:n=Xb,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=v.useRef(!0),s=v.useRef(!1),c=v.useRef(0);return v.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(Qb,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:v.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:v.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:v.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),tx=`Tooltip`,[nx,rx]=Kb(tx),ix=Gb(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=$b(tx,e.__scopeTooltip),l=Jb(t),[u,d]=v.useState(null),[f,p]=v.useState(void 0),m=pp(),h=v.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,y=v.useRef(!1),[b,x]=Sp({prop:r,defaultProp:i??!1,onChange:Gb(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Zb))):c.onClose(),a?.(e)},`onChange`),caller:tx}),S=v.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=v.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,x(!0)},[x]),w=v.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x(!1)},[x]),T=v.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,x(!0),h.current=0},_)},[_,x]);v.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let E=f??m;return(0,R.jsx)(Lb,{...l,children:(0,R.jsx)(nx,{scope:t,contentId:E,setContentId:p,open:b,stateAttribute:S,trigger:u,onTriggerChange:d,onTriggerEnter:v.useCallback(()=>{c.isOpenDelayedRef.current?T():C()},[c.isOpenDelayedRef,T,C]),onTriggerLeave:v.useCallback(()=>{g?w():(window.clearTimeout(h.current),h.current=0)},[w,g]),onOpen:C,onClose:w,disableHoverableContent:g,children:n})})},`Tooltip`),ax=`TooltipTrigger`,ox=v.forwardRef(Gb(function(e,t){let{__scopeTooltip:n,...r}=e,i=rx(ax,n),a=$b(ax,n),o=Jb(n),s=np(t,v.useRef(null),i.onTriggerChange),c=v.useRef(!1),l=v.useRef(!1),u=v.useCallback(()=>c.current=!1,[]);return v.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,R.jsx)(Rb,{asChild:!0,...o,children:(0,R.jsx)(Gp.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:J(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:J(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:J(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:J(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:J(e.onBlur,i.onClose),onClick:J(e.onClick,i.onClose)})})},`TooltipTrigger`)),sx=`TooltipPortal`,[cx,lx]=Kb(sx,{forceMount:void 0}),ux=Gb(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=rx(sx,t);return(0,R.jsx)(cx,{scope:t,forceMount:n,children:(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),dx=`TooltipContent`,fx=v.forwardRef(Gb(function(e,t){let n=lx(dx,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=rx(dx,e.__scopeTooltip);return(0,R.jsx)(Mm,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(hx,{side:i,...a,ref:t}):(0,R.jsx)(px,{side:i,...a,ref:t})})},`TooltipContent`)),px=v.forwardRef(Gb(function(e,t){let n=rx(dx,e.__scopeTooltip),r=$b(dx,e.__scopeTooltip),i=v.useRef(null),a=np(t,i),[o,s]=v.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=v.useCallback(()=>{s(null),d(!1)},[d]),p=v.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=_x(r,gx(r,n.getBoundingClientRect())),a=vx(t.getBoundingClientRect()),o=bx([...i,...a]);s(o),d(!0)},[d]);return v.useEffect(()=>()=>f(),[f]),v.useEffect(()=>{if(c&&u){let e=Gb(e=>p(e,u),`handleTriggerLeave`),t=Gb(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),v.useEffect(()=>{if(o){let e=Gb(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!yx(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(hx,{...e,ref:a})},`TooltipContentHoverable`)),mx=Mp(`TooltipContent`),hx=v.forwardRef(Gb(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=rx(dx,n),u=Jb(n),{onClose:d}=l;v.useEffect(()=>(document.addEventListener(Zb,d),()=>document.removeEventListener(Zb,d)),[d]),v.useEffect(()=>{if(l.trigger){let e=Gb(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return cp(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,R.jsx)(rm,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,R.jsxs)(zb,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,R.jsx)(mx,{children:r}),i?(0,R.jsx)(Ub,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`));function gx(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Gb(gx,`getExitSideFromRect`);function _x(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Gb(_x,`getPaddedExitPoints`);function vx(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Gb(vx,`getPointsFromRect`);function yx(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Gb(yx,`isPointInPolygon`);function bx(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),xx(t)}Gb(bx,`getHull`);function xx(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Gb(xx,`getHullPresorted`);var Sx=ex,Cx=ix,wx=ox,Tx=ux,Ex=fx;function Dx({children:e}){return(0,R.jsx)(Sx,{delayDuration:250,children:e})}var Ox=`z-50 max-w-[280px] rounded-[8px] border border-rule bg-surface px-[10px] py-[7px] text-[12.5px] leading-[1.35] text-ink shadow-pop outline-none data-[state=delayed-open]:animate-[q-pop_120ms_ease-out] data-[state=closed]:animate-[q-pop-out_100ms_ease-in_forwards]`;function kx({content:e,children:t,side:n=`top`,align:r=`center`,className:i}){return(0,R.jsxs)(Cx,{children:[(0,R.jsx)(wx,{asChild:!0,children:t}),(0,R.jsx)(Tx,{children:(0,R.jsx)(Ex,{side:n,align:r,sideOffset:6,collisionPadding:12,className:Y(Ox,i),children:e})})]})}function Ax(){window.dispatchEvent(new CustomEvent(`design:palette`))}var jx=av===`⌘`?`⌘K`:`Ctrl K`;function Mx({width:e=240,label:t=`Search and jump`,compact:n}){if(n)return(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t,` `,(0,R.jsx)(S_,{children:jx})]}),children:(0,R.jsx)(`button`,{type:`button`,onClick:Ax,"aria-label":t,className:`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] border border-rule bg-soft text-muted transition-colors hover:border-rule-strong`,children:(0,R.jsx)(X,{name:`search`,size:15})})});let r=n===!1;return(0,R.jsxs)(`button`,{type:`button`,onClick:Ax,style:{width:e},"aria-label":t,className:Y(`flex h-ctrl min-w-0 cursor-pointer items-center gap-2 rounded-[6px] border border-rule bg-soft pr-1.5 pl-3 text-ctrl text-muted transition-colors hover:border-rule-strong`,r?`shrink-0`:`shrink max-lg:w-auto! max-md:w-ctrl! max-md:justify-center max-md:border-0! max-md:bg-transparent! max-md:p-0!`),children:[(0,R.jsx)(X,{name:`search`,size:15}),(0,R.jsx)(`span`,{className:Y(`min-w-0 grow truncate text-left`,!r&&`max-lg:hidden`),children:t}),(0,R.jsx)(`span`,{className:Y(`flex`,!r&&`max-md:hidden`),children:(0,R.jsx)(S_,{children:jx})})]})}var Nx=Object.defineProperty,Px=(e,t)=>Nx(e,`name`,{value:t,configurable:!0});function Fx(e){let t=e+`CollectionProvider`,[n,r]=op(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Px(e=>{let{scope:t,children:n}=e,r=v.useRef(null),a=v.useRef(new Map).current;return(0,R.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=Ap(s),l=v.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=np(t,a(s,n).collectionRef);return(0,R.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Ap(u),p=v.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=v.useRef(null),s=np(t,o),c=a(u,n);return v.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,R.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return v.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 Px(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}Px(Fx,`createCollection`);var Ix=new WeakMap,Lx=class e extends Map{static{Px(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Ix.set(this,!0)}set(e,t){return Ix.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=Bx(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=Rx(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Rx(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Rx(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 Rx(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=zx(e,t);return n===-1?void 0:e[n]}Px(Rx,`at`);function zx(e,t){let n=e.length,r=Bx(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Px(zx,`toSafeIndex`);function Bx(e){return e!==e||e===0?0:Math.trunc(e)}Px(Bx,`toSafeInteger`);function Vx(e){let t=e+`CollectionProvider`,[n,r]=op(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Lx,setItemMap:Px(()=>void 0,`setItemMap`)}),o=Px(({state:e,...t})=>e?(0,R.jsx)(c,{...t,state:e}):(0,R.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=Px(e=>{let t=h();return(0,R.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=Px(e=>{let{scope:t,children:n,state:r}=e,a=v.useRef(null),[o,s]=v.useState(null),c=np(a,s),[l,u]=r;return v.useEffect(()=>{if(!o)return;let e=Gx(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,R.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=Ap(l),d=v.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=np(t,a(l,n).collectionRef);return(0,R.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=Ap(f),m=v.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=v.useRef(null),[s,c]=v.useState(null),l=np(t,o,c),{setItemMap:u}=a(f,n),d=v.useRef(i);Hx(d.current,i)||(d.current=i);let m=d.current;return v.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Wx):(t.set(s,{...e,element:s}),t.toSorted(Wx)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Lx(e)))}},[s,m,u]),(0,R.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return v.useState(new Lx)}Px(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Px(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}Px(Vx,`createCollection`);function Hx(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}Px(Hx,`shallowEqual`);function Ux(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Px(Ux,`isElementPreceding`);function Wx(e,t){return!e[1].element||!t[1].element?0:Ux(e[1].element,t[1].element)?-1:1}Px(Wx,`sortByDocumentPosition`);function Gx(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Px(Gx,`getChildListObserver`);var Kx=Object.defineProperty,qx=(e,t)=>Kx(e,`name`,{value:t,configurable:!0}),Jx=v.createContext(void 0);function Yx(e){let t=v.useContext(Jx);return e||t||`ltr`}qx(Yx,`useDirection`);var Xx=Object.defineProperty,Zx=(e,t)=>Xx(e,`name`,{value:t,configurable:!0}),Qx=!1;function $x(){let[e,t]=v.useState(Qx);return v.useEffect(()=>{Qx||(Qx=!0,t(!0))},[]),e}Zx($x,`useIsHydrated`);var eS=v.useSyncExternalStore;function tS(){return()=>{}}Zx(tS,`subscribe`);function nS(){return eS(tS,()=>!0,()=>!1)}Zx(nS,`useIsHydratedModern`);var rS=typeof eS==`function`?nS:$x,iS=Object.defineProperty,aS=(e,t)=>iS(e,`name`,{value:t,configurable:!0}),oS=`rovingFocusGroup.onEntryFocus`,sS={bubbles:!1,cancelable:!0},cS=`RovingFocusGroup`,[lS,uS,dS]=Fx(cS),[fS,pS]=op(cS,[dS]),[mS,hS]=fS(cS),gS=v.forwardRef(aS(function(e,t){return(0,R.jsx)(lS.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(lS.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(_S,{...e,ref:t})})})},`RovingFocusGroup`)),_S=v.forwardRef(aS(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=v.useRef(null),p=np(t,f),m=Yx(a),[h,g]=Sp({prop:o,defaultProp:s??null,onChange:c,caller:cS}),[_,y]=v.useState(!1),b=Yp(l),x=uS(n),S=v.useRef(!1),[C,w]=v.useState(0);return v.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(oS,b),()=>e.removeEventListener(oS,b)},[b]),(0,R.jsx)(mS,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:v.useCallback(e=>g(e),[g]),onItemShiftTab:v.useCallback(()=>y(!0),[]),onFocusableItemAdd:v.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:v.useCallback(()=>w(e=>e-1),[]),children:(0,R.jsx)(Gp.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:J(e.onMouseDown,()=>{S.current=!0}),onFocus:J(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(oS,sS);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);CS([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:J(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),vS=`RovingFocusGroupItem`,yS=v.forwardRef(aS(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=pp(),l=a||c,u=hS(vS,n),d=u.currentTabStopId===l,f=uS(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=rS();return cp(()=>{if(g&&r)return p(),()=>m()},[g,r,p,m]),v.useEffect(()=>{if(!g&&r)return p(),()=>m()},[g,r,p,m]),(0,R.jsx)(lS.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(Gp.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:J(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:J(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:J(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=SS(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?wS(n,r+1):n.slice(r+1)}setTimeout(()=>CS(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),bS={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function xS(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}aS(xS,`getDirectionAwareKey`);function SS(e,t,n){let r=xS(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return bS[r]}aS(SS,`getFocusIntent`);function CS(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}aS(CS,`focusFirst`);function wS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}aS(wS,`wrapArray`);var TS=gS,ES=yS,DS=Object.defineProperty,OS=(e,t)=>DS(e,`name`,{value:t,configurable:!0}),kS=[`Enter`,` `],AS=[`ArrowDown`,`PageUp`,`Home`],jS=[`ArrowUp`,`PageDown`,`End`],MS=[...AS,...jS];[...kS],[...kS];var NS=`Menu`,[PS,FS,IS]=Fx(NS),[LS,RS]=op(NS,[IS,wb,pS]),zS=wb(),BS=pS(),[VS,HS]=LS(NS),[US,WS]=LS(NS),GS=OS(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=zS(t),[c,l]=v.useState(null),u=v.useRef(!1),d=Yp(a),f=Yx(i);return v.useEffect(()=>{let e=OS(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=OS(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),v.useEffect(()=>{if(!n)return;let e=OS(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,R.jsx)(Lb,{...s,children:(0,R.jsx)(VS,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(US,{scope:t,onClose:v.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),KS=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,...r}=e,i=zS(n);return(0,R.jsx)(Rb,{...i,...r,ref:t})},`MenuAnchor`)),qS=`MenuPortal`,[JS,YS]=LS(qS,{forceMount:void 0}),XS=OS(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=HS(qS,t);return(0,R.jsx)(JS,{scope:t,forceMount:n,children:(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:r})})})},`MenuPortal`),ZS=`MenuContent`,[QS,$S]=LS(ZS),eC=v.forwardRef(OS(function(e,t){let n=YS(ZS,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=HS(ZS,e.__scopeMenu),o=WS(ZS,e.__scopeMenu);return(0,R.jsx)(PS.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(Mm,{present:r||a.open,children:(0,R.jsx)(PS.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(tC,{...i,ref:t}):(0,R.jsx)(nC,{...i,ref:t})})})})},`MenuContent`)),tC=v.forwardRef(OS(function(e,t){let n=HS(ZS,e.__scopeMenu),r=v.useRef(null),i=np(t,r);return v.useEffect(()=>{let e=r.current;if(e)return sg(e)},[]),(0,R.jsx)(iC,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),nC=v.forwardRef(OS(function(e,t){let n=HS(ZS,e.__scopeMenu);return(0,R.jsx)(iC,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),rC=Ap(`MenuContent.ScrollLock`),iC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=HS(ZS,n),_=WS(ZS,n),y=zS(n),b=BS(n),x=FS(n),[S,C]=v.useState(null),w=v.useRef(null),T=np(t,w,g.onContentChange),E=v.useRef(0),D=v.useRef(``),O=v.useRef(0),k=v.useRef(null),A=v.useRef(`right`),j=v.useRef(0),M=m?Qh:v.Fragment,ee=m?{as:rC,allowPinchZoom:!0}:void 0,N=OS(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=SC(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;OS((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);v.useEffect(()=>()=>window.clearTimeout(E.current),[]),Um();let P=v.useCallback(e=>A.current===k.current?.side&&wC(e,k.current?.area),[]);return(0,R.jsx)(QS,{scope:n,searchRef:D,onItemEnter:v.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:v.useCallback(e=>{P(e)||(w.current?.focus(),C(null))},[P]),onTriggerLeave:v.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:O,onPointerGraceIntentChange:v.useCallback(e=>{k.current=e},[]),children:(0,R.jsx)(M,{...ee,children:(0,R.jsx)(hm,{asChild:!0,trapped:i,onMountAutoFocus:J(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(rm,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(TS,{asChild:!0,...b,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:J(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(zb,{role:`menu`,"aria-orientation":`vertical`,"data-state":_C(g.open),"data-radix-menu-content":``,dir:_.dir,...y,...h,ref:T,style:{outline:`none`,...h.style},onKeyDown:J(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=w.current;if(e.target!==i||!MS.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);jS.includes(e.key)&&a.reverse(),bC(a)}),onBlur:J(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:J(e.onPointerMove,TC(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),aC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(Gp.div,{...r,ref:t})},`MenuLabel`)),oC=`MenuItem`,sC=`menu.itemSelect`,cC=v.forwardRef(OS(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=v.useRef(null),o=WS(oC,e.__scopeMenu),s=$S(oC,e.__scopeMenu),c=np(t,a),l=v.useRef(!1),u=OS(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(sC,{bubbles:!0,cancelable:!0});e.addEventListener(sC,e=>r?.(e),{once:!0}),Kp(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,R.jsx)(lC,{...i,ref:c,disabled:n,onClick:J(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:J(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:J(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&kS.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),lC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=$S(oC,n),s=BS(n),c=v.useRef(null),l=np(t,c),[u,d]=v.useState(!1),[f,p]=v.useState(``);return v.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(PS.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(ES,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(Gp.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:J(e.onPointerMove,TC(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(e.onPointerLeave,TC(e=>o.onItemLeave(e))),onFocus:J(e.onFocus,()=>d(!0)),onBlur:J(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[uC,dC]=LS(`MenuRadioGroup`,{value:void 0,onValueChange:OS(()=>{},`onValueChange`)}),[fC,pC]=LS(`MenuItemIndicator`,{checked:!1}),mC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(Gp.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[hC,gC]=LS(`MenuSub`);function _C(e){return e?`open`:`closed`}OS(_C,`getOpenState`);function vC(e){return e===`indeterminate`}OS(vC,`isIndeterminate`);function yC(e){return vC(e)?`indeterminate`:e?`checked`:`unchecked`}OS(yC,`getCheckedState`);function bC(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}OS(bC,`focusFirst`);function xC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}OS(xC,`wrapArray`);function SC(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=xC(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}OS(SC,`getNextMatch`);function CC(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}OS(CC,`isPointInPolygon`);function wC(e,t){return t?CC({x:e.clientX,y:e.clientY},t):!1}OS(wC,`isPointerInGraceArea`);function TC(e){return t=>t.pointerType===`mouse`?e(t):void 0}OS(TC,`whenMouse`);var EC=GS,DC=KS,OC=XS,kC=eC,AC=aC,jC=cC,MC=mC,NC=Object.defineProperty,PC=(e,t)=>NC(e,`name`,{value:t,configurable:!0}),FC=`DropdownMenu`,[IC,LC]=op(FC,[RS]),RC=RS(),[zC,BC]=IC(FC),VC=PC(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=RC(t),l=v.useRef(null),[u,d]=Sp({prop:i,defaultProp:a??!1,onChange:o,caller:FC});return(0,R.jsx)(zC,{scope:t,triggerId:pp(),triggerRef:l,contentId:pp(),open:u,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(EC,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),HC=`DropdownMenuTrigger`,UC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=BC(HC,n),o=RC(n),s=np(t,a.triggerRef);return(0,R.jsx)(DC,{asChild:!0,...o,children:(0,R.jsx)(Gp.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:J(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:J(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),WC=PC(e=>{let{__scopeDropdownMenu:t,...n}=e,r=RC(t);return(0,R.jsx)(OC,{...r,...n})},`DropdownMenuPortal`),GC=`DropdownMenuContent`,KC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=BC(GC,n),a=RC(n),o=v.useRef(!1);return(0,R.jsx)(kC,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:J(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),qC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=RC(n);return(0,R.jsx)(AC,{...i,...r,ref:t})},`DropdownMenuLabel`)),JC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=RC(n);return(0,R.jsx)(jC,{...i,...r,ref:t})},`DropdownMenuItem`)),YC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=RC(n);return(0,R.jsx)(MC,{...i,...r,ref:t})},`DropdownMenuSeparator`)),XC=VC,ZC=UC,QC=WC,$C=KC,ew=qC,tw=JC,nw=YC,rw=`z-50 overflow-hidden rounded-[8px] border border-rule bg-surface shadow-pop outline-none py-1 data-[state=open]:animate-[q-pop_120ms_ease-out] data-[state=closed]:animate-[q-pop-out_100ms_ease-in_forwards]`,iw=null;typeof document<`u`&&document.addEventListener(`pointerover`,e=>iw=e.target,{capture:!0,passive:!0});function aw(){let e=document.activeElement;return e instanceof HTMLIFrameElement&&iw!==e}function ow({trigger:e,children:t,width:n=220,align:r=`start`,side:i=`bottom`,sideOffset:a=6,open:o,onOpenChange:s}){let[c,l]=(0,v.useState)(!1);return(0,R.jsxs)(XC,{open:o??c,onOpenChange:e=>{(e||!aw())&&(l(e),s?.(e))},modal:!1,children:[(0,R.jsx)(ZC,{asChild:!0,children:e}),(0,R.jsx)(QC,{children:(0,R.jsx)($C,{align:r,side:i,sideOffset:a,collisionPadding:12,onFocusOutside:sw,className:rw,style:{width:n,maxWidth:`calc(100vw - 24px)`},children:t})})]})}function sw(e){aw()&&e.preventDefault()}var cw=(e,t)=>Y(`flex min-h-9 w-full cursor-pointer items-center gap-2.5 border-0 px-3 py-1.5 text-left text-[13.5px] outline-none select-none`,`data-[highlighted]:bg-soft data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,t?`bg-soft`:`bg-transparent`,e?`text-danger-text`:`text-ink`);function lw({children:e,onSelect:t,danger:n,active:r,disabled:i,hint:a,className:o}){return(0,R.jsxs)(tw,{disabled:i,onSelect:t,className:Y(cw(n,r),o),children:[e,a?(0,R.jsx)(`span`,{className:`ml-auto pl-3 text-[12px] text-muted`,children:a}):null]})}function uw(){return(0,R.jsx)(nw,{className:`my-1 h-px bg-rule`})}function dw({children:e}){return(0,R.jsx)(ew,{className:`px-3 pt-1.5 pb-1 text-[12px] text-muted`,children:e})}var fw=[{value:`system`,label:`System`,icon:`monitor`},{value:`light`,label:`Light`,icon:`sun`},{value:`dark`,label:`Dark`,icon:`moon`}];function pw(){let e=y_(),t=b_();return(0,R.jsxs)(ow,{align:`end`,width:180,trigger:(0,R.jsx)(N_,{icon:t===`dark`?`moon`:`sun`,label:`Appearance`}),children:[(0,R.jsx)(dw,{children:`Appearance`}),fw.map(t=>(0,R.jsxs)(lw,{active:e===t.value,onSelect:()=>v_(t.value),children:[(0,R.jsx)(X,{name:t.icon,size:15,className:`text-ink2`}),t.label,e===t.value?(0,R.jsx)(X,{name:`check`,size:15,className:`ml-auto text-ink2`}):null]},t.value))]})}function mw({size:e=24}){return(0,R.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 32 32`,"aria-hidden":`true`,className:`shrink-0`,children:[(0,R.jsx)(`rect`,{width:`32`,height:`32`,rx:`7`,className:`fill-primary`}),(0,R.jsx)(`rect`,{x:`7`,y:`7`,width:`8`,height:`11`,rx:`1.5`,className:`fill-primary-ink`}),(0,R.jsx)(`rect`,{x:`17`,y:`7`,width:`8`,height:`6`,rx:`1.5`,fill:`#f0a040`}),(0,R.jsx)(`rect`,{x:`17`,y:`15`,width:`8`,height:`10`,rx:`1.5`,className:`fill-primary-ink`}),(0,R.jsx)(`rect`,{x:`7`,y:`20`,width:`8`,height:`5`,rx:`1.5`,className:`fill-primary-ink`})]})}function hw({name:e,version:t}){return(0,R.jsxs)(ye,{href:`/`,title:t?`foss-design ${t}`:void 0,className:`flex min-w-0 items-center gap-2 text-[14px] font-semibold text-ink no-underline`,children:[(0,R.jsx)(mw,{}),(0,R.jsx)(`span`,{className:`truncate`,children:e??`Design`})]})}function gw({children:e,className:t}){return(0,R.jsx)(`header`,{className:Y(`sticky top-0 z-30 flex h-[52px] shrink-0 items-center gap-3 border-b border-rule bg-surface px-4`,t),children:e})}var _w=(0,v.createContext)(!1).Provider;function vw(e,t,n){let[r,i]=(0,v.useState)(!1),a=(0,v.useRef)(0);return(0,v.useLayoutEffect)(()=>{let n=e.current,r=t.current;if(!n||!r)return;let o=()=>{let e=[...n.querySelectorAll(`[data-fit]`)].reduce((e,t)=>e+Math.max(0,t.scrollWidth-t.clientWidth),0),t=r.getBoundingClientRect().left-n.getBoundingClientRect().right;i(n=>n?t-e<a.current-r.offsetWidth+16:(a.current=r.offsetWidth,e>0))};o();let s=new ResizeObserver(o);return s.observe(n.parentElement??n),s.observe(r),()=>s.disconnect()},n),r}var yw=[{to:`/`,label:`Canvases`,match:e=>e===`/`||e.startsWith(`/c/`)},{to:`/system`,label:`Design system`,match:e=>e.startsWith(`/system`)}];function bw({location:e}){let t=(0,v.useRef)(null),n=yw.findIndex(t=>t.match(e)),[r,i]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let t=e.children[n];if(!t?.offsetWidth){i(null);return}let r=t.offsetLeft+10,a=t.offsetWidth-20;i(e=>e?.tab===n&&e.x===r&&e.width===a?e:{tab:n,x:r,width:a,slide:e!==null&&e.tab!==n})};r();let a=new ResizeObserver(r);return a.observe(e),()=>a.disconnect()},[n]),(0,R.jsxs)(`nav`,{ref:t,className:`relative flex h-[52px] items-stretch gap-0.5 max-md:hidden`,children:[yw.map((e,t)=>(0,R.jsx)(ye,{href:e.to,"aria-current":t===n?`page`:void 0,className:Y(`flex items-center px-2.5 text-[14px] no-underline transition-colors`,t===n?`font-medium text-ink`:`text-ink2 hover:text-ink`),children:e.label},e.to)),r?(0,R.jsx)(Gf.span,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 h-[2px] bg-action`,initial:!1,animate:{x:r.x,width:r.width},transition:r.slide?{type:`spring`,stiffness:520,damping:42}:{duration:0}}):null]})}function xw(){let e=n_().data,{slots:t}=$g(),[n]=I();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(gw,{children:[t.barStart,(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-6`,children:[t.brand??(0,R.jsx)(hw,{name:e?.name,version:e?.version}),(0,R.jsx)(bw,{location:n})]}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,R.jsx)(Mx,{}),(0,R.jsx)(`span`,{className:Y(`flex`,t.barEnd?`max-md:hidden`:void 0),children:(0,R.jsx)(pw,{})}),t.barEnd]})]}),(0,R.jsx)(Sw,{location:n}),t.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:t.belowBar}):null]})}function Sw({location:e}){return(0,R.jsx)(`nav`,{className:`sticky top-[52px] z-30 hidden h-10 shrink-0 items-stretch border-b border-rule bg-surface px-2 max-md:flex`,children:yw.map(t=>{let n=t.match(e);return(0,R.jsxs)(ye,{href:t.to,"aria-current":n?`page`:void 0,className:Y(`relative flex grow items-center justify-center text-[13.5px] no-underline`,n?`font-medium text-ink`:`text-ink2`),children:[t.label,n?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-x-6 bottom-0 h-[2px] rounded-full bg-action`}):null]},t.to)})})}var Cw=window.matchMedia(`(max-width: 767px)`),ww=e=>(Cw.addEventListener(`change`,e),()=>Cw.removeEventListener(`change`,e));function Tw(){return(0,v.useSyncExternalStore)(ww,()=>Cw.matches)}var Ew=Object.defineProperty,Dw=(e,t)=>Ew(e,`name`,{value:t,configurable:!0}),Ow=`Popover`,[kw,Aw]=op(Ow,[wb]),jw=wb(),[Mw,Nw]=kw(Ow),Pw=Dw(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=jw(t),c=v.useRef(null),[l,u]=v.useState(!1),[d,f]=Sp({prop:r,defaultProp:i??!1,onChange:a,caller:Ow});return(0,R.jsx)(Lb,{...s,children:(0,R.jsx)(Mw,{scope:t,contentId:pp(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:v.useCallback(()=>u(!0),[]),onCustomAnchorRemove:v.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),Fw=`PopoverTrigger`,Iw=v.forwardRef(Dw(function(e,t){let{__scopePopover:n,...r}=e,i=Nw(Fw,n),a=jw(n),o=np(t,i.triggerRef),s=(0,R.jsx)(Gp.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":qw(i.open),...r,ref:o,onClick:J(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,R.jsx)(Rb,{asChild:!0,...a,children:s})},`PopoverTrigger`)),Lw=`PopoverPortal`,[Rw,zw]=kw(Lw,{forceMount:void 0}),Bw=Dw(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Nw(Lw,t);return(0,R.jsx)(Rw,{scope:t,forceMount:n,children:(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),Vw=`PopoverContent`,Hw=v.forwardRef(Dw(function(e,t){let n=zw(Vw,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Nw(Vw,e.__scopePopover);return(0,R.jsx)(Mm,{present:r||a.open,children:a.modal?(0,R.jsx)(Ww,{...i,ref:t}):(0,R.jsx)(Gw,{...i,ref:t})})},`PopoverContent`)),Uw=Ap(`PopoverContent.RemoveScroll`),Ww=v.forwardRef(Dw(function(e,t){let n=Nw(Vw,e.__scopePopover),r=v.useRef(null),i=np(t,r),a=v.useRef(!1);return v.useEffect(()=>{let e=r.current;if(e)return sg(e)},[]),(0,R.jsx)(Qh,{as:Uw,allowPinchZoom:!0,children:(0,R.jsx)(Kw,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),Gw=v.forwardRef(Dw(function(e,t){let n=Nw(Vw,e.__scopePopover),r=v.useRef(!1),i=v.useRef(!1);return(0,R.jsx)(Kw,{...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()}})},`PopoverContentNonModal`)),Kw=v.forwardRef(Dw(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Nw(Vw,n),p=jw(n);return Um(),(0,R.jsx)(hm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(rm,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,R.jsx)(zb,{"data-state":qw(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function qw(e){return e?`open`:`closed`}Dw(qw,`getState`);var Jw=Pw,Yw=Iw,Xw=Bw,Zw=Hw,Qw=new u_([]),$w=1;function eT(e,t,n=`ok`){let r=$w++;Qw.set(i=>[...i.slice(-2),{id:r,title:e,text:t,tone:n}]),setTimeout(()=>Qw.set(e=>e.filter(e=>e.id!==r)),n===`error`?4200:2200)}var tT=new u_([]),nT=1;function rT(){let[e]=(0,v.useState)(()=>nT++);(0,v.useEffect)(()=>(tT.set(t=>[...t,e]),()=>tT.set(t=>t.filter(t=>t!==e))),[e]);let t=d_(tT,t=>t[0]===e),n=d_(Qw);return t?(0,R.jsx)(`div`,{className:`pointer-events-none fixed bottom-5 left-1/2 z-[60] flex -translate-x-1/2 flex-col items-center gap-2`,children:(0,R.jsx)(ed,{mode:`popLayout`,children:n.map(e=>(0,R.jsxs)(Gf.div,{layout:!0,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,transition:{duration:.12}},transition:{type:`spring`,stiffness:520,damping:40},className:`flex max-w-[min(420px,calc(100vw-32px))] min-w-0 items-center gap-2.5 rounded-[8px] border border-rule bg-surface px-3 py-2 text-[13px] text-ink shadow-pop`,children:[e.tone===`error`?(0,R.jsx)(X,{name:`alert`,size:15,className:`text-danger-text`}):e.tone===`info`?(0,R.jsx)(X,{name:`info`,size:15,className:`text-muted`}):(0,R.jsx)(X,{name:`check`,size:15,className:`text-ok-text`}),(0,R.jsx)(`span`,{className:`shrink-0 font-medium whitespace-nowrap`,children:e.title}),e.text?(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px] text-muted`,children:e.text}):null]},e.id))})}):null}async function iT(e,t=`Copied`){try{await navigator.clipboard.writeText(e),eT(t,e.length>64?void 0:e)}catch{eT(`Could not copy`,`The browser blocked clipboard access`,`error`)}}function aT(e){return e.split(`/`).filter(Boolean)}function oT(e){return{pattern:e,segments:aT(e).map(e=>e===`*`?{kind:`splat`}:e.startsWith(`:`)?{kind:`param`,optional:e.endsWith(`?`)}:{kind:`static`,value:e})}}function sT(e){try{return decodeURIComponent(e)}catch{return e}}function cT(e,t){let n=aT(t.split(/[?#]/)[0]??``).map(sT),r=(t,i)=>{if(t===e.segments.length)return i===n.length?0:null;let a=e.segments[t];if(a.kind===`splat`)return 0;if(a.kind===`static`){if(n[i]!==a.value)return null;let e=r(t+1,i+1);return e===null?null:e+4}if(i<n.length){let e=r(t+1,i+1);if(e!==null)return e+2}return a.optional?r(t+1,i):null};return r(0,0)}function lT(e,t){let n=null;for(let r of e)for(let e of r.routes){let i=cT(e,t);i!==null&&(!n||i>n.score)&&(n={score:i,value:r.value})}return n?.value??null}function uT(e,t=`/`){let n=e.trim();if(!n||n.startsWith(`#`)||/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith(`//`))return null;let r=new URL(n,`http://app.invalid${t.replace(/\/:[^/]+\??|\/\*$/g,`/x`)}`);return r.pathname+r.search+r.hash}function dT(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fT=dT();function pT(e){fT=e}var mT={exec:()=>null};function hT(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function Q(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(_T.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var gT=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),_T={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:hT(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:hT(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:hT(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:hT(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:hT(e=>RegExp(`^ {0,${e}}(?:</?(?:${MT})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:hT(e=>RegExp(`^ {0,${e}}>`))},vT=/^(?:[ \t]*(?:\n|$))+/,yT=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,bT=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xT=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ST=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,CT=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wT=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,TT=Q(wT).replace(/bull/g,CT).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ET=Q(wT).replace(/bull/g,CT).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),DT=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,OT=/^[^\n]+/,kT=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,AT=Q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,kT).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),jT=Q(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,CT).getRegex(),MT=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,NT=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,PT=Q(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,NT).replace(`tag`,MT).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),FT=e=>Q(DT).replace(`hr`,xT).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,MT).getRegex(),IT=FT(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),LT=FT(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),RT={blockquote:Q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,LT).getRegex(),code:yT,def:AT,fences:bT,heading:ST,hr:xT,html:PT,lheading:TT,list:jT,newline:vT,paragraph:IT,table:mT,text:OT},zT=Q(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,xT).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,MT).getRegex(),BT={...RT,lheading:ET,table:zT,paragraph:Q(DT).replace(`hr`,xT).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,zT).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,MT).getRegex()},VT={...RT,html:Q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,NT).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:mT,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Q(DT).replace(`hr`,xT).replace(`heading`,` *#{1,6} *[^
57
+ `},qh=0,Jh=[];function Yh(e){var t=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),i=v.useState(qh++)[0],a=v.useState(_h)[0],o=v.useRef(e);v.useEffect(function(){o.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=qm([e.lockRef.current],(e.shards||[]).map(Wh),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=v.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Hh(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Fh(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Fh(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Vh(h,t,e,h===`h`?s:c,!0)},[]),c=v.useCallback(function(e){var n=e;if(Jh.length&&Jh[Jh.length-1]===a){var r=`deltaY`in n?Uh(n):Hh(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Gh(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Wh).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=v.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Xh(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=v.useCallback(function(e){n.current=Hh(e),r.current=void 0},[]),d=v.useCallback(function(t){l(t.type,Uh(t),t.target,s(t,e.lockRef.current))},[]),f=v.useCallback(function(t){l(t.type,Hh(t),t.target,s(t,e.lockRef.current))},[]);v.useEffect(function(){return Jh.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ah),document.addEventListener(`touchmove`,c,Ah),document.addEventListener(`touchstart`,u,Ah),function(){Jh=Jh.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ah),document.removeEventListener(`touchmove`,c,Ah),document.removeEventListener(`touchstart`,u,Ah)}},[]);var p=e.removeScrollBar,m=e.inert;return v.createElement(v.Fragment,null,m?v.createElement(a,{styles:Kh(i)}):null,p?v.createElement(Dh,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xh(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Zh=sh(ch,Yh),Qh=v.forwardRef(function(e,t){return v.createElement(uh,Gm({},e,{ref:t,sideCar:Zh}))});Qh.classNames=uh.classNames;var $h=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},eg=new WeakMap,tg=new WeakMap,ng={},rg=0,ig=function(e){return e&&(e.host||ig(e.parentNode))},ag=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ig(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},og=function(e,t,n,r){var i=ag(t,Array.isArray(e)?e:[e]);ng[n]||(ng[n]=new WeakMap);var a=ng[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(eg.get(e)||0)+1,l=(a.get(e)||0)+1;eg.set(e,c),a.set(e,l),o.push(e),c===1&&i&&tg.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),rg++,function(){o.forEach(function(e){var t=eg.get(e)-1,i=a.get(e)-1;eg.set(e,t),a.set(e,i),t||(tg.has(e)||e.removeAttribute(r),tg.delete(e)),i||e.removeAttribute(n)}),rg--,rg||(eg=new WeakMap,eg=new WeakMap,tg=new WeakMap,ng={})}},sg=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||$h(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),og(r,i,n,`aria-hidden`)):function(){return null}},cg=Object.defineProperty,lg=(e,t)=>cg(e,`name`,{value:t,configurable:!0}),ug=`Dialog`,[dg,fg]=op(ug),[pg,mg]=dg(ug),hg=lg(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=v.useRef(null),c=v.useRef(null),[l,u]=Sp({prop:r,defaultProp:i??!1,onChange:a,caller:ug}),[d,f]=v.useState(0),[p,m]=v.useState(0);return(0,R.jsx)(pg,{scope:t,triggerRef:s,contentRef:c,contentId:pp(),titleId:pp(),descriptionId:pp(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:v.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),gg=`DialogPortal`,[_g,vg]=dg(gg,{forceMount:void 0}),yg=lg(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=mg(gg,t);return(0,R.jsx)(_g,{scope:t,forceMount:n,children:v.Children.map(r,e=>(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),bg=`DialogOverlay`,xg=v.forwardRef(lg(function(e,t){let n=vg(bg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mg(bg,e.__scopeDialog);return a.modal?(0,R.jsx)(Mm,{present:r||a.open,children:(0,R.jsx)(Cg,{...i,ref:t})}):null},`DialogOverlay`)),Sg=Ap(`DialogOverlay.RemoveScroll`),Cg=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,...r}=e,i=mg(bg,n),a=np(t,im());return(0,R.jsx)(Qh,{as:Sg,allowPinchZoom:!0,shards:[i.contentRef],children:(0,R.jsx)(Gp.div,{"data-state":Ng(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),wg=`DialogContent`,Tg=v.forwardRef(lg(function(e,t){let n=vg(wg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mg(wg,e.__scopeDialog);return(0,R.jsx)(Mm,{present:r||a.open,children:a.modal?(0,R.jsx)(Eg,{...i,ref:t}):(0,R.jsx)(Dg,{...i,ref:t})})},`DialogContent`)),Eg=v.forwardRef(lg(function(e,t){let n=mg(wg,e.__scopeDialog),r=v.useRef(null),i=np(t,n.contentRef,r);return v.useEffect(()=>{let e=r.current;if(e)return sg(e)},[]),(0,R.jsx)(Og,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Dg=v.forwardRef(lg(function(e,t){let n=mg(wg,e.__scopeDialog),r=v.useRef(!1),i=v.useRef(!1);return(0,R.jsx)(Og,{...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`)),Og=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=mg(wg,n);return Um(),(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(hm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(rm,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Ng(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),kg=`DialogTitle`,Ag=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,...r}=e,i=mg(kg,n),{setTitleCount:a}=i;return cp(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(Gp.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),jg=`DialogClose`,Mg=v.forwardRef(lg(function(e,t){let{__scopeDialog:n,...r}=e,i=mg(jg,n);return(0,R.jsx)(Gp.button,{type:`button`,...r,ref:t,onClick:J(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Ng(e){return e?`open`:`closed`}lg(Ng,`getState`);var Pg=window.__DESIGN_STATIC__===!0,Fg=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function Ig(e,t){let n=await fetch(e,{cache:t});if(!n.ok){let e=`${n.status} ${n.statusText}`;try{let t=await n.json();t.error&&(e=t.error)}catch{}throw new Fg(n.status,e)}return await n.json()}async function Lg(e){try{return await e}catch(e){if(e instanceof Fg&&e.status===404)return null;throw e}}var Rg=``;function zg(e){return Rg!==e.version&&(Rg=e.version,console.info(`foss-design ${e.version}${Pg?` (static build)`:``}`)),e}var Bg={live:!0,project:()=>Ig(`/api/project`,`no-store`).then(zg),canvas:async e=>({doc:await Ig(`/api/canvas/${encodeURIComponent(e)}`,`no-store`),base:``}),system:async()=>{let e=await Lg(Ig(`/api/system`,`no-store`));return e?{doc:e,base:``}:null},async source(e){let t=await fetch(`/api/source?path=${encodeURIComponent(e)}`,{cache:`no-store`});if(!t.ok)throw new Fg(t.status,`Could not read ${e}`);return t.text()},async setIcon(e){let t=await fetch(`/api/icon`,{method:e?`PUT`:`DELETE`,headers:e?{"content-type":e.type||`application/octet-stream`}:void 0,body:e});if(!t.ok){let e=await t.json().catch(()=>({}));throw new Fg(t.status,e.error??`${t.status} ${t.statusText}`)}}},Vg=null,Hg={live:!1,project:()=>Ig(`api/project.json`,`default`).then(zg),canvas:async e=>({doc:await Ig(`api/canvas/${encodeURIComponent(e)}.json`,`default`),base:``}),system:async()=>{let e=await Lg(Ig(`api/system.json`,`default`));return e?{doc:e,base:``}:null},async source(e){Vg??=Ig(`api/sources.json`,`default`).catch(()=>({}));let t=(await Vg)[e];if(t===void 0)throw new Fg(404,`${e} is not in this build`);return t}};function Ug(e,t){try{let n=typeof document>`u`?`http://localhost/`:document.baseURI;if(!t){let t=new URL(e,n);return t.protocol===`http:`||t.protocol===`https:`?e:``}let r=new URL(t.endsWith(`/`)?t:`${t}/`,n),i=new URL(e,r);return i.origin===r.origin&&i.href.startsWith(r.href)?i.href:``}catch{return``}}function Wg(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:``}catch{return``}}function Gg(e,t){let n=e=>Ug(e,t);return{...e,pages:e.pages.map(e=>({...e,sections:e.sections.map(e=>({...e,items:e.items.map(e=>{if(e.kind===`screen`){let t=e=>e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t&&n(t)]).filter(([,e])=>e)):void 0,r=n(e.url);return{...e,url:r,missing:e.missing||!r,snapshots:t(e.snapshots),thumbs:t(e.thumbs)}}return e.kind===`image`?{...e,url:n(e.url)}:e.kind===`url`?{...e,url:Wg(e.url)}:e})}))}))}}function Kg(e,t){let n=e=>Ug(e,t);return{...e,components:e.components.map(e=>({...e,url:n(e.url)})),assets:e.assets.map(e=>({...e,url:n(e.url)})),typographyUrl:e.typographyUrl&&n(e.typographyUrl)}}function qg(e){return{all:[`design`,e],project:[`design`,e,`project`],canvas:t=>[`design`,e,`canvas`,t],system:[`design`,e,`system`],sources:[`design`,e,`source`],source:(t,n)=>[`design`,e,`source`,t,n]}}var Jg=`clipboard-read; clipboard-write; fullscreen`,Yg=new WeakMap,Xg=0;function Zg(e){let t=Yg.get(e);return t||(Xg+=1,t=String(Xg),Yg.set(e,t)),t}var Qg=(0,v.createContext)(null);function $g(){let e=(0,v.useContext)(Qg);if(!e)throw Error(`foss-design: this component renders inside <DesignViewer>`);return e}function e_(e,t){if(e===t)return!0;try{return decodeURIComponent(e)===t}catch{return!1}}function t_(e){return new zt({defaultOptions:{queries:{staleTime:e?0:1/0,retry:1,refetchOnWindowFocus:!1}}})}function n_(){let{source:e,keys:t,scope:n}=$g();return Zt({queryKey:t.project,queryFn:()=>e.project(),enabled:!n})}function r_(e,t=!0){let{source:n,keys:r}=$g();return Zt({queryKey:r.canvas(e),queryFn:async()=>{let{doc:t,base:r}=await n.canvas(e);return Gg(t,r)},placeholderData:e=>e,enabled:t})}function i_(e=!0){let{source:t,keys:n}=$g();return Zt({queryKey:n.system,queryFn:async()=>{let e=await t.system();return e?Kg(e.doc,e.base):null},enabled:e})}function a_(e,t=`system`){let{source:n,keys:r}=$g();return Zt({queryKey:r.source(t,e??``),queryFn:()=>n.source(e,t),enabled:!!e})}function o_(e,t){let n=null,r=!1;return n=new EventSource(`/api/events`),n.onopen=()=>{r&&(r=!1,e.invalidateQueries({queryKey:t.all}))},n.onerror=()=>{r=!0},n.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}if(r.type===`project`)e.invalidateQueries({queryKey:t.project});else if(r.type===`system`)e.invalidateQueries({queryKey:t.system}),e.invalidateQueries({queryKey:t.sources});else if(r.type===`canvas`||r.type===`snapshot`){let n=r.type===`canvas`?r.id:r.canvas;e.invalidateQueries({queryKey:t.canvas(n)}),r.type===`snapshot`&&e.invalidateQueries({queryKey:t.project})}},()=>n?.close()}function Y(...e){return e.filter(Boolean).join(` `)}var s_=null;function c_(e,t){s_={canvas:e,item:t},window.dispatchEvent(new CustomEvent(`design:focus`,{detail:s_}))}function l_(e){if(!s_||s_.canvas!==e)return null;let t=s_.item;return s_=null,t}var u_=class{value;listeners=new Set;constructor(e){this.value=e}get=()=>this.value;set=e=>{let t=typeof e==`function`?e(this.value):e;if(!Object.is(t,this.value)){this.value=t;for(let e of this.listeners)e()}};subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)})};function d_(e,t=e=>e){return(0,v.useSyncExternalStore)(e.subscribe,()=>t(e.get()),()=>t(e.get()))}var f_=`foss-design.theme`;function p_(){try{let e=localStorage.getItem(f_);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var m_=new u_(p_()),h_=window.matchMedia(`(prefers-color-scheme: dark)`);function g_(e){return e===`system`?h_.matches?`dark`:`light`:e}function __(){document.documentElement.dataset.theme=g_(m_.get())}h_.addEventListener(`change`,__),m_.subscribe(__),__();function v_(e){try{localStorage.setItem(f_,e)}catch{}m_.set(e)}function y_(){return d_(m_)}function b_(){let e=d_(m_),t=(0,v.useSyncExternalStore)(e=>(h_.addEventListener(`change`,e),()=>h_.removeEventListener(`change`,e)),()=>h_.matches);return e===`system`?t?`dark`:`light`:e}var x_={plus:`<path d="M5 12h14"/><path d="M12 5v14"/>`,check:`<path d="M20 6 9 17l-5-5"/>`,x:`<path d="M18 6 6 18"/><path d="m6 6 12 12"/>`,"chevron-down":`<path d="m6 9 6 6 6-6"/>`,"chevron-up":`<path d="m18 15-6-6-6 6"/>`,"chevron-right":`<path d="m9 18 6-6-6-6"/>`,"arrow-right":`<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>`,chevrons:`<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>`,copy:`<rect width="14" height="14" x="8" y="8" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>`,search:`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>`,bell:`<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>`,refresh:`<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>`,"up-right":`<path d="M7 7h10v10"/><path d="M7 17 17 7"/>`,"down-left":`<path d="M17 7 7 17"/><path d="M17 17H7V7"/>`,external:`<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>`,"user-plus":`<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M19 8v6"/><path d="M22 11h-6"/>`,user:`<circle cx="12" cy="8" r="5"/><path d="M20 21a8 8 0 0 0-16 0"/>`,trash:`<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>`,more:`<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>`,alert:`<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/>`,info:`<circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/>`,upload:`<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m17 8-5-5-5 5"/><path d="M12 3v12"/>`,download:`<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/>`,shield:`<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/><path d="m9 12 2 2 4-4"/>`,logout:`<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><path d="m16 17 5-5-5-5"/><path d="M21 12H9"/>`,loader:`<path d="M21 12a9 9 0 1 1-6.219-8.56"/>`,"circle-check":`<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>`,"circle-dashed":`<circle cx="12" cy="12" r="9" stroke-dasharray="3 3"/>`,clock:`<circle cx="12" cy="12" r="10"/><path d="M12 6v6l4 2"/>`,mail:`<rect width="20" height="16" x="2" y="4" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>`,send:`<path d="m22 2-7 20-4-9-9-4Z"/><path d="M22 2 11 13"/>`,chat:`<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/>`,wallet:`<path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"/><path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"/>`,"file-code":`<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/>`,ban:`<circle cx="12" cy="12" r="10"/><path d="m4.9 4.9 14.2 14.2"/>`,code:`<path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/>`,"chevron-left":`<path d="m15 18-6-6 6-6"/>`,bluetooth:`<path d="m7 7 10 10-5 5V2l5 5L7 17"/>`,face:`<path d="M3 7V5a2 2 0 0 1 2-2h2"/><path d="M17 3h2a2 2 0 0 1 2 2v2"/><path d="M21 17v2a2 2 0 0 1-2 2h-2"/><path d="M7 21H5a2 2 0 0 1-2-2v-2"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01"/><path d="M15 9h.01"/>`,eye:`<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/>`,clipboard:`<rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/>`,grip:`<circle cx="9" cy="5" r="1"/><circle cx="9" cy="12" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="19" r="1"/>`,list:`<path d="M3 12h.01"/><path d="M3 18h.01"/><path d="M3 6h.01"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M8 6h13"/>`,lock:`<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>`,hw:`<rect width="20" height="10" x="2" y="7" rx="2"/><path d="M15 7v10"/><circle cx="8" cy="12" r="1.5"/>`,link:`<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>`,signal:`<path d="M2 20h.01"/><path d="M7 20v-4"/><path d="M12 20v-8"/><path d="M17 20V8"/>`,grid:`<rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/>`,coins:`<circle cx="8" cy="8" r="6"/><path d="M18.09 10.37A6 6 0 1 1 10.34 18"/><path d="M7 6h1v4"/><path d="m16.71 13.88.7.71-2.82 2.82"/>`,arrows:`<path d="M8 3 4 7l4 4"/><path d="M4 7h16"/><path d="m16 21 4-4-4-4"/><path d="M20 17H4"/>`,key:`<path d="m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4"/><path d="m21 2-9.6 9.6"/><circle cx="7.5" cy="15.5" r="5.5"/>`,blocks:`<rect width="7" height="7" x="14" y="3" rx="1"/><path d="M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3"/>`,settings:`<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>`,qr:`<rect width="5" height="5" x="3" y="3" rx="1"/><rect width="5" height="5" x="16" y="3" rx="1"/><rect width="5" height="5" x="3" y="16" rx="1"/><path d="M21 16h-3a2 2 0 0 0-2 2v3"/><path d="M21 21v.01"/><path d="M12 7v3a2 2 0 0 1-2 2H7"/><path d="M3 12h.01"/><path d="M12 3h.01"/><path d="M12 16v.01"/><path d="M16 12h1"/><path d="M21 12v.01"/><path d="M12 21v-1"/>`,edit:`<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/>`,star:`<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"/>`,home:`<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>`,moon:`<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>`,sun:`<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>`,languages:`<path d="m5 8 6 6"/><path d="m4 14 6-6 2-3"/><path d="M2 5h12"/><path d="M7 2h1"/><path d="m22 22-5-10-5 10"/><path d="M14 18h6"/>`,"arrow-left":`<path d="m12 19-7-7 7-7"/><path d="M19 12H5"/>`,play:`<polygon points="6 3 20 12 6 21 6 3"/>`,"zoom-in":`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/><path d="M11 8v6"/><path d="M8 11h6"/>`,"zoom-out":`<circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/><path d="M8 11h6"/>`,fit:`<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>`,"panel-left":`<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/>`,layers:`<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"/><path d="m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"/><path d="m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"/>`,file:`<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/>`,palette:`<circle cx="13.5" cy="6.5" r="1"/><circle cx="17.5" cy="10.5" r="1"/><circle cx="8.5" cy="7.5" r="1"/><circle cx="6.5" cy="12.5" r="1"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.93 0 1.65-.75 1.65-1.69 0-.44-.18-.84-.44-1.13-.29-.29-.44-.65-.44-1.13a1.64 1.64 0 0 1 1.67-1.67h2c3.05 0 5.55-2.5 5.55-5.55C21.96 6.01 17.46 2 12 2z"/>`,type:`<path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/>`,shape:`<path d="M5 3a2 2 0 0 0-2 2"/><path d="M19 3a2 2 0 0 1 2 2"/><path d="M21 19a2 2 0 0 1-2 2"/><path d="M5 21a2 2 0 0 1-2-2"/><path d="M9 3h1"/><path d="M9 21h1"/><path d="M14 3h1"/><path d="M14 21h1"/><path d="M3 9v1"/><path d="M21 9v1"/><path d="M3 14v1"/><path d="M21 14v1"/>`,motion:`<path d="M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/><path d="M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/><path d="M2 6c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"/>`,book:`<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/>`,image:`<rect width="18" height="18" x="3" y="3" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.09-3.09a2 2 0 0 0-2.82 0L6 21"/>`,monitor:`<rect width="20" height="14" x="2" y="3" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/>`,smartphone:`<rect width="14" height="20" x="5" y="2" rx="2"/><path d="M12 18h.01"/>`,tablet:`<rect width="16" height="20" x="4" y="2" rx="2"/><path d="M12 18h.01"/>`,note:`<path d="M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z"/><path d="M15 3v4a2 2 0 0 0 2 2h4"/>`,globe:`<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>`,share:`<path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><path d="m16 6-4-4-4 4"/><path d="M12 2v13"/>`,pointer:`<path d="M4.04 4.69a.5.5 0 0 1 .65-.65l16 6.5a.5.5 0 0 1-.06.95l-6.12 1.58a2 2 0 0 0-1.44 1.44l-1.58 6.12a.5.5 0 0 1-.95.06z"/>`,component:`<path d="M5.5 8.5 9 12l-3.5 3.5L2 12l3.5-3.5Z"/><path d="m12 2 3.5 3.5L12 9 8.5 5.5 12 2Z"/><path d="M18.5 8.5 22 12l-3.5 3.5L15 12l3.5-3.5Z"/><path d="m12 15 3.5 3.5L12 22l-3.5-3.5L12 15Z"/>`,keyboard:`<rect width="20" height="16" x="2" y="4" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M8 12h.01"/><path d="M12 12h.01"/><path d="M16 12h.01"/><path d="M7 16h10"/>`,folder:`<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/>`,canvas:`<rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/>`};function X({name:e,size:t=16,strokeWidth:n=1.75,className:r}){return(0,R.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:n,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`shrink-0 ${e===`loader`?`animate-spin`:``} ${r??``}`,dangerouslySetInnerHTML:{__html:x_[e]}})}function Z({children:e,size:t=12.5,className:n,title:r,wrap:i}){return(0,R.jsx)(`span`,{title:r,className:Y(i?`break-all`:`whitespace-nowrap`,`font-mono`,n),style:{fontSize:t},children:e})}function S_({children:e}){return(0,R.jsx)(`kbd`,{className:`rounded-[4px] border border-rule bg-surface px-[5px] py-px font-mono text-[11px] text-ink2`,children:e})}function C_({top:e,bottom:t,weight:n=500}){return(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-px`,children:[(0,R.jsx)(`span`,{className:`truncate leading-[1.35]`,style:{fontWeight:n},children:e}),t?(0,R.jsx)(`span`,{className:`flex min-w-0 items-center gap-2.5 overflow-hidden whitespace-nowrap text-[12.5px] leading-[1.35] text-muted`,children:t}):null]})}var w_={canvas:`This canvas`,canvases:`Canvases`,system:`Design system`,actions:`Actions`};function T_(e){let t=/^\/c\/([^/]+)/.exec(e);return t?decodeURIComponent(t[1]):null}function E_({onClose:e}){let[t,n]=I(),r=$g().scope,i=n_().data,a=r?.canvas??T_(t),o=r_(a??``,!!a).data,s=i_(!!i?.system).data,[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(0),f=t=>()=>{e(),t()},p=[];if(o)for(let e of o.pages){p.push({id:`page:${e.id}`,group:`canvas`,label:e.title,icon:`file`,hint:`Page`,run:f(()=>n(`/c/${encodeURIComponent(o.id)}/p/${encodeURIComponent(e.id)}`))});for(let t of e.sections)for(let r of t.items)(r.kind===`screen`||r.kind===`url`)&&p.push({id:`item:${e.id}:${r.id}`,group:`canvas`,label:r.title,icon:r.kind===`url`?`globe`:`monitor`,hint:t.title?`${e.title} · ${t.title}`:e.title,keywords:`${r.id} ${t.title??``}`,searchOnly:!0,run:f(()=>{n(`/c/${encodeURIComponent(o.id)}/p/${encodeURIComponent(e.id)}`),c_(o.id,r.id)})})}for(let e of i?.canvases??[])e.id!==a&&p.push({id:`canvas:${e.id}`,group:`canvases`,label:e.title,icon:`canvas`,hint:`${e.screens} screens`,keywords:e.id,run:f(()=>n(`/c/${encodeURIComponent(e.id)}`))});if(i?.system){for(let[e,t,r]of[[`Overview`,`/system`,`book`],[`Colors`,`/system/colors`,`palette`],[`Typography`,`/system/typography`,`type`],[`Spacing & shape`,`/system/shape`,`shape`]])p.push({id:`sys:${t}`,group:`system`,label:e,icon:r,run:f(()=>n(t))});for(let e of s?.components??[])p.push({id:`component:${e.id}`,group:`system`,label:e.title,icon:`component`,hint:e.group,searchOnly:!0,run:f(()=>n(`/system/components/${encodeURIComponent(e.id)}`))});for(let e of s?.guidelines??[])p.push({id:`guide:${e.slug}`,group:`system`,label:e.title,icon:`book`,hint:`Guideline`,searchOnly:!0,run:f(()=>n(`/system/guidelines/${encodeURIComponent(e.slug)}`))})}r||p.push({id:`home`,group:`actions`,label:`All canvases`,icon:`home`,run:f(()=>n(`/`))}),p.push({id:`light`,group:`actions`,label:`Light appearance`,icon:`sun`,searchOnly:!0,run:f(()=>v_(`light`))},{id:`dark`,group:`actions`,label:`Dark appearance`,icon:`moon`,searchOnly:!0,run:f(()=>v_(`dark`))},{id:`system-theme`,group:`actions`,label:`System appearance`,icon:`monitor`,searchOnly:!0,run:f(()=>v_(`system`))});let m=c.trim().toLowerCase(),h=p.filter(e=>m?`${e.label} ${e.keywords??``} ${typeof e.hint==`string`?e.hint:``}`.toLowerCase().includes(m):!e.searchOnly),g=[`canvas`,`canvases`,`system`,`actions`].map(e=>({group:e,items:h.filter(t=>t.group===e)})).filter(e=>e.items.length),_=g.flatMap(e=>e.items),y=Math.min(u,Math.max(_.length-1,0)),b=-1;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Ag,{className:`sr-only`,children:`Search and jump`}),(0,R.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2.5 border-b border-rule px-4`,children:[(0,R.jsx)(X,{name:`search`,size:16,className:`text-muted`}),(0,R.jsx)(`input`,{value:c,onChange:e=>{l(e.target.value),d(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),d((y+1)%Math.max(_.length,1))):e.key===`ArrowUp`?(e.preventDefault(),d((y-1+_.length)%Math.max(_.length,1))):e.key===`Enter`&&(e.preventDefault(),_[y]?.run())},placeholder:`Canvases, screens, components…`,"aria-label":`Search and jump`,role:`combobox`,"aria-expanded":`true`,"aria-controls":`palette-list`,autoComplete:`off`,spellCheck:!1,className:`h-full min-w-0 grow border-0 bg-transparent text-[15px] text-ink outline-none placeholder:text-muted`}),(0,R.jsx)(S_,{children:`esc`})]}),(0,R.jsx)(`div`,{id:`palette-list`,role:`listbox`,className:`min-h-0 grow overflow-y-auto py-1.5`,children:g.length?g.map(({group:e,items:t})=>(0,R.jsxs)(`div`,{role:`presentation`,children:[(0,R.jsx)(`div`,{className:`px-4 pt-2.5 pb-1 text-[12px] text-muted`,children:w_[e]}),t.map(e=>{b+=1;let t=b,n=t===y;return(0,R.jsxs)(`button`,{type:`button`,role:`option`,tabIndex:-1,"aria-selected":n,ref:n?e=>e?.scrollIntoView({block:`nearest`}):void 0,onMouseMove:()=>n?void 0:d(t),onClick:e.run,className:Y(`flex h-10 w-full cursor-pointer items-center gap-3 border-0 px-4 text-left text-[13.5px] text-ink`,n?`bg-soft`:`bg-transparent`),children:[(0,R.jsx)(`span`,{className:`flex w-5 shrink-0 justify-center text-ink2`,children:(0,R.jsx)(X,{name:e.icon,size:16})}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`flex shrink-0 items-center text-[12.5px] text-muted`,children:e.hint}):null]},e.id)})]},e)):(0,R.jsx)(`div`,{className:`px-6 py-10 text-center text-[13px] text-muted`,children:`Nothing matches.`})}),(0,R.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-4 border-t border-rule bg-soft px-4 text-[12px] text-muted`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(S_,{children:`↑`}),(0,R.jsx)(S_,{children:`↓`}),`move`]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(S_,{children:`↵`}),`open`]})]})]})}function D_(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=()=>t(e=>!e),n=t=>{(t.metaKey||t.ctrlKey)&&t.key.toLowerCase()===`k`&&(t.preventDefault(),e())};return window.addEventListener(`keydown`,n),window.addEventListener(`design:palette`,e),()=>{window.removeEventListener(`keydown`,n),window.removeEventListener(`design:palette`,e)}},[]),(0,R.jsx)(hg,{open:e,onOpenChange:t,children:(0,R.jsx)(ed,{children:e?(0,R.jsx)(yg,{forceMount:!0,children:(0,R.jsx)(xg,{asChild:!0,forceMount:!0,children:(0,R.jsx)(Gf.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.14},className:`fixed inset-0 z-50 flex items-start justify-center bg-overlay p-6 pt-[12vh]`,children:(0,R.jsx)(Tg,{asChild:!0,forceMount:!0,"aria-describedby":void 0,children:(0,R.jsx)(Gf.div,{initial:{opacity:0,scale:.98,y:-6},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.98,transition:{duration:.1}},transition:{type:`spring`,stiffness:560,damping:40},className:`flex max-h-[min(560px,76vh)] w-[560px] max-w-full flex-col overflow-hidden rounded-[12px] border border-rule bg-surface shadow-pop outline-none`,children:(0,R.jsx)(E_,{onClose:()=>t(!1)})})})})})}):null})})}var O_={primary:`border border-primary bg-primary text-primary-ink hover:opacity-90`,secondary:`border border-rule-strong bg-surface text-ink hover:bg-soft`,ghost:`border border-transparent bg-transparent text-ink2 hover:bg-soft2`,dashed:`border border-dashed border-rule-strong bg-transparent text-ink2 hover:bg-soft`,danger:`border border-danger bg-danger text-on-danger hover:opacity-90`},k_=(e=`secondary`,t)=>Y(`inline-flex h-ctrl shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-[6px] px-ctrl text-ctrl font-medium leading-none no-underline transition-[background-color,opacity,scale] duration-100 active:not-disabled:scale-[0.97]`,`disabled:cursor-not-allowed disabled:opacity-45 aria-disabled:cursor-not-allowed aria-disabled:opacity-45`,O_[e],t),A_=(0,v.forwardRef)(function({kind:e=`secondary`,icon:t,loading:n,disabled:r,className:i,children:a,type:o=`button`,...s},c){return(0,R.jsxs)(`button`,{ref:c,type:o,disabled:r||n,"aria-busy":n||void 0,className:k_(e,i),...s,children:[n?(0,R.jsx)(X,{name:`loader`,size:15,className:`animate-spin`}):t?(0,R.jsx)(X,{name:t,size:15}):null,a]})}),j_={ghost:`border border-transparent bg-transparent text-muted hover:bg-soft2 hover:text-ink2`,secondary:`border border-rule-strong bg-surface text-ink2 hover:bg-soft`},M_=(e=`ghost`,t)=>Y(`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] p-0 transition-[color,background-color,scale] duration-100 active:not-disabled:scale-[0.94] disabled:cursor-not-allowed disabled:opacity-45`,j_[e],t),N_=(0,v.forwardRef)(function({icon:e,label:t,kind:n=`ghost`,size:r=16,className:i,type:a=`button`,...o},s){return(0,R.jsx)(`button`,{ref:s,type:a,"aria-label":t,title:t,className:M_(n,i),...o,children:(0,R.jsx)(X,{name:e,size:r})})});function P_({to:e,kind:t=`secondary`,icon:n,className:r,children:i}){return(0,R.jsxs)(ye,{href:e,className:k_(t,r),children:[n?(0,R.jsx)(X,{name:n,size:15}):null,i]})}function F_({kind:e=`secondary`,icon:t,className:n,children:r,...i}){return(0,R.jsxs)(`a`,{className:k_(e,n),...i,children:[t?(0,R.jsx)(X,{name:t,size:15}):null,r]})}var I_={neutral:`bg-soft2 text-ink2`,action:`bg-action-soft text-action`,ok:`bg-ok-soft text-ok-text`,danger:`bg-danger-soft text-danger-text`};function L_({tone:e=`neutral`,children:t,className:n}){return(0,R.jsx)(`span`,{className:Y(`inline-flex h-[22px] shrink-0 items-center gap-1 whitespace-nowrap rounded-[6px] px-2 text-[12px] font-medium`,I_[e],n),children:t})}function R_({value:e,tone:t=`neutral`}){return(0,R.jsx)(`span`,{className:Y(`inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-[4px] px-[5px] text-[11.5px] font-semibold tabular`,t===`action`?`bg-action-soft text-action`:t===`danger`?`bg-danger-soft text-danger-text`:`bg-soft2 text-ink2`),children:e})}function z_({children:e,className:t,style:n}){return(0,R.jsx)(`section`,{className:Y(`min-w-0 shrink-0 overflow-hidden rounded-[10px] border border-rule bg-surface`,t),style:n,children:e})}function B_({title:e,count:t,sub:n,right:r,as:i=`h2`}){return(0,R.jsxs)(`div`,{className:`flex min-h-[46px] items-center justify-between gap-3 px-4`,children:[(0,R.jsxs)(i,{className:`m-0 flex min-w-0 items-center gap-2 whitespace-nowrap text-[14px] font-semibold`,children:[e,t===void 0?null:(0,R.jsx)(R_,{value:t}),n?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] font-normal text-muted`,children:n}):null]}),r?(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:r}):null]})}function V_({items:e,value:t,onChange:n,right:r}){let i=(0,v.useId)();return(0,R.jsxs)(`div`,{className:`flex h-[46px] items-center justify-between gap-3 px-4`,children:[(0,R.jsx)(`div`,{role:`tablist`,className:`flex gap-5`,children:e.map(e=>{let r=e.value===t;return(0,R.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.value),className:Y(`relative flex h-[46px] cursor-pointer items-center gap-1.5 border-0 bg-transparent px-0.5 text-[14px] transition-colors`,r?`font-semibold text-ink`:`font-medium text-ink2 hover:text-ink`),children:[e.label,e.count===void 0?null:(0,R.jsx)(R_,{value:e.count}),r?(0,R.jsx)(Gf.span,{layoutId:i,className:`absolute inset-x-0 bottom-0 h-[2px] bg-ink`,transition:{type:`spring`,stiffness:520,damping:42}}):null]},e.value)})}),r?(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:r}):null]})}function H_({align:e,children:t}){return(0,R.jsx)(`div`,{className:Y(`flex min-w-0 items-center gap-2`,e===`r`&&`justify-end text-right`,e===`c`&&`justify-center`),children:t})}function U_(e,t){return v.Children.toArray(e).map((e,n)=>(0,R.jsx)(H_,{align:t?.[n]??`l`,children:e},n))}function W_({cols:e,align:t,labels:n}){return(0,R.jsx)(`div`,{className:`grid h-8 items-center gap-x-4 border-t border-rule bg-soft px-4 text-[12.5px] text-muted`,style:{gridTemplateColumns:e},children:n.map((e,n)=>(0,R.jsx)(H_,{align:t?.[n]??`l`,children:(0,R.jsx)(`span`,{className:`whitespace-nowrap`,children:e})},n))})}var G_=(e,t,n)=>Y(`grid items-center gap-x-4 border-rule`,!e&&`border-t`,t&&`cursor-pointer transition-colors hover:bg-soft`,n);function K_({cols:e,align:t,minH:n=44,pad:r=`10px 16px`,children:i,first:a,className:o,onClick:s,title:c}){return(0,R.jsx)(`div`,{className:G_(a,!!s,o),style:{gridTemplateColumns:e,minHeight:n,padding:r},onClick:s,title:c,children:U_(i,t)})}function q_({to:e,cols:t,align:n,minH:r=44,pad:i=`10px 16px`,first:a,className:o,children:s}){return(0,R.jsx)(ye,{href:e,className:Y(G_(a,!0,o),`text-inherit no-underline`),style:{gridTemplateColumns:t,minHeight:r,padding:i},children:U_(s,n)})}function J_({label:e,children:t,labelWidth:n=180,minH:r=40,end:i=!1}){return(0,R.jsxs)(`div`,{className:`grid content-center items-baseline gap-x-4 border-t border-rule px-4 py-2`,style:{gridTemplateColumns:`min(${n}px, 42%) minmax(0, 1fr)`,minHeight:r},children:[(0,R.jsx)(`span`,{className:`text-[13px] text-muted`,children:e}),(0,R.jsx)(`div`,{className:Y(`flex min-w-0 flex-wrap items-center gap-2`,i&&`justify-end`),children:t})]})}function Y_({children:e,pad:t=`16px`,gap:n=16,top:r=!0,className:i}){return(0,R.jsx)(`div`,{className:Y(`flex flex-col`,r&&`border-t border-rule`,i),style:{padding:t,gap:n},children:e})}function X_({children:e,className:t,gap:n=20,wide:r=!1}){return(0,R.jsx)(`main`,{className:Y(`mx-auto flex w-full min-h-0 grow flex-col px-8 pt-6 pb-7 animate-[q-fade-in_160ms_ease-out] max-md:px-4 max-md:pt-4`,r?`max-w-[1440px]`:`max-w-[1200px]`,t),style:{gap:n},children:e})}function Z_({title:e,sub:t,right:n,badge:r,crumbs:i}){return(0,R.jsxs)(`div`,{className:`flex shrink-0 items-end justify-between gap-6 max-md:flex-col max-md:items-stretch max-md:gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[i?(0,R.jsx)(`div`,{className:`flex items-center gap-1.5 text-[13px] text-muted`,children:i}):null,(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`h1`,{className:`m-0 text-[22px] font-semibold tracking-[-0.01em]`,children:e}),r]}),t?(0,R.jsx)(`div`,{className:`text-[13px] [overflow-wrap:anywhere] text-muted`,children:t}):null]}),n?(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n}):null]})}function Q_({items:e,label:t}){let[n]=I();return(0,R.jsx)(`nav`,{"aria-label":t,className:`flex flex-col gap-0.5`,children:e.map(e=>{let t=n===e.to;return(0,R.jsxs)(ye,{href:e.to,"aria-current":t?`page`:void 0,className:Y(`relative flex h-8 items-center gap-2 whitespace-nowrap rounded-[6px] px-3 text-[13.5px] no-underline transition-colors focus-visible:outline-offset-[-2px]`,t?`font-medium text-ink`:`text-ink2 hover:bg-soft2`),children:[t?(0,R.jsx)(Gf.span,{layoutId:`sub-nav-active`,"aria-hidden":!0,className:`absolute inset-0 z-0 rounded-[6px] bg-soft2`,transition:{type:`spring`,stiffness:520,damping:42}}):null,(0,R.jsx)(`span`,{className:`relative z-[1] min-w-0 truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`relative z-[1] ml-auto text-[12px] font-normal text-muted`,children:e.hint}):null]},e.to)})})}function $_({children:e}){return(0,R.jsx)(`div`,{className:`px-3 pt-4 pb-1 text-[12px] text-muted`,children:e})}function ev({title:e,text:t,action:n}){return(0,R.jsxs)(z_,{className:`flex w-[480px] max-w-full flex-col items-center gap-2 px-6 py-8 text-center`,children:[(0,R.jsx)(`h1`,{className:`m-0 text-[16px] font-semibold`,children:e}),t?(0,R.jsx)(`div`,{className:`m-0 max-w-[400px] text-[14px] text-ink2`,children:t}):null,n?(0,R.jsx)(`div`,{className:`mt-3 flex flex-wrap justify-center gap-2`,children:n}):null]})}function tv(e){return(0,R.jsx)(`div`,{className:`flex min-h-[50vh] grow items-center justify-center p-6 max-md:px-4`,children:(0,R.jsx)(ev,{...e})})}function nv({error:e}){let t=!!$g().scope;return(0,R.jsx)(tv,{title:`This page failed to show`,text:(0,R.jsx)(`span`,{className:`font-mono text-[12.5px] break-words`,children:e.message.slice(0,500)}),action:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(A_,{onClick:()=>window.location.reload(),children:`Reload`}),t?null:(0,R.jsx)(P_,{to:`/`,children:`All canvases`})]})})}var rv=class extends v.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){console.error(`[design] a page failed to render`,e,t.componentStack)}componentDidUpdate(e){this.state.error&&e.at!==this.props.at&&this.setState({error:null})}render(){return this.state.error?(0,R.jsx)(nv,{error:this.state.error}):this.props.children}};function iv({children:e}){let[t]=I();return(0,R.jsx)(rv,{at:t,children:e})}var av=/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`,ov=[`top`,`right`,`bottom`,`left`],sv=Math.min,cv=Math.max,lv=Math.round,uv=Math.floor,dv=e=>({x:e,y:e}),fv={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function pv(e,t,n){return cv(e,sv(t,n))}function mv(e,t){return typeof e==`function`?e(t):e}function hv(e){return e.split(`-`)[0]}function gv(e){return e.split(`-`)[1]}function _v(e){return e===`x`?`y`:`x`}function vv(e){return e===`y`?`height`:`width`}function yv(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function bv(e){return _v(yv(e))}function xv(e,t,n){n===void 0&&(n=!1);let r=gv(e),i=bv(e),a=vv(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Av(o)),[o,Av(o)]}function Sv(e){let t=Av(e);return[Cv(e),t,Cv(t)]}function Cv(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var wv=[`left`,`right`],Tv=[`right`,`left`],Ev=[`top`,`bottom`],Dv=[`bottom`,`top`];function Ov(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Tv:wv:t?wv:Tv;case`left`:case`right`:return t?Ev:Dv;default:return[]}}function kv(e,t,n,r){let i=gv(e),a=Ov(hv(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Cv)))),a}function Av(e){let t=hv(e);return fv[t]+e.slice(t.length)}function jv(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Mv(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:jv(e)}function Nv(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Pv(e,t,n){let{reference:r,floating:i}=e,a=yv(t),o=bv(t),s=vv(o),c=hv(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=gv(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Fv(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=mv(t,e),p=Mv(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Nv(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Nv(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Iv=50,Lv=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Fv},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Pv(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Iv&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Pv(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Rv=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=mv(e,t)||{};if(l==null)return{};let d=Mv(u),f={x:n,y:r},p=bv(i),m=vv(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=sv(d[_],T),D=sv(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=pv(E,k,O),j=!c.arrow&&gv(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),zv=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=mv(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=hv(r),_=yv(o),v=hv(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Av(o)]:Sv(o)),x=p!==`none`;!d&&x&&b.push(...kv(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=xv(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===yv(t)||T.every(e=>yv(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=yv(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Bv(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Vv(e){return ov.some(t=>e[t]>=0)}var Hv=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=mv(e,t);switch(i){case`referenceHidden`:{let e=Bv(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Vv(e)}}}case`escaped`:{let e=Bv(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Vv(e)}}}default:return{}}}}},Uv=new Set([`left`,`top`]);async function Wv(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=hv(n),s=gv(n),c=yv(n)===`y`,l=Uv.has(o)?-1:1,u=a&&c?-1:1,d=mv(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Gv=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Wv(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Kv=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=mv(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=yv(i),p=_v(f),m=u[p],h=u[f],g=(e,t)=>pv(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},qv=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=mv(e,t),u={x:n,y:r},d=yv(i),f=_v(d),p=u[f],m=u[d],h=mv(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Uv.has(hv(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Jv=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=mv(e,t),c=await i.detectOverflow(t,s),l=hv(n),u=gv(n),d=yv(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=sv(p-c[m],g),y=sv(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*cv(c.left,c.right):S=p-2*cv(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Yv(){return typeof window<`u`}function Xv(e){return $v(e)?(e.nodeName||``).toLowerCase():`#document`}function Zv(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Qv(e){return(($v(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function $v(e){return Yv()?e instanceof Node||e instanceof Zv(e).Node:!1}function ey(e){return Yv()?e instanceof Element||e instanceof Zv(e).Element:!1}function ty(e){return Yv()?e instanceof HTMLElement||e instanceof Zv(e).HTMLElement:!1}function ny(e){return!Yv()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Zv(e).ShadowRoot}function ry(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=my(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function iy(e){return/^(table|td|th)$/.test(Xv(e))}function ay(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var oy=/transform|translate|scale|rotate|perspective|filter/,sy=/paint|layout|strict|content/,cy=e=>!!e&&e!==`none`,ly;function uy(e){let t=ey(e)?my(e):e;return cy(t.transform)||cy(t.translate)||cy(t.scale)||cy(t.rotate)||cy(t.perspective)||!fy()&&(cy(t.backdropFilter)||cy(t.filter))||oy.test(t.willChange||``)||sy.test(t.contain||``)}function dy(e){let t=gy(e);for(;ty(t)&&!py(t);){if(uy(t))return t;if(ay(t))return null;t=gy(t)}return null}function fy(){return ly??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ly}function py(e){return/^(html|body|#document)$/.test(Xv(e))}function my(e){return Zv(e).getComputedStyle(e)}function hy(e){return ey(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function gy(e){if(Xv(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ny(e)&&e.host||Qv(e);return ny(t)?t.host:t}function _y(e){let t=gy(e);return py(t)?(e.ownerDocument||e).body:ty(t)&&ry(t)?t:_y(t)}function vy(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=_y(e),i=r===e.ownerDocument?.body,a=Zv(r);if(i){let e=yy(a);return t.concat(a,a.visualViewport||[],ry(r)?r:[],e&&n?vy(e):[])}return t.concat(r,vy(r,[],n))}function yy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function by(e){let t=my(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ty(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=lv(n)!==a||lv(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function xy(e){return ey(e)?e:e.contextElement}function Sy(e){let t=xy(e);if(!ty(t))return dv(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=by(t),o=(a?lv(n.width):n.width)/r,s=(a?lv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Cy=dv(0);function wy(e){let t=Zv(e);return!fy()||!t.visualViewport?Cy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ty(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Zv(e)}function Ey(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=xy(e),o=dv(1);t&&(r?ey(r)&&(o=Sy(r)):o=Sy(e));let s=Ty(a,n,r)?wy(a):dv(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Zv(a),t=ey(r)?Zv(r):r,n=e,i=yy(n);for(;i&&t!==n;){let e=Sy(i),t=i.getBoundingClientRect(),r=my(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Zv(i),i=yy(n)}}return Nv({width:u,height:d,x:c,y:l})}function Dy(e,t){let n=hy(e).scrollLeft;return t?t.left+n:Ey(Qv(e)).left+n}function Oy(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Dy(e,n),y:n.top+t.scrollTop}}function ky(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Qv(r),s=t?ay(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=dv(1),u=dv(0),d=ty(r);if((d||!a)&&((Xv(r)!==`body`||ry(o))&&(c=hy(r)),d)){let e=Ey(r);l=Sy(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Oy(o,c):dv(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ay(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function jy(e){let t=hy(e),n=e.ownerDocument.body,r=cv(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=cv(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Dy(e),o=-t.scrollTop;return my(n).direction===`rtl`&&(a+=cv(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var My=25;function Ny(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Zv(e),a=Qv(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!fy()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Dy(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=My&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Py(e,t){let n=Ey(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Sy(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Fy(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ny(e,n,t);else if(t===`document`)r=jy(Qv(e));else if(ey(t))r=Py(t,n);else{let n=wy(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Nv(r)}function Iy(e,t){let n=t.get(e);if(n)return n;let r=vy(e,[],!1).filter(e=>ey(e)&&Xv(e)!==`body`),i=null,a=my(e).position===`fixed`,o=a?gy(e):e;for(;ey(o)&&!py(o);){let e=my(o),t=uy(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=gy(o)}return t.set(e,r),r}function Ly(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?ay(t)?[]:Iy(t,this._c):[].concat(n),r],o=Fy(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Fy(t,a[e],i);s=cv(n.top,s),c=sv(n.right,c),l=sv(n.bottom,l),u=cv(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ry(e){let{width:t,height:n}=by(e);return{width:t,height:n}}function zy(e,t,n){let r=ty(t),i=Qv(t),a=n===`fixed`,o=Ey(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=dv(0);if((r||!a)&&((Xv(t)!==`body`||ry(i))&&(s=hy(t)),r)){let e=Ey(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Dy(i));let l=i&&!r&&!a?Oy(i,s):dv(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function By(e){return my(e).position===`static`}function Vy(e,t){if(!ty(e)||my(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Qv(e)===n&&(n=n.ownerDocument.body),n}function Hy(e,t){let n=Zv(e);if(ay(e))return n;if(!ty(e)){let t=gy(e);for(;t&&!py(t);){if(ey(t)&&!By(t))return t;t=gy(t)}return n}let r=Vy(e,t);for(;r&&iy(r)&&By(r);)r=Vy(r,t);return r&&py(r)&&By(r)&&!uy(r)?n:r||dy(e)||n}var Uy=async function(e){let t=this.getOffsetParent||Hy,n=this.getDimensions,r=await n(e.floating);return{reference:zy(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Wy(e){return my(e).direction===`rtl`}var Gy={convertOffsetParentRelativeRectToViewportRelativeRect:ky,getDocumentElement:Qv,getClippingRect:Ly,getOffsetParent:Hy,getElementRects:Uy,getClientRects:Ay,getDimensions:Ry,getScale:Sy,isElement:ey,isRTL:Wy};function Ky(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qy(e,t,n){let r=null,i,a=Qv(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=uv(d),h=uv(a.clientWidth-(u+f)),g=uv(a.clientHeight-(d+p)),_=uv(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:cv(0,sv(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Ky(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Zv(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Jy(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=xy(e),u=i||a?[...l?vy(l):[],...t?vy(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?qy(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Ey(e):null;c&&g();function g(){let t=Ey(e);h&&!Ky(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Yy=Gv,Xy=Kv,Zy=zv,Qy=Jv,$y=Hv,eb=Rv,tb=qv,nb=(e,t,n)=>{let r=new Map,i=n??{},a={...Gy,...i.platform,_c:r};return Lv(e,t,{...i,platform:a})},rb=typeof document<`u`?v.useLayoutEffect:function(){};function ib(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ib(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ib(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ab(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function ob(e,t){let n=ab(e);return Math.round(t*n)/n}function sb(e){let t=v.useRef(e);return rb(()=>{t.current=e}),t}function cb(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=v.useState(r);ib(f,r)||p(r);let[m,h]=v.useState(null),[g,_]=v.useState(null),y=v.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=v.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=v.useRef(null),w=v.useRef(null),T=v.useRef(u),E=c!=null,D=sb(c),O=sb(i),k=sb(l),A=v.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),nb(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!ib(T.current,t)&&(T.current=t,Dp.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);rb(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=v.useRef(!1);rb(()=>(j.current=!0,()=>{j.current=!1}),[]),rb(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=v.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),ee=v.useMemo(()=>({reference:x,floating:S}),[x,S]),N=v.useMemo(()=>{let e={position:n,left:0,top:0};if(!ee.floating)return e;let t=ob(ee.floating,u.x),r=ob(ee.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ab(ee.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,ee.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:A,refs:M,elements:ee,floatingStyles:N}),[u,A,M,ee,N])}var lb=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:eb({element:r.current,padding:i}).fn(n):r?eb({element:r,padding:i}).fn(n):{}}}},ub=(e,t)=>{let n=Yy(e);return{name:n.name,fn:n.fn,options:[e,t]}},db=(e,t)=>{let n=Xy(e);return{name:n.name,fn:n.fn,options:[e,t]}},fb=(e,t)=>({fn:tb(e).fn,options:[e,t]}),pb=(e,t)=>{let n=Zy(e);return{name:n.name,fn:n.fn,options:[e,t]}},mb=(e,t)=>{let n=Qy(e);return{name:n.name,fn:n.fn,options:[e,t]}},hb=(e,t)=>{let n=$y(e);return{name:n.name,fn:n.fn,options:[e,t]}},gb=(e,t)=>{let n=lb(e);return{name:n.name,fn:n.fn,options:[e,t]}},_b=Object.defineProperty,vb=(e,t)=>_b(e,`name`,{value:t,configurable:!0});function yb(e){let[t,n]=v.useState(void 0);return cp(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}vb(yb,`useSize`);var bb=Object.defineProperty,xb=(e,t)=>bb(e,`name`,{value:t,configurable:!0}),Sb=`Popper`,[Cb,wb]=op(Sb),[Tb,Eb]=Cb(Sb),Db=xb(e=>{let{__scopePopper:t,children:n}=e,[r,i]=v.useState(null),[a,o]=v.useState(void 0);return(0,R.jsx)(Tb,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Ob=`PopperAnchor`,kb=v.forwardRef(xb(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Eb(Ob,n),o=v.useRef(null),s=a.onAnchorChange,c=np(t,v.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=v.useRef(null);v.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Ib(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,R.jsx)(Gp.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),Ab=`PopperContent`,[jb,Mb]=Cb(Ab),Nb=v.forwardRef(xb(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=Eb(Ab,n),[_,y]=v.useState(null),b=np(t,y),[x,S]=v.useState(null),C=yb(x),w=C?.width??0,T=C?.height??0,E=r+(a===`center`?``:`-`+a),D=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:D,boundary:O.filter(Pb),altBoundary:k},{refs:j,floatingStyles:M,placement:ee,isPositioned:N,middlewareData:P}=cb({strategy:`fixed`,placement:E,whileElementsMounted:xb((...e)=>Jy(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[ub({mainAxis:i+T,alignmentAxis:o}),c&&db({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?fb():void 0,...A}),c&&pb({...A}),mb({...A,apply:xb(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),x&&gb({element:x,padding:s}),Fb({arrowWidth:w,arrowHeight:T}),f&&hb({strategy:`referenceHidden`,...A,boundary:k?A.boundary:void 0})]}),te=g.setPlacementState;cp(()=>(te(ee),()=>{te(void 0)}),[ee,te]);let[ne,F]=Ib(ee),re=Yp(m);cp(()=>{N&&re?.()},[N,re]);let ie=P.arrow?.x,ae=P.arrow?.y,oe=P.arrow?.centerOffset!==0,[se,ce]=v.useState();return cp(()=>{_&&ce(window.getComputedStyle(_).zIndex)},[_]),(0,R.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:N?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,R.jsx)(jb,{scope:n,placedSide:ne,placedAlign:F,onArrowChange:S,arrowX:ie,arrowY:ae,shouldHideArrow:oe,children:(0,R.jsx)(Gp.div,{"data-side":ne,"data-align":F,...h,ref:b,style:{...h.style,animation:N?h.style?.animation:`none`}})})})},`PopperContent`));function Pb(e){return e!==null}xb(Pb,`isNotNull`);var Fb=xb(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Ib(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Ib(e){let[t,n=`center`]=e.split(`-`);return[t,n]}xb(Ib,`getSideAndAlignFromPlacement`);var Lb=Db,Rb=kb,zb=Nb,Bb=Object.defineProperty,Vb=(e,t)=>Bb(e,`name`,{value:t,configurable:!0}),Hb=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`}),Ub=v.forwardRef(Vb(function(e,t){return(0,R.jsx)(Gp.span,{...e,ref:t,style:{...Hb,...e.style}})},`VisuallyHidden`)),Wb=Object.defineProperty,Gb=(e,t)=>Wb(e,`name`,{value:t,configurable:!0}),[Kb,qb]=op(`Tooltip`,[wb]),Jb=wb(),Yb=`TooltipProvider`,Xb=700,Zb=`tooltip.open`,[Qb,$b]=Kb(Yb),ex=Gb(e=>{let{__scopeTooltip:t,delayDuration:n=Xb,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=v.useRef(!0),s=v.useRef(!1),c=v.useRef(0);return v.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(Qb,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:v.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:v.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:v.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),tx=`Tooltip`,[nx,rx]=Kb(tx),ix=Gb(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=$b(tx,e.__scopeTooltip),l=Jb(t),[u,d]=v.useState(null),[f,p]=v.useState(void 0),m=pp(),h=v.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,y=v.useRef(!1),[b,x]=Sp({prop:r,defaultProp:i??!1,onChange:Gb(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Zb))):c.onClose(),a?.(e)},`onChange`),caller:tx}),S=v.useMemo(()=>b?y.current?`delayed-open`:`instant-open`:`closed`,[b]),C=v.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,x(!0)},[x]),w=v.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x(!1)},[x]),T=v.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,x(!0),h.current=0},_)},[_,x]);v.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let E=f??m;return(0,R.jsx)(Lb,{...l,children:(0,R.jsx)(nx,{scope:t,contentId:E,setContentId:p,open:b,stateAttribute:S,trigger:u,onTriggerChange:d,onTriggerEnter:v.useCallback(()=>{c.isOpenDelayedRef.current?T():C()},[c.isOpenDelayedRef,T,C]),onTriggerLeave:v.useCallback(()=>{g?w():(window.clearTimeout(h.current),h.current=0)},[w,g]),onOpen:C,onClose:w,disableHoverableContent:g,children:n})})},`Tooltip`),ax=`TooltipTrigger`,ox=v.forwardRef(Gb(function(e,t){let{__scopeTooltip:n,...r}=e,i=rx(ax,n),a=$b(ax,n),o=Jb(n),s=np(t,v.useRef(null),i.onTriggerChange),c=v.useRef(!1),l=v.useRef(!1),u=v.useCallback(()=>c.current=!1,[]);return v.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,R.jsx)(Rb,{asChild:!0,...o,children:(0,R.jsx)(Gp.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:J(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:J(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:J(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:J(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:J(e.onBlur,i.onClose),onClick:J(e.onClick,i.onClose)})})},`TooltipTrigger`)),sx=`TooltipPortal`,[cx,lx]=Kb(sx,{forceMount:void 0}),ux=Gb(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=rx(sx,t);return(0,R.jsx)(cx,{scope:t,forceMount:n,children:(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),dx=`TooltipContent`,fx=v.forwardRef(Gb(function(e,t){let n=lx(dx,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=rx(dx,e.__scopeTooltip);return(0,R.jsx)(Mm,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(hx,{side:i,...a,ref:t}):(0,R.jsx)(px,{side:i,...a,ref:t})})},`TooltipContent`)),px=v.forwardRef(Gb(function(e,t){let n=rx(dx,e.__scopeTooltip),r=$b(dx,e.__scopeTooltip),i=v.useRef(null),a=np(t,i),[o,s]=v.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=v.useCallback(()=>{s(null),d(!1)},[d]),p=v.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=_x(r,gx(r,n.getBoundingClientRect())),a=vx(t.getBoundingClientRect()),o=bx([...i,...a]);s(o),d(!0)},[d]);return v.useEffect(()=>()=>f(),[f]),v.useEffect(()=>{if(c&&u){let e=Gb(e=>p(e,u),`handleTriggerLeave`),t=Gb(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),v.useEffect(()=>{if(o){let e=Gb(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!yx(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(hx,{...e,ref:a})},`TooltipContentHoverable`)),mx=Mp(`TooltipContent`),hx=v.forwardRef(Gb(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=rx(dx,n),u=Jb(n),{onClose:d}=l;v.useEffect(()=>(document.addEventListener(Zb,d),()=>document.removeEventListener(Zb,d)),[d]),v.useEffect(()=>{if(l.trigger){let e=Gb(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return cp(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,R.jsx)(rm,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,R.jsxs)(zb,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,R.jsx)(mx,{children:r}),i?(0,R.jsx)(Ub,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`));function gx(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Gb(gx,`getExitSideFromRect`);function _x(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Gb(_x,`getPaddedExitPoints`);function vx(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Gb(vx,`getPointsFromRect`);function yx(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Gb(yx,`isPointInPolygon`);function bx(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),xx(t)}Gb(bx,`getHull`);function xx(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Gb(xx,`getHullPresorted`);var Sx=ex,Cx=ix,wx=ox,Tx=ux,Ex=fx;function Dx({children:e}){return(0,R.jsx)(Sx,{delayDuration:250,children:e})}var Ox=`z-50 max-w-[280px] rounded-[8px] border border-rule bg-surface px-[10px] py-[7px] text-[12.5px] leading-[1.35] text-ink shadow-pop outline-none data-[state=delayed-open]:animate-[q-pop_120ms_ease-out] data-[state=closed]:animate-[q-pop-out_100ms_ease-in_forwards]`;function kx({content:e,children:t,side:n=`top`,align:r=`center`,className:i}){return(0,R.jsxs)(Cx,{children:[(0,R.jsx)(wx,{asChild:!0,children:t}),(0,R.jsx)(Tx,{children:(0,R.jsx)(Ex,{side:n,align:r,sideOffset:6,collisionPadding:12,className:Y(Ox,i),children:e})})]})}function Ax(){window.dispatchEvent(new CustomEvent(`design:palette`))}var jx=av===`⌘`?`⌘K`:`Ctrl K`;function Mx({width:e=240,label:t=`Search and jump`,compact:n}){if(n)return(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t,` `,(0,R.jsx)(S_,{children:jx})]}),children:(0,R.jsx)(`button`,{type:`button`,onClick:Ax,"aria-label":t,className:`inline-flex h-ctrl w-ctrl shrink-0 cursor-pointer items-center justify-center rounded-[6px] border border-rule bg-soft text-muted transition-colors hover:border-rule-strong`,children:(0,R.jsx)(X,{name:`search`,size:15})})});let r=n===!1;return(0,R.jsxs)(`button`,{type:`button`,onClick:Ax,style:{width:e},"aria-label":t,className:Y(`flex h-ctrl min-w-0 cursor-pointer items-center gap-2 rounded-[6px] border border-rule bg-soft pr-1.5 pl-3 text-ctrl text-muted transition-colors hover:border-rule-strong`,r?`shrink-0`:`shrink max-lg:w-auto! max-md:w-ctrl! max-md:justify-center max-md:border-0! max-md:bg-transparent! max-md:p-0!`),children:[(0,R.jsx)(X,{name:`search`,size:15}),(0,R.jsx)(`span`,{className:Y(`min-w-0 grow truncate text-left`,!r&&`max-lg:hidden`),children:t}),(0,R.jsx)(`span`,{className:Y(`flex`,!r&&`max-md:hidden`),children:(0,R.jsx)(S_,{children:jx})})]})}var Nx=Object.defineProperty,Px=(e,t)=>Nx(e,`name`,{value:t,configurable:!0});function Fx(e){let t=e+`CollectionProvider`,[n,r]=op(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Px(e=>{let{scope:t,children:n}=e,r=v.useRef(null),a=v.useRef(new Map).current;return(0,R.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=Ap(s),l=v.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=np(t,a(s,n).collectionRef);return(0,R.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Ap(u),p=v.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=v.useRef(null),s=np(t,o),c=a(u,n);return v.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,R.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return v.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 Px(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}Px(Fx,`createCollection`);var Ix=new WeakMap,Lx=class e extends Map{static{Px(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Ix.set(this,!0)}set(e,t){return Ix.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=Bx(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=Rx(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Rx(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Rx(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 Rx(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=zx(e,t);return n===-1?void 0:e[n]}Px(Rx,`at`);function zx(e,t){let n=e.length,r=Bx(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Px(zx,`toSafeIndex`);function Bx(e){return e!==e||e===0?0:Math.trunc(e)}Px(Bx,`toSafeInteger`);function Vx(e){let t=e+`CollectionProvider`,[n,r]=op(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Lx,setItemMap:Px(()=>void 0,`setItemMap`)}),o=Px(({state:e,...t})=>e?(0,R.jsx)(c,{...t,state:e}):(0,R.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=Px(e=>{let t=h();return(0,R.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=Px(e=>{let{scope:t,children:n,state:r}=e,a=v.useRef(null),[o,s]=v.useState(null),c=np(a,s),[l,u]=r;return v.useEffect(()=>{if(!o)return;let e=Gx(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,R.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=Ap(l),d=v.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=np(t,a(l,n).collectionRef);return(0,R.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=Ap(f),m=v.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=v.useRef(null),[s,c]=v.useState(null),l=np(t,o,c),{setItemMap:u}=a(f,n),d=v.useRef(i);Hx(d.current,i)||(d.current=i);let m=d.current;return v.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Wx):(t.set(s,{...e,element:s}),t.toSorted(Wx)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Lx(e)))}},[s,m,u]),(0,R.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return v.useState(new Lx)}Px(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Px(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}Px(Vx,`createCollection`);function Hx(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}Px(Hx,`shallowEqual`);function Ux(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Px(Ux,`isElementPreceding`);function Wx(e,t){return!e[1].element||!t[1].element?0:Ux(e[1].element,t[1].element)?-1:1}Px(Wx,`sortByDocumentPosition`);function Gx(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Px(Gx,`getChildListObserver`);var Kx=Object.defineProperty,qx=(e,t)=>Kx(e,`name`,{value:t,configurable:!0}),Jx=v.createContext(void 0);function Yx(e){let t=v.useContext(Jx);return e||t||`ltr`}qx(Yx,`useDirection`);var Xx=Object.defineProperty,Zx=(e,t)=>Xx(e,`name`,{value:t,configurable:!0}),Qx=!1;function $x(){let[e,t]=v.useState(Qx);return v.useEffect(()=>{Qx||(Qx=!0,t(!0))},[]),e}Zx($x,`useIsHydrated`);var eS=v.useSyncExternalStore;function tS(){return()=>{}}Zx(tS,`subscribe`);function nS(){return eS(tS,()=>!0,()=>!1)}Zx(nS,`useIsHydratedModern`);var rS=typeof eS==`function`?nS:$x,iS=Object.defineProperty,aS=(e,t)=>iS(e,`name`,{value:t,configurable:!0}),oS=`rovingFocusGroup.onEntryFocus`,sS={bubbles:!1,cancelable:!0},cS=`RovingFocusGroup`,[lS,uS,dS]=Fx(cS),[fS,pS]=op(cS,[dS]),[mS,hS]=fS(cS),gS=v.forwardRef(aS(function(e,t){return(0,R.jsx)(lS.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(lS.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(_S,{...e,ref:t})})})},`RovingFocusGroup`)),_S=v.forwardRef(aS(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=v.useRef(null),p=np(t,f),m=Yx(a),[h,g]=Sp({prop:o,defaultProp:s??null,onChange:c,caller:cS}),[_,y]=v.useState(!1),b=Yp(l),x=uS(n),S=v.useRef(!1),[C,w]=v.useState(0);return v.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(oS,b),()=>e.removeEventListener(oS,b)},[b]),(0,R.jsx)(mS,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:v.useCallback(e=>g(e),[g]),onItemShiftTab:v.useCallback(()=>y(!0),[]),onFocusableItemAdd:v.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:v.useCallback(()=>w(e=>e-1),[]),children:(0,R.jsx)(Gp.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:J(e.onMouseDown,()=>{S.current=!0}),onFocus:J(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(oS,sS);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);CS([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:J(e.onBlur,()=>y(!1))})})},`RovingFocusGroupImpl`)),vS=`RovingFocusGroupItem`,yS=v.forwardRef(aS(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=pp(),l=a||c,u=hS(vS,n),d=u.currentTabStopId===l,f=uS(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=rS();return cp(()=>{if(g&&r)return p(),()=>m()},[g,r,p,m]),v.useEffect(()=>{if(!g&&r)return p(),()=>m()},[g,r,p,m]),(0,R.jsx)(lS.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(Gp.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:J(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:J(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:J(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=SS(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?wS(n,r+1):n.slice(r+1)}setTimeout(()=>CS(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),bS={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function xS(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}aS(xS,`getDirectionAwareKey`);function SS(e,t,n){let r=xS(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return bS[r]}aS(SS,`getFocusIntent`);function CS(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}aS(CS,`focusFirst`);function wS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}aS(wS,`wrapArray`);var TS=gS,ES=yS,DS=Object.defineProperty,OS=(e,t)=>DS(e,`name`,{value:t,configurable:!0}),kS=[`Enter`,` `],AS=[`ArrowDown`,`PageUp`,`Home`],jS=[`ArrowUp`,`PageDown`,`End`],MS=[...AS,...jS];[...kS],[...kS];var NS=`Menu`,[PS,FS,IS]=Fx(NS),[LS,RS]=op(NS,[IS,wb,pS]),zS=wb(),BS=pS(),[VS,HS]=LS(NS),[US,WS]=LS(NS),GS=OS(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=zS(t),[c,l]=v.useState(null),u=v.useRef(!1),d=Yp(a),f=Yx(i);return v.useEffect(()=>{let e=OS(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=OS(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),v.useEffect(()=>{if(!n)return;let e=OS(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,R.jsx)(Lb,{...s,children:(0,R.jsx)(VS,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(US,{scope:t,onClose:v.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),KS=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,...r}=e,i=zS(n);return(0,R.jsx)(Rb,{...i,...r,ref:t})},`MenuAnchor`)),qS=`MenuPortal`,[JS,YS]=LS(qS,{forceMount:void 0}),XS=OS(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=HS(qS,t);return(0,R.jsx)(JS,{scope:t,forceMount:n,children:(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:r})})})},`MenuPortal`),ZS=`MenuContent`,[QS,$S]=LS(ZS),eC=v.forwardRef(OS(function(e,t){let n=YS(ZS,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=HS(ZS,e.__scopeMenu),o=WS(ZS,e.__scopeMenu);return(0,R.jsx)(PS.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(Mm,{present:r||a.open,children:(0,R.jsx)(PS.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(tC,{...i,ref:t}):(0,R.jsx)(nC,{...i,ref:t})})})})},`MenuContent`)),tC=v.forwardRef(OS(function(e,t){let n=HS(ZS,e.__scopeMenu),r=v.useRef(null),i=np(t,r);return v.useEffect(()=>{let e=r.current;if(e)return sg(e)},[]),(0,R.jsx)(iC,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),nC=v.forwardRef(OS(function(e,t){let n=HS(ZS,e.__scopeMenu);return(0,R.jsx)(iC,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),rC=Ap(`MenuContent.ScrollLock`),iC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=HS(ZS,n),_=WS(ZS,n),y=zS(n),b=BS(n),x=FS(n),[S,C]=v.useState(null),w=v.useRef(null),T=np(t,w,g.onContentChange),E=v.useRef(0),D=v.useRef(``),O=v.useRef(0),k=v.useRef(null),A=v.useRef(`right`),j=v.useRef(0),M=m?Qh:v.Fragment,ee=m?{as:rC,allowPinchZoom:!0}:void 0,N=OS(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=SC(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;OS((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);v.useEffect(()=>()=>window.clearTimeout(E.current),[]),Um();let P=v.useCallback(e=>A.current===k.current?.side&&wC(e,k.current?.area),[]);return(0,R.jsx)(QS,{scope:n,searchRef:D,onItemEnter:v.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:v.useCallback(e=>{P(e)||(w.current?.focus(),C(null))},[P]),onTriggerLeave:v.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:O,onPointerGraceIntentChange:v.useCallback(e=>{k.current=e},[]),children:(0,R.jsx)(M,{...ee,children:(0,R.jsx)(hm,{asChild:!0,trapped:i,onMountAutoFocus:J(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(rm,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(TS,{asChild:!0,...b,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:J(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(zb,{role:`menu`,"aria-orientation":`vertical`,"data-state":_C(g.open),"data-radix-menu-content":``,dir:_.dir,...y,...h,ref:T,style:{outline:`none`,...h.style},onKeyDown:J(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=w.current;if(e.target!==i||!MS.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);jS.includes(e.key)&&a.reverse(),bC(a)}),onBlur:J(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:J(e.onPointerMove,TC(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),aC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(Gp.div,{...r,ref:t})},`MenuLabel`)),oC=`MenuItem`,sC=`menu.itemSelect`,cC=v.forwardRef(OS(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=v.useRef(null),o=WS(oC,e.__scopeMenu),s=$S(oC,e.__scopeMenu),c=np(t,a),l=v.useRef(!1),u=OS(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(sC,{bubbles:!0,cancelable:!0});e.addEventListener(sC,e=>r?.(e),{once:!0}),Kp(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,R.jsx)(lC,{...i,ref:c,disabled:n,onClick:J(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:J(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:J(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&kS.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),lC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=$S(oC,n),s=BS(n),c=v.useRef(null),l=np(t,c),[u,d]=v.useState(!1),[f,p]=v.useState(``);return v.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(PS.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(ES,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(Gp.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:J(e.onPointerMove,TC(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:J(e.onPointerLeave,TC(e=>o.onItemLeave(e))),onFocus:J(e.onFocus,()=>d(!0)),onBlur:J(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[uC,dC]=LS(`MenuRadioGroup`,{value:void 0,onValueChange:OS(()=>{},`onValueChange`)}),[fC,pC]=LS(`MenuItemIndicator`,{checked:!1}),mC=v.forwardRef(OS(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(Gp.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[hC,gC]=LS(`MenuSub`);function _C(e){return e?`open`:`closed`}OS(_C,`getOpenState`);function vC(e){return e===`indeterminate`}OS(vC,`isIndeterminate`);function yC(e){return vC(e)?`indeterminate`:e?`checked`:`unchecked`}OS(yC,`getCheckedState`);function bC(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}OS(bC,`focusFirst`);function xC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}OS(xC,`wrapArray`);function SC(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=xC(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}OS(SC,`getNextMatch`);function CC(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}OS(CC,`isPointInPolygon`);function wC(e,t){return t?CC({x:e.clientX,y:e.clientY},t):!1}OS(wC,`isPointerInGraceArea`);function TC(e){return t=>t.pointerType===`mouse`?e(t):void 0}OS(TC,`whenMouse`);var EC=GS,DC=KS,OC=XS,kC=eC,AC=aC,jC=cC,MC=mC,NC=Object.defineProperty,PC=(e,t)=>NC(e,`name`,{value:t,configurable:!0}),FC=`DropdownMenu`,[IC,LC]=op(FC,[RS]),RC=RS(),[zC,BC]=IC(FC),VC=PC(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=RC(t),l=v.useRef(null),[u,d]=Sp({prop:i,defaultProp:a??!1,onChange:o,caller:FC});return(0,R.jsx)(zC,{scope:t,triggerId:pp(),triggerRef:l,contentId:pp(),open:u,onOpenChange:d,onOpenToggle:v.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(EC,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),HC=`DropdownMenuTrigger`,UC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=BC(HC,n),o=RC(n),s=np(t,a.triggerRef);return(0,R.jsx)(DC,{asChild:!0,...o,children:(0,R.jsx)(Gp.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:J(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:J(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),WC=PC(e=>{let{__scopeDropdownMenu:t,...n}=e,r=RC(t);return(0,R.jsx)(OC,{...r,...n})},`DropdownMenuPortal`),GC=`DropdownMenuContent`,KC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=BC(GC,n),a=RC(n),o=v.useRef(!1);return(0,R.jsx)(kC,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:J(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),qC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=RC(n);return(0,R.jsx)(AC,{...i,...r,ref:t})},`DropdownMenuLabel`)),JC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=RC(n);return(0,R.jsx)(jC,{...i,...r,ref:t})},`DropdownMenuItem`)),YC=v.forwardRef(PC(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=RC(n);return(0,R.jsx)(MC,{...i,...r,ref:t})},`DropdownMenuSeparator`)),XC=VC,ZC=UC,QC=WC,$C=KC,ew=qC,tw=JC,nw=YC,rw=`z-50 overflow-hidden rounded-[8px] border border-rule bg-surface shadow-pop outline-none py-1 data-[state=open]:animate-[q-pop_120ms_ease-out] data-[state=closed]:animate-[q-pop-out_100ms_ease-in_forwards]`,iw=null;typeof document<`u`&&document.addEventListener(`pointerover`,e=>iw=e.target,{capture:!0,passive:!0});function aw(){let e=document.activeElement;return e instanceof HTMLIFrameElement&&iw!==e}function ow({trigger:e,children:t,width:n=220,align:r=`start`,side:i=`bottom`,sideOffset:a=6,open:o,onOpenChange:s}){let[c,l]=(0,v.useState)(!1);return(0,R.jsxs)(XC,{open:o??c,onOpenChange:e=>{(e||!aw())&&(l(e),s?.(e))},modal:!1,children:[(0,R.jsx)(ZC,{asChild:!0,children:e}),(0,R.jsx)(QC,{children:(0,R.jsx)($C,{align:r,side:i,sideOffset:a,collisionPadding:12,onFocusOutside:sw,className:rw,style:{width:n,maxWidth:`calc(100vw - 24px)`},children:t})})]})}function sw(e){aw()&&e.preventDefault()}var cw=(e,t)=>Y(`flex min-h-9 w-full cursor-pointer items-center gap-2.5 border-0 px-3 py-1.5 text-left text-[13.5px] outline-none select-none`,`data-[highlighted]:bg-soft data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,t?`bg-soft`:`bg-transparent`,e?`text-danger-text`:`text-ink`);function lw({children:e,onSelect:t,danger:n,active:r,disabled:i,hint:a,className:o}){return(0,R.jsxs)(tw,{disabled:i,onSelect:t,className:Y(cw(n,r),o),children:[e,a?(0,R.jsx)(`span`,{className:`ml-auto pl-3 text-[12px] text-muted`,children:a}):null]})}function uw(){return(0,R.jsx)(nw,{className:`my-1 h-px bg-rule`})}function dw({children:e}){return(0,R.jsx)(ew,{className:`px-3 pt-1.5 pb-1 text-[12px] text-muted`,children:e})}var fw=[{value:`system`,label:`System`,icon:`monitor`},{value:`light`,label:`Light`,icon:`sun`},{value:`dark`,label:`Dark`,icon:`moon`}];function pw(){let e=y_(),t=b_();return(0,R.jsxs)(ow,{align:`end`,width:180,trigger:(0,R.jsx)(N_,{icon:t===`dark`?`moon`:`sun`,label:`Appearance`}),children:[(0,R.jsx)(dw,{children:`Appearance`}),fw.map(t=>(0,R.jsxs)(lw,{active:e===t.value,onSelect:()=>v_(t.value),children:[(0,R.jsx)(X,{name:t.icon,size:15,className:`text-ink2`}),t.label,e===t.value?(0,R.jsx)(X,{name:`check`,size:15,className:`ml-auto text-ink2`}):null]},t.value))]})}function mw({size:e=24}){return(0,R.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 32 32`,"aria-hidden":`true`,className:`shrink-0`,children:[(0,R.jsx)(`rect`,{width:`32`,height:`32`,rx:`7`,className:`fill-primary`}),(0,R.jsx)(`rect`,{x:`7`,y:`7`,width:`8`,height:`11`,rx:`1.5`,className:`fill-primary-ink`}),(0,R.jsx)(`rect`,{x:`17`,y:`7`,width:`8`,height:`6`,rx:`1.5`,fill:`#f0a040`}),(0,R.jsx)(`rect`,{x:`17`,y:`15`,width:`8`,height:`10`,rx:`1.5`,className:`fill-primary-ink`}),(0,R.jsx)(`rect`,{x:`7`,y:`20`,width:`8`,height:`5`,rx:`1.5`,className:`fill-primary-ink`})]})}function hw({name:e,version:t}){return(0,R.jsxs)(ye,{href:`/`,title:t?`foss-design ${t}`:void 0,className:`flex min-w-0 items-center gap-2 text-[14px] font-semibold text-ink no-underline`,children:[(0,R.jsx)(mw,{}),(0,R.jsx)(`span`,{className:`truncate`,children:e??`Design`})]})}function gw({children:e,className:t}){return(0,R.jsx)(`header`,{className:Y(`sticky top-0 z-30 flex h-[52px] shrink-0 items-center gap-3 border-b border-rule bg-surface px-4`,t),children:e})}var _w=(0,v.createContext)(!1).Provider;function vw(e,t,n){let[r,i]=(0,v.useState)(!1),a=(0,v.useRef)(0);return(0,v.useLayoutEffect)(()=>{let n=e.current,r=t.current;if(!n||!r)return;let o=()=>{let e=[...n.querySelectorAll(`[data-fit]`)].reduce((e,t)=>e+Math.max(0,t.scrollWidth-t.clientWidth),0),t=r.getBoundingClientRect().left-n.getBoundingClientRect().right;i(n=>n?t-e<a.current-r.offsetWidth+16:(a.current=r.offsetWidth,e>0))};o();let s=new ResizeObserver(o);return s.observe(n.parentElement??n),s.observe(r),()=>s.disconnect()},n),r}var yw=[{to:`/`,label:`Canvases`,match:e=>e===`/`||e.startsWith(`/c/`)},{to:`/system`,label:`Design system`,match:e=>e.startsWith(`/system`)}];function bw({location:e}){let t=(0,v.useRef)(null),n=yw.findIndex(t=>t.match(e)),[r,i]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let e=t.current;if(!e)return;let r=()=>{let t=e.children[n];if(!t?.offsetWidth){i(null);return}let r=t.offsetLeft+10,a=t.offsetWidth-20;i(e=>e?.tab===n&&e.x===r&&e.width===a?e:{tab:n,x:r,width:a,slide:e!==null&&e.tab!==n})};r();let a=new ResizeObserver(r);return a.observe(e),()=>a.disconnect()},[n]),(0,R.jsxs)(`nav`,{ref:t,className:`relative flex h-[52px] items-stretch gap-0.5 max-md:hidden`,children:[yw.map((e,t)=>(0,R.jsx)(ye,{href:e.to,"aria-current":t===n?`page`:void 0,className:Y(`flex items-center px-2.5 text-[14px] no-underline transition-colors`,t===n?`font-medium text-ink`:`text-ink2 hover:text-ink`),children:e.label},e.to)),r?(0,R.jsx)(Gf.span,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 h-[2px] bg-action`,initial:!1,animate:{x:r.x,width:r.width},transition:r.slide?{type:`spring`,stiffness:520,damping:42}:{duration:0}}):null]})}function xw(){let e=n_().data,{slots:t}=$g(),[n]=I();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(gw,{children:[t.barStart,(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-6`,children:[t.brand??(0,R.jsx)(hw,{name:e?.name,version:e?.version}),(0,R.jsx)(bw,{location:n})]}),(0,R.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,R.jsx)(Mx,{}),(0,R.jsx)(`span`,{className:Y(`flex`,t.barEnd?`max-md:hidden`:void 0),children:(0,R.jsx)(pw,{})}),t.barEnd]})]}),(0,R.jsx)(Sw,{location:n}),t.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:t.belowBar}):null]})}function Sw({location:e}){return(0,R.jsx)(`nav`,{className:`sticky top-[52px] z-30 hidden h-10 shrink-0 items-stretch border-b border-rule bg-surface px-2 max-md:flex`,children:yw.map(t=>{let n=t.match(e);return(0,R.jsxs)(ye,{href:t.to,"aria-current":n?`page`:void 0,className:Y(`relative flex grow items-center justify-center text-[13.5px] no-underline`,n?`font-medium text-ink`:`text-ink2`),children:[t.label,n?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-x-6 bottom-0 h-[2px] rounded-full bg-action`}):null]},t.to)})})}var Cw=window.matchMedia(`(max-width: 767px)`),ww=e=>(Cw.addEventListener(`change`,e),()=>Cw.removeEventListener(`change`,e));function Tw(){return(0,v.useSyncExternalStore)(ww,()=>Cw.matches)}var Ew=Object.defineProperty,Dw=(e,t)=>Ew(e,`name`,{value:t,configurable:!0}),Ow=`Popover`,[kw,Aw]=op(Ow,[wb]),jw=wb(),[Mw,Nw]=kw(Ow),Pw=Dw(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=jw(t),c=v.useRef(null),[l,u]=v.useState(!1),[d,f]=Sp({prop:r,defaultProp:i??!1,onChange:a,caller:Ow});return(0,R.jsx)(Lb,{...s,children:(0,R.jsx)(Mw,{scope:t,contentId:pp(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:v.useCallback(()=>u(!0),[]),onCustomAnchorRemove:v.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),Fw=`PopoverTrigger`,Iw=v.forwardRef(Dw(function(e,t){let{__scopePopover:n,...r}=e,i=Nw(Fw,n),a=jw(n),o=np(t,i.triggerRef),s=(0,R.jsx)(Gp.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":qw(i.open),...r,ref:o,onClick:J(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,R.jsx)(Rb,{asChild:!0,...a,children:s})},`PopoverTrigger`)),Lw=`PopoverPortal`,[Rw,zw]=kw(Lw,{forceMount:void 0}),Bw=Dw(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Nw(Lw,t);return(0,R.jsx)(Rw,{scope:t,forceMount:n,children:(0,R.jsx)(Mm,{present:n||a.open,children:(0,R.jsx)(Om,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),Vw=`PopoverContent`,Hw=v.forwardRef(Dw(function(e,t){let n=zw(Vw,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Nw(Vw,e.__scopePopover);return(0,R.jsx)(Mm,{present:r||a.open,children:a.modal?(0,R.jsx)(Ww,{...i,ref:t}):(0,R.jsx)(Gw,{...i,ref:t})})},`PopoverContent`)),Uw=Ap(`PopoverContent.RemoveScroll`),Ww=v.forwardRef(Dw(function(e,t){let n=Nw(Vw,e.__scopePopover),r=v.useRef(null),i=np(t,r),a=v.useRef(!1);return v.useEffect(()=>{let e=r.current;if(e)return sg(e)},[]),(0,R.jsx)(Qh,{as:Uw,allowPinchZoom:!0,children:(0,R.jsx)(Kw,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:J(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:J(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:J(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),Gw=v.forwardRef(Dw(function(e,t){let n=Nw(Vw,e.__scopePopover),r=v.useRef(!1),i=v.useRef(!1);return(0,R.jsx)(Kw,{...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()}})},`PopoverContentNonModal`)),Kw=v.forwardRef(Dw(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Nw(Vw,n),p=jw(n);return Um(),(0,R.jsx)(hm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(rm,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,R.jsx)(zb,{"data-state":qw(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function qw(e){return e?`open`:`closed`}Dw(qw,`getState`);var Jw=Pw,Yw=Iw,Xw=Bw,Zw=Hw,Qw=new u_([]),$w=1;function eT(e,t,n=`ok`){let r=$w++;Qw.set(i=>[...i.slice(-2),{id:r,title:e,text:t,tone:n}]),setTimeout(()=>Qw.set(e=>e.filter(e=>e.id!==r)),n===`error`?4200:2200)}var tT=new u_([]),nT=1;function rT(){let[e]=(0,v.useState)(()=>nT++);(0,v.useEffect)(()=>(tT.set(t=>[...t,e]),()=>tT.set(t=>t.filter(t=>t!==e))),[e]);let t=d_(tT,t=>t[0]===e),n=d_(Qw);return t?(0,R.jsx)(`div`,{className:`pointer-events-none fixed bottom-5 left-1/2 z-[60] flex -translate-x-1/2 flex-col items-center gap-2`,children:(0,R.jsx)(ed,{mode:`popLayout`,children:n.map(e=>(0,R.jsxs)(Gf.div,{layout:!0,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,transition:{duration:.12}},transition:{type:`spring`,stiffness:520,damping:40},className:`flex max-w-[min(420px,calc(100vw-32px))] min-w-0 items-center gap-2.5 rounded-[8px] border border-rule bg-surface px-3 py-2 text-[13px] text-ink shadow-pop`,children:[e.tone===`error`?(0,R.jsx)(X,{name:`alert`,size:15,className:`text-danger-text`}):e.tone===`info`?(0,R.jsx)(X,{name:`info`,size:15,className:`text-muted`}):(0,R.jsx)(X,{name:`check`,size:15,className:`text-ok-text`}),(0,R.jsx)(`span`,{className:`shrink-0 font-medium whitespace-nowrap`,children:e.title}),e.text?(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px] text-muted`,children:e.text}):null]},e.id))})}):null}async function iT(e,t=`Copied`){try{await navigator.clipboard.writeText(e),eT(t,e.length>64?void 0:e)}catch{eT(`Could not copy`,`The browser blocked clipboard access`,`error`)}}function aT(e){return e.split(`/`).filter(Boolean)}function oT(e){return{pattern:e,segments:aT(e).map(e=>e===`*`?{kind:`splat`}:e.startsWith(`:`)?{kind:`param`,optional:e.endsWith(`?`)}:{kind:`static`,value:e})}}function sT(e){try{return decodeURIComponent(e)}catch{return e}}function cT(e,t){let n=aT(t.split(/[?#]/)[0]??``).map(sT),r=(t,i)=>{if(t===e.segments.length)return i===n.length?0:null;let a=e.segments[t];if(a.kind===`splat`)return 0;if(a.kind===`static`){if(n[i]!==a.value)return null;let e=r(t+1,i+1);return e===null?null:e+4}if(i<n.length){let e=r(t+1,i+1);if(e!==null)return e+2}return a.optional?r(t+1,i):null};return r(0,0)}function lT(e,t){let n=null;for(let r of e)for(let e of r.routes){let i=cT(e,t);i!==null&&(!n||i>n.score)&&(n={score:i,value:r.value})}return n?.value??null}function uT(e,t=`/`){let n=e.trim();if(!n||n.startsWith(`#`)||/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith(`//`))return null;let r=new URL(n,`http://app.invalid${t.replace(/\/:[^/]+\??|\/\*$/g,`/x`)}`);return r.pathname+r.search+r.hash}function dT(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fT=dT();function pT(e){fT=e}var mT={exec:()=>null};function hT(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function Q(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(_T.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var gT=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),_T={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:hT(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:hT(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:hT(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:hT(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:hT(e=>RegExp(`^ {0,${e}}(?:</?(?:${MT})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:hT(e=>RegExp(`^ {0,${e}}>`))},vT=/^(?:[ \t]*(?:\n|$))+/,yT=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,bT=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xT=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ST=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,CT=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wT=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,TT=Q(wT).replace(/bull/g,CT).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ET=Q(wT).replace(/bull/g,CT).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),DT=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,OT=/^[^\n]+/,kT=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,AT=Q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,kT).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),jT=Q(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,CT).getRegex(),MT=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,NT=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,PT=Q(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,NT).replace(`tag`,MT).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),FT=e=>Q(DT).replace(`hr`,xT).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,MT).getRegex(),IT=FT(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),LT=FT(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),RT={blockquote:Q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,LT).getRegex(),code:yT,def:AT,fences:bT,heading:ST,hr:xT,html:PT,lheading:TT,list:jT,newline:vT,paragraph:IT,table:mT,text:OT},zT=Q(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,xT).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,MT).getRegex(),BT={...RT,lheading:ET,table:zT,paragraph:Q(DT).replace(`hr`,xT).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,zT).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,MT).getRegex()},VT={...RT,html:Q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,NT).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:mT,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Q(DT).replace(`hr`,xT).replace(`heading`,` *#{1,6} *[^
58
58
  ]`).replace(`lheading`,TT).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},HT=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,UT=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,WT=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,GT=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,KT=/[\p{P}\p{S}]/u,qT=/[\s\p{P}\p{S}]/u,JT=/[^\s\p{P}\p{S}]/u,YT=Q(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,qT).getRegex(),XT=/[\p{Pi}\p{Ps}"']/u,ZT=/(?!~)[\p{P}\p{S}]/u,QT=/(?!~)[\s\p{P}\p{S}]/u,$T=/(?:[^\s\p{P}\p{S}]|~)/u,eE=Q(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,gT?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),tE=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,nE=Q(tE,`u`).replace(/punct/g,KT).getRegex(),rE=Q(tE,`u`).replace(/punct/g,ZT).getRegex(),iE=Q(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,XT).replace(/punct/g,KT).getRegex(),aE=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,oE=Q(aE,`gu`).replace(/notPunctSpace/g,JT).replace(/punctSpace/g,qT).replace(/punct/g,KT).getRegex(),sE=Q(aE,`gu`).replace(/notPunctSpace/g,$T).replace(/punctSpace/g,QT).replace(/punct/g,ZT).getRegex(),cE=Q(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,JT).replace(/punctSpace/g,qT).replace(/punct/g,KT).getRegex(),lE=Q(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,JT).replace(/punctSpace/g,qT).replace(/punct/g,KT).getRegex(),uE=Q(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,JT).replace(/punctSpace/g,qT).replace(/punct/g,KT).getRegex(),dE=Q(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,KT).getRegex(),fE=Q(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,JT).replace(/punctSpace/g,qT).replace(/punct/g,KT).getRegex(),pE=Q(/\\(punct)/,`gu`).replace(/punct/g,KT).getRegex(),mE=Q(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),hE=Q(NT).replace(`(?:-->|$)`,`-->`).getRegex(),gE=Q(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,hE).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),_E=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,vE=Q(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,_E).getRegex(),yE=Q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,vE).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),bE=Q(/^!?\[(label)\]\[(ref)\]/).replace(`label`,vE).replace(`ref`,kT).getRegex(),xE=Q(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,kT).getRegex(),SE=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,CE=Q(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,_E).getRegex(),wE=Q(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Q(/^!?\[(label)\]\[(ref)\]/).replace(`label`,CE).replace(`ref`,SE).getRegex()).replace(`nolink`,Q(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,SE).getRegex()).getRegex(),TE=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,EE=Q(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),DE={_backpedal:mT,anyPunctuation:pE,autolink:mE,blockSkip:eE,br:WT,code:UT,del:mT,delLDelim:mT,delRDelim:mT,emStrongLDelim:nE,emStrongRDelimAst:oE,emStrongRDelimUnd:lE,escape:HT,link:yE,nolink:xE,punctuation:YT,reflink:bE,reflinkSearch:wE,tag:gE,text:GT,url:mT},OE={...DE,emStrongLDelim:iE,emStrongRDelimAst:cE,emStrongRDelimUnd:uE,link:Q(/^!?\[(label)\]\((.*?)\)/).replace(`label`,vE).getRegex(),reflink:Q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,vE).getRegex()},kE={...DE,emStrongRDelimAst:sE,emStrongLDelim:rE,delLDelim:dE,delRDelim:fE,url:Q(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,EE).replace(`protocol`,TE).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Q(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,TE).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},AE={...kE,br:Q(WT).replace(`{2,}`,`*`).getRegex(),text:Q(kE.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},jE={normal:RT,gfm:BT,pedantic:VT},ME={normal:DE,gfm:kE,breaks:AE,pedantic:OE},NE={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},PE=e=>NE[e];function FE(e,t){if(t){if(_T.escapeTest.test(e))return e.replace(_T.escapeReplace,PE)}else if(_T.escapeTestNoEncode.test(e))return e.replace(_T.escapeReplaceNoEncode,PE);return e}function IE(e){return e.replace(_T.numericCharacterReference,(e,t,n)=>{let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}function LE(e){try{e=encodeURI(e).replace(_T.percentDecode,`%`)}catch{return null}return e}function RE(e,t){let n=e.replace(_T.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(_T.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(_T.slashPipe,`|`);return n}function zE(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function BE(e){let t=e.split(`
59
59
  `),n=t.length-1;for(;n>=0&&_T.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
60
60
  `)}function VE(e){return e.trim().toLowerCase().toUpperCase().toLowerCase()}function HE(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function UE(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function WE(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),c=e[0].charAt(0)===`!`;r.state.inLink=!0;let l=r.state.linkEmitted,u=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),f=r.state.linkEmitted;if(r.state.linkEmitted=l,r.state.inLink=!1,!c){if(f){r.state.inRawBlock=u;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:d}}function GE(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
@@ -121,39 +121,39 @@ ${e}</tr>
121
121
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
122
122
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${FE(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?FE(n,!0):this.parser.parseInline(r),o=LE(e);if(o===null)return a;e=FE(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+FE(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=LE(e);if(i===null)return FE(n);e=i;let a=`<img src="${FE(e)}" alt="${FE(n)}"`;return t&&(a+=` title="${FE(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:FE(e.text)}},XE=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},ZE=class e{options;renderer;textRenderer;constructor(e){this.options=e||fT,this.options.renderer=this.options.renderer||new YE,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new XE}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},QE=class{options;block;constructor(e){this.options=e||fT}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?JE.lex:JE.lexInline}provideParser(e=this.block){return e?ZE.parse:ZE.parseInline}},$E=class{defaults=dT();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ZE;Renderer=YE;TextRenderer=XE;Lexer=JE;Tokenizer=qE;Hooks=QE;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new YE(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new qE(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new QE;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=QE.passThroughHooks.has(n)?e=>{if(this.defaults.async&&QE.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return JE.lex(e,t??this.defaults)}parser(e,t){return ZE.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?JE.lex:JE.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?ZE.parse:ZE.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?JE.lex:JE.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?ZE.parse:ZE.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
123
123
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+FE(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},eD=new $E;function tD(e,t){return eD.parse(e,t)}tD.options=tD.setOptions=function(e){return eD.setOptions(e),tD.defaults=eD.defaults,pT(tD.defaults),tD},tD.getDefaults=dT,tD.defaults=fT;function nD(...e){return eD.use(...e),tD.defaults=eD.defaults,pT(tD.defaults),tD}tD.use=nD,tD.walkTokens=function(e,t){return eD.walkTokens(e,t)},tD.parseInline=eD.parseInline,tD.Parser=ZE,tD.parser=ZE.parse,tD.Renderer=YE,tD.TextRenderer=XE,tD.Lexer=JE,tD.lexer=JE.lex,tD.Tokenizer=qE,tD.Hooks=QE,tD.parse=tD,tD.options,tD.setOptions,tD.walkTokens,tD.parseInline,ZE.parse,JE.lex;var rD=new Set([`http:`,`https:`,`mailto:`]);function iD(e){try{return rD.has(new URL(e,`http://relative.invalid/`).protocol)}catch{return!1}}function aD(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}var oD={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,colon:`:`,sol:`/`,period:`.`,num:`#`,quest:`?`,equals:`=`,percnt:`%`,tab:` `,newline:`
124
- `,nbsp:`\xA0`};function sD(e){return e.replace(/&(?:#(\d{1,7})|#x([0-9a-f]{1,6})|([a-z]{2,8}));/gi,(e,t,n,r)=>{if(r)return oD[r.toLowerCase()]??e;let i=t?Number(t):Number.parseInt(n,16);return i>0&&i<=1114111&&(i<55296||i>57343)?String.fromCodePoint(i):`�`})}var cD=new $E({gfm:!0,breaks:!1},{renderer:{html:({text:e})=>aD(e),link(e){let t=this.parser.parseInline(e.tokens),n=sD(e.href);if(!iD(n))return t;let r=e.title?` title="${aD(sD(e.title))}"`:``;return`<a target="_blank" rel="noreferrer" href="${aD(n)}"${r}>${t}</a>`},image(e){let t=aD(sD(e.text)),n=sD(e.href);if(!iD(n))return t;let r=e.title?` title="${aD(sD(e.title))}"`:``;return`<img src="${aD(n)}" alt="${t}"${r}>`}}});function lD(e){return cD.parse(e,{async:!1})}function uD({text:e,className:t}){let n=(0,v.useMemo)(()=>lD(e),[e]);return(0,R.jsx)(`div`,{className:Y(`prose`,t),dangerouslySetInnerHTML:{__html:n}})}var dD=1e5,fD=2e3,pD=e=>typeof e==`object`&&!!e&&!Array.isArray(e),$=e=>typeof e==`string`,mD=e=>typeof e==`number`&&Number.isFinite(e),hD=e=>typeof e==`boolean`,gD=e=>t=>t===void 0||e(t),_D=e=>t=>Array.isArray(t)&&t.every(e),vD=e=>t=>pD(t)&&Object.entries(e).every(([e,n])=>n(t[e])),yD=e=>Array.isArray(e)&&e.length===2&&$(e[0])&&$(e[1]),bD=e=>Array.isArray(e)&&e.length===4&&e.every(mD),xD=vD({ref:mD,label:$}),SD=vD({value:$,css:$,token:gD($)}),CD=vD({value:$,token:gD($)}),wD=vD({ref:mD,tag:$,label:$,text:gD($),classes:_D($),attributes:_D(yD),component:gD(vD({owners:_D($),file:gD($)})),rect:vD({x:mD,y:mD,w:mD,h:mD}),margin:bD,border:bD,padding:bD,layout:_D(yD),typography:gD(vD({family:$,familyToken:gD($),size:$,sizeToken:gD($),weight:$,lineHeight:$,letterSpacing:$,color:SD,align:$,transform:gD($)})),appearance:vD({background:gD(SD),backgroundImage:gD($),border:gD(vD({width:$,style:$,color:SD})),radius:gD(CD),shadow:gD(CD),opacity:gD($)}),path:_D(xD),children:_D(xD),css:$}),TD={ready:{},blur:{},updated:{},"inspect-escape":{},size:{width:mD,height:mD},error:{message:$},go:{target:$},link:{href:$,path:e=>e===null||$(e),form:hD,raw:gD($),pushed:gD(hD)},wheel:{deltaX:mD,deltaY:mD,x:mD,y:mD,zoom:hD},keydown:{code:$},pointer:{x:mD,y:mD,down:hD},key:{name:$,down:hD},inspect:{info:e=>e===null||wD(e)}},ED=e=>Math.min(dD,Math.max(0,e));function DD(e){if(!pD(e)||e.source!==`design-runtime`||!$(e.key)||!$(e.type))return null;let t=Object.hasOwn(TD,e.type)?TD[e.type]:null;if(!t||!vD(t)(e))return null;let n=e;return n.type===`size`?{...n,width:ED(n.width),height:ED(n.height)}:n.type===`error`?{...n,message:n.message.slice(0,fD)}:n}function OD(e,t){return e.includes(t)||e.length>=20?e:[...e,t]}var kD=new Map;window.addEventListener(`message`,e=>{let t=e.source?kD.get(e.source):void 0;if(!t)return;let n=DD(e.data);if(n)for(let e of t)e(n)});function AD(e,t){let n=null,r=()=>{if(!n)return;let e=kD.get(n);e?.delete(t),e?.size||kD.delete(n),n=null},i=()=>{if(r(),n=e.contentWindow,!n)return;let i=kD.get(n)??new Set;i.add(t),kD.set(n,i)};return i(),e.addEventListener(`load`,i),()=>{e.removeEventListener(`load`,i),r()}}function jD(e,t){e?.contentWindow?.postMessage({source:`design-viewer`,...t},`*`)}function MD(e){jD(e,{type:`canvas`})}function ND(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=getComputedStyle(n),r=e=>/(auto|scroll|overlay)/.test(e),i=r(e.overflowY)&&n.scrollHeight>n.clientHeight,a=r(e.overflowX)&&n.scrollWidth>n.clientWidth;if(i||a){n.scrollBy({left:a?t.deltaX:0,top:i?t.deltaY:0,behavior:`instant`});return}}window.scrollBy({left:t.deltaX,top:t.deltaY,behavior:`instant`})}function PD(e,t){jD(e,{type:`theme`,theme:t})}function FD(e){e&&(e.src=e.src)}var ID=(()=>{if(Pg)return``;let{protocol:e,hostname:t,port:n}=window.location,r=t===`localhost`?`127.0.0.1`:t===`127.0.0.1`?`localhost`:null;return r?`${e}//${r}${n?`:${n}`:``}`:``})();function LD(e,t,n){let[r=``,i=``]=e.split(`?`),a=new URLSearchParams(i);a.set(`theme`,t);for(let[e,t]of Object.entries(n??{}))a.set(e,t);return`${r.startsWith(`/`)?ID:``}${r}?${a.toString()}`}function RD(e){return new URL(e,document.baseURI).toString()}function zD(e,t,n,r,i){if(e.form){eT(`Forms are not sent from a screen`,void 0,`info`);return}if(e.path===null){if(!iD(e.href)||!/^(https?|mailto):/i.test(e.href.trim())){eT(`Link not opened`,e.href.slice(0,200),`info`);return}window.open(e.href,`_blank`,`noopener,noreferrer`)||eT(`Link to another site`,e.href,`info`);return}let a=Array.isArray(t)?t:t.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))),o=a.find(e=>e.id===r),s=e.raw===void 0?e.path:uT(e.raw,o?.routes?.[0]);if(s===null)return;let c=lT(a.map(e=>({routes:(e.routes??[]).map(oT),value:e.id})),s);if(c){c!==r&&n(c);return}let l=s.split(/[?#]/)[0].replace(/\/+$/,``),u=l.slice(l.lastIndexOf(`/`)+1).replace(/\.html?$/,``);try{u=decodeURIComponent(u)}catch{}if(u&&u!==r&&a.some(e=>e.id===u))n(u);else if(e.pushed)return;else i?i(s):eT(`No screen for this link`,s,`info`)}function BD(e,t,n){let r=n_().data,i=i_(!!r?.system).data?.tokens,[a,o]=(0,v.useState)(null),s=(0,v.useRef)({enabled:t,tokens:i,picked:null});s.current={enabled:t,tokens:i,picked:a?.frame??null};let c=(0,v.useRef)(n.onEscape);c.current=n.onEscape;let l=(0,v.useRef)(e);l.current=e;let u=(0,v.useRef)(new Map),d=(e,t=!1)=>{let{enabled:n,tokens:r}=s.current,i=u.current.get(e);(t||i?.on!==n||i.tokens!==r)&&(u.current.set(e,{on:n,tokens:r}),jD(e,{type:`inspect`,on:n,tokens:n?r??[]:void 0}))};(0,v.useEffect)(()=>{for(let t of e)d(t);for(let t of u.current.keys())e.includes(t)||u.current.delete(t)},[e,t,i]),(0,v.useEffect)(()=>{let t=e.map(e=>AD(e,t=>{if(t.type===`ready`)s.current.enabled?d(e,!0):u.current.set(e,{on:!1});else if(t.type===`inspect`){if(t.info&&(s.current.enabled||s.current.picked===e)){for(let t of l.current)t!==e&&jD(t,{type:`inspect-select`,ref:null});o({info:t.info,frame:e})}else o(t=>t?.frame===e?null:t)}else t.type===`inspect-escape`&&c.current()}));return()=>{for(let e of t)e()}},[e]);let f=a&&e.includes(a.frame)?a.frame:null;return{info:f?a.info:null,frame:f,select(e){if(e===null){for(let e of l.current)jD(e,{type:`inspect-select`,ref:null});o(null)}else a&&jD(a.frame,{type:`inspect-select`,ref:e})}}}function VD(e){let[t,n]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=e=>e===`Meta`||e===`Control`,r=!1,i=!1,a,o=()=>{r=!1,clearTimeout(a),n(!1)},s=e=>{if(t(e)){if(r)return;r=!0,i=!1,a=setTimeout(()=>{r&&!i&&n(!0)},150)}else r&&(i=!0,clearTimeout(a),n(!1))},c=e=>s(e.key),l=e=>{t(e.key)&&o()};window.addEventListener(`keydown`,c,!0),window.addEventListener(`keyup`,l,!0),window.addEventListener(`blur`,o);let u=e.map(e=>AD(e,e=>{e.type===`key`?e.down?s(e.name):t(e.name)&&o():e.type===`blur`&&o()}));return()=>{window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`keyup`,l,!0),window.removeEventListener(`blur`,o);for(let e of u)e();clearTimeout(a)}},[e]),t}function HD({title:e,children:t,right:n}){return(0,R.jsxs)(`section`,{className:`border-t border-rule pb-2 first:border-t-0`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center justify-between px-4 text-[12px] font-medium text-muted`,children:[e,n]}),t]})}function UD({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid min-h-7 grid-cols-[92px_minmax(0,1fr)] items-center gap-x-3 px-4 py-0.5 text-[12.5px]`,children:[(0,R.jsx)(`span`,{className:`text-muted`,children:e}),(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-ink`,children:t})]})}function WD({name:e}){return e?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void iT(`var(${e})`,`Token copied`),title:`Copy var()`,className:`shrink-0 cursor-pointer truncate rounded-[4px] border-0 bg-action-soft px-1.5 py-px font-mono text-[11px] text-action`,children:e}):null}function GD({children:e,title:t}){return(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:t,children:e})}function KD({label:e,color:t}){return(0,R.jsxs)(UD,{label:e,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:t.css}}),(0,R.jsx)(GD,{title:t.css,children:t.value}),(0,R.jsx)(WD,{name:t.token})]})}var qD=e=>e?String(e):`–`;function JD({label:e,values:t,className:n,children:r}){let[i,a,o,s]=t;return(0,R.jsxs)(`div`,{className:Y(`relative grid grid-cols-[28px_minmax(0,1fr)_28px] grid-rows-[20px_auto_20px] rounded-[4px]`,n),children:[(0,R.jsx)(`span`,{className:`absolute top-1 left-1.5 text-[9.5px] tracking-wide text-muted uppercase`,children:e}),(0,R.jsx)(`span`,{className:`col-start-2 self-center text-center`,children:qD(i)}),(0,R.jsx)(`span`,{className:`row-start-2 self-center text-center`,children:qD(s)}),(0,R.jsx)(`div`,{className:`row-start-2 col-start-2`,children:r}),(0,R.jsx)(`span`,{className:`row-start-2 col-start-3 self-center text-center`,children:qD(a)}),(0,R.jsx)(`span`,{className:`row-start-3 col-start-2 self-center text-center`,children:qD(o)})]})}function YD({info:e}){let t={w:Math.max(0,e.rect.w-e.border[1]-e.border[3]-e.padding[1]-e.padding[3]),h:Math.max(0,e.rect.h-e.border[0]-e.border[2]-e.padding[0]-e.padding[2])};return(0,R.jsx)(`div`,{className:`px-4 pt-1 pb-2 font-mono text-[11px] text-ink2`,children:(0,R.jsx)(JD,{label:`margin`,values:e.margin,className:`border border-dashed border-rule-strong bg-[#f6b26b]/15`,children:(0,R.jsx)(JD,{label:`border`,values:e.border,className:`border border-rule-strong bg-[#f9e27d]/15`,children:(0,R.jsx)(JD,{label:`padding`,values:e.padding,className:`border border-rule-strong bg-[#93c47d]/20`,children:(0,R.jsxs)(`div`,{className:`flex h-8 items-center justify-center rounded-[3px] border border-rule-strong bg-[#6fa8dc]/25 text-ink`,children:[Math.round(t.w*100)/100,` × `,Math.round(t.h*100)/100]})})})})})}function XD({info:e,onSelect:t}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-4 pb-2`,children:[e.path.slice(-4).map((e,n)=>(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`cursor-pointer rounded-[4px] border-0 bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2 hover:text-ink`,children:e.label}),(0,R.jsx)(X,{name:`chevron-right`,size:11,className:`text-muted`})]},n)),(0,R.jsx)(`span`,{className:`rounded-[4px] bg-action-soft px-1.5 py-0.5 font-mono text-[11px] text-action`,children:e.label})]})}function ZD({info:e,onSelect:t,onClose:n,active:r}){return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[320px] shrink-0 flex-col overflow-hidden border-l border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex h-[46px] shrink-0 items-center justify-between border-b border-rule pr-2 pl-4`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px] font-semibold`,children:[(0,R.jsx)(X,{name:`pointer`,size:15,className:`text-action`}),` Inspect`]}),(0,R.jsx)(N_,{icon:`x`,label:`Close inspector (I)`,onClick:n})]}),e?(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,R.jsxs)(HD,{title:`Element`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 pb-2`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:e.component?.owners[0]?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:[`<`,e.component.owners[0],`>`]}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[12px] text-muted`,children:e.tag})]}):(0,R.jsx)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:e.label})}),e.component&&e.component.owners.length>1?(0,R.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[`in `,e.component.owners.slice(1).join(` ← `)]}):null,e.component?.file?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void iT(e.component.file,`Path copied`),className:`w-fit max-w-full cursor-pointer truncate border-0 bg-transparent p-0 text-left font-mono text-[11.5px] text-muted hover:text-ink2`,title:`Copy path`,children:e.component.file}):null,e.text?(0,R.jsxs)(`span`,{className:`line-clamp-2 text-[12.5px] text-ink2`,children:[`“`,e.text,`”`]}):null]}),(0,R.jsx)(XD,{info:e,onSelect:t})]}),(0,R.jsxs)(HD,{title:`Box`,children:[(0,R.jsx)(YD,{info:e}),(0,R.jsx)(UD,{label:`Size`,children:(0,R.jsxs)(GD,{children:[e.rect.w,` × `,e.rect.h]})}),(0,R.jsx)(UD,{label:`Position`,children:(0,R.jsxs)(GD,{children:[`x `,e.rect.x,` · y `,e.rect.y]})})]}),e.layout.length?(0,R.jsx)(HD,{title:`Layout`,children:e.layout.map(([e,t])=>(0,R.jsx)(UD,{label:e,children:(0,R.jsx)(GD,{title:t,children:t})},e))}):null,e.typography?(0,R.jsxs)(HD,{title:`Typography`,children:[(0,R.jsxs)(UD,{label:`Font`,children:[(0,R.jsx)(GD,{title:e.typography.family,children:e.typography.family.split(`,`)[0]?.replace(/["']/g,``)}),(0,R.jsx)(WD,{name:e.typography.familyToken})]}),(0,R.jsxs)(UD,{label:`Size`,children:[(0,R.jsxs)(GD,{children:[e.typography.size,` / `,e.typography.lineHeight]}),(0,R.jsx)(WD,{name:e.typography.sizeToken})]}),(0,R.jsx)(UD,{label:`Weight`,children:(0,R.jsx)(GD,{children:e.typography.weight})}),e.typography.letterSpacing===`normal`?null:(0,R.jsx)(UD,{label:`Tracking`,children:(0,R.jsx)(GD,{children:e.typography.letterSpacing})}),(0,R.jsx)(KD,{label:`Color`,color:e.typography.color}),e.typography.align===`start`?null:(0,R.jsx)(UD,{label:`Align`,children:(0,R.jsx)(GD,{children:e.typography.align})}),e.typography.transform?(0,R.jsx)(UD,{label:`Transform`,children:(0,R.jsx)(GD,{children:e.typography.transform})}):null]}):null,Object.values(e.appearance).some(Boolean)?(0,R.jsxs)(HD,{title:`Appearance`,children:[e.appearance.background?(0,R.jsx)(KD,{label:`Background`,color:e.appearance.background}):null,e.appearance.backgroundImage?(0,R.jsx)(UD,{label:`Image`,children:(0,R.jsx)(GD,{title:e.appearance.backgroundImage,children:e.appearance.backgroundImage})}):null,e.appearance.border?(0,R.jsxs)(UD,{label:`Border`,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:e.appearance.border.color.css}}),(0,R.jsxs)(GD,{children:[e.appearance.border.width,` `,e.appearance.border.style,` `,e.appearance.border.color.value]}),(0,R.jsx)(WD,{name:e.appearance.border.color.token})]}):null,e.appearance.radius?(0,R.jsxs)(UD,{label:`Radius`,children:[(0,R.jsx)(GD,{children:e.appearance.radius.value}),(0,R.jsx)(WD,{name:e.appearance.radius.token})]}):null,e.appearance.shadow?(0,R.jsxs)(UD,{label:`Shadow`,children:[(0,R.jsx)(GD,{title:e.appearance.shadow.value,children:e.appearance.shadow.value}),(0,R.jsx)(WD,{name:e.appearance.shadow.token})]}):null,e.appearance.opacity?(0,R.jsx)(UD,{label:`Opacity`,children:(0,R.jsx)(GD,{children:e.appearance.opacity})}):null]}):null,e.classes.length?(0,R.jsx)(HD,{title:`Classes`,right:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void iT(e.classes.join(` `),`Classes copied`),className:`cursor-pointer border-0 bg-transparent text-[12px] text-muted hover:text-ink2`,children:`Copy`}),children:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 px-4 pb-1`,children:e.classes.map(e=>(0,R.jsx)(`span`,{className:`rounded-[4px] bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2`,children:e},e))})}):null,e.attributes.length?(0,R.jsx)(HD,{title:`Attributes`,children:e.attributes.map(([e,t])=>(0,R.jsx)(UD,{label:e,children:(0,R.jsx)(GD,{title:t,children:t})},e))}):null,e.children.length?(0,R.jsx)(HD,{title:`Children · ${e.children.length}`,children:(0,R.jsx)(`div`,{className:`flex flex-col px-2 pb-1`,children:e.children.map((e,n)=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`flex h-7 cursor-pointer items-center gap-2 rounded-[6px] border-0 bg-transparent px-2 text-left font-mono text-[12px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(X,{name:`chevron-right`,size:12,className:`text-muted`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},n))})}):null]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-10 text-center`,children:[(0,R.jsx)(X,{name:`pointer`,size:22,className:`text-muted`}),(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:r?`Click an element in any screen.`:`Hold ${av} to highlight, click to inspect.`}),(0,R.jsx)(`span`,{className:`text-[12.5px] leading-[1.5] text-muted`,children:`Hover shows margin, padding and content. Clicks go to the inspector, not the screen.`}),(0,R.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-[12px] text-muted`,children:[(0,R.jsx)(S_,{children:`I`}),` toggle · hold `,(0,R.jsx)(S_,{children:av}),` · `,(0,R.jsx)(S_,{children:`esc`}),` clear`]})]}),e?(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-rule bg-soft px-4 py-2.5`,children:(0,R.jsx)(A_,{icon:`copy`,onClick:()=>void iT(e.css,`CSS copied`),className:`grow`,children:`Copy CSS`})}):null]})}function QD({issues:e,className:t}){return(0,R.jsx)(`div`,{className:Y(`flex flex-col`,t),children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5 border-t border-rule px-4 py-2.5 text-[13px] first:border-t-0`,children:[(0,R.jsx)(X,{name:e.severity===`error`?`alert`:`info`,size:15,className:Y(`mt-0.5`,e.severity===`error`?`text-danger-text`:`text-action`)}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-ink`,children:e.message}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] break-all text-muted`,children:[e.file,e.at?` · ${e.at}`:``]})]})]},t))})}function $D({issues:e,title:t=`Problems`}){if(!e.length)return null;let n=e.filter(e=>e.severity===`error`).length;return(0,R.jsxs)(z_,{className:n?`border-danger/40`:void 0,children:[(0,R.jsx)(B_,{title:t,count:e.length,sub:n?`${n} blocking`:`warnings`}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(QD,{issues:e})})]})}var eO=[.2,.7,.2,1];function tO({open:e,side:t,width:n,children:r}){return(0,R.jsx)(ed,{initial:!1,children:e?(0,R.jsx)(Gf.div,{initial:{width:0,opacity:.6},animate:{width:n,opacity:1},exit:{width:0,opacity:.6},transition:{duration:.22,ease:eO},className:Y(`flex min-h-0 shrink-0 overflow-hidden`,t===`right`?`justify-start`:`justify-end`),children:(0,R.jsx)(`div`,{className:`flex min-h-0 shrink-0`,style:{width:n},children:r})},`panel`):null})}function nO({title:e=`Nothing here`,text:t}){let n=!!$g().scope;return(0,R.jsx)(tv,{title:e,text:t??`This address does not match a canvas or a page of the design system.`,action:n?void 0:(0,R.jsx)(P_,{to:`/`,children:`All canvases`})})}var rO=.1,iO=(e,t=rO)=>Math.min(8,Math.max(t,e)),aO=class{camera={x:0,y:0,z:1};minZoom=rO;listeners=new Set;animation=0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}set(e){this.camera={x:e.x,y:e.y,z:iO(e.z,this.minZoom)};for(let e of this.listeners)e(this.camera)}interrupt(){cancelAnimationFrame(this.animation),this.animation=0}panBy(e,t){this.interrupt();let{x:n,y:r,z:i}=this.camera;this.set({x:n+e,y:r+t,z:i})}zoomAt(e,t,n){this.interrupt();let{x:r,y:i,z:a}=this.camera,o=iO(a*n,this.minZoom),s=(e-r)/a,c=(t-i)/a;this.set({x:e-s*o,y:t-c*o,z:o})}animateTo(e,t=320){this.interrupt();let n={...this.camera},r={...e,z:iO(e.z,this.minZoom)};if(t<=0||matchMedia(`(prefers-reduced-motion: reduce)`).matches){this.set(r);return}let i=performance.now(),a=e=>{let o=Math.min(1,(e-i)/t),s=1-(1-o)**3,c=n.z*(r.z/n.z)**s,l=n.z===r.z?s:(c-n.z)/(r.z-n.z);this.set({x:n.x+(r.x-n.x)*l,y:n.y+(r.y-n.y)*l,z:c}),this.animation=o<1?requestAnimationFrame(a):0};this.animation=requestAnimationFrame(a)}toWorld(e,t){let{x:n,y:r,z:i}=this.camera;return{x:(e-n)/i,y:(t-r)/i}}};function oO(e,t,n,r=72,i=1,a=rO){let o=iO(Math.min((t-r*2)/Math.max(e.w,1),(n-r*2)/Math.max(e.h,1),i),a),s=(e,t,n)=>t*o<=n-r*2?n/2-(e+t/2)*o:r-e*o;return{z:o,x:s(e.x,e.w,t),y:s(e.y,e.h,n)}}function sO(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function cO({items:e,value:t,onChange:n,label:r,stretch:i,size:a=`ctrl`}){let o=(0,v.useId)();return(0,R.jsx)(`div`,{role:`group`,"aria-label":r,className:Y(`shrink-0 items-center gap-0.5 rounded-[6px] bg-track p-[3px]`,a===`ctrl`?`h-ctrl`:`h-7`,i?`flex`:`inline-flex`),children:e.map(e=>{let r=e.value===t;return(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":r,title:e.title,onClick:()=>n(e.value),className:Y(`relative flex h-full cursor-pointer items-center justify-center whitespace-nowrap rounded-[4px] border-0 bg-transparent font-medium transition-colors`,a===`ctrl`?`px-2.5 text-ctrl`:`px-2 text-[12.5px]`,i&&`flex-1`,r?`text-ink`:`text-muted hover:text-ink2`),children:[r?(0,R.jsx)(Gf.span,{layoutId:o,className:`absolute inset-0 z-0 rounded-[4px] bg-surface shadow-[0_1px_2px_rgba(0,0,0,0.10)]`,transition:{type:`spring`,stiffness:520,damping:42}}):null,(0,R.jsx)(`span`,{className:`relative z-[1] flex items-center gap-1.5`,children:e.label})]},e.value)})})}var lO=5500,uO=350,dO=(e,t)=>e>=window.innerWidth/2&&t<=window.innerHeight/2;function fO({frame:e,note:t,badge:n,children:r}){let[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(0),g=(0,v.useRef)(void 0),_=(0,v.useRef)(void 0),y=e=>{a(!0),clearTimeout(g.current),g.current=setTimeout(()=>a(!1),e)},b=(e,t)=>{let n=e>=0&&dO(e,t);clearTimeout(_.current),n?s(!0):_.current=setTimeout(()=>s(!1),uO)};(0,v.useEffect)(()=>{if(!e)return;let t=()=>{jD(e,{type:`pointer`}),y(lO),h(e=>e+1)};e.addEventListener(`load`,t);let n=AD(e,t=>{if(t.type!==`pointer`)return;if(d(!0),t.x<0)return b(-1,-1);let n=e.getBoundingClientRect(),r=n.left+t.x,i=n.top+t.y;t.down&&dO(r,i)?y(lO):b(r,i)});return()=>{e.removeEventListener(`load`,t),n()}},[e]),(0,v.useEffect)(()=>{let e=e=>b(e.clientX,e.clientY),t=e=>{e.relatedTarget||b(-1,-1)};return window.addEventListener(`pointermove`,e,{passive:!0}),document.addEventListener(`pointerout`,t),()=>{window.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerout`,t),clearTimeout(g.current),clearTimeout(_.current)}},[]),(0,v.useEffect)(()=>{if(u)return;let e=document.documentElement,t=()=>p(!0),n=()=>p(!1);return e.addEventListener(`pointerenter`,t),e.addEventListener(`pointerleave`,n),()=>{e.removeEventListener(`pointerenter`,t),e.removeEventListener(`pointerleave`,n)}},[u]);let x=i||o||c||!u&&f;return(0,R.jsxs)(R.Fragment,{children:[n?(0,R.jsx)(Gf.button,{type:`button`,"aria-label":`Show the page's notice`,initial:!1,animate:x?{opacity:0,scale:.8}:{opacity:1,scale:1},transition:{duration:.2,delay:x?0:.25},onClick:()=>y(lO),tabIndex:x?-1:0,className:Y(`absolute top-3 right-3 inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-rule bg-surface/90 px-2.5 text-[11.5px] text-muted shadow-[0_1px_3px_rgb(0_0_0/0.08)] backdrop-blur-sm hover:text-ink2`,x&&`pointer-events-none`),children:n}):null,(0,R.jsx)(Gf.div,{initial:{opacity:0,scale:.94,y:-4},animate:x?{opacity:1,scale:1,y:0}:{opacity:0,scale:.97,y:-2},transition:x?{type:`spring`,stiffness:420,damping:30}:{duration:.45,ease:`easeOut`},style:{transformOrigin:`top right`},className:Y(`absolute top-3 right-3 flex max-w-[calc(100%-24px)] flex-col items-end`,!x&&`pointer-events-none`),"aria-hidden":!x||void 0,onFocus:()=>l(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},children:(0,R.jsxs)(`div`,{className:`relative flex max-w-full flex-col gap-1 rounded-[8px] border border-rule bg-surface p-1 shadow-pop`,children:[m>0?(0,R.jsx)(Gf.span,{"aria-hidden":!0,initial:{opacity:.55,scale:1},animate:{opacity:0,scale:1.18},transition:{duration:1.1,ease:`easeOut`,delay:.15},className:`pointer-events-none absolute -inset-px rounded-[8px] border-2 border-action`},m):null,r?(0,R.jsx)(`div`,{className:`flex items-center gap-1`,children:r}):null,t?(0,R.jsx)(`div`,{className:`px-2 pb-1 text-[11.5px] leading-snug text-muted`,children:t}):null]})})]})}var pO=(e,t,n)=>`/c/${encodeURIComponent(e)}/full/${encodeURIComponent(t)}?theme=${n}`;function mO(e,t,n){let{frameSandbox:r}=$g(),{base:i}=le();return t?t.kind===`url`?t.url:RD(r?`${i}${pO(e,t.id,t.theme??n)}`:LD(t.url,t.theme??n)):null}function hO({canvasId:e,itemId:t}){let{data:n,error:r,isLoading:i}=r_(e),[,a]=I(),{frameSandbox:o,frameAllow:s,slots:c}=$g(),l=b_(),u=(0,v.useRef)(null),[d,f]=(0,v.useState)(null),p=(0,v.useCallback)(e=>{u.current=e,f(e)},[]),m=new URLSearchParams(window.location.search).get(`theme`),h=n?n.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))):[],g=h.find(e=>e.id===t),_=(g?.kind===`screen`?g.theme:void 0)??(m===`light`||m===`dark`?m:n?.theme??l),y=g?g.kind===`screen`?LD(g.url,_):g.url:``,b=`/c/${encodeURIComponent(e)}`;return(0,v.useEffect)(()=>{g&&(document.title=`${g.title} · ${n?.title??``}`)},[g,n?.title]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a(b)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,b]),(0,v.useEffect)(()=>{let r=u.current;if(r&&g?.kind===`screen`)return AD(r,r=>{if(r.type===`keydown`&&r.code===`Escape`)a(b);else if(r.type===`go`){let t=r.target.includes(`/`)?r.target.split(`/`)[1]:r.target;h.some(e=>e.id===t)&&a(pO(e,t,_),{replace:!0})}else r.type===`link`&&n&&zD(r,n,t=>a(pO(e,t,_),{replace:!0}),t)})},[y,g?.kind]),r?(0,R.jsx)(nO,{title:`Canvas not found`,text:r.message}):i||!n?(0,R.jsx)(`div`,{className:`h-dvh bg-surface`}):g?(0,R.jsxs)(`div`,{className:`fixed inset-0 bg-surface`,children:[(0,R.jsx)(`iframe`,{ref:p,src:y,title:g.title,allow:s,sandbox:o,className:`block h-full w-full border-0`,style:{colorScheme:_},onLoad:()=>g.kind===`screen`&&PD(u.current,_)},`${g.id}:${g.kind===`screen`?g.rev:g.url}`),(0,R.jsxs)(fO,{frame:d,note:c.fullPlate?.note,badge:c.fullPlate?.badge,children:[(0,R.jsxs)(ye,{href:b,className:`flex h-8 min-w-0 items-center gap-2 rounded-[6px] px-2 text-[12.5px] text-ink2 no-underline hover:bg-soft2 hover:text-ink`,children:[(0,R.jsx)(X,{name:`x`,size:14}),(0,R.jsxs)(`span`,{className:`truncate`,children:[`Back to `,n.title]}),(0,R.jsx)(S_,{children:`esc`})]}),c.fullPlate?.actions]})]}):(0,R.jsx)(nO,{title:`Screen not found`,text:`No screen "${t}" on this canvas.`})}function gO(e){return e.kind===`note`?`note`:e.kind===`image`?`image`:e.kind===`url`?`globe`:e.frame.width<600?`smartphone`:e.frame.width<1100?`tablet`:`monitor`}function _O(e,t){return`/c/${encodeURIComponent(e.id)}/p/${encodeURIComponent(t.id)}`}function vO({canvas:e,page:t,store:n,onPick:r}){let i=d_(n,e=>e.selected),a=d_(n,e=>e.frames);return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[264px] shrink-0 flex-col overflow-hidden border-r border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-rule px-4 py-3.5`,children:[(0,R.jsx)(`div`,{className:`truncate text-[14px] font-semibold`,children:e.title}),e.description?(0,R.jsx)(`div`,{className:`line-clamp-3 text-[12.5px] leading-[1.45] text-muted`,children:e.description}):null]}),(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto pb-4`,children:[e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:`Pages`}),(0,R.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2`,children:e.pages.map(n=>{let r=n.sections.reduce((e,t)=>e+t.items.filter(e=>e.kind===`screen`||e.kind===`url`).length,0);return(0,R.jsxs)(ye,{href:_O(e,n),className:Y(`flex h-8 items-center gap-2 rounded-[6px] px-2.5 text-[13.5px] no-underline transition-colors focus-visible:outline-offset-[-2px]`,n.id===t.id?`bg-soft2 font-medium text-ink`:`text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:n.title}),(0,R.jsx)(`span`,{className:`text-[12px] text-muted tabular`,children:r})]},n.id)})})]}):null,(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.pages.length>1?t.title:`Layers`}),(0,R.jsx)(`div`,{className:`flex flex-col px-2`,children:t.sections.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.title?(0,R.jsxs)(`div`,{className:`flex h-7 items-center gap-2 px-2.5 pt-1 text-[12px] font-medium text-ink2`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.title}),(0,R.jsx)(R_,{value:e.items.length})]}):null,e.items.map(t=>{let n=(a[t.id]?.errors.length??0)>0||t.kind===`screen`&&t.missing;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.id),className:Y(`flex h-8 w-full cursor-pointer items-center gap-2 rounded-[6px] border-0 px-2.5 text-left text-[13px] transition-colors focus-visible:outline-offset-[-2px]`,e.title&&`pl-4`,i===t.id?`bg-action-soft text-ink`:`bg-transparent text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:gO(t),size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:t.title||(t.kind===`note`?`Note`:t.id)}),n?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`}):null]},t.id)})]},e.id))})]})]})}function yO({canvas:e,page:t,theme:n,onTheme:r,sidebar:i,onSidebar:a,onPlay:o,canPlay:s,inspect:c,onInspect:l}){let[,u]=I(),{slots:d,scope:f}=$g(),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=vw(p,m,[e.title,t?.title,e.pages.length]);return(0,R.jsxs)(_w,{value:h,children:[(0,R.jsxs)(gw,{children:[d.barStart,d.brand?d.brand:f?(0,R.jsx)(mw,{}):(0,R.jsx)(kx,{content:`All canvases`,children:(0,R.jsx)(ye,{href:`/`,className:`flex items-center`,"aria-label":`All canvases`,children:(0,R.jsx)(mw,{})})}),(0,R.jsx)(N_,{icon:`panel-left`,label:i?`Hide sidebar (⌘\\)`:`Show sidebar (⌘\\)`,onClick:()=>a(!i)}),(0,R.jsxs)(`div`,{ref:p,className:`flex min-w-0 items-center gap-1.5 text-[14px]`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate font-semibold`,children:e.title}),t&&e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{name:`chevron-right`,size:14,className:`shrink-0 text-muted`}),(0,R.jsxs)(ow,{width:240,trigger:(0,R.jsxs)(`button`,{type:`button`,className:`flex h-ctrl cursor-pointer items-center gap-1 rounded-[6px] border-0 bg-transparent px-2 text-[14px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate`,children:t.title}),(0,R.jsx)(X,{name:`chevron-down`,size:14,className:`text-muted`})]}),children:[(0,R.jsx)(dw,{children:`Pages`}),e.pages.map(n=>(0,R.jsxs)(lw,{active:n.id===t.id,onSelect:()=>u(_O(e,n)),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),n.title]},n.id))]})]}):null]}),(0,R.jsxs)(`div`,{ref:m,className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(cO,{label:`Screen theme`,value:n,onChange:r,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:15}),title:`Light screens`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:15}),title:`Dark screens`}]}),(0,R.jsx)(xO,{on:c,onChange:l,compact:h}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Play `,(0,R.jsx)(S_,{children:`P`})]}),children:(0,R.jsx)(A_,{kind:`secondary`,icon:`play`,onClick:o,disabled:!s,"aria-label":`Play`,className:h?`w-ctrl px-0`:void 0,children:h?null:`Play`})}),(0,R.jsx)(Mx,{width:180,label:`Search`,compact:h}),(0,R.jsx)(pw,{}),d.barEnd]})]}),d.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:d.belowBar}):null]})}function bO({canvas:e,store:t,layoutItems:n,theme:r,onPlay:i,inspect:a}){let o=d_(t,e=>e.selected),s=d_(t,e=>e.active),c=d_(t,e=>o?e.frames[o]:void 0),l=n.find(e=>e.id===o),u=mO(e.id,l?.kind===`screen`||l?.kind===`url`?l:void 0,r);if(!l)return null;let d=l.kind===`screen`||l.kind===`url`,f=()=>FD(document.querySelector(`[data-item="${CSS.escape(l.id)}"] iframe`)),p=c?.errors??[];return(0,R.jsx)(`div`,{"data-ui":!0,className:`pointer-events-none absolute inset-x-0 bottom-5 z-20 flex justify-center px-4`,children:(0,R.jsxs)(`div`,{className:`pointer-events-auto flex max-w-full flex-col overflow-hidden rounded-[10px] border border-rule bg-surface shadow-pop animate-[q-pop_120ms_ease-out]`,children:[p.length?(0,R.jsxs)(`div`,{className:`flex max-h-40 items-start gap-2 overflow-y-auto border-b border-rule bg-danger-soft px-3.5 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px`}),(0,R.jsx)(`span`,{className:`min-w-0`,children:p.join(`
125
- `)})]}):null,(0,R.jsxs)(`div`,{className:`flex h-[44px] items-center gap-1 pr-1.5 pl-3.5`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 pr-2`,children:[(0,R.jsx)(`span`,{className:`truncate text-[13.5px] font-medium`,children:l.title||l.id}),d&&s===l.id?(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[12px] text-muted`,children:[(0,R.jsx)(X,{name:`pointer`,size:13}),` `,a?`Inspecting`:`Interacting`,` `,(0,R.jsx)(S_,{children:`esc`})]}):d?(0,R.jsx)(`span`,{className:`shrink-0 text-[12px] text-muted`,children:a?`Click an element to inspect it`:`Click the screen to interact`}):null]}),d?(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Play `,(0,R.jsx)(S_,{children:`↵`})]}),children:(0,R.jsx)(N_,{icon:`play`,label:`Play`,onClick:()=>i(l.id)})}):null,u?(0,R.jsx)(kx,{content:`Open in a new tab`,children:(0,R.jsx)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,"aria-label":`Open in a new tab`,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,children:(0,R.jsx)(X,{name:`external`,size:16})})}):null,d?(0,R.jsx)(kx,{content:`Reload`,children:(0,R.jsx)(N_,{icon:`refresh`,label:`Reload`,onClick:f})}):null,l.kind===`screen`?(0,R.jsx)(kx,{content:`Copy source path`,children:(0,R.jsx)(N_,{icon:`copy`,label:`Copy source path`,onClick:()=>void iT(l.file,`Path copied`)})}):null,(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Zoom to `,(0,R.jsx)(S_,{children:`⇧2`})]}),children:(0,R.jsx)(N_,{icon:`fit`,label:`Zoom to`,onClick:()=>window.dispatchEvent(new CustomEvent(`design:focus`,{detail:{canvas:e.id,item:l.id}}))})})]})]})})}function xO({on:e,onChange:t,compact:n=!1}){return(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Inspect elements `,(0,R.jsx)(S_,{children:`I`})]}),children:(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e,"aria-label":`Inspect elements`,onClick:()=>t(!e),className:Y(`inline-flex h-ctrl shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-[6px] border text-ctrl font-medium`,n?`w-ctrl px-0`:`px-ctrl`,e?`border-action-line bg-action-soft text-action`:`border-rule-strong bg-surface text-ink hover:bg-soft`),children:[(0,R.jsx)(X,{name:`pointer`,size:15}),n?null:`Inspect`]})})}var SO=280,CO=96,wO=150,TO=110,EO=720,DO=e=>e.kind===`screen`||e.kind===`url`;function OO(e,t){let n=t[e.id];if(e.kind===`screen`||e.kind===`url`){let t=e.frame.width;if(e.frame.height!==`auto`)return{w:t,h:e.frame.height};let r=e.kind===`screen`?e.measuredHeight:void 0;return{w:t,h:n?.h??r??900}}if(e.kind===`note`)return{w:e.width,h:n?.h??Math.max(80,Math.ceil(e.text.length/38)*26+40)};let r=e.width??n?.w??480;return{w:r,h:n?.w?n.h/n.w*r:n?.h??r*.62}}function kO(e,t){return!e.title&&!e.description?0:t[`section:${e.id}`]?.h??(e.title?56:0)+(e.description?60:0)}function AO(e,t){let n=[],r=[];if(e.layout===`free`){let r=0;for(let i of e.sections)for(let e of i.items){let{w:a,h:o}=OO(e,t),s=e.x??r,c=e.y??0;r=Math.max(r,s+a+CO),n.push({item:e,section:i,x:s,y:c,w:a,h:o})}}else{let i=0;for(let a of e.sections){let e=kO(a,t),o=i,s=i+(e?e+TO:0),c=0,l=0,u=0,d=0;for(let e of a.items){a.columns&&d===a.columns&&(s+=l+wO,c=0,l=0,d=0);let{w:r,h:i}=OO(e,t);n.push({item:e,section:a,x:c,y:s,w:r,h:i}),c+=r+CO,u=Math.max(u,c-CO),l=Math.max(l,i),d++}let f=s+l;r.push({section:a,x:0,y:o,w:Math.max(u,e?EO:0),h:f-o,header:e}),i=f+SO}}let i=0,a=0,o=0,s=0,c=[...n,...r];return c.length&&(i=Math.min(...c.map(e=>e.x)),a=Math.min(...c.map(e=>e.y)),o=Math.max(...c.map(e=>e.x+e.w)),s=Math.max(...c.map(e=>e.y+e.h))),{items:n,sections:r,bounds:{x:i,y:a,w:o-i,h:s-a}}}function jO(e){return e.items.filter(e=>DO(e.item))}function MO(){return new u_({selected:null,active:null,hovered:null,sizes:{},frames:{},live:[],panning:!1,zoomTiny:!1,frameEls:{},inspecting:!1})}function NO(e,t,n){e.set(e=>{let r=e.sizes[t];return r&&Math.abs(r.h-n.h)<1&&r.w===n.w?e:{...e,sizes:{...e.sizes,[t]:n}}})}function PO(e,t,n){e.set(e=>{let r=e.frames[t]??{ready:!1,errors:[]};return{...e,frames:{...e.frames,[t]:{...r,...n}}}})}function FO(e,t,n){e.set(e=>e.frameEls[t]===n?e:{...e,frameEls:{...e.frameEls,[t]:n}})}function IO(e,t,n=!0){let r=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let i=r.current;if(!i||!n)return;let a=new ResizeObserver(()=>NO(e,t,{h:i.offsetHeight}));return a.observe(i),()=>a.disconnect()},[e,t,n]),r}function LO(e){return e<600?`smartphone`:e<1100?`tablet`:`monitor`}var RO=(0,v.memo)(function({placed:e,mode:t,thumb:n,theme:r,store:i,events:a,capture:o}){let{item:s,x:c,y:l,w:u,h:d}=e,f=(0,v.useRef)(null),{frameSandbox:p,frameAllow:m}=$g(),h=(0,v.useCallback)(e=>{f.current=e,FO(i,s.id,e)},[i,s.id]),g=d_(i,e=>e.frames[s.id]),_=d_(i,e=>e.active===s.id),y=d_(i,e=>e.inspecting&&s.kind===`screen`),b=s.frame.height===`auto`,x=s.kind===`screen`?s.theme??r:r,S=s.kind===`screen`?s.rev:s.url,[C]=(0,v.useState)(x),w=s.kind===`screen`?LD(s.url,C,o?{capture:`1`}:void 0):s.url,T=!!g?.ready,E=t===`off`,D=!E&&!(s.kind===`screen`&&s.missing)&&!!s.url;(0,v.useEffect)(()=>{E&&PO(i,s.id,{ready:!1})},[E,i,s.id]),(0,v.useEffect)(()=>{let e=f.current;if(e&&!E&&s.kind===`screen`)return AD(e,t=>{switch(t.type){case`ready`:PO(i,s.id,{ready:!0}),MD(e);break;case`size`:b&&NO(i,s.id,{h:Math.max(200,t.height)});break;case`error`:{let e=i.get().frames[s.id]?.errors??[],n=OD(e,t.message);n!==e&&PO(i,s.id,{errors:n});break}case`updated`:PO(i,s.id,{errors:[]});break;case`go`:a.onGo(s.id,t.target);break;case`link`:a.onLink(s.id,t);break;case`wheel`:a.onWheel(e,t);break;case`keydown`:t.code===`Escape`&&a.onEscape()}})},[E,s.id,s.kind,b,i,a,w,S]),(0,v.useEffect)(()=>{s.kind===`screen`&&PD(f.current,x)},[x,s.kind]);let O=x===`dark`?`light`:`dark`,k=e=>e?.[x]??e?.[O],A=s.kind===`screen`?k(s.snapshots):void 0,j=n&&s.kind===`screen`?k(s.thumbs)??A:A,M=t===`asleep`&&T&&!!j;return(0,R.jsxs)(`div`,{"data-item":s.id,className:`absolute overflow-clip bg-surface`,style:{left:c,top:l,width:u,height:d,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:[(!T||M)&&j?(0,R.jsx)(`img`,{src:j,alt:``,draggable:!1,loading:`lazy`,decoding:`async`,className:`absolute inset-0 h-full w-full object-cover object-top select-none`}):null,!T&&!j?(0,R.jsx)(zO,{item:s,loading:D}):null,D?(0,R.jsx)(`div`,{className:`absolute inset-0`,style:{contentVisibility:M?`hidden`:`visible`},children:(0,R.jsx)(`iframe`,{ref:h,src:w,title:s.title,allow:m,sandbox:p,className:Y(`absolute top-0 left-0 block border-0 transition-opacity duration-200`,T?`opacity-100`:`opacity-0`),style:{width:u,height:d,colorScheme:x},onLoad:()=>{s.kind===`url`?PO(i,s.id,{ready:!0}):(PD(f.current,x),MD(f.current))}},S)}):null,_||y?null:(0,R.jsx)(`div`,{"data-shield":s.id,className:`absolute inset-0`})]})});function zO({item:e,loading:t}){let n=e.kind===`screen`&&e.missing;return(0,R.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-soft text-muted`,children:[(0,R.jsx)(X,{name:n?`alert`:e.kind===`url`?`globe`:LO(e.frame.width),size:Math.max(24,Math.min(96,e.frame.width/12)),strokeWidth:1.25,className:n?`text-danger-text`:void 0}),(0,R.jsx)(`div`,{className:`max-w-[80%] truncate text-center`,style:{fontSize:Math.max(14,e.frame.width/40)},children:n?`Missing file: ${e.kind===`screen`?e.src:``}`:t?`Loading…`:e.title})]})}var BO=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a}=e,o=IO(t,n.id),s=n.tone===`plain`;return(0,R.jsxs)(`div`,{ref:o,"data-item":n.id,className:Y(`absolute`,s?``:`rounded-[10px] border border-note-line bg-note px-6 py-5 shadow-frame`),style:{left:r,top:i,width:a},children:[n.title?(0,R.jsx)(`div`,{className:`mb-2 font-semibold text-ink`,style:{fontSize:s?26:19},children:n.title}):null,(0,R.jsx)(uD,{text:n.text,className:s?`prose-plain`:`prose-note`})]})}),VO=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a,h:o}=e;return(0,R.jsx)(`div`,{"data-item":n.id,className:`absolute overflow-clip rounded-[6px] bg-surface`,style:{left:r,top:i,width:a,height:o,boxShadow:`0 0 0 1px var(--rule)`},children:n.missing?(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:20}),` Missing image`]}):(0,R.jsx)(`img`,{src:n.url,alt:n.title,draggable:!1,className:`block h-full w-full object-contain select-none`,onLoad:e=>{let r=e.currentTarget;NO(t,n.id,{w:r.naturalWidth,h:r.naturalHeight})}})})}),HO=(0,v.memo)(function({section:e,x:t,y:n,w:r,store:i}){let a=IO(i,`section:${e.id}`);return!e.title&&!e.description?null:(0,R.jsxs)(`div`,{ref:a,className:`canvas-section absolute`,style:{left:t,top:n,width:Math.min(Math.max(r,720),1400)},children:[e.title?(0,R.jsx)(`div`,{className:`text-[40px] leading-[1.15] font-semibold tracking-[-0.015em] text-ink`,children:e.title}):null,e.description?(0,R.jsx)(`div`,{className:`mt-3 max-w-[1100px]`,children:(0,R.jsx)(uD,{text:e.description,className:`prose-plain`})}):null]})}),UO={phone:{width:390,height:844,label:`Phone`},"phone-sm":{width:375,height:667,label:`Phone S`},"phone-lg":{width:430,height:932,label:`Phone L`},tablet:{width:834,height:1194,label:`Tablet`},"tablet-landscape":{width:1194,height:834,label:`Tablet landscape`},laptop:{width:1280,height:800,label:`Laptop`},desktop:{width:1440,height:900,label:`Desktop`},wide:{width:1920,height:1080,label:`Wide`}};Object.keys(UO);var WO=e=>({"--x":e.x,"--y":e.y,"--w":e.w,"--h":e.h});function GO(e){let t=e.item;if(t.kind!==`screen`&&t.kind!==`url`)return``;let n=t.frame.device?UO[t.frame.device]?.label:void 0,r=`${t.frame.width} × ${t.frame.height===`auto`?`auto`:t.frame.height}`;return n?`${n} · ${r}`:r}var KO=(0,v.memo)(function({placed:e,store:t}){let n=e.item.id,r=d_(t,e=>e.selected===n),i=d_(t,e=>e.frames[n]?.errors.length??0);return(0,R.jsxs)(`div`,{"data-at":``,"data-label":n,style:WO(e),className:Y(`frame-label pointer-events-auto flex cursor-default items-center gap-1.5 overflow-hidden pb-1.5 text-[12.5px] leading-none whitespace-nowrap select-none`,r?`text-ink`:`text-muted hover:text-ink2`),children:[i?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`,title:`${i} errors`}):null,(0,R.jsx)(`span`,{className:Y(`min-w-[3ch] truncate`,r?`font-semibold`:`font-medium`),children:e.item.title}),(0,R.jsx)(`span`,{className:`frame-device min-w-0 shrink-[20] truncate text-[11.5px] text-muted opacity-80`,children:GO(e)})]})}),qO=(0,v.memo)(function({placed:e}){return(0,R.jsx)(`div`,{"data-at":``,style:{"--x":e.x,"--y":e.y},className:`section-title text-[15px] leading-none font-semibold whitespace-nowrap text-ink select-none`,children:e.section.title})});function JO({placed:e,kind:t}){return(0,R.jsx)(`div`,{"data-at":``,style:WO(e),className:Y(`frame-outline rounded-[1px]`,t===`hover`?`outline outline-[1.5px] outline-action/60`:`outline-2 outline-action outline`)})}function YO({layout:e,view:t,store:n,overlayRef:r}){let i=d_(n,e=>e.selected),a=d_(n,e=>e.active),o=d_(n,e=>e.hovered),s=d_(n,e=>e.zoomTiny),c=(0,v.useMemo)(()=>e.items.filter(e=>DO(e.item)),[e]),l=(0,v.useMemo)(()=>{if(!t||s)return[];let{x:e,y:n,z:r,w:i,h:a}=t,o={x:-e/r-i/r,y:-n/r-a/r,w:i/r*3,h:a/r*3};return c.filter(e=>sO(e,o))},[c,t,s]),u=(0,v.useMemo)(()=>e.sections.filter(e=>e.section.title),[e]),d=t=>t?e.items.find(e=>e.item.id===t):void 0,f=d(i),p=o&&o!==i?d(o):void 0;return(0,R.jsxs)(`div`,{ref:r,className:`canvas-overlay`,"data-tiny":s,children:[u.map(e=>(0,R.jsx)(qO,{placed:e},e.section.id)),l.map(e=>(0,R.jsx)(KO,{placed:e,store:n},e.item.id)),p?(0,R.jsx)(JO,{placed:p,kind:`hover`}):null,f?(0,R.jsx)(JO,{placed:f,kind:a===i?`active`:`selected`}):null]})}var XO=12,ZO=.4,QO=20,$O=110,ek=.2,tk=400,nk=.2,rk=3,ik=8e3,ak=14,ok=96;function sk({layout:e,theme:t,store:n,camera:r,events:i,capture:a,apiRef:o,onPlay:s,onSelect:c}){let l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(null),f=(0,v.useRef)(null),[p,m]=(0,v.useState)(null),h=d_(n,e=>e.panning),g=d_(n,e=>e.selected),_=d_(n,e=>e.active),y=(0,v.useMemo)(()=>e.items.filter(e=>DO(e.item)),[e]);(0,v.useLayoutEffect)(()=>{let e=l.current,t=u.current,i=d.current,a,o,s=!1,c=0,p=()=>m({...r.camera,w:e.clientWidth,h:e.clientHeight,moving:s}),h=e=>{t.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.z})`,s||(s=!0,t.classList.add(`moving`)),clearTimeout(a),a=setTimeout(()=>{s=!1,t.classList.remove(`moving`),p()},160);let r=f.current;r&&(r.style.setProperty(`--tx`,String(e.x)),r.style.setProperty(`--ty`,String(e.y)),r.style.setProperty(`--z`,String(e.z)));let l=24*e.z;for(;l<ak;)l*=4;for(;l>ok;)l/=4;l!==c&&(c=l,i.style.backgroundSize=`${l}px ${l}px`);let u=e=>((e+ok)%l+l)%l-l;i.style.transform=`translate3d(${u(e.x)}px, ${u(e.y)}px, 0)`;let d=e.z<.09;n.get().zoomTiny!==d&&n.set(e=>({...e,zoomTiny:d})),t.classList.toggle(`far`,e.z<.15);let m=e.z<ZO;t.classList.toggle(`small-titles`,m),r&&(r.dataset.titles=m?`on`:`off`),o??=setTimeout(()=>{o=void 0,p()},90)};h(r.camera),p();let g=r.subscribe(h),_=e.getBoundingClientRect().left,v=new ResizeObserver(()=>{let t=e.getBoundingClientRect().left;if(t!==_){let e=r.camera;r.set({...e,x:e.x-(t-_)}),_=t}p()});return v.observe(e),()=>{g(),v.disconnect(),clearTimeout(a),clearTimeout(o)}},[r,n]),(0,v.useEffect)(()=>{let t=l.current,n=()=>{let{w:n,h:i}={w:t.clientWidth,h:t.clientHeight},o=e.bounds,s=o.w&&n?Math.min((n-160)/o.w,(i-160)/Math.max(o.h,1)):1;r.minZoom=a?.01:Math.min(.25,Math.max(rO,s*.5))};n();let i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[r,e.bounds,a]),(0,v.useEffect)(()=>{let t=l.current,n=()=>({w:t.clientWidth,h:t.clientHeight});o.current={size:n,openView(){let{w:t,h:i}=n(),a=e.bounds;if(!a.w)return;if(Math.min((t-160)/a.w,(i-160)/Math.max(a.h,1))>=nk)return this.fitAll(!1);let o=e.sections[0]??a,s=Math.min(.5,Math.max(.25,(t-160)/Math.max(o.w,1)));r.set({z:s,x:80-a.x*s,y:80-a.y*s})},fitAll(t=!0){let{w:i,h:a}=n();if(!e.bounds.w)return;let o=oO(e.bounds,i,a,80,1,r.minZoom);t?r.animateTo(o):r.set(o)},fitItem(t,i=!0){let a=e.items.find(e=>e.item.id===t);if(!a)return;let{w:o,h:s}=n(),c=oO(a,o,s,64,1,r.minZoom);i?r.animateTo(c):r.set(c)},zoomBy(e){let{w:t,h:i}=n(),a=r.camera,o=a.z*e,s=(t/2-a.x)/a.z,c=(i/2-a.y)/a.z;r.animateTo({z:o,x:t/2-s*o,y:i/2-c*o},180)},zoomTo(e){let{w:t,h:i}=n(),a=r.camera,o=(t/2-a.x)/a.z,s=(i/2-a.y)/a.z;r.animateTo({z:e,x:t/2-o*e,y:i/2-s*e},220)}}},[o,r,e]);let b=(0,v.useRef)([]),x=(0,v.useRef)(new Map),[S,C]=(0,v.useState)(0),w=d_(n,e=>ck(e.frames)),T=(0,v.useMemo)(()=>{let e=new Map;if(a){for(let t of y)e.set(t.item.id,`live`);return e}if(!p)return e;let{x:t,y:n,z:r,w:i,h:o}=p,s={x:-t/r,y:-n/r,w:i/r,h:o/r},c={x:s.x-s.w*.25,y:s.y-s.h*.25,w:s.w*1.5,h:s.h*1.5},l=s.x+s.w/2,u=s.y+s.h/2,d=e=>Math.max(0,Math.min(e.x+e.w,s.x+s.w)-Math.max(e.x,s.x))*Math.max(0,Math.min(e.y+e.h,s.y+s.h)-Math.max(e.y,s.y)),f=e=>Math.hypot(e.x+e.w/2-l,e.y+e.h/2-u),m=y.filter(e=>r>=ek&&sO(e,c)&&e.w*r>=$O).sort((e,t)=>d(t)-d(e)||f(e)-f(t)).slice(0,XO).map(e=>e.item.id),h=[_,g].filter(e=>!!e),v=new Set(y.map(e=>e.item.id)),S=new Set(w.split(`
126
- `)),C=new Set(b.current),T=performance.now(),E=e=>!S.has(e)&&T-(x.current.get(e)??0)<ik,D=rk-[...C].filter(E).length,O=[];for(let e of new Set([...h,...m]))v.has(e)&&(C.has(e)?O.push(e):(h.includes(e)||!p.moving&&D>0)&&(O.push(e),x.current.set(e,T),D--));let k=[...new Set([...O,...b.current])].filter(e=>v.has(e)).slice(0,QO);b.current=k;for(let e of x.current.keys())k.includes(e)||x.current.delete(e);for(let t of k)e.set(t,O.includes(t)?`live`:`asleep`);return e},[p,y,_,g,a,w,S]);(0,v.useEffect)(()=>{let e=performance.now(),t=new Set(w.split(`
127
- `)),n=[...x.current].filter(([e])=>!t.has(e)).map(([,t])=>t+ik-e).filter(e=>e>0);if(!n.length)return;let r=setTimeout(()=>C(e=>e+1),Math.min(...n)+20);return()=>clearTimeout(r)},[T,w]);let E=(0,v.useRef)(null),D=(0,v.useRef)(new Map),O=(0,v.useRef)(null),k=(0,v.useRef)(!1),A=e=>{n.get().panning!==e&&n.set(t=>({...t,panning:e}))};(0,v.useEffect)(()=>{let e=e=>{e.code===`Space`&&!lk(e.target)&&(k.current=!0,l.current?.classList.add(`cursor-grab`),e.preventDefault())},t=e=>{e.code===`Space`&&(k.current=!1,l.current?.classList.remove(`cursor-grab`))};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]);let j=e=>{let t=e;return(t?.closest(`[data-shield]`))?.dataset.shield??(t?.closest(`[data-label]`))?.dataset.label??(t?.closest(`[data-item]`))?.dataset.item??null},M=e=>{if(e.target.closest(`[data-ui]`)||e.button!==0&&e.button!==1)return;if(l.current.setPointerCapture(e.pointerId),D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),r.interrupt(),D.current.size===2){let[e,t]=[...D.current.values()];O.current={dist:Math.hypot(e.x-t.x,e.y-t.y),midX:(e.x+t.x)/2,midY:(e.y+t.y)/2},E.current=null,A(!0);return}let t=e.button===1||k.current;E.current={id:t?null:j(e.target),startX:e.clientX,startY:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:t},t&&A(!0)},ee=e=>{if(D.current.has(e.pointerId)&&D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),O.current&&D.current.size===2){let[e,t]=[...D.current.values()],n=Math.hypot(e.x-t.x,e.y-t.y),i=(e.x+t.x)/2,a=(e.y+t.y)/2,o=l.current.getBoundingClientRect();r.panBy(i-O.current.midX,a-O.current.midY),r.zoomAt(i-o.left,a-o.top,n/Math.max(O.current.dist,1)),O.current={dist:n,midX:i,midY:a};return}let t=E.current;if(!t){if(!n.get().panning){let t=j(e.target);n.get().hovered!==t&&n.set(e=>({...e,hovered:t}))}return}!t.moved&&Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>3&&(t.moved=!0,A(!0)),t.moved&&r.panBy(e.clientX-t.lastX,e.clientY-t.lastY),t.lastX=e.clientX,t.lastY=e.clientY},N=e=>{D.current.delete(e.pointerId),D.current.size<2&&(O.current=null);let t=E.current;E.current=null,t&&!t.moved&&c(t.id,{x:e.clientX,y:e.clientY}),D.current.size||A(!1)};(0,v.useEffect)(()=>{let e=l.current,t=t=>{if(t.target.closest(`[data-ui]`))return;t.preventDefault();let n=e.getBoundingClientRect(),i=t.deltaMode===1?16:t.deltaMode===2?n.height:1;if(t.ctrlKey||t.metaKey){let e=t.deltaY*i,a=Math.abs(e)<40?.012:.0025;r.zoomAt(t.clientX-n.left,t.clientY-n.top,Math.exp(-e*a))}else r.panBy(-t.deltaX*i,-t.deltaY*i)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[r]);let P=e.sections;return(0,R.jsxs)(`div`,{ref:l,className:Y(`canvas-root relative h-full w-full touch-none overflow-clip select-none animate-[q-fade-in_160ms_ease-out]`,h&&`canvas-panning cursor-grabbing`),onPointerDown:M,onPointerMove:ee,onPointerUp:N,onPointerCancel:N,onPointerLeave:()=>n.get().hovered&&n.set(e=>({...e,hovered:null})),onDoubleClick:t=>{let n=j(t.target),r=n?e.items.find(e=>e.item.id===n):void 0;r&&DO(r.item)&&s(r.item.id)},children:[(0,R.jsx)(`div`,{ref:d,className:`canvas-grid`}),(0,R.jsxs)(`div`,{ref:u,className:`canvas-world`,children:[P.map(e=>(0,R.jsx)(HO,{section:e.section,x:e.x,y:e.y,w:e.w,store:n},`section:${e.section.id}`)),e.items.map(e=>{let{item:r}=e;return r.kind===`screen`||r.kind===`url`?(0,R.jsx)(RO,{placed:e,mode:T.get(r.id)??`off`,thumb:!a&&!!p&&e.w*p.z*devicePixelRatio<=tk,theme:t,store:n,events:i,capture:a},r.id):r.kind===`note`?(0,R.jsx)(BO,{placed:e,store:n},r.id):(0,R.jsx)(VO,{placed:e,store:n},r.id)})]}),(0,R.jsx)(YO,{layout:e,view:p,store:n,overlayRef:f})]})}function ck(e){return Object.keys(e).filter(t=>e[t].ready).sort().join(`
128
- `)}function lk(e){let t=e;return!!t&&(t.isContentEditable||/^(input|textarea|select)$/i.test(t.tagName))}var uk=new URLSearchParams(window.location.search),dk=uk.has(`capture`),fk=(e,t)=>`foss-design.camera.${e}.${t}`;function pk(e){try{let t=JSON.parse(sessionStorage.getItem(e)??`null`);if(t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.z))return t}catch{}return null}function mk(e){let t=b_(),n=uk.get(`theme`),[r,i]=(0,v.useState)(n===`dark`||n===`light`?n:null);return[r??e?.theme??t,i]}function hk({canvasId:e,pageId:t}){let{data:n,error:r,isLoading:i}=r_(e);if(r)return(0,R.jsx)(nO,{title:`Canvas not found`,text:r.message});if(i||!n)return(0,R.jsx)(`div`,{className:`canvas-dots grow`});let a=t??uk.get(`page`)??void 0,o=n.pages.find(e=>e.id===a)??n.pages[0];return(0,R.jsx)(gk,{canvas:n,page:o},`${n.id}/${o?.id??``}`)}function gk({canvas:e,page:t}){let[,n]=I(),r=(0,v.useMemo)(()=>MO(),[]),i=(0,v.useMemo)(()=>new aO,[]),a=(0,v.useRef)(null),[o,s]=mk(e),[c,l]=(0,v.useState)(()=>!dk&&window.innerWidth>900),[u,d]=(0,v.useState)(!1),f=d_(r,e=>e.sizes),p=(0,v.useMemo)(()=>t?AO(t,f):{items:[],sections:[],bounds:{x:0,y:0,w:0,h:0}},[t,f]),m=bk(d_(r,e=>e.frameEls),p),h=VD(m),g=u||h;(0,v.useEffect)(()=>{r.set(e=>e.inspecting===g?e:{...e,inspecting:g,active:null})},[g,r]);let _=BD(m,g,{onEscape:()=>d(!1)}),y=!!_.info;(0,v.useEffect)(()=>{y&&d(!0)},[y]),(0,v.useEffect)(()=>{let e=_.frame;if(!e)return;let t=Object.entries(r.get().frameEls).find(([,t])=>t===e)?.[0];t&&r.get().selected!==t&&r.set(e=>({...e,selected:t}))},[_.frame,r]);let b=(0,v.useMemo)(()=>jO(p),[p]),x=fk(e.id,t?.id??``),S=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(S.current||!p.bounds.w)return;S.current=!0;let t=l_(e.id),n=dk?null:pk(x);t?(r.set(e=>({...e,selected:t})),requestAnimationFrame(()=>a.current?.fitItem(t,!1))):n&&n.z>=i.minZoom?i.set(n):requestAnimationFrame(()=>dk?a.current?.fitAll(!1):a.current?.openView())},[p,i,x,e.id,r]),(0,v.useEffect)(()=>{if(dk)return;let e,t=i.subscribe(t=>{clearTimeout(e),e=setTimeout(()=>sessionStorage.setItem(x,JSON.stringify(t)),250)});return()=>{t(),clearTimeout(e)}},[i,x]);let C=(0,v.useCallback)(e=>{let t=e?p.items.find(t=>t.item.id===e)?.item:void 0;r.set(e=>({...e,selected:t?t.id:null,active:t&&DO(t)?t.id:null,hovered:null}))},[p,r]),w=(0,v.useCallback)(e=>{C(e),a.current?.fitItem(e)},[C]),T=(0,v.useCallback)(r=>n(`/c/${encodeURIComponent(e.id)}/play/${encodeURIComponent(r)}${t?`?page=${encodeURIComponent(t.id)}`:``}`),[e.id,t,n]),E=(0,v.useCallback)(()=>{let e=r.get().selected,t=e&&b.find(t=>t.item.id===e)||b[0];t&&T(t.item.id)},[r,b,T]);(0,v.useEffect)(()=>{let t=t=>{let n=t.detail;n.canvas===e.id&&p.items.some(e=>e.item.id===n.item)&&(l_(e.id),w(n.item))};return window.addEventListener(`design:focus`,t),()=>window.removeEventListener(`design:focus`,t)},[e.id,p,w]);let D=(0,v.useMemo)(()=>({onGo(r,i){let[a,o]=i.includes(`/`)?i.split(`/`):[null,i],s=a?e.pages.filter(e=>e.id===a):[t,...e.pages.filter(e=>e!==t)];for(let r of s)if(r&&r.sections.some(e=>e.items.some(e=>e.id===o))){r===t?w(o):(n(_O(e,r)),window.dispatchEvent(new CustomEvent(`design:focus`,{detail:{canvas:e.id,item:o}})));return}console.warn(`[design] go("${i}"): no such screen`)},onLink(t,n){zD(n,e,e=>this.onGo(t,e),t)},onWheel(e,t){let n=e.closest(`.canvas-root`);if(!n)return;let r=n.getBoundingClientRect(),a=e.getBoundingClientRect(),o=i.camera.z;if(t.zoom){let e=Math.abs(t.deltaY)<40?.012:.0025;i.zoomAt(a.left-r.left+t.x*o,a.top-r.top+t.y*o,Math.exp(-t.deltaY*e))}else i.panBy(-t.deltaX,-t.deltaY)},onEscape(){r.set(e=>({...e,active:null}))}}),[e,t,i,r,w,n]);return(0,v.useEffect)(()=>{if(!dk)return;let e=Date.now(),t=setInterval(()=>{let n=r.get().frames;(b.every(e=>n[e.item.id]?.ready||e.item.kind===`screen`&&e.item.missing)||Date.now()-e>6e4)&&(clearInterval(t),a.current?.fitAll(!1),requestAnimationFrame(()=>requestAnimationFrame(()=>window.__DESIGN_CANVAS_READY__=!0)))},250);return()=>clearInterval(t)},[b,r]),(0,v.useEffect)(()=>{let i=i=>{if(lk(i.target)||document.querySelector(`[role="dialog"]`))return;let o=a.current,s=r.get(),c=i.metaKey||i.ctrlKey;if(i.key===`Escape`)_.info?_.select(null):u?d(!1):s.active?r.set(e=>({...e,active:null})):s.selected&&r.set(e=>({...e,selected:null}));else if(i.key===`i`&&!c&&!i.altKey)d(e=>!e);else if(i.key===`p`&&!c&&!i.altKey)E();else if(i.shiftKey&&i.code===`Digit1`)o?.fitAll();else if(i.shiftKey&&i.code===`Digit2`&&s.selected)o?.fitItem(s.selected);else if(i.shiftKey&&i.code===`Digit0`)o?.zoomTo(1);else if((i.key===`=`||i.key===`+`)&&!i.altKey)i.preventDefault(),o?.zoomBy(1.4);else if(i.key===`-`&&!i.altKey)i.preventDefault(),o?.zoomBy(1/1.4);else if(c&&i.key===`0`)i.preventDefault(),o?.zoomTo(1);else if(c&&i.key===`\\`)i.preventDefault(),l(e=>!e);else if([`ArrowRight`,`ArrowDown`,`ArrowLeft`,`ArrowUp`].includes(i.key)&&b.length){i.preventDefault();let e=b.findIndex(e=>e.item.id===s.selected),t=i.key===`ArrowRight`||i.key===`ArrowDown`?1:-1,n=b[e===-1?0:(e+t+b.length)%b.length];r.set(e=>({...e,selected:n.item.id,active:null})),o?.fitItem(n.item.id)}else if(i.key===`Enter`&&s.selected){let e=p.items.find(e=>e.item.id===s.selected)?.item;e&&DO(e)&&T(e.id)}else if(i.key===`]`||i.key===`[`){let r=t?e.pages.indexOf(t):-1,a=e.pages[r+(i.key===`]`?1:-1)];a&&n(_O(e,a))}};return window.addEventListener(`keydown`,i),()=>window.removeEventListener(`keydown`,i)},[r,b,p,T,E,e,t,n,u,_]),dk?(0,R.jsx)(`div`,{className:`flex h-dvh`,children:(0,R.jsx)(sk,{layout:p,theme:o,store:r,camera:i,events:D,capture:!0,apiRef:a,onPlay:()=>{},onSelect:()=>{}})}):(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(yO,{canvas:e,page:t,theme:o,onTheme:s,sidebar:c,onSidebar:l,inspect:u,onInspect:d,onPlay:E,canPlay:b.length>0}),(0,R.jsxs)(`div`,{className:`flex min-h-0 grow basis-0`,children:[(0,R.jsx)(tO,{open:c&&!!t,side:`left`,width:264,children:t?(0,R.jsx)(vO,{canvas:e,page:t,store:r,onPick:w}):null}),(0,R.jsxs)(`div`,{className:`relative min-w-0 grow`,children:[t&&p.items.length?(0,R.jsx)(sk,{layout:p,theme:o,store:r,camera:i,events:D,capture:!1,apiRef:a,onPlay:T,onSelect:C}):(0,R.jsx)(`div`,{className:`canvas-dots flex h-full`,children:(0,R.jsx)(tv,{title:t?`This page is empty`:`This canvas has no pages`,text:(0,R.jsxs)(R.Fragment,{children:[`Add sections and screens to`,` `,(0,R.jsxs)(`code`,{className:`font-mono text-[13px]`,children:[`.design/canvas/`,e.id,`/canvas.json`]}),`.`]})})}),(0,R.jsx)(bO,{canvas:e,store:r,layoutItems:p.items.map(e=>e.item),theme:o,onPlay:T,inspect:g}),(0,R.jsx)(vk,{camera:i,apiRef:a}),e.issues.length?(0,R.jsx)(yk,{canvas:e}):null]}),(0,R.jsx)(tO,{open:u,side:`right`,width:320,children:(0,R.jsx)(ZD,{info:_.info,active:!0,onSelect:e=>_.select(e),onClose:()=>{d(!1),_.select(null)}})})]})]})}function _k({camera:e}){let[t,n]=(0,v.useState)(e.camera.z);return(0,v.useEffect)(()=>{let t=0;return e.subscribe(e=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>n(e.z))})},[e]),(0,R.jsxs)(R.Fragment,{children:[Math.round(t*100),`%`]})}function vk({camera:e,apiRef:t}){return(0,R.jsxs)(`div`,{"data-ui":!0,className:`absolute right-4 bottom-5 z-20 flex h-[46px] items-center gap-0.5 rounded-[10px] border border-rule bg-surface px-1.5 shadow-pop`,children:[(0,R.jsx)(N_,{icon:`zoom-out`,label:`Zoom out (−)`,onClick:()=>t.current?.zoomBy(1/1.4)}),(0,R.jsxs)(ow,{side:`top`,align:`end`,width:210,trigger:(0,R.jsx)(`button`,{type:`button`,className:`h-ctrl min-w-[56px] cursor-pointer rounded-[6px] border-0 bg-transparent px-1.5 text-[12.5px] font-medium text-ink2 tabular hover:bg-soft2`,children:(0,R.jsx)(_k,{camera:e})}),children:[(0,R.jsx)(lw,{onSelect:()=>t.current?.fitAll(),hint:`⇧1`,children:`Zoom to fit`}),(0,R.jsx)(lw,{onSelect:()=>t.current?.zoomTo(1),hint:`⇧0`,children:`100%`}),(0,R.jsx)(uw,{}),[.25,.5,2].map(e=>(0,R.jsxs)(lw,{onSelect:()=>t.current?.zoomTo(e),children:[e*100,`%`]},e))]}),(0,R.jsx)(N_,{icon:`zoom-in`,label:`Zoom in (+)`,onClick:()=>t.current?.zoomBy(1.4)}),(0,R.jsx)(`div`,{className:`mx-0.5 h-5 w-px bg-rule`}),(0,R.jsx)(N_,{icon:`fit`,label:`Zoom to fit (⇧1)`,onClick:()=>t.current?.fitAll()})]})}function yk({canvas:e}){let t=e.issues.filter(e=>e.severity===`error`).length;return(0,R.jsxs)(Jw,{children:[(0,R.jsx)(Yw,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"data-ui":!0,className:`absolute bottom-5 left-4 z-20 flex h-[46px] cursor-pointer items-center gap-2 rounded-[10px] border border-rule bg-surface px-3.5 text-[13px] font-medium shadow-pop hover:bg-soft`,children:[(0,R.jsx)(X,{name:`alert`,size:15,className:t?`text-danger-text`:`text-action`}),e.issues.length,` `,e.issues.length===1?`problem`:`problems`,` in canvas.json`]})}),(0,R.jsx)(Xw,{children:(0,R.jsx)(Zw,{side:`top`,align:`start`,sideOffset:8,collisionPadding:12,onFocusOutside:sw,className:`z-50 max-h-[50vh] w-[460px] max-w-[calc(100vw-24px)] overflow-y-auto rounded-[10px] border border-rule bg-surface shadow-pop outline-none data-[state=open]:animate-[q-pop_120ms_ease-out]`,children:(0,R.jsx)(QD,{issues:e.issues})})})]})}function bk(e,t){let n=(0,v.useRef)([]);return(0,v.useMemo)(()=>{let r=new Set(t.items.filter(e=>e.item.kind===`screen`).map(e=>e.item.id)),i=Object.entries(e).filter(e=>!!e[1]&&r.has(e[0])).map(([,e])=>e);return i.length===n.current.length&&i.every((e,t)=>e===n.current[t])||(n.current=i),n.current},[e,t])}function xk({open:e,onOpenChange:t,title:n,children:r}){return(0,R.jsx)(hg,{open:e,onOpenChange:t,children:(0,R.jsx)(ed,{children:e?(0,R.jsxs)(yg,{forceMount:!0,children:[(0,R.jsx)(xg,{asChild:!0,forceMount:!0,children:(0,R.jsx)(Gf.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16},className:`fixed inset-0 z-50 bg-overlay`})}),(0,R.jsx)(Tg,{asChild:!0,forceMount:!0,"aria-describedby":void 0,children:(0,R.jsxs)(Gf.div,{initial:{y:`100%`},animate:{y:0},exit:{y:`100%`,transition:{duration:.18,ease:`easeIn`}},transition:{type:`spring`,stiffness:420,damping:40},className:`fixed inset-x-0 bottom-0 z-50 flex max-h-[82dvh] flex-col rounded-t-[14px] border-t border-rule bg-surface pb-[env(safe-area-inset-bottom)] shadow-pop outline-none`,children:[(0,R.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-9 rounded-full bg-rule-strong`})}),(0,R.jsxs)(`div`,{className:`flex min-h-[48px] items-center justify-between gap-3 pr-2 pl-4`,children:[(0,R.jsx)(Ag,{className:`m-0 truncate text-[15px] font-semibold`,children:n}),(0,R.jsx)(Mg,{asChild:!0,children:(0,R.jsx)(N_,{icon:`x`,label:`Close`})})]}),(0,R.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain border-t border-rule`,children:r})]})})]}):null})})}function Sk(e,t){return(t?e.pages.filter(e=>e.id===t):e.pages).flatMap(t=>t.sections.flatMap(n=>n.items.filter(e=>e.kind===`screen`||e.kind===`url`).map(r=>({item:r,pageId:t.id,where:[e.pages.length>1?t.title:null,n.title].filter(Boolean).join(` · `)}))))}var Ck=(e,t,n)=>`/c/${encodeURIComponent(e)}/play/${encodeURIComponent(t)}?page=${encodeURIComponent(n)}`;function wk({canvasId:e,itemId:t}){let{data:n,error:r,isLoading:i}=r_(e);return r?(0,R.jsx)(nO,{title:`Canvas not found`,text:r.message}):i||!n?null:(0,R.jsx)(Tk,{canvas:n,itemId:t})}function Tk({canvas:e,itemId:t}){let[,n]=I(),{frameSandbox:r,frameAllow:i,slots:a}=$g(),o=new URLSearchParams(window.location.search).get(`page`)??(window.location.hash.split(`?`)[1]?new URLSearchParams(window.location.hash.split(`?`)[1]).get(`page`):null),s=(0,v.useMemo)(()=>Sk(e,null),[e]),c=s.find(e=>e.item.id===t),l=o??c?.pageId??null,u=(0,v.useMemo)(()=>l?Sk(e,l):s,[e,l,s]),d=u.findIndex(e=>e.item.id===t),f=b_(),[p,m]=(0,v.useState)(e.theme??f),[h,g]=(0,v.useState)(`fit`),_=(0,v.useRef)(null),y=(0,v.useRef)(null),[b,x]=(0,v.useState)(null),S=(0,v.useCallback)(e=>{y.current=e,x(e)},[]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)({w:0,h:0}),[D,O]=(0,v.useState)([]),k=l?`/c/${encodeURIComponent(e.id)}/p/${encodeURIComponent(l)}`:`/c/${encodeURIComponent(e.id)}`,A=t=>{if(!u.length)return;let r=u[(d+t+u.length)%u.length];n(Ck(e.id,r.item.id,r.pageId),{replace:!0})};(0,v.useLayoutEffect)(()=>{let e=_.current;if(!e)return;let t=new ResizeObserver(()=>E({w:e.clientWidth,h:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[]),(0,v.useEffect)(()=>{let e=e=>{lk(e.target)||document.querySelector(`[role="dialog"]`)||(e.key===`ArrowRight`?A(1):e.key===`ArrowLeft`?A(-1):e.key===`i`&&!e.metaKey&&!e.ctrlKey&&!e.altKey?w(e=>!e):e.key===`Escape`&&(re.info?re.select(null):C?w(!1):n(k)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let j=u[d],M=j?.item,ee=M?.kind===`screen`?M.theme??p:p,N=mO(e.id,M,ee),[P]=(0,v.useState)(ee),te=M?M.kind===`screen`?LD(M.url,P):M.url:``,ne=(0,v.useMemo)(()=>b&&M?.kind===`screen`?[b]:[],[b,M?.kind]),F=VD(ne),re=BD(ne,C||F,{onEscape:()=>w(!1)}),ie=!!re.info;if((0,v.useEffect)(()=>{ie&&w(!0)},[ie]),(0,v.useEffect)(()=>{let t=y.current;if(t&&M?.kind===`screen`)return O([]),AD(t,t=>{if(t.type===`error`)O(e=>OD(e,t.message));else if(t.type===`updated`)O([]);else if(t.type===`keydown`&&t.code===`Escape`)n(k);else if(t.type===`go`){let[r,i]=t.target.includes(`/`)?t.target.split(`/`):[null,t.target],a=s.find(e=>e.item.id===i&&(!r||e.pageId===r));a&&n(Ck(e.id,a.item.id,a.pageId))}else t.type===`link`&&zD(t,e,t=>{let r=s.find(e=>e.item.id===t);r&&n(Ck(e.id,r.item.id,r.pageId))},M?.id)})},[M,te,s,e.id,n,k]),(0,v.useEffect)(()=>{M?.kind===`screen`&&PD(y.current,ee)},[ee,M]),!M)return(0,R.jsx)(nO,{title:`Screen not found`,text:`No screen "${t}" on this canvas.`});let ae=M.frame.width,oe=M.frame.height===`auto`?Math.max(T.h-48,400):M.frame.height,se=h===`fit`?Math.min(1,(T.w-48)/ae,(T.h-48)/oe):1,ce=ae<=T.w-48&&oe<=T.h-48;return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsxs)(gw,{children:[a.barStart,(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Back to canvas `,(0,R.jsx)(S_,{children:`esc`})]}),children:(0,R.jsx)(ye,{href:k,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,"aria-label":`Back to canvas`,children:(0,R.jsx)(X,{name:`arrow-left`,size:16})})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col leading-tight`,children:[(0,R.jsx)(`span`,{className:`truncate text-[14px] font-semibold`,children:M.title}),(0,R.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:[e.title,j.where].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(`div`,{className:`mx-auto flex items-center gap-1`,children:[(0,R.jsx)(N_,{icon:`chevron-left`,label:`Previous screen (←)`,onClick:()=>A(-1),disabled:u.length<2}),(0,R.jsxs)(`span`,{className:`min-w-[52px] text-center text-[12.5px] text-muted tabular`,children:[d+1,` / `,u.length]}),(0,R.jsx)(N_,{icon:`chevron-right`,label:`Next screen (→)`,onClick:()=>A(1),disabled:u.length<2})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ce?null:(0,R.jsx)(cO,{label:`Scale`,value:h,onChange:g,items:[{value:`fit`,label:`Fit`},{value:`actual`,label:`100%`}]}),M.kind===`screen`&&!M.theme?(0,R.jsx)(cO,{label:`Screen theme`,value:p,onChange:m,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:15}),title:`Light`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:15}),title:`Dark`}]}):null,M.kind===`screen`?(0,R.jsx)(xO,{on:C,onChange:w}):null,(0,R.jsx)(N_,{icon:`refresh`,label:`Reload`,onClick:()=>FD(y.current)}),N?(0,R.jsx)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,title:`Open in a new tab`,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,children:(0,R.jsx)(X,{name:`external`,size:16})}):null,(0,R.jsx)(pw,{}),a.barEnd]})]}),a.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:a.belowBar}):null,(0,R.jsxs)(`div`,{className:`flex min-h-0 grow basis-0`,children:[(0,R.jsxs)(`div`,{ref:_,className:`canvas-dots relative min-w-0 grow overscroll-none ${h===`actual`?`overflow-auto`:`overflow-hidden`}`,children:[D.length?(0,R.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-10 flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px`}),D.join(`
129
- `)]}):null,(0,R.jsx)(`div`,{className:`flex min-h-full min-w-full items-center justify-center p-6`,style:{width:h===`actual`?ae+48:void 0},children:(0,R.jsx)(`div`,{className:`shrink-0 animate-[q-fade-in_160ms_ease-out] overflow-clip bg-surface`,style:{width:ae*se,height:oe*se,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:(0,R.jsx)(`iframe`,{ref:S,src:te,title:M.title,allow:i,sandbox:r,className:`block border-0`,style:{width:ae,height:oe,transform:`scale(${se})`,transformOrigin:`0 0`,colorScheme:ee},onLoad:()=>M.kind===`screen`&&PD(y.current,ee)},`${M.id}:${M.kind===`screen`?M.rev:M.url}`)},M.id)})]}),(0,R.jsx)(tO,{open:C,side:`right`,width:320,children:(0,R.jsx)(ZD,{info:re.info,active:!0,onSelect:e=>re.select(e),onClose:()=>{w(!1),re.select(null)}})})]})]})}var Ek=12;function Dk({canvasId:e,pageId:t,itemId:n}){let{data:r,error:i,isLoading:a}=r_(e);return i?(0,R.jsx)(nO,{title:`Canvas not found`,text:i.message}):a||!r?(0,R.jsx)(`div`,{className:`canvas-dots h-dvh`}):(0,R.jsx)(Ok,{canvas:r,pageId:t,itemId:n})}function Ok({canvas:e,pageId:t,itemId:n}){let[,r]=I(),{frameSandbox:i,frameAllow:a,slots:o,scope:s}=$g(),c=b_(),l=(0,v.useMemo)(()=>Sk(e,null),[e]),u=Math.max(0,n?l.findIndex(e=>e.item.id===n):t?l.findIndex(e=>e.pageId===t):0),d=l[u],f=d?.item,[p,m]=(0,v.useState)(e.theme??c),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(0),[E,D]=(0,v.useState)(!1),O=(0,v.useRef)(null),k=(0,v.useRef)(null),[A,j]=(0,v.useState)(null),M=(0,v.useCallback)(e=>{e&&(k.current=e,j(e))},[]),ee=(0,v.useCallback)((t,n=0)=>{T(n),r(Ck(e.id,t.item.id,t.pageId),{replace:!0})},[e.id,r]),N=e=>{l.length<2||ee(l[(u+e+l.length)%l.length],e)},P=e=>{let t=l.find(t=>t.item.id===e);t&&ee(t,l.indexOf(t)>u?1:-1)};(0,v.useLayoutEffect)(()=>{let e=O.current;if(!e)return;let t=new ResizeObserver(()=>x(e.clientWidth));return t.observe(e),()=>t.disconnect()},[]);let te=f?.kind===`screen`?f.theme??p:p,[ne]=(0,v.useState)(te),F=f?f.kind===`screen`?LD(f.url,ne):f.url:``,re=mO(e.id,f,te);(0,v.useEffect)(()=>{y([]),C(f?.kind===`screen`?f.measuredHeight??null:null),O.current?.scrollTo({top:0});let t=k.current;if(t&&f?.kind===`screen`)return AD(t,t=>{t.type===`size`?C(t.height):t.type===`error`?y(e=>OD(e,t.message)):t.type===`updated`?y([]):t.type===`go`?P(t.target.includes(`/`)?t.target.split(`/`)[1]:t.target):t.type===`link`&&zD(t,e,P,f.id)})},[A,F]),(0,v.useEffect)(()=>{f?.kind===`screen`&&PD(k.current,te)},[te,f]),(0,v.useEffect)(()=>{let e=e=>{document.querySelector(`[role="dialog"]`)||(e.key===`ArrowRight`?N(1):e.key===`ArrowLeft`&&N(-1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let ie=(0,v.useRef)(null),ae=e=>{let t=e.touches[0];ie.current=t?{x:t.clientX,y:t.clientY}:null},oe=e=>{let t=ie.current,n=e.changedTouches[0];if(ie.current=null,!t||!n)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>56&&Math.abs(r)>Math.abs(i)*1.5&&N(r<0?1:-1)};if(!f||!d)return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(Ak,{canvas:e,title:e.title,sub:null}),(0,R.jsx)(nO,{title:`No screens here`,text:`This canvas has no screens to show yet.`})]});let se=f.frame.width,ce=b?Math.min(1,(b-24)/se):0,le=ce>0&&ce<.8,ue=le&&E?1:ce,de=f.frame.height===`auto`?Math.max(S??0,480):f.frame.height,fe=f.kind===`screen`&&!f.theme;return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(Ak,{canvas:e,title:f.title||f.id,sub:[e.title,d.where].filter(Boolean).join(` · `),back:s?void 0:`/`,end:(0,R.jsxs)(R.Fragment,{children:[le?(0,R.jsx)(N_,{icon:E?`zoom-out`:`zoom-in`,label:E?`Fit to width`:`Actual size`,onClick:()=>D(e=>!e)}):null,(0,R.jsxs)(ow,{align:`end`,width:220,trigger:(0,R.jsx)(N_,{icon:`more`,label:`Screen options`}),children:[fe?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(dw,{children:`Screen theme`}),(0,R.jsx)(kk,{value:`light`,current:p,onPick:m}),(0,R.jsx)(kk,{value:`dark`,current:p,onPick:m}),(0,R.jsx)(uw,{})]}):null,(0,R.jsxs)(lw,{onSelect:()=>FD(k.current),children:[(0,R.jsx)(X,{name:`refresh`,size:15,className:`text-ink2`}),`Reload screen`]}),re?(0,R.jsxs)(lw,{onSelect:()=>window.open(re,`_blank`,`noopener`),children:[(0,R.jsx)(X,{name:`external`,size:15,className:`text-ink2`}),`Open in a new tab`]}):null,(0,R.jsxs)(lw,{onSelect:()=>v_(c===`dark`?`light`:`dark`),children:[(0,R.jsx)(X,{name:c===`dark`?`sun`:`moon`,size:15,className:`text-ink2`}),c===`dark`?`Light appearance`:`Dark appearance`]})]}),o.barEnd]})}),o.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:o.belowBar}):null,(0,R.jsxs)(`div`,{ref:O,onTouchStart:ae,onTouchEnd:oe,className:Y(`canvas-dots relative min-h-0 grow overflow-y-auto overscroll-contain`,le&&E?`overflow-x-auto`:`overflow-x-hidden`),children:[_.length?(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:_.join(`
130
- `)})]}):null,(0,R.jsx)(ed,{initial:!1,mode:`popLayout`,custom:w,children:(0,R.jsx)(Gf.div,{custom:w,initial:{opacity:0,x:w*40},animate:{opacity:1,x:0},exit:{opacity:0,x:w*-40,transition:{duration:.12}},transition:{type:`spring`,stiffness:420,damping:38},className:Y(`flex`,le&&E?`w-max`:`justify-center`),style:{padding:Ek},children:ue?(0,R.jsx)(`div`,{className:`shrink-0 overflow-hidden rounded-[6px] bg-surface`,style:{width:se*ue,height:de*ue,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:(0,R.jsx)(`iframe`,{ref:M,src:F,title:f.title,allow:a,sandbox:i,className:`block border-0`,style:{width:se,height:de,transform:`scale(${ue})`,transformOrigin:`0 0`,colorScheme:te},onLoad:()=>f.kind===`screen`&&PD(k.current,te)},`${f.id}:${f.kind===`screen`?f.rev:f.url}`)}):null},f.id)})]}),(0,R.jsxs)(`nav`,{"aria-label":`Screens`,className:`flex shrink-0 items-center gap-1 border-t border-rule bg-surface px-2 pt-1.5 pb-[max(6px,env(safe-area-inset-bottom))]`,children:[(0,R.jsx)(N_,{icon:`chevron-left`,label:`Previous screen`,onClick:()=>N(-1),disabled:l.length<2}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),className:`flex h-10 min-w-0 grow cursor-pointer items-center justify-center gap-2 rounded-[8px] border-0 bg-transparent px-3 text-[13.5px] text-ink active:bg-soft2`,children:[(0,R.jsx)(X,{name:`list`,size:15,className:`shrink-0 text-muted`}),(0,R.jsxs)(`span`,{className:`tabular shrink-0 text-muted`,children:[u+1,` / `,l.length]}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:f.title||f.id})]}),(0,R.jsx)(N_,{icon:`chevron-right`,label:`Next screen`,onClick:()=>N(1),disabled:l.length<2})]}),(0,R.jsx)(xk,{open:h,onOpenChange:g,title:e.title,children:(0,R.jsx)(Mk,{canvas:e,current:f.id,onPick:e=>{g(!1),P(e)}})})]})}function kk({value:e,current:t,onPick:n}){return(0,R.jsxs)(lw,{active:t===e,onSelect:()=>n(e),children:[(0,R.jsx)(X,{name:e===`dark`?`moon`:`sun`,size:15,className:`text-ink2`}),e===`dark`?`Dark`:`Light`,t===e?(0,R.jsx)(X,{name:`check`,size:15,className:`ml-auto text-ink2`}):null]})}function Ak({canvas:e,title:t,sub:n,back:r,end:i}){let{slots:a}=$g();return(0,R.jsxs)(`header`,{className:`flex h-[52px] shrink-0 items-center gap-2 border-b border-rule bg-surface pr-2 pl-2 pt-[env(safe-area-inset-top)]`,children:[a.barStart,r?(0,R.jsx)(ye,{href:r,"aria-label":`All canvases, leaving ${e.title}`,className:`inline-flex size-10 shrink-0 items-center justify-center rounded-[8px] text-ink2 active:bg-soft2`,children:(0,R.jsx)(X,{name:`arrow-left`,size:18})}):(0,R.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center`,children:(0,R.jsx)(mw,{})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 grow flex-col leading-tight`,children:[(0,R.jsx)(`span`,{className:`truncate text-[14.5px] font-semibold`,children:t}),n?(0,R.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:n}):null]}),(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:i})]})}var jk=e=>e.item.kind===`url`?`globe`:e.item.frame.device===`phone`?`smartphone`:e.item.frame.device===`tablet`?`tablet`:`monitor`;function Mk({canvas:e,current:t,onPick:n}){let r=(0,v.useRef)(null);(0,v.useEffect)(()=>{r.current?.scrollIntoView({block:`center`})},[]);let i=e.pages.length>1;return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:e.pages.map(a=>{let o=Sk(e,a.id);return o.length?(0,R.jsxs)(`section`,{className:`flex flex-col`,children:[i?(0,R.jsx)(`h3`,{className:`sticky top-0 z-[1] m-0 border-b border-rule bg-soft px-4 py-2 text-[12px] font-semibold text-ink2`,children:a.title}):null,a.sections.map(e=>{let i=o.filter(t=>e.items.includes(t.item));return i.length?(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.title?(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.title}):null,i.map(e=>{let i=e.item.id===t;return(0,R.jsxs)(`button`,{ref:i?r:void 0,type:`button`,"aria-current":i?`true`:void 0,onClick:()=>n(e.item.id),className:Y(`flex min-h-[48px] cursor-pointer items-center gap-3 border-0 bg-transparent px-4 text-left text-[14px] active:bg-soft2`,i?`font-medium text-ink`:`text-ink2`),children:[(0,R.jsx)(`span`,{className:Y(`flex size-8 shrink-0 items-center justify-center rounded-[8px]`,i?`bg-action-soft text-action`:`bg-soft2 text-muted`),children:(0,R.jsx)(X,{name:jk(e),size:15})}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.item.title||e.item.id}),i?(0,R.jsx)(X,{name:`check`,size:16,className:`shrink-0 text-action`}):null]},e.item.id)})]},e.id):null})]},a.id):null})})}var Nk=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60]],Pk=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`});function Fk(e){if(!e)return``;let t=(e-Date.now())/1e3;for(let[e,n]of Nk)if(Math.abs(t)>=n)return Pk.format(Math.round(t/n),e);return`just now`}function Ik(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Lk(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Rk({className:e,style:t}){return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:Y(`block animate-pulse rounded-[6px] bg-soft2`,e),style:t})}function zk({rows:e=3,lead:t=28,minH:n=56}){return(0,R.jsx)(`div`,{role:`status`,"aria-label":`Loading`,children:Array.from({length:e},(e,r)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-rule px-4`,style:{minHeight:n,opacity:1-r*.18},children:[t?(0,R.jsx)(Rk,{style:{width:t,height:Math.min(t,n-20)}}):null,(0,R.jsxs)(`span`,{className:`flex min-w-0 grow flex-col gap-1.5`,children:[(0,R.jsx)(Rk,{className:`h-3 w-[38%]`}),(0,R.jsx)(Rk,{className:`h-2.5 w-[62%]`})]}),(0,R.jsx)(Rk,{className:`h-3 w-14`})]},r))})}function Bk({canvas:e}){return(0,R.jsx)(`div`,{className:`flex h-[54px] w-[86px] shrink-0 items-center justify-center overflow-hidden rounded-[6px] border border-rule bg-soft`,children:e.cover?(0,R.jsx)(`img`,{src:e.cover,alt:``,className:`h-full w-full object-cover object-top`}):(0,R.jsx)(X,{name:`canvas`,size:18,className:`text-muted`})})}function Vk({src:e}){return(0,R.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-[6px] border border-rule bg-soft`,children:(0,R.jsx)(`img`,{src:e,alt:``,className:`size-full object-contain`})})}function Hk({project:e}){let{source:t,keys:n}=$g(),r=Me(),i=(0,v.useRef)(null);if(!t.setIcon||e.static)return null;let a=async e=>{try{await t.setIcon(e),await r.invalidateQueries({queryKey:n.project}),eT(e?`Icon set`:`Icon removed`,e?`Saved as .design/icon; a linked project takes it to the cloud on its next push or pull.`:void 0)}catch(e){eT(`Could not change the icon`,e.message,`error`)}};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{ref:i,type:`file`,accept:`.svg,.png,.webp,image/svg+xml,image/png,image/webp`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&a(t)}}),(0,R.jsxs)(ow,{trigger:(0,R.jsx)(A_,{children:`Icon`}),align:`end`,width:240,children:[(0,R.jsxs)(lw,{onSelect:()=>i.current?.click(),hint:`≤ 256 KB`,children:[(0,R.jsx)(X,{name:`upload`,size:15}),e.icon?`Replace icon`:`Upload icon`]}),e.icon?(0,R.jsxs)(lw,{danger:!0,onSelect:()=>void a(null),children:[(0,R.jsx)(X,{name:`trash`,size:15}),`Remove icon`]}):null]})]})}function Uk({actions:e,children:t}){return e?(0,R.jsxs)(`div`,{className:`grid items-center border-t border-rule transition-colors hover:bg-soft`,style:{gridTemplateColumns:`minmax(0,1fr) auto`},children:[t,(0,R.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:e})]}):t}function Wk({children:e}){return e?(0,R.jsx)(`div`,{className:`flex items-center gap-2.5 border-t border-rule bg-soft px-4 py-3 text-[12.5px] text-muted`,children:e}):null}function Gk({project:e}){let{canvasRowActions:t,canvasesFoot:n}=$g().slots,r=Tw();return e.canvases.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Canvases`,count:e.canvases.length}),e.canvases.map(e=>{let n=t?.(e.id);return(0,R.jsx)(Uk,{actions:n,children:r?(0,R.jsxs)(q_,{to:`/c/${encodeURIComponent(e.id)}`,cols:`86px minmax(0,1fr)`,align:`ll`,pad:`10px 16px`,minH:74,first:!!n,children:[(0,R.jsx)(Bk,{canvas:e}),(0,R.jsx)(C_,{top:e.title,bottom:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[e.issues?(0,R.jsx)(L_,{tone:`danger`,children:Lk(e.issues,`problem`)}):null,(0,R.jsxs)(`span`,{className:`truncate`,children:[Lk(e.screens,`screen`),` · `,Fk(e.updatedAt)]})]})})]}):(0,R.jsxs)(q_,{to:`/c/${encodeURIComponent(e.id)}`,cols:`86px minmax(0,1fr) auto auto`,align:`llrr`,pad:`10px 16px`,minH:74,first:!!n,children:[(0,R.jsx)(Bk,{canvas:e}),(0,R.jsx)(C_,{top:e.title,bottom:(0,R.jsx)(`span`,{className:`truncate`,children:e.description??e.id})}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[12.5px] whitespace-nowrap text-muted`,children:[e.issues?(0,R.jsx)(L_,{tone:`danger`,children:Lk(e.issues,`problem`)}):null,Lk(e.screens,`screen`),` · `,Lk(e.pages,`page`)]}),(0,R.jsx)(`span`,{className:`w-[92px] text-[12.5px] whitespace-nowrap text-muted`,children:Fk(e.updatedAt)})]})},e.id)}),(0,R.jsx)(Wk,{children:n})]}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Canvases`,count:0}),(0,R.jsx)(Y_,{children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 py-6 text-center`,children:[(0,R.jsx)(`span`,{className:`text-[14px] text-ink2`,children:`No canvases yet.`}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Ask your agent to design something, or run `,(0,R.jsx)(Z,{children:`design new <name>`}),` in the project.`]})]})}),(0,R.jsx)(Wk,{children:n})]})}function Kk({project:e}){let t=e.system;return t?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Design system`,right:(0,R.jsx)(P_,{to:`/system`,children:`Open`})}),(0,R.jsxs)(Y_,{gap:6,children:[(0,R.jsx)(`span`,{className:`text-[15px] font-semibold`,children:t.name}),t.description?(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:t.description}):null]}),(0,R.jsx)(J_,{label:`Tokens`,labelWidth:120,end:!0,children:(0,R.jsx)(R_,{value:t.tokens})}),(0,R.jsx)(J_,{label:`Components`,labelWidth:120,end:!0,children:(0,R.jsx)(R_,{value:t.components})}),(0,R.jsx)(J_,{label:`Guidelines`,labelWidth:120,end:!0,children:(0,R.jsx)(R_,{value:t.guidelines})}),t.issues?(0,R.jsx)(J_,{label:`Problems`,labelWidth:120,end:!0,children:(0,R.jsx)(L_,{tone:`danger`,children:t.issues})}):null]}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Design system`}),(0,R.jsx)(Y_,{children:(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`No design system yet. Ask your agent to build one from the codebase, or run `,(0,R.jsx)(Z,{children:`design system init`}),`.`]})})]})}function qk(){return(0,R.jsxs)(X_,{children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1 pb-1`,children:[(0,R.jsx)(Rk,{className:`h-6 w-[220px]`}),(0,R.jsx)(Rk,{className:`h-3.5 w-[300px]`})]}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-lg:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 340px`},children:[(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Canvases`}),(0,R.jsx)(zk,{rows:3,lead:86,minH:74})]}),(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Design system`}),(0,R.jsx)(zk,{rows:3,lead:0,minH:40})]})]})]})}function Jk(){let{data:e,error:t,isLoading:n}=n_(),{slots:r}=$g(),i=Tw();return t?(0,R.jsx)(tv,{title:`Could not load the project`,text:t.message}):n||!e?(0,R.jsx)(qk,{}):(0,R.jsxs)(X_,{children:[(0,R.jsx)(Z_,{title:e.icon?(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,R.jsx)(Vk,{src:e.icon}),e.name]}):e.name,right:i?void 0:r.homeActions??(0,R.jsx)(Hk,{project:e}),badge:i&&r.homeActions?(0,R.jsx)(`span`,{className:`ml-auto flex`,children:r.homeActions}):void 0,sub:r.homeSub?r.homeSub:e.static?`Snapshot built with foss-design ${e.version}`:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(Z,{size:12.5,wrap:!0,children:[e.root,`/.design`]}),` `,`· foss-design `,e.version]})}),(0,R.jsx)($D,{issues:e.issues,title:`Problems in design.json`}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-lg:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 340px`},children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,R.jsx)(Gk,{project:e}),r.canvasesAfter]}),(0,R.jsx)(Kk,{project:e})]}),r.homeAfter]})}function Yk(e){let t=e.utility;if(t===void 0)return[];let n=t?`-${t}`:``;switch(e.kind){case`color`:return[`bg${n}`,`text${n}`,`border${n}`];case`font`:return[`font${n}`];case`text`:return[`text${n}`];case`weight`:return[`font${n}`];case`leading`:return[`leading${n}`];case`tracking`:return[`tracking${n}`];case`spacing`:return t?[`p${n}`,`gap${n}`]:[`p-1`,`gap-4`,`m-2`];case`radius`:return[`rounded${n}`];case`shadow`:return e.name.startsWith(`--inset-shadow-`)?[`inset-shadow${n}`]:e.name.startsWith(`--drop-shadow-`)?[`drop-shadow${n}`]:e.name.startsWith(`--text-shadow-`)?[`text-shadow${n}`]:[`shadow${n}`];case`blur`:return[`blur${n}`,`backdrop-blur${n}`];case`ease`:return[`ease${n}`];case`animation`:return[`animate${n}`];case`breakpoint`:return e.name.startsWith(`--container-`)?[`@${t}:`,`max-w${n}`]:[`${t}:`];default:return[]}}function Xk(e,...t){return e.filter(e=>t.includes(e.kind))}function Zk(e){let t=new Map;for(let n of e){let e=t.get(n.group)??[];e.push(n),t.set(n.group,e)}return[...t].map(([e,t])=>({group:e,tokens:t}))}function Qk(e){let t=/^(-?[\d.]+)(px|rem|em)?$/.exec(e.trim());if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?t[2]===`rem`||t[2]===`em`?n*16:n:null}function $k(e,t){return(t===`dark`?e.dark?.value:void 0)??e.light?.value}function eA(){let e=b_(),[t,n]=(0,v.useState)(null);return[t??e,n]}function tA({value:e,onChange:t}){return(0,R.jsx)(cO,{label:`Theme`,size:`sm`,value:e,onChange:t,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:14}),title:`Light`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:14}),title:`Dark`}]})}function nA({items:e}){return e.length?(0,R.jsx)(`span`,{className:`flex min-w-0 flex-wrap gap-x-2 gap-y-0.5`,children:e.map(e=>(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e},e))}):null}function rA({title:e,children:t}){return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e}),(0,R.jsx)(Y_,{children:(0,R.jsx)(`div`,{className:`py-4 text-[13px] text-muted`,children:t})})]})}var iA=`.design/system/tokens.css`;function aA({children:e,className:t}){return(0,R.jsx)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere] ${t??``}`,children:e})}function oA({asset:e,index:t}){if(e.kind===`image`)return(0,R.jsx)(`span`,{className:`checker flex h-[132px] items-center justify-center overflow-hidden border-b border-rule`,children:(0,R.jsx)(`img`,{src:e.url,alt:``,className:`max-h-[96px] max-w-[80%] object-contain`})});if(e.kind===`font`){let n=`design-asset-font-${t}`;return(0,R.jsxs)(`span`,{className:`flex h-[132px] items-center justify-center border-b border-rule bg-soft`,children:[(0,R.jsx)(`style`,{children:`@font-face{font-family:"${n}";src:url("${e.url.replace(/"/g,`%22`)}")}`}),(0,R.jsx)(`span`,{className:`text-[52px] leading-none text-ink`,style:{fontFamily:`"${n}", var(--font-sans)`},children:`Aa`})]})}return(0,R.jsx)(`span`,{className:`flex h-[132px] items-center justify-center border-b border-rule bg-soft text-muted`,children:(0,R.jsx)(X,{name:`file`,size:28})})}function sA({system:e}){return e.assets.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Assets`,sub:`Click an asset to copy its import path.`}),(0,R.jsx)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(210px, 1fr))`},children:e.assets.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,title:`Copy the import path`,onClick:()=>iT(`@system/${e.path}`),className:`block cursor-pointer border-0 bg-transparent p-0 text-left`,children:(0,R.jsxs)(z_,{className:`transition-colors hover:border-rule-strong`,children:[(0,R.jsx)(oA,{asset:e,index:t}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-3.5 py-2.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-[13.5px] font-medium text-ink`,children:e.name}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[12.5px] text-muted`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:Ik(e.size)}),(0,R.jsx)(Z,{size:12,className:`truncate`,children:e.path})]})]})]})},e.path))})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Assets`}),(0,R.jsxs)(rA,{title:`No assets`,children:[`Put logos, icons, images and font files in `,(0,R.jsx)(Z,{children:`.design/system/assets`}),`; screens import them as`,` `,(0,R.jsx)(Z,{children:`@system/assets/…`}),`.`]})]})}function cA({color:e,label:t,className:n}){return e?(0,R.jsx)(`span`,{title:`${t}: ${e}`,className:Y(`checker relative h-[30px] w-[44px] shrink-0 overflow-hidden rounded-[6px]`,n),children:(0,R.jsx)(`span`,{className:`absolute inset-0 rounded-[6px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1)] dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.12)]`,style:{background:e}})}):(0,R.jsx)(`span`,{className:Y(`h-[30px] w-[44px] shrink-0`,n)})}function lA({tokens:e}){let t=e.some(e=>e.dark),n=t=>(0,R.jsxs)(`div`,{className:`relative flex h-9 min-w-0 grow overflow-hidden rounded-[6px]`,children:[(0,R.jsx)(`span`,{className:`pointer-events-none absolute inset-0 z-10 rounded-[6px] shadow-[inset_0_0_0_1px_var(--rule-strong)] opacity-60`}),e.map(e=>{let n=t===`dark`?e.dark?.value??e.light?.value:e.light?.value;return(0,R.jsx)(`button`,{type:`button`,title:`${e.name}: ${n}`,onClick:()=>iT(`var(${e.name})`),className:`h-full min-w-0 flex-1 cursor-pointer border-0 p-0 transition-[flex-grow] duration-150 hover:grow-[1.6]`,style:{background:n}},e.name)})]});return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-rule px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t?(0,R.jsx)(`span`,{className:`w-9 shrink-0 text-[12px] text-muted`,children:`Light`}):null,n(`light`)]}),t?(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`w-9 shrink-0 text-[12px] text-muted`,children:`Dark`}),n(`dark`)]}):null]})}function uA({token:e}){return(0,R.jsxs)(K_,{cols:`100px minmax(170px, 0.9fr) minmax(0, 1.4fr)`,minH:56,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(cA,{color:e.light?.value,label:`Light`}),e.dark?(0,R.jsx)(cA,{color:e.dark.value,label:`Dark`}):null]}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(nA,{items:Yk(e).slice(0,2)})]}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-wrap gap-x-3`,children:[(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),e.dark?(0,R.jsxs)(Z,{size:12,className:`text-muted`,children:[`dark `,e.dark.value]}):null]}),e.description?(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:e.description}):null]})]})}function dA({system:e}){let t=Xk(e.tokens,`color`),n=Zk(t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Colors`,sub:t.length?`${t.length} tokens · click a color to copy its variable`:void 0}),n.length?n.map(({group:e,tokens:t})=>(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(lA,{tokens:t}),t.map(e=>(0,R.jsx)(uA,{token:e},e.name))]},e)):(0,R.jsxs)(rA,{title:`No color tokens`,children:[`Add them to `,(0,R.jsx)(Z,{children:iA}),`: light values in `,(0,R.jsx)(Z,{children:`:root`}),`, dark ones in`,` `,(0,R.jsx)(Z,{children:`:root[data-theme="dark"]`}),`, and map them to Tailwind with `,(0,R.jsx)(Z,{children:`--color-*`}),` in`,` `,(0,R.jsx)(Z,{children:`@theme inline`}),`.`]})]})}function fA({src:e,theme:t,title:n,minHeight:r=120,width:i,className:a}){let o=(0,v.useRef)(null),{frameSandbox:s,frameAllow:c}=$g(),[l]=(0,v.useState)(()=>({src:e,theme:t})),u=LD(e,l.src===e?l.theme:t),[d,f]=(0,v.useState)(r),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=o.current;if(e)return m(!1),g([]),AD(e,t=>{t.type===`size`?f(Math.max(r,t.height)):t.type===`ready`?m(!0):t.type===`error`?g(e=>OD(e,t.message)):t.type===`updated`?g([]):t.type===`wheel`&&!t.zoom&&ND(e,t)})},[r,u]),(0,v.useEffect)(()=>{PD(o.current,t)},[t]),(0,R.jsxs)(`div`,{className:Y(`relative`,a),style:{width:i},children:[h.length?(0,R.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2.5 text-[12.5px] text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:15,className:`mt-px`}),(0,R.jsx)(`div`,{className:`min-w-0 font-mono break-words`,children:h.join(`
131
- `)})]}):null,(0,R.jsx)(`iframe`,{ref:o,src:u,title:n,allow:c,sandbox:s,className:Y(`block w-full border-0 transition-opacity duration-150`,p?`opacity-100`:`opacity-0`),style:{height:d,colorScheme:t},onLoad:()=>PD(o.current,t)},u),p?null:(0,R.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted`,children:(0,R.jsx)(X,{name:`loader`,size:18})})]})}var pA=`identifier keyword string class property entity jsxliterals sign comment break space`.split(` `),[mA,hA,gA,_A,vA,yA,bA,xA,SA,CA,wA]=pA.map((e,t)=>t);new Map(pA.map((e,t)=>[e,t]));function TA(e,t){let n=[],r=0,i=[],a=!1;function o(e){n.push({index:r++,value:e.map(([,e])=>e).join(``),tokens:e.map(([e,t])=>({type:pA[e],value:t})),annotations:[]})}for(let e=0;e<t.length;e++){let n=t[e],[r,s]=n;if(r!==CA){if(s.includes(`
124
+ `,nbsp:`\xA0`};function sD(e){return e.replace(/&(?:#(\d{1,7})|#x([0-9a-f]{1,6})|([a-z]{2,8}));/gi,(e,t,n,r)=>{if(r)return oD[r.toLowerCase()]??e;let i=t?Number(t):Number.parseInt(n,16);return i>0&&i<=1114111&&(i<55296||i>57343)?String.fromCodePoint(i):`�`})}var cD=new $E({gfm:!0,breaks:!1},{renderer:{html:({text:e})=>aD(e),link(e){let t=this.parser.parseInline(e.tokens),n=sD(e.href);if(!iD(n))return t;let r=e.title?` title="${aD(sD(e.title))}"`:``;return`<a target="_blank" rel="noreferrer" href="${aD(n)}"${r}>${t}</a>`},image(e){let t=aD(sD(e.text)),n=sD(e.href);if(!iD(n))return t;let r=e.title?` title="${aD(sD(e.title))}"`:``;return`<img src="${aD(n)}" alt="${t}"${r}>`}}});function lD(e){return cD.parse(e,{async:!1})}function uD({text:e,className:t}){let n=(0,v.useMemo)(()=>lD(e),[e]);return(0,R.jsx)(`div`,{className:Y(`prose`,t),dangerouslySetInnerHTML:{__html:n}})}var dD=1e5,fD=2e3,pD=e=>typeof e==`object`&&!!e&&!Array.isArray(e),$=e=>typeof e==`string`,mD=e=>typeof e==`number`&&Number.isFinite(e),hD=e=>typeof e==`boolean`,gD=e=>t=>t===void 0||e(t),_D=e=>t=>Array.isArray(t)&&t.every(e),vD=e=>t=>pD(t)&&Object.entries(e).every(([e,n])=>n(t[e])),yD=e=>Array.isArray(e)&&e.length===2&&$(e[0])&&$(e[1]),bD=e=>Array.isArray(e)&&e.length===4&&e.every(mD),xD=vD({ref:mD,label:$}),SD=vD({value:$,css:$,token:gD($)}),CD=vD({value:$,token:gD($)}),wD=vD({ref:mD,tag:$,label:$,text:gD($),classes:_D($),attributes:_D(yD),component:gD(vD({owners:_D($),file:gD($)})),rect:vD({x:mD,y:mD,w:mD,h:mD}),margin:bD,border:bD,padding:bD,layout:_D(yD),typography:gD(vD({family:$,familyToken:gD($),size:$,sizeToken:gD($),weight:$,lineHeight:$,letterSpacing:$,color:SD,align:$,transform:gD($)})),appearance:vD({background:gD(SD),backgroundImage:gD($),border:gD(vD({width:$,style:$,color:SD})),radius:gD(CD),shadow:gD(CD),opacity:gD($)}),path:_D(xD),children:_D(xD),css:$}),TD={ready:{},blur:{},updated:{},"inspect-escape":{},size:{width:mD,height:mD},error:{message:$},go:{target:$},link:{href:$,path:e=>e===null||$(e),form:hD,raw:gD($),pushed:gD(hD)},wheel:{deltaX:mD,deltaY:mD,x:mD,y:mD,zoom:hD},keydown:{code:$},pointer:{x:mD,y:mD,down:hD},key:{name:$,down:hD},inspect:{info:e=>e===null||wD(e)}},ED=e=>Math.min(dD,Math.max(0,e));function DD(e){if(!pD(e)||e.source!==`design-runtime`||!$(e.key)||!$(e.type))return null;let t=Object.hasOwn(TD,e.type)?TD[e.type]:null;if(!t||!vD(t)(e))return null;let n=e;return n.type===`size`?{...n,width:ED(n.width),height:ED(n.height)}:n.type===`error`?{...n,message:n.message.slice(0,fD)}:n}function OD(e,t){return e.includes(t)||e.length>=20?e:[...e,t]}var kD=new Map;window.addEventListener(`message`,e=>{let t=e.source?kD.get(e.source):void 0;if(!t)return;let n=DD(e.data);if(n)for(let e of t)e(n)});function AD(e,t){let n=null,r=()=>{if(!n)return;let e=kD.get(n);e?.delete(t),e?.size||kD.delete(n),n=null},i=()=>{if(r(),n=e.contentWindow,!n)return;let i=kD.get(n)??new Set;i.add(t),kD.set(n,i)};return i(),e.addEventListener(`load`,i),()=>{e.removeEventListener(`load`,i),r()}}function jD(e,t){e?.contentWindow?.postMessage({source:`design-viewer`,...t},`*`)}function MD(e){jD(e,{type:`canvas`})}function ND(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=getComputedStyle(n),r=e=>/(auto|scroll|overlay)/.test(e),i=r(e.overflowY)&&n.scrollHeight>n.clientHeight,a=r(e.overflowX)&&n.scrollWidth>n.clientWidth;if(i||a){n.scrollBy({left:a?t.deltaX:0,top:i?t.deltaY:0,behavior:`instant`});return}}window.scrollBy({left:t.deltaX,top:t.deltaY,behavior:`instant`})}function PD(e,t){jD(e,{type:`theme`,theme:t})}function FD(e){e&&(e.src=e.src)}var ID=(()=>{if(Pg)return``;let{protocol:e,hostname:t,port:n}=window.location,r=t===`localhost`?`127.0.0.1`:t===`127.0.0.1`?`localhost`:null;return r?`${e}//${r}${n?`:${n}`:``}`:``})();function LD(e,t,n){let[r=``,i=``]=e.split(`?`),a=new URLSearchParams(i);a.set(`theme`,t);for(let[e,t]of Object.entries(n??{}))a.set(e,t);return`${r.startsWith(`/`)?ID:``}${r}?${a.toString()}`}function RD(e){return new URL(e,document.baseURI).toString()}function zD(e,t,n,r,i){if(e.form){eT(`Forms are not sent from a screen`,void 0,`info`);return}if(e.path===null){if(!iD(e.href)||!/^(https?|mailto):/i.test(e.href.trim())){eT(`Link not opened`,e.href.slice(0,200),`info`);return}window.open(e.href,`_blank`,`noopener,noreferrer`)||eT(`Link to another site`,e.href,`info`);return}let a=Array.isArray(t)?t:t.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))),o=a.find(e=>e.id===r),s=e.raw===void 0?e.path:uT(e.raw,o?.routes?.[0]);if(s===null)return;let c=lT(a.map(e=>({routes:(e.routes??[]).map(oT),value:e.id})),s);if(c){c!==r&&n(c);return}let l=s.split(/[?#]/)[0].replace(/\/+$/,``),u=l.slice(l.lastIndexOf(`/`)+1).replace(/\.html?$/,``);try{u=decodeURIComponent(u)}catch{}if(u&&u!==r&&a.some(e=>e.id===u))n(u);else if(e.pushed)return;else i?i(s):eT(`No screen for this link`,s,`info`)}function BD(e,t,n){let r=n_().data,i=i_(!!r?.system).data?.tokens,[a,o]=(0,v.useState)(null),s=(0,v.useRef)({enabled:t,tokens:i,picked:null});s.current={enabled:t,tokens:i,picked:a?.frame??null};let c=(0,v.useRef)(n.onEscape);c.current=n.onEscape;let l=(0,v.useRef)(e);l.current=e;let u=(0,v.useRef)(new Map),d=(e,t=!1)=>{let{enabled:n,tokens:r}=s.current,i=u.current.get(e);(t||i?.on!==n||i.tokens!==r)&&(u.current.set(e,{on:n,tokens:r}),jD(e,{type:`inspect`,on:n,tokens:n?r??[]:void 0}))};(0,v.useEffect)(()=>{for(let t of e)d(t);for(let t of u.current.keys())e.includes(t)||u.current.delete(t)},[e,t,i]),(0,v.useEffect)(()=>{let t=e.map(e=>AD(e,t=>{if(t.type===`ready`)s.current.enabled?d(e,!0):u.current.set(e,{on:!1});else if(t.type===`inspect`){if(t.info&&(s.current.enabled||s.current.picked===e)){for(let t of l.current)t!==e&&jD(t,{type:`inspect-select`,ref:null});o({info:t.info,frame:e})}else o(t=>t?.frame===e?null:t)}else t.type===`inspect-escape`&&c.current()}));return()=>{for(let e of t)e()}},[e]);let f=a&&e.includes(a.frame)?a.frame:null;return{info:f?a.info:null,frame:f,select(e){if(e===null){for(let e of l.current)jD(e,{type:`inspect-select`,ref:null});o(null)}else a&&jD(a.frame,{type:`inspect-select`,ref:e})}}}function VD(e){let[t,n]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=e=>e===`Meta`||e===`Control`,r=!1,i=!1,a,o=()=>{r=!1,clearTimeout(a),n(!1)},s=e=>{if(t(e)){if(r)return;r=!0,i=!1,a=setTimeout(()=>{r&&!i&&n(!0)},150)}else r&&(i=!0,clearTimeout(a),n(!1))},c=e=>s(e.key),l=e=>{t(e.key)&&o()};window.addEventListener(`keydown`,c,!0),window.addEventListener(`keyup`,l,!0),window.addEventListener(`blur`,o);let u=e.map(e=>AD(e,e=>{e.type===`key`?e.down?s(e.name):t(e.name)&&o():e.type===`blur`&&o()}));return()=>{window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`keyup`,l,!0),window.removeEventListener(`blur`,o);for(let e of u)e();clearTimeout(a)}},[e]),t}function HD({title:e,children:t,right:n}){return(0,R.jsxs)(`section`,{className:`border-t border-rule pb-2 first:border-t-0`,children:[(0,R.jsxs)(`div`,{className:`flex h-9 items-center justify-between px-4 text-[12px] font-medium text-muted`,children:[e,n]}),t]})}function UD({label:e,children:t}){return(0,R.jsxs)(`div`,{className:`grid min-h-7 grid-cols-[92px_minmax(0,1fr)] items-center gap-x-3 px-4 py-0.5 text-[12.5px]`,children:[(0,R.jsx)(`span`,{className:`text-muted`,children:e}),(0,R.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-ink`,children:t})]})}function WD({name:e}){return e?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void iT(`var(${e})`,`Token copied`),title:`Copy var()`,className:`shrink-0 cursor-pointer truncate rounded-[4px] border-0 bg-action-soft px-1.5 py-px font-mono text-[11px] text-action`,children:e}):null}function GD({children:e,title:t}){return(0,R.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[12px]`,title:t,children:e})}function KD({label:e,color:t}){return(0,R.jsxs)(UD,{label:e,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:t.css}}),(0,R.jsx)(GD,{title:t.css,children:t.value}),(0,R.jsx)(WD,{name:t.token})]})}var qD=e=>e?String(e):`–`;function JD({label:e,values:t,className:n,children:r}){let[i,a,o,s]=t;return(0,R.jsxs)(`div`,{className:Y(`relative grid grid-cols-[28px_minmax(0,1fr)_28px] grid-rows-[20px_auto_20px] rounded-[4px]`,n),children:[(0,R.jsx)(`span`,{className:`absolute top-1 left-1.5 text-[9.5px] tracking-wide text-muted uppercase`,children:e}),(0,R.jsx)(`span`,{className:`col-start-2 self-center text-center`,children:qD(i)}),(0,R.jsx)(`span`,{className:`row-start-2 self-center text-center`,children:qD(s)}),(0,R.jsx)(`div`,{className:`row-start-2 col-start-2`,children:r}),(0,R.jsx)(`span`,{className:`row-start-2 col-start-3 self-center text-center`,children:qD(a)}),(0,R.jsx)(`span`,{className:`row-start-3 col-start-2 self-center text-center`,children:qD(o)})]})}function YD({info:e}){let t={w:Math.max(0,e.rect.w-e.border[1]-e.border[3]-e.padding[1]-e.padding[3]),h:Math.max(0,e.rect.h-e.border[0]-e.border[2]-e.padding[0]-e.padding[2])};return(0,R.jsx)(`div`,{className:`px-4 pt-1 pb-2 font-mono text-[11px] text-ink2`,children:(0,R.jsx)(JD,{label:`margin`,values:e.margin,className:`border border-dashed border-rule-strong bg-[#f6b26b]/15`,children:(0,R.jsx)(JD,{label:`border`,values:e.border,className:`border border-rule-strong bg-[#f9e27d]/15`,children:(0,R.jsx)(JD,{label:`padding`,values:e.padding,className:`border border-rule-strong bg-[#93c47d]/20`,children:(0,R.jsxs)(`div`,{className:`flex h-8 items-center justify-center rounded-[3px] border border-rule-strong bg-[#6fa8dc]/25 text-ink`,children:[Math.round(t.w*100)/100,` × `,Math.round(t.h*100)/100]})})})})})}function XD({info:e,onSelect:t}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-4 pb-2`,children:[e.path.slice(-4).map((e,n)=>(0,R.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`cursor-pointer rounded-[4px] border-0 bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2 hover:text-ink`,children:e.label}),(0,R.jsx)(X,{name:`chevron-right`,size:11,className:`text-muted`})]},n)),(0,R.jsx)(`span`,{className:`rounded-[4px] bg-action-soft px-1.5 py-0.5 font-mono text-[11px] text-action`,children:e.label})]})}function ZD({info:e,onSelect:t,onClose:n,active:r}){return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[320px] shrink-0 flex-col overflow-hidden border-l border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex h-[46px] shrink-0 items-center justify-between border-b border-rule pr-2 pl-4`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[14px] font-semibold`,children:[(0,R.jsx)(X,{name:`pointer`,size:15,className:`text-action`}),` Inspect`]}),(0,R.jsx)(N_,{icon:`x`,label:`Close inspector (I)`,onClick:n})]}),e?(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto`,children:[(0,R.jsxs)(HD,{title:`Element`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 pb-2`,children:[(0,R.jsx)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:e.component?.owners[0]?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:[`<`,e.component.owners[0],`>`]}),(0,R.jsx)(`span`,{className:`truncate font-mono text-[12px] text-muted`,children:e.tag})]}):(0,R.jsx)(`span`,{className:`truncate font-mono text-[14px] font-medium text-ink`,children:e.label})}),e.component&&e.component.owners.length>1?(0,R.jsxs)(`span`,{className:`truncate text-[12px] text-muted`,children:[`in `,e.component.owners.slice(1).join(` ← `)]}):null,e.component?.file?(0,R.jsx)(`button`,{type:`button`,onClick:()=>void iT(e.component.file,`Path copied`),className:`w-fit max-w-full cursor-pointer truncate border-0 bg-transparent p-0 text-left font-mono text-[11.5px] text-muted hover:text-ink2`,title:`Copy path`,children:e.component.file}):null,e.text?(0,R.jsxs)(`span`,{className:`line-clamp-2 text-[12.5px] text-ink2`,children:[`“`,e.text,`”`]}):null]}),(0,R.jsx)(XD,{info:e,onSelect:t})]}),(0,R.jsxs)(HD,{title:`Box`,children:[(0,R.jsx)(YD,{info:e}),(0,R.jsx)(UD,{label:`Size`,children:(0,R.jsxs)(GD,{children:[e.rect.w,` × `,e.rect.h]})}),(0,R.jsx)(UD,{label:`Position`,children:(0,R.jsxs)(GD,{children:[`x `,e.rect.x,` · y `,e.rect.y]})})]}),e.layout.length?(0,R.jsx)(HD,{title:`Layout`,children:e.layout.map(([e,t])=>(0,R.jsx)(UD,{label:e,children:(0,R.jsx)(GD,{title:t,children:t})},e))}):null,e.typography?(0,R.jsxs)(HD,{title:`Typography`,children:[(0,R.jsxs)(UD,{label:`Font`,children:[(0,R.jsx)(GD,{title:e.typography.family,children:e.typography.family.split(`,`)[0]?.replace(/["']/g,``)}),(0,R.jsx)(WD,{name:e.typography.familyToken})]}),(0,R.jsxs)(UD,{label:`Size`,children:[(0,R.jsxs)(GD,{children:[e.typography.size,` / `,e.typography.lineHeight]}),(0,R.jsx)(WD,{name:e.typography.sizeToken})]}),(0,R.jsx)(UD,{label:`Weight`,children:(0,R.jsx)(GD,{children:e.typography.weight})}),e.typography.letterSpacing===`normal`?null:(0,R.jsx)(UD,{label:`Tracking`,children:(0,R.jsx)(GD,{children:e.typography.letterSpacing})}),(0,R.jsx)(KD,{label:`Color`,color:e.typography.color}),e.typography.align===`start`?null:(0,R.jsx)(UD,{label:`Align`,children:(0,R.jsx)(GD,{children:e.typography.align})}),e.typography.transform?(0,R.jsx)(UD,{label:`Transform`,children:(0,R.jsx)(GD,{children:e.typography.transform})}):null]}):null,Object.values(e.appearance).some(Boolean)?(0,R.jsxs)(HD,{title:`Appearance`,children:[e.appearance.background?(0,R.jsx)(KD,{label:`Background`,color:e.appearance.background}):null,e.appearance.backgroundImage?(0,R.jsx)(UD,{label:`Image`,children:(0,R.jsx)(GD,{title:e.appearance.backgroundImage,children:e.appearance.backgroundImage})}):null,e.appearance.border?(0,R.jsxs)(UD,{label:`Border`,children:[(0,R.jsx)(`span`,{className:`size-3.5 shrink-0 rounded-[3px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.12)]`,style:{background:e.appearance.border.color.css}}),(0,R.jsxs)(GD,{children:[e.appearance.border.width,` `,e.appearance.border.style,` `,e.appearance.border.color.value]}),(0,R.jsx)(WD,{name:e.appearance.border.color.token})]}):null,e.appearance.radius?(0,R.jsxs)(UD,{label:`Radius`,children:[(0,R.jsx)(GD,{children:e.appearance.radius.value}),(0,R.jsx)(WD,{name:e.appearance.radius.token})]}):null,e.appearance.shadow?(0,R.jsxs)(UD,{label:`Shadow`,children:[(0,R.jsx)(GD,{title:e.appearance.shadow.value,children:e.appearance.shadow.value}),(0,R.jsx)(WD,{name:e.appearance.shadow.token})]}):null,e.appearance.opacity?(0,R.jsx)(UD,{label:`Opacity`,children:(0,R.jsx)(GD,{children:e.appearance.opacity})}):null]}):null,e.classes.length?(0,R.jsx)(HD,{title:`Classes`,right:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void iT(e.classes.join(` `),`Classes copied`),className:`cursor-pointer border-0 bg-transparent text-[12px] text-muted hover:text-ink2`,children:`Copy`}),children:(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 px-4 pb-1`,children:e.classes.map(e=>(0,R.jsx)(`span`,{className:`rounded-[4px] bg-soft2 px-1.5 py-0.5 font-mono text-[11px] text-ink2`,children:e},e))})}):null,e.attributes.length?(0,R.jsx)(HD,{title:`Attributes`,children:e.attributes.map(([e,t])=>(0,R.jsx)(UD,{label:e,children:(0,R.jsx)(GD,{title:t,children:t})},e))}):null,e.children.length?(0,R.jsx)(HD,{title:`Children · ${e.children.length}`,children:(0,R.jsx)(`div`,{className:`flex flex-col px-2 pb-1`,children:e.children.map((e,n)=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(e.ref),className:`flex h-7 cursor-pointer items-center gap-2 rounded-[6px] border-0 bg-transparent px-2 text-left font-mono text-[12px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(X,{name:`chevron-right`,size:12,className:`text-muted`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.label})]},n))})}):null]}):(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-6 py-10 text-center`,children:[(0,R.jsx)(X,{name:`pointer`,size:22,className:`text-muted`}),(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:r?`Click an element in any screen.`:`Hold ${av} to highlight, click to inspect.`}),(0,R.jsx)(`span`,{className:`text-[12.5px] leading-[1.5] text-muted`,children:`Hover shows margin, padding and content. Clicks go to the inspector, not the screen.`}),(0,R.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-[12px] text-muted`,children:[(0,R.jsx)(S_,{children:`I`}),` toggle · hold `,(0,R.jsx)(S_,{children:av}),` · `,(0,R.jsx)(S_,{children:`esc`}),` clear`]})]}),e?(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-rule bg-soft px-4 py-2.5`,children:(0,R.jsx)(A_,{icon:`copy`,onClick:()=>void iT(e.css,`CSS copied`),className:`grow`,children:`Copy CSS`})}):null]})}function QD({issues:e,className:t}){return(0,R.jsx)(`div`,{className:Y(`flex flex-col`,t),children:e.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5 border-t border-rule px-4 py-2.5 text-[13px] first:border-t-0`,children:[(0,R.jsx)(X,{name:e.severity===`error`?`alert`:`info`,size:15,className:Y(`mt-0.5`,e.severity===`error`?`text-danger-text`:`text-action`)}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-ink`,children:e.message}),(0,R.jsxs)(`span`,{className:`font-mono text-[12px] break-all text-muted`,children:[e.file,e.at?` · ${e.at}`:``]})]})]},t))})}function $D({issues:e,title:t=`Problems`}){if(!e.length)return null;let n=e.filter(e=>e.severity===`error`).length;return(0,R.jsxs)(z_,{className:n?`border-danger/40`:void 0,children:[(0,R.jsx)(B_,{title:t,count:e.length,sub:n?`${n} blocking`:`warnings`}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(QD,{issues:e})})]})}var eO=[.2,.7,.2,1];function tO({open:e,side:t,width:n,children:r}){return(0,R.jsx)(ed,{initial:!1,children:e?(0,R.jsx)(Gf.div,{initial:{width:0,opacity:.6},animate:{width:n,opacity:1},exit:{width:0,opacity:.6},transition:{duration:.22,ease:eO},className:Y(`flex min-h-0 shrink-0 overflow-hidden`,t===`right`?`justify-start`:`justify-end`),children:(0,R.jsx)(`div`,{className:`flex min-h-0 shrink-0`,style:{width:n},children:r})},`panel`):null})}function nO({title:e=`Nothing here`,text:t}){let n=!!$g().scope;return(0,R.jsx)(tv,{title:e,text:t??`This address does not match a canvas or a page of the design system.`,action:n?void 0:(0,R.jsx)(P_,{to:`/`,children:`All canvases`})})}var rO=.1,iO=(e,t=rO)=>Math.min(8,Math.max(t,e)),aO=class{camera={x:0,y:0,z:1};minZoom=rO;listeners=new Set;animation=0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}set(e){this.camera={x:e.x,y:e.y,z:iO(e.z,this.minZoom)};for(let e of this.listeners)e(this.camera)}interrupt(){cancelAnimationFrame(this.animation),this.animation=0}panBy(e,t){this.interrupt();let{x:n,y:r,z:i}=this.camera;this.set({x:n+e,y:r+t,z:i})}zoomAt(e,t,n){this.interrupt();let{x:r,y:i,z:a}=this.camera,o=iO(a*n,this.minZoom),s=(e-r)/a,c=(t-i)/a;this.set({x:e-s*o,y:t-c*o,z:o})}animateTo(e,t=320){this.interrupt();let n={...this.camera},r={...e,z:iO(e.z,this.minZoom)};if(t<=0||matchMedia(`(prefers-reduced-motion: reduce)`).matches){this.set(r);return}let i=performance.now(),a=e=>{let o=Math.min(1,(e-i)/t),s=1-(1-o)**3,c=n.z*(r.z/n.z)**s,l=n.z===r.z?s:(c-n.z)/(r.z-n.z);this.set({x:n.x+(r.x-n.x)*l,y:n.y+(r.y-n.y)*l,z:c}),this.animation=o<1?requestAnimationFrame(a):0};this.animation=requestAnimationFrame(a)}toWorld(e,t){let{x:n,y:r,z:i}=this.camera;return{x:(e-n)/i,y:(t-r)/i}}};function oO(e,t,n,r=72,i=1,a=rO){let o=iO(Math.min((t-r*2)/Math.max(e.w,1),(n-r*2)/Math.max(e.h,1),i),a),s=(e,t,n)=>t*o<=n-r*2?n/2-(e+t/2)*o:r-e*o;return{z:o,x:s(e.x,e.w,t),y:s(e.y,e.h,n)}}function sO(e,t){return e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y}function cO({items:e,value:t,onChange:n,label:r,stretch:i,size:a=`ctrl`}){let o=(0,v.useId)();return(0,R.jsx)(`div`,{role:`group`,"aria-label":r,className:Y(`shrink-0 items-center gap-0.5 rounded-[6px] bg-track p-[3px]`,a===`ctrl`?`h-ctrl`:`h-7`,i?`flex`:`inline-flex`),children:e.map(e=>{let r=e.value===t;return(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":r,title:e.title,onClick:()=>n(e.value),className:Y(`relative flex h-full cursor-pointer items-center justify-center whitespace-nowrap rounded-[4px] border-0 bg-transparent font-medium transition-colors`,a===`ctrl`?`px-2.5 text-ctrl`:`px-2 text-[12.5px]`,i&&`flex-1`,r?`text-ink`:`text-muted hover:text-ink2`),children:[r?(0,R.jsx)(Gf.span,{layoutId:o,className:`absolute inset-0 z-0 rounded-[4px] bg-surface shadow-[0_1px_2px_rgba(0,0,0,0.10)]`,transition:{type:`spring`,stiffness:520,damping:42}}):null,(0,R.jsx)(`span`,{className:`relative z-[1] flex items-center gap-1.5`,children:e.label})]},e.value)})})}var lO=5500,uO=350,dO=(e,t)=>e>=window.innerWidth/2&&t<=window.innerHeight/2;function fO({frame:e,note:t,badge:n,children:r}){let[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(0),g=(0,v.useRef)(void 0),_=(0,v.useRef)(void 0),y=e=>{a(!0),clearTimeout(g.current),g.current=setTimeout(()=>a(!1),e)},b=(e,t)=>{let n=e>=0&&dO(e,t);clearTimeout(_.current),n?s(!0):_.current=setTimeout(()=>s(!1),uO)};(0,v.useEffect)(()=>{if(!e)return;let t=()=>{jD(e,{type:`pointer`}),y(lO),h(e=>e+1)};e.addEventListener(`load`,t);let n=AD(e,t=>{if(t.type!==`pointer`)return;if(d(!0),t.x<0)return b(-1,-1);let n=e.getBoundingClientRect(),r=n.left+t.x,i=n.top+t.y;t.down&&dO(r,i)?y(lO):b(r,i)});return()=>{e.removeEventListener(`load`,t),n()}},[e]),(0,v.useEffect)(()=>{let e=e=>b(e.clientX,e.clientY),t=e=>{e.relatedTarget||b(-1,-1)};return window.addEventListener(`pointermove`,e,{passive:!0}),document.addEventListener(`pointerout`,t),()=>{window.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerout`,t),clearTimeout(g.current),clearTimeout(_.current)}},[]),(0,v.useEffect)(()=>{if(u)return;let e=document.documentElement,t=()=>p(!0),n=()=>p(!1);return e.addEventListener(`pointerenter`,t),e.addEventListener(`pointerleave`,n),()=>{e.removeEventListener(`pointerenter`,t),e.removeEventListener(`pointerleave`,n)}},[u]);let x=i||o||c||!u&&f;return(0,R.jsxs)(R.Fragment,{children:[n?(0,R.jsx)(Gf.button,{type:`button`,"aria-label":`Show the page's notice`,initial:!1,animate:x?{opacity:0,scale:.8}:{opacity:1,scale:1},transition:{duration:.2,delay:x?0:.25},onClick:()=>y(lO),tabIndex:x?-1:0,className:Y(`absolute top-3 right-3 inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full border border-rule bg-surface/90 px-2.5 text-[11.5px] text-muted shadow-[0_1px_3px_rgb(0_0_0/0.08)] backdrop-blur-sm hover:text-ink2`,x&&`pointer-events-none`),children:n}):null,(0,R.jsx)(Gf.div,{initial:{opacity:0,scale:.94,y:-4},animate:x?{opacity:1,scale:1,y:0}:{opacity:0,scale:.97,y:-2},transition:x?{type:`spring`,stiffness:420,damping:30}:{duration:.45,ease:`easeOut`},style:{transformOrigin:`top right`},className:Y(`absolute top-3 right-3 flex max-w-[calc(100%-24px)] flex-col items-end`,!x&&`pointer-events-none`),"aria-hidden":!x||void 0,onFocus:()=>l(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||l(!1)},children:(0,R.jsxs)(`div`,{className:`relative flex max-w-full flex-col gap-1 rounded-[8px] border border-rule bg-surface p-1 shadow-pop`,children:[m>0?(0,R.jsx)(Gf.span,{"aria-hidden":!0,initial:{opacity:.55,scale:1},animate:{opacity:0,scale:1.18},transition:{duration:1.1,ease:`easeOut`,delay:.15},className:`pointer-events-none absolute -inset-px rounded-[8px] border-2 border-action`},m):null,r?(0,R.jsx)(`div`,{className:`flex items-center gap-1`,children:r}):null,t?(0,R.jsx)(`div`,{className:`px-2 pb-1 text-[11.5px] leading-snug text-muted`,children:t}):null]})})]})}var pO=(e,t,n)=>`/c/${encodeURIComponent(e)}/full/${encodeURIComponent(t)}?theme=${n}`;function mO(e,t,n){let{frameSandbox:r}=$g(),{base:i}=le();return t?t.kind===`url`?t.url:RD(r?`${i}${pO(e,t.id,t.theme??n)}`:LD(t.url,t.theme??n)):null}function hO({canvasId:e,itemId:t}){let{data:n,error:r,isLoading:i}=r_(e),[,a]=I(),{frameSandbox:o,frameAllow:s,slots:c}=$g(),l=b_(),u=(0,v.useRef)(null),[d,f]=(0,v.useState)(null),p=(0,v.useCallback)(e=>{u.current=e,f(e)},[]),m=new URLSearchParams(window.location.search).get(`theme`),h=n?n.pages.flatMap(e=>e.sections.flatMap(e=>e.items.filter(e=>e.kind===`screen`||e.kind===`url`))):[],g=h.find(e=>e.id===t),_=(g?.kind===`screen`?g.theme:void 0)??(m===`light`||m===`dark`?m:n?.theme??l),y=g?g.kind===`screen`?LD(g.url,_):g.url:``,b=`/c/${encodeURIComponent(e)}`;return(0,v.useEffect)(()=>{g&&(document.title=`${g.title} · ${n?.title??``}`)},[g,n?.title]),(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a(b)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,b]),(0,v.useEffect)(()=>{let r=u.current;if(r&&g?.kind===`screen`)return AD(r,r=>{if(r.type===`keydown`&&r.code===`Escape`)a(b);else if(r.type===`go`){let t=r.target.includes(`/`)?r.target.split(`/`)[1]:r.target;h.some(e=>e.id===t)&&a(pO(e,t,_),{replace:!0})}else r.type===`link`&&n&&zD(r,n,t=>a(pO(e,t,_),{replace:!0}),t)})},[y,g?.kind]),r?(0,R.jsx)(nO,{title:`Canvas not found`,text:r.message}):i||!n?(0,R.jsx)(`div`,{className:`h-dvh bg-surface`}):g?(0,R.jsxs)(`div`,{className:`fixed inset-0 bg-surface`,children:[(0,R.jsx)(`iframe`,{ref:p,src:y,title:g.title,allow:s,sandbox:o,className:`block h-full w-full border-0`,style:{colorScheme:_},onLoad:()=>g.kind===`screen`&&PD(u.current,_)},`${g.id}:${g.kind===`screen`?g.rev:g.url}`),(0,R.jsxs)(fO,{frame:d,note:c.fullPlate?.note,badge:c.fullPlate?.badge,children:[(0,R.jsxs)(ye,{href:b,className:`flex h-8 min-w-0 items-center gap-2 rounded-[6px] px-2 text-[12.5px] text-ink2 no-underline hover:bg-soft2 hover:text-ink`,children:[(0,R.jsx)(X,{name:`x`,size:14}),(0,R.jsxs)(`span`,{className:`truncate`,children:[`Back to `,n.title]}),(0,R.jsx)(S_,{children:`esc`})]}),c.fullPlate?.actions]})]}):(0,R.jsx)(nO,{title:`Screen not found`,text:`No screen "${t}" on this canvas.`})}function gO(e){return e.kind===`note`?`note`:e.kind===`image`?`image`:e.kind===`url`?`globe`:e.frame.width<600?`smartphone`:e.frame.width<1100?`tablet`:`monitor`}function _O(e,t){return`/c/${encodeURIComponent(e.id)}/p/${encodeURIComponent(t.id)}`}function vO({canvas:e,page:t,store:n,onPick:r}){let i=d_(n,e=>e.selected),a=d_(n,e=>e.frames);return(0,R.jsxs)(`aside`,{"data-ui":!0,className:`flex w-[264px] shrink-0 flex-col overflow-hidden border-r border-rule bg-surface`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-rule px-4 py-3.5`,children:[(0,R.jsx)(`div`,{className:`truncate text-[14px] font-semibold`,children:e.title}),e.description?(0,R.jsx)(`div`,{className:`line-clamp-3 text-[12.5px] leading-[1.45] text-muted`,children:e.description}):null]}),(0,R.jsxs)(`div`,{className:`min-h-0 grow overflow-y-auto pb-4`,children:[e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:`Pages`}),(0,R.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2`,children:e.pages.map(n=>{let r=n.sections.reduce((e,t)=>e+t.items.filter(e=>e.kind===`screen`||e.kind===`url`).length,0);return(0,R.jsxs)(ye,{href:_O(e,n),className:Y(`flex h-8 items-center gap-2 rounded-[6px] px-2.5 text-[13.5px] no-underline transition-colors focus-visible:outline-offset-[-2px]`,n.id===t.id?`bg-soft2 font-medium text-ink`:`text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:n.title}),(0,R.jsx)(`span`,{className:`text-[12px] text-muted tabular`,children:r})]},n.id)})})]}):null,(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.pages.length>1?t.title:`Layers`}),(0,R.jsx)(`div`,{className:`flex flex-col px-2`,children:t.sections.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.title?(0,R.jsxs)(`div`,{className:`flex h-7 items-center gap-2 px-2.5 pt-1 text-[12px] font-medium text-ink2`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.title}),(0,R.jsx)(R_,{value:e.items.length})]}):null,e.items.map(t=>{let n=(a[t.id]?.errors.length??0)>0||t.kind===`screen`&&t.missing;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.id),className:Y(`flex h-8 w-full cursor-pointer items-center gap-2 rounded-[6px] border-0 px-2.5 text-left text-[13px] transition-colors focus-visible:outline-offset-[-2px]`,e.title&&`pl-4`,i===t.id?`bg-action-soft text-ink`:`bg-transparent text-ink2 hover:bg-soft2`),children:[(0,R.jsx)(X,{name:gO(t),size:15,className:`text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:t.title||(t.kind===`note`?`Note`:t.id)}),n?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`}):null]},t.id)})]},e.id))})]})]})}function yO({canvas:e,page:t,theme:n,onTheme:r,sidebar:i,onSidebar:a,onPlay:o,canPlay:s,inspect:c,onInspect:l}){let[,u]=I(),{slots:d,scope:f}=$g(),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=vw(p,m,[e.title,t?.title,e.pages.length]);return(0,R.jsxs)(_w,{value:h,children:[(0,R.jsxs)(gw,{children:[d.barStart,d.brand?d.brand:f?(0,R.jsx)(mw,{}):(0,R.jsx)(kx,{content:`All canvases`,children:(0,R.jsx)(ye,{href:`/`,className:`flex items-center`,"aria-label":`All canvases`,children:(0,R.jsx)(mw,{})})}),(0,R.jsx)(N_,{icon:`panel-left`,label:i?`Hide sidebar (⌘\\)`:`Show sidebar (⌘\\)`,onClick:()=>a(!i)}),(0,R.jsxs)(`div`,{ref:p,className:`flex min-w-0 items-center gap-1.5 text-[14px]`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate font-semibold`,children:e.title}),t&&e.pages.length>1?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(X,{name:`chevron-right`,size:14,className:`shrink-0 text-muted`}),(0,R.jsxs)(ow,{width:240,trigger:(0,R.jsxs)(`button`,{type:`button`,className:`flex h-ctrl cursor-pointer items-center gap-1 rounded-[6px] border-0 bg-transparent px-2 text-[14px] text-ink2 hover:bg-soft2`,children:[(0,R.jsx)(`span`,{"data-fit":!0,className:`truncate`,children:t.title}),(0,R.jsx)(X,{name:`chevron-down`,size:14,className:`text-muted`})]}),children:[(0,R.jsx)(dw,{children:`Pages`}),e.pages.map(n=>(0,R.jsxs)(lw,{active:n.id===t.id,onSelect:()=>u(_O(e,n)),children:[(0,R.jsx)(X,{name:`file`,size:15,className:`text-muted`}),n.title]},n.id))]})]}):null]}),(0,R.jsxs)(`div`,{ref:m,className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(cO,{label:`Screen theme`,value:n,onChange:r,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:15}),title:`Light screens`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:15}),title:`Dark screens`}]}),(0,R.jsx)(SO,{on:c,onChange:l,compact:h}),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Play `,(0,R.jsx)(S_,{children:`P`})]}),children:(0,R.jsx)(A_,{kind:`secondary`,icon:`play`,onClick:o,disabled:!s,"aria-label":`Play`,className:h?`w-ctrl px-0`:void 0,children:h?null:`Play`})}),(0,R.jsx)(Mx,{width:180,label:`Search`,compact:h}),(0,R.jsx)(pw,{}),d.barEnd]})]}),d.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:d.belowBar}):null]})}function bO({canvas:e,store:t,layoutItems:n,theme:r,onPlay:i,inspect:a}){let o=d_(t,e=>e.selected),s=n.find(e=>e.id===o);return(0,R.jsx)(`div`,{"data-ui":!0,className:`pointer-events-none absolute inset-x-0 bottom-5 z-20 flex justify-center px-4`,children:(0,R.jsx)(ed,{children:s?(0,R.jsx)(xO,{canvas:e,store:t,item:s,theme:r,onPlay:i,inspect:a},`bar`):null})})}function xO({canvas:e,store:t,item:n,theme:r,onPlay:i,inspect:a}){let{slots:o}=$g(),s=d_(t,e=>e.frames[n.id]),c=mO(e.id,n.kind===`screen`||n.kind===`url`?n:void 0,r),l=n.kind===`screen`||n.kind===`url`,u=()=>FD(document.querySelector(`[data-item="${CSS.escape(n.id)}"] iframe`)),d=s?.errors??[];return(0,R.jsxs)(Gf.div,{initial:{opacity:0,y:10,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.98,transition:{duration:.14,ease:`easeIn`}},transition:{type:`spring`,duration:.26,bounce:.12},className:`relative flex w-fit max-w-[95%] min-w-0 flex-col`,children:[(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-x-5 bottom-full flex justify-center`,children:(0,R.jsx)(ed,{children:l&&a?(0,R.jsx)(Gf.div,{initial:{y:`100%`,opacity:0},animate:{y:0,opacity:.9},exit:{y:`100%`,opacity:0},transition:{type:`spring`,duration:.28,bounce:.15},className:`flex h-[22px] min-w-0 items-center rounded-t-[7px] border border-b-0 border-rule bg-surface/80 px-3 text-[11.5px] whitespace-nowrap text-muted backdrop-blur-md`,children:(0,R.jsx)(`span`,{className:`truncate`,children:`Click an element to inspect it`})},`inspect`):null})}),(0,R.jsxs)(`div`,{className:`pointer-events-auto relative flex max-w-full flex-col overflow-hidden rounded-[10px] border border-rule bg-surface shadow-pop`,children:[d.length?(0,R.jsxs)(`div`,{className:`flex max-h-40 items-start gap-2 overflow-y-auto border-b border-rule bg-danger-soft px-3.5 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px`}),(0,R.jsx)(`span`,{className:`min-w-0`,children:d.join(`
125
+ `)})]}):null,(0,R.jsxs)(`div`,{className:`flex h-[44px] items-center gap-1 pr-1.5 pl-3.5 [&>:not(:first-child)]:shrink-0`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate pr-2 text-[13.5px] font-medium`,children:n.title||n.id}),l?(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Play `,(0,R.jsx)(S_,{children:`↵`})]}),children:(0,R.jsx)(N_,{icon:`play`,label:`Play`,onClick:()=>i(n.id)})}):null,c?(0,R.jsx)(kx,{content:`Open in a new tab`,children:(0,R.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer`,"aria-label":`Open in a new tab`,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,children:(0,R.jsx)(X,{name:`external`,size:16})})}):null,l?(0,R.jsx)(kx,{content:`Reload`,children:(0,R.jsx)(N_,{icon:`refresh`,label:`Reload`,onClick:u})}):null,n.kind===`screen`?(0,R.jsx)(kx,{content:`Copy source path`,children:(0,R.jsx)(N_,{icon:`copy`,label:`Copy source path`,onClick:()=>void iT(n.file,`Path copied`)})}):null,o.selectionActions?.(e.id,n),(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Zoom to `,(0,R.jsx)(S_,{children:`⇧2`})]}),children:(0,R.jsx)(N_,{icon:`fit`,label:`Zoom to`,onClick:()=>window.dispatchEvent(new CustomEvent(`design:focus`,{detail:{canvas:e.id,item:n.id}}))})})]})]})]})}function SO({on:e,onChange:t,compact:n=!1}){return(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Inspect elements `,(0,R.jsx)(S_,{children:`I`})]}),children:(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e,"aria-label":`Inspect elements`,onClick:()=>t(!e),className:Y(`inline-flex h-ctrl shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-[6px] border text-ctrl font-medium`,n?`w-ctrl px-0`:`px-ctrl`,e?`border-action-line bg-action-soft text-action`:`border-rule-strong bg-surface text-ink hover:bg-soft`),children:[(0,R.jsx)(X,{name:`pointer`,size:15}),n?null:`Inspect`]})})}var CO=280,wO=96,TO=150,EO=110,DO=720,OO=e=>e.kind===`screen`||e.kind===`url`;function kO(e,t){let n=t[e.id];if(e.kind===`screen`||e.kind===`url`){let t=e.frame.width;if(e.frame.height!==`auto`)return{w:t,h:e.frame.height};let r=e.kind===`screen`?e.measuredHeight:void 0;return{w:t,h:n?.h??r??900}}if(e.kind===`note`)return{w:e.width,h:n?.h??Math.max(80,Math.ceil(e.text.length/38)*26+40)};let r=e.width??n?.w??480;return{w:r,h:n?.w?n.h/n.w*r:n?.h??r*.62}}function AO(e,t){return!e.title&&!e.description?0:t[`section:${e.id}`]?.h??(e.title?56:0)+(e.description?60:0)}function jO(e,t){let n=[],r=[];if(e.layout===`free`){let r=0;for(let i of e.sections)for(let e of i.items){let{w:a,h:o}=kO(e,t),s=e.x??r,c=e.y??0;r=Math.max(r,s+a+wO),n.push({item:e,section:i,x:s,y:c,w:a,h:o})}}else{let i=0;for(let a of e.sections){let e=AO(a,t),o=i,s=i+(e?e+EO:0),c=0,l=0,u=0,d=0;for(let e of a.items){a.columns&&d===a.columns&&(s+=l+TO,c=0,l=0,d=0);let{w:r,h:i}=kO(e,t);n.push({item:e,section:a,x:c,y:s,w:r,h:i}),c+=r+wO,u=Math.max(u,c-wO),l=Math.max(l,i),d++}let f=s+l;r.push({section:a,x:0,y:o,w:Math.max(u,e?DO:0),h:f-o,header:e,body:e?e+EO:0}),i=f+CO}}let i=0,a=0,o=0,s=0,c=[...n,...r];return c.length&&(i=Math.min(...c.map(e=>e.x)),a=Math.min(...c.map(e=>e.y)),o=Math.max(...c.map(e=>e.x+e.w)),s=Math.max(...c.map(e=>e.y+e.h))),{items:n,sections:r,bounds:{x:i,y:a,w:o-i,h:s-a}}}function MO(e){return e.items.filter(e=>OO(e.item))}function NO(){return new u_({selected:null,active:null,hovered:null,sizes:{},frames:{},live:[],panning:!1,zoomTiny:!1,frameEls:{},inspecting:!1})}function PO(e,t,n){e.set(e=>{let r=e.sizes[t];return r&&Math.abs(r.h-n.h)<1&&r.w===n.w?e:{...e,sizes:{...e.sizes,[t]:n}}})}function FO(e,t,n){e.set(e=>{let r=e.frames[t]??{ready:!1,errors:[]};return{...e,frames:{...e.frames,[t]:{...r,...n}}}})}function IO(e,t,n){e.set(e=>e.frameEls[t]===n?e:{...e,frameEls:{...e.frameEls,[t]:n}})}function LO(e,t,n=!0){let r=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let i=r.current;if(!i||!n)return;let a=new ResizeObserver(()=>PO(e,t,{h:i.offsetHeight}));return a.observe(i),()=>a.disconnect()},[e,t,n]),r}function RO(e){return e<600?`smartphone`:e<1100?`tablet`:`monitor`}var zO=(0,v.memo)(function({placed:e,mode:t,thumb:n,theme:r,store:i,events:a,capture:o}){let{item:s,x:c,y:l,w:u,h:d}=e,f=(0,v.useRef)(null),{frameSandbox:p,frameAllow:m}=$g(),h=(0,v.useCallback)(e=>{f.current=e,IO(i,s.id,e)},[i,s.id]),g=d_(i,e=>e.frames[s.id]),_=d_(i,e=>e.active===s.id),y=d_(i,e=>e.inspecting&&s.kind===`screen`),b=s.frame.height===`auto`,x=s.kind===`screen`?s.theme??r:r,S=s.kind===`screen`?s.rev:s.url,[C]=(0,v.useState)(x),w=s.kind===`screen`?LD(s.url,C,o?{capture:`1`}:void 0):s.url,T=!!g?.ready,E=t===`off`,D=!E&&!(s.kind===`screen`&&s.missing)&&!!s.url;(0,v.useEffect)(()=>{E&&FO(i,s.id,{ready:!1})},[E,i,s.id]),(0,v.useEffect)(()=>{let e=f.current;if(e&&!E&&s.kind===`screen`)return AD(e,t=>{switch(t.type){case`ready`:FO(i,s.id,{ready:!0}),MD(e);break;case`size`:b&&PO(i,s.id,{h:Math.max(200,t.height)});break;case`error`:{let e=i.get().frames[s.id]?.errors??[],n=OD(e,t.message);n!==e&&FO(i,s.id,{errors:n});break}case`updated`:FO(i,s.id,{errors:[]});break;case`go`:a.onGo(s.id,t.target);break;case`link`:a.onLink(s.id,t);break;case`wheel`:a.onWheel(e,t);break;case`keydown`:t.code===`Escape`&&a.onEscape()}})},[E,s.id,s.kind,b,i,a,w,S]),(0,v.useEffect)(()=>{s.kind===`screen`&&PD(f.current,x)},[x,s.kind]);let O=x===`dark`?`light`:`dark`,k=e=>e?.[x]??e?.[O],A=s.kind===`screen`?k(s.snapshots):void 0,j=n&&s.kind===`screen`?k(s.thumbs)??A:A,M=t===`asleep`&&T&&!!j;return(0,R.jsxs)(`div`,{"data-item":s.id,className:`absolute overflow-clip bg-surface`,style:{left:c,top:l,width:u,height:d,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:[(!T||M)&&j?(0,R.jsx)(`img`,{src:j,alt:``,draggable:!1,loading:`lazy`,decoding:`async`,className:`absolute inset-0 h-full w-full object-cover object-top select-none`}):null,!T&&!j?(0,R.jsx)(BO,{item:s,loading:D}):null,D?(0,R.jsx)(`div`,{className:`absolute inset-0`,style:{contentVisibility:M?`hidden`:`visible`},children:(0,R.jsx)(`iframe`,{ref:h,src:w,title:s.title,allow:m,sandbox:p,className:Y(`absolute top-0 left-0 block border-0 transition-opacity duration-200`,T?`opacity-100`:`opacity-0`),style:{width:u,height:d,colorScheme:x},onLoad:()=>{s.kind===`url`?FO(i,s.id,{ready:!0}):(PD(f.current,x),MD(f.current))}},S)}):null,_||y?null:(0,R.jsx)(`div`,{"data-shield":s.id,className:`absolute inset-0`})]})});function BO({item:e,loading:t}){let n=e.kind===`screen`&&e.missing;return(0,R.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-soft text-muted`,children:[(0,R.jsx)(X,{name:n?`alert`:e.kind===`url`?`globe`:RO(e.frame.width),size:Math.max(24,Math.min(96,e.frame.width/12)),strokeWidth:1.25,className:n?`text-danger-text`:void 0}),(0,R.jsx)(`div`,{className:`max-w-[80%] truncate text-center`,style:{fontSize:Math.max(14,e.frame.width/40)},children:n?`Missing file: ${e.kind===`screen`?e.src:``}`:t?`Loading…`:e.title})]})}var VO=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a}=e,o=LO(t,n.id),s=n.tone===`plain`;return(0,R.jsxs)(`div`,{ref:o,"data-item":n.id,className:Y(`absolute`,s?``:`rounded-[10px] border border-note-line bg-note px-6 py-5 shadow-frame`),style:{left:r,top:i,width:a},children:[n.title?(0,R.jsx)(`div`,{className:`mb-2 font-semibold text-ink`,style:{fontSize:s?26:19},children:n.title}):null,(0,R.jsx)(uD,{text:n.text,className:s?`prose-plain`:`prose-note`})]})}),HO=(0,v.memo)(function({placed:e,store:t}){let{item:n,x:r,y:i,w:a,h:o}=e;return(0,R.jsx)(`div`,{"data-item":n.id,className:`absolute overflow-clip rounded-[6px] bg-surface`,style:{left:r,top:i,width:a,height:o,boxShadow:`0 0 0 1px var(--rule)`},children:n.missing?(0,R.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:20}),` Missing image`]}):(0,R.jsx)(`img`,{src:n.url,alt:n.title,draggable:!1,className:`block h-full w-full object-contain select-none`,onLoad:e=>{let r=e.currentTarget;PO(t,n.id,{w:r.naturalWidth,h:r.naturalHeight})}})})}),UO=(0,v.memo)(function({section:e,x:t,y:n,w:r,store:i}){let a=LO(i,`section:${e.id}`);return!e.title&&!e.description?null:(0,R.jsxs)(`div`,{ref:a,className:`canvas-section absolute`,style:{left:t,top:n,width:Math.min(Math.max(r,720),1400)},children:[e.title?(0,R.jsx)(`div`,{className:`text-[40px] leading-[1.15] font-semibold tracking-[-0.015em] text-ink`,children:e.title}):null,e.description?(0,R.jsx)(`div`,{className:`mt-3 max-w-[1100px]`,children:(0,R.jsx)(uD,{text:e.description,className:`prose-plain`})}):null]})}),WO={phone:{width:390,height:844,label:`Phone`},"phone-sm":{width:375,height:667,label:`Phone S`},"phone-lg":{width:430,height:932,label:`Phone L`},tablet:{width:834,height:1194,label:`Tablet`},"tablet-landscape":{width:1194,height:834,label:`Tablet landscape`},laptop:{width:1280,height:800,label:`Laptop`},desktop:{width:1440,height:900,label:`Desktop`},wide:{width:1920,height:1080,label:`Wide`}};Object.keys(WO);var GO=e=>({"--x":e.x,"--y":e.y,"--w":e.w,"--h":e.h});function KO(e){let t=e.item;if(t.kind!==`screen`&&t.kind!==`url`)return``;let n=t.frame.device?WO[t.frame.device]?.label:void 0,r=`${t.frame.width} × ${t.frame.height===`auto`?`auto`:t.frame.height}`;return n?`${n} · ${r}`:r}var qO=(0,v.memo)(function({placed:e,store:t}){let n=e.item.id,r=d_(t,e=>e.selected===n),i=d_(t,e=>e.frames[n]?.errors.length??0);return(0,R.jsxs)(`div`,{"data-at":``,"data-label":n,style:GO(e),className:Y(`frame-label pointer-events-auto flex cursor-default items-center gap-1.5 overflow-hidden pb-1.5 text-[12.5px] leading-none whitespace-nowrap select-none`,r?`text-ink`:`text-muted hover:text-ink2`),children:[i?(0,R.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-danger`,title:`${i} errors`}):null,(0,R.jsx)(`span`,{className:Y(`min-w-[3ch] truncate`,r?`font-semibold`:`font-medium`),children:e.item.title}),(0,R.jsx)(`span`,{className:`frame-device min-w-0 shrink-[20] truncate text-[11.5px] text-muted opacity-80`,children:KO(e)})]})}),JO=(0,v.memo)(function({placed:e}){return(0,R.jsx)(`div`,{"data-at":``,style:{"--x":e.x,"--y":e.y,"--body":e.body},className:`section-title text-[15px] leading-none font-semibold whitespace-nowrap text-ink select-none`,children:e.section.title})});function YO({placed:e,kind:t}){return(0,R.jsx)(`div`,{"data-at":``,style:GO(e),className:Y(`frame-outline rounded-[1px]`,t===`hover`?`outline outline-[1.5px] outline-action/60`:`outline-2 outline-action outline`)})}function XO({layout:e,view:t,store:n,overlayRef:r}){let i=d_(n,e=>e.selected),a=d_(n,e=>e.active),o=d_(n,e=>e.hovered),s=d_(n,e=>e.zoomTiny),c=(0,v.useMemo)(()=>e.items.filter(e=>OO(e.item)),[e]),l=(0,v.useMemo)(()=>{if(!t||s)return[];let{x:e,y:n,z:r,w:i,h:a}=t,o={x:-e/r-i/r,y:-n/r-a/r,w:i/r*3,h:a/r*3};return c.filter(e=>sO(e,o))},[c,t,s]),u=(0,v.useMemo)(()=>e.sections.filter(e=>e.section.title),[e]),d=t=>t?e.items.find(e=>e.item.id===t):void 0,f=d(i),p=o&&o!==i?d(o):void 0;return(0,R.jsxs)(`div`,{ref:r,className:`canvas-overlay`,"data-tiny":s,children:[u.map(e=>(0,R.jsx)(JO,{placed:e},e.section.id)),l.map(e=>(0,R.jsx)(qO,{placed:e,store:n},e.item.id)),p?(0,R.jsx)(YO,{placed:p,kind:`hover`}):null,f?(0,R.jsx)(YO,{placed:f,kind:a===i?`active`:`selected`}):null]})}var ZO=12,QO=.4,$O=20,ek=110,tk=.2,nk=400,rk=.2,ik=3,ak=8e3,ok=14,sk=96;function ck({layout:e,theme:t,store:n,camera:r,events:i,capture:a,apiRef:o,onPlay:s,onSelect:c}){let l=(0,v.useRef)(null),u=(0,v.useRef)(null),d=(0,v.useRef)(null),f=(0,v.useRef)(null),[p,m]=(0,v.useState)(null),h=d_(n,e=>e.panning),g=d_(n,e=>e.selected),_=d_(n,e=>e.active),y=(0,v.useMemo)(()=>e.items.filter(e=>OO(e.item)),[e]);(0,v.useLayoutEffect)(()=>{let e=l.current,t=u.current,i=d.current,a,o,s=!1,c=0,p=()=>m({...r.camera,w:e.clientWidth,h:e.clientHeight,moving:s}),h=e=>{t.style.transform=`translate3d(${e.x}px, ${e.y}px, 0) scale(${e.z})`,s||(s=!0,t.classList.add(`moving`)),clearTimeout(a),a=setTimeout(()=>{s=!1,t.classList.remove(`moving`),p()},160);let r=f.current;r&&(r.style.setProperty(`--tx`,String(e.x)),r.style.setProperty(`--ty`,String(e.y)),r.style.setProperty(`--z`,String(e.z)));let l=24*e.z;for(;l<ok;)l*=4;for(;l>sk;)l/=4;l!==c&&(c=l,i.style.backgroundSize=`${l}px ${l}px`);let u=e=>((e+sk)%l+l)%l-l;i.style.transform=`translate3d(${u(e.x)}px, ${u(e.y)}px, 0)`;let d=e.z<.09;n.get().zoomTiny!==d&&n.set(e=>({...e,zoomTiny:d})),t.classList.toggle(`far`,e.z<.15);let m=e.z<QO;t.classList.toggle(`small-titles`,m),r&&(r.dataset.titles=m?`on`:`off`),o??=setTimeout(()=>{o=void 0,p()},90)};h(r.camera),p();let g=r.subscribe(h),_=e.getBoundingClientRect().left,v=new ResizeObserver(()=>{let t=e.getBoundingClientRect().left;if(t!==_){let e=r.camera;r.set({...e,x:e.x-(t-_)}),_=t}p()});return v.observe(e),()=>{g(),v.disconnect(),clearTimeout(a),clearTimeout(o)}},[r,n]),(0,v.useEffect)(()=>{let t=l.current,n=()=>{let{w:n,h:i}={w:t.clientWidth,h:t.clientHeight},o=e.bounds,s=o.w&&n?Math.min((n-160)/o.w,(i-160)/Math.max(o.h,1)):1;r.minZoom=a?.01:Math.min(.25,Math.max(rO,s*.5))};n();let i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[r,e.bounds,a]),(0,v.useEffect)(()=>{let t=l.current,n=()=>({w:t.clientWidth,h:t.clientHeight});o.current={size:n,openView(){let{w:t,h:i}=n(),a=e.bounds;if(!a.w)return;if(Math.min((t-160)/a.w,(i-160)/Math.max(a.h,1))>=rk)return this.fitAll(!1);let o=e.sections[0]??a,s=Math.min(.5,Math.max(.25,(t-160)/Math.max(o.w,1)));r.set({z:s,x:80-a.x*s,y:80-a.y*s})},fitAll(t=!0){let{w:i,h:a}=n();if(!e.bounds.w)return;let o=oO(e.bounds,i,a,80,1,r.minZoom);t?r.animateTo(o):r.set(o)},fitItem(t,i=!0){let a=e.items.find(e=>e.item.id===t);if(!a)return;let{w:o,h:s}=n(),c=oO(a,o,s,64,1,r.minZoom);i?r.animateTo(c):r.set(c)},zoomBy(e){let{w:t,h:i}=n(),a=r.camera,o=a.z*e,s=(t/2-a.x)/a.z,c=(i/2-a.y)/a.z;r.animateTo({z:o,x:t/2-s*o,y:i/2-c*o},180)},zoomTo(e){let{w:t,h:i}=n(),a=r.camera,o=(t/2-a.x)/a.z,s=(i/2-a.y)/a.z;r.animateTo({z:e,x:t/2-o*e,y:i/2-s*e},220)}}},[o,r,e]);let b=(0,v.useRef)([]),x=(0,v.useRef)(new Map),[S,C]=(0,v.useState)(0),w=d_(n,e=>lk(e.frames)),T=(0,v.useMemo)(()=>{let e=new Map;if(a){for(let t of y)e.set(t.item.id,`live`);return e}if(!p)return e;let{x:t,y:n,z:r,w:i,h:o}=p,s={x:-t/r,y:-n/r,w:i/r,h:o/r},c={x:s.x-s.w*.25,y:s.y-s.h*.25,w:s.w*1.5,h:s.h*1.5},l=s.x+s.w/2,u=s.y+s.h/2,d=e=>Math.max(0,Math.min(e.x+e.w,s.x+s.w)-Math.max(e.x,s.x))*Math.max(0,Math.min(e.y+e.h,s.y+s.h)-Math.max(e.y,s.y)),f=e=>Math.hypot(e.x+e.w/2-l,e.y+e.h/2-u),m=y.filter(e=>r>=tk&&sO(e,c)&&e.w*r>=ek).sort((e,t)=>d(t)-d(e)||f(e)-f(t)).slice(0,ZO).map(e=>e.item.id),h=[_,g].filter(e=>!!e),v=new Set(y.map(e=>e.item.id)),S=new Set(w.split(`
126
+ `)),C=new Set(b.current),T=performance.now(),E=e=>!S.has(e)&&T-(x.current.get(e)??0)<ak,D=ik-[...C].filter(E).length,O=[];for(let e of new Set([...h,...m]))v.has(e)&&(C.has(e)?O.push(e):(h.includes(e)||!p.moving&&D>0)&&(O.push(e),x.current.set(e,T),D--));let k=[...new Set([...O,...b.current])].filter(e=>v.has(e)).slice(0,$O);b.current=k;for(let e of x.current.keys())k.includes(e)||x.current.delete(e);for(let t of k)e.set(t,O.includes(t)?`live`:`asleep`);return e},[p,y,_,g,a,w,S]);(0,v.useEffect)(()=>{let e=performance.now(),t=new Set(w.split(`
127
+ `)),n=[...x.current].filter(([e])=>!t.has(e)).map(([,t])=>t+ak-e).filter(e=>e>0);if(!n.length)return;let r=setTimeout(()=>C(e=>e+1),Math.min(...n)+20);return()=>clearTimeout(r)},[T,w]);let E=(0,v.useRef)(null),D=(0,v.useRef)(new Map),O=(0,v.useRef)(null),k=(0,v.useRef)(!1),A=e=>{n.get().panning!==e&&n.set(t=>({...t,panning:e}))};(0,v.useEffect)(()=>{let e=e=>{e.code===`Space`&&!uk(e.target)&&(k.current=!0,l.current?.classList.add(`cursor-grab`),e.preventDefault())},t=e=>{e.code===`Space`&&(k.current=!1,l.current?.classList.remove(`cursor-grab`))};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[]);let j=e=>{let t=e;return(t?.closest(`[data-shield]`))?.dataset.shield??(t?.closest(`[data-label]`))?.dataset.label??(t?.closest(`[data-item]`))?.dataset.item??null},M=e=>{if(e.target.closest(`[data-ui]`)||e.button!==0&&e.button!==1)return;if(l.current.setPointerCapture(e.pointerId),D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),r.interrupt(),D.current.size===2){let[e,t]=[...D.current.values()];O.current={dist:Math.hypot(e.x-t.x,e.y-t.y),midX:(e.x+t.x)/2,midY:(e.y+t.y)/2},E.current=null,A(!0);return}let t=e.button===1||k.current;E.current={id:t?null:j(e.target),startX:e.clientX,startY:e.clientY,lastX:e.clientX,lastY:e.clientY,moved:t},t&&A(!0)},ee=e=>{if(D.current.has(e.pointerId)&&D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),O.current&&D.current.size===2){let[e,t]=[...D.current.values()],n=Math.hypot(e.x-t.x,e.y-t.y),i=(e.x+t.x)/2,a=(e.y+t.y)/2,o=l.current.getBoundingClientRect();r.panBy(i-O.current.midX,a-O.current.midY),r.zoomAt(i-o.left,a-o.top,n/Math.max(O.current.dist,1)),O.current={dist:n,midX:i,midY:a};return}let t=E.current;if(!t){if(!n.get().panning){let t=j(e.target);n.get().hovered!==t&&n.set(e=>({...e,hovered:t}))}return}!t.moved&&Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>3&&(t.moved=!0,A(!0)),t.moved&&r.panBy(e.clientX-t.lastX,e.clientY-t.lastY),t.lastX=e.clientX,t.lastY=e.clientY},N=e=>{D.current.delete(e.pointerId),D.current.size<2&&(O.current=null);let t=E.current;E.current=null,t&&!t.moved&&c(t.id,{x:e.clientX,y:e.clientY}),D.current.size||A(!1)};(0,v.useEffect)(()=>{let e=l.current,t=t=>{if(t.target.closest(`[data-ui]`))return;t.preventDefault();let n=e.getBoundingClientRect(),i=t.deltaMode===1?16:t.deltaMode===2?n.height:1;if(t.ctrlKey||t.metaKey){let e=t.deltaY*i,a=Math.abs(e)<40?.012:.0025;r.zoomAt(t.clientX-n.left,t.clientY-n.top,Math.exp(-e*a))}else r.panBy(-t.deltaX*i,-t.deltaY*i)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[r]);let P=e.sections;return(0,R.jsxs)(`div`,{ref:l,className:Y(`canvas-root relative h-full w-full touch-none overflow-clip select-none animate-[q-fade-in_160ms_ease-out]`,h&&`canvas-panning cursor-grabbing`),onPointerDown:M,onPointerMove:ee,onPointerUp:N,onPointerCancel:N,onPointerLeave:()=>n.get().hovered&&n.set(e=>({...e,hovered:null})),onDoubleClick:t=>{let n=j(t.target),r=n?e.items.find(e=>e.item.id===n):void 0;r&&OO(r.item)&&s(r.item.id)},children:[(0,R.jsx)(`div`,{ref:d,className:`canvas-grid`}),(0,R.jsxs)(`div`,{ref:u,className:`canvas-world`,children:[P.map(e=>(0,R.jsx)(UO,{section:e.section,x:e.x,y:e.y,w:e.w,store:n},`section:${e.section.id}`)),e.items.map(e=>{let{item:r}=e;return r.kind===`screen`||r.kind===`url`?(0,R.jsx)(zO,{placed:e,mode:T.get(r.id)??`off`,thumb:!a&&!!p&&e.w*p.z*devicePixelRatio<=nk,theme:t,store:n,events:i,capture:a},r.id):r.kind===`note`?(0,R.jsx)(VO,{placed:e,store:n},r.id):(0,R.jsx)(HO,{placed:e,store:n},r.id)})]}),(0,R.jsx)(XO,{layout:e,view:p,store:n,overlayRef:f})]})}function lk(e){return Object.keys(e).filter(t=>e[t].ready).sort().join(`
128
+ `)}function uk(e){let t=e;return!!t&&(t.isContentEditable||/^(input|textarea|select)$/i.test(t.tagName))}var dk=new URLSearchParams(window.location.search),fk=dk.has(`capture`),pk=(e,t)=>`foss-design.camera.${e}.${t}`;function mk(e){try{let t=JSON.parse(sessionStorage.getItem(e)??`null`);if(t&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.z))return t}catch{}return null}function hk(e){let t=b_(),n=dk.get(`theme`),[r,i]=(0,v.useState)(n===`dark`||n===`light`?n:null);return[r??e?.theme??t,i]}function gk({canvasId:e,pageId:t}){let{data:n,error:r,isLoading:i}=r_(e);if(r)return(0,R.jsx)(nO,{title:`Canvas not found`,text:r.message});if(i||!n)return(0,R.jsx)(`div`,{className:`canvas-dots grow`});let a=t??dk.get(`page`)??void 0,o=n.pages.find(e=>e.id===a)??n.pages[0];return(0,R.jsx)(_k,{canvas:n,page:o},`${n.id}/${o?.id??``}`)}function _k({canvas:e,page:t}){let[,n]=I(),r=(0,v.useMemo)(()=>NO(),[]),i=(0,v.useMemo)(()=>new aO,[]),a=(0,v.useRef)(null),[o,s]=hk(e),[c,l]=(0,v.useState)(()=>!fk&&window.innerWidth>900),[u,d]=(0,v.useState)(!1),f=d_(r,e=>e.sizes),p=(0,v.useMemo)(()=>t?jO(t,f):{items:[],sections:[],bounds:{x:0,y:0,w:0,h:0}},[t,f]),m=xk(d_(r,e=>e.frameEls),p),h=VD(m),g=u||h;(0,v.useEffect)(()=>{r.set(e=>e.inspecting===g?e:{...e,inspecting:g,active:null})},[g,r]);let _=BD(m,g,{onEscape:()=>d(!1)}),y=!!_.info;(0,v.useEffect)(()=>{y&&d(!0)},[y]);let b=_.info;(0,v.useEffect)(()=>{let e=_.frame;if(!e||!b)return;let t=Object.entries(r.get().frameEls).find(([,t])=>t===e)?.[0];t&&r.get().selected!==t&&r.set(e=>({...e,selected:t}))},[_.frame,b,r]);let x=(0,v.useMemo)(()=>MO(p),[p]),S=pk(e.id,t?.id??``),C=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(C.current||!p.bounds.w)return;C.current=!0;let t=l_(e.id),n=fk?null:mk(S);t?(r.set(e=>({...e,selected:t})),requestAnimationFrame(()=>a.current?.fitItem(t,!1))):n&&n.z>=i.minZoom?i.set(n):requestAnimationFrame(()=>fk?a.current?.fitAll(!1):a.current?.openView())},[p,i,S,e.id,r]),(0,v.useEffect)(()=>{if(fk)return;let e,t=i.subscribe(t=>{clearTimeout(e),e=setTimeout(()=>sessionStorage.setItem(S,JSON.stringify(t)),250)});return()=>{t(),clearTimeout(e)}},[i,S]);let w=(0,v.useCallback)(e=>{let t=e?p.items.find(t=>t.item.id===e)?.item:void 0;r.set(e=>({...e,selected:t?t.id:null,active:t&&OO(t)?t.id:null,hovered:null}))},[p,r]),T=(0,v.useCallback)(e=>{w(e),a.current?.fitItem(e)},[w]),E=(0,v.useCallback)(r=>n(`/c/${encodeURIComponent(e.id)}/play/${encodeURIComponent(r)}${t?`?page=${encodeURIComponent(t.id)}`:``}`),[e.id,t,n]),D=(0,v.useCallback)(()=>{let e=r.get().selected,t=e&&x.find(t=>t.item.id===e)||x[0];t&&E(t.item.id)},[r,x,E]);(0,v.useEffect)(()=>{let t=t=>{let n=t.detail;n.canvas===e.id&&p.items.some(e=>e.item.id===n.item)&&(l_(e.id),T(n.item))};return window.addEventListener(`design:focus`,t),()=>window.removeEventListener(`design:focus`,t)},[e.id,p,T]);let O=(0,v.useMemo)(()=>({onGo(r,i){let[a,o]=i.includes(`/`)?i.split(`/`):[null,i],s=a?e.pages.filter(e=>e.id===a):[t,...e.pages.filter(e=>e!==t)];for(let r of s)if(r&&r.sections.some(e=>e.items.some(e=>e.id===o))){r===t?T(o):(n(_O(e,r)),window.dispatchEvent(new CustomEvent(`design:focus`,{detail:{canvas:e.id,item:o}})));return}console.warn(`[design] go("${i}"): no such screen`)},onLink(t,n){zD(n,e,e=>this.onGo(t,e),t)},onWheel(e,t){let n=e.closest(`.canvas-root`);if(!n)return;let r=n.getBoundingClientRect(),a=e.getBoundingClientRect(),o=i.camera.z;if(t.zoom){let e=Math.abs(t.deltaY)<40?.012:.0025;i.zoomAt(a.left-r.left+t.x*o,a.top-r.top+t.y*o,Math.exp(-t.deltaY*e))}else i.panBy(-t.deltaX,-t.deltaY)},onEscape(){r.set(e=>({...e,active:null,selected:null}))}}),[e,t,i,r,T,n]);return(0,v.useEffect)(()=>{if(!fk)return;let e=Date.now(),t=setInterval(()=>{let n=r.get().frames;(x.every(e=>n[e.item.id]?.ready||e.item.kind===`screen`&&e.item.missing)||Date.now()-e>6e4)&&(clearInterval(t),a.current?.fitAll(!1),requestAnimationFrame(()=>requestAnimationFrame(()=>window.__DESIGN_CANVAS_READY__=!0)))},250);return()=>clearInterval(t)},[x,r]),(0,v.useEffect)(()=>{let i=i=>{if(uk(i.target)||document.querySelector(`[role="dialog"]`))return;let o=a.current,s=r.get(),c=i.metaKey||i.ctrlKey;if(i.key===`Escape`)_.info?_.select(null):u?d(!1):(s.active||s.selected)&&r.set(e=>({...e,active:null,selected:null}));else if(i.key===`i`&&!c&&!i.altKey)d(e=>!e);else if(i.key===`p`&&!c&&!i.altKey)D();else if(i.shiftKey&&i.code===`Digit1`)o?.fitAll();else if(i.shiftKey&&i.code===`Digit2`&&s.selected)o?.fitItem(s.selected);else if(i.shiftKey&&i.code===`Digit0`)o?.zoomTo(1);else if((i.key===`=`||i.key===`+`)&&!i.altKey)i.preventDefault(),o?.zoomBy(1.4);else if(i.key===`-`&&!i.altKey)i.preventDefault(),o?.zoomBy(1/1.4);else if(c&&i.key===`0`)i.preventDefault(),o?.zoomTo(1);else if(c&&i.key===`\\`)i.preventDefault(),l(e=>!e);else if([`ArrowRight`,`ArrowDown`,`ArrowLeft`,`ArrowUp`].includes(i.key)&&x.length){i.preventDefault();let e=x.findIndex(e=>e.item.id===s.selected),t=i.key===`ArrowRight`||i.key===`ArrowDown`?1:-1,n=x[e===-1?0:(e+t+x.length)%x.length];r.set(e=>({...e,selected:n.item.id,active:null})),o?.fitItem(n.item.id)}else if(i.key===`Enter`&&s.selected){let e=p.items.find(e=>e.item.id===s.selected)?.item;e&&OO(e)&&E(e.id)}else if(i.key===`]`||i.key===`[`){let r=t?e.pages.indexOf(t):-1,a=e.pages[r+(i.key===`]`?1:-1)];a&&n(_O(e,a))}};return window.addEventListener(`keydown`,i),()=>window.removeEventListener(`keydown`,i)},[r,x,p,E,D,e,t,n,u,_]),fk?(0,R.jsx)(`div`,{className:`flex h-dvh`,children:(0,R.jsx)(ck,{layout:p,theme:o,store:r,camera:i,events:O,capture:!0,apiRef:a,onPlay:()=>{},onSelect:()=>{}})}):(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(yO,{canvas:e,page:t,theme:o,onTheme:s,sidebar:c,onSidebar:l,inspect:u,onInspect:d,onPlay:D,canPlay:x.length>0}),(0,R.jsxs)(`div`,{className:`flex min-h-0 grow basis-0`,children:[(0,R.jsx)(tO,{open:c&&!!t,side:`left`,width:264,children:t?(0,R.jsx)(vO,{canvas:e,page:t,store:r,onPick:T}):null}),(0,R.jsxs)(`div`,{className:`relative min-w-0 grow`,children:[t&&p.items.length?(0,R.jsx)(ck,{layout:p,theme:o,store:r,camera:i,events:O,capture:!1,apiRef:a,onPlay:E,onSelect:e=>{e||(_.select(null),d(!1)),w(e)}}):(0,R.jsx)(`div`,{className:`canvas-dots flex h-full`,children:(0,R.jsx)(tv,{title:t?`This page is empty`:`This canvas has no pages`,text:(0,R.jsxs)(R.Fragment,{children:[`Add sections and screens to`,` `,(0,R.jsxs)(`code`,{className:`font-mono text-[13px]`,children:[`.design/canvas/`,e.id,`/canvas.json`]}),`.`]})})}),(0,R.jsx)(bO,{canvas:e,store:r,layoutItems:p.items.map(e=>e.item),theme:o,onPlay:E,inspect:g}),(0,R.jsx)(yk,{camera:i,apiRef:a}),e.issues.length?(0,R.jsx)(bk,{canvas:e}):null]}),(0,R.jsx)(tO,{open:u,side:`right`,width:320,children:(0,R.jsx)(ZD,{info:_.info,active:!0,onSelect:e=>_.select(e),onClose:()=>{d(!1),_.select(null)}})})]})]})}function vk({camera:e}){let[t,n]=(0,v.useState)(e.camera.z);return(0,v.useEffect)(()=>{let t=0;return e.subscribe(e=>{cancelAnimationFrame(t),t=requestAnimationFrame(()=>n(e.z))})},[e]),(0,R.jsxs)(R.Fragment,{children:[Math.round(t*100),`%`]})}function yk({camera:e,apiRef:t}){return(0,R.jsxs)(`div`,{"data-ui":!0,className:`absolute right-4 bottom-5 z-20 flex h-[46px] items-center gap-0.5 rounded-[10px] border border-rule bg-surface px-1.5 shadow-pop`,children:[(0,R.jsx)(N_,{icon:`zoom-out`,label:`Zoom out (−)`,onClick:()=>t.current?.zoomBy(1/1.4)}),(0,R.jsxs)(ow,{side:`top`,align:`end`,width:210,trigger:(0,R.jsx)(`button`,{type:`button`,className:`h-ctrl min-w-[56px] cursor-pointer rounded-[6px] border-0 bg-transparent px-1.5 text-[12.5px] font-medium text-ink2 tabular hover:bg-soft2`,children:(0,R.jsx)(vk,{camera:e})}),children:[(0,R.jsx)(lw,{onSelect:()=>t.current?.fitAll(),hint:`⇧1`,children:`Zoom to fit`}),(0,R.jsx)(lw,{onSelect:()=>t.current?.zoomTo(1),hint:`⇧0`,children:`100%`}),(0,R.jsx)(uw,{}),[.25,.5,2].map(e=>(0,R.jsxs)(lw,{onSelect:()=>t.current?.zoomTo(e),children:[e*100,`%`]},e))]}),(0,R.jsx)(N_,{icon:`zoom-in`,label:`Zoom in (+)`,onClick:()=>t.current?.zoomBy(1.4)}),(0,R.jsx)(`div`,{className:`mx-0.5 h-5 w-px bg-rule`}),(0,R.jsx)(N_,{icon:`fit`,label:`Zoom to fit (⇧1)`,onClick:()=>t.current?.fitAll()})]})}function bk({canvas:e}){let t=e.issues.filter(e=>e.severity===`error`).length;return(0,R.jsxs)(Jw,{children:[(0,R.jsx)(Yw,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"data-ui":!0,className:`absolute bottom-5 left-4 z-20 flex h-[46px] cursor-pointer items-center gap-2 rounded-[10px] border border-rule bg-surface px-3.5 text-[13px] font-medium shadow-pop hover:bg-soft`,children:[(0,R.jsx)(X,{name:`alert`,size:15,className:t?`text-danger-text`:`text-action`}),e.issues.length,` `,e.issues.length===1?`problem`:`problems`,` in canvas.json`]})}),(0,R.jsx)(Xw,{children:(0,R.jsx)(Zw,{side:`top`,align:`start`,sideOffset:8,collisionPadding:12,onFocusOutside:sw,className:`z-50 max-h-[50vh] w-[460px] max-w-[calc(100vw-24px)] overflow-y-auto rounded-[10px] border border-rule bg-surface shadow-pop outline-none data-[state=open]:animate-[q-pop_120ms_ease-out]`,children:(0,R.jsx)(QD,{issues:e.issues})})})]})}function xk(e,t){let n=(0,v.useRef)([]);return(0,v.useMemo)(()=>{let r=new Set(t.items.filter(e=>e.item.kind===`screen`).map(e=>e.item.id)),i=Object.entries(e).filter(e=>!!e[1]&&r.has(e[0])).map(([,e])=>e);return i.length===n.current.length&&i.every((e,t)=>e===n.current[t])||(n.current=i),n.current},[e,t])}function Sk({open:e,onOpenChange:t,title:n,children:r}){return(0,R.jsx)(hg,{open:e,onOpenChange:t,children:(0,R.jsx)(ed,{children:e?(0,R.jsxs)(yg,{forceMount:!0,children:[(0,R.jsx)(xg,{asChild:!0,forceMount:!0,children:(0,R.jsx)(Gf.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16},className:`fixed inset-0 z-50 bg-overlay`})}),(0,R.jsx)(Tg,{asChild:!0,forceMount:!0,"aria-describedby":void 0,children:(0,R.jsxs)(Gf.div,{initial:{y:`100%`},animate:{y:0},exit:{y:`100%`,transition:{duration:.18,ease:`easeIn`}},transition:{type:`spring`,stiffness:420,damping:40},className:`fixed inset-x-0 bottom-0 z-50 flex max-h-[82dvh] flex-col rounded-t-[14px] border-t border-rule bg-surface pb-[env(safe-area-inset-bottom)] shadow-pop outline-none`,children:[(0,R.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-9 rounded-full bg-rule-strong`})}),(0,R.jsxs)(`div`,{className:`flex min-h-[48px] items-center justify-between gap-3 pr-2 pl-4`,children:[(0,R.jsx)(Ag,{className:`m-0 truncate text-[15px] font-semibold`,children:n}),(0,R.jsx)(Mg,{asChild:!0,children:(0,R.jsx)(N_,{icon:`x`,label:`Close`})})]}),(0,R.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain border-t border-rule`,children:r})]})})]}):null})})}function Ck(e,t){return(t?e.pages.filter(e=>e.id===t):e.pages).flatMap(t=>t.sections.flatMap(n=>n.items.filter(e=>e.kind===`screen`||e.kind===`url`).map(r=>({item:r,pageId:t.id,where:[e.pages.length>1?t.title:null,n.title].filter(Boolean).join(` · `)}))))}var wk=(e,t,n)=>`/c/${encodeURIComponent(e)}/play/${encodeURIComponent(t)}?page=${encodeURIComponent(n)}`;function Tk({canvasId:e,itemId:t}){let{data:n,error:r,isLoading:i}=r_(e);return r?(0,R.jsx)(nO,{title:`Canvas not found`,text:r.message}):i||!n?null:(0,R.jsx)(Ek,{canvas:n,itemId:t})}function Ek({canvas:e,itemId:t}){let[,n]=I(),{frameSandbox:r,frameAllow:i,slots:a}=$g(),o=new URLSearchParams(window.location.search).get(`page`)??(window.location.hash.split(`?`)[1]?new URLSearchParams(window.location.hash.split(`?`)[1]).get(`page`):null),s=(0,v.useMemo)(()=>Ck(e,null),[e]),c=s.find(e=>e.item.id===t),l=o??c?.pageId??null,u=(0,v.useMemo)(()=>l?Ck(e,l):s,[e,l,s]),d=u.findIndex(e=>e.item.id===t),f=b_(),[p,m]=(0,v.useState)(e.theme??f),[h,g]=(0,v.useState)(`fit`),_=(0,v.useRef)(null),y=(0,v.useRef)(null),[b,x]=(0,v.useState)(null),S=(0,v.useCallback)(e=>{y.current=e,x(e)},[]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)({w:0,h:0}),[D,O]=(0,v.useState)([]),k=l?`/c/${encodeURIComponent(e.id)}/p/${encodeURIComponent(l)}`:`/c/${encodeURIComponent(e.id)}`,A=t=>{if(!u.length)return;let r=u[(d+t+u.length)%u.length];n(wk(e.id,r.item.id,r.pageId),{replace:!0})};(0,v.useLayoutEffect)(()=>{let e=_.current;if(!e)return;let t=new ResizeObserver(()=>E({w:e.clientWidth,h:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[]),(0,v.useEffect)(()=>{let e=e=>{uk(e.target)||document.querySelector(`[role="dialog"]`)||(e.key===`ArrowRight`?A(1):e.key===`ArrowLeft`?A(-1):e.key===`i`&&!e.metaKey&&!e.ctrlKey&&!e.altKey?w(e=>!e):e.key===`Escape`&&(re.info?re.select(null):C?w(!1):n(k)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let j=u[d],M=j?.item,ee=M?.kind===`screen`?M.theme??p:p,N=mO(e.id,M,ee),[P]=(0,v.useState)(ee),te=M?M.kind===`screen`?LD(M.url,P):M.url:``,ne=(0,v.useMemo)(()=>b&&M?.kind===`screen`?[b]:[],[b,M?.kind]),F=VD(ne),re=BD(ne,C||F,{onEscape:()=>w(!1)}),ie=!!re.info;if((0,v.useEffect)(()=>{ie&&w(!0)},[ie]),(0,v.useEffect)(()=>{let t=y.current;if(t&&M?.kind===`screen`)return O([]),AD(t,t=>{if(t.type===`error`)O(e=>OD(e,t.message));else if(t.type===`updated`)O([]);else if(t.type===`keydown`&&t.code===`Escape`)n(k);else if(t.type===`go`){let[r,i]=t.target.includes(`/`)?t.target.split(`/`):[null,t.target],a=s.find(e=>e.item.id===i&&(!r||e.pageId===r));a&&n(wk(e.id,a.item.id,a.pageId))}else t.type===`link`&&zD(t,e,t=>{let r=s.find(e=>e.item.id===t);r&&n(wk(e.id,r.item.id,r.pageId))},M?.id)})},[M,te,s,e.id,n,k]),(0,v.useEffect)(()=>{M?.kind===`screen`&&PD(y.current,ee)},[ee,M]),!M)return(0,R.jsx)(nO,{title:`Screen not found`,text:`No screen "${t}" on this canvas.`});let ae=M.frame.width,oe=M.frame.height===`auto`?Math.max(T.h-48,400):M.frame.height,se=h===`fit`?Math.min(1,(T.w-48)/ae,(T.h-48)/oe):1,ce=ae<=T.w-48&&oe<=T.h-48;return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsxs)(gw,{children:[a.barStart,(0,R.jsx)(kx,{content:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Back to canvas `,(0,R.jsx)(S_,{children:`esc`})]}),children:(0,R.jsx)(ye,{href:k,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,"aria-label":`Back to canvas`,children:(0,R.jsx)(X,{name:`arrow-left`,size:16})})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col leading-tight`,children:[(0,R.jsx)(`span`,{className:`truncate text-[14px] font-semibold`,children:M.title}),(0,R.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:[e.title,j.where].filter(Boolean).join(` · `)})]}),(0,R.jsxs)(`div`,{className:`mx-auto flex items-center gap-1`,children:[(0,R.jsx)(N_,{icon:`chevron-left`,label:`Previous screen (←)`,onClick:()=>A(-1),disabled:u.length<2}),(0,R.jsxs)(`span`,{className:`min-w-[52px] text-center text-[12.5px] text-muted tabular`,children:[d+1,` / `,u.length]}),(0,R.jsx)(N_,{icon:`chevron-right`,label:`Next screen (→)`,onClick:()=>A(1),disabled:u.length<2})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ce?null:(0,R.jsx)(cO,{label:`Scale`,value:h,onChange:g,items:[{value:`fit`,label:`Fit`},{value:`actual`,label:`100%`}]}),M.kind===`screen`&&!M.theme?(0,R.jsx)(cO,{label:`Screen theme`,value:p,onChange:m,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:15}),title:`Light`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:15}),title:`Dark`}]}):null,M.kind===`screen`?(0,R.jsx)(SO,{on:C,onChange:w}):null,(0,R.jsx)(N_,{icon:`refresh`,label:`Reload`,onClick:()=>FD(y.current)}),N?(0,R.jsx)(`a`,{href:N,target:`_blank`,rel:`noreferrer`,title:`Open in a new tab`,className:`inline-flex h-ctrl w-ctrl items-center justify-center rounded-[6px] text-muted hover:bg-soft2 hover:text-ink2`,children:(0,R.jsx)(X,{name:`external`,size:16})}):null,(0,R.jsx)(pw,{}),a.barEnd]})]}),a.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:a.belowBar}):null,(0,R.jsxs)(`div`,{className:`flex min-h-0 grow basis-0`,children:[(0,R.jsxs)(`div`,{ref:_,className:`canvas-dots relative min-w-0 grow overscroll-none ${h===`actual`?`overflow-auto`:`overflow-hidden`}`,children:[D.length?(0,R.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-10 flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px`}),D.join(`
129
+ `)]}):null,(0,R.jsx)(`div`,{className:`flex min-h-full min-w-full items-center justify-center p-6`,style:{width:h===`actual`?ae+48:void 0},children:(0,R.jsx)(`div`,{className:`shrink-0 animate-[q-fade-in_160ms_ease-out] overflow-clip bg-surface`,style:{width:ae*se,height:oe*se,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:(0,R.jsx)(`iframe`,{ref:S,src:te,title:M.title,allow:i,sandbox:r,className:`block border-0`,style:{width:ae,height:oe,transform:`scale(${se})`,transformOrigin:`0 0`,colorScheme:ee},onLoad:()=>M.kind===`screen`&&PD(y.current,ee)},`${M.id}:${M.kind===`screen`?M.rev:M.url}`)},M.id)})]}),(0,R.jsx)(tO,{open:C,side:`right`,width:320,children:(0,R.jsx)(ZD,{info:re.info,active:!0,onSelect:e=>re.select(e),onClose:()=>{w(!1),re.select(null)}})})]})]})}var Dk=12;function Ok({canvasId:e,pageId:t,itemId:n}){let{data:r,error:i,isLoading:a}=r_(e);return i?(0,R.jsx)(nO,{title:`Canvas not found`,text:i.message}):a||!r?(0,R.jsx)(`div`,{className:`canvas-dots h-dvh`}):(0,R.jsx)(kk,{canvas:r,pageId:t,itemId:n})}function kk({canvas:e,pageId:t,itemId:n}){let[,r]=I(),{frameSandbox:i,frameAllow:a,slots:o,scope:s}=$g(),c=b_(),l=(0,v.useMemo)(()=>Ck(e,null),[e]),u=Math.max(0,n?l.findIndex(e=>e.item.id===n):t?l.findIndex(e=>e.pageId===t):0),d=l[u],f=d?.item,[p,m]=(0,v.useState)(e.theme??c),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)([]),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(0),[E,D]=(0,v.useState)(!1),O=(0,v.useRef)(null),k=(0,v.useRef)(null),[A,j]=(0,v.useState)(null),M=(0,v.useCallback)(e=>{e&&(k.current=e,j(e))},[]),ee=(0,v.useCallback)((t,n=0)=>{T(n),r(wk(e.id,t.item.id,t.pageId),{replace:!0})},[e.id,r]),N=e=>{l.length<2||ee(l[(u+e+l.length)%l.length],e)},P=e=>{let t=l.find(t=>t.item.id===e);t&&ee(t,l.indexOf(t)>u?1:-1)};(0,v.useLayoutEffect)(()=>{let e=O.current;if(!e)return;let t=new ResizeObserver(()=>x(e.clientWidth));return t.observe(e),()=>t.disconnect()},[]);let te=f?.kind===`screen`?f.theme??p:p,[ne]=(0,v.useState)(te),F=f?f.kind===`screen`?LD(f.url,ne):f.url:``,re=mO(e.id,f,te);(0,v.useEffect)(()=>{y([]),C(f?.kind===`screen`?f.measuredHeight??null:null),O.current?.scrollTo({top:0});let t=k.current;if(t&&f?.kind===`screen`)return AD(t,t=>{t.type===`size`?C(t.height):t.type===`error`?y(e=>OD(e,t.message)):t.type===`updated`?y([]):t.type===`go`?P(t.target.includes(`/`)?t.target.split(`/`)[1]:t.target):t.type===`link`&&zD(t,e,P,f.id)})},[A,F]),(0,v.useEffect)(()=>{f?.kind===`screen`&&PD(k.current,te)},[te,f]),(0,v.useEffect)(()=>{let e=e=>{document.querySelector(`[role="dialog"]`)||(e.key===`ArrowRight`?N(1):e.key===`ArrowLeft`&&N(-1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let ie=(0,v.useRef)(null),ae=e=>{let t=e.touches[0];ie.current=t?{x:t.clientX,y:t.clientY}:null},oe=e=>{let t=ie.current,n=e.changedTouches[0];if(ie.current=null,!t||!n)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>56&&Math.abs(r)>Math.abs(i)*1.5&&N(r<0?1:-1)};if(!f||!d)return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(jk,{canvas:e,title:e.title,sub:null}),(0,R.jsx)(nO,{title:`No screens here`,text:`This canvas has no screens to show yet.`})]});let se=f.frame.width,ce=b?Math.min(1,(b-24)/se):0,le=ce>0&&ce<.8,ue=le&&E?1:ce,de=f.frame.height===`auto`?Math.max(S??0,480):f.frame.height,fe=f.kind===`screen`&&!f.theme;return(0,R.jsxs)(`div`,{className:`flex h-dvh flex-col`,children:[(0,R.jsx)(jk,{canvas:e,title:f.title||f.id,sub:[e.title,d.where].filter(Boolean).join(` · `),back:s?void 0:`/`,end:(0,R.jsxs)(R.Fragment,{children:[le?(0,R.jsx)(N_,{icon:E?`zoom-out`:`zoom-in`,label:E?`Fit to width`:`Actual size`,onClick:()=>D(e=>!e)}):null,(0,R.jsxs)(ow,{align:`end`,width:220,trigger:(0,R.jsx)(N_,{icon:`more`,label:`Screen options`}),children:[fe?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(dw,{children:`Screen theme`}),(0,R.jsx)(Ak,{value:`light`,current:p,onPick:m}),(0,R.jsx)(Ak,{value:`dark`,current:p,onPick:m}),(0,R.jsx)(uw,{})]}):null,(0,R.jsxs)(lw,{onSelect:()=>FD(k.current),children:[(0,R.jsx)(X,{name:`refresh`,size:15,className:`text-ink2`}),`Reload screen`]}),re?(0,R.jsxs)(lw,{onSelect:()=>window.open(re,`_blank`,`noopener`),children:[(0,R.jsx)(X,{name:`external`,size:15,className:`text-ink2`}),`Open in a new tab`]}):null,(0,R.jsxs)(lw,{onSelect:()=>v_(c===`dark`?`light`:`dark`),children:[(0,R.jsx)(X,{name:c===`dark`?`sun`:`moon`,size:15,className:`text-ink2`}),c===`dark`?`Light appearance`:`Dark appearance`]})]}),o.barEnd]})}),o.belowBar?(0,R.jsx)(`div`,{className:`shrink-0`,children:o.belowBar}):null,(0,R.jsxs)(`div`,{ref:O,onTouchStart:ae,onTouchEnd:oe,className:Y(`canvas-dots relative min-h-0 grow overflow-y-auto overscroll-contain`,le&&E?`overflow-x-auto`:`overflow-x-hidden`),children:[_.length?(0,R.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2 font-mono text-[12px] whitespace-pre-wrap text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:14,className:`mt-px shrink-0`}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:_.join(`
130
+ `)})]}):null,(0,R.jsx)(ed,{initial:!1,mode:`popLayout`,custom:w,children:(0,R.jsx)(Gf.div,{custom:w,initial:{opacity:0,x:w*40},animate:{opacity:1,x:0},exit:{opacity:0,x:w*-40,transition:{duration:.12}},transition:{type:`spring`,stiffness:420,damping:38},className:Y(`flex`,le&&E?`w-max`:`justify-center`),style:{padding:Dk},children:ue?(0,R.jsx)(`div`,{className:`shrink-0 overflow-hidden rounded-[6px] bg-surface`,style:{width:se*ue,height:de*ue,boxShadow:`var(--shadow-frame), 0 0 0 1px var(--rule)`},children:(0,R.jsx)(`iframe`,{ref:M,src:F,title:f.title,allow:a,sandbox:i,className:`block border-0`,style:{width:se,height:de,transform:`scale(${ue})`,transformOrigin:`0 0`,colorScheme:te},onLoad:()=>f.kind===`screen`&&PD(k.current,te)},`${f.id}:${f.kind===`screen`?f.rev:f.url}`)}):null},f.id)})]}),(0,R.jsxs)(`nav`,{"aria-label":`Screens`,className:`flex shrink-0 items-center gap-1 border-t border-rule bg-surface px-2 pt-1.5 pb-[max(6px,env(safe-area-inset-bottom))]`,children:[(0,R.jsx)(N_,{icon:`chevron-left`,label:`Previous screen`,onClick:()=>N(-1),disabled:l.length<2}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>g(!0),className:`flex h-10 min-w-0 grow cursor-pointer items-center justify-center gap-2 rounded-[8px] border-0 bg-transparent px-3 text-[13.5px] text-ink active:bg-soft2`,children:[(0,R.jsx)(X,{name:`list`,size:15,className:`shrink-0 text-muted`}),(0,R.jsxs)(`span`,{className:`tabular shrink-0 text-muted`,children:[u+1,` / `,l.length]}),(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:f.title||f.id})]}),(0,R.jsx)(N_,{icon:`chevron-right`,label:`Next screen`,onClick:()=>N(1),disabled:l.length<2})]}),(0,R.jsx)(Sk,{open:h,onOpenChange:g,title:e.title,children:(0,R.jsx)(Nk,{canvas:e,current:f.id,onPick:e=>{g(!1),P(e)}})})]})}function Ak({value:e,current:t,onPick:n}){return(0,R.jsxs)(lw,{active:t===e,onSelect:()=>n(e),children:[(0,R.jsx)(X,{name:e===`dark`?`moon`:`sun`,size:15,className:`text-ink2`}),e===`dark`?`Dark`:`Light`,t===e?(0,R.jsx)(X,{name:`check`,size:15,className:`ml-auto text-ink2`}):null]})}function jk({canvas:e,title:t,sub:n,back:r,end:i}){let{slots:a}=$g();return(0,R.jsxs)(`header`,{className:`flex h-[52px] shrink-0 items-center gap-2 border-b border-rule bg-surface pr-2 pl-2 pt-[env(safe-area-inset-top)]`,children:[a.barStart,r?(0,R.jsx)(ye,{href:r,"aria-label":`All canvases, leaving ${e.title}`,className:`inline-flex size-10 shrink-0 items-center justify-center rounded-[8px] text-ink2 active:bg-soft2`,children:(0,R.jsx)(X,{name:`arrow-left`,size:18})}):(0,R.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center`,children:(0,R.jsx)(mw,{})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 grow flex-col leading-tight`,children:[(0,R.jsx)(`span`,{className:`truncate text-[14.5px] font-semibold`,children:t}),n?(0,R.jsx)(`span`,{className:`truncate text-[12px] text-muted`,children:n}):null]}),(0,R.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:i})]})}var Mk=e=>e.item.kind===`url`?`globe`:e.item.frame.device===`phone`?`smartphone`:e.item.frame.device===`tablet`?`tablet`:`monitor`;function Nk({canvas:e,current:t,onPick:n}){let r=(0,v.useRef)(null);(0,v.useEffect)(()=>{r.current?.scrollIntoView({block:`center`})},[]);let i=e.pages.length>1;return(0,R.jsx)(`div`,{className:`flex flex-col pb-2`,children:e.pages.map(a=>{let o=Ck(e,a.id);return o.length?(0,R.jsxs)(`section`,{className:`flex flex-col`,children:[i?(0,R.jsx)(`h3`,{className:`sticky top-0 z-[1] m-0 border-b border-rule bg-soft px-4 py-2 text-[12px] font-semibold text-ink2`,children:a.title}):null,a.sections.map(e=>{let i=o.filter(t=>e.items.includes(t.item));return i.length?(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.title?(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.title}):null,i.map(e=>{let i=e.item.id===t;return(0,R.jsxs)(`button`,{ref:i?r:void 0,type:`button`,"aria-current":i?`true`:void 0,onClick:()=>n(e.item.id),className:Y(`flex min-h-[48px] cursor-pointer items-center gap-3 border-0 bg-transparent px-4 text-left text-[14px] active:bg-soft2`,i?`font-medium text-ink`:`text-ink2`),children:[(0,R.jsx)(`span`,{className:Y(`flex size-8 shrink-0 items-center justify-center rounded-[8px]`,i?`bg-action-soft text-action`:`bg-soft2 text-muted`),children:(0,R.jsx)(X,{name:Mk(e),size:15})}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.item.title||e.item.id}),i?(0,R.jsx)(X,{name:`check`,size:16,className:`shrink-0 text-action`}):null]},e.item.id)})]},e.id):null})]},a.id):null})})}var Pk=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60]],Fk=new Intl.RelativeTimeFormat(`en`,{numeric:`auto`});function Ik(e){if(!e)return``;let t=(e-Date.now())/1e3;for(let[e,n]of Pk)if(Math.abs(t)>=n)return Fk.format(Math.round(t/n),e);return`just now`}function Lk(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Rk(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function zk({className:e,style:t}){return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:Y(`block animate-pulse rounded-[6px] bg-soft2`,e),style:t})}function Bk({rows:e=3,lead:t=28,minH:n=56}){return(0,R.jsx)(`div`,{role:`status`,"aria-label":`Loading`,children:Array.from({length:e},(e,r)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-rule px-4`,style:{minHeight:n,opacity:1-r*.18},children:[t?(0,R.jsx)(zk,{style:{width:t,height:Math.min(t,n-20)}}):null,(0,R.jsxs)(`span`,{className:`flex min-w-0 grow flex-col gap-1.5`,children:[(0,R.jsx)(zk,{className:`h-3 w-[38%]`}),(0,R.jsx)(zk,{className:`h-2.5 w-[62%]`})]}),(0,R.jsx)(zk,{className:`h-3 w-14`})]},r))})}function Vk({canvas:e}){return(0,R.jsx)(`div`,{className:`flex h-[54px] w-[86px] shrink-0 items-center justify-center overflow-hidden rounded-[6px] border border-rule bg-soft`,children:e.cover?(0,R.jsx)(`img`,{src:e.cover,alt:``,className:`h-full w-full object-cover object-top`}):(0,R.jsx)(X,{name:`canvas`,size:18,className:`text-muted`})})}function Hk({src:e}){return(0,R.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-[6px] border border-rule bg-soft`,children:(0,R.jsx)(`img`,{src:e,alt:``,className:`size-full object-contain`})})}function Uk({project:e}){let{source:t,keys:n}=$g(),r=Me(),i=(0,v.useRef)(null);if(!t.setIcon||e.static)return null;let a=async e=>{try{await t.setIcon(e),await r.invalidateQueries({queryKey:n.project}),eT(e?`Icon set`:`Icon removed`,e?`Saved as .design/icon; a linked project takes it to the cloud on its next push or pull.`:void 0)}catch(e){eT(`Could not change the icon`,e.message,`error`)}};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{ref:i,type:`file`,accept:`.svg,.png,.webp,image/svg+xml,image/png,image/webp`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&a(t)}}),(0,R.jsxs)(ow,{trigger:(0,R.jsx)(A_,{children:`Icon`}),align:`end`,width:240,children:[(0,R.jsxs)(lw,{onSelect:()=>i.current?.click(),hint:`≤ 256 KB`,children:[(0,R.jsx)(X,{name:`upload`,size:15}),e.icon?`Replace icon`:`Upload icon`]}),e.icon?(0,R.jsxs)(lw,{danger:!0,onSelect:()=>void a(null),children:[(0,R.jsx)(X,{name:`trash`,size:15}),`Remove icon`]}):null]})]})}function Wk({actions:e,children:t}){return e?(0,R.jsxs)(`div`,{className:`grid items-center border-t border-rule transition-colors hover:bg-soft`,style:{gridTemplateColumns:`minmax(0,1fr) auto`},children:[t,(0,R.jsx)(`div`,{className:`flex items-center gap-2 pr-4`,children:e})]}):t}function Gk({children:e}){return e?(0,R.jsx)(`div`,{className:`flex items-center gap-2.5 border-t border-rule bg-soft px-4 py-3 text-[12.5px] text-muted`,children:e}):null}function Kk({project:e}){let{canvasRowActions:t,canvasesFoot:n}=$g().slots,r=Tw();return e.canvases.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Canvases`,count:e.canvases.length}),e.canvases.map(e=>{let n=t?.(e.id);return(0,R.jsx)(Wk,{actions:n,children:r?(0,R.jsxs)(q_,{to:`/c/${encodeURIComponent(e.id)}`,cols:`86px minmax(0,1fr)`,align:`ll`,pad:`10px 16px`,minH:74,first:!!n,children:[(0,R.jsx)(Vk,{canvas:e}),(0,R.jsx)(C_,{top:e.title,bottom:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[e.issues?(0,R.jsx)(L_,{tone:`danger`,children:Rk(e.issues,`problem`)}):null,(0,R.jsxs)(`span`,{className:`truncate`,children:[Rk(e.screens,`screen`),` · `,Ik(e.updatedAt)]})]})})]}):(0,R.jsxs)(q_,{to:`/c/${encodeURIComponent(e.id)}`,cols:`86px minmax(0,1fr) auto auto`,align:`llrr`,pad:`10px 16px`,minH:74,first:!!n,children:[(0,R.jsx)(Vk,{canvas:e}),(0,R.jsx)(C_,{top:e.title,bottom:(0,R.jsx)(`span`,{className:`truncate`,children:e.description??e.id})}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 text-[12.5px] whitespace-nowrap text-muted`,children:[e.issues?(0,R.jsx)(L_,{tone:`danger`,children:Rk(e.issues,`problem`)}):null,Rk(e.screens,`screen`),` · `,Rk(e.pages,`page`)]}),(0,R.jsx)(`span`,{className:`w-[92px] text-[12.5px] whitespace-nowrap text-muted`,children:Ik(e.updatedAt)})]})},e.id)}),(0,R.jsx)(Gk,{children:n})]}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Canvases`,count:0}),(0,R.jsx)(Y_,{children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 py-6 text-center`,children:[(0,R.jsx)(`span`,{className:`text-[14px] text-ink2`,children:`No canvases yet.`}),(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Ask your agent to design something, or run `,(0,R.jsx)(Z,{children:`design new <name>`}),` in the project.`]})]})}),(0,R.jsx)(Gk,{children:n})]})}function qk({project:e}){let t=e.system;return t?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Design system`,right:(0,R.jsx)(P_,{to:`/system`,children:`Open`})}),(0,R.jsxs)(Y_,{gap:6,children:[(0,R.jsx)(`span`,{className:`text-[15px] font-semibold`,children:t.name}),t.description?(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:t.description}):null]}),(0,R.jsx)(J_,{label:`Tokens`,labelWidth:120,end:!0,children:(0,R.jsx)(R_,{value:t.tokens})}),(0,R.jsx)(J_,{label:`Components`,labelWidth:120,end:!0,children:(0,R.jsx)(R_,{value:t.components})}),(0,R.jsx)(J_,{label:`Guidelines`,labelWidth:120,end:!0,children:(0,R.jsx)(R_,{value:t.guidelines})}),t.issues?(0,R.jsx)(J_,{label:`Problems`,labelWidth:120,end:!0,children:(0,R.jsx)(L_,{tone:`danger`,children:t.issues})}):null]}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Design system`}),(0,R.jsx)(Y_,{children:(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`No design system yet. Ask your agent to build one from the codebase, or run `,(0,R.jsx)(Z,{children:`design system init`}),`.`]})})]})}function Jk(){return(0,R.jsxs)(X_,{children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-2.5 pt-1 pb-1`,children:[(0,R.jsx)(zk,{className:`h-6 w-[220px]`}),(0,R.jsx)(zk,{className:`h-3.5 w-[300px]`})]}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-lg:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 340px`},children:[(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Canvases`}),(0,R.jsx)(Bk,{rows:3,lead:86,minH:74})]}),(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Design system`}),(0,R.jsx)(Bk,{rows:3,lead:0,minH:40})]})]})]})}function Yk(){let{data:e,error:t,isLoading:n}=n_(),{slots:r}=$g(),i=Tw();return t?(0,R.jsx)(tv,{title:`Could not load the project`,text:t.message}):n||!e?(0,R.jsx)(Jk,{}):(0,R.jsxs)(X_,{children:[(0,R.jsx)(Z_,{title:e.icon?(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,R.jsx)(Hk,{src:e.icon}),e.name]}):e.name,right:i?void 0:r.homeActions??(0,R.jsx)(Uk,{project:e}),badge:i&&r.homeActions?(0,R.jsx)(`span`,{className:`ml-auto flex`,children:r.homeActions}):void 0,sub:r.homeSub?r.homeSub:e.static?`Snapshot built with foss-design ${e.version}`:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(Z,{size:12.5,wrap:!0,children:[e.root,`/.design`]}),` `,`· foss-design `,e.version]})}),(0,R.jsx)($D,{issues:e.issues,title:`Problems in design.json`}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-lg:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 340px`},children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-5`,children:[(0,R.jsx)(Kk,{project:e}),r.canvasesAfter]}),(0,R.jsx)(qk,{project:e})]}),r.homeAfter]})}function Xk(e){let t=e.utility;if(t===void 0)return[];let n=t?`-${t}`:``;switch(e.kind){case`color`:return[`bg${n}`,`text${n}`,`border${n}`];case`font`:return[`font${n}`];case`text`:return[`text${n}`];case`weight`:return[`font${n}`];case`leading`:return[`leading${n}`];case`tracking`:return[`tracking${n}`];case`spacing`:return t?[`p${n}`,`gap${n}`]:[`p-1`,`gap-4`,`m-2`];case`radius`:return[`rounded${n}`];case`shadow`:return e.name.startsWith(`--inset-shadow-`)?[`inset-shadow${n}`]:e.name.startsWith(`--drop-shadow-`)?[`drop-shadow${n}`]:e.name.startsWith(`--text-shadow-`)?[`text-shadow${n}`]:[`shadow${n}`];case`blur`:return[`blur${n}`,`backdrop-blur${n}`];case`ease`:return[`ease${n}`];case`animation`:return[`animate${n}`];case`breakpoint`:return e.name.startsWith(`--container-`)?[`@${t}:`,`max-w${n}`]:[`${t}:`];default:return[]}}function Zk(e,...t){return e.filter(e=>t.includes(e.kind))}function Qk(e){let t=new Map;for(let n of e){let e=t.get(n.group)??[];e.push(n),t.set(n.group,e)}return[...t].map(([e,t])=>({group:e,tokens:t}))}function $k(e){let t=/^(-?[\d.]+)(px|rem|em)?$/.exec(e.trim());if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?t[2]===`rem`||t[2]===`em`?n*16:n:null}function eA(e,t){return(t===`dark`?e.dark?.value:void 0)??e.light?.value}function tA(){let e=b_(),[t,n]=(0,v.useState)(null);return[t??e,n]}function nA({value:e,onChange:t}){return(0,R.jsx)(cO,{label:`Theme`,size:`sm`,value:e,onChange:t,items:[{value:`light`,label:(0,R.jsx)(X,{name:`sun`,size:14}),title:`Light`},{value:`dark`,label:(0,R.jsx)(X,{name:`moon`,size:14}),title:`Dark`}]})}function rA({items:e}){return e.length?(0,R.jsx)(`span`,{className:`flex min-w-0 flex-wrap gap-x-2 gap-y-0.5`,children:e.map(e=>(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e},e))}):null}function iA({title:e,children:t}){return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e}),(0,R.jsx)(Y_,{children:(0,R.jsx)(`div`,{className:`py-4 text-[13px] text-muted`,children:t})})]})}var aA=`.design/system/tokens.css`;function oA({children:e,className:t}){return(0,R.jsx)(`span`,{className:`font-mono text-[12px] text-muted [overflow-wrap:anywhere] ${t??``}`,children:e})}function sA({asset:e,index:t}){if(e.kind===`image`)return(0,R.jsx)(`span`,{className:`checker flex h-[132px] items-center justify-center overflow-hidden border-b border-rule`,children:(0,R.jsx)(`img`,{src:e.url,alt:``,className:`max-h-[96px] max-w-[80%] object-contain`})});if(e.kind===`font`){let n=`design-asset-font-${t}`;return(0,R.jsxs)(`span`,{className:`flex h-[132px] items-center justify-center border-b border-rule bg-soft`,children:[(0,R.jsx)(`style`,{children:`@font-face{font-family:"${n}";src:url("${e.url.replace(/"/g,`%22`)}")}`}),(0,R.jsx)(`span`,{className:`text-[52px] leading-none text-ink`,style:{fontFamily:`"${n}", var(--font-sans)`},children:`Aa`})]})}return(0,R.jsx)(`span`,{className:`flex h-[132px] items-center justify-center border-b border-rule bg-soft text-muted`,children:(0,R.jsx)(X,{name:`file`,size:28})})}function cA({system:e}){return e.assets.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Assets`,sub:`Click an asset to copy its import path.`}),(0,R.jsx)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(210px, 1fr))`},children:e.assets.map((e,t)=>(0,R.jsx)(`button`,{type:`button`,title:`Copy the import path`,onClick:()=>iT(`@system/${e.path}`),className:`block cursor-pointer border-0 bg-transparent p-0 text-left`,children:(0,R.jsxs)(z_,{className:`transition-colors hover:border-rule-strong`,children:[(0,R.jsx)(sA,{asset:e,index:t}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-3.5 py-2.5`,children:[(0,R.jsx)(`span`,{className:`truncate text-[13.5px] font-medium text-ink`,children:e.name}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[12.5px] text-muted`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:Lk(e.size)}),(0,R.jsx)(Z,{size:12,className:`truncate`,children:e.path})]})]})]})},e.path))})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Assets`}),(0,R.jsxs)(iA,{title:`No assets`,children:[`Put logos, icons, images and font files in `,(0,R.jsx)(Z,{children:`.design/system/assets`}),`; screens import them as`,` `,(0,R.jsx)(Z,{children:`@system/assets/…`}),`.`]})]})}function lA({color:e,label:t,className:n}){return e?(0,R.jsx)(`span`,{title:`${t}: ${e}`,className:Y(`checker relative h-[30px] w-[44px] shrink-0 overflow-hidden rounded-[6px]`,n),children:(0,R.jsx)(`span`,{className:`absolute inset-0 rounded-[6px] shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1)] dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.12)]`,style:{background:e}})}):(0,R.jsx)(`span`,{className:Y(`h-[30px] w-[44px] shrink-0`,n)})}function uA({tokens:e}){let t=e.some(e=>e.dark),n=t=>(0,R.jsxs)(`div`,{className:`relative flex h-9 min-w-0 grow overflow-hidden rounded-[6px]`,children:[(0,R.jsx)(`span`,{className:`pointer-events-none absolute inset-0 z-10 rounded-[6px] shadow-[inset_0_0_0_1px_var(--rule-strong)] opacity-60`}),e.map(e=>{let n=t===`dark`?e.dark?.value??e.light?.value:e.light?.value;return(0,R.jsx)(`button`,{type:`button`,title:`${e.name}: ${n}`,onClick:()=>iT(`var(${e.name})`),className:`h-full min-w-0 flex-1 cursor-pointer border-0 p-0 transition-[flex-grow] duration-150 hover:grow-[1.6]`,style:{background:n}},e.name)})]});return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-rule px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t?(0,R.jsx)(`span`,{className:`w-9 shrink-0 text-[12px] text-muted`,children:`Light`}):null,n(`light`)]}),t?(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`w-9 shrink-0 text-[12px] text-muted`,children:`Dark`}),n(`dark`)]}):null]})}function dA({token:e}){return(0,R.jsxs)(K_,{cols:`100px minmax(170px, 0.9fr) minmax(0, 1.4fr)`,minH:56,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(lA,{color:e.light?.value,label:`Light`}),e.dark?(0,R.jsx)(lA,{color:e.dark.value,label:`Dark`}):null]}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(rA,{items:Xk(e).slice(0,2)})]}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-wrap gap-x-3`,children:[(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),e.dark?(0,R.jsxs)(Z,{size:12,className:`text-muted`,children:[`dark `,e.dark.value]}):null]}),e.description?(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:e.description}):null]})]})}function fA({system:e}){let t=Zk(e.tokens,`color`),n=Qk(t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Colors`,sub:t.length?`${t.length} tokens · click a color to copy its variable`:void 0}),n.length?n.map(({group:e,tokens:t})=>(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(uA,{tokens:t}),t.map(e=>(0,R.jsx)(dA,{token:e},e.name))]},e)):(0,R.jsxs)(iA,{title:`No color tokens`,children:[`Add them to `,(0,R.jsx)(Z,{children:aA}),`: light values in `,(0,R.jsx)(Z,{children:`:root`}),`, dark ones in`,` `,(0,R.jsx)(Z,{children:`:root[data-theme="dark"]`}),`, and map them to Tailwind with `,(0,R.jsx)(Z,{children:`--color-*`}),` in`,` `,(0,R.jsx)(Z,{children:`@theme inline`}),`.`]})]})}function pA({src:e,theme:t,title:n,minHeight:r=120,width:i,className:a}){let o=(0,v.useRef)(null),{frameSandbox:s,frameAllow:c}=$g(),[l]=(0,v.useState)(()=>({src:e,theme:t})),u=LD(e,l.src===e?l.theme:t),[d,f]=(0,v.useState)(r),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=o.current;if(e)return m(!1),g([]),AD(e,t=>{t.type===`size`?f(Math.max(r,t.height)):t.type===`ready`?m(!0):t.type===`error`?g(e=>OD(e,t.message)):t.type===`updated`?g([]):t.type===`wheel`&&!t.zoom&&ND(e,t)})},[r,u]),(0,v.useEffect)(()=>{PD(o.current,t)},[t]),(0,R.jsxs)(`div`,{className:Y(`relative`,a),style:{width:i},children:[h.length?(0,R.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-rule bg-danger-soft px-4 py-2.5 text-[12.5px] text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:15,className:`mt-px`}),(0,R.jsx)(`div`,{className:`min-w-0 font-mono break-words`,children:h.join(`
131
+ `)})]}):null,(0,R.jsx)(`iframe`,{ref:o,src:u,title:n,allow:c,sandbox:s,className:Y(`block w-full border-0 transition-opacity duration-150`,p?`opacity-100`:`opacity-0`),style:{height:d,colorScheme:t},onLoad:()=>PD(o.current,t)},u),p?null:(0,R.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted`,children:(0,R.jsx)(X,{name:`loader`,size:18})})]})}var mA=`identifier keyword string class property entity jsxliterals sign comment break space`.split(` `),[hA,gA,_A,vA,yA,bA,xA,SA,CA,wA,TA]=mA.map((e,t)=>t);new Map(mA.map((e,t)=>[e,t]));function EA(e,t){let n=[],r=0,i=[],a=!1;function o(e){n.push({index:r++,value:e.map(([,e])=>e).join(``),tokens:e.map(([e,t])=>({type:mA[e],value:t})),annotations:[]})}for(let e=0;e<t.length;e++){let n=t[e],[r,s]=n;if(r!==wA){if(s.includes(`
132
132
  `)){let e=s.split(`
133
- `);for(let t=0;t<e.length;t++)i.push([r,e[t]]),t<e.length-1&&(o(i),i.length=0)}else i.push(n);a=!1}else a?o([]):(o(i),i.length=0),e===t.length-1&&o([]),a=!0}return i.length&&o(i),{value:e,lines:n}}function EA(e,t){let n={index:e.index,value:e.value,tokens:e.tokens,annotations:e.annotations,className:`sh__line${e.annotations.map(e=>` sh__line--${e}`).join(``)}`,style:{},properties:{}};return t?.(n),n}function DA({type:e,value:t},n,r){let i=n?.[e],a={type:e,value:t,className:`sh__token--${e}${i?` ${i}`:``}`,style:{color:`var(--sh-${e})`},properties:{}};return r?.(a),a}function OA(e,t){let n=t?.cx,r=t?.mark,i=t?.markLine;return!n&&!r&&!i?e.lines.map(e=>{let t=`sh__line${e.annotations.map(e=>` sh__line--${e}`).join(``)}`,n=e.tokens.map(({type:e,value:t})=>`<span class="sh__token--${e}" style="color:var(--sh-${e})">${AA(t)}</span>`).join(``);return`<span class="${AA(t)}">${n}</span>`}).join(`
134
- `):e.lines.map(e=>{let t=EA(e,i),a=e.tokens.map(e=>{let t=DA(e,n,r);return`<span ${jA({...t.properties,className:t.className,style:t.style})}>${AA(t.value)}</span>`}).join(``);return`<span ${jA({...t.properties,className:t.className,style:t.style})}>${a}</span>`}).join(`
135
- `)}var kA={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#039;`},AA=e=>e.replace(/[&<>"']/g,e=>kA[e]);function jA(e){let t=Object.entries(e.style||{}).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${t}`).join(`;`),n=Object.entries(e).filter(([e,t])=>/^[\w:-]+$/.test(e)&&e!==`className`&&e!==`style`&&t!==!1&&t!=null).map(([e,t])=>t===!0?e:`${e}="${AA(String(t))}"`).join(` `);return`class="${AA(e.className||``)}"${t?` style="${AA(t)}"`:``}${n?` ${n}`:``}`}var MA=new Set(`+-*/%=!&|^~?:.,;()[]{}<>#@\\`.split(``)),NA=()=>0,PA=e=>e===`_`||e===`$`||/[\p{L}\p{N}]/u.test(e);function FA(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return e[t]===`:`}function IA(e,t){if(typeof t?.tokenize==`function`)return t.tokenize(e,t);let n=t?.keywords||new Set,r=t?.typeKeywords||new Set,i=t?.onCommentStart||NA,a=t?.onCommentEnd||NA,o=t?.caseInsensitive?e=>e.toLowerCase():e=>e,s=[],c=``;function l(e,t){t&&(s.push([e,t]),e!==wA&&e!==CA&&(c=t))}for(let s=0;s<e.length;){let u=e[s],d=e[s+1],f=i(u,d,s,e);if(f){let t=s++;for(;s<e.length;){if(a(e[s-1],e[s],s,e,t)==f){s++;break}s++}l(SA,e.slice(t,s));continue}let p=t?.onLiteral?.(u,s,e);if(p){l(gA,e.slice(s,s+p)),s+=p;continue}if(typeof t?.onQuote==`function`&&u===`'`){let n=t.onQuote(u,s,e);if(typeof n==`number`&&n>=1){l(mA,e.slice(s,s+n)),s+=n;continue}}if(u===`"`||u===`'`||t?.templateStrings&&u==="`"){let n=u,r=s++;for(;s<e.length;){if(e[s]===`\\`)s++;else if(e[s]===n){s++;break}s++}let i=e.slice(r,s);l(t?.quotedKeys&&FA(e,s)?vA:gA,i);continue}if(u===`
136
- `){l(CA,u),s++;continue}if(/[^\S\r\n]/.test(u)){let t=s++;for(;s<e.length&&/[^\S\r\n]/.test(e[s]);)s++;l(wA,e.slice(t,s));continue}if(PA(u)){let t=s++;for(;s<e.length&&PA(e[s]);)s++;if(/^\d/.test(u)&&e[s]===`.`&&/\d/.test(e[s+1]||``))for(s++;s<e.length&&PA(e[s]);)s++;let i=e.slice(t,s),a=o(i);l(r.has(a)?_A:n.has(a)?hA:c===`.`?vA:/^\d/.test(i)||i===`null`||/^\p{Lu}/u.test(i)?_A:mA,i);continue}if(MA.has(u)){l(xA,u),s++;continue}l(gA,u),s++}return s}function LA(e,t){let n=TA(e,IA(e,t));if(t?.annotateLine)for(let e of n.lines)t.annotateLine(e);return n}var RA=(e,t)=>{let n=e+t;return n===`//`?1:n===`/*`?2:0},zA=(e,t)=>t===`
137
- `?1:e+t===`*/`?2:0,BA=s({keywords:()=>HA,onCommentEnd:()=>zA,onCommentStart:()=>RA,typeKeywords:()=>VA}),VA=new Set([`void`,`char`,`short`,`int`,`long`,`float`,`double`,`signed`,`unsigned`,`_Bool`,`_Complex`,`_Imaginary`]),HA=new Set(`auto.break.case.const.continue.default.do.else.enum.extern.for.goto.if.inline.register.restrict.return.sizeof.static.struct.switch.typedef.union.volatile.while._Alignas._Alignof._Atomic._Generic._Noreturn._Static_assert._Thread_local`.split(`.`)),UA=s({keywords:()=>WA,onCommentEnd:()=>zA,onCommentStart:()=>RA,typeKeywords:()=>GA}),WA=new Set(`alignas.alignof.and.and_eq.asm.auto.bitand.bitor.break.case.catch.class.compl.concept.const.consteval.constexpr.constinit.const_cast.continue.co_await.co_return.co_yield.decltype.default.delete.do.dynamic_cast.else.enum.explicit.export.extern.false.for.friend.goto.if.inline.mutable.namespace.new.noexcept.not.not_eq.nullptr.operator.or.or_eq.private.protected.public.register.reinterpret_cast.requires.return.sizeof.static.static_assert.static_cast.struct.switch.template.this.thread_local.throw.true.try.typedef.typeid.typename.union.using.virtual.volatile.while.xor.xor_eq`.split(`.`)),GA=new Set([`bool`,`char`,`char8_t`,`char16_t`,`char32_t`,`double`,`float`,`int`,`long`,`short`,`signed`,`unsigned`,`void`,`wchar_t`]),KA=s({keywords:()=>qA,onCommentEnd:()=>zA,onCommentStart:()=>RA,typeKeywords:()=>JA}),qA=new Set(`abstract.as.async.await.base.break.case.catch.checked.class.const.continue.default.delegate.do.else.enum.event.explicit.extern.false.finally.fixed.for.foreach.from.get.global.goto.if.implicit.in.init.interface.internal.into.is.join.let.lock.namespace.new.null.on.operator.orderby.out.override.params.partial.private.protected.public.readonly.record.ref.remove.required.return.sealed.select.set.sizeof.stackalloc.static.struct.switch.this.throw.true.try.typeof.unchecked.unsafe.using.value.virtual.volatile.when.where.while.with.yield`.split(`.`)),JA=new Set([`bool`,`byte`,`char`,`decimal`,`double`,`dynamic`,`float`,`int`,`long`,`nint`,`nuint`,`object`,`sbyte`,`short`,`string`,`uint`,`ulong`,`ushort`,`void`]),YA=s({keywords:()=>XA,onCommentEnd:()=>QA,onCommentStart:()=>ZA,onLiteral:()=>$A,tokenize:()=>sj}),XA=new Set([`@media`,`@import`,`@keyframes`,`@font-face`,`@supports`,`@page`,`@counter-style`,`@font-feature-values`,`@viewport`,`@counter-style`,`@font-feature-values`,`@document`]),ZA=(e,t)=>+(e+t===`/*`),QA=(e,t)=>+(e+t===`*/`),$A=(e,t,n)=>e===`#`&&n.slice(t).match(/^#(?:[\da-f]{8}|[\da-f]{6}|[\da-f]{4}|[\da-f]{3})(?![\w-])/i)?.[0].length||0,ej=e=>e===wA||e===CA||e===SA,tj=([e,t])=>e===mA||e===_A||e===xA&&t===`-`,nj=([e])=>e===mA||e===_A||e===vA,rj=e=>nj(e)&&!/^\d/.test(e[1]),ij=([e,t])=>e===xA&&t===`-`,aj=e=>{for(let t=0;t<e.length;t++){let n=t,r=t;if(ij(e[r])){for(;e[r]&&ij(e[r]);)r++;if(!e[r]||!rj(e[r]))continue;n=r++}else if(rj(e[r]))r++;else continue;let i=n>t;for(;e[r]&&ij(e[r]);){let t=r;for(;e[r]&&ij(e[r]);)r++;if(!e[r]||!nj(e[r])){r=t;break}i=!0,r++}if(!i)continue;let a=e.slice(t,r).map(([,e])=>e).join(``);e.splice(t,r-t,[e[n][0],a])}},oj=(e,t)=>{let n=0,r=0;for(let i=t;i<e.length;i++){let[t,a]=e[i];if(t===xA){if(a===`(`)n++;else if(a===`)`)n--;else if(a===`[`)r++;else if(a===`]`)r--;else if(!n&&!r&&a===`{`)return!0;else if(!n&&!r&&(a===`;`||a===`}`))return!1}}return!1},sj=(e,t)=>{let n=IA(e,{...t,tokenize:void 0});aj(n);let r=0,i=!1;for(let e=0;e<n.length;e++){let[t,a]=n[e];if(t===xA&&a===`{`){r++,i=!0;continue}if(t===xA&&a===`}`){r--,i=!1;continue}if(t===xA&&a===`;`){i=r>0;continue}if(!i||ej(t))continue;let o=e,s=e;for(;s<n.length&&tj(n[s]);)s++;let c=s;for(;c<n.length&&ej(n[c][0]);)c++;if(s>o&&n[c]?.[0]===xA&&n[c][1]===`:`&&!oj(n,c+1)){let e=n.slice(o,s).map(([,e])=>e).join(``);n.splice(o,s-o,[vA,e])}i=!1}return n},cj=s({annotateLine:()=>uj,keywords:()=>lj}),lj=new Set([]),uj=e=>{let t=``;if(e.value.startsWith(`+`)&&!e.value.startsWith(`+++`))t=`diff-add`;else if(e.value.startsWith(`-`)&&!e.value.startsWith(`---`))t=`diff-remove`;else if(e.value.startsWith(`@@`))t=`diff-hunk`;else if(/^(diff --git|index |--- |\+\+\+ )/.test(e.value)){t=`diff-meta`;for(let t of e.tokens)t.type===`property`&&(t.type=`identifier`)}t&&e.annotations.push(t)},dj=e=>+(e===`#`),fj=(e,t)=>+(t===`
138
- `),pj=s({caseInsensitive:()=>!0,keywords:()=>mj,onCommentEnd:()=>fj,onCommentStart:()=>dj}),mj=new Set([`add`,`arg`,`cmd`,`copy`,`entrypoint`,`env`,`expose`,`from`,`healthcheck`,`label`,`maintainer`,`onbuild`,`run`,`shell`,`stopsignal`,`user`,`volume`,`workdir`]),hj=s({keywords:()=>_j,onCommentEnd:()=>zA,onCommentStart:()=>RA,typeKeywords:()=>gj}),gj=new Set([`bool`,`byte`,`complex64`,`complex128`,`error`,`float32`,`float64`,`int`,`int8`,`int16`,`int32`,`int64`,`rune`,`string`,`uint`,`uint8`,`uint16`,`uint32`,`uint64`,`uintptr`]),_j=new Set([`break`,`case`,`chan`,`const`,`continue`,`default`,`defer`,`else`,`fallthrough`,`for`,`func`,`go`,`goto`,`if`,`import`,`interface`,`map`,`package`,`range`,`return`,`select`,`struct`,`switch`,`type`,`var`]),vj=s({keywords:()=>yj,onCommentEnd:()=>fj,onCommentStart:()=>dj,typeKeywords:()=>bj}),yj=new Set([`directive`,`enum`,`extend`,`fragment`,`implements`,`input`,`interface`,`mutation`,`on`,`query`,`repeatable`,`scalar`,`schema`,`subscription`,`type`,`union`]),bj=new Set([`Boolean`,`Float`,`ID`,`Int`,`String`]),xj=s({keywords:()=>Sj,onCommentEnd:()=>wj,onCommentStart:()=>Cj}),Sj=new Set([`false`,`for`,`if`,`in`,`null`,`true`]),Cj=(e,t)=>e===`#`||e+t===`//`?1:e+t===`/*`?2:0,wj=(e,t)=>t===`
139
- `?1:e+t===`*/`?2:0,Tj=new Set([`<`,`>`,`{`,`}`,`[`,`]`]),Ej=new Set(`for.do.while.if.else.return.function.var.let.const.true.false.undefined.this.new.delete.typeof.in.instanceof.void.break.continue.switch.case.default.throw.try.catch.finally.debugger.with.yield.async.await.class.extends.super.import.export.from.static`.split(`.`)),Dj=new Set([...Ej,`type`,`interface`,`enum`,`implements`,`readonly`,`abstract`,`declare`,`namespace`,`module`,`private`,`protected`,`public`,`override`,`keyof`,`infer`,`is`,`asserts`,`satisfies`,`as`,`unknown`,`never`,`any`,`number`,`string`,`boolean`,`bigint`,`symbol`,`object`]),Oj=new Set([`+`,`-`,`*`,`/`,`%`,`=`,`!`,`&`,`|`,`^`,`~`,`!`,`?`,`:`,`.`,`,`,`;`,`'`,`"`,`.`,`(`,`)`,`[`,`]`,`#`,`@`,`\\`,...Tj]),kj={keywords:Ej,onCommentStart:Hj,onCommentEnd:Uj,jsx:!0,regex:!0,templateStrings:!0};function Aj(e){return{...kj,...e}}function jj(e){let t=0;return/\binterface\s+[A-Za-z_$][\w$]*/.test(e)&&(t+=2),/\btype\s+[A-Za-z_$][\w$]*\s*=/.test(e)&&(t+=2),/\benum\s+[A-Za-z_$][\w$]*/.test(e)&&(t+=2),/\b(?:implements|readonly|declare|namespace|satisfies|infer|keyof|asserts)\b/.test(e)&&(t+=2),/:\s*[A-Za-z_$][\w$]*(?:<[^>\n]+>)?(?:\[\])?(?=\s*[,)=;{])/m.test(e)&&(t+=1),/\b(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*:\s*/.test(e)&&(t+=1),/\)\s*:\s*[A-Za-z_$][\w$]*(?:<[^>\n]+>)?(?:\[\])?\s*(?:=>|\{)/.test(e)&&(t+=1),t>=2}function Mj(e,t){if(e[t]!==`<`)return!1;let n=0,r=!1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`<`){n++;continue}if(t===`>`){if(n--,n===0){let t=i+1;for(;t<e.length&&/\s/.test(e[t]);)t++;if(!(r&&e[t]===`(`))return!1;let n=e.slice(t,t+320);return/\)\s*(?::[\s\S]{0,120}?)?=>/.test(n)}continue}if(n!==0){if(/[$A-Za-z_]/.test(t)){r=!0;continue}if(!/[\s,\.\=\?\:\|\&\[\]]/.test(t))return!1}}return!1}function Nj(e){return/^[^\S\r\n]+$/g.test(e)}function Pj(e){return Oj.has(e)}function Fj(e){return/^[\w$\u0080-\uffff]+$/.test(e||``)}function Ij(e){return/^[0-9A-Z\p{Lu}]/u.test(e)||e===`null`}function Lj(e){return/^[a-zA-Z]$/.test(e)}function Rj(e){return/^[$_A-Za-z\u0080-\uffff]$/.test(e||``)}function zj(e){return Rj(e[0])&&Fj(e)}function Bj(e){return e==="`"}function Vj(e){return e===`"`||e===`'`}function Hj(e,t){let n=e+t;return n===`/*`?2:+(n===`//`)}function Uj(e,t){return e+t===`*/`?2:+(t===`
140
- `)}function Wj(e){return e[0]===`/`&&!Hj(e[0],e[1])}function Gj(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n++;return e[n]===`:`}function Kj(e,t){let n=Aj(t),r=n.keywords!==kj.keywords,i=typeof n.typescript==`boolean`?n.typescript:jj(e),a=r?n.keywords:i?Dj:Ej,{onCommentStart:o,onCommentEnd:s}=n,c=n.typeKeywords instanceof Set?n.typeKeywords:null,l=n.jsx!==!1,u=n.regex!==!1,d=n.templateStrings!==!1,f=n.caseInsensitive?e=>e.toLowerCase():e=>e,p=e=>d&&Bj(e),m=``,h=-1,g=[-1,``],_=[-2,``],v=[],y=!1,b=0,x=0,S=0,C=0,w=()=>y&&!x&&!b,T=()=>b,E=()=>w()&&C,D=null,O=0,k=!1,A=0,j=0,M=()=>D!==null,ee=()=>k,N=()=>j>A,P=()=>j>0&&j===A,te=()=>M()||N();function ne(e){let t=e===`
141
- `;if(T()){if(M())return gA;let[,t]=g;if(zj(e)){if(t===`<`||t===`</`)return yA;if(!S&&/^\s+$/.test(v[v.length-1]?.[1]||``))return vA}}if(E())return bA;if(M()||N())return gA;if(c&&c.has(f(e)))return g[1]===`.`?mA:_A;if(a.has(f(e)))return g[1]===`.`?mA:hA;if(t)return CA;if(Nj(e))return wA;if(e.split(``).every(Pj))return xA;if(Ij(e))return T()&&!S?mA:_A;if(zj(e)){let e=g[1]===`.`&&zj(_[1]);if(!te()&&!e)return mA;if(e)return vA}return gA}let F=(e,t)=>{if(t&&(m=t),m){h=typeof e==`number`?e:ne(m);let t=[h,m];h!==wA&&h!==CA&&(_=g,g=t),T()&&h===xA&&(m===`{`&&S++,m===`}`&&S--),v.push(t)}m=``};for(let t=0;t<e.length;t++){let r=e[t],i=e[t-1],c=e[t+1],d=i+r,f=r+c;if(typeof n.onQuote==`function`&&r===`'`&&!M()&&!E()&&!N()){let i=n.onQuote(r,t,e);if(typeof i==`number`&&i>=1&&!Number.isNaN(i)){let n=Math.min(i,e.length-t),r=t+n;F(),m=e.slice(t,r),F(mA),t=r-1;continue}}if(Vj(r)&&!E()&&!N()){F();let i=!1;if(D&&r===D?(D=null,i=!0):D||(D=r,O=v.length),F(gA,r),n.quotedKeys&&i&&Gj(e,t))for(let e=O;e<v.length;e++)v[e][0]=vA;continue}if(p(r)){F(),j+=N()?-1:1,F(gA,r);continue}if(N()&&f==="${"){A++,F(gA),F(xA,f),t++;continue}if(P()&&r===`}`){F(),A--,F(xA,r);continue}if(w()&&r===`{`){F(),F(xA,r),x=1;continue}if(y){if(!b&&r===`<`){F(),c===`/`?(b=2,m=f,t++):(b=1,m=r),F(xA);continue}if(b){if(r===`>`&&!`/=`.includes(i)){F(),b===1?(b=0,C++):(b=0,y=!1),F(xA,r);continue}if(f===`/>`||f===`</`){m!==`<`&&m!==`/`&&F(),f===`/>`?b=0:C--,C||(y=!1),m=f,t++,F(xA);continue}if(r===`<`){F(),m=r,F(xA);continue}if(r===`-`&&m&&!te()&&!E()){let n=t+1;for(;n<e.length&&/[$\w-]/.test(e[n]);)n++;F(vA,m+e.slice(t,n)),t=n-1;continue}if(c===`=`&&!te()&&!Nj(r)){Nj(m)&&F();let e=m+r;if(zj(e)){F(vA,e);continue}}}}if(l&&!b&&(r===`<`&&Rj(c)||f===`</`)){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;let i=n>=0?e[n]:``,[o,s]=g,l=!1,u=!1;if(m&&!Nj(m)){let e=m;Ij(e)||e===`true`||e===`false`?l=!0:a.has(e)&&zj(e)?u=!0:zj(e)&&(l=!0)}let d=r===`<`&&/[$\w\]\)]/.test(i)&&(l||!u&&(o===mA||o===_A||o===xA&&(s===`)`||s===`]`))),f=r===`<`&&Mj(e,t);!d&&!f&&(b=c===`/`?2:1),r===`<`&&(c===`/`||Lj(c))&&!d&&!f&&!te()&&!E()&&!ee()&&(y=!0)}let h=Vj(r)||p(r),_=N(),S=u&&!y&&Wj(f),T=E();if(h||_||Vj(D))m+=r,r===`\\`&&(m+=e[++t]||``);else if(S){F();let[n,i]=g;if(S&&n!==-1&&!(n===xA&&i!==`)`||n===SA)){m=r,F();continue}k=!0;let a=t++,o=!1,s=!1;for(;t<e.length&&e[t]!==`
133
+ `);for(let t=0;t<e.length;t++)i.push([r,e[t]]),t<e.length-1&&(o(i),i.length=0)}else i.push(n);a=!1}else a?o([]):(o(i),i.length=0),e===t.length-1&&o([]),a=!0}return i.length&&o(i),{value:e,lines:n}}function DA(e,t){let n={index:e.index,value:e.value,tokens:e.tokens,annotations:e.annotations,className:`sh__line${e.annotations.map(e=>` sh__line--${e}`).join(``)}`,style:{},properties:{}};return t?.(n),n}function OA({type:e,value:t},n,r){let i=n?.[e],a={type:e,value:t,className:`sh__token--${e}${i?` ${i}`:``}`,style:{color:`var(--sh-${e})`},properties:{}};return r?.(a),a}function kA(e,t){let n=t?.cx,r=t?.mark,i=t?.markLine;return!n&&!r&&!i?e.lines.map(e=>{let t=`sh__line${e.annotations.map(e=>` sh__line--${e}`).join(``)}`,n=e.tokens.map(({type:e,value:t})=>`<span class="sh__token--${e}" style="color:var(--sh-${e})">${jA(t)}</span>`).join(``);return`<span class="${jA(t)}">${n}</span>`}).join(`
134
+ `):e.lines.map(e=>{let t=DA(e,i),a=e.tokens.map(e=>{let t=OA(e,n,r);return`<span ${MA({...t.properties,className:t.className,style:t.style})}>${jA(t.value)}</span>`}).join(``);return`<span ${MA({...t.properties,className:t.className,style:t.style})}>${a}</span>`}).join(`
135
+ `)}var AA={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#039;`},jA=e=>e.replace(/[&<>"']/g,e=>AA[e]);function MA(e){let t=Object.entries(e.style||{}).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${t}`).join(`;`),n=Object.entries(e).filter(([e,t])=>/^[\w:-]+$/.test(e)&&e!==`className`&&e!==`style`&&t!==!1&&t!=null).map(([e,t])=>t===!0?e:`${e}="${jA(String(t))}"`).join(` `);return`class="${jA(e.className||``)}"${t?` style="${jA(t)}"`:``}${n?` ${n}`:``}`}var NA=new Set(`+-*/%=!&|^~?:.,;()[]{}<>#@\\`.split(``)),PA=()=>0,FA=e=>e===`_`||e===`$`||/[\p{L}\p{N}]/u.test(e);function IA(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return e[t]===`:`}function LA(e,t){if(typeof t?.tokenize==`function`)return t.tokenize(e,t);let n=t?.keywords||new Set,r=t?.typeKeywords||new Set,i=t?.onCommentStart||PA,a=t?.onCommentEnd||PA,o=t?.caseInsensitive?e=>e.toLowerCase():e=>e,s=[],c=``;function l(e,t){t&&(s.push([e,t]),e!==TA&&e!==wA&&(c=t))}for(let s=0;s<e.length;){let u=e[s],d=e[s+1],f=i(u,d,s,e);if(f){let t=s++;for(;s<e.length;){if(a(e[s-1],e[s],s,e,t)==f){s++;break}s++}l(CA,e.slice(t,s));continue}let p=t?.onLiteral?.(u,s,e);if(p){l(_A,e.slice(s,s+p)),s+=p;continue}if(typeof t?.onQuote==`function`&&u===`'`){let n=t.onQuote(u,s,e);if(typeof n==`number`&&n>=1){l(hA,e.slice(s,s+n)),s+=n;continue}}if(u===`"`||u===`'`||t?.templateStrings&&u==="`"){let n=u,r=s++;for(;s<e.length;){if(e[s]===`\\`)s++;else if(e[s]===n){s++;break}s++}let i=e.slice(r,s);l(t?.quotedKeys&&IA(e,s)?yA:_A,i);continue}if(u===`
136
+ `){l(wA,u),s++;continue}if(/[^\S\r\n]/.test(u)){let t=s++;for(;s<e.length&&/[^\S\r\n]/.test(e[s]);)s++;l(TA,e.slice(t,s));continue}if(FA(u)){let t=s++;for(;s<e.length&&FA(e[s]);)s++;if(/^\d/.test(u)&&e[s]===`.`&&/\d/.test(e[s+1]||``))for(s++;s<e.length&&FA(e[s]);)s++;let i=e.slice(t,s),a=o(i);l(r.has(a)?vA:n.has(a)?gA:c===`.`?yA:/^\d/.test(i)||i===`null`||/^\p{Lu}/u.test(i)?vA:hA,i);continue}if(NA.has(u)){l(SA,u),s++;continue}l(_A,u),s++}return s}function RA(e,t){let n=EA(e,LA(e,t));if(t?.annotateLine)for(let e of n.lines)t.annotateLine(e);return n}var zA=(e,t)=>{let n=e+t;return n===`//`?1:n===`/*`?2:0},BA=(e,t)=>t===`
137
+ `?1:e+t===`*/`?2:0,VA=s({keywords:()=>UA,onCommentEnd:()=>BA,onCommentStart:()=>zA,typeKeywords:()=>HA}),HA=new Set([`void`,`char`,`short`,`int`,`long`,`float`,`double`,`signed`,`unsigned`,`_Bool`,`_Complex`,`_Imaginary`]),UA=new Set(`auto.break.case.const.continue.default.do.else.enum.extern.for.goto.if.inline.register.restrict.return.sizeof.static.struct.switch.typedef.union.volatile.while._Alignas._Alignof._Atomic._Generic._Noreturn._Static_assert._Thread_local`.split(`.`)),WA=s({keywords:()=>GA,onCommentEnd:()=>BA,onCommentStart:()=>zA,typeKeywords:()=>KA}),GA=new Set(`alignas.alignof.and.and_eq.asm.auto.bitand.bitor.break.case.catch.class.compl.concept.const.consteval.constexpr.constinit.const_cast.continue.co_await.co_return.co_yield.decltype.default.delete.do.dynamic_cast.else.enum.explicit.export.extern.false.for.friend.goto.if.inline.mutable.namespace.new.noexcept.not.not_eq.nullptr.operator.or.or_eq.private.protected.public.register.reinterpret_cast.requires.return.sizeof.static.static_assert.static_cast.struct.switch.template.this.thread_local.throw.true.try.typedef.typeid.typename.union.using.virtual.volatile.while.xor.xor_eq`.split(`.`)),KA=new Set([`bool`,`char`,`char8_t`,`char16_t`,`char32_t`,`double`,`float`,`int`,`long`,`short`,`signed`,`unsigned`,`void`,`wchar_t`]),qA=s({keywords:()=>JA,onCommentEnd:()=>BA,onCommentStart:()=>zA,typeKeywords:()=>YA}),JA=new Set(`abstract.as.async.await.base.break.case.catch.checked.class.const.continue.default.delegate.do.else.enum.event.explicit.extern.false.finally.fixed.for.foreach.from.get.global.goto.if.implicit.in.init.interface.internal.into.is.join.let.lock.namespace.new.null.on.operator.orderby.out.override.params.partial.private.protected.public.readonly.record.ref.remove.required.return.sealed.select.set.sizeof.stackalloc.static.struct.switch.this.throw.true.try.typeof.unchecked.unsafe.using.value.virtual.volatile.when.where.while.with.yield`.split(`.`)),YA=new Set([`bool`,`byte`,`char`,`decimal`,`double`,`dynamic`,`float`,`int`,`long`,`nint`,`nuint`,`object`,`sbyte`,`short`,`string`,`uint`,`ulong`,`ushort`,`void`]),XA=s({keywords:()=>ZA,onCommentEnd:()=>$A,onCommentStart:()=>QA,onLiteral:()=>ej,tokenize:()=>cj}),ZA=new Set([`@media`,`@import`,`@keyframes`,`@font-face`,`@supports`,`@page`,`@counter-style`,`@font-feature-values`,`@viewport`,`@counter-style`,`@font-feature-values`,`@document`]),QA=(e,t)=>+(e+t===`/*`),$A=(e,t)=>+(e+t===`*/`),ej=(e,t,n)=>e===`#`&&n.slice(t).match(/^#(?:[\da-f]{8}|[\da-f]{6}|[\da-f]{4}|[\da-f]{3})(?![\w-])/i)?.[0].length||0,tj=e=>e===TA||e===wA||e===CA,nj=([e,t])=>e===hA||e===vA||e===SA&&t===`-`,rj=([e])=>e===hA||e===vA||e===yA,ij=e=>rj(e)&&!/^\d/.test(e[1]),aj=([e,t])=>e===SA&&t===`-`,oj=e=>{for(let t=0;t<e.length;t++){let n=t,r=t;if(aj(e[r])){for(;e[r]&&aj(e[r]);)r++;if(!e[r]||!ij(e[r]))continue;n=r++}else if(ij(e[r]))r++;else continue;let i=n>t;for(;e[r]&&aj(e[r]);){let t=r;for(;e[r]&&aj(e[r]);)r++;if(!e[r]||!rj(e[r])){r=t;break}i=!0,r++}if(!i)continue;let a=e.slice(t,r).map(([,e])=>e).join(``);e.splice(t,r-t,[e[n][0],a])}},sj=(e,t)=>{let n=0,r=0;for(let i=t;i<e.length;i++){let[t,a]=e[i];if(t===SA){if(a===`(`)n++;else if(a===`)`)n--;else if(a===`[`)r++;else if(a===`]`)r--;else if(!n&&!r&&a===`{`)return!0;else if(!n&&!r&&(a===`;`||a===`}`))return!1}}return!1},cj=(e,t)=>{let n=LA(e,{...t,tokenize:void 0});oj(n);let r=0,i=!1;for(let e=0;e<n.length;e++){let[t,a]=n[e];if(t===SA&&a===`{`){r++,i=!0;continue}if(t===SA&&a===`}`){r--,i=!1;continue}if(t===SA&&a===`;`){i=r>0;continue}if(!i||tj(t))continue;let o=e,s=e;for(;s<n.length&&nj(n[s]);)s++;let c=s;for(;c<n.length&&tj(n[c][0]);)c++;if(s>o&&n[c]?.[0]===SA&&n[c][1]===`:`&&!sj(n,c+1)){let e=n.slice(o,s).map(([,e])=>e).join(``);n.splice(o,s-o,[yA,e])}i=!1}return n},lj=s({annotateLine:()=>dj,keywords:()=>uj}),uj=new Set([]),dj=e=>{let t=``;if(e.value.startsWith(`+`)&&!e.value.startsWith(`+++`))t=`diff-add`;else if(e.value.startsWith(`-`)&&!e.value.startsWith(`---`))t=`diff-remove`;else if(e.value.startsWith(`@@`))t=`diff-hunk`;else if(/^(diff --git|index |--- |\+\+\+ )/.test(e.value)){t=`diff-meta`;for(let t of e.tokens)t.type===`property`&&(t.type=`identifier`)}t&&e.annotations.push(t)},fj=e=>+(e===`#`),pj=(e,t)=>+(t===`
138
+ `),mj=s({caseInsensitive:()=>!0,keywords:()=>hj,onCommentEnd:()=>pj,onCommentStart:()=>fj}),hj=new Set([`add`,`arg`,`cmd`,`copy`,`entrypoint`,`env`,`expose`,`from`,`healthcheck`,`label`,`maintainer`,`onbuild`,`run`,`shell`,`stopsignal`,`user`,`volume`,`workdir`]),gj=s({keywords:()=>vj,onCommentEnd:()=>BA,onCommentStart:()=>zA,typeKeywords:()=>_j}),_j=new Set([`bool`,`byte`,`complex64`,`complex128`,`error`,`float32`,`float64`,`int`,`int8`,`int16`,`int32`,`int64`,`rune`,`string`,`uint`,`uint8`,`uint16`,`uint32`,`uint64`,`uintptr`]),vj=new Set([`break`,`case`,`chan`,`const`,`continue`,`default`,`defer`,`else`,`fallthrough`,`for`,`func`,`go`,`goto`,`if`,`import`,`interface`,`map`,`package`,`range`,`return`,`select`,`struct`,`switch`,`type`,`var`]),yj=s({keywords:()=>bj,onCommentEnd:()=>pj,onCommentStart:()=>fj,typeKeywords:()=>xj}),bj=new Set([`directive`,`enum`,`extend`,`fragment`,`implements`,`input`,`interface`,`mutation`,`on`,`query`,`repeatable`,`scalar`,`schema`,`subscription`,`type`,`union`]),xj=new Set([`Boolean`,`Float`,`ID`,`Int`,`String`]),Sj=s({keywords:()=>Cj,onCommentEnd:()=>Tj,onCommentStart:()=>wj}),Cj=new Set([`false`,`for`,`if`,`in`,`null`,`true`]),wj=(e,t)=>e===`#`||e+t===`//`?1:e+t===`/*`?2:0,Tj=(e,t)=>t===`
139
+ `?1:e+t===`*/`?2:0,Ej=new Set([`<`,`>`,`{`,`}`,`[`,`]`]),Dj=new Set(`for.do.while.if.else.return.function.var.let.const.true.false.undefined.this.new.delete.typeof.in.instanceof.void.break.continue.switch.case.default.throw.try.catch.finally.debugger.with.yield.async.await.class.extends.super.import.export.from.static`.split(`.`)),Oj=new Set([...Dj,`type`,`interface`,`enum`,`implements`,`readonly`,`abstract`,`declare`,`namespace`,`module`,`private`,`protected`,`public`,`override`,`keyof`,`infer`,`is`,`asserts`,`satisfies`,`as`,`unknown`,`never`,`any`,`number`,`string`,`boolean`,`bigint`,`symbol`,`object`]),kj=new Set([`+`,`-`,`*`,`/`,`%`,`=`,`!`,`&`,`|`,`^`,`~`,`!`,`?`,`:`,`.`,`,`,`;`,`'`,`"`,`.`,`(`,`)`,`[`,`]`,`#`,`@`,`\\`,...Ej]),Aj={keywords:Dj,onCommentStart:Uj,onCommentEnd:Wj,jsx:!0,regex:!0,templateStrings:!0};function jj(e){return{...Aj,...e}}function Mj(e){let t=0;return/\binterface\s+[A-Za-z_$][\w$]*/.test(e)&&(t+=2),/\btype\s+[A-Za-z_$][\w$]*\s*=/.test(e)&&(t+=2),/\benum\s+[A-Za-z_$][\w$]*/.test(e)&&(t+=2),/\b(?:implements|readonly|declare|namespace|satisfies|infer|keyof|asserts)\b/.test(e)&&(t+=2),/:\s*[A-Za-z_$][\w$]*(?:<[^>\n]+>)?(?:\[\])?(?=\s*[,)=;{])/m.test(e)&&(t+=1),/\b(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*:\s*/.test(e)&&(t+=1),/\)\s*:\s*[A-Za-z_$][\w$]*(?:<[^>\n]+>)?(?:\[\])?\s*(?:=>|\{)/.test(e)&&(t+=1),t>=2}function Nj(e,t){if(e[t]!==`<`)return!1;let n=0,r=!1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`<`){n++;continue}if(t===`>`){if(n--,n===0){let t=i+1;for(;t<e.length&&/\s/.test(e[t]);)t++;if(!(r&&e[t]===`(`))return!1;let n=e.slice(t,t+320);return/\)\s*(?::[\s\S]{0,120}?)?=>/.test(n)}continue}if(n!==0){if(/[$A-Za-z_]/.test(t)){r=!0;continue}if(!/[\s,\.\=\?\:\|\&\[\]]/.test(t))return!1}}return!1}function Pj(e){return/^[^\S\r\n]+$/g.test(e)}function Fj(e){return kj.has(e)}function Ij(e){return/^[\w$\u0080-\uffff]+$/.test(e||``)}function Lj(e){return/^[0-9A-Z\p{Lu}]/u.test(e)||e===`null`}function Rj(e){return/^[a-zA-Z]$/.test(e)}function zj(e){return/^[$_A-Za-z\u0080-\uffff]$/.test(e||``)}function Bj(e){return zj(e[0])&&Ij(e)}function Vj(e){return e==="`"}function Hj(e){return e===`"`||e===`'`}function Uj(e,t){let n=e+t;return n===`/*`?2:+(n===`//`)}function Wj(e,t){return e+t===`*/`?2:+(t===`
140
+ `)}function Gj(e){return e[0]===`/`&&!Uj(e[0],e[1])}function Kj(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n++;return e[n]===`:`}function qj(e,t){let n=jj(t),r=n.keywords!==Aj.keywords,i=typeof n.typescript==`boolean`?n.typescript:Mj(e),a=r?n.keywords:i?Oj:Dj,{onCommentStart:o,onCommentEnd:s}=n,c=n.typeKeywords instanceof Set?n.typeKeywords:null,l=n.jsx!==!1,u=n.regex!==!1,d=n.templateStrings!==!1,f=n.caseInsensitive?e=>e.toLowerCase():e=>e,p=e=>d&&Vj(e),m=``,h=-1,g=[-1,``],_=[-2,``],v=[],y=!1,b=0,x=0,S=0,C=0,w=()=>y&&!x&&!b,T=()=>b,E=()=>w()&&C,D=null,O=0,k=!1,A=0,j=0,M=()=>D!==null,ee=()=>k,N=()=>j>A,P=()=>j>0&&j===A,te=()=>M()||N();function ne(e){let t=e===`
141
+ `;if(T()){if(M())return _A;let[,t]=g;if(Bj(e)){if(t===`<`||t===`</`)return bA;if(!S&&/^\s+$/.test(v[v.length-1]?.[1]||``))return yA}}if(E())return xA;if(M()||N())return _A;if(c&&c.has(f(e)))return g[1]===`.`?hA:vA;if(a.has(f(e)))return g[1]===`.`?hA:gA;if(t)return wA;if(Pj(e))return TA;if(e.split(``).every(Fj))return SA;if(Lj(e))return T()&&!S?hA:vA;if(Bj(e)){let e=g[1]===`.`&&Bj(_[1]);if(!te()&&!e)return hA;if(e)return yA}return _A}let F=(e,t)=>{if(t&&(m=t),m){h=typeof e==`number`?e:ne(m);let t=[h,m];h!==TA&&h!==wA&&(_=g,g=t),T()&&h===SA&&(m===`{`&&S++,m===`}`&&S--),v.push(t)}m=``};for(let t=0;t<e.length;t++){let r=e[t],i=e[t-1],c=e[t+1],d=i+r,f=r+c;if(typeof n.onQuote==`function`&&r===`'`&&!M()&&!E()&&!N()){let i=n.onQuote(r,t,e);if(typeof i==`number`&&i>=1&&!Number.isNaN(i)){let n=Math.min(i,e.length-t),r=t+n;F(),m=e.slice(t,r),F(hA),t=r-1;continue}}if(Hj(r)&&!E()&&!N()){F();let i=!1;if(D&&r===D?(D=null,i=!0):D||(D=r,O=v.length),F(_A,r),n.quotedKeys&&i&&Kj(e,t))for(let e=O;e<v.length;e++)v[e][0]=yA;continue}if(p(r)){F(),j+=N()?-1:1,F(_A,r);continue}if(N()&&f==="${"){A++,F(_A),F(SA,f),t++;continue}if(P()&&r===`}`){F(),A--,F(SA,r);continue}if(w()&&r===`{`){F(),F(SA,r),x=1;continue}if(y){if(!b&&r===`<`){F(),c===`/`?(b=2,m=f,t++):(b=1,m=r),F(SA);continue}if(b){if(r===`>`&&!`/=`.includes(i)){F(),b===1?(b=0,C++):(b=0,y=!1),F(SA,r);continue}if(f===`/>`||f===`</`){m!==`<`&&m!==`/`&&F(),f===`/>`?b=0:C--,C||(y=!1),m=f,t++,F(SA);continue}if(r===`<`){F(),m=r,F(SA);continue}if(r===`-`&&m&&!te()&&!E()){let n=t+1;for(;n<e.length&&/[$\w-]/.test(e[n]);)n++;F(yA,m+e.slice(t,n)),t=n-1;continue}if(c===`=`&&!te()&&!Pj(r)){Pj(m)&&F();let e=m+r;if(Bj(e)){F(yA,e);continue}}}}if(l&&!b&&(r===`<`&&zj(c)||f===`</`)){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;let i=n>=0?e[n]:``,[o,s]=g,l=!1,u=!1;if(m&&!Pj(m)){let e=m;Lj(e)||e===`true`||e===`false`?l=!0:a.has(e)&&Bj(e)?u=!0:Bj(e)&&(l=!0)}let d=r===`<`&&/[$\w\]\)]/.test(i)&&(l||!u&&(o===hA||o===vA||o===SA&&(s===`)`||s===`]`))),f=r===`<`&&Nj(e,t);!d&&!f&&(b=c===`/`?2:1),r===`<`&&(c===`/`||Rj(c))&&!d&&!f&&!te()&&!E()&&!ee()&&(y=!0)}let h=Hj(r)||p(r),_=N(),S=u&&!y&&Gj(f),T=E();if(h||_||Hj(D))m+=r,r===`\\`&&(m+=e[++t]||``);else if(S){F();let[n,i]=g;if(S&&n!==-1&&!(n===SA&&i!==`)`||n===CA)){m=r,F();continue}k=!0;let a=t++,o=!1,s=!1;for(;t<e.length&&e[t]!==`
142
142
  `;t++){let n=e[t];if(n===`\\`){if(e[t+1]===`
143
- `)break;t++;continue}if(n===`[`&&(s=!0),n===`]`&&(s=!1),n===`/`&&!s){for(o=!0;/^[a-z]$/.test(e[t+1]);)t++;break}}k=!1,a!==t&&o?(m=e.slice(a,t+1),F(gA)):(m=r,F(),t=a)}else if(o(r,c,t,e)){F();let n=t,i=o(r,c,t,e);if(i)for(;t<e.length&&s(e[t-1],e[t],t,e)!=i;t++);m=e.slice(n,t+1),F(SA)}else if(r===` `||r===`
144
- `){if(r===` `&&(Nj(m)||!m||T)){let n=t+1;for(;e[n]===` `;)n++;m+=e.slice(t,n),t=n-1,e[n]===`<`&&F()}else F(),m=r,F()}else x&&r===`}`?(F(),m=r,F(),x--):T&&!Tj.has(r)||N()||(Fj(r)===Fj(m[m.length-1])||w())&&!Oj.has(r)?m+=r:(d===`</`&&(m=d),F(),d!==`</`&&(m=r),f===`</`||f===`/>`?(m=f,F(),t++):Tj.has(r)&&F()),x&&r===`{`&&x++}return F(),v}var qj=s({tokenize:()=>Jj}),Jj=Kj,Yj={keywords:new Set,jsx:!0,regex:!1,templateStrings:!1,onCommentStart:(e,t,n,r)=>r.startsWith(`<!--`,n)?2:0,onCommentEnd:(e,t,n,r)=>r.slice(n-2,n+1)===`-->`?2:0},Xj=e=>Jj(e,Yj),Zj=/^<\s*(script|style)\b/i,Qj=e=>RegExp(`</\\s*${e}\\s*>`,`ig`);function $j(e,t){let n=``;for(let r=t;r<e.length;r++){let t=e[r];if(n)t===n&&(n=``);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return r+1}return-1}function eM(e){let t=[],n=0;for(;n<e.length;){if(e.startsWith(`<!--`,n)){let t=e.indexOf(`-->`,n+4);n=t===-1?e.length:t+3;continue}if(e[n]!==`<`){n++;continue}let r=$j(e,n);if(r===-1)break;let i=e.slice(n,r).match(Zj);if(!i){n=r;continue}let a=i[1].toLowerCase(),o=Qj(a);o.lastIndex=r;let s=o.exec(e);if(!s){n=r;continue}t.push({start:n,openEnd:r,closeStart:s.index,end:o.lastIndex,tag:a}),n=o.lastIndex}return t}function tM(e){let t=[],n=0;for(let r of eM(e)){let{start:i,openEnd:a,closeStart:o,end:s,tag:c}=r;t.push(...Xj(e.slice(n,i))),t.push(...Xj(e.slice(i,a))),t.push(...c===`style`?sj(e.slice(a,o)):Jj(e.slice(a,o),{jsx:!1})),t.push(...Xj(e.slice(o,s))),n=s}return t.push(...Xj(e.slice(n))),t}var nM=s({jsx:()=>!0,keywords:()=>rM,onCommentEnd:()=>oM,onCommentStart:()=>aM,regex:()=>!1,templateStrings:()=>!1,tokenize:()=>iM}),rM=new Set([]),iM=tM,aM=(e,t,n,r)=>r.startsWith(`<!--`,n)?2:0,oM=(e,t,n,r)=>r.slice(n-2,n+1)===`-->`?2:0,sM=s({keywords:()=>lM,onCommentEnd:()=>zA,onCommentStart:()=>RA,typeKeywords:()=>cM}),cM=new Set([`boolean`,`byte`,`char`,`double`,`float`,`int`,`long`,`short`,`void`]),lM=new Set(`abstract.assert.break.case.catch.class.const.continue.default.do.else.enum.extends.final.finally.for.goto.if.implements.import.instanceof.interface.native.new.package.private.protected.public.return.static.strictfp.super.switch.synchronized.this.throw.throws.transient.try.volatile.while`.split(`.`)),uM=s({keywords:()=>dM,onCommentEnd:()=>zA,onCommentStart:()=>RA,quotedKeys:()=>!0}),dM=new Set([`true`,`false`,`null`]),fM=s({keywords:()=>pM,onCommentEnd:()=>zA,onCommentStart:()=>RA,typeKeywords:()=>mM}),pM=new Set(`as.break.by.catch.class.companion.const.constructor.continue.data.do.else.enum.false.finally.for.fun.get.if.import.in.infix.init.interface.internal.is.lateinit.noinline.null.object.open.operator.out.override.package.private.protected.public.reified.return.sealed.set.suspend.tailrec.this.throw.true.try.typealias.val.var.vararg.when.where.while`.split(`.`)),mM=new Set([`Any`,`Boolean`,`Byte`,`Char`,`Double`,`Float`,`Int`,`Long`,`Nothing`,`Short`,`String`,`Unit`]),hM=s({keywords:()=>gM,onCommentEnd:()=>vM,onCommentStart:()=>_M,onLiteral:()=>yM}),gM=new Set([`and`,`break`,`do`,`else`,`elseif`,`end`,`false`,`for`,`function`,`goto`,`if`,`in`,`local`,`nil`,`not`,`or`,`repeat`,`return`,`then`,`true`,`until`,`while`]);function _M(e,t,n,r){return e===`#`&&n===0&&t===`!`?1:e+t===`--`?/^--\[=*\[/.test(r.slice(n))?2:1:0}function vM(e,t,n,r,i){if(t===`
145
- `)return 1;if(t!==`]`)return 0;let a=r.slice(i).match(/^--\[(=*)\[/);if(!a)return 0;let o=`]${a[1]}]`;return r.slice(n-o.length+1,n+1)===o?2:0}function yM(e,t,n){if(e!==`[`)return 0;let r=n.slice(t).match(/^\[(=*)\[/);if(!r)return 0;let i=`]${r[1]}]`,a=n.indexOf(i,t+r[0].length);return a===-1?n.length-t:a+i.length-t}var bM=()=>0,xM=()=>0,SM=s({annotateLine:()=>TM,keywords:()=>CM,onCommentEnd:()=>xM,onCommentStart:()=>bM,tokenize:()=>wM}),CM=new Set([]),wM=e=>{let t=[],n=``,r=!1,i=(e,n)=>{if(!n)return;let r=t[t.length-1];r?.[0]===e?r[1]+=n:t.push([e,n])};for(let t of e.match(/[^\n]*(?:\n|$)/g)||[]){if(!t)continue;let e=t.endsWith(`
143
+ `)break;t++;continue}if(n===`[`&&(s=!0),n===`]`&&(s=!1),n===`/`&&!s){for(o=!0;/^[a-z]$/.test(e[t+1]);)t++;break}}k=!1,a!==t&&o?(m=e.slice(a,t+1),F(_A)):(m=r,F(),t=a)}else if(o(r,c,t,e)){F();let n=t,i=o(r,c,t,e);if(i)for(;t<e.length&&s(e[t-1],e[t],t,e)!=i;t++);m=e.slice(n,t+1),F(CA)}else if(r===` `||r===`
144
+ `){if(r===` `&&(Pj(m)||!m||T)){let n=t+1;for(;e[n]===` `;)n++;m+=e.slice(t,n),t=n-1,e[n]===`<`&&F()}else F(),m=r,F()}else x&&r===`}`?(F(),m=r,F(),x--):T&&!Ej.has(r)||N()||(Ij(r)===Ij(m[m.length-1])||w())&&!kj.has(r)?m+=r:(d===`</`&&(m=d),F(),d!==`</`&&(m=r),f===`</`||f===`/>`?(m=f,F(),t++):Ej.has(r)&&F()),x&&r===`{`&&x++}return F(),v}var Jj=s({tokenize:()=>Yj}),Yj=qj,Xj={keywords:new Set,jsx:!0,regex:!1,templateStrings:!1,onCommentStart:(e,t,n,r)=>r.startsWith(`<!--`,n)?2:0,onCommentEnd:(e,t,n,r)=>r.slice(n-2,n+1)===`-->`?2:0},Zj=e=>Yj(e,Xj),Qj=/^<\s*(script|style)\b/i,$j=e=>RegExp(`</\\s*${e}\\s*>`,`ig`);function eM(e,t){let n=``;for(let r=t;r<e.length;r++){let t=e[r];if(n)t===n&&(n=``);else if(t===`"`||t===`'`)n=t;else if(t===`>`)return r+1}return-1}function tM(e){let t=[],n=0;for(;n<e.length;){if(e.startsWith(`<!--`,n)){let t=e.indexOf(`-->`,n+4);n=t===-1?e.length:t+3;continue}if(e[n]!==`<`){n++;continue}let r=eM(e,n);if(r===-1)break;let i=e.slice(n,r).match(Qj);if(!i){n=r;continue}let a=i[1].toLowerCase(),o=$j(a);o.lastIndex=r;let s=o.exec(e);if(!s){n=r;continue}t.push({start:n,openEnd:r,closeStart:s.index,end:o.lastIndex,tag:a}),n=o.lastIndex}return t}function nM(e){let t=[],n=0;for(let r of tM(e)){let{start:i,openEnd:a,closeStart:o,end:s,tag:c}=r;t.push(...Zj(e.slice(n,i))),t.push(...Zj(e.slice(i,a))),t.push(...c===`style`?cj(e.slice(a,o)):Yj(e.slice(a,o),{jsx:!1})),t.push(...Zj(e.slice(o,s))),n=s}return t.push(...Zj(e.slice(n))),t}var rM=s({jsx:()=>!0,keywords:()=>iM,onCommentEnd:()=>sM,onCommentStart:()=>oM,regex:()=>!1,templateStrings:()=>!1,tokenize:()=>aM}),iM=new Set([]),aM=nM,oM=(e,t,n,r)=>r.startsWith(`<!--`,n)?2:0,sM=(e,t,n,r)=>r.slice(n-2,n+1)===`-->`?2:0,cM=s({keywords:()=>uM,onCommentEnd:()=>BA,onCommentStart:()=>zA,typeKeywords:()=>lM}),lM=new Set([`boolean`,`byte`,`char`,`double`,`float`,`int`,`long`,`short`,`void`]),uM=new Set(`abstract.assert.break.case.catch.class.const.continue.default.do.else.enum.extends.final.finally.for.goto.if.implements.import.instanceof.interface.native.new.package.private.protected.public.return.static.strictfp.super.switch.synchronized.this.throw.throws.transient.try.volatile.while`.split(`.`)),dM=s({keywords:()=>fM,onCommentEnd:()=>BA,onCommentStart:()=>zA,quotedKeys:()=>!0}),fM=new Set([`true`,`false`,`null`]),pM=s({keywords:()=>mM,onCommentEnd:()=>BA,onCommentStart:()=>zA,typeKeywords:()=>hM}),mM=new Set(`as.break.by.catch.class.companion.const.constructor.continue.data.do.else.enum.false.finally.for.fun.get.if.import.in.infix.init.interface.internal.is.lateinit.noinline.null.object.open.operator.out.override.package.private.protected.public.reified.return.sealed.set.suspend.tailrec.this.throw.true.try.typealias.val.var.vararg.when.where.while`.split(`.`)),hM=new Set([`Any`,`Boolean`,`Byte`,`Char`,`Double`,`Float`,`Int`,`Long`,`Nothing`,`Short`,`String`,`Unit`]),gM=s({keywords:()=>_M,onCommentEnd:()=>yM,onCommentStart:()=>vM,onLiteral:()=>bM}),_M=new Set([`and`,`break`,`do`,`else`,`elseif`,`end`,`false`,`for`,`function`,`goto`,`if`,`in`,`local`,`nil`,`not`,`or`,`repeat`,`return`,`then`,`true`,`until`,`while`]);function vM(e,t,n,r){return e===`#`&&n===0&&t===`!`?1:e+t===`--`?/^--\[=*\[/.test(r.slice(n))?2:1:0}function yM(e,t,n,r,i){if(t===`
145
+ `)return 1;if(t!==`]`)return 0;let a=r.slice(i).match(/^--\[(=*)\[/);if(!a)return 0;let o=`]${a[1]}]`;return r.slice(n-o.length+1,n+1)===o?2:0}function bM(e,t,n){if(e!==`[`)return 0;let r=n.slice(t).match(/^\[(=*)\[/);if(!r)return 0;let i=`]${r[1]}]`,a=n.indexOf(i,t+r[0].length);return a===-1?n.length-t:a+i.length-t}var xM=()=>0,SM=()=>0,CM=s({annotateLine:()=>EM,keywords:()=>wM,onCommentEnd:()=>SM,onCommentStart:()=>xM,tokenize:()=>TM}),wM=new Set([]),TM=e=>{let t=[],n=``,r=!1,i=(e,n)=>{if(!n)return;let r=t[t.length-1];r?.[0]===e?r[1]+=n:t.push([e,n])};for(let t of e.match(/[^\n]*(?:\n|$)/g)||[]){if(!t)continue;let e=t.endsWith(`
146
146
  `)?`
147
- `:``,a=e?t.slice(0,-1):t,o=[],s=a.match(/^(?: {0,3}>[ \t]?)*/)?.[0]||``;if(!n||r)for(let e of s.matchAll(/>/g))o.push([e.index,e.index+1]);let c=s.length,l=0;for(;l<3&&a[c]===` `;)c++,l++;let u=a.slice(c).match(/^(`{3,}|~{3,})/)?.[1];if(n)u?.[0]===n[0]&&u.length>=n.length&&/^\s*$/.test(a.slice(c+u.length))&&(o.push([c,c+u.length]),n=``,r=!1);else if(u)o.push([c,c+u.length]),n=u,r=s.includes(`>`);else{let e=a.slice(c).match(/^(#{1,6}(?=\s)|(?:[-+*]|\d+[.)])(?=\s)|(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$)/)?.[1];e&&o.push([c,c+e.length]);for(let e of a.matchAll(/(`+)(.*?)\1|(\*{1,3}|_{1,3}|~{2})(?=\S)(.*?\S)\3/g)){let t=e[1]||e[3];a[e.index-1]===`\\`||t[0]===`_`&&/\w/.test(a[e.index-1]||``)||o.push([e.index,e.index+t.length],[e.index+e[0].length-t.length,e.index+e[0].length])}}let d=0;for(let[e,t]of o.sort((e,t)=>e[0]-t[0]))e<d||(i(mA,a.slice(d,e)),i(xA,a.slice(e,t)),d=t);i(mA,a.slice(d)+e)}return t},TM=e=>{let t=``;/^#{1,6}\s/.test(e.value)?t=`markdown-heading`:/^\s*>/.test(e.value)?t=`markdown-quote`:/^\s*(?:[-*+] |\d+[.)] )/.test(e.value)?t=`markdown-list`:/^\s*```/.test(e.value)&&(t=`markdown-fence`),t&&e.annotations.push(t)},EM=s({keywords:()=>DM,onCommentEnd:()=>AM,onCommentStart:()=>kM,typeKeywords:()=>OM}),DM=new Set(`abstract.and.array.as.break.callable.case.catch.class.clone.const.continue.declare.default.do.echo.else.elseif.empty.enddeclare.endfor.endforeach.endif.endswitch.endwhile.enum.eval.exit.extends.false.final.finally.fn.for.foreach.from.function.global.goto.if.implements.include.include_once.instanceof.insteadof.interface.isset.list.match.namespace.new.null.or.print.private.protected.public.readonly.require.require_once.return.static.switch.throw.trait.true.try.unset.use.var.while.xor.yield`.split(`.`)),OM=new Set([`bool`,`float`,`int`,`iterable`,`mixed`,`never`,`object`,`string`,`void`]),kM=(e,t)=>e===`#`||e+t===`//`?1:e+t===`/*`?2:0,AM=(e,t)=>t===`
148
- `?1:e+t===`*/`?2:0,jM=s({tokenize:()=>MM}),MM=e=>[[mA,e]],NM=s({caseInsensitive:()=>!0,keywords:()=>PM,onCommentEnd:()=>IM,onCommentStart:()=>FM}),PM=new Set(`begin.break.catch.class.continue.data.define.do.dynamicparam.else.elseif.end.enum.exit.filter.finally.for.foreach.from.function.if.in.param.process.return.switch.throw.trap.try.until.using.while`.split(`.`)),FM=(e,t)=>e===`#`?1:e+t===`<#`?2:0,IM=(e,t)=>t===`
149
- `?1:e+t===`#>`?2:0,LM=s({keywords:()=>RM,onCommentEnd:()=>BM,onCommentStart:()=>zM}),RM=new Set(`and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield`.split(`.`)),zM=(e,t)=>+(e===`#`),BM=(e,t)=>+(t===`
150
- `),VM=s({keywords:()=>HM,onCommentEnd:()=>GM,onCommentStart:()=>WM}),HM=new Set(`BEGIN.END.__ENCODING__.__FILE__.__LINE__.alias.and.begin.break.case.class.def.defined.do.else.elsif.end.ensure.false.for.if.in.module.next.nil.not.or.redo.rescue.retry.return.self.super.then.true.undef.unless.until.when.while.yield`.split(`.`));function UM(e,t){return e>0&&t[e-1]!==`
151
- `?!1:/^=begin(?:\s|$)/.test(t.slice(e))}function WM(e,t,n,r){return e===`#`?1:e===`=`&&UM(n,r)?2:0}function GM(e,t,n,r){if(t!==`
147
+ `:``,a=e?t.slice(0,-1):t,o=[],s=a.match(/^(?: {0,3}>[ \t]?)*/)?.[0]||``;if(!n||r)for(let e of s.matchAll(/>/g))o.push([e.index,e.index+1]);let c=s.length,l=0;for(;l<3&&a[c]===` `;)c++,l++;let u=a.slice(c).match(/^(`{3,}|~{3,})/)?.[1];if(n)u?.[0]===n[0]&&u.length>=n.length&&/^\s*$/.test(a.slice(c+u.length))&&(o.push([c,c+u.length]),n=``,r=!1);else if(u)o.push([c,c+u.length]),n=u,r=s.includes(`>`);else{let e=a.slice(c).match(/^(#{1,6}(?=\s)|(?:[-+*]|\d+[.)])(?=\s)|(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$)/)?.[1];e&&o.push([c,c+e.length]);for(let e of a.matchAll(/(`+)(.*?)\1|(\*{1,3}|_{1,3}|~{2})(?=\S)(.*?\S)\3/g)){let t=e[1]||e[3];a[e.index-1]===`\\`||t[0]===`_`&&/\w/.test(a[e.index-1]||``)||o.push([e.index,e.index+t.length],[e.index+e[0].length-t.length,e.index+e[0].length])}}let d=0;for(let[e,t]of o.sort((e,t)=>e[0]-t[0]))e<d||(i(hA,a.slice(d,e)),i(SA,a.slice(e,t)),d=t);i(hA,a.slice(d)+e)}return t},EM=e=>{let t=``;/^#{1,6}\s/.test(e.value)?t=`markdown-heading`:/^\s*>/.test(e.value)?t=`markdown-quote`:/^\s*(?:[-*+] |\d+[.)] )/.test(e.value)?t=`markdown-list`:/^\s*```/.test(e.value)&&(t=`markdown-fence`),t&&e.annotations.push(t)},DM=s({keywords:()=>OM,onCommentEnd:()=>jM,onCommentStart:()=>AM,typeKeywords:()=>kM}),OM=new Set(`abstract.and.array.as.break.callable.case.catch.class.clone.const.continue.declare.default.do.echo.else.elseif.empty.enddeclare.endfor.endforeach.endif.endswitch.endwhile.enum.eval.exit.extends.false.final.finally.fn.for.foreach.from.function.global.goto.if.implements.include.include_once.instanceof.insteadof.interface.isset.list.match.namespace.new.null.or.print.private.protected.public.readonly.require.require_once.return.static.switch.throw.trait.true.try.unset.use.var.while.xor.yield`.split(`.`)),kM=new Set([`bool`,`float`,`int`,`iterable`,`mixed`,`never`,`object`,`string`,`void`]),AM=(e,t)=>e===`#`||e+t===`//`?1:e+t===`/*`?2:0,jM=(e,t)=>t===`
148
+ `?1:e+t===`*/`?2:0,MM=s({tokenize:()=>NM}),NM=e=>[[hA,e]],PM=s({caseInsensitive:()=>!0,keywords:()=>FM,onCommentEnd:()=>LM,onCommentStart:()=>IM}),FM=new Set(`begin.break.catch.class.continue.data.define.do.dynamicparam.else.elseif.end.enum.exit.filter.finally.for.foreach.from.function.if.in.param.process.return.switch.throw.trap.try.until.using.while`.split(`.`)),IM=(e,t)=>e===`#`?1:e+t===`<#`?2:0,LM=(e,t)=>t===`
149
+ `?1:e+t===`#>`?2:0,RM=s({keywords:()=>zM,onCommentEnd:()=>VM,onCommentStart:()=>BM}),zM=new Set(`and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield`.split(`.`)),BM=(e,t)=>+(e===`#`),VM=(e,t)=>+(t===`
150
+ `),HM=s({keywords:()=>UM,onCommentEnd:()=>KM,onCommentStart:()=>GM}),UM=new Set(`BEGIN.END.__ENCODING__.__FILE__.__LINE__.alias.and.begin.break.case.class.def.defined.do.else.elsif.end.ensure.false.for.if.in.module.next.nil.not.or.redo.rescue.retry.return.self.super.then.true.undef.unless.until.when.while.yield`.split(`.`));function WM(e,t){return e>0&&t[e-1]!==`
151
+ `?!1:/^=begin(?:\s|$)/.test(t.slice(e))}function GM(e,t,n,r){return e===`#`?1:e===`=`&&WM(n,r)?2:0}function KM(e,t,n,r){if(t!==`
152
152
  `)return 0;let i=r.lastIndexOf(`
153
- `,n-1)+1,a=r.slice(i,n);return/^=end(?:\s|$)/.test(a)?2:1}var KM=s({keywords:()=>qM,onQuote:()=>JM}),qM=new Set(`as.break.const.continue.crate.else.enum.extern.false.fn.for.if.impl.in.let.loop.match.mod.move.mut.pub.ref.return.self.Self.static.struct.super.trait.true.type.unsafe.use.where.while.async.await.dyn.abstract.become.box.do.final.macro.override.priv.typeof.unsized.virtual.yield.try`.split(`.`));function JM(e,t,n){if(e!==`'`||t+1>=n.length)return 1;let r=n[t+1];if(r===`\\`){let e=t+2;for(;e<n.length;){if(n[e]===`\\`){e+=2;continue}if(n[e]===`'`)return e-t+1;e++}return n.length-t}if(r===`_`)return 2;if(/[a-zA-Z]/.test(r)){let e=t+2;for(;e<n.length&&/[a-zA-Z0-9_]/.test(n[e]);)e++;return e<n.length&&n[e]===`'`?e-t+1:e-t}return 1}var YM=s({keywords:()=>XM,onCommentEnd:()=>fj,onCommentStart:()=>dj}),XM=new Set([`case`,`coproc`,`do`,`done`,`elif`,`else`,`esac`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`readonly`,`return`,`select`,`then`,`time`,`until`,`while`]),ZM=s({caseInsensitive:()=>!0,keywords:()=>QM,onCommentEnd:()=>tN,onCommentStart:()=>eN,typeKeywords:()=>$M}),QM=new Set(`add.all.alter.and.as.asc.between.by.case.check.column.constraint.create.cross.database.default.delete.desc.distinct.drop.else.end.exists.foreign.from.full.group.having.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.primary.references.right.select.set.table.then.union.unique.update.values.view.when.where.with`.split(`.`)),$M=new Set([`bigint`,`binary`,`bit`,`blob`,`boolean`,`char`,`date`,`datetime`,`decimal`,`double`,`float`,`int`,`integer`,`interval`,`json`,`numeric`,`real`,`smallint`,`text`,`time`,`timestamp`,`uuid`,`varchar`]),eN=(e,t)=>{let n=e+t;return n===`--`?1:n===`/*`?2:0},tN=(e,t)=>t===`
154
- `?1:e+t===`*/`?2:0,nN=s({keywords:()=>rN,onCommentEnd:()=>zA,onCommentStart:()=>RA,typeKeywords:()=>iN}),rN=new Set(`as.associatedtype.break.case.catch.class.continue.convenience.default.defer.deinit.didSet.do.dynamic.else.enum.extension.fallthrough.false.fileprivate.final.for.func.get.guard.if.import.in.indirect.infix.init.inout.internal.is.lazy.let.mutating.nil.nonmutating.open.operator.override.precedencegroup.private.protocol.public.repeat.required.rethrows.return.self.set.some.static.struct.subscript.super.switch.throw.throws.true.try.typealias.unowned.var.weak.where.while.willSet`.split(`.`)),iN=new Set([`Any`,`Bool`,`Character`,`Double`,`Float`,`Int`,`Never`,`String`,`UInt`,`Void`]),aN=s({keywords:()=>oN,onCommentEnd:()=>fj,onCommentStart:()=>dj,quotedKeys:()=>!0}),oN=new Set([`false`,`true`]),sN=s({tokenize:()=>cN}),cN=(e,t)=>Kj(e,{...t,typescript:!0}),lN=s({jsx:()=>!0,keywords:()=>rM,onCommentEnd:()=>oM,onCommentStart:()=>aM,regex:()=>!1,templateStrings:()=>!1,tokenize:()=>tM}),uN=s({jsx:()=>!0,keywords:()=>rM,onCommentEnd:()=>oM,onCommentStart:()=>aM,regex:()=>!1,templateStrings:()=>!1,tokenize:()=>tM}),dN=s({keywords:()=>fN,onCommentEnd:()=>fj,onCommentStart:()=>dj,quotedKeys:()=>!0}),fN=new Set([`false`,`False`,`FALSE`,`no`,`No`,`NO`,`null`,`Null`,`NULL`,`off`,`Off`,`OFF`,`on`,`On`,`ON`,`true`,`True`,`TRUE`,`yes`,`Yes`,`YES`]),pN=s({keywords:()=>mN,onCommentEnd:()=>_N,onCommentStart:()=>gN,onLiteral:()=>vN,typeKeywords:()=>hN}),mN=new Set(`addrspace.align.allowzero.and.anyframe.anytype.asm.async.await.break.callconv.catch.comptime.const.continue.defer.else.enum.errdefer.error.export.extern.false.fn.for.if.inline.linksection.noalias.noinline.nosuspend.null.opaque.or.orelse.packed.pub.resume.return.struct.suspend.switch.test.threadlocal.true.try.undefined.union.unreachable.usingnamespace.var.volatile.while`.split(`.`)),hN=new Set(`anyerror.anyopaque.bool.c_char.c_int.c_long.c_longdouble.c_longlong.c_short.c_uint.c_ulong.c_ulonglong.c_ushort.comptime_float.comptime_int.f16.f32.f64.f80.f128.i8.i16.i32.i64.i128.isize.noreturn.type.u8.u16.u32.u64.u128.usize.void`.split(`.`)),gN=(e,t)=>+(e+t===`//`),_N=(e,t)=>+(t===`
155
- `);function vN(e,t,n){if(e!==`\\`||n[t+1]!==`\\`)return 0;let r=n.lastIndexOf(`
153
+ `,n-1)+1,a=r.slice(i,n);return/^=end(?:\s|$)/.test(a)?2:1}var qM=s({keywords:()=>JM,onQuote:()=>YM}),JM=new Set(`as.break.const.continue.crate.else.enum.extern.false.fn.for.if.impl.in.let.loop.match.mod.move.mut.pub.ref.return.self.Self.static.struct.super.trait.true.type.unsafe.use.where.while.async.await.dyn.abstract.become.box.do.final.macro.override.priv.typeof.unsized.virtual.yield.try`.split(`.`));function YM(e,t,n){if(e!==`'`||t+1>=n.length)return 1;let r=n[t+1];if(r===`\\`){let e=t+2;for(;e<n.length;){if(n[e]===`\\`){e+=2;continue}if(n[e]===`'`)return e-t+1;e++}return n.length-t}if(r===`_`)return 2;if(/[a-zA-Z]/.test(r)){let e=t+2;for(;e<n.length&&/[a-zA-Z0-9_]/.test(n[e]);)e++;return e<n.length&&n[e]===`'`?e-t+1:e-t}return 1}var XM=s({keywords:()=>ZM,onCommentEnd:()=>pj,onCommentStart:()=>fj}),ZM=new Set([`case`,`coproc`,`do`,`done`,`elif`,`else`,`esac`,`export`,`fi`,`for`,`function`,`if`,`in`,`local`,`readonly`,`return`,`select`,`then`,`time`,`until`,`while`]),QM=s({caseInsensitive:()=>!0,keywords:()=>$M,onCommentEnd:()=>nN,onCommentStart:()=>tN,typeKeywords:()=>eN}),$M=new Set(`add.all.alter.and.as.asc.between.by.case.check.column.constraint.create.cross.database.default.delete.desc.distinct.drop.else.end.exists.foreign.from.full.group.having.in.index.inner.insert.into.is.join.key.left.like.limit.not.null.offset.on.or.order.outer.primary.references.right.select.set.table.then.union.unique.update.values.view.when.where.with`.split(`.`)),eN=new Set([`bigint`,`binary`,`bit`,`blob`,`boolean`,`char`,`date`,`datetime`,`decimal`,`double`,`float`,`int`,`integer`,`interval`,`json`,`numeric`,`real`,`smallint`,`text`,`time`,`timestamp`,`uuid`,`varchar`]),tN=(e,t)=>{let n=e+t;return n===`--`?1:n===`/*`?2:0},nN=(e,t)=>t===`
154
+ `?1:e+t===`*/`?2:0,rN=s({keywords:()=>iN,onCommentEnd:()=>BA,onCommentStart:()=>zA,typeKeywords:()=>aN}),iN=new Set(`as.associatedtype.break.case.catch.class.continue.convenience.default.defer.deinit.didSet.do.dynamic.else.enum.extension.fallthrough.false.fileprivate.final.for.func.get.guard.if.import.in.indirect.infix.init.inout.internal.is.lazy.let.mutating.nil.nonmutating.open.operator.override.precedencegroup.private.protocol.public.repeat.required.rethrows.return.self.set.some.static.struct.subscript.super.switch.throw.throws.true.try.typealias.unowned.var.weak.where.while.willSet`.split(`.`)),aN=new Set([`Any`,`Bool`,`Character`,`Double`,`Float`,`Int`,`Never`,`String`,`UInt`,`Void`]),oN=s({keywords:()=>sN,onCommentEnd:()=>pj,onCommentStart:()=>fj,quotedKeys:()=>!0}),sN=new Set([`false`,`true`]),cN=s({tokenize:()=>lN}),lN=(e,t)=>qj(e,{...t,typescript:!0}),uN=s({jsx:()=>!0,keywords:()=>iM,onCommentEnd:()=>sM,onCommentStart:()=>oM,regex:()=>!1,templateStrings:()=>!1,tokenize:()=>nM}),dN=s({jsx:()=>!0,keywords:()=>iM,onCommentEnd:()=>sM,onCommentStart:()=>oM,regex:()=>!1,templateStrings:()=>!1,tokenize:()=>nM}),fN=s({keywords:()=>pN,onCommentEnd:()=>pj,onCommentStart:()=>fj,quotedKeys:()=>!0}),pN=new Set([`false`,`False`,`FALSE`,`no`,`No`,`NO`,`null`,`Null`,`NULL`,`off`,`Off`,`OFF`,`on`,`On`,`ON`,`true`,`True`,`TRUE`,`yes`,`Yes`,`YES`]),mN=s({keywords:()=>hN,onCommentEnd:()=>vN,onCommentStart:()=>_N,onLiteral:()=>yN,typeKeywords:()=>gN}),hN=new Set(`addrspace.align.allowzero.and.anyframe.anytype.asm.async.await.break.callconv.catch.comptime.const.continue.defer.else.enum.errdefer.error.export.extern.false.fn.for.if.inline.linksection.noalias.noinline.nosuspend.null.opaque.or.orelse.packed.pub.resume.return.struct.suspend.switch.test.threadlocal.true.try.undefined.union.unreachable.usingnamespace.var.volatile.while`.split(`.`)),gN=new Set(`anyerror.anyopaque.bool.c_char.c_int.c_long.c_longdouble.c_longlong.c_short.c_uint.c_ulong.c_ulonglong.c_ushort.comptime_float.comptime_int.f16.f32.f64.f80.f128.i8.i16.i32.i64.i128.isize.noreturn.type.u8.u16.u32.u64.u128.usize.void`.split(`.`)),_N=(e,t)=>+(e+t===`//`),vN=(e,t)=>+(t===`
155
+ `);function yN(e,t,n){if(e!==`\\`||n[t+1]!==`\\`)return 0;let r=n.lastIndexOf(`
156
156
  `,t-1)+1;if(n.slice(r,t).trim())return 0;let i=n.indexOf(`
157
- `,t+2);return(i===-1?n.length:i)-t}function yN(e){return{...e,jsx:!1,regex:!1,templateStrings:!1}}function bN(){return{javascript:qj,typescript:sN,css:yN(YA),python:yN(LM),c:yN(BA),go:yN(hj),java:yN(sM),rust:yN(KM),json:yN(uM),diff:yN(cj),shell:yN(YM),cpp:yN(UA),csharp:yN(KA),sql:yN(ZM),html:nM,vue:uN,svelte:lN,yaml:yN(dN),markdown:yN(SM),plaintext:yN(jM),ruby:yN(VM),kotlin:yN(fM),swift:yN(nN),php:yN(EM),toml:yN(aN),powershell:yN(NM),dockerfile:yN(pj),graphql:yN(vj),hcl:yN(xj),zig:yN(pN),lua:yN(hM)}}var xN=bN();function SN(e){return xN[e||`javascript`]}function CN(e,t){let{lang:n,cx:r,mark:i,markLine:a}=t||{};return OA(LA(e,SN(n)),{cx:r,mark:i,markLine:a})}function wN({code:e,path:t,className:n}){let r=e.replace(/\n$/,``),i=(0,v.useMemo)(()=>CN(r),[r]),a=r.split(`
157
+ `,t+2);return(i===-1?n.length:i)-t}function bN(e){return{...e,jsx:!1,regex:!1,templateStrings:!1}}function xN(){return{javascript:Jj,typescript:cN,css:bN(XA),python:bN(RM),c:bN(VA),go:bN(gj),java:bN(cM),rust:bN(qM),json:bN(dM),diff:bN(lj),shell:bN(XM),cpp:bN(WA),csharp:bN(qA),sql:bN(QM),html:rM,vue:dN,svelte:uN,yaml:bN(fN),markdown:bN(CM),plaintext:bN(MM),ruby:bN(HM),kotlin:bN(pM),swift:bN(rN),php:bN(DM),toml:bN(oN),powershell:bN(PM),dockerfile:bN(mj),graphql:bN(yj),hcl:bN(Sj),zig:bN(mN),lua:bN(gM)}}var SN=xN();function CN(e){return SN[e||`javascript`]}function wN(e,t){let{lang:n,cx:r,mark:i,markLine:a}=t||{};return kA(RA(e,CN(n)),{cx:r,mark:i,markLine:a})}function TN({code:e,path:t,className:n}){let r=e.replace(/\n$/,``),i=(0,v.useMemo)(()=>wN(r),[r]),a=r.split(`
158
158
  `).length;return(0,R.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col`,n),children:[t?(0,R.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-3 border-b border-rule bg-soft pr-1.5 pl-4`,children:[(0,R.jsx)(Z,{size:12,className:`truncate text-muted`,title:t,children:t}),(0,R.jsx)(N_,{icon:`copy`,label:`Copy file`,size:15,onClick:()=>iT(e,`Copied the file`)})]}):null,(0,R.jsxs)(`div`,{className:`flex max-h-[640px] min-w-0 overflow-auto font-mono text-[12.5px] leading-[1.6]`,children:[(0,R.jsx)(`pre`,{"aria-hidden":`true`,className:`sticky left-0 m-0 shrink-0 select-none border-r border-rule bg-surface py-3 pr-3 pl-4 text-right text-muted`,children:Array.from({length:a},(e,t)=>t+1).join(`
159
- `)}),(0,R.jsx)(`pre`,{className:`m-0 min-w-0 grow py-3 pr-6 pl-4 text-ink`,children:(0,R.jsx)(`code`,{dangerouslySetInnerHTML:{__html:i}})})]})]})}var TN={beta:`action`,experimental:`action`,draft:`action`,deprecated:`danger`,stable:`ok`},EN=`.design/system/components/`;function DN(e){return e.startsWith(EN)?`@system/components/${e.slice(26).replace(/\.(tsx|jsx|ts|js)$/,``).replace(/\/index$/,``)}`:null}function ON(e){let t=new Set;for(let n of e.matchAll(/export\s+(?:async\s+)?(?:function|const|class|let)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);for(let n of e.matchAll(/export\s*\{([^}]+)\}/g))for(let e of n[1].split(`,`)){let n=e.trim().split(/\s+as\s+/).pop()?.trim();n&&n!=="default"&&t.add(n)}return[...t].filter(e=>/^[A-Z]/.test(e))}function kN({path:e}){let t=DN(e),n=a_(t?e:null).data;if(!t)return null;let r=n?ON(n):[],i=`import { ${r.length?r.join(`, `):`…`} } from '${t}'`;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-rule py-1.5 pr-1.5 pl-4`,children:[(0,R.jsx)(Z,{size:12.5,className:`min-w-0 truncate text-ink2`,title:i,children:i}),(0,R.jsx)(N_,{icon:`copy`,label:`Copy the import`,size:14,className:`ml-auto`,onClick:()=>iT(i)})]})}function AN({component:e,theme:t,width:n}){return n===`fill`?(0,R.jsx)(fA,{src:e.url,theme:t,title:e.title,minHeight:160}):(0,R.jsx)(`div`,{className:`flex justify-center overflow-x-auto bg-soft p-6`,children:(0,R.jsx)(`div`,{className:`shrink-0 overflow-hidden rounded-[8px] border border-rule bg-surface shadow-frame`,children:(0,R.jsx)(fA,{src:e.url,theme:t,title:e.title,minHeight:160,width:Number(n)})})})}function jN({component:e}){let t=[...e.sources,e.specimen],[n,r]=(0,v.useState)(t[0]),i=t.includes(n)?n:t[0],{data:a,error:o,isLoading:s}=a_(i);return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[t.length>1?(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-rule px-4 py-2.5`,children:(0,R.jsx)(cO,{label:`File`,size:`sm`,value:i,onChange:r,items:t.map(t=>({value:t,label:t===e.specimen?`${MN(t)} · specimen`:MN(t),title:t}))})}):null,DN(i)?(0,R.jsx)(kN,{path:i}):null,o?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-6 text-[13px] text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:15}),o.message]}):s||a===void 0?(0,R.jsx)(`div`,{className:`flex items-center justify-center py-10 text-muted`,children:(0,R.jsx)(X,{name:`loader`,size:18})}):(0,R.jsx)(wN,{code:a,path:i})]})}function MN(e){return e.split(`/`).pop()??e}function NN({system:e,id:t}){let n=e.components.find(e=>e.id===t),[r,i]=(0,v.useState)(`preview`),[a,o]=eA(),[s,c]=(0,v.useState)(`fill`),l=!$g().frameSandbox;if(!n)return(0,R.jsx)(nO,{title:`No such component`,text:`There is no specimen "${t}" in .design/system/specimens.`});let u=n.status?.toLowerCase();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,badge:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(L_,{children:n.group}),u?(0,R.jsx)(L_,{tone:TN[u]??`neutral`,children:n.status}):null]}),sub:n.description}),(0,R.jsxs)(z_,{children:[(0,R.jsx)(V_,{value:r,onChange:i,items:[{value:`preview`,label:`Preview`},{value:`code`,label:`Code`,count:n.sources.length+1}],right:r===`preview`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(cO,{label:`Width`,size:`sm`,value:s,onChange:c,items:[{value:`fill`,label:`Fill`},{value:`768`,label:`768`},{value:`390`,label:`390`}]}),(0,R.jsx)(tA,{value:a,onChange:o}),l?(0,R.jsx)(F_,{icon:`external`,href:RD(LD(n.url,a)),target:`_blank`,rel:`noreferrer`,children:`Open`}):null]}):null}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:r===`preview`?(0,R.jsx)(AN,{component:n,theme:a,width:s}):(0,R.jsx)(jN,{component:n})})]})]})}function PN(e,t){let n=/^\s*#\s+(.+)\r?\n/.exec(e);return n&&n[1].trim()===t?e.slice(n[0].length):e}function FN({system:e,slug:t}){let n=e.guidelines.find(e=>e.slug===t);if(!n)return(0,R.jsx)(nO,{title:`No such guideline`,text:`There is no guideline "${t}" in .design/system/guidelines.`});let r=PN(n.markdown,n.title).trim();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,sub:`Guideline`}),(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:r?(0,R.jsx)(uD,{text:r,className:`max-w-[760px]`}):(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`This guideline is empty. Write it in `,(0,R.jsx)(Z,{children:`.design/system/guidelines`}),`.`]})})})]})}var IN={linear:[0,0,1,1],ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]};function LN(e){let t=e.trim();if(IN[t])return IN[t];let n=/^cubic-bezier\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)$/.exec(t);if(!n)return null;let r=n.slice(1).map(Number);return r.every(Number.isFinite)?r:null}function RN(e){let t=/^(-?[\d.]+)(ms|s)$/.exec(e.trim());return t?Number(t[1])*(t[2]===`s`?1e3:1):null}var zN=132,BN=22;function VN({bezier:e}){let[t,n,r,i]=e,a=Math.min(0,n,i),o=Math.max(1,n,i),s=88/(o-a),c=e=>BN+e*88,l=e=>BN+(o-e)*s;return(0,R.jsxs)(`svg`,{width:zN,height:zN,viewBox:`0 0 ${zN} ${zN}`,"aria-hidden":`true`,className:`shrink-0`,children:[(0,R.jsx)(`rect`,{x:c(0),y:l(1),width:88,height:l(0)-l(1),className:`fill-none stroke-rule`}),(0,R.jsx)(`line`,{x1:c(0),y1:l(0),x2:c(t),y2:l(n),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`line`,{x1:c(1),y1:l(1),x2:c(r),y2:l(i),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`path`,{d:`M ${c(0)} ${l(0)} C ${c(t)} ${l(n)}, ${c(r)} ${l(i)}, ${c(1)} ${l(1)}`,className:`fill-none stroke-ink`,strokeWidth:2,strokeLinecap:`round`}),(0,R.jsx)(`circle`,{cx:c(t),cy:l(n),r:3,className:`fill-action`}),(0,R.jsx)(`circle`,{cx:c(r),cy:l(i),r:3,className:`fill-action`})]})}function HN({token:e,duration:t}){let[n,r]=(0,v.useState)(!1),i=e.light?.value??``,a=LN(i);return(0,R.jsxs)(`button`,{type:`button`,title:`Hover to play; click to copy the variable`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),onClick:()=>iT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col gap-3 rounded-[8px] border border-transparent bg-transparent p-3 text-left transition-colors hover:border-rule hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex h-[132px] items-center justify-center rounded-[6px] bg-soft`,children:a?(0,R.jsx)(VN,{bezier:a}):(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`No curve to draw`})}),(0,R.jsx)(`span`,{className:`relative mx-1 h-2 rounded-full bg-soft2`,children:(0,R.jsx)(`span`,{className:`absolute top-1/2 size-3.5 -translate-y-1/2 rounded-full bg-ink`,style:{left:n?`calc(100% - 14px)`:`0px`,transition:`left ${t}ms ${i||`ease`}`}})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(nA,{items:Yk(e)}),(0,R.jsx)(aA,{children:i}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function UN({system:e}){let t=Xk(e.tokens,`ease`),n=Xk(e.tokens,`duration`),r=Xk(e.tokens,`animation`),i=`minmax(170px,1fr) 100px minmax(0,2fr)`,a=`minmax(170px,1fr) minmax(140px,0.7fr) minmax(0,2fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Motion`,sub:`Hover an easing to see it move.`}),!t.length&&!n.length&&!r.length?(0,R.jsxs)(rA,{title:`No motion tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--ease-*`}),` and `,(0,R.jsx)(Z,{children:`--animate-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block, and durations as`,` `,(0,R.jsx)(Z,{children:`--duration-*`}),`, in `,(0,R.jsx)(Z,{children:iA}),`.`]}):null,t.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Easing`,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(190px, 1fr))`},children:t.map(e=>(0,R.jsx)(HN,{token:e,duration:900},e.name))})]}):null,n.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Durations`,count:n.length}),(0,R.jsx)(W_,{cols:i,labels:[`Token`,`Value`,``]}),n.map(e=>{let t=e.light?RN(e.light.value):null;return(0,R.jsxs)(K_,{cols:i,minH:40,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),t===null?(0,R.jsx)(`span`,{}):(0,R.jsx)(`span`,{className:`h-3 rounded-[3px] bg-action/70`,style:{width:Math.max(2,Math.min(t/2,480))}})]},e.name)})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Animations`,count:r.length,sub:`keyframes live in the system stylesheet`}),(0,R.jsx)(W_,{cols:a,labels:[`Token`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:a,minH:40,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(nA,{items:Yk(e)}),(0,R.jsx)(aA,{children:e.light?.value})]},e.name))]}):null]})}function WN({system:e}){let t=Tw(),n=new Set(e.tokens.map(e=>e.kind)),r=[{to:`/system/colors`,label:`Colors`,hint:GN(e,`color`)},{to:`/system/typography`,label:`Typography`},{to:`/system/shape`,label:`Spacing & shape`}];(n.has(`ease`)||n.has(`duration`)||n.has(`animation`))&&r.push({to:`/system/motion`,label:`Motion`}),n.has(`other`)&&r.push({to:`/system/tokens`,label:`Other tokens`,hint:GN(e,`other`)}),e.assets.length&&r.push({to:`/system/assets`,label:`Assets`,hint:e.assets.length});let i=new Map;for(let t of e.components){let e=i.get(t.group)??[];e.push({to:`/system/components/${encodeURIComponent(t.id)}`,label:t.title,hint:t.status}),i.set(t.group,e)}let a=e.guidelines.filter(e=>e.slug!==`overview`);if(t){let e=[{label:``,items:[{to:`/system`,label:`Overview`}]},{label:`Foundations`,items:r},{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))},...[...i].map(([e,t])=>({label:e,items:t}))];return(0,R.jsx)(KN,{sections:e.filter(e=>e.items.length)})}return(0,R.jsxs)(`div`,{className:`flex flex-col max-lg:gap-1 max-lg:[&_nav]:flex-row max-lg:[&_nav]:flex-wrap`,children:[(0,R.jsx)(Q_,{label:`Overview`,items:[{to:`/system`,label:`Overview`}]}),(0,R.jsx)($_,{children:`Foundations`}),(0,R.jsx)(Q_,{label:`Foundations`,items:r}),a.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)($_,{children:`Guidelines`}),(0,R.jsx)(Q_,{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))})]}):null,[...i].map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[(0,R.jsx)($_,{children:e}),(0,R.jsx)(Q_,{label:e,items:t})]},e))]})}function GN(e,t){return e.tokens.filter(e=>e.kind===t).length||void 0}function KN({sections:e}){let[t]=I(),[n,r]=(0,v.useState)(!1),i=e.flatMap(e=>e.items).find(e=>e.to===t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex h-11 w-full cursor-pointer items-center gap-2 rounded-[8px] border border-rule bg-surface px-3.5 text-left text-[14px] text-ink`,children:[(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`Section`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate font-medium`,children:i?.label??`Overview`}),(0,R.jsx)(X,{name:`chevron-down`,size:16,className:`shrink-0 text-muted`})]}),(0,R.jsx)(xk,{open:n,onOpenChange:r,title:`Design system`,children:(0,R.jsx)(`nav`,{"aria-label":`Design system`,className:`flex flex-col pb-2`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.label?(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.label}):null,e.items.map(e=>{let n=e.to===t;return(0,R.jsxs)(ye,{href:e.to,onClick:()=>r(!1),"aria-current":n?`page`:void 0,className:Y(`flex min-h-[46px] items-center gap-2 px-4 text-[14px] no-underline active:bg-soft2`,n?`font-medium text-ink`:`text-ink2`),children:[(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:e.hint}):null,n?(0,R.jsx)(X,{name:`check`,size:16,className:`shrink-0 text-action`}):null]},e.to)})]},e.label||`overview`))})})]})}function qN({system:e}){let t=Xk(e.tokens,`other`),n=`minmax(170px,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1.3fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Other tokens`,sub:`Variables that are not colors, type, spacing, shape or motion.`}),t.length?Zk(t).map(({group:e,tokens:t})=>(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(W_,{cols:n,labels:[`Token`,`Light`,`Dark`,`Description`]}),t.map(e=>(0,R.jsxs)(K_,{cols:n,minH:40,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(aA,{children:e.light?.value}),(0,R.jsx)(aA,{children:e.dark?.value??`—`}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:e.description})]},e.name))]},e)):(0,R.jsxs)(rA,{title:`No other tokens`,children:[`Variables in `,(0,R.jsx)(Z,{children:`:root`}),` of `,(0,R.jsx)(Z,{children:iA}),` that are not colors or lengths show here.`]})]})}function JN(e,...t){return e.tokens.filter(e=>t.includes(e.kind)).length}function YN(e){let t=[{to:`/system/colors`,icon:`palette`,title:`Colors`,text:Lk(JN(e,`color`),`token`)},{to:`/system/typography`,icon:`type`,title:`Typography`,text:`${Lk(JN(e,`font`),`family`,`families`)} · ${Lk(JN(e,`text`),`size`)}`},{to:`/system/shape`,icon:`shape`,title:`Spacing & shape`,text:Lk(JN(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),`token`)}],n=JN(e,`ease`,`duration`,`animation`);n&&t.push({to:`/system/motion`,icon:`motion`,title:`Motion`,text:Lk(n,`token`)}),e.assets.length&&t.push({to:`/system/assets`,icon:`image`,title:`Assets`,text:Lk(e.assets.length,`file`)});let r=e.components[0];return r&&t.push({to:`/system/components/${encodeURIComponent(r.id)}`,icon:`component`,title:`Components`,text:Lk(e.components.length,`component`)}),t}function XN({system:e}){return(0,R.jsx)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(220px, 1fr))`},children:YN(e).map(e=>(0,R.jsxs)(ye,{href:e.to,className:`flex items-center gap-3 rounded-[10px] border border-rule bg-surface px-4 py-3.5 text-inherit no-underline transition-colors hover:border-rule-strong hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[8px] bg-soft2 text-ink2`,children:(0,R.jsx)(X,{name:e.icon,size:17})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[14px] font-medium text-ink`,children:e.title}),(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.text})]})]},e.to))})}function ZN({system:e}){let[,t]=I(),n=[{label:`Color tokens`,value:JN(e,`color`),to:`/system/colors`},{label:`Type tokens`,value:JN(e,`font`,`text`,`weight`,`leading`,`tracking`),to:`/system/typography`},{label:`Spacing & shape tokens`,value:JN(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),to:`/system/shape`},{label:`Motion tokens`,value:JN(e,`ease`,`duration`,`animation`),to:`/system/motion`},{label:`Other tokens`,value:JN(e,`other`),to:`/system/tokens`},{label:`Components`,value:e.components.length},{label:`Guidelines`,value:e.guidelines.length}];return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`At a glance`}),n.filter(e=>e.value||!e.to||e.to===`/system/colors`).map(e=>(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,onClick:e.to&&e.value?()=>t(e.to):void 0,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:e.label}),(0,R.jsx)(R_,{value:e.value})]},e.label)),e.fonts.length?(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:`Web fonts`}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5`,children:e.fonts.map(e=>(0,R.jsx)(Z,{size:12,className:`max-w-[260px] truncate text-muted`,title:e,children:QN(e)},e))})]}):null]})}function QN(e){try{let t=new URL(e),n=t.searchParams.getAll(`family`).map(e=>e.split(`:`)[0].replace(/\+/g,` `));return n.length?n.join(`, `):t.host}catch{return e}}function $N({system:e}){let t=e.guidelines.find(e=>e.slug===`overview`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:e.name,sub:e.description}),(0,R.jsx)($D,{issues:e.issues,title:`Problems in the design system`}),(0,R.jsx)(XN,{system:e}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-xl:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 320px`},children:[t?(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:(0,R.jsx)(uD,{text:t.markdown})})}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Overview`}),(0,R.jsxs)(`div`,{className:`border-t border-rule px-4 py-5 text-[13px] text-muted`,children:[`Write the principles every screen follows in `,(0,R.jsx)(Z,{children:`.design/system/guidelines/01-overview.md`}),`; it shows here.`]})]}),(0,R.jsx)(ZN,{system:e})]})]})}var eP=[1,2,3,4,6,8,12,16],tP=480;function nP({px:e}){return e===null?(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`not a plain length`}):(0,R.jsxs)(`span`,{className:`flex h-3 items-center`,children:[(0,R.jsx)(`span`,{className:`h-3 rounded-[3px] bg-action/70`,style:{width:Math.max(2,Math.min(e,tP))},title:`${e}px`}),e>tP?(0,R.jsx)(`span`,{className:`ml-1.5 text-[12px] text-muted`,children:`…`}):null]})}function rP({tokens:e}){let t=e.find(e=>e.name===`--spacing`),n=e.filter(e=>e!==t),r=t?.light?Qk(t.light.value):null,i=`minmax(150px,0.8fr) 110px minmax(0,2fr)`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Spacing`,count:e.length,sub:t?`base ${t.light?.value}`:void 0}),(0,R.jsx)(W_,{cols:i,labels:[`Class or token`,`Value`,``]}),t&&r!==null?eP.map(e=>(0,R.jsxs)(K_,{cols:i,minH:36,pad:`6px 16px`,children:[(0,R.jsxs)(Z,{size:12.5,className:`text-ink`,children:[`p-`,e,` · gap-`,e]}),(0,R.jsxs)(Z,{size:12,className:`text-muted`,children:[r*e,`px`]}),(0,R.jsx)(nP,{px:r*e})]},e)):null,n.map(e=>(0,R.jsxs)(K_,{cols:i,minH:40,pad:`6px 16px`,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),(0,R.jsx)(nP,{px:e.light?Qk(e.light.value):null})]},e.name))]})}function iP({token:e,children:t}){return(0,R.jsxs)(`button`,{type:`button`,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col items-stretch gap-2.5 rounded-[8px] border border-transparent bg-transparent p-2 text-left transition-colors hover:border-rule hover:bg-soft`,children:[t,(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(nA,{items:Yk(e)}),(0,R.jsx)(aA,{children:e.light?.value}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function aP({title:e,tokens:t,min:n=170,children:r}){return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(${n}px, 1fr))`},children:t.map(e=>(0,R.jsx)(iP,{token:e,children:r(e)},e.name))})]})}function oP({tokens:e}){let t=`minmax(170px,1fr) minmax(90px,0.6fr) 110px 90px`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Breakpoints`,count:e.length}),(0,R.jsx)(W_,{cols:t,labels:[`Token`,`Variant`,`Value`,`Pixels`],align:`lllr`}),e.map(e=>{let n=e.light?Qk(e.light.value):null;return(0,R.jsxs)(K_,{cols:t,align:`lllr`,minH:40,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(nA,{items:Yk(e)}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:n===null?``:`${n}px`})]},e.name)})]})}function sP({system:e}){let t=b_(),n=Xk(e.tokens,`spacing`),r=Xk(e.tokens,`radius`),i=Xk(e.tokens,`shadow`),a=Xk(e.tokens,`blur`),o=Xk(e.tokens,`breakpoint`),s=!n.length&&!r.length&&!i.length&&!a.length&&!o.length;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Spacing & shape`,sub:`Click a token to copy its variable.`}),s?(0,R.jsxs)(rA,{title:`No spacing or shape tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--spacing`}),` (the base step), `,(0,R.jsx)(Z,{children:`--spacing-*`}),`, `,(0,R.jsx)(Z,{children:`--radius-*`}),`,`,` `,(0,R.jsx)(Z,{children:`--shadow-*`}),` and `,(0,R.jsx)(Z,{children:`--breakpoint-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block in`,` `,(0,R.jsx)(Z,{children:iA}),`.`]}):null,n.length?(0,R.jsx)(rP,{tokens:n}):null,r.length?(0,R.jsx)(aP,{title:`Radii`,tokens:r,children:e=>(0,R.jsx)(`span`,{className:`flex h-[88px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`size-14 border border-rule-strong bg-surface`,style:{borderRadius:e.light?.value}})})}):null,i.length?(0,R.jsx)(aP,{title:`Shadows`,tokens:i,min:200,children:e=>(0,R.jsx)(`span`,{className:`flex h-[112px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`h-[60px] w-[108px] rounded-[8px] bg-surface`,style:{boxShadow:$k(e,t)}})})}):null,a.length?(0,R.jsx)(aP,{title:`Blur`,tokens:a,children:e=>(0,R.jsxs)(`span`,{className:`relative flex h-[88px] items-center justify-center overflow-hidden rounded-[6px] bg-soft`,children:[(0,R.jsx)(`span`,{className:`absolute left-5 top-4 size-10 rounded-full bg-action`}),(0,R.jsx)(`span`,{className:`absolute right-6 bottom-3 size-12 rounded-[6px] bg-ink2`}),(0,R.jsx)(`span`,{className:`absolute inset-x-6 inset-y-5 rounded-[6px] bg-surface/40`,style:{backdropFilter:`blur(${e.light?.value})`}})]})}):null,o.length?(0,R.jsx)(oP,{tokens:o}):null]})}var cP={font:`Family`,text:`Size`,weight:`Weight`,leading:`Line height`,tracking:`Letter spacing`};function lP(e){return e.kind===`text`?[e.light?.value,e.lineHeight].filter(Boolean).join(` / `):e.light?.value??``}function uP({system:e}){let[t,n]=eA(),r=Xk(e.tokens,`font`,`text`,`weight`,`leading`,`tracking`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Typography`,sub:`Set in the design system's own stylesheet, with its fonts.`}),e.typographyUrl?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Specimen`,right:(0,R.jsx)(tA,{value:t,onChange:n})}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(fA,{src:e.typographyUrl,theme:t,title:`Typography specimen`,minHeight:200})})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Tokens`,count:r.length}),(0,R.jsx)(W_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,labels:[`Token`,`Kind`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,minH:42,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:cP[e.kind]}),(0,R.jsx)(nA,{items:Yk(e)}),(0,R.jsx)(aA,{children:lP(e)})]},e.name))]}):(0,R.jsxs)(rA,{title:`No type tokens`,children:[`Add font families (`,(0,R.jsx)(Z,{children:`--font-*`}),`), sizes (`,(0,R.jsx)(Z,{children:`--text-*`}),` with`,` `,(0,R.jsx)(Z,{children:`--text-*--line-height`}),`) and weights (`,(0,R.jsx)(Z,{children:`--font-weight-*`}),`) to the `,(0,R.jsx)(Z,{children:`@theme`}),` `,`block in `,(0,R.jsx)(Z,{children:iA}),`. Web fonts go in `,(0,R.jsx)(Z,{children:`system.json`}),` `,(0,R.jsx)(Z,{children:`fonts`}),`.`]})]})}function dP({system:e}){let[t]=I();return(0,R.jsx)(`main`,{className:`mx-auto flex w-full max-w-[1440px] grow animate-[q-fade-in_160ms_ease-out] px-8 max-md:px-4`,children:(0,R.jsxs)(`div`,{className:`grid w-full items-start gap-6 max-lg:grid-cols-1! max-lg:gap-0`,style:{gridTemplateColumns:`232px minmax(0, 1fr)`},children:[(0,R.jsx)(`aside`,{className:`sticky top-[52px] flex max-h-[calc(100dvh-52px)] flex-col overflow-y-auto pt-6 pb-4 max-lg:static max-lg:max-h-none max-lg:overflow-visible max-lg:pb-0 max-md:pt-4`,children:(0,R.jsx)(WN,{system:e})}),(0,R.jsx)(`div`,{className:`flex min-w-0 animate-[q-fade-in_160ms_ease-out] flex-col gap-5 pt-6 pb-7`,children:(0,R.jsxs)(xe,{children:[(0,R.jsx)(ve,{path:`/system`,children:(0,R.jsx)($N,{system:e})}),(0,R.jsx)(ve,{path:`/system/colors`,children:(0,R.jsx)(dA,{system:e})}),(0,R.jsx)(ve,{path:`/system/typography`,children:(0,R.jsx)(uP,{system:e})}),(0,R.jsx)(ve,{path:`/system/shape`,children:(0,R.jsx)(sP,{system:e})}),(0,R.jsx)(ve,{path:`/system/motion`,children:(0,R.jsx)(UN,{system:e})}),(0,R.jsx)(ve,{path:`/system/tokens`,children:(0,R.jsx)(qN,{system:e})}),(0,R.jsx)(ve,{path:`/system/assets`,children:(0,R.jsx)(sA,{system:e})}),(0,R.jsx)(ve,{path:`/system/guidelines/:slug`,children:t=>(0,R.jsx)(FN,{system:e,slug:decodeURIComponent(t.slug)})}),(0,R.jsx)(ve,{path:`/system/components/:id`,children:t=>(0,R.jsx)(NN,{system:e,id:decodeURIComponent(t.id)})}),(0,R.jsx)(ve,{children:(0,R.jsx)(nO,{title:`No such page`,text:`This page is not part of the design system.`})})]})},t)]})})}function fP(){return(0,R.jsx)(tv,{title:`No design system yet`,text:(0,R.jsxs)(R.Fragment,{children:[`Ask your agent to build one from the codebase, or run `,(0,R.jsx)(Z,{children:`design system init`}),` to start from a template in `,(0,R.jsx)(Z,{children:`.design/system`}),`.`]})})}function pP(){let e=n_().data,t=e?e.system!==null:void 0,{data:n,error:r,isLoading:i}=i_(t===!0);return t===!1||n===null||r instanceof Fg&&r.status===404?(0,R.jsx)(fP,{}):r?(0,R.jsx)(tv,{title:`Could not load the design system`,text:r.message}):i||!n?null:(0,R.jsx)(dP,{system:n})}function mP(){let{name:e,icon:t}=n_().data??{};return(0,v.useEffect)(()=>{e&&(document.title=`${e} · Design`)},[e]),(0,v.useEffect)(()=>{let e=document.querySelector(`link[rel="icon"]`);e&&(e.dataset.fallback??=e.getAttribute(`href`)??``,e.removeAttribute(`type`),e.href=t||e.dataset.fallback)},[t]),null}var hP=new URLSearchParams(window.location.search).has(`capture`);function gP(){let e=Tw()&&!hP;return{play:(t,n)=>e?(0,R.jsx)(Dk,{canvasId:t,itemId:n}):(0,R.jsx)(wk,{canvasId:t,itemId:n}),canvas:(t,n)=>e?(0,R.jsx)(Dk,{canvasId:t,pageId:n}):(0,R.jsx)(hk,{canvasId:t,pageId:n})}}function _P(){let e=gP();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(ve,{path:`/c/:canvas/full/:item`,children:e=>(0,R.jsx)(hO,{canvasId:e.canvas,itemId:e.item})}),(0,R.jsx)(ve,{path:`/c/:canvas/play/:item`,children:t=>e.play(t.canvas,t.item)}),(0,R.jsx)(ve,{path:`/c/:canvas/p/:page`,children:t=>e.canvas(t.canvas,t.page)}),(0,R.jsx)(ve,{path:`/c/:canvas`,children:t=>e.canvas(t.canvas)}),(0,R.jsxs)(ve,{path:`/system/*?`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(pP,{})]}),(0,R.jsxs)(ve,{path:`/`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(Jk,{})]}),(0,R.jsxs)(ve,{children:[(0,R.jsx)(xw,{}),(0,R.jsx)(nO,{})]})]})}function vP({canvas:e}){let t=`/c/${encodeURIComponent(e)}`,n=(n,r)=>e_(n,e)?r:(0,R.jsx)(Se,{to:t,replace:!0}),r=gP();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(ve,{path:`/c/:canvas/full/:item`,children:t=>n(t.canvas,(0,R.jsx)(hO,{canvasId:e,itemId:t.item}))}),(0,R.jsx)(ve,{path:`/c/:canvas/play/:item`,children:t=>n(t.canvas,r.play(e,t.item))}),(0,R.jsx)(ve,{path:`/c/:canvas/p/:page`,children:t=>n(t.canvas,r.canvas(e,t.page))}),(0,R.jsx)(ve,{path:`/c/:canvas`,children:t=>n(t.canvas,r.canvas(e))}),(0,R.jsx)(ve,{children:(0,R.jsx)(Se,{to:t,replace:!0})})]})}function yP({source:e,base:t=``,frameSandbox:n,frameAllow:r=Jg,slots:i,scope:a,queryClient:o}){let[s]=(0,v.useState)(()=>o??t_(e.live)),c=o??s,l=(0,v.useMemo)(()=>qg(Zg(e)),[e]),u=a?.canvas,d=(0,v.useMemo)(()=>({source:e,keys:l,frameSandbox:n,frameAllow:r,slots:i??{},scope:u===void 0?null:{canvas:u}}),[e,l,n,r,i,u]);return(0,v.useEffect)(()=>e.live?o_(c,l):void 0,[e,c,l]),(0,R.jsx)(Ne,{client:c,children:(0,R.jsx)(Qg.Provider,{value:d,children:(0,R.jsx)(id,{reducedMotion:`user`,children:(0,R.jsxs)(Dx,{children:[(0,R.jsx)(mP,{}),(0,R.jsxs)(he,{base:t,children:[(0,R.jsx)(iv,{children:d.scope?(0,R.jsx)(vP,{canvas:d.scope.canvas}):(0,R.jsx)(_P,{})}),(0,R.jsx)(D_,{})]}),(0,R.jsx)(rT,{})]})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(v.StrictMode,{children:Pg?(0,R.jsx)(he,{hook:ke,hrefs:e=>`#${e}`,children:(0,R.jsx)(yP,{source:Hg})}):(0,R.jsx)(yP,{source:Bg})}));
159
+ `)}),(0,R.jsx)(`pre`,{className:`m-0 min-w-0 grow py-3 pr-6 pl-4 text-ink`,children:(0,R.jsx)(`code`,{dangerouslySetInnerHTML:{__html:i}})})]})]})}var EN={beta:`action`,experimental:`action`,draft:`action`,deprecated:`danger`,stable:`ok`},DN=`.design/system/components/`;function ON(e){return e.startsWith(DN)?`@system/components/${e.slice(26).replace(/\.(tsx|jsx|ts|js)$/,``).replace(/\/index$/,``)}`:null}function kN(e){let t=new Set;for(let n of e.matchAll(/export\s+(?:async\s+)?(?:function|const|class|let)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);for(let n of e.matchAll(/export\s*\{([^}]+)\}/g))for(let e of n[1].split(`,`)){let n=e.trim().split(/\s+as\s+/).pop()?.trim();n&&n!=="default"&&t.add(n)}return[...t].filter(e=>/^[A-Z]/.test(e))}function AN({path:e}){let t=ON(e),n=a_(t?e:null).data;if(!t)return null;let r=n?kN(n):[],i=`import { ${r.length?r.join(`, `):`…`} } from '${t}'`;return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-rule py-1.5 pr-1.5 pl-4`,children:[(0,R.jsx)(Z,{size:12.5,className:`min-w-0 truncate text-ink2`,title:i,children:i}),(0,R.jsx)(N_,{icon:`copy`,label:`Copy the import`,size:14,className:`ml-auto`,onClick:()=>iT(i)})]})}function jN({component:e,theme:t,width:n}){return n===`fill`?(0,R.jsx)(pA,{src:e.url,theme:t,title:e.title,minHeight:160}):(0,R.jsx)(`div`,{className:`flex justify-center overflow-x-auto bg-soft p-6`,children:(0,R.jsx)(`div`,{className:`shrink-0 overflow-hidden rounded-[8px] border border-rule bg-surface shadow-frame`,children:(0,R.jsx)(pA,{src:e.url,theme:t,title:e.title,minHeight:160,width:Number(n)})})})}function MN({component:e}){let t=[...e.sources,e.specimen],[n,r]=(0,v.useState)(t[0]),i=t.includes(n)?n:t[0],{data:a,error:o,isLoading:s}=a_(i);return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[t.length>1?(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-rule px-4 py-2.5`,children:(0,R.jsx)(cO,{label:`File`,size:`sm`,value:i,onChange:r,items:t.map(t=>({value:t,label:t===e.specimen?`${NN(t)} · specimen`:NN(t),title:t}))})}):null,ON(i)?(0,R.jsx)(AN,{path:i}):null,o?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-6 text-[13px] text-danger-text`,children:[(0,R.jsx)(X,{name:`alert`,size:15}),o.message]}):s||a===void 0?(0,R.jsx)(`div`,{className:`flex items-center justify-center py-10 text-muted`,children:(0,R.jsx)(X,{name:`loader`,size:18})}):(0,R.jsx)(TN,{code:a,path:i})]})}function NN(e){return e.split(`/`).pop()??e}function PN({system:e,id:t}){let n=e.components.find(e=>e.id===t),[r,i]=(0,v.useState)(`preview`),[a,o]=tA(),[s,c]=(0,v.useState)(`fill`),l=!$g().frameSandbox;if(!n)return(0,R.jsx)(nO,{title:`No such component`,text:`There is no specimen "${t}" in .design/system/specimens.`});let u=n.status?.toLowerCase();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,badge:(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(L_,{children:n.group}),u?(0,R.jsx)(L_,{tone:EN[u]??`neutral`,children:n.status}):null]}),sub:n.description}),(0,R.jsxs)(z_,{children:[(0,R.jsx)(V_,{value:r,onChange:i,items:[{value:`preview`,label:`Preview`},{value:`code`,label:`Code`,count:n.sources.length+1}],right:r===`preview`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(cO,{label:`Width`,size:`sm`,value:s,onChange:c,items:[{value:`fill`,label:`Fill`},{value:`768`,label:`768`},{value:`390`,label:`390`}]}),(0,R.jsx)(nA,{value:a,onChange:o}),l?(0,R.jsx)(F_,{icon:`external`,href:RD(LD(n.url,a)),target:`_blank`,rel:`noreferrer`,children:`Open`}):null]}):null}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:r===`preview`?(0,R.jsx)(jN,{component:n,theme:a,width:s}):(0,R.jsx)(MN,{component:n})})]})]})}function FN(e,t){let n=/^\s*#\s+(.+)\r?\n/.exec(e);return n&&n[1].trim()===t?e.slice(n[0].length):e}function IN({system:e,slug:t}){let n=e.guidelines.find(e=>e.slug===t);if(!n)return(0,R.jsx)(nO,{title:`No such guideline`,text:`There is no guideline "${t}" in .design/system/guidelines.`});let r=FN(n.markdown,n.title).trim();return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:n.title,sub:`Guideline`}),(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:r?(0,R.jsx)(uD,{text:r,className:`max-w-[760px]`}):(0,R.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`This guideline is empty. Write it in `,(0,R.jsx)(Z,{children:`.design/system/guidelines`}),`.`]})})})]})}var LN={linear:[0,0,1,1],ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]};function RN(e){let t=e.trim();if(LN[t])return LN[t];let n=/^cubic-bezier\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)$/.exec(t);if(!n)return null;let r=n.slice(1).map(Number);return r.every(Number.isFinite)?r:null}function zN(e){let t=/^(-?[\d.]+)(ms|s)$/.exec(e.trim());return t?Number(t[1])*(t[2]===`s`?1e3:1):null}var BN=132,VN=22;function HN({bezier:e}){let[t,n,r,i]=e,a=Math.min(0,n,i),o=Math.max(1,n,i),s=88/(o-a),c=e=>VN+e*88,l=e=>VN+(o-e)*s;return(0,R.jsxs)(`svg`,{width:BN,height:BN,viewBox:`0 0 ${BN} ${BN}`,"aria-hidden":`true`,className:`shrink-0`,children:[(0,R.jsx)(`rect`,{x:c(0),y:l(1),width:88,height:l(0)-l(1),className:`fill-none stroke-rule`}),(0,R.jsx)(`line`,{x1:c(0),y1:l(0),x2:c(t),y2:l(n),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`line`,{x1:c(1),y1:l(1),x2:c(r),y2:l(i),className:`stroke-rule-strong`,strokeDasharray:`3 3`}),(0,R.jsx)(`path`,{d:`M ${c(0)} ${l(0)} C ${c(t)} ${l(n)}, ${c(r)} ${l(i)}, ${c(1)} ${l(1)}`,className:`fill-none stroke-ink`,strokeWidth:2,strokeLinecap:`round`}),(0,R.jsx)(`circle`,{cx:c(t),cy:l(n),r:3,className:`fill-action`}),(0,R.jsx)(`circle`,{cx:c(r),cy:l(i),r:3,className:`fill-action`})]})}function UN({token:e,duration:t}){let[n,r]=(0,v.useState)(!1),i=e.light?.value??``,a=RN(i);return(0,R.jsxs)(`button`,{type:`button`,title:`Hover to play; click to copy the variable`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),onClick:()=>iT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col gap-3 rounded-[8px] border border-transparent bg-transparent p-3 text-left transition-colors hover:border-rule hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex h-[132px] items-center justify-center rounded-[6px] bg-soft`,children:a?(0,R.jsx)(HN,{bezier:a}):(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`No curve to draw`})}),(0,R.jsx)(`span`,{className:`relative mx-1 h-2 rounded-full bg-soft2`,children:(0,R.jsx)(`span`,{className:`absolute top-1/2 size-3.5 -translate-y-1/2 rounded-full bg-ink`,style:{left:n?`calc(100% - 14px)`:`0px`,transition:`left ${t}ms ${i||`ease`}`}})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(rA,{items:Xk(e)}),(0,R.jsx)(oA,{children:i}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function WN({system:e}){let t=Zk(e.tokens,`ease`),n=Zk(e.tokens,`duration`),r=Zk(e.tokens,`animation`),i=`minmax(170px,1fr) 100px minmax(0,2fr)`,a=`minmax(170px,1fr) minmax(140px,0.7fr) minmax(0,2fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Motion`,sub:`Hover an easing to see it move.`}),!t.length&&!n.length&&!r.length?(0,R.jsxs)(iA,{title:`No motion tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--ease-*`}),` and `,(0,R.jsx)(Z,{children:`--animate-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block, and durations as`,` `,(0,R.jsx)(Z,{children:`--duration-*`}),`, in `,(0,R.jsx)(Z,{children:aA}),`.`]}):null,t.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Easing`,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(190px, 1fr))`},children:t.map(e=>(0,R.jsx)(UN,{token:e,duration:900},e.name))})]}):null,n.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Durations`,count:n.length}),(0,R.jsx)(W_,{cols:i,labels:[`Token`,`Value`,``]}),n.map(e=>{let t=e.light?zN(e.light.value):null;return(0,R.jsxs)(K_,{cols:i,minH:40,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),t===null?(0,R.jsx)(`span`,{}):(0,R.jsx)(`span`,{className:`h-3 rounded-[3px] bg-action/70`,style:{width:Math.max(2,Math.min(t/2,480))}})]},e.name)})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Animations`,count:r.length,sub:`keyframes live in the system stylesheet`}),(0,R.jsx)(W_,{cols:a,labels:[`Token`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:a,minH:40,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(rA,{items:Xk(e)}),(0,R.jsx)(oA,{children:e.light?.value})]},e.name))]}):null]})}function GN({system:e}){let t=Tw(),n=new Set(e.tokens.map(e=>e.kind)),r=[{to:`/system/colors`,label:`Colors`,hint:KN(e,`color`)},{to:`/system/typography`,label:`Typography`},{to:`/system/shape`,label:`Spacing & shape`}];(n.has(`ease`)||n.has(`duration`)||n.has(`animation`))&&r.push({to:`/system/motion`,label:`Motion`}),n.has(`other`)&&r.push({to:`/system/tokens`,label:`Other tokens`,hint:KN(e,`other`)}),e.assets.length&&r.push({to:`/system/assets`,label:`Assets`,hint:e.assets.length});let i=new Map;for(let t of e.components){let e=i.get(t.group)??[];e.push({to:`/system/components/${encodeURIComponent(t.id)}`,label:t.title,hint:t.status}),i.set(t.group,e)}let a=e.guidelines.filter(e=>e.slug!==`overview`);if(t){let e=[{label:``,items:[{to:`/system`,label:`Overview`}]},{label:`Foundations`,items:r},{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))},...[...i].map(([e,t])=>({label:e,items:t}))];return(0,R.jsx)(qN,{sections:e.filter(e=>e.items.length)})}return(0,R.jsxs)(`div`,{className:`flex flex-col max-lg:gap-1 max-lg:[&_nav]:flex-row max-lg:[&_nav]:flex-wrap`,children:[(0,R.jsx)(Q_,{label:`Overview`,items:[{to:`/system`,label:`Overview`}]}),(0,R.jsx)($_,{children:`Foundations`}),(0,R.jsx)(Q_,{label:`Foundations`,items:r}),a.length?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)($_,{children:`Guidelines`}),(0,R.jsx)(Q_,{label:`Guidelines`,items:a.map(e=>({to:`/system/guidelines/${encodeURIComponent(e.slug)}`,label:e.title}))})]}):null,[...i].map(([e,t])=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[(0,R.jsx)($_,{children:e}),(0,R.jsx)(Q_,{label:e,items:t})]},e))]})}function KN(e,t){return e.tokens.filter(e=>e.kind===t).length||void 0}function qN({sections:e}){let[t]=I(),[n,r]=(0,v.useState)(!1),i=e.flatMap(e=>e.items).find(e=>e.to===t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`flex h-11 w-full cursor-pointer items-center gap-2 rounded-[8px] border border-rule bg-surface px-3.5 text-left text-[14px] text-ink`,children:[(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`Section`}),(0,R.jsx)(`span`,{className:`min-w-0 grow truncate font-medium`,children:i?.label??`Overview`}),(0,R.jsx)(X,{name:`chevron-down`,size:16,className:`shrink-0 text-muted`})]}),(0,R.jsx)(Sk,{open:n,onOpenChange:r,title:`Design system`,children:(0,R.jsx)(`nav`,{"aria-label":`Design system`,className:`flex flex-col pb-2`,children:e.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[e.label?(0,R.jsx)(`div`,{className:`px-4 pt-3 pb-1 text-[12px] text-muted`,children:e.label}):null,e.items.map(e=>{let n=e.to===t;return(0,R.jsxs)(ye,{href:e.to,onClick:()=>r(!1),"aria-current":n?`page`:void 0,className:Y(`flex min-h-[46px] items-center gap-2 px-4 text-[14px] no-underline active:bg-soft2`,n?`font-medium text-ink`:`text-ink2`),children:[(0,R.jsx)(`span`,{className:`min-w-0 grow truncate`,children:e.label}),e.hint?(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:e.hint}):null,n?(0,R.jsx)(X,{name:`check`,size:16,className:`shrink-0 text-action`}):null]},e.to)})]},e.label||`overview`))})})]})}function JN({system:e}){let t=Zk(e.tokens,`other`),n=`minmax(170px,1fr) minmax(0,1fr) minmax(0,1fr) minmax(0,1.3fr)`;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Other tokens`,sub:`Variables that are not colors, type, spacing, shape or motion.`}),t.length?Qk(t).map(({group:e,tokens:t})=>(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(W_,{cols:n,labels:[`Token`,`Light`,`Dark`,`Description`]}),t.map(e=>(0,R.jsxs)(K_,{cols:n,minH:40,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(oA,{children:e.light?.value}),(0,R.jsx)(oA,{children:e.dark?.value??`—`}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:e.description})]},e.name))]},e)):(0,R.jsxs)(iA,{title:`No other tokens`,children:[`Variables in `,(0,R.jsx)(Z,{children:`:root`}),` of `,(0,R.jsx)(Z,{children:aA}),` that are not colors or lengths show here.`]})]})}function YN(e,...t){return e.tokens.filter(e=>t.includes(e.kind)).length}function XN(e){let t=[{to:`/system/colors`,icon:`palette`,title:`Colors`,text:Rk(YN(e,`color`),`token`)},{to:`/system/typography`,icon:`type`,title:`Typography`,text:`${Rk(YN(e,`font`),`family`,`families`)} · ${Rk(YN(e,`text`),`size`)}`},{to:`/system/shape`,icon:`shape`,title:`Spacing & shape`,text:Rk(YN(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),`token`)}],n=YN(e,`ease`,`duration`,`animation`);n&&t.push({to:`/system/motion`,icon:`motion`,title:`Motion`,text:Rk(n,`token`)}),e.assets.length&&t.push({to:`/system/assets`,icon:`image`,title:`Assets`,text:Rk(e.assets.length,`file`)});let r=e.components[0];return r&&t.push({to:`/system/components/${encodeURIComponent(r.id)}`,icon:`component`,title:`Components`,text:Rk(e.components.length,`component`)}),t}function ZN({system:e}){return(0,R.jsx)(`div`,{className:`grid gap-4`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(220px, 1fr))`},children:XN(e).map(e=>(0,R.jsxs)(ye,{href:e.to,className:`flex items-center gap-3 rounded-[10px] border border-rule bg-surface px-4 py-3.5 text-inherit no-underline transition-colors hover:border-rule-strong hover:bg-soft`,children:[(0,R.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[8px] bg-soft2 text-ink2`,children:(0,R.jsx)(X,{name:e.icon,size:17})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[14px] font-medium text-ink`,children:e.title}),(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.text})]})]},e.to))})}function QN({system:e}){let[,t]=I(),n=[{label:`Color tokens`,value:YN(e,`color`),to:`/system/colors`},{label:`Type tokens`,value:YN(e,`font`,`text`,`weight`,`leading`,`tracking`),to:`/system/typography`},{label:`Spacing & shape tokens`,value:YN(e,`spacing`,`radius`,`shadow`,`blur`,`breakpoint`),to:`/system/shape`},{label:`Motion tokens`,value:YN(e,`ease`,`duration`,`animation`),to:`/system/motion`},{label:`Other tokens`,value:YN(e,`other`),to:`/system/tokens`},{label:`Components`,value:e.components.length},{label:`Guidelines`,value:e.guidelines.length}];return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`At a glance`}),n.filter(e=>e.value||!e.to||e.to===`/system/colors`).map(e=>(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,onClick:e.to&&e.value?()=>t(e.to):void 0,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:e.label}),(0,R.jsx)(R_,{value:e.value})]},e.label)),e.fonts.length?(0,R.jsxs)(K_,{cols:`minmax(0,1fr) auto`,align:`lr`,minH:40,pad:`8px 16px`,children:[(0,R.jsx)(`span`,{className:`text-[13.5px] text-ink2`,children:`Web fonts`}),(0,R.jsx)(`span`,{className:`flex min-w-0 flex-col items-end gap-0.5`,children:e.fonts.map(e=>(0,R.jsx)(Z,{size:12,className:`max-w-[260px] truncate text-muted`,title:e,children:$N(e)},e))})]}):null]})}function $N(e){try{let t=new URL(e),n=t.searchParams.getAll(`family`).map(e=>e.split(`:`)[0].replace(/\+/g,` `));return n.length?n.join(`, `):t.host}catch{return e}}function eP({system:e}){let t=e.guidelines.find(e=>e.slug===`overview`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:e.name,sub:e.description}),(0,R.jsx)($D,{issues:e.issues,title:`Problems in the design system`}),(0,R.jsx)(ZN,{system:e}),(0,R.jsxs)(`div`,{className:`grid items-start gap-5 max-xl:grid-cols-1!`,style:{gridTemplateColumns:`minmax(0,1fr) 320px`},children:[t?(0,R.jsx)(z_,{children:(0,R.jsx)(`div`,{className:`px-6 py-5`,children:(0,R.jsx)(uD,{text:t.markdown})})}):(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Overview`}),(0,R.jsxs)(`div`,{className:`border-t border-rule px-4 py-5 text-[13px] text-muted`,children:[`Write the principles every screen follows in `,(0,R.jsx)(Z,{children:`.design/system/guidelines/01-overview.md`}),`; it shows here.`]})]}),(0,R.jsx)(QN,{system:e})]})]})}var tP=[1,2,3,4,6,8,12,16],nP=480;function rP({px:e}){return e===null?(0,R.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`not a plain length`}):(0,R.jsxs)(`span`,{className:`flex h-3 items-center`,children:[(0,R.jsx)(`span`,{className:`h-3 rounded-[3px] bg-action/70`,style:{width:Math.max(2,Math.min(e,nP))},title:`${e}px`}),e>nP?(0,R.jsx)(`span`,{className:`ml-1.5 text-[12px] text-muted`,children:`…`}):null]})}function iP({tokens:e}){let t=e.find(e=>e.name===`--spacing`),n=e.filter(e=>e!==t),r=t?.light?$k(t.light.value):null,i=`minmax(150px,0.8fr) 110px minmax(0,2fr)`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Spacing`,count:e.length,sub:t?`base ${t.light?.value}`:void 0}),(0,R.jsx)(W_,{cols:i,labels:[`Class or token`,`Value`,``]}),t&&r!==null?tP.map(e=>(0,R.jsxs)(K_,{cols:i,minH:36,pad:`6px 16px`,children:[(0,R.jsxs)(Z,{size:12.5,className:`text-ink`,children:[`p-`,e,` · gap-`,e]}),(0,R.jsxs)(Z,{size:12,className:`text-muted`,children:[r*e,`px`]}),(0,R.jsx)(rP,{px:r*e})]},e)):null,n.map(e=>(0,R.jsxs)(K_,{cols:i,minH:40,pad:`6px 16px`,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),(0,R.jsx)(rP,{px:e.light?$k(e.light.value):null})]},e.name))]})}function aP({token:e,children:t}){return(0,R.jsxs)(`button`,{type:`button`,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),className:`flex min-w-0 cursor-pointer flex-col items-stretch gap-2.5 rounded-[8px] border border-transparent bg-transparent p-2 text-left transition-colors hover:border-rule hover:bg-soft`,children:[t,(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5 px-1`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(rA,{items:Xk(e)}),(0,R.jsx)(oA,{children:e.light?.value}),e.description?(0,R.jsx)(`span`,{className:`text-[12.5px] text-ink2`,children:e.description}):null]})]})}function oP({title:e,tokens:t,min:n=170,children:r}){return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:e,count:t.length}),(0,R.jsx)(`div`,{className:`grid gap-2 border-t border-rule p-3`,style:{gridTemplateColumns:`repeat(auto-fill, minmax(${n}px, 1fr))`},children:t.map(e=>(0,R.jsx)(aP,{token:e,children:r(e)},e.name))})]})}function sP({tokens:e}){let t=`minmax(170px,1fr) minmax(90px,0.6fr) 110px 90px`;return(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Breakpoints`,count:e.length}),(0,R.jsx)(W_,{cols:t,labels:[`Token`,`Variant`,`Value`,`Pixels`],align:`lllr`}),e.map(e=>{let n=e.light?$k(e.light.value):null;return(0,R.jsxs)(K_,{cols:t,align:`lllr`,minH:40,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),(0,R.jsx)(rA,{items:Xk(e)}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:e.light?.value}),(0,R.jsx)(Z,{size:12,className:`text-muted`,children:n===null?``:`${n}px`})]},e.name)})]})}function cP({system:e}){let t=b_(),n=Zk(e.tokens,`spacing`),r=Zk(e.tokens,`radius`),i=Zk(e.tokens,`shadow`),a=Zk(e.tokens,`blur`),o=Zk(e.tokens,`breakpoint`),s=!n.length&&!r.length&&!i.length&&!a.length&&!o.length;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Spacing & shape`,sub:`Click a token to copy its variable.`}),s?(0,R.jsxs)(iA,{title:`No spacing or shape tokens`,children:[`Add `,(0,R.jsx)(Z,{children:`--spacing`}),` (the base step), `,(0,R.jsx)(Z,{children:`--spacing-*`}),`, `,(0,R.jsx)(Z,{children:`--radius-*`}),`,`,` `,(0,R.jsx)(Z,{children:`--shadow-*`}),` and `,(0,R.jsx)(Z,{children:`--breakpoint-*`}),` to the `,(0,R.jsx)(Z,{children:`@theme`}),` block in`,` `,(0,R.jsx)(Z,{children:aA}),`.`]}):null,n.length?(0,R.jsx)(iP,{tokens:n}):null,r.length?(0,R.jsx)(oP,{title:`Radii`,tokens:r,children:e=>(0,R.jsx)(`span`,{className:`flex h-[88px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`size-14 border border-rule-strong bg-surface`,style:{borderRadius:e.light?.value}})})}):null,i.length?(0,R.jsx)(oP,{title:`Shadows`,tokens:i,min:200,children:e=>(0,R.jsx)(`span`,{className:`flex h-[112px] items-center justify-center rounded-[6px] bg-soft`,children:(0,R.jsx)(`span`,{className:`h-[60px] w-[108px] rounded-[8px] bg-surface`,style:{boxShadow:eA(e,t)}})})}):null,a.length?(0,R.jsx)(oP,{title:`Blur`,tokens:a,children:e=>(0,R.jsxs)(`span`,{className:`relative flex h-[88px] items-center justify-center overflow-hidden rounded-[6px] bg-soft`,children:[(0,R.jsx)(`span`,{className:`absolute left-5 top-4 size-10 rounded-full bg-action`}),(0,R.jsx)(`span`,{className:`absolute right-6 bottom-3 size-12 rounded-[6px] bg-ink2`}),(0,R.jsx)(`span`,{className:`absolute inset-x-6 inset-y-5 rounded-[6px] bg-surface/40`,style:{backdropFilter:`blur(${e.light?.value})`}})]})}):null,o.length?(0,R.jsx)(sP,{tokens:o}):null]})}var lP={font:`Family`,text:`Size`,weight:`Weight`,leading:`Line height`,tracking:`Letter spacing`};function uP(e){return e.kind===`text`?[e.light?.value,e.lineHeight].filter(Boolean).join(` / `):e.light?.value??``}function dP({system:e}){let[t,n]=tA(),r=Zk(e.tokens,`font`,`text`,`weight`,`leading`,`tracking`);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Z_,{title:`Typography`,sub:`Set in the design system's own stylesheet, with its fonts.`}),e.typographyUrl?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Specimen`,right:(0,R.jsx)(nA,{value:t,onChange:n})}),(0,R.jsx)(`div`,{className:`border-t border-rule`,children:(0,R.jsx)(pA,{src:e.typographyUrl,theme:t,title:`Typography specimen`,minHeight:200})})]}):null,r.length?(0,R.jsxs)(z_,{children:[(0,R.jsx)(B_,{title:`Tokens`,count:r.length}),(0,R.jsx)(W_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,labels:[`Token`,`Kind`,`Class`,`Value`]}),r.map(e=>(0,R.jsxs)(K_,{cols:`minmax(160px,1fr) 110px minmax(120px,0.8fr) minmax(0,1.4fr)`,minH:42,title:`Copy the variable`,onClick:()=>iT(`var(${e.name})`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,R.jsx)(Z,{size:12.5,className:`truncate text-ink`,children:e.name}),e.description?(0,R.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.description}):null]}),(0,R.jsx)(`span`,{className:`text-[13px] text-ink2`,children:lP[e.kind]}),(0,R.jsx)(rA,{items:Xk(e)}),(0,R.jsx)(oA,{children:uP(e)})]},e.name))]}):(0,R.jsxs)(iA,{title:`No type tokens`,children:[`Add font families (`,(0,R.jsx)(Z,{children:`--font-*`}),`), sizes (`,(0,R.jsx)(Z,{children:`--text-*`}),` with`,` `,(0,R.jsx)(Z,{children:`--text-*--line-height`}),`) and weights (`,(0,R.jsx)(Z,{children:`--font-weight-*`}),`) to the `,(0,R.jsx)(Z,{children:`@theme`}),` `,`block in `,(0,R.jsx)(Z,{children:aA}),`. Web fonts go in `,(0,R.jsx)(Z,{children:`system.json`}),` `,(0,R.jsx)(Z,{children:`fonts`}),`.`]})]})}function fP({system:e}){let[t]=I();return(0,R.jsx)(`main`,{className:`mx-auto flex w-full max-w-[1440px] grow animate-[q-fade-in_160ms_ease-out] px-8 max-md:px-4`,children:(0,R.jsxs)(`div`,{className:`grid w-full items-start gap-6 max-lg:grid-cols-1! max-lg:gap-0`,style:{gridTemplateColumns:`232px minmax(0, 1fr)`},children:[(0,R.jsx)(`aside`,{className:`sticky top-[52px] flex max-h-[calc(100dvh-52px)] flex-col overflow-y-auto pt-6 pb-4 max-lg:static max-lg:max-h-none max-lg:overflow-visible max-lg:pb-0 max-md:pt-4`,children:(0,R.jsx)(GN,{system:e})}),(0,R.jsx)(`div`,{className:`flex min-w-0 animate-[q-fade-in_160ms_ease-out] flex-col gap-5 pt-6 pb-7`,children:(0,R.jsxs)(xe,{children:[(0,R.jsx)(ve,{path:`/system`,children:(0,R.jsx)(eP,{system:e})}),(0,R.jsx)(ve,{path:`/system/colors`,children:(0,R.jsx)(fA,{system:e})}),(0,R.jsx)(ve,{path:`/system/typography`,children:(0,R.jsx)(dP,{system:e})}),(0,R.jsx)(ve,{path:`/system/shape`,children:(0,R.jsx)(cP,{system:e})}),(0,R.jsx)(ve,{path:`/system/motion`,children:(0,R.jsx)(WN,{system:e})}),(0,R.jsx)(ve,{path:`/system/tokens`,children:(0,R.jsx)(JN,{system:e})}),(0,R.jsx)(ve,{path:`/system/assets`,children:(0,R.jsx)(cA,{system:e})}),(0,R.jsx)(ve,{path:`/system/guidelines/:slug`,children:t=>(0,R.jsx)(IN,{system:e,slug:decodeURIComponent(t.slug)})}),(0,R.jsx)(ve,{path:`/system/components/:id`,children:t=>(0,R.jsx)(PN,{system:e,id:decodeURIComponent(t.id)})}),(0,R.jsx)(ve,{children:(0,R.jsx)(nO,{title:`No such page`,text:`This page is not part of the design system.`})})]})},t)]})})}function pP(){return(0,R.jsx)(tv,{title:`No design system yet`,text:(0,R.jsxs)(R.Fragment,{children:[`Ask your agent to build one from the codebase, or run `,(0,R.jsx)(Z,{children:`design system init`}),` to start from a template in `,(0,R.jsx)(Z,{children:`.design/system`}),`.`]})})}function mP(){let e=n_().data,t=e?e.system!==null:void 0,{data:n,error:r,isLoading:i}=i_(t===!0);return t===!1||n===null||r instanceof Fg&&r.status===404?(0,R.jsx)(pP,{}):r?(0,R.jsx)(tv,{title:`Could not load the design system`,text:r.message}):i||!n?null:(0,R.jsx)(fP,{system:n})}function hP(){let{name:e,icon:t}=n_().data??{};return(0,v.useEffect)(()=>{e&&(document.title=`${e} · Design`)},[e]),(0,v.useEffect)(()=>{let e=document.querySelector(`link[rel="icon"]`);e&&(e.dataset.fallback??=e.getAttribute(`href`)??``,e.removeAttribute(`type`),e.href=t||e.dataset.fallback)},[t]),null}var gP=new URLSearchParams(window.location.search).has(`capture`);function _P(){let e=Tw()&&!gP;return{play:(t,n)=>e?(0,R.jsx)(Ok,{canvasId:t,itemId:n}):(0,R.jsx)(Tk,{canvasId:t,itemId:n}),canvas:(t,n)=>e?(0,R.jsx)(Ok,{canvasId:t,pageId:n}):(0,R.jsx)(gk,{canvasId:t,pageId:n})}}function vP(){let e=_P();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(ve,{path:`/c/:canvas/full/:item`,children:e=>(0,R.jsx)(hO,{canvasId:e.canvas,itemId:e.item})}),(0,R.jsx)(ve,{path:`/c/:canvas/play/:item`,children:t=>e.play(t.canvas,t.item)}),(0,R.jsx)(ve,{path:`/c/:canvas/p/:page`,children:t=>e.canvas(t.canvas,t.page)}),(0,R.jsx)(ve,{path:`/c/:canvas`,children:t=>e.canvas(t.canvas)}),(0,R.jsxs)(ve,{path:`/system/*?`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(mP,{})]}),(0,R.jsxs)(ve,{path:`/`,children:[(0,R.jsx)(xw,{}),(0,R.jsx)(Yk,{})]}),(0,R.jsxs)(ve,{children:[(0,R.jsx)(xw,{}),(0,R.jsx)(nO,{})]})]})}function yP({canvas:e}){let t=`/c/${encodeURIComponent(e)}`,n=(n,r)=>e_(n,e)?r:(0,R.jsx)(Se,{to:t,replace:!0}),r=_P();return(0,R.jsxs)(xe,{children:[(0,R.jsx)(ve,{path:`/c/:canvas/full/:item`,children:t=>n(t.canvas,(0,R.jsx)(hO,{canvasId:e,itemId:t.item}))}),(0,R.jsx)(ve,{path:`/c/:canvas/play/:item`,children:t=>n(t.canvas,r.play(e,t.item))}),(0,R.jsx)(ve,{path:`/c/:canvas/p/:page`,children:t=>n(t.canvas,r.canvas(e,t.page))}),(0,R.jsx)(ve,{path:`/c/:canvas`,children:t=>n(t.canvas,r.canvas(e))}),(0,R.jsx)(ve,{children:(0,R.jsx)(Se,{to:t,replace:!0})})]})}function bP({source:e,base:t=``,frameSandbox:n,frameAllow:r=Jg,slots:i,scope:a,queryClient:o}){let[s]=(0,v.useState)(()=>o??t_(e.live)),c=o??s,l=(0,v.useMemo)(()=>qg(Zg(e)),[e]),u=a?.canvas,d=(0,v.useMemo)(()=>({source:e,keys:l,frameSandbox:n,frameAllow:r,slots:i??{},scope:u===void 0?null:{canvas:u}}),[e,l,n,r,i,u]);return(0,v.useEffect)(()=>e.live?o_(c,l):void 0,[e,c,l]),(0,R.jsx)(Ne,{client:c,children:(0,R.jsx)(Qg.Provider,{value:d,children:(0,R.jsx)(id,{reducedMotion:`user`,children:(0,R.jsxs)(Dx,{children:[(0,R.jsx)(hP,{}),(0,R.jsxs)(he,{base:t,children:[(0,R.jsx)(iv,{children:d.scope?(0,R.jsx)(yP,{canvas:d.scope.canvas}):(0,R.jsx)(vP,{})}),(0,R.jsx)(D_,{})]}),(0,R.jsx)(rT,{})]})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(v.StrictMode,{children:Pg?(0,R.jsx)(he,{hook:ke,hrefs:e=>`#${e}`,children:(0,R.jsx)(bP,{source:Hg})}):(0,R.jsx)(bP,{source:Bg})}));