@valbuild/ui 0.75.0 → 0.75.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/ui",
3
- "version": "0.75.0",
3
+ "version": "0.75.1",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "typecheck": "tsc --noEmit",
@@ -422,7 +422,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
422
422
  `)},v_=function(){var e=parseInt(document.body.getAttribute(Bc)||"0",10);return isFinite(e)?e:0},AK=function(){g.useEffect(function(){return document.body.setAttribute(Bc,(v_()+1).toString()),function(){var e=v_()-1;e<=0?document.body.removeAttribute(Bc):document.body.setAttribute(Bc,e.toString())}},[])},DK=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;AK();var i=g.useMemo(function(){return jK(o)},[o]);return g.createElement(RK,{styles:IK(i,!t,o,n?"":"!important")})},Ob=!1;if(typeof window<"u")try{var Gp=Object.defineProperty({},"passive",{get:function(){return Ob=!0,!0}});window.addEventListener("test",Gp,Gp),window.removeEventListener("test",Gp,Gp)}catch{Ob=!1}var ec=Ob?{passive:!1}:!1,LK=function(e){return e.tagName==="TEXTAREA"},JR=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!LK(e)&&n[t]==="visible")},FK=function(e){return JR(e,"overflowY")},zK=function(e){return JR(e,"overflowX")},y_=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=XR(e,r);if(o){var i=ZR(e,r),s=i[1],a=i[2];if(s>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},BK=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},$K=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},XR=function(e,t){return e==="v"?FK(t):zK(t)},ZR=function(e,t){return e==="v"?BK(t):$K(t)},VK=function(e,t){return e==="h"&&t==="rtl"?-1:1},UK=function(e,t,n,r,o){var i=VK(e,window.getComputedStyle(t).direction),s=i*r,a=n.target,l=t.contains(a),c=!1,u=s>0,d=0,h=0;do{var p=ZR(e,a),m=p[0],v=p[1],b=p[2],x=v-b-i*m;(m||x)&&XR(e,a)&&(d+=x,h+=m),a instanceof ShadowRoot?a=a.host:a=a.parentNode}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(Math.abs(d)<1||!o)||!u&&(Math.abs(h)<1||!o))&&(c=!0),c},qp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},x_=function(e){return[e.deltaX,e.deltaY]},b_=function(e){return e&&"current"in e?e.current:e},HK=function(e,t){return e[0]===t[0]&&e[1]===t[1]},WK=function(e){return`
423
423
  .block-interactivity-`.concat(e,` {pointer-events: none;}
424
424
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
425
- `)},KK=0,tc=[];function GK(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),o=g.useState(KK++)[0],i=g.useState(YR)[0],s=g.useRef(e);g.useEffect(function(){s.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=pK([e.lockRef.current],(e.shards||[]).map(b_),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!s.current.allowPinchZoom;var x=qp(v),w=n.current,S="deltaX"in v?v.deltaX:w[0]-x[0],C="deltaY"in v?v.deltaY:w[1]-x[1],_,P=v.target,O=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in v&&O==="h"&&P.type==="range")return!1;var j=y_(O,P);if(!j)return!0;if(j?_=O:(_=O==="v"?"h":"v",j=y_(O,P)),!j)return!1;if(!r.current&&"changedTouches"in v&&(S||C)&&(r.current=_),!_)return!0;var I=r.current||_;return UK(I,b,v,I==="h"?S:C,!0)},[]),l=g.useCallback(function(v){var b=v;if(!(!tc.length||tc[tc.length-1]!==i)){var x="deltaY"in b?x_(b):qp(b),w=t.current.filter(function(_){return _.name===b.type&&(_.target===b.target||b.target===_.shadowParent)&&HK(_.delta,x)})[0];if(w&&w.should){b.cancelable&&b.preventDefault();return}if(!w){var S=(s.current.shards||[]).map(b_).filter(Boolean).filter(function(_){return _.contains(b.target)}),C=S.length>0?a(b,S[0]):!s.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,x,w){var S={name:v,delta:b,target:x,should:w,shadowParent:qK(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),u=g.useCallback(function(v){n.current=qp(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,x_(v),v.target,a(v,e.lockRef.current))},[]),h=g.useCallback(function(v){c(v.type,qp(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return tc.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,ec),document.addEventListener("touchmove",l,ec),document.addEventListener("touchstart",u,ec),function(){tc=tc.filter(function(v){return v!==i}),document.removeEventListener("wheel",l,ec),document.removeEventListener("touchmove",l,ec),document.removeEventListener("touchstart",u,ec)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(i,{styles:WK(o)}):null,p?g.createElement(DK,{gapMode:e.gapMode}):null)}function qK(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const YK=kK(qR,GK);var np=g.forwardRef(function(e,t){return g.createElement(Jv,ri({},e,{ref:t,sideCar:YK}))});np.classNames=Jv.classNames;var PS="Popover",[QR,xme]=uo(PS,[bi]),rp=bi(),[JK,Ra]=QR(PS),eI=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=rp(t),l=g.useRef(null),[c,u]=g.useState(!1),[d=!1,h]=Fr({prop:r,defaultProp:o,onChange:i});return f.jsx(Hh,{...a,children:f.jsx(JK,{scope:t,contentId:Ir(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:g.useCallback(()=>u(!0),[]),onCustomAnchorRemove:g.useCallback(()=>u(!1),[]),modal:s,children:n})})};eI.displayName=PS;var tI="PopoverAnchor",XK=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ra(tI,n),i=rp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return g.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(Ru,{...i,...r,ref:t})});XK.displayName=tI;var nI="PopoverTrigger",rh=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ra(nI,n),i=rp(n),s=Be(t,o.triggerRef),a=f.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":aI(o.open),...r,ref:s,onClick:te(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(Ru,{asChild:!0,...i,children:a})});rh.displayName=nI;var NS="PopoverPortal",[ZK,QK]=QR(NS,{forceMount:void 0}),rI=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Ra(NS,t);return f.jsx(ZK,{scope:t,forceMount:n,children:f.jsx(an,{present:n||i.open,children:f.jsx(Iu,{asChild:!0,container:o,children:r})})})};rI.displayName=NS;var pu="PopoverContent",oI=g.forwardRef((e,t)=>{const n=QK(pu,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Ra(pu,e.__scopePopover);return f.jsx(an,{present:r||i.open,children:i.modal?f.jsx(eG,{...o,ref:t}):f.jsx(tG,{...o,ref:t})})});oI.displayName=pu;var eG=g.forwardRef((e,t)=>{const n=Ra(pu,e.__scopePopover),r=g.useRef(null),o=Be(t,r),i=g.useRef(!1);return g.useEffect(()=>{const s=r.current;if(s)return Yv(s)},[]),f.jsx(np,{as:Qi,allowPinchZoom:!0,children:f.jsx(iI,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:te(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:te(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),tG=g.forwardRef((e,t)=>{const n=Ra(pu,e.__scopePopover),r=g.useRef(!1),o=g.useRef(!1);return f.jsx(iI,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),iI=g.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=Ra(pu,n),p=rp(n);return qv(),f.jsx(tp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx($l,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(Wh,{"data-state":aI(h.open),role:"dialog",id:h.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)"}})})})}),sI="PopoverClose",Xv=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ra(sI,n);return f.jsx(_e.button,{type:"button",...r,ref:t,onClick:te(e.onClick,()=>o.onOpenChange(!1))})});Xv.displayName=sI;var nG="PopoverArrow",rG=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=rp(n);return f.jsx(Kh,{...o,...r,ref:t})});rG.displayName=nG;function aI(e){return e?"open":"closed"}var oG=eI,iG=rh,sG=rI,lI=oI;const ns=oG,Fu=iG,hi=g.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(sG,{container:r.container,children:f.jsx(lI,{ref:o,align:t,sideOffset:n,className:ze("z-50 w-72 rounded-md border bg-bg-secondary_alt p-4 text-text-secondary shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));hi.displayName=lI.displayName;function w_({profile:e,size:t="md"}){var c,u,d;const[n,r]=g.useState(((c=e==null?void 0:e.avatar)==null?void 0:c.url)||null);g.useEffect(()=>{var h,p;(h=e==null?void 0:e.avatar)!=null&&h.url?r((p=e==null?void 0:e.avatar)==null?void 0:p.url):r(null)},[(u=e==null?void 0:e.avatar)==null?void 0:u.url]);const[o,...i]=((d=e.fullName)==null?void 0:d.split(" "))||[""],s=i[i.length-1]||"",a=`${o[0].toUpperCase()}${s[0].toUpperCase()}`,l=ke("rounded-full text-center inline-block bg-bg-brand-primary text-text-brand-primary",{"h-8 w-8 leading-8 text-xs":t==="sm","h-10 w-10 leading-10 text-base":t==="md","h-12 w-12 leading-[3rem] text-lg":t==="lg"});return n?f.jsx("img",{src:n,alt:a,className:l,onError:()=>{r(null)}}):f.jsx("span",{className:l,children:a})}const cI=1280;function aG(){const e=Du(),[t,n]=g.useState(""),[r,o]=g.useState("");g.useEffect(()=>{async function x(){let w=!1;const S=async C=>{if(!w)try{(await fetch(C)).ok&&(w=!0,n(C))}catch{}};await S("/favicon.ico"),await S("/favicon.svg"),await S("/favicon.png"),await S("/apple-touch-icon.png"),await S("https://valbuild.com/favicon.ico")}if(x(),e!=null&&e.project)o(e.project);else try{let w=new URL(location.origin).hostname;if(w!=="localhost"){const S=w.split(".");S.length>=2&&(w=S.slice(1,-1).join(".")),o(cf(w))}else o("Dev mode")}catch{o("Studio")}},[JSON.stringify(e)]);const i=Xh(),s=Kr(),{theme:a,setTheme:l}=Uv(),{navMenu:c}=Fy(),u=(e==null?void 0:e.appHost)||ub,[d,h]=r.split("/"),p=XW(),m=`${u}/orgs/${d}`,v=`${u}/orgs/${d}/members`,b=`${m}/projects/${h}`;return f.jsxs("nav",{className:"relative min-h-[100svh] bg-bg-primary",children:[f.jsxs("div",{className:"flex items-center justify-between h-16 gap-4 p-4 pr-6 border-b border-border-primary",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[t?f.jsx("img",{src:t,alt:"",className:"w-4 h-4"}):f.jsx("div",{className:"w-4 h-4"}),d&&h?f.jsx("a",{className:"truncate hover:underline",href:b,children:r}):f.jsx("span",{className:"truncate",children:r})]}),f.jsx("button",{className:"lg:hidden",onClick:()=>{c.setOpen(!c.isOpen)},children:f.jsx(kg,{size:16,className:ke("transform",{"rotate-180":!c.isOpen})})})]}),"data"in i&&f.jsx("div",{className:ke("py-4 pl-2",{}),children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-32px-64px-32px-16px)]",children:f.jsx(cG,{})})})}),f.jsx("div",{className:"h-6 p-4"}),f.jsx("div",{className:"absolute bottom-0 left-0 w-full",children:f.jsxs(ns,{children:[f.jsxs(rh,{className:"flex items-center justify-between w-full p-4 border-t border-border-primary hover:bg-bg-secondary data-[state=open]:bg-bg-secondary",children:[f.jsx("span",{children:p&&f.jsx(w_,{size:"sm",profile:p})}),f.jsx(bR,{size:16})]}),f.jsx(hi,{className:"p-0 py-2",container:s,side:"top",children:f.jsxs("div",{className:"flex flex-col items-center justify-between gap-2",children:[p&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center w-full gap-2 px-4 py-2",children:[f.jsx(w_,{size:"sm",profile:p}),f.jsxs("div",{className:"text-sm",children:[f.jsx("div",{className:"truncate",children:p.fullName}),p.email&&f.jsx("div",{className:"font-light truncate",children:p.email})]})]}),f.jsx("hr",{className:"w-full h-1 mb-1 border-t border-border-primary"})]}),f.jsxs("div",{className:"flex items-center w-full gap-2 px-4",children:[a==="dark"?f.jsx(E7,{size:"1rem"}):f.jsx(I7,{size:"1rem"}),f.jsx("button",{className:"",onClick:()=>{l(a==="dark"?"light":"dark")},children:a==="dark"?f.jsx("span",{className:"text-sm",children:"Dark mode"}):f.jsx("span",{className:"text-sm",children:"Light mode"})})]}),p&&f.jsxs("div",{className:"flex items-center w-full gap-2 px-4",children:[f.jsx(V7,{size:"1rem"}),f.jsx("a",{href:v,children:f.jsx("span",{className:"text-sm truncate",children:"Manage members"})})]}),p&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{className:"w-full h-1 mt-1 mb-1 border-t border-border-primary"}),f.jsxs("div",{className:"flex items-center w-full gap-2 px-4",children:[f.jsx(S7,{size:"1rem"}),f.jsx("a",{href:Qf("/api/val/logout",{redirect_to:`${window.location.origin}`}),children:f.jsx("span",{className:"text-sm",children:"Log out"})})]})]})]})})]})})]})}function lG(){const e=Xh();return g.useMemo(()=>{if(e.status==="success"){const t=Object.keys(e.data);return{status:e.status,data:U7(t)}}return e},[e])}function cG({title:e}){const t=lG();if(t.status==="error")return console.error(t.error),null;if(t.status!=="success")return f.jsx(uG,{});const n=t.data;return f.jsxs("div",{className:"pl-0 pr-4",children:[e&&f.jsx("div",{className:"py-2",children:e}),f.jsx("div",{children:n.children.sort(uI).map((r,o)=>g.createElement(dI,{...r,name:r.name,key:o}))})]})}function uG(){return null}function uI(e,t){return e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)}function dI({name:e,fullPath:t,isDirectory:n,children:r}){const{navigate:o,currentSourcePath:i}=Vn(),{navMenu:s}=Fy(),[a,l]=g.useState(!0),c=ja()||{},u=g.useMemo(()=>{let v=!1;for(const b in c)if(b.startsWith(t)){v=!0;break}return v},[c,t]),d=g.useMemo(()=>{if(n){if(!a)return u}else if(!n)return u;return!1},[u,a,n]),h=t,p=It(h),m="data"in p?p.data.type:"loading";return f.jsxs("div",{className:"w-full text-sm",children:[f.jsxs("button",{className:ke("relative flex justify-between w-full p-2",{underline:i.startsWith(h)&&!n,"font-bold":i.startsWith(h)&&n}),onClick:()=>{n?l(!a):(window.innerWidth<cI&&s.setOpen(!1),o(h))},children:[f.jsxs("div",{className:"flex items-center pr-2",children:[n?f.jsx(Wv,{size:16,className:ke("transform mr-2",{"rotate-90":a,hidden:!r.length})}):f.jsx(dG,{type:m,size:14}),f.jsx("span",{children:fu(e)})]}),d&&f.jsx("div",{className:"w-2 h-2 ml-2 rounded-full bg-bg-error-primary"})]}),f.jsx("div",{className:"pl-2",children:f.jsx(nh,{isOpen:a,children:r.sort(uI).map((v,b)=>g.createElement(dI,{...v,key:b}))})})]})}function dG({size:e,type:t}){if(t==="loading")return f.jsx(Uo,{size:e,className:"mr-2 animate-spin"});switch(t){case"string":return f.jsx(z7,{size:e,className:"mr-2"});case"number":return f.jsx(m7,{size:e,className:"mr-2"});case"boolean":return f.jsx(D7,{size:e,className:"mr-2"});case"object":return f.jsx(y7,{size:e,className:"mr-2"});case"literal":return f.jsx(d7,{size:e,className:"mr-2"});case"array":return f.jsx(ER,{size:e,className:"mr-2"});case"union":return f.jsx(N7,{size:e,className:"mr-2"});case"richtext":return f.jsx(h7,{size:e,className:"mr-2"});case"record":return f.jsx(A7,{size:e,className:"mr-2"});case"keyOf":return f.jsx(v7,{size:e,className:"mr-2"});case"file":return f.jsx(SR,{size:e,className:"mr-2"});case"date":return f.jsx(xR,{size:e,className:"mr-2"});case"image":return f.jsx(kR,{size:e,className:"mr-2"});default:return f.jsx(c7,{size:e,className:"mr-2"})}}function OS(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var MS="Checkbox",[fG,bme]=uo(MS),[hG,pG]=fG(MS),fI=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=g.useState(null),m=Be(t,C=>p(C)),v=g.useRef(!1),b=h?u||!!h.closest("form"):!0,[x=!1,w]=Fr({prop:o,defaultProp:i,onChange:c}),S=g.useRef(x);return g.useEffect(()=>{const C=h==null?void 0:h.form;if(C){const _=()=>w(S.current);return C.addEventListener("reset",_),()=>C.removeEventListener("reset",_)}},[h,w]),f.jsxs(hG,{scope:n,state:x,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"checkbox","aria-checked":ia(x)?"mixed":x,"aria-required":s,"data-state":mI(x),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:m,onKeyDown:te(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:te(e.onClick,C=>{w(_=>ia(_)?!0:!_),b&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),b&&f.jsx(mG,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ia(i)?!1:i})]})});fI.displayName=MS;var hI="CheckboxIndicator",pI=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=pG(hI,n);return f.jsx(an,{present:r||ia(i.state)||i.state===!0,children:f.jsx(_e.span,{"data-state":mI(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});pI.displayName=hI;var mG=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=g.useRef(null),a=OS(n),l=aS(t);g.useEffect(()=>{const u=s.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=ia(n),p.call(u,ia(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=g.useRef(ia(n)?!1:n);return f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ia(e){return e==="indeterminate"}function mI(e){return ia(e)?"indeterminate":e?"checked":"unchecked"}var gI=fI,gG=pI;const zu=g.forwardRef(({className:e,...t},n)=>{const[r,o]=g.useState();return g.useEffect(()=>{o(t.checked)},[t.checked]),f.jsx(gI,{ref:n,checked:r,onCheckedChange:i=>{o(i),t.onCheckedChange&&t.onCheckedChange(i)},className:ze("peer h-4 w-4 shrink-0 rounded-sm bg-bg-primary border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 data-[state=checked]:bg-bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:f.jsxs(gG,{className:ze("flex items-center justify-center text-current"),children:[r===!0&&f.jsx(Zh,{size:12}),r==="indeterminate"&&f.jsx(k7,{size:12})]})})});zu.displayName=gI.displayName;function zx(e,t){const n=new Date(t).getTime(),r=e.getTime(),o=Math.floor((r-n)/1e3),i=Math.floor(o/60),s=Math.floor(o/3600),a=Math.floor(o/86400),l=Math.floor(a/30);return o<60?"just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a===1?"yesterday":a<30?`${a}d ago`:`${l}mo ago`}const S_=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,k_=iR,vG=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return k_(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(c=>{const u=n==null?void 0:n[c],d=i==null?void 0:i[c];if(u===null)return null;const h=S_(u)||S_(d);return o[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,h]=u;return h===void 0||(c[d]=h),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:h,...p}=u;return Object.entries(p).every(m=>{let[v,b]=m;return Array.isArray(b)?b.includes({...i,...a}[v]):{...i,...a}[v]===b})?[...c,d,h]:c},[]);return k_(e,s,l,n==null?void 0:n.class,n==null?void 0:n.className)},Mb=vG("inline-flex items-center justify-center whitespace-nowrap rounded-md text-fg-primary text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:text-text-disabled disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-bg-brand-primary text-fg-primary hover:bg-bg-secondary_hover/90 disabled:bg-bg-primary disabled:text-text-disabled disabled:border disabled:border-border-primary",destructive:"bg-bg-error text-text-error-pimary hover:bg-bg-error_hover/90",outline:"border border-input bg-bg-background hover:bg-bg-brand-solid_hover hover:text-secondary_hover",secondary:"bg-bg-secondary text-fg-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-bg-secondary_hover hover:text-fg-secondary",link:"text-fg-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Lt=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const s=r?Qi:"button";return f.jsx(s,{className:ze(Mb({variant:t,size:n,className:e})),ref:i,...o})});Lt.displayName="Button";var Bx,jS="HoverCard",[vI,wme]=uo(jS,[bi]),Zv=bi(),[yG,RS]=vI(jS),yI=e=>{const{__scopeHoverCard:t,children:n,open:r,defaultOpen:o,onOpenChange:i,openDelay:s=700,closeDelay:a=300}=e,l=Zv(t),c=g.useRef(0),u=g.useRef(0),d=g.useRef(!1),h=g.useRef(!1),[p=!1,m]=Fr({prop:r,defaultProp:o,onChange:i}),v=g.useCallback(()=>{clearTimeout(u.current),c.current=window.setTimeout(()=>m(!0),s)},[s,m]),b=g.useCallback(()=>{clearTimeout(c.current),!d.current&&!h.current&&(u.current=window.setTimeout(()=>m(!1),a))},[a,m]),x=g.useCallback(()=>m(!1),[m]);return g.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(u.current)},[]),f.jsx(yG,{scope:t,open:p,onOpenChange:m,onOpen:v,onClose:b,onDismiss:x,hasSelectionRef:d,isPointerDownOnContentRef:h,children:f.jsx(Hh,{...l,children:n})})};yI.displayName=jS;var xI="HoverCardTrigger",IS=g.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=RS(xI,n),i=Zv(n);return f.jsx(Ru,{asChild:!0,...i,children:f.jsx(_e.a,{"data-state":o.open?"open":"closed",...r,ref:t,onPointerEnter:te(e.onPointerEnter,Tg(o.onOpen)),onPointerLeave:te(e.onPointerLeave,Tg(o.onClose)),onFocus:te(e.onFocus,o.onOpen),onBlur:te(e.onBlur,o.onClose),onTouchStart:te(e.onTouchStart,s=>s.preventDefault())})})});IS.displayName=xI;var xG="HoverCardPortal",[Sme,bG]=vI(xG,{forceMount:void 0}),_g="HoverCardContent",AS=g.forwardRef((e,t)=>{const n=bG(_g,e.__scopeHoverCard),{forceMount:r=n.forceMount,...o}=e,i=RS(_g,e.__scopeHoverCard);return f.jsx(an,{present:r||i.open,children:f.jsx(wG,{"data-state":i.open?"open":"closed",...o,onPointerEnter:te(e.onPointerEnter,Tg(i.onOpen)),onPointerLeave:te(e.onPointerLeave,Tg(i.onClose)),ref:t})})});AS.displayName=_g;var wG=g.forwardRef((e,t)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,...a}=e,l=RS(_g,n),c=Zv(n),u=g.useRef(null),d=Be(t,u),[h,p]=g.useState(!1);return g.useEffect(()=>{if(h){const m=document.body;return Bx=m.style.userSelect||m.style.webkitUserSelect,m.style.userSelect="none",m.style.webkitUserSelect="none",()=>{m.style.userSelect=Bx,m.style.webkitUserSelect=Bx}}},[h]),g.useEffect(()=>{if(u.current){const m=()=>{p(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var b;((b=document.getSelection())==null?void 0:b.toString())!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",m),()=>{document.removeEventListener("pointerup",m),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),g.useEffect(()=>{u.current&&EG(u.current).forEach(v=>v.setAttribute("tabindex","-1"))}),f.jsx($l,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:s,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:te(i,m=>{m.preventDefault()}),onDismiss:l.onDismiss,children:f.jsx(Wh,{...c,...a,onPointerDown:te(a.onPointerDown,m=>{m.currentTarget.contains(m.target)&&p(!0),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!0}),ref:d,style:{...a.style,userSelect:h?"text":void 0,WebkitUserSelect:h?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),SG="HoverCardArrow",kG=g.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=Zv(n);return f.jsx(Kh,{...o,...r,ref:t})});kG.displayName=SG;function Tg(e){return t=>t.pointerType==="touch"?void 0:e()}function EG(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)t.push(n.currentNode);return t}var CG=yI,_G=IS,bI=AS;const al=CG,$c=_G,ll=g.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(bI,{ref:o,align:t,sideOffset:n,className:ze("z-50 w-64 text-xs rounded-md border bg-bg-secondary p-4 text-text-secondary shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));ll.displayName=bI.displayName;function wI({onPublish:e,onClose:t}){const[n,r]=g.useState(null),o=qh(),{summary:i,canGenerate:s,setSummary:a,publishDisabled:l,generateSummary:c}=Yh(),[u,d]=g.useState(!1),h=()=>{d(!1),i.type!=="not-asked"&&a({...i})};g.useEffect(()=>{i.type!=="not-asked"&&!i.isGenerating&&!lu(i.patchIds,o)&&d(!0)},[i,o]);const p=g.useCallback(()=>{h(),c().then(b=>{b.type==="ai"?a({type:"ai",text:b.text.trim()}):r(b.message)})},[h,c,a,r]),m="w-full p-2 border rounded bg-bg-secondary",v="text"in i?i.text:"";return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("div",{className:"flex items-center justify-between w-full gap-2",children:[f.jsx("span",{className:"font-semibold",children:"Summary"}),s&&f.jsx(E_,{onClick:p,isGenerating:i.isGenerating})]}),n&&f.jsx("div",{className:"p-4 rounded bg-bg-error-primary text-text-error-primary",children:n}),f.jsxs("div",{className:"grid text-xs font-light",children:[f.jsx("div",{"aria-hidden":!0,className:ze(m,"invisible whitespace-pre-wrap"),style:{gridArea:"1 / 1 / 2 / 2"},children:v+" "}),f.jsx("textarea",{disabled:!!i.isGenerating,className:ze(m,"resize-none overflow-clip disabled:opacity-50"),value:v,style:{gridArea:"1 / 1 / 2 / 2"},placeholder:"Write a summary of your changes"+(s?" or generate one using AI":""),onChange:b=>{h(),a({type:"manual",text:b.currentTarget.value})}})]}),f.jsxs("div",{className:ze("p-2 text-xs flex-grow font-light bg-bg-warning-primary text-[black] rounded flex items-center","flex justify-between w-full gap-2 py-2",{hidden:!u}),"aria-hidden":u,children:[f.jsx("span",{children:"Summary might be outdated. "}),f.jsx("button",{className:"underline",onClick:h,children:"Dismiss"})]}),f.jsx("div",{className:"flex items-center justify-end gap-2",children:e?f.jsxs(f.Fragment,{children:[f.jsx(Lt,{variant:"outline",onClick:()=>{t()},children:"Close"}),u&&s&&f.jsx(E_,{isGenerating:i.isGenerating,onClick:p}),!u&&f.jsxs(Lt,{disabled:l||v.trim()==="",onClick:()=>{i.type!=="not-asked"&&e()},variant:"default",className:"flex items-center gap-2",children:[f.jsxs("span",{children:[" ",l?"Pushing...":"Publish"]}),f.jsx(kS,{size:16})]})]}):f.jsx(f.Fragment,{children:f.jsx(Lt,{variant:"outline",onClick:()=>{t()},children:"Close"})})})]})}function E_({isGenerating:e,onClick:t}){return f.jsx(Lt,{className:"truncate",disabled:!!e,onClick:()=>{t()},variant:"outline",children:f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx("span",{children:e?"Generating...":"Generate"}),f.jsx(_R,{size:16})]})})}function TG(e,t=[]){let n=[];function r(i,s){const a=g.createContext(s),l=n.length;n=[...n,s];function c(d){const{scope:h,children:p,...m}=d,v=(h==null?void 0:h[e][l])||a,b=g.useMemo(()=>m,Object.values(m));return f.jsx(v.Provider,{value:b,children:p})}function u(d,h){const p=(h==null?void 0:h[e][l])||a,m=g.useContext(p);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>g.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,PG(o,...t)]}function PG(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Qv(e){const t=e+"CollectionProvider",[n,r]=TG(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:m,children:v}=p,b=Se.useRef(null),x=Se.useRef(new Map).current;return f.jsx(o,{scope:m,itemMap:x,collectionRef:b,children:v})};s.displayName=t;const a=e+"CollectionSlot",l=Se.forwardRef((p,m)=>{const{scope:v,children:b}=p,x=i(a,v),w=Be(m,x.collectionRef);return f.jsx(Qi,{ref:w,children:b})});l.displayName=a;const c=e+"CollectionItemSlot",u="data-radix-collection-item",d=Se.forwardRef((p,m)=>{const{scope:v,children:b,...x}=p,w=Se.useRef(null),S=Be(m,w),C=i(c,v);return Se.useEffect(()=>(C.itemMap.set(w,{ref:w,...x}),()=>void C.itemMap.delete(w))),f.jsx(Qi,{[u]:"",ref:S,children:b})});d.displayName=c;function h(p){const m=i(e+"CollectionConsumer",p);return Se.useCallback(()=>{const b=m.collectionRef.current;if(!b)return[];const x=Array.from(b.querySelectorAll(`[${u}]`));return Array.from(m.itemMap.values()).sort((C,_)=>x.indexOf(C.ref.current)-x.indexOf(_.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},h,r]}var DS="Collapsible",[NG,SI]=uo(DS),[OG,LS]=NG(DS),kI=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:s,...a}=e,[l=!1,c]=Fr({prop:r,defaultProp:o,onChange:s});return f.jsx(OG,{scope:n,disabled:i,contentId:Ir(),open:l,onOpenToggle:g.useCallback(()=>c(u=>!u),[c]),children:f.jsx(_e.div,{"data-state":zS(l),"data-disabled":i?"":void 0,...a,ref:t})})});kI.displayName=DS;var EI="CollapsibleTrigger",CI=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=LS(EI,n);return f.jsx(_e.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":zS(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:te(e.onClick,o.onOpenToggle)})});CI.displayName=EI;var FS="CollapsibleContent",_I=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=LS(FS,e.__scopeCollapsible);return f.jsx(an,{present:n||o.open,children:({present:i})=>f.jsx(MG,{...r,ref:t,present:i})})});_I.displayName=FS;var MG=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,s=LS(FS,n),[a,l]=g.useState(r),c=g.useRef(null),u=Be(t,c),d=g.useRef(0),h=d.current,p=g.useRef(0),m=p.current,v=s.open||a,b=g.useRef(v),x=g.useRef();return g.useEffect(()=>{const w=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(w)},[]),_n(()=>{const w=c.current;if(w){x.current=x.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();d.current=S.height,p.current=S.width,b.current||(w.style.transitionDuration=x.current.transitionDuration,w.style.animationName=x.current.animationName),l(r)}},[s.open,r]),f.jsx(_e.div,{"data-state":zS(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!v,...i,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:v&&o})});function zS(e){return e?"open":"closed"}var jG=kI,RG=CI,IG=_I,ls="Accordion",AG=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[BS,DG,LG]=Qv(ls),[ey,kme]=uo(ls,[LG,SI]),$S=SI(),VS=Se.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,i=r;return f.jsx(BS.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?f.jsx($G,{...i,ref:t}):f.jsx(BG,{...o,ref:t})})});VS.displayName=ls;var[TI,FG]=ey(ls),[PI,zG]=ey(ls,{collapsible:!1}),BG=Se.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:i=!1,...s}=e,[a,l]=Fr({prop:n,defaultProp:r,onChange:o});return f.jsx(TI,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:Se.useCallback(()=>i&&l(""),[i,l]),children:f.jsx(PI,{scope:e.__scopeAccordion,collapsible:i,children:f.jsx(NI,{...s,ref:t})})})}),$G=Se.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...i}=e,[s=[],a]=Fr({prop:n,defaultProp:r,onChange:o}),l=Se.useCallback(u=>a((d=[])=>[...d,u]),[a]),c=Se.useCallback(u=>a((d=[])=>d.filter(h=>h!==u)),[a]);return f.jsx(TI,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c,children:f.jsx(PI,{scope:e.__scopeAccordion,collapsible:!0,children:f.jsx(NI,{...i,ref:t})})})}),[VG,ty]=ey(ls),NI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:i="vertical",...s}=e,a=Se.useRef(null),l=Be(a,t),c=DG(n),d=ep(o)==="ltr",h=te(e.onKeyDown,p=>{var j;if(!AG.includes(p.key))return;const m=p.target,v=c().filter(I=>{var F;return!((F=I.ref.current)!=null&&F.disabled)}),b=v.findIndex(I=>I.ref.current===m),x=v.length;if(b===-1)return;p.preventDefault();let w=b;const S=0,C=x-1,_=()=>{w=b+1,w>C&&(w=S)},P=()=>{w=b-1,w<S&&(w=C)};switch(p.key){case"Home":w=S;break;case"End":w=C;break;case"ArrowRight":i==="horizontal"&&(d?_():P());break;case"ArrowDown":i==="vertical"&&_();break;case"ArrowLeft":i==="horizontal"&&(d?P():_());break;case"ArrowUp":i==="vertical"&&P();break}const O=w%x;(j=v[O].ref.current)==null||j.focus()});return f.jsx(VG,{scope:n,disabled:r,direction:o,orientation:i,children:f.jsx(BS.Slot,{scope:n,children:f.jsx(_e.div,{...s,"data-orientation":i,ref:l,onKeyDown:r?void 0:h})})})}),Pg="AccordionItem",[UG,US]=ey(Pg),OI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,i=ty(Pg,n),s=FG(Pg,n),a=$S(n),l=Ir(),c=r&&s.value.includes(r)||!1,u=i.disabled||e.disabled;return f.jsx(UG,{scope:n,open:c,disabled:u,triggerId:l,children:f.jsx(jG,{"data-orientation":i.orientation,"data-state":DI(c),...a,...o,ref:t,disabled:u,open:c,onOpenChange:d=>{d?s.onItemOpen(r):s.onItemClose(r)}})})});OI.displayName=Pg;var MI="AccordionHeader",jI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ty(ls,n),i=US(MI,n);return f.jsx(_e.h3,{"data-orientation":o.orientation,"data-state":DI(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});jI.displayName=MI;var jb="AccordionTrigger",RI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ty(ls,n),i=US(jb,n),s=zG(jb,n),a=$S(n);return f.jsx(BS.ItemSlot,{scope:n,children:f.jsx(RG,{"aria-disabled":i.open&&!s.collapsible||void 0,"data-orientation":o.orientation,id:i.triggerId,...a,...r,ref:t})})});RI.displayName=jb;var II="AccordionContent",AI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ty(ls,n),i=US(II,n),s=$S(n);return f.jsx(IG,{role:"region","aria-labelledby":i.triggerId,"data-orientation":o.orientation,...s,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});AI.displayName=II;function DI(e){return e?"open":"closed"}var HG=VS,WG=OI,KG=jI,LI=RI,FI=AI;const oh=HG,Cl=g.forwardRef(({className:e,...t},n)=>f.jsx(WG,{ref:n,className:ze("border-b",e),...t}));Cl.displayName="AccordionItem";const _l=g.forwardRef(({className:e,children:t,...n},r)=>f.jsx(KG,{className:"flex",children:f.jsxs(LI,{ref:r,className:ze("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,f.jsx(Qh,{className:"w-4 h-4 transition-transform duration-200 shrink-0"})]})}));_l.displayName=LI.displayName;const Tl=g.forwardRef(({className:e,children:t,...n},r)=>f.jsx(FI,{ref:r,className:ze("overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",e),...n,children:f.jsx("div",{className:"pt-0 pb-4",children:t})}));Tl.displayName=FI.displayName;function zI(e,t,n){if(e.length===0)return{success:!1,error:"Empty path"};let r=-1,o="";const i=c=>{o===""?o=c:o+="."+c};let s=t,a=n;const l=[{modulePath:o,schema:s,source:a}];for(const c of e){if(r++,c==="")return{success:!1,error:`Empty path part in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(s.type==="array"){s=s.item;const u=Number(c);if(!Number.isSafeInteger(u))return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an integer but got '${c}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(typeof a!="object")return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===null)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'null' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===void 0)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'undefined' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!Array.isArray(a))return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an array but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!a[u])return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an index less than ${a.length} but got '${u}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};a=a[u],i(c)}else if(s.type==="record"){s=s.item;const u=Yp(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="object"){s=s.items[c];const u=Yp(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="union"){const u=typeof s.key=="object"&&s.key.type==="literal"?s:void 0,d=typeof s.key=="string"?s:void 0;if(u)return{success:!1,error:"Invalid lookup in string union"};if(d){const h=Yp(e,c,r,a,"union object");if(!h.success)return{success:!1,error:h.error};const p=h.source;let m;for(const v of d.items){const b=v.items[d.key];if(b.type==="literal"){if(p[d.key]===b.value){m=v;break}}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}if(!m)return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};s=m.items[c],a=p[c],i(JSON.stringify(c))}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}else if(s.type==="image"||s.type==="file"){const u=Yp(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else return{success:!1,error:`Cannot construct sub-path in schema of '${s.type}' in: '${e.join("/")}'. Path was: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")}`};l.push({modulePath:o,schema:s,source:a})}return{success:!0,modulePath:o,schema:s,source:a,allResolved:l}}function Yp(e,t,n,r,o){return typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===null?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'null' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===void 0?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'undefined' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:Array.isArray(r)?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'array' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:t in r?{success:!0,source:r}:{success:!1,error:`Could not find key of source: '${e.join("/")}'. Expected a key in ${Object.keys(r).join(", ")} but got '${t}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}}function GG(e,t){return(t==null?void 0:t.type)==="array"?e.type!=="string":(t==null?void 0:t.type)==="record"}function BI(e,t,n){if(!n)return null;const[r,o]=ee.splitModuleFilePathAndModulePath(e);if(!o)return r;const i=t[r],s=n[r];if(!i||!s)return null;const a=zI(ee.splitModulePath(o),s,i);if(a.success){for(let l=a.allResolved.length-1;l>=0;l--){const c=a.allResolved[l],u=a.allResolved[l-1];if(GG(c.schema,(u==null?void 0:u.schema)||null))return c.modulePath===""?r:ee.joinModuleFilePathAndModulePath(r,c.modulePath)}return r}else console.error(`Error resolving path: ${a.error} for path: ${e}`);return null}function ny({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:o=!0}){const i=Du(),s=g.useRef(null),a=g.useRef(new Map),[l,c]=g.useState([]),[u,d]=g.useState(),h=wS(),p=Xh(),{navigate:m}=Vn();g.useEffect(()=>{const b=e?ee.splitModuleFilePath(e):[],x=t,w=()=>{if(!s.current)return;const C=s.current,_=getComputedStyle(C),P=`${_.fontSize} ${_.fontFamily}`,O=C.offsetWidth,j=b.map(qG).concat(x).map(W=>`/${W}`);d(j.join(""));const I=W=>{const B=`${W}:${P}`,A=a.current.get(B)??YG(W,P);return a.current.set(B,A),A},F="/…",H=I(F),$=[];let J=0;for(let W=j.length-1;W>=0;W--){const B=I(j[W]),R=!(W===0);if(J+B+(R?H:0)<=O){const N=W>b.length?"module-path":"module-file-path";$.unshift({text:j[W],type:N,moduleFilePath:e,modulePathSegments:x.slice(0,W)}),J+=B}else{$.unshift({type:"ellipsis",text:F});break}}c($)},S=new ResizeObserver(w);return s.current&&(S.observe(s.current),w()),()=>{s.current&&S.unobserve(s.current)}},[e,t]);const v=g.useMemo(()=>{if(!o)return null;const b="data"in p?p.data:{},x=zI(t,b[e],h[e]);if(x.success){const w=ee.joinModuleFilePathAndModulePath(e,x.modulePath),S=BI(w,h,b);if(S)return{navPath:S,scrollToId:w};console.debug(`Failed to resolve nav path for ${e} and ${t.join(".")}: ${S}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(".")}: ${x.error}`);return null},[e,t,h,p]);return f.jsxs(dR,{open:r===!1?!1:void 0,children:[f.jsx(fS,{asChild:!0,children:f.jsx("a",{href:v&&i?`${i.studioPrefix}${v.navPath}#${v.scrollToId}`:void 0,ref:s,className:ke("inline-block whitespace-nowrap overflow-hidden w-full align-baseline",{"cursor-pointer hover:underline":o},n),onClick:b=>{o&&v&&b.metaKey===!1&&b.ctrlKey===!1&&b.shiftKey===!1&&(b.preventDefault(),m(v.navPath,{scrollToId:v.scrollToId}))},children:l.map((b,x)=>f.jsx("span",{children:b.text},x))})}),f.jsx(mS,{side:"top",children:f.jsx(oi,{orientation:"horizontal",className:"max-w-[calc(100vw-3rem)] whitespace-nowrap",children:u})})]})}function qG(e){const t=fu(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function YG(e,t){const r=document.createElement("canvas").getContext("2d");return r?(r.font=t,r.measureText(e).width):0}function $I({className:e,loadingStatus:t}){const n=qh(),r=Lu(),o=KW(),i=WW(),s=Kr(),[a,l]=g.useState(!1),{canGenerate:c}=Yh(),u=ja(),{autoPublish:d}=yS(),h=g.useMemo(()=>{var w;let x=0;for(const S in u)x+=((w=u[S])==null?void 0:w.length)||0;return x},[u]),p=n.length-o.size,m=Vn(),{deployments:v,dismissDeployment:b}=HW();return f.jsxs("div",{className:ke("text-sm",e),children:[u&&h>0&&f.jsx("div",{className:"sticky top-0 text-white border-b border-border-primary bg-bg-error-primary z-5",children:f.jsx(oi,{orientation:"horizontal",children:f.jsx(oh,{type:"single",className:"px-4 font-serif",collapsible:!0,children:f.jsxs(Cl,{value:"error",className:"border-b-0 data-[state=open]:mb-4",children:[f.jsxs(_l,{children:[h," validation error",h>1?"s":""]}),f.jsx(Tl,{className:"w-full",children:f.jsx("div",{className:"flex flex-col gap-2",children:f.jsx(oh,{type:"multiple",className:"w-full",children:Object.entries(u).map(([x,w],S)=>f.jsxs(Cl,{value:x+"#"+S,children:[f.jsx(_l,{children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"underline cursor-pointer",onClick:()=>{m.navigate(x)},children:x}),f.jsxs("span",{className:"pl-4",children:["(",(w==null?void 0:w.length)||0,")"]})]})}),f.jsx(Tl,{children:f.jsx("div",{className:"flex flex-col gap-2",children:w==null?void 0:w.map((C,_)=>f.jsxs("div",{children:[f.jsx("div",{children:C.message}),f.jsxs("div",{className:"pl-4 font-thin",children:["at",f.jsx("span",{className:"underline cursor-pointer",onClick:()=>{m.navigate(x)},children:x})]})]},_))})})]},x+"#"+S))})})})]})})})}),v.length>0&&f.jsx("div",{className:"p-4 border-b border-border-primary",children:f.jsx(JG,{deployments:v,onDismiss:b})}),f.jsx("div",{className:"p-4 z-5",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"font-bold",children:[p<=0?"No ":`${p} `,"pending change",p===1?"":"s"]}),(t==="loading"||t==="not-asked")&&f.jsx("div",{className:"",children:f.jsx(Uo,{size:16,className:"animate-spin"})})]}),r==="http"&&f.jsxs(ns,{open:a,onOpenChange:x=>{l(x)},children:[f.jsx(Fu,{asChild:!0,children:f.jsxs(Lt,{variant:"outline",className:"flex items-center gap-2 text-sm",children:[f.jsx("span",{children:"Summary"}),c&&f.jsx(_R,{size:14})]})}),f.jsxs(hi,{container:s,align:"end",className:"z-[9001] flex flex-col gap-4",children:[f.jsx(Xv,{asChild:!0,className:"self-end cursor-pointer",children:f.jsx(du,{size:12})}),f.jsx(wI,{onClose:()=>{l(!1)}})]})]})]})}),(!d||h>0)&&f.jsx("div",{className:"flex flex-col gap-[2px]",children:"data"in i&&n.length>0&&i.data.map(x=>f.jsx(eq,{committedPatchIds:o,patchSet:x},x.moduleFilePath+":"+x.patchPath.join("/")))})]})}function JG({deployments:e,onDismiss:t}){return f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between p-2 font-bold",children:[f.jsx("span",{children:"Deployments"}),f.jsx(Uo,{size:16,className:"inline animate-spin"})]}),f.jsx("div",{children:e.reverse().map(n=>f.jsx(XG,{deployment:n,onDismiss:()=>{t(n.commitSha)}},n.commitSha))})]})}function XG({deployment:e}){var o;const t=bS(),n=Kr(),r=e.creator&&t[e.creator];return f.jsxs("div",{className:"flex items-start justify-between p-2",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[r&&f.jsx("img",{src:(o=r.avatar)==null?void 0:o.url,alt:r.fullName,className:"w-8 h-8 rounded-full"}),f.jsxs(dR,{children:[f.jsx(Qj,{container:n}),f.jsx($W,{children:f.jsx("div",{className:"max-w-[180px] overflow-clip font-light truncate",children:e.commitMessage})}),f.jsx(mS,{className:"max-w-[320px]",children:f.jsx("pre",{className:"font-sans font-light whitespace-break-spaces",children:e.commitMessage})})]})]}),f.jsx(ZG,{since:new Date(e.createdAt)})]})}function ZG({since:e}){const[t,n]=g.useState("00"),[r,o]=g.useState("00");return g.useEffect(()=>{let i;const s=()=>{const a=Date.now(),l=Math.floor((a-e.getTime())/1e3),c=Math.floor(l/60),u=l%60;let d;c>4?(d=(60-u)*1e3,n(c.toString()),o(null)):(d=1e3,n(c.toString().padStart(2,"0")),o(u.toString().padStart(2,"0"))),i=setTimeout(s,d)};return s(),()=>{clearTimeout(i)}},[e]),f.jsxs("div",{className:"text-xs font-light text-text-quartenary",children:[t,r!==null?`:${r}`:" mins"]})}function QG({moduleFilePath:e,patchMetadata:t,committedPatchIds:n}){var d;const r=VI([t.opType],t.createdAt,n.has(t.patchId)),o=bS(),{patchErrors:i,skippedPatches:s}=xS(),[a,l]=g.useMemo(()=>[i[t.patchId]||[],!!s[t.patchId]],[t.patchId,i[t.patchId],s[t.patchId]]),c=Lu();let u=[];if(t.author){const h=o[t.author];if(h){const p=((d=h==null?void 0:h.avatar)==null?void 0:d.url)??null;u=[{fullName:h.fullName,url:p}]}else console.warn("Did not find profile for author: ",t.author,{profilesById:o})}return u.length===0&&c==="http"&&console.warn("No authors",{patchMetadata:t}),f.jsx(Rb,{moduleFilePath:e,patchPath:t.patchPath,changeDescription:l?"Skipped":r,authors:u,errors:a,skipped:l,isApplied:n.has(t.patchId)})}function VI(e,t,n){const[r,o]=g.useState(new Date);if(g.useEffect(()=>{const a=setInterval(()=>{o(new Date)},6e4);return()=>{clearInterval(a)}},[]),n)return"Pushed "+zx(r,t);if(e.length>1)return"Updated "+zx(r,t);const i=e[0];let s=i;return i==="add"?s="Added":i==="remove"?s="Removed":i==="replace"?s="Replaced":i==="move"?s="Moved":i==="copy"?s="Copied":i==="test"?s="Tested":i==="file"?s="Updated":console.warn("Unexpected op type: ",i),s+" "+zx(r,t)}function eq({patchSet:e,committedPatchIds:t}){const[n,r]=g.useState(!1),o=g.useRef(null),[i,s]=g.useState(!1);g.useEffect(()=>{const v=new IntersectionObserver(b=>{b[0].isIntersecting&&s(!0)},{threshold:0});return o.current&&v.observe(o.current),()=>{v.disconnect()}},[]);const{patchErrors:a,skippedPatches:l}=xS(),{deletePatches:c}=UW(),u=g.useMemo(()=>e.patches.map(v=>v.patchId),[e.patches.map(v=>v.patchId).join(",")]),d=g.useMemo(()=>{const v=[];for(const b of u)for(const x of a[b]||[])l[b]||v.unshift(x);return v},[u,a,l]),h=VI(e.opTypes,e.lastUpdated,!1),p=bS(),m=e.patches.every(v=>t.has(v.patchId));return i?f.jsxs(f.Fragment,{children:[f.jsx(Rb,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,isApplied:m,authors:e.authors.reduce((v,b)=>v.includes(b)?v:v.concat(b),[]).flatMap(v=>{var x;const b=p[v];if(b){const w=((x=b==null?void 0:b.avatar)==null?void 0:x.url)??null;return[{fullName:b.fullName,url:w}]}return[]}),changeDescription:h,isOpen:n,setOpen:r,errors:d,onDelete:()=>{c(u.filter(v=>!t.has(v)))},amount:new Set(u).size}),f.jsx(nh,{isOpen:n,children:e.patches.map((v,b)=>f.jsx(QG,{committedPatchIds:t,moduleFilePath:e.moduleFilePath,patchMetadata:v},e.moduleFilePath+":"+e.patchPath.join("/")+v.patchId+b))})]}):f.jsx(Rb,{ref:o,isApplied:m})}const Rb=g.forwardRef(({moduleFilePath:e,patchPath:t,changeDescription:n,authors:r,isOpen:o,setOpen:i,isSelected:s,setSelected:a,errors:l,skipped:c,onDelete:u,amount:d,isApplied:h},p)=>f.jsxs("div",{ref:p,className:ke("p-6",{"bg-bg-secondary":!o,"bg-bg-quartenary":o,"opacity-50":h}),children:[f.jsxs("div",{className:"relative",children:[f.jsx("span",{className:"inline-block w-[calc(320px-24px-8px-16px-24px-48px)] truncate mr-2 ",children:e&&t&&f.jsx(ny,{moduleFilePath:e,patchPath:t,link:!0,toolTip:!0})}),s===void 0&&f.jsx("span",{className:ke("inline-block w-6 h-6 rounded",{"bg-bg-disabled animate-pulse":t===void 0})}),s!==void 0&&!h&&f.jsx(zu,{checked:s,onCheckedChange:m=>{a&&a(m)}}),u&&!h&&f.jsxs("button",{onClick:u,title:"Revert change",className:"relative ml-5",children:[d&&f.jsx("span",{className:"absolute px-2 text-xs rounded-full -top-6 -right-5 bg-bg-quartenary",children:d>10?"10+":d}),f.jsx(B7,{size:16,className:"inline"})]})]}),l&&l.length>0&&!c&&f.jsxs("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-text-primary",children:[l.slice(0,1).map((m,v)=>f.jsx("div",{title:m,className:"truncate",children:m},v)),l.length>1&&f.jsxs("div",{className:"truncate",children:["+",l.length-1," more"]})]}),(!l||l.length===0)&&c&&f.jsx("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-text-primary",children:f.jsx("div",{className:"truncate",children:"Skipped"})}),f.jsxs("div",{className:"flex items-center justify-between pt-2",children:[f.jsxs("span",{className:"flex flex-shrink-0 gap-2",children:[r!==void 0&&r.length>0&&f.jsxs("span",{className:"flex gap-1 mr-2",children:[r.slice(0,2).map((m,v)=>{if(m.url)return f.jsxs(al,{children:[f.jsx($c,{className:"flex-shrink-0 w-6 h-6 ",children:f.jsx("img",{src:m.url,alt:m.fullName,className:ke("rounded-full",{"-ml-3":r.length>2&&v>0})})}),f.jsx(ll,{children:f.jsx("div",{children:m.fullName})})]},m.url);const b=tq(m.fullName);return f.jsxs(al,{children:[f.jsx($c,{className:ke({"-ml-3":r.length>2&&v>0}),children:f.jsx("span",{className:ke("flex items-center justify-center w-6 h-6 text-xs font-semibold rounded-full bg-bg-quartenary text-fg-primary"),"aria-label":"Initials for: "+m.fullName,children:b})}),f.jsx(ll,{children:f.jsx("div",{children:m.fullName})})]},m.fullName+m.url)}),r.length>2&&f.jsxs(al,{children:[f.jsx($c,{className:ke({"-ml-3":r.length>2}),children:f.jsxs("span",{className:"flex items-center justify-center w-6 h-6 -ml-3 text-xs font-semibold rounded-full bg-bg-quartenary text-fg-primary",children:["+",r.length-2]})}),f.jsx(ll,{className:"grid grid-cols-[auto,1fr] gap-2",children:r.slice(2).map(m=>f.jsxs(g.Fragment,{children:[m.url?f.jsx("img",{src:m.url,alt:m.fullName,title:m.fullName,className:ke("w-6 h-6 rounded-full")},m.url):f.jsx("div",{}),f.jsx("div",{children:m.fullName})]},m.fullName+m.url))})]})]}),r===void 0&&f.jsx("span",{className:ke("inline-block w-6 h-6 mr-2",{"bg-bg-disabled animate-pulse rounded-3xl":r===void 0})}),n&&f.jsx("span",{className:ke({"text-text-disabled":c}),children:n})]}),o!==void 0&&f.jsx("button",{className:"flex-shrink-0 inline-block",onClick:()=>{i&&i(!o)},children:f.jsx(Qh,{size:16,className:ke("transform",{"rotate-180":o})})})]})]}));function tq(e){return!e||typeof e!="string"?"":e.trim().normalize("NFC").split(/\s+/).filter(r=>r.length>0).map(r=>/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(r)?r[0]:r[0].toLocaleUpperCase()).join("")}function Ib(){const[e,t]=g.useState(!1),{publish:n,publishDisabled:r,isPublishing:o,summary:i}=Yh(),s=ja(),a=s!==void 0&&Object.keys(s).length>0,l=pR(),c=mR(),u=Lu(),d=Kr(),{autoPublish:h}=yS();return u==="fs"?f.jsxs(Lt,{className:"flex items-center gap-2",disabled:r||a||h||l.length===0||c.length>0,title:a?"Please fix validation errors":"",onClick:()=>{n("No summary provided")},children:[a?f.jsx("span",{children:"Save"}):f.jsx("span",{children:o?"Saving":"Save"}),o&&f.jsx(Uo,{className:"animate-spin",size:16})]}):f.jsx("span",{children:f.jsxs(ns,{open:e,onOpenChange:p=>{t(p)},children:[f.jsx(Fu,{asChild:!0,children:f.jsxs(Lt,{className:"flex items-center gap-2",disabled:r||a||l.length===0||c.length>0,title:a?"Please fix validation errors":"",onClick:()=>{t(!0)},children:[!o&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"Ready"}),f.jsx(kS,{size:16})]}),o&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"Pushing"}),f.jsx(Uo,{className:"animate-spin",size:16})]})]})}),f.jsxs(hi,{container:d,align:"end",className:"z-[9001] flex flex-col gap-4",children:[f.jsx(Xv,{asChild:!0,className:"self-end cursor-pointer",children:f.jsx(du,{size:12})}),f.jsx(wI,{onClose:()=>{t(!1)},onPublish:()=>{if(t(!1),i.type==="not-asked")return;const p=i.text.trim();n(p)}})]})]})})}function nq(){const e=Hv(),{isPublishing:t}=Yh(),n=ja()||{},{globalErrors:r}=xS(),o=Lu(),[i,s]=g.useMemo(()=>{const a=new Set;let l=0;for(const c in n){const[u]=ee.splitModuleFilePathAndModulePath(c);a.add(u),l+=1}return[Array.from(a).sort(),l]},[n]);return f.jsxs("div",{className:"min-h-[100svh] bg-bg-primary",style:{"--menu-width":"320px"},children:[f.jsx("div",{className:"h-16 border-b border-border-primary",children:f.jsx(iq,{})}),t&&f.jsxs("div",{className:"flex items-center justify-end gap-2 p-4 text-right border-t bg-bg-tertiary text-text-primary border-border-primary",children:[f.jsx("span",{children:"Publishing changes "}),f.jsx(Uo,{size:16,className:"animate-spin"})]}),f.jsx(oi,{children:f.jsxs("div",{className:"max-h-[calc(100svh-64px)]",children:[r&&r.length>0&&r.length!==s&&f.jsx(oh,{type:"single",collapsible:!0,children:f.jsxs(Cl,{value:"global-errors",children:[f.jsxs(_l,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-text-error-primary",children:["Cannot ",o==="fs"?"save":"publish"," now. Found"," ",r==null?void 0:r.length," errors in all."," ",r.length-s," were non-validation errors. A developer might need to fix these issues."]}),f.jsx(Tl,{children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-128px)] max-w-[var(--menu-width)]",children:r==null?void 0:r.map((a,l)=>f.jsx(oq,{error:a},l))})})})]})}),(r==null?void 0:r.length)===s&&i.length>0&&f.jsx(oh,{type:"single",collapsible:!0,children:f.jsxs(Cl,{value:"global-errors",children:[f.jsx(_l,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-text-error-primary",children:f.jsxs("div",{children:[f.jsxs("div",{children:["Cannot ",o==="fs"?"save":"publish"," now."]}),f.jsx("div",{children:"Found errors in modules"})]})}),f.jsx(Tl,{children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-64px)] max-w-[var(--menu-width)]",children:i==null?void 0:i.map((a,l)=>f.jsx(rq,{moduleFilePath:a},l))})})})]})}),e!=="not-asked"&&f.jsx("div",{className:ke("",{}),children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-64px)] border-b border-border-primary",children:f.jsx($I,{loadingStatus:e})})})})]})})]})}function rq({moduleFilePath:e}){const t=ee.splitModuleFilePath(e),n=Vn();return f.jsx("div",{className:"px-4 py-2 border-b bg-bg-error-primary text-text-error-primary border-border-error",children:f.jsx("button",{className:"underline cursor-pointer",onClick:()=>{n.navigate(e)},children:t.map((r,o)=>f.jsxs(g.Fragment,{children:[f.jsx("span",{className:ze("text-text-brand-secondary",{"ml-1":o>0}),children:"/"}),f.jsx("span",{children:fu(r)})]},o))})})}function oq({error:e}){const[t,n]=g.useState(!1);return f.jsx("div",{className:ze("px-1 py-2 bg-bg-error-primary text-text-error-primary border-b border-border-error",{truncate:!t,"whitespace-normal":t}),onClick:()=>n(!t),children:e})}function iq(){const{navMenu:e,toolsMenu:t}=Fy(),n=Lu(),{setAutoPublish:r,autoPublish:o}=yS();return f.jsx("div",{className:"flex flex-col",children:f.jsxs("div",{className:"flex items-center justify-between w-full gap-2 p-4",children:[f.jsx("button",{className:"lg:hidden",onClick:()=>{t.setOpen(!t.isOpen)},children:f.jsx(kg,{size:16,className:ke("transform",{"rotate-180":!e.isOpen})})}),f.jsxs("div",{className:"flex items-center justify-end w-full gap-2",children:[n==="fs"&&f.jsxs("div",{className:"overflow-hidden flex items-center gap-2 text-[10px] lg:text-xs",children:[f.jsx("span",{className:"truncate text-text-secondary",children:"Auto-save"}),f.jsx(zu,{checked:o,onCheckedChange:r})]}),f.jsxs(Lt,{className:"flex items-center gap-2",variant:"outline",onClick:()=>{window.location.href=Qf("/api/val/enable",{redirect_to:window.origin})},children:[f.jsx("span",{children:"Preview"}),f.jsx(wR,{size:16})]}),f.jsx(Ib,{})]})]})})}function qt({error:e,path:t}){return f.jsx("div",{id:t,children:f.jsx("div",{className:"p-4 bg-bg-error-primary text-text-error-primary",children:e})})}function gt({path:e,type:t}){return f.jsx("div",{id:e,className:ke("pt-6",{"w-full flex items-center justify-center":t==="module","text-left":t!=="module"}),children:f.jsx(Uo,{size:t==="module"?24:16,className:"animate-spin"})})}function Tn({path:e,type:t}){const[n,r]=g.useState(!1);return g.useEffect(()=>{const o=setTimeout(()=>{r(!0)},2e3);return()=>{clearTimeout(o)}},[]),e.length===0?null:n?f.jsx("div",{className:"pt-6",id:e,children:f.jsx("div",{children:"Could not get data"})}):f.jsx(gt,{path:e,type:t})}function vr({actualType:e,expectedType:t,path:n}){return f.jsx("div",{id:n,children:f.jsxs("div",{children:["Schema mismatch: actual: ",e," vs expected: ",t," "]})})}function nt({error:e,path:t}){return f.jsx("div",{id:t,children:f.jsxs("div",{className:"p-4 rounded bg-bg-error-primary text-text-primary",children:["Source error: ",e]})})}function sq(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const ry=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Bu(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function HS(e){return"nodeType"in e}function yr(e){var t,n;return e?Bu(e)?e:HS(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function WS(e){const{Document:t}=yr(e);return e instanceof t}function op(e){return Bu(e)?!1:e instanceof yr(e).HTMLElement}function UI(e){return e instanceof yr(e).SVGElement}function $u(e){return e?Bu(e)?e.document:HS(e)?WS(e)?e:op(e)||UI(e)?e.ownerDocument:document:document:document}const pi=ry?g.useLayoutEffect:g.useEffect;function KS(e){const t=g.useRef(e);return pi(()=>{t.current=e}),g.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function aq(){const e=g.useRef(null),t=g.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=g.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ih(e,t){t===void 0&&(t=[e]);const n=g.useRef(e);return pi(()=>{n.current!==e&&(n.current=e)},t),n}function ip(e,t){const n=g.useRef();return g.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ng(e){const t=KS(e),n=g.useRef(null),r=g.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function Ab(e){const t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}let $x={};function sp(e,t){return g.useMemo(()=>{if(t)return t;const n=$x[e]==null?0:$x[e]+1;return $x[e]=n,e+"-"+n},[e,t])}function HI(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+e*c)}return i},{...t})}}const Vc=HI(1),sh=HI(-1);function lq(e){return"clientX"in e&&"clientY"in e}function GS(e){if(!e)return!1;const{KeyboardEvent:t}=yr(e.target);return t&&e instanceof t}function cq(e){if(!e)return!1;const{TouchEvent:t}=yr(e.target);return t&&e instanceof t}function Db(e){if(cq(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return lq(e)?{x:e.clientX,y:e.clientY}:null}const ah=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ah.Translate.toString(e),ah.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),C_="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function uq(e){return e.matches(C_)?e:e.querySelector(C_)}const dq={display:"none"};function fq(e){let{id:t,value:n}=e;return Se.createElement("div",{id:t,style:dq},n)}function hq(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Se.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function pq(){const[e,t]=g.useState("");return{announce:g.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const WI=g.createContext(null);function mq(e){const t=g.useContext(WI);g.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function gq(){const[e]=g.useState(()=>new Set),t=g.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[g.useCallback(r=>{let{type:o,event:i}=r;e.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[e]),t]}const vq={draggable:`
425
+ `)},KK=0,tc=[];function GK(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),o=g.useState(KK++)[0],i=g.useState(YR)[0],s=g.useRef(e);g.useEffect(function(){s.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=pK([e.lockRef.current],(e.shards||[]).map(b_),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!s.current.allowPinchZoom;var x=qp(v),w=n.current,S="deltaX"in v?v.deltaX:w[0]-x[0],C="deltaY"in v?v.deltaY:w[1]-x[1],_,P=v.target,O=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in v&&O==="h"&&P.type==="range")return!1;var j=y_(O,P);if(!j)return!0;if(j?_=O:(_=O==="v"?"h":"v",j=y_(O,P)),!j)return!1;if(!r.current&&"changedTouches"in v&&(S||C)&&(r.current=_),!_)return!0;var I=r.current||_;return UK(I,b,v,I==="h"?S:C,!0)},[]),l=g.useCallback(function(v){var b=v;if(!(!tc.length||tc[tc.length-1]!==i)){var x="deltaY"in b?x_(b):qp(b),w=t.current.filter(function(_){return _.name===b.type&&(_.target===b.target||b.target===_.shadowParent)&&HK(_.delta,x)})[0];if(w&&w.should){b.cancelable&&b.preventDefault();return}if(!w){var S=(s.current.shards||[]).map(b_).filter(Boolean).filter(function(_){return _.contains(b.target)}),C=S.length>0?a(b,S[0]):!s.current.noIsolation;C&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,x,w){var S={name:v,delta:b,target:x,should:w,shadowParent:qK(x)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),u=g.useCallback(function(v){n.current=qp(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,x_(v),v.target,a(v,e.lockRef.current))},[]),h=g.useCallback(function(v){c(v.type,qp(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return tc.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,ec),document.addEventListener("touchmove",l,ec),document.addEventListener("touchstart",u,ec),function(){tc=tc.filter(function(v){return v!==i}),document.removeEventListener("wheel",l,ec),document.removeEventListener("touchmove",l,ec),document.removeEventListener("touchstart",u,ec)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(i,{styles:WK(o)}):null,p?g.createElement(DK,{gapMode:e.gapMode}):null)}function qK(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const YK=kK(qR,GK);var np=g.forwardRef(function(e,t){return g.createElement(Jv,ri({},e,{ref:t,sideCar:YK}))});np.classNames=Jv.classNames;var PS="Popover",[QR,xme]=uo(PS,[bi]),rp=bi(),[JK,Ra]=QR(PS),eI=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=rp(t),l=g.useRef(null),[c,u]=g.useState(!1),[d=!1,h]=Fr({prop:r,defaultProp:o,onChange:i});return f.jsx(Hh,{...a,children:f.jsx(JK,{scope:t,contentId:Ir(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:g.useCallback(()=>u(!0),[]),onCustomAnchorRemove:g.useCallback(()=>u(!1),[]),modal:s,children:n})})};eI.displayName=PS;var tI="PopoverAnchor",XK=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ra(tI,n),i=rp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return g.useEffect(()=>(s(),()=>a()),[s,a]),f.jsx(Ru,{...i,...r,ref:t})});XK.displayName=tI;var nI="PopoverTrigger",rh=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ra(nI,n),i=rp(n),s=Be(t,o.triggerRef),a=f.jsx(_e.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":aI(o.open),...r,ref:s,onClick:te(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:f.jsx(Ru,{asChild:!0,...i,children:a})});rh.displayName=nI;var NS="PopoverPortal",[ZK,QK]=QR(NS,{forceMount:void 0}),rI=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Ra(NS,t);return f.jsx(ZK,{scope:t,forceMount:n,children:f.jsx(an,{present:n||i.open,children:f.jsx(Iu,{asChild:!0,container:o,children:r})})})};rI.displayName=NS;var pu="PopoverContent",oI=g.forwardRef((e,t)=>{const n=QK(pu,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Ra(pu,e.__scopePopover);return f.jsx(an,{present:r||i.open,children:i.modal?f.jsx(eG,{...o,ref:t}):f.jsx(tG,{...o,ref:t})})});oI.displayName=pu;var eG=g.forwardRef((e,t)=>{const n=Ra(pu,e.__scopePopover),r=g.useRef(null),o=Be(t,r),i=g.useRef(!1);return g.useEffect(()=>{const s=r.current;if(s)return Yv(s)},[]),f.jsx(np,{as:Qi,allowPinchZoom:!0,children:f.jsx(iI,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:te(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:te(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),tG=g.forwardRef((e,t)=>{const n=Ra(pu,e.__scopePopover),r=g.useRef(!1),o=g.useRef(!1);return f.jsx(iI,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),iI=g.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=e,h=Ra(pu,n),p=rp(n);return qv(),f.jsx(tp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:f.jsx($l,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:f.jsx(Wh,{"data-state":aI(h.open),role:"dialog",id:h.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)"}})})})}),sI="PopoverClose",Xv=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ra(sI,n);return f.jsx(_e.button,{type:"button",...r,ref:t,onClick:te(e.onClick,()=>o.onOpenChange(!1))})});Xv.displayName=sI;var nG="PopoverArrow",rG=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=rp(n);return f.jsx(Kh,{...o,...r,ref:t})});rG.displayName=nG;function aI(e){return e?"open":"closed"}var oG=eI,iG=rh,sG=rI,lI=oI;const ns=oG,Fu=iG,hi=g.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(sG,{container:r.container,children:f.jsx(lI,{ref:o,align:t,sideOffset:n,className:ze("z-50 w-72 rounded-md border bg-bg-secondary_alt p-4 text-text-secondary shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));hi.displayName=lI.displayName;function w_({profile:e,size:t="md"}){var c,u,d;const[n,r]=g.useState(((c=e==null?void 0:e.avatar)==null?void 0:c.url)||null);g.useEffect(()=>{var h,p;(h=e==null?void 0:e.avatar)!=null&&h.url?r((p=e==null?void 0:e.avatar)==null?void 0:p.url):r(null)},[(u=e==null?void 0:e.avatar)==null?void 0:u.url]);const[o,...i]=((d=e.fullName)==null?void 0:d.split(" "))||[""],s=i[i.length-1]||"",a=`${o[0].toUpperCase()}${s[0].toUpperCase()}`,l=ke("rounded-full text-center inline-block bg-bg-brand-primary text-text-brand-primary",{"h-8 w-8 leading-8 text-xs":t==="sm","h-10 w-10 leading-10 text-base":t==="md","h-12 w-12 leading-[3rem] text-lg":t==="lg"});return n?f.jsx("img",{src:n,alt:a,className:l,onError:()=>{r(null)}}):f.jsx("span",{className:l,children:a})}const cI=1280;function aG(){const e=Du(),[t,n]=g.useState(""),[r,o]=g.useState("");g.useEffect(()=>{async function x(){let w=!1;const S=async C=>{if(!w)try{(await fetch(C)).ok&&(w=!0,n(C))}catch{}};await S("/favicon.ico"),await S("/favicon.svg"),await S("/favicon.png"),await S("/apple-touch-icon.png"),await S("https://valbuild.com/favicon.ico")}if(x(),e!=null&&e.project)o(e.project);else try{let w=new URL(location.origin).hostname;if(w!=="localhost"){const S=w.split(".");S.length>=2&&(w=S.slice(1,-1).join(".")),o(cf(w))}else o("Dev mode")}catch{o("Studio")}},[JSON.stringify(e)]);const i=Xh(),s=Kr(),{theme:a,setTheme:l}=Uv(),{navMenu:c}=Fy(),u=(e==null?void 0:e.appHost)||ub,[d,h]=r.split("/"),p=XW(),m=`${u}/orgs/${d}`,v=`${u}/orgs/${d}/members`,b=`${m}/projects/${h}`;return f.jsxs("nav",{className:"relative min-h-[100svh] bg-bg-primary",children:[f.jsxs("div",{className:"flex items-center justify-between h-16 gap-4 p-4 pr-6 border-b border-border-primary",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[t?f.jsx("img",{src:t,alt:"",className:"w-4 h-4"}):f.jsx("div",{className:"w-4 h-4"}),d&&h?f.jsx("a",{className:"truncate hover:underline",href:b,children:r}):f.jsx("span",{className:"truncate",children:r})]}),f.jsx("button",{className:"lg:hidden",onClick:()=>{c.setOpen(!c.isOpen)},children:f.jsx(kg,{size:16,className:ke("transform",{"rotate-180":!c.isOpen})})})]}),"data"in i&&f.jsx("div",{className:ke("py-4 pl-2",{}),children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-32px-64px-32px-16px)]",children:f.jsx(cG,{})})})}),f.jsx("div",{className:"h-6 p-4"}),f.jsx("div",{className:"absolute bottom-0 left-0 w-full",children:f.jsxs(ns,{children:[f.jsxs(rh,{className:"flex items-center justify-between w-full p-4 border-t border-border-primary hover:bg-bg-secondary data-[state=open]:bg-bg-secondary",children:[f.jsx("span",{children:p&&f.jsx(w_,{size:"sm",profile:p})}),f.jsx(bR,{size:16})]}),f.jsx(hi,{className:"p-0 py-2",container:s,side:"top",children:f.jsxs("div",{className:"flex flex-col items-center justify-between gap-2",children:[p&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center w-full gap-2 px-4 py-2",children:[f.jsx(w_,{size:"sm",profile:p}),f.jsxs("div",{className:"text-sm",children:[f.jsx("div",{className:"truncate",children:p.fullName}),p.email&&f.jsx("div",{className:"font-light truncate",children:p.email})]})]}),f.jsx("hr",{className:"w-full h-1 mb-1 border-t border-border-primary"})]}),f.jsxs("div",{className:"flex items-center w-full gap-2 px-4",children:[a==="dark"?f.jsx(E7,{size:"1rem"}):f.jsx(I7,{size:"1rem"}),f.jsx("button",{className:"",onClick:()=>{l(a==="dark"?"light":"dark")},children:a==="dark"?f.jsx("span",{className:"text-sm",children:"Dark mode"}):f.jsx("span",{className:"text-sm",children:"Light mode"})})]}),p&&f.jsxs("div",{className:"flex items-center w-full gap-2 px-4",children:[f.jsx(V7,{size:"1rem"}),f.jsx("a",{href:v,children:f.jsx("span",{className:"text-sm truncate",children:"Manage members"})})]}),p&&f.jsxs(f.Fragment,{children:[f.jsx("hr",{className:"w-full h-1 mt-1 mb-1 border-t border-border-primary"}),f.jsxs("div",{className:"flex items-center w-full gap-2 px-4",children:[f.jsx(S7,{size:"1rem"}),f.jsx("a",{href:Qf("/api/val/logout",{redirect_to:`${window.location.origin}`}),children:f.jsx("span",{className:"text-sm",children:"Log out"})})]})]})]})})]})})]})}function lG(){const e=Xh();return g.useMemo(()=>{if(e.status==="success"){const t=Object.keys(e.data);return{status:e.status,data:U7(t)}}return e},[e])}function cG({title:e}){const t=lG();if(t.status==="error")return console.error(t.error),null;if(t.status!=="success")return f.jsx(uG,{});const n=t.data;return f.jsxs("div",{className:"pl-0 pr-4",children:[e&&f.jsx("div",{className:"py-2",children:e}),f.jsx("div",{children:n.children.sort(uI).map((r,o)=>g.createElement(dI,{...r,name:r.name,key:o}))})]})}function uG(){return null}function uI(e,t){return e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)}function dI({name:e,fullPath:t,isDirectory:n,children:r}){const{navigate:o,currentSourcePath:i}=Vn(),{navMenu:s}=Fy(),[a,l]=g.useState(!0),c=ja()||{},u=g.useMemo(()=>{let v=!1;for(const b in c)if(b.startsWith(t)){v=!0;break}return v},[c,t]),d=g.useMemo(()=>{if(n){if(!a)return u}else if(!n)return u;return!1},[u,a,n]),h=t,p=It(h),m="data"in p?p.data.type:"loading";return f.jsxs("div",{className:"w-full text-sm",children:[f.jsxs("button",{className:ke("relative flex justify-between w-full p-2",{underline:i.startsWith(h)&&!n,"font-bold":i.startsWith(h)&&n}),onClick:()=>{n?l(!a):(window.innerWidth<cI&&s.setOpen(!1),o(h))},children:[f.jsxs("div",{className:"flex items-center pr-2",children:[n?f.jsx(Wv,{size:16,className:ke("transform mr-2",{"rotate-90":a,hidden:!r.length})}):f.jsx(dG,{type:m,size:14}),f.jsx("span",{children:fu(e)})]}),d&&f.jsx("div",{className:"w-2 h-2 ml-2 rounded-full bg-bg-error-primary"})]}),f.jsx("div",{className:"pl-2",children:f.jsx(nh,{isOpen:a,children:r.sort(uI).map((v,b)=>g.createElement(dI,{...v,key:b}))})})]})}function dG({size:e,type:t}){if(t==="loading")return f.jsx(Uo,{size:e,className:"mr-2 animate-spin"});switch(t){case"string":return f.jsx(z7,{size:e,className:"mr-2"});case"number":return f.jsx(m7,{size:e,className:"mr-2"});case"boolean":return f.jsx(D7,{size:e,className:"mr-2"});case"object":return f.jsx(y7,{size:e,className:"mr-2"});case"literal":return f.jsx(d7,{size:e,className:"mr-2"});case"array":return f.jsx(ER,{size:e,className:"mr-2"});case"union":return f.jsx(N7,{size:e,className:"mr-2"});case"richtext":return f.jsx(h7,{size:e,className:"mr-2"});case"record":return f.jsx(A7,{size:e,className:"mr-2"});case"keyOf":return f.jsx(v7,{size:e,className:"mr-2"});case"file":return f.jsx(SR,{size:e,className:"mr-2"});case"date":return f.jsx(xR,{size:e,className:"mr-2"});case"image":return f.jsx(kR,{size:e,className:"mr-2"});default:return f.jsx(c7,{size:e,className:"mr-2"})}}function OS(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var MS="Checkbox",[fG,bme]=uo(MS),[hG,pG]=fG(MS),fI=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=e,[h,p]=g.useState(null),m=Be(t,C=>p(C)),v=g.useRef(!1),b=h?u||!!h.closest("form"):!0,[x=!1,w]=Fr({prop:o,defaultProp:i,onChange:c}),S=g.useRef(x);return g.useEffect(()=>{const C=h==null?void 0:h.form;if(C){const _=()=>w(S.current);return C.addEventListener("reset",_),()=>C.removeEventListener("reset",_)}},[h,w]),f.jsxs(hG,{scope:n,state:x,disabled:a,children:[f.jsx(_e.button,{type:"button",role:"checkbox","aria-checked":ia(x)?"mixed":x,"aria-required":s,"data-state":mI(x),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:m,onKeyDown:te(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:te(e.onClick,C=>{w(_=>ia(_)?!0:!_),b&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),b&&f.jsx(mG,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ia(i)?!1:i})]})});fI.displayName=MS;var hI="CheckboxIndicator",pI=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=pG(hI,n);return f.jsx(an,{present:r||ia(i.state)||i.state===!0,children:f.jsx(_e.span,{"data-state":mI(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});pI.displayName=hI;var mG=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=g.useRef(null),a=OS(n),l=aS(t);g.useEffect(()=>{const u=s.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=ia(n),p.call(u,ia(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=g.useRef(ia(n)?!1:n);return f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ia(e){return e==="indeterminate"}function mI(e){return ia(e)?"indeterminate":e?"checked":"unchecked"}var gI=fI,gG=pI;const zu=g.forwardRef(({className:e,...t},n)=>{const[r,o]=g.useState();return g.useEffect(()=>{o(t.checked)},[t.checked]),f.jsx(gI,{ref:n,checked:r,onCheckedChange:i=>{o(i),t.onCheckedChange&&t.onCheckedChange(i)},className:ze("peer h-4 w-4 shrink-0 rounded-sm bg-bg-primary border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 data-[state=checked]:bg-bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:f.jsxs(gG,{className:ze("flex items-center justify-center text-current"),children:[r===!0&&f.jsx(Zh,{size:12}),r==="indeterminate"&&f.jsx(k7,{size:12})]})})});zu.displayName=gI.displayName;function zx(e,t){const n=new Date(t).getTime(),r=e.getTime(),o=Math.floor((r-n)/1e3),i=Math.floor(o/60),s=Math.floor(o/3600),a=Math.floor(o/86400),l=Math.floor(a/30);return o<60?"just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a===1?"yesterday":a<30?`${a}d ago`:`${l}mo ago`}const S_=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,k_=iR,vG=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return k_(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(c=>{const u=n==null?void 0:n[c],d=i==null?void 0:i[c];if(u===null)return null;const h=S_(u)||S_(d);return o[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,h]=u;return h===void 0||(c[d]=h),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:h,...p}=u;return Object.entries(p).every(m=>{let[v,b]=m;return Array.isArray(b)?b.includes({...i,...a}[v]):{...i,...a}[v]===b})?[...c,d,h]:c},[]);return k_(e,s,l,n==null?void 0:n.class,n==null?void 0:n.className)},Mb=vG("inline-flex items-center justify-center whitespace-nowrap rounded-md text-fg-primary text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:text-text-disabled disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-bg-brand-primary text-fg-primary hover:bg-bg-secondary_hover/90 disabled:bg-bg-primary disabled:text-text-disabled disabled:border disabled:border-border-primary",destructive:"bg-bg-error text-text-error-pimary hover:bg-bg-error_hover/90",outline:"border border-input bg-bg-background hover:bg-bg-brand-solid_hover hover:text-secondary_hover",secondary:"bg-bg-secondary text-fg-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-bg-secondary_hover hover:text-fg-secondary",link:"text-fg-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Lt=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const s=r?Qi:"button";return f.jsx(s,{className:ze(Mb({variant:t,size:n,className:e})),ref:i,...o})});Lt.displayName="Button";var Bx,jS="HoverCard",[vI,wme]=uo(jS,[bi]),Zv=bi(),[yG,RS]=vI(jS),yI=e=>{const{__scopeHoverCard:t,children:n,open:r,defaultOpen:o,onOpenChange:i,openDelay:s=700,closeDelay:a=300}=e,l=Zv(t),c=g.useRef(0),u=g.useRef(0),d=g.useRef(!1),h=g.useRef(!1),[p=!1,m]=Fr({prop:r,defaultProp:o,onChange:i}),v=g.useCallback(()=>{clearTimeout(u.current),c.current=window.setTimeout(()=>m(!0),s)},[s,m]),b=g.useCallback(()=>{clearTimeout(c.current),!d.current&&!h.current&&(u.current=window.setTimeout(()=>m(!1),a))},[a,m]),x=g.useCallback(()=>m(!1),[m]);return g.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(u.current)},[]),f.jsx(yG,{scope:t,open:p,onOpenChange:m,onOpen:v,onClose:b,onDismiss:x,hasSelectionRef:d,isPointerDownOnContentRef:h,children:f.jsx(Hh,{...l,children:n})})};yI.displayName=jS;var xI="HoverCardTrigger",IS=g.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=RS(xI,n),i=Zv(n);return f.jsx(Ru,{asChild:!0,...i,children:f.jsx(_e.a,{"data-state":o.open?"open":"closed",...r,ref:t,onPointerEnter:te(e.onPointerEnter,Tg(o.onOpen)),onPointerLeave:te(e.onPointerLeave,Tg(o.onClose)),onFocus:te(e.onFocus,o.onOpen),onBlur:te(e.onBlur,o.onClose),onTouchStart:te(e.onTouchStart,s=>s.preventDefault())})})});IS.displayName=xI;var xG="HoverCardPortal",[Sme,bG]=vI(xG,{forceMount:void 0}),_g="HoverCardContent",AS=g.forwardRef((e,t)=>{const n=bG(_g,e.__scopeHoverCard),{forceMount:r=n.forceMount,...o}=e,i=RS(_g,e.__scopeHoverCard);return f.jsx(an,{present:r||i.open,children:f.jsx(wG,{"data-state":i.open?"open":"closed",...o,onPointerEnter:te(e.onPointerEnter,Tg(i.onOpen)),onPointerLeave:te(e.onPointerLeave,Tg(i.onClose)),ref:t})})});AS.displayName=_g;var wG=g.forwardRef((e,t)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,...a}=e,l=RS(_g,n),c=Zv(n),u=g.useRef(null),d=Be(t,u),[h,p]=g.useState(!1);return g.useEffect(()=>{if(h){const m=document.body;return Bx=m.style.userSelect||m.style.webkitUserSelect,m.style.userSelect="none",m.style.webkitUserSelect="none",()=>{m.style.userSelect=Bx,m.style.webkitUserSelect=Bx}}},[h]),g.useEffect(()=>{if(u.current){const m=()=>{p(!1),l.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var b;((b=document.getSelection())==null?void 0:b.toString())!==""&&(l.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",m),()=>{document.removeEventListener("pointerup",m),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!1}}},[l.isPointerDownOnContentRef,l.hasSelectionRef]),g.useEffect(()=>{u.current&&EG(u.current).forEach(v=>v.setAttribute("tabindex","-1"))}),f.jsx($l,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:s,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:te(i,m=>{m.preventDefault()}),onDismiss:l.onDismiss,children:f.jsx(Wh,{...c,...a,onPointerDown:te(a.onPointerDown,m=>{m.currentTarget.contains(m.target)&&p(!0),l.hasSelectionRef.current=!1,l.isPointerDownOnContentRef.current=!0}),ref:d,style:{...a.style,userSelect:h?"text":void 0,WebkitUserSelect:h?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),SG="HoverCardArrow",kG=g.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,o=Zv(n);return f.jsx(Kh,{...o,...r,ref:t})});kG.displayName=SG;function Tg(e){return t=>t.pointerType==="touch"?void 0:e()}function EG(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)t.push(n.currentNode);return t}var CG=yI,_G=IS,bI=AS;const al=CG,$c=_G,ll=g.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>f.jsx(bI,{ref:o,align:t,sideOffset:n,className:ze("z-50 w-64 text-xs rounded-md border bg-bg-secondary p-4 text-text-secondary shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));ll.displayName=bI.displayName;function wI({onPublish:e,onClose:t}){const[n,r]=g.useState(null),o=qh(),{summary:i,canGenerate:s,setSummary:a,publishDisabled:l,generateSummary:c}=Yh(),[u,d]=g.useState(!1),h=()=>{d(!1),i.type!=="not-asked"&&a({...i})};g.useEffect(()=>{i.type!=="not-asked"&&!i.isGenerating&&!lu(i.patchIds,o)&&d(!0)},[i,o]);const p=g.useCallback(()=>{h(),c().then(b=>{b.type==="ai"?a({type:"ai",text:b.text.trim()}):r(b.message)})},[h,c,a,r]),m="w-full p-2 border rounded bg-bg-secondary",v="text"in i?i.text:"";return f.jsxs("div",{className:"flex flex-col gap-4",children:[f.jsxs("div",{className:"flex items-center justify-between w-full gap-2",children:[f.jsx("span",{className:"font-semibold",children:"Summary"}),s&&f.jsx(E_,{onClick:p,isGenerating:i.isGenerating})]}),n&&f.jsx("div",{className:"p-4 rounded bg-bg-error-primary text-text-error-primary",children:n}),f.jsxs("div",{className:"grid text-xs font-light",children:[f.jsx("div",{"aria-hidden":!0,className:ze(m,"invisible whitespace-pre-wrap"),style:{gridArea:"1 / 1 / 2 / 2"},children:v+" "}),f.jsx("textarea",{disabled:!!i.isGenerating,className:ze(m,"resize-none overflow-clip disabled:opacity-50"),value:v,style:{gridArea:"1 / 1 / 2 / 2"},placeholder:"Write a summary of your changes"+(s?" or generate one using AI":""),onChange:b=>{h(),a({type:"manual",text:b.currentTarget.value})}})]}),f.jsxs("div",{className:ze("p-2 text-xs flex-grow font-light bg-bg-warning-primary text-[black] rounded flex items-center","flex justify-between w-full gap-2 py-2",{hidden:!u}),"aria-hidden":u,children:[f.jsx("span",{children:"Summary might be outdated. "}),f.jsx("button",{className:"underline",onClick:h,children:"Dismiss"})]}),f.jsx("div",{className:"flex items-center justify-end gap-2",children:e?f.jsxs(f.Fragment,{children:[f.jsx(Lt,{variant:"outline",onClick:()=>{t()},children:"Close"}),u&&s&&f.jsx(E_,{isGenerating:i.isGenerating,onClick:p}),!u&&f.jsxs(Lt,{disabled:l||v.trim()==="",onClick:()=>{i.type!=="not-asked"&&e()},variant:"default",className:"flex items-center gap-2",children:[f.jsxs("span",{children:[" ",l?"Pushing...":"Publish"]}),f.jsx(kS,{size:16})]})]}):f.jsx(f.Fragment,{children:f.jsx(Lt,{variant:"outline",onClick:()=>{t()},children:"Close"})})})]})}function E_({isGenerating:e,onClick:t}){return f.jsx(Lt,{className:"truncate",disabled:!!e,onClick:()=>{t()},variant:"outline",children:f.jsxs("span",{className:"flex items-center gap-2",children:[f.jsx("span",{children:e?"Generating...":"Generate"}),f.jsx(_R,{size:16})]})})}function TG(e,t=[]){let n=[];function r(i,s){const a=g.createContext(s),l=n.length;n=[...n,s];function c(d){const{scope:h,children:p,...m}=d,v=(h==null?void 0:h[e][l])||a,b=g.useMemo(()=>m,Object.values(m));return f.jsx(v.Provider,{value:b,children:p})}function u(d,h){const p=(h==null?void 0:h[e][l])||a,m=g.useContext(p);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>g.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,PG(o,...t)]}function PG(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function Qv(e){const t=e+"CollectionProvider",[n,r]=TG(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:m,children:v}=p,b=Se.useRef(null),x=Se.useRef(new Map).current;return f.jsx(o,{scope:m,itemMap:x,collectionRef:b,children:v})};s.displayName=t;const a=e+"CollectionSlot",l=Se.forwardRef((p,m)=>{const{scope:v,children:b}=p,x=i(a,v),w=Be(m,x.collectionRef);return f.jsx(Qi,{ref:w,children:b})});l.displayName=a;const c=e+"CollectionItemSlot",u="data-radix-collection-item",d=Se.forwardRef((p,m)=>{const{scope:v,children:b,...x}=p,w=Se.useRef(null),S=Be(m,w),C=i(c,v);return Se.useEffect(()=>(C.itemMap.set(w,{ref:w,...x}),()=>void C.itemMap.delete(w))),f.jsx(Qi,{[u]:"",ref:S,children:b})});d.displayName=c;function h(p){const m=i(e+"CollectionConsumer",p);return Se.useCallback(()=>{const b=m.collectionRef.current;if(!b)return[];const x=Array.from(b.querySelectorAll(`[${u}]`));return Array.from(m.itemMap.values()).sort((C,_)=>x.indexOf(C.ref.current)-x.indexOf(_.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},h,r]}var DS="Collapsible",[NG,SI]=uo(DS),[OG,LS]=NG(DS),kI=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:s,...a}=e,[l=!1,c]=Fr({prop:r,defaultProp:o,onChange:s});return f.jsx(OG,{scope:n,disabled:i,contentId:Ir(),open:l,onOpenToggle:g.useCallback(()=>c(u=>!u),[c]),children:f.jsx(_e.div,{"data-state":zS(l),"data-disabled":i?"":void 0,...a,ref:t})})});kI.displayName=DS;var EI="CollapsibleTrigger",CI=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=LS(EI,n);return f.jsx(_e.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":zS(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:te(e.onClick,o.onOpenToggle)})});CI.displayName=EI;var FS="CollapsibleContent",_I=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=LS(FS,e.__scopeCollapsible);return f.jsx(an,{present:n||o.open,children:({present:i})=>f.jsx(MG,{...r,ref:t,present:i})})});_I.displayName=FS;var MG=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,s=LS(FS,n),[a,l]=g.useState(r),c=g.useRef(null),u=Be(t,c),d=g.useRef(0),h=d.current,p=g.useRef(0),m=p.current,v=s.open||a,b=g.useRef(v),x=g.useRef();return g.useEffect(()=>{const w=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(w)},[]),_n(()=>{const w=c.current;if(w){x.current=x.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();d.current=S.height,p.current=S.width,b.current||(w.style.transitionDuration=x.current.transitionDuration,w.style.animationName=x.current.animationName),l(r)}},[s.open,r]),f.jsx(_e.div,{"data-state":zS(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!v,...i,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:v&&o})});function zS(e){return e?"open":"closed"}var jG=kI,RG=CI,IG=_I,ls="Accordion",AG=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[BS,DG,LG]=Qv(ls),[ey,kme]=uo(ls,[LG,SI]),$S=SI(),VS=Se.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,i=r;return f.jsx(BS.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?f.jsx($G,{...i,ref:t}):f.jsx(BG,{...o,ref:t})})});VS.displayName=ls;var[TI,FG]=ey(ls),[PI,zG]=ey(ls,{collapsible:!1}),BG=Se.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:i=!1,...s}=e,[a,l]=Fr({prop:n,defaultProp:r,onChange:o});return f.jsx(TI,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:Se.useCallback(()=>i&&l(""),[i,l]),children:f.jsx(PI,{scope:e.__scopeAccordion,collapsible:i,children:f.jsx(NI,{...s,ref:t})})})}),$G=Se.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...i}=e,[s=[],a]=Fr({prop:n,defaultProp:r,onChange:o}),l=Se.useCallback(u=>a((d=[])=>[...d,u]),[a]),c=Se.useCallback(u=>a((d=[])=>d.filter(h=>h!==u)),[a]);return f.jsx(TI,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c,children:f.jsx(PI,{scope:e.__scopeAccordion,collapsible:!0,children:f.jsx(NI,{...i,ref:t})})})}),[VG,ty]=ey(ls),NI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:i="vertical",...s}=e,a=Se.useRef(null),l=Be(a,t),c=DG(n),d=ep(o)==="ltr",h=te(e.onKeyDown,p=>{var j;if(!AG.includes(p.key))return;const m=p.target,v=c().filter(I=>{var F;return!((F=I.ref.current)!=null&&F.disabled)}),b=v.findIndex(I=>I.ref.current===m),x=v.length;if(b===-1)return;p.preventDefault();let w=b;const S=0,C=x-1,_=()=>{w=b+1,w>C&&(w=S)},P=()=>{w=b-1,w<S&&(w=C)};switch(p.key){case"Home":w=S;break;case"End":w=C;break;case"ArrowRight":i==="horizontal"&&(d?_():P());break;case"ArrowDown":i==="vertical"&&_();break;case"ArrowLeft":i==="horizontal"&&(d?P():_());break;case"ArrowUp":i==="vertical"&&P();break}const O=w%x;(j=v[O].ref.current)==null||j.focus()});return f.jsx(VG,{scope:n,disabled:r,direction:o,orientation:i,children:f.jsx(BS.Slot,{scope:n,children:f.jsx(_e.div,{...s,"data-orientation":i,ref:l,onKeyDown:r?void 0:h})})})}),Pg="AccordionItem",[UG,US]=ey(Pg),OI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,i=ty(Pg,n),s=FG(Pg,n),a=$S(n),l=Ir(),c=r&&s.value.includes(r)||!1,u=i.disabled||e.disabled;return f.jsx(UG,{scope:n,open:c,disabled:u,triggerId:l,children:f.jsx(jG,{"data-orientation":i.orientation,"data-state":DI(c),...a,...o,ref:t,disabled:u,open:c,onOpenChange:d=>{d?s.onItemOpen(r):s.onItemClose(r)}})})});OI.displayName=Pg;var MI="AccordionHeader",jI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ty(ls,n),i=US(MI,n);return f.jsx(_e.h3,{"data-orientation":o.orientation,"data-state":DI(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});jI.displayName=MI;var jb="AccordionTrigger",RI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ty(ls,n),i=US(jb,n),s=zG(jb,n),a=$S(n);return f.jsx(BS.ItemSlot,{scope:n,children:f.jsx(RG,{"aria-disabled":i.open&&!s.collapsible||void 0,"data-orientation":o.orientation,id:i.triggerId,...a,...r,ref:t})})});RI.displayName=jb;var II="AccordionContent",AI=Se.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ty(ls,n),i=US(II,n),s=$S(n);return f.jsx(IG,{role:"region","aria-labelledby":i.triggerId,"data-orientation":o.orientation,...s,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});AI.displayName=II;function DI(e){return e?"open":"closed"}var HG=VS,WG=OI,KG=jI,LI=RI,FI=AI;const oh=HG,Cl=g.forwardRef(({className:e,...t},n)=>f.jsx(WG,{ref:n,className:ze("border-b",e),...t}));Cl.displayName="AccordionItem";const _l=g.forwardRef(({className:e,children:t,...n},r)=>f.jsx(KG,{className:"flex",children:f.jsxs(LI,{ref:r,className:ze("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,f.jsx(Qh,{className:"w-4 h-4 transition-transform duration-200 shrink-0"})]})}));_l.displayName=LI.displayName;const Tl=g.forwardRef(({className:e,children:t,...n},r)=>f.jsx(FI,{ref:r,className:ze("overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",e),...n,children:f.jsx("div",{className:"pt-0 pb-4",children:t})}));Tl.displayName=FI.displayName;function zI(e,t,n){if(e.length===0)return{success:!1,error:"Empty path"};let r=-1,o="";const i=c=>{o===""?o=c:o+="."+c};if(t===void 0)return{success:!1,error:`Undefined schema in: '${e.join("/")}'.`};if(n===void 0)return{success:!1,error:`Undefined source in: '${e.join("/")}'.`};let s=t,a=n;const l=[{modulePath:o,schema:s,source:a}];for(const c of e){if(r++,c==="")return{success:!1,error:`Empty path part in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(s.type==="array"){s=s.item;const u=Number(c);if(!Number.isSafeInteger(u))return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an integer but got '${c}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(typeof a!="object")return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===null)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'null' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===void 0)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'undefined' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!Array.isArray(a))return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an array but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!a[u])return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an index less than ${a.length} but got '${u}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};a=a[u],i(c)}else if(s.type==="record"){s=s.item;const u=Yp(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="object"){s=s.items[c];const u=Yp(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="union"){const u=typeof s.key=="object"&&s.key.type==="literal"?s:void 0,d=typeof s.key=="string"?s:void 0;if(u)return{success:!1,error:"Invalid lookup in string union"};if(d){const h=Yp(e,c,r,a,"union object");if(!h.success)return{success:!1,error:h.error};const p=h.source;let m;for(const v of d.items){const b=v.items[d.key];if(b.type==="literal"){if(p[d.key]===b.value){m=v;break}}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}if(!m)return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};s=m.items[c],a=p[c],i(JSON.stringify(c))}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}else if(s.type==="image"||s.type==="file"){const u=Yp(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else return{success:!1,error:`Cannot construct sub-path in schema of '${s.type}' in: '${e.join("/")}'. Path was: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")}`};l.push({modulePath:o,schema:s,source:a})}return{success:!0,modulePath:o,schema:s,source:a,allResolved:l}}function Yp(e,t,n,r,o){return typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===null?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'null' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===void 0?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'undefined' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:Array.isArray(r)?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'array' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:t in r?{success:!0,source:r}:{success:!1,error:`Could not find key of source: '${e.join("/")}'. Expected a key in ${Object.keys(r).join(", ")} but got '${t}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}}function GG(e,t){return(t==null?void 0:t.type)==="array"?e.type!=="string":(t==null?void 0:t.type)==="record"}function BI(e,t,n){if(!n)return null;const[r,o]=ee.splitModuleFilePathAndModulePath(e);if(!o)return r;const i=t[r],s=n[r];if(i===void 0||!s)return null;const a=zI(ee.splitModulePath(o),s,i);if(a.success){for(let l=a.allResolved.length-1;l>=0;l--){const c=a.allResolved[l],u=a.allResolved[l-1];if(GG(c.schema,(u==null?void 0:u.schema)||null))return c.modulePath===""?r:ee.joinModuleFilePathAndModulePath(r,c.modulePath)}return r}else console.error(`Error resolving path: ${a.error} for path: ${e}`);return null}function ny({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:o=!0}){const i=Du(),s=g.useRef(null),a=g.useRef(new Map),[l,c]=g.useState([]),[u,d]=g.useState(),h=wS(),p=Xh(),{navigate:m}=Vn();g.useEffect(()=>{const b=e?ee.splitModuleFilePath(e):[],x=t,w=()=>{if(!s.current)return;const C=s.current,_=getComputedStyle(C),P=`${_.fontSize} ${_.fontFamily}`,O=C.offsetWidth,j=b.map(qG).concat(x).map(W=>`/${W}`);d(j.join(""));const I=W=>{const B=`${W}:${P}`,A=a.current.get(B)??YG(W,P);return a.current.set(B,A),A},F="/…",H=I(F),$=[];let J=0;for(let W=j.length-1;W>=0;W--){const B=I(j[W]),R=!(W===0);if(J+B+(R?H:0)<=O){const N=W>b.length?"module-path":"module-file-path";$.unshift({text:j[W],type:N,moduleFilePath:e,modulePathSegments:x.slice(0,W)}),J+=B}else{$.unshift({type:"ellipsis",text:F});break}}c($)},S=new ResizeObserver(w);return s.current&&(S.observe(s.current),w()),()=>{s.current&&S.unobserve(s.current)}},[e,t]);const v=g.useMemo(()=>{if(!o)return null;const b="data"in p?p.data:{},x=zI(t,b[e],h[e]);if(x.success){const w=ee.joinModuleFilePathAndModulePath(e,x.modulePath),S=BI(w,h,b);if(S)return{navPath:S,scrollToId:w};console.debug(`Failed to resolve nav path for ${e} and ${t.join(".")}: ${S}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(".")}: ${x.error}`);return null},[e,t,h,p]);return f.jsxs(dR,{open:r===!1?!1:void 0,children:[f.jsx(fS,{asChild:!0,children:f.jsx("a",{href:v&&i?`${i.studioPrefix}${v.navPath}#${v.scrollToId}`:void 0,ref:s,className:ke("inline-block whitespace-nowrap overflow-hidden w-full align-baseline",{"cursor-pointer hover:underline":o},n),onClick:b=>{o&&v&&b.metaKey===!1&&b.ctrlKey===!1&&b.shiftKey===!1&&(b.preventDefault(),m(v.navPath,{scrollToId:v.scrollToId}))},children:l.map((b,x)=>f.jsx("span",{children:b.text},x))})}),f.jsx(mS,{side:"top",children:f.jsx(oi,{orientation:"horizontal",className:"max-w-[calc(100vw-3rem)] whitespace-nowrap",children:u})})]})}function qG(e){const t=fu(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function YG(e,t){const r=document.createElement("canvas").getContext("2d");return r?(r.font=t,r.measureText(e).width):0}function $I({className:e,loadingStatus:t}){const n=qh(),r=Lu(),o=KW(),i=WW(),s=Kr(),[a,l]=g.useState(!1),{canGenerate:c}=Yh(),u=ja(),{autoPublish:d}=yS(),h=g.useMemo(()=>{var w;let x=0;for(const S in u)x+=((w=u[S])==null?void 0:w.length)||0;return x},[u]),p=n.length-o.size,m=Vn(),{deployments:v,dismissDeployment:b}=HW();return f.jsxs("div",{className:ke("text-sm",e),children:[u&&h>0&&f.jsx("div",{className:"sticky top-0 text-white border-b border-border-primary bg-bg-error-primary z-5",children:f.jsx(oi,{orientation:"horizontal",children:f.jsx(oh,{type:"single",className:"px-4 font-serif",collapsible:!0,children:f.jsxs(Cl,{value:"error",className:"border-b-0 data-[state=open]:mb-4",children:[f.jsxs(_l,{children:[h," validation error",h>1?"s":""]}),f.jsx(Tl,{className:"w-full",children:f.jsx("div",{className:"flex flex-col gap-2",children:f.jsx(oh,{type:"multiple",className:"w-full",children:Object.entries(u).map(([x,w],S)=>f.jsxs(Cl,{value:x+"#"+S,children:[f.jsx(_l,{children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"underline cursor-pointer",onClick:()=>{m.navigate(x)},children:x}),f.jsxs("span",{className:"pl-4",children:["(",(w==null?void 0:w.length)||0,")"]})]})}),f.jsx(Tl,{children:f.jsx("div",{className:"flex flex-col gap-2",children:w==null?void 0:w.map((C,_)=>f.jsxs("div",{children:[f.jsx("div",{children:C.message}),f.jsxs("div",{className:"pl-4 font-thin",children:["at",f.jsx("span",{className:"underline cursor-pointer",onClick:()=>{m.navigate(x)},children:x})]})]},_))})})]},x+"#"+S))})})})]})})})}),v.length>0&&f.jsx("div",{className:"p-4 border-b border-border-primary",children:f.jsx(JG,{deployments:v,onDismiss:b})}),f.jsx("div",{className:"p-4 z-5",children:f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"font-bold",children:[p<=0?"No ":`${p} `,"pending change",p===1?"":"s"]}),(t==="loading"||t==="not-asked")&&f.jsx("div",{className:"",children:f.jsx(Uo,{size:16,className:"animate-spin"})})]}),r==="http"&&f.jsxs(ns,{open:a,onOpenChange:x=>{l(x)},children:[f.jsx(Fu,{asChild:!0,children:f.jsxs(Lt,{variant:"outline",className:"flex items-center gap-2 text-sm",children:[f.jsx("span",{children:"Summary"}),c&&f.jsx(_R,{size:14})]})}),f.jsxs(hi,{container:s,align:"end",className:"z-[9001] flex flex-col gap-4",children:[f.jsx(Xv,{asChild:!0,className:"self-end cursor-pointer",children:f.jsx(du,{size:12})}),f.jsx(wI,{onClose:()=>{l(!1)}})]})]})]})}),(!d||h>0)&&f.jsx("div",{className:"flex flex-col gap-[2px]",children:"data"in i&&n.length>0&&i.data.map(x=>f.jsx(eq,{committedPatchIds:o,patchSet:x},x.moduleFilePath+":"+x.patchPath.join("/")))})]})}function JG({deployments:e,onDismiss:t}){return f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between p-2 font-bold",children:[f.jsx("span",{children:"Deployments"}),f.jsx(Uo,{size:16,className:"inline animate-spin"})]}),f.jsx("div",{children:e.reverse().map(n=>f.jsx(XG,{deployment:n,onDismiss:()=>{t(n.commitSha)}},n.commitSha))})]})}function XG({deployment:e}){var o;const t=bS(),n=Kr(),r=e.creator&&t[e.creator];return f.jsxs("div",{className:"flex items-start justify-between p-2",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[r&&f.jsx("img",{src:(o=r.avatar)==null?void 0:o.url,alt:r.fullName,className:"w-8 h-8 rounded-full"}),f.jsxs(dR,{children:[f.jsx(Qj,{container:n}),f.jsx($W,{children:f.jsx("div",{className:"max-w-[180px] overflow-clip font-light truncate",children:e.commitMessage})}),f.jsx(mS,{className:"max-w-[320px]",children:f.jsx("pre",{className:"font-sans font-light whitespace-break-spaces",children:e.commitMessage})})]})]}),f.jsx(ZG,{since:new Date(e.createdAt)})]})}function ZG({since:e}){const[t,n]=g.useState("00"),[r,o]=g.useState("00");return g.useEffect(()=>{let i;const s=()=>{const a=Date.now(),l=Math.floor((a-e.getTime())/1e3),c=Math.floor(l/60),u=l%60;let d;c>4?(d=(60-u)*1e3,n(c.toString()),o(null)):(d=1e3,n(c.toString().padStart(2,"0")),o(u.toString().padStart(2,"0"))),i=setTimeout(s,d)};return s(),()=>{clearTimeout(i)}},[e]),f.jsxs("div",{className:"text-xs font-light text-text-quartenary",children:[t,r!==null?`:${r}`:" mins"]})}function QG({moduleFilePath:e,patchMetadata:t,committedPatchIds:n}){var d;const r=VI([t.opType],t.createdAt,n.has(t.patchId)),o=bS(),{patchErrors:i,skippedPatches:s}=xS(),[a,l]=g.useMemo(()=>[i[t.patchId]||[],!!s[t.patchId]],[t.patchId,i[t.patchId],s[t.patchId]]),c=Lu();let u=[];if(t.author){const h=o[t.author];if(h){const p=((d=h==null?void 0:h.avatar)==null?void 0:d.url)??null;u=[{fullName:h.fullName,url:p}]}else console.warn("Did not find profile for author: ",t.author,{profilesById:o})}return u.length===0&&c==="http"&&console.warn("No authors",{patchMetadata:t}),f.jsx(Rb,{moduleFilePath:e,patchPath:t.patchPath,changeDescription:l?"Skipped":r,authors:u,errors:a,skipped:l,isApplied:n.has(t.patchId)})}function VI(e,t,n){const[r,o]=g.useState(new Date);if(g.useEffect(()=>{const a=setInterval(()=>{o(new Date)},6e4);return()=>{clearInterval(a)}},[]),n)return"Pushed "+zx(r,t);if(e.length>1)return"Updated "+zx(r,t);const i=e[0];let s=i;return i==="add"?s="Added":i==="remove"?s="Removed":i==="replace"?s="Replaced":i==="move"?s="Moved":i==="copy"?s="Copied":i==="test"?s="Tested":i==="file"?s="Updated":console.warn("Unexpected op type: ",i),s+" "+zx(r,t)}function eq({patchSet:e,committedPatchIds:t}){const[n,r]=g.useState(!1),o=g.useRef(null),[i,s]=g.useState(!1);g.useEffect(()=>{const v=new IntersectionObserver(b=>{b[0].isIntersecting&&s(!0)},{threshold:0});return o.current&&v.observe(o.current),()=>{v.disconnect()}},[]);const{patchErrors:a,skippedPatches:l}=xS(),{deletePatches:c}=UW(),u=g.useMemo(()=>e.patches.map(v=>v.patchId),[e.patches.map(v=>v.patchId).join(",")]),d=g.useMemo(()=>{const v=[];for(const b of u)for(const x of a[b]||[])l[b]||v.unshift(x);return v},[u,a,l]),h=VI(e.opTypes,e.lastUpdated,!1),p=bS(),m=e.patches.every(v=>t.has(v.patchId));return i?f.jsxs(f.Fragment,{children:[f.jsx(Rb,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,isApplied:m,authors:e.authors.reduce((v,b)=>v.includes(b)?v:v.concat(b),[]).flatMap(v=>{var x;const b=p[v];if(b){const w=((x=b==null?void 0:b.avatar)==null?void 0:x.url)??null;return[{fullName:b.fullName,url:w}]}return[]}),changeDescription:h,isOpen:n,setOpen:r,errors:d,onDelete:()=>{c(u.filter(v=>!t.has(v)))},amount:new Set(u).size}),f.jsx(nh,{isOpen:n,children:e.patches.map((v,b)=>f.jsx(QG,{committedPatchIds:t,moduleFilePath:e.moduleFilePath,patchMetadata:v},e.moduleFilePath+":"+e.patchPath.join("/")+v.patchId+b))})]}):f.jsx(Rb,{ref:o,isApplied:m})}const Rb=g.forwardRef(({moduleFilePath:e,patchPath:t,changeDescription:n,authors:r,isOpen:o,setOpen:i,isSelected:s,setSelected:a,errors:l,skipped:c,onDelete:u,amount:d,isApplied:h},p)=>f.jsxs("div",{ref:p,className:ke("p-6",{"bg-bg-secondary":!o,"bg-bg-quartenary":o,"opacity-50":h}),children:[f.jsxs("div",{className:"relative",children:[f.jsx("span",{className:"inline-block w-[calc(320px-24px-8px-16px-24px-48px)] truncate mr-2 ",children:e&&t&&f.jsx(ny,{moduleFilePath:e,patchPath:t,link:!0,toolTip:!0})}),s===void 0&&f.jsx("span",{className:ke("inline-block w-6 h-6 rounded",{"bg-bg-disabled animate-pulse":t===void 0})}),s!==void 0&&!h&&f.jsx(zu,{checked:s,onCheckedChange:m=>{a&&a(m)}}),u&&!h&&f.jsxs("button",{onClick:u,title:"Revert change",className:"relative ml-5",children:[d&&f.jsx("span",{className:"absolute px-2 text-xs rounded-full -top-6 -right-5 bg-bg-quartenary",children:d>10?"10+":d}),f.jsx(B7,{size:16,className:"inline"})]})]}),l&&l.length>0&&!c&&f.jsxs("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-text-primary",children:[l.slice(0,1).map((m,v)=>f.jsx("div",{title:m,className:"truncate",children:m},v)),l.length>1&&f.jsxs("div",{className:"truncate",children:["+",l.length-1," more"]})]}),(!l||l.length===0)&&c&&f.jsx("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-text-primary",children:f.jsx("div",{className:"truncate",children:"Skipped"})}),f.jsxs("div",{className:"flex items-center justify-between pt-2",children:[f.jsxs("span",{className:"flex flex-shrink-0 gap-2",children:[r!==void 0&&r.length>0&&f.jsxs("span",{className:"flex gap-1 mr-2",children:[r.slice(0,2).map((m,v)=>{if(m.url)return f.jsxs(al,{children:[f.jsx($c,{className:"flex-shrink-0 w-6 h-6 ",children:f.jsx("img",{src:m.url,alt:m.fullName,className:ke("rounded-full",{"-ml-3":r.length>2&&v>0})})}),f.jsx(ll,{children:f.jsx("div",{children:m.fullName})})]},m.url);const b=tq(m.fullName);return f.jsxs(al,{children:[f.jsx($c,{className:ke({"-ml-3":r.length>2&&v>0}),children:f.jsx("span",{className:ke("flex items-center justify-center w-6 h-6 text-xs font-semibold rounded-full bg-bg-quartenary text-fg-primary"),"aria-label":"Initials for: "+m.fullName,children:b})}),f.jsx(ll,{children:f.jsx("div",{children:m.fullName})})]},m.fullName+m.url)}),r.length>2&&f.jsxs(al,{children:[f.jsx($c,{className:ke({"-ml-3":r.length>2}),children:f.jsxs("span",{className:"flex items-center justify-center w-6 h-6 -ml-3 text-xs font-semibold rounded-full bg-bg-quartenary text-fg-primary",children:["+",r.length-2]})}),f.jsx(ll,{className:"grid grid-cols-[auto,1fr] gap-2",children:r.slice(2).map(m=>f.jsxs(g.Fragment,{children:[m.url?f.jsx("img",{src:m.url,alt:m.fullName,title:m.fullName,className:ke("w-6 h-6 rounded-full")},m.url):f.jsx("div",{}),f.jsx("div",{children:m.fullName})]},m.fullName+m.url))})]})]}),r===void 0&&f.jsx("span",{className:ke("inline-block w-6 h-6 mr-2",{"bg-bg-disabled animate-pulse rounded-3xl":r===void 0})}),n&&f.jsx("span",{className:ke({"text-text-disabled":c}),children:n})]}),o!==void 0&&f.jsx("button",{className:"flex-shrink-0 inline-block",onClick:()=>{i&&i(!o)},children:f.jsx(Qh,{size:16,className:ke("transform",{"rotate-180":o})})})]})]}));function tq(e){return!e||typeof e!="string"?"":e.trim().normalize("NFC").split(/\s+/).filter(r=>r.length>0).map(r=>/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(r)?r[0]:r[0].toLocaleUpperCase()).join("")}function Ib(){const[e,t]=g.useState(!1),{publish:n,publishDisabled:r,isPublishing:o,summary:i}=Yh(),s=ja(),a=s!==void 0&&Object.keys(s).length>0,l=pR(),c=mR(),u=Lu(),d=Kr(),{autoPublish:h}=yS();return u==="fs"?f.jsxs(Lt,{className:"flex items-center gap-2",disabled:r||a||h||l.length===0||c.length>0,title:a?"Please fix validation errors":"",onClick:()=>{n("No summary provided")},children:[a?f.jsx("span",{children:"Save"}):f.jsx("span",{children:o?"Saving":"Save"}),o&&f.jsx(Uo,{className:"animate-spin",size:16})]}):f.jsx("span",{children:f.jsxs(ns,{open:e,onOpenChange:p=>{t(p)},children:[f.jsx(Fu,{asChild:!0,children:f.jsxs(Lt,{className:"flex items-center gap-2",disabled:r||a||l.length===0||c.length>0,title:a?"Please fix validation errors":"",onClick:()=>{t(!0)},children:[!o&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"Ready"}),f.jsx(kS,{size:16})]}),o&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"Pushing"}),f.jsx(Uo,{className:"animate-spin",size:16})]})]})}),f.jsxs(hi,{container:d,align:"end",className:"z-[9001] flex flex-col gap-4",children:[f.jsx(Xv,{asChild:!0,className:"self-end cursor-pointer",children:f.jsx(du,{size:12})}),f.jsx(wI,{onClose:()=>{t(!1)},onPublish:()=>{if(t(!1),i.type==="not-asked")return;const p=i.text.trim();n(p)}})]})]})})}function nq(){const e=Hv(),{isPublishing:t}=Yh(),n=ja()||{},{globalErrors:r}=xS(),o=Lu(),[i,s]=g.useMemo(()=>{const a=new Set;let l=0;for(const c in n){const[u]=ee.splitModuleFilePathAndModulePath(c);a.add(u),l+=1}return[Array.from(a).sort(),l]},[n]);return f.jsxs("div",{className:"min-h-[100svh] bg-bg-primary",style:{"--menu-width":"320px"},children:[f.jsx("div",{className:"h-16 border-b border-border-primary",children:f.jsx(iq,{})}),t&&f.jsxs("div",{className:"flex items-center justify-end gap-2 p-4 text-right border-t bg-bg-tertiary text-text-primary border-border-primary",children:[f.jsx("span",{children:"Publishing changes "}),f.jsx(Uo,{size:16,className:"animate-spin"})]}),f.jsx(oi,{children:f.jsxs("div",{className:"max-h-[calc(100svh-64px)]",children:[r&&r.length>0&&r.length!==s&&f.jsx(oh,{type:"single",collapsible:!0,children:f.jsxs(Cl,{value:"global-errors",children:[f.jsxs(_l,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-text-error-primary",children:["Cannot ",o==="fs"?"save":"publish"," now. Found"," ",r==null?void 0:r.length," errors in all."," ",r.length-s," were non-validation errors. A developer might need to fix these issues."]}),f.jsx(Tl,{children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-128px)] max-w-[var(--menu-width)]",children:r==null?void 0:r.map((a,l)=>f.jsx(oq,{error:a},l))})})})]})}),(r==null?void 0:r.length)===s&&i.length>0&&f.jsx(oh,{type:"single",collapsible:!0,children:f.jsxs(Cl,{value:"global-errors",children:[f.jsx(_l,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-text-error-primary",children:f.jsxs("div",{children:[f.jsxs("div",{children:["Cannot ",o==="fs"?"save":"publish"," now."]}),f.jsx("div",{children:"Found errors in modules"})]})}),f.jsx(Tl,{children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-64px)] max-w-[var(--menu-width)]",children:i==null?void 0:i.map((a,l)=>f.jsx(rq,{moduleFilePath:a},l))})})})]})}),e!=="not-asked"&&f.jsx("div",{className:ke("",{}),children:f.jsx(oi,{children:f.jsx("div",{className:"max-h-[calc(100svh-64px)] border-b border-border-primary",children:f.jsx($I,{loadingStatus:e})})})})]})})]})}function rq({moduleFilePath:e}){const t=ee.splitModuleFilePath(e),n=Vn();return f.jsx("div",{className:"px-4 py-2 border-b bg-bg-error-primary text-text-error-primary border-border-error",children:f.jsx("button",{className:"underline cursor-pointer",onClick:()=>{n.navigate(e)},children:t.map((r,o)=>f.jsxs(g.Fragment,{children:[f.jsx("span",{className:ze("text-text-brand-secondary",{"ml-1":o>0}),children:"/"}),f.jsx("span",{children:fu(r)})]},o))})})}function oq({error:e}){const[t,n]=g.useState(!1);return f.jsx("div",{className:ze("px-1 py-2 bg-bg-error-primary text-text-error-primary border-b border-border-error",{truncate:!t,"whitespace-normal":t}),onClick:()=>n(!t),children:e})}function iq(){const{navMenu:e,toolsMenu:t}=Fy(),n=Lu(),{setAutoPublish:r,autoPublish:o}=yS();return f.jsx("div",{className:"flex flex-col",children:f.jsxs("div",{className:"flex items-center justify-between w-full gap-2 p-4",children:[f.jsx("button",{className:"lg:hidden",onClick:()=>{t.setOpen(!t.isOpen)},children:f.jsx(kg,{size:16,className:ke("transform",{"rotate-180":!e.isOpen})})}),f.jsxs("div",{className:"flex items-center justify-end w-full gap-2",children:[n==="fs"&&f.jsxs("div",{className:"overflow-hidden flex items-center gap-2 text-[10px] lg:text-xs",children:[f.jsx("span",{className:"truncate text-text-secondary",children:"Auto-save"}),f.jsx(zu,{checked:o,onCheckedChange:r})]}),f.jsxs(Lt,{className:"flex items-center gap-2",variant:"outline",onClick:()=>{window.location.href=Qf("/api/val/enable",{redirect_to:window.origin})},children:[f.jsx("span",{children:"Preview"}),f.jsx(wR,{size:16})]}),f.jsx(Ib,{})]})]})})}function qt({error:e,path:t}){return f.jsx("div",{id:t,children:f.jsx("div",{className:"p-4 bg-bg-error-primary text-text-error-primary",children:e})})}function gt({path:e,type:t}){return f.jsx("div",{id:e,className:ke("pt-6",{"w-full flex items-center justify-center":t==="module","text-left":t!=="module"}),children:f.jsx(Uo,{size:t==="module"?24:16,className:"animate-spin"})})}function Tn({path:e,type:t}){const[n,r]=g.useState(!1);return g.useEffect(()=>{const o=setTimeout(()=>{r(!0)},2e3);return()=>{clearTimeout(o)}},[]),e.length===0?null:n?f.jsx("div",{className:"pt-6",id:e,children:f.jsx("div",{children:"Could not get data"})}):f.jsx(gt,{path:e,type:t})}function vr({actualType:e,expectedType:t,path:n}){return f.jsx("div",{id:n,children:f.jsxs("div",{children:["Schema mismatch: actual: ",e," vs expected: ",t," "]})})}function nt({error:e,path:t}){return f.jsx("div",{id:t,children:f.jsxs("div",{className:"p-4 rounded bg-bg-error-primary text-text-primary",children:["Source error: ",e]})})}function sq(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const ry=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Bu(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function HS(e){return"nodeType"in e}function yr(e){var t,n;return e?Bu(e)?e:HS(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function WS(e){const{Document:t}=yr(e);return e instanceof t}function op(e){return Bu(e)?!1:e instanceof yr(e).HTMLElement}function UI(e){return e instanceof yr(e).SVGElement}function $u(e){return e?Bu(e)?e.document:HS(e)?WS(e)?e:op(e)||UI(e)?e.ownerDocument:document:document:document}const pi=ry?g.useLayoutEffect:g.useEffect;function KS(e){const t=g.useRef(e);return pi(()=>{t.current=e}),g.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function aq(){const e=g.useRef(null),t=g.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=g.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ih(e,t){t===void 0&&(t=[e]);const n=g.useRef(e);return pi(()=>{n.current!==e&&(n.current=e)},t),n}function ip(e,t){const n=g.useRef();return g.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ng(e){const t=KS(e),n=g.useRef(null),r=g.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function Ab(e){const t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}let $x={};function sp(e,t){return g.useMemo(()=>{if(t)return t;const n=$x[e]==null?0:$x[e]+1;return $x[e]=n,e+"-"+n},[e,t])}function HI(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+e*c)}return i},{...t})}}const Vc=HI(1),sh=HI(-1);function lq(e){return"clientX"in e&&"clientY"in e}function GS(e){if(!e)return!1;const{KeyboardEvent:t}=yr(e.target);return t&&e instanceof t}function cq(e){if(!e)return!1;const{TouchEvent:t}=yr(e.target);return t&&e instanceof t}function Db(e){if(cq(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return lq(e)?{x:e.clientX,y:e.clientY}:null}const ah=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[ah.Translate.toString(e),ah.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),C_="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function uq(e){return e.matches(C_)?e:e.querySelector(C_)}const dq={display:"none"};function fq(e){let{id:t,value:n}=e;return Se.createElement("div",{id:t,style:dq},n)}function hq(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Se.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function pq(){const[e,t]=g.useState("");return{announce:g.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const WI=g.createContext(null);function mq(e){const t=g.useContext(WI);g.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function gq(){const[e]=g.useState(()=>new Set),t=g.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[g.useCallback(r=>{let{type:o,event:i}=r;e.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[e]),t]}const vq={draggable:`
426
426
  To pick up a draggable item, press the space bar.
427
427
  While dragging, use the arrow keys to move the item.
428
428
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Val</title>
7
- <script type="module" crossorigin src="/api/val/static/assets/index-B4xpMmmQ.js"></script>
7
+ <script type="module" crossorigin src="/api/val/static/assets/index-DXULLBtF.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/api/val/static/assets/index-CDA2_ifk.css">
9
9
  </head>
10
10
  <body>