headroom-cms 0.1.5 → 0.1.6
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/admin/assets/{AdminsPage-C4tJy6Vj.js → AdminsPage-BqfhR4Zc.js} +1 -1
- package/admin/assets/{AllContentPage-DL0-UlYh.js → AllContentPage-C11eeRMt.js} +1 -1
- package/admin/assets/{ApiKeysPage-pZ6nKCZ_.js → ApiKeysPage-DJjOSLoR.js} +1 -1
- package/admin/assets/AuditPage-DJNk7IaW.js +1 -0
- package/admin/assets/{BlockEditor-D0Jk8u7w.js → BlockEditor-DDsml97y.js} +2 -2
- package/admin/assets/BlockTypeEditPage-Cg7BifaZ.js +1 -0
- package/admin/assets/{BlockTypesPage-Q7keQKxn.js → BlockTypesPage-BDFj8TSL.js} +1 -1
- package/admin/assets/{BulkActionBar-BGDrNwCg.js → BulkActionBar-CastJGEP.js} +1 -1
- package/admin/assets/CollectionEditPage-DGW4iMfo.js +1 -0
- package/admin/assets/{CollectionsPage-DDZ-5H7Y.js → CollectionsPage-C8XNxRda.js} +1 -1
- package/admin/assets/{ContentCreatePage-C3jn0Etf.js → ContentCreatePage-CX4aOzTR.js} +1 -1
- package/admin/assets/ContentEditPage-Dj3RK2BF.js +2 -0
- package/admin/assets/ContentListPage-CoDanHrR.js +1 -0
- package/admin/assets/{CustomBlockPreview-f9j4g35U.js → CustomBlockPreview-DfDOcbmR.js} +1 -1
- package/admin/assets/{FieldBuilder-p1Y8RubR.js → FieldBuilder-8VVLG_j0.js} +2 -2
- package/admin/assets/FilterBar-JCp03kkK.js +1 -0
- package/admin/assets/{LoginPage-9YUPS1YH.js → LoginPage-gPNC9XRN.js} +1 -1
- package/admin/assets/{MediaField-DJpYbUA8.js → MediaField-Du7_gRse.js} +1 -1
- package/admin/assets/MediaPage-D9763lEk.js +1 -0
- package/admin/assets/RelationshipPicker-D7dFI43Q.js +1 -0
- package/admin/assets/SiteSettingsPage-Tfiex2yn.js +1 -0
- package/admin/assets/{SiteUsersPage-CtVaB0vq.js → SiteUsersPage-CSV8syR3.js} +1 -1
- package/admin/assets/{SitesPage-B-sNyP-Y.js → SitesPage-BFIZ3Y5K.js} +1 -1
- package/admin/assets/SubmissionDetailPage-8vtUQsLd.js +1 -0
- package/admin/assets/SubmissionEditPage-PgowJuvq.js +1 -0
- package/admin/assets/SubmissionListPage-HFDQxPhn.js +1 -0
- package/admin/assets/{TagInput-CrI2BIuz.js → TagInput-CDkKZboX.js} +1 -1
- package/admin/assets/{TagsPage-BSX5KQvZ.js → TagsPage-BW15-W4H.js} +1 -1
- package/admin/assets/{UsersPage-BCTpWULa.js → UsersPage-C-zlDeTy.js} +1 -1
- package/admin/assets/{WebhookEditPage-CQO3nmaT.js → WebhookEditPage-cPPALIbH.js} +1 -1
- package/admin/assets/{WebhooksPage-ByaTlUGU.js → WebhooksPage-vkPC4m9a.js} +1 -1
- package/admin/assets/{card-uKxSQehY.js → card-10FqkZPA.js} +1 -1
- package/admin/assets/{checkbox-z1kYnX5o.js → checkbox-fC1QPb_4.js} +1 -1
- package/admin/assets/collapsible-B414SspL.js +1 -0
- package/admin/assets/{command-CuWC4GrT.js → command-BeacdV75.js} +1 -1
- package/admin/assets/{index-HoCNSqv2.css → index-Do_SK4Zl.css} +1 -1
- package/admin/assets/{index-b-u0-VCO.js → index-wYNPRVrc.js} +12 -12
- package/admin/assets/{popover-rcnajqN6.js → popover-BJDj8C6y.js} +1 -1
- package/admin/assets/{select-BKaV0BO_.js → select-BV3jemT6.js} +1 -1
- package/admin/assets/{serializeToText-BfR2RCzd.js → serializeToText-BJy0Ms5I.js} +1 -1
- package/admin/assets/sortable.esm-QyXA6fio.js +1 -0
- package/admin/assets/{table-Bozosvl6.js → table-WkEcC9MH.js} +1 -1
- package/admin/assets/{textarea-BnjAxJtk.js → textarea-CHQ9tT69.js} +1 -1
- package/admin/assets/{useAdminResolver-B0ady82Q.js → useAdminResolver-CpZj93vH.js} +1 -1
- package/admin/assets/useContent-D8yDRTTy.js +1 -0
- package/admin/assets/useContentSearch-B-_p0_QX.js +1 -0
- package/admin/assets/useFilterParams-DYdEuWPE.js +1 -0
- package/admin/assets/{useMedia-CXQpRNYL.js → useMedia-m6zKB__r.js} +1 -1
- package/admin/assets/usePageTitle-Bwf-MpTD.js +1 -0
- package/admin/assets/{useSiteUsers-BfzIdhvs.js → useSiteUsers-QbiItSH1.js} +1 -1
- package/admin/assets/{useTags-B6FtXCHF.js → useTags-CLPWVUB3.js} +1 -1
- package/admin/assets/{useWebhooks-iPRX5y4s.js → useWebhooks-no0l3-mF.js} +1 -1
- package/admin/index.html +3 -3
- package/admin/sw.js +1 -1
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -1
- package/dist/api.js.map +1 -1
- package/dist/cdn.js +1 -1
- package/dist/cdn.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/lambda/api/bootstrap +0 -0
- package/lambda/image-lambda/index.mjs +1 -1
- package/lambda/webhook-worker/bootstrap +0 -0
- package/package.json +1 -1
- package/src/api.ts +2 -1
- package/src/cdn.ts +1 -1
- package/src/index.ts +1 -0
- package/admin/assets/AuditPage-aVmcP6Ts.js +0 -1
- package/admin/assets/BlockTypeEditPage-DIe2yYEr.js +0 -1
- package/admin/assets/CollectionEditPage-Bq75MpXk.js +0 -1
- package/admin/assets/ContentEditPage-9tODvFEv.js +0 -2
- package/admin/assets/ContentListPage-VCT6GTCF.js +0 -1
- package/admin/assets/MediaPage-BgDRQR21.js +0 -1
- package/admin/assets/SiteSettingsPage-Diy-PauR.js +0 -1
- package/admin/assets/SubmissionDetailPage-DW6QJvAy.js +0 -1
- package/admin/assets/SubmissionEditPage-CxYPdI9-.js +0 -1
- package/admin/assets/SubmissionListPage-BHF82NF3.js +0 -1
- package/admin/assets/sortable.esm-BHilUL-2.js +0 -1
- package/admin/assets/useContent-B2MUK4An.js +0 -1
- package/admin/assets/usePageTitle-Do4xyFdL.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as g,R as T,L as Dt,u as kt}from"./react-vendor-C2CvUxFh.js";import{u as St}from"./useFilterParams-DYdEuWPE.js";import{a as Tt,b as It,c as Mt,d as Rt,e as ct,f as _t,g as At,h as Et,i as Ft,j as zt,k as $t,l as Pt,m as Ot}from"./useMedia-m6zKB__r.js";import{y as P,aa as dt,ab as Ut,ac as Lt,ad as Ht,ae as Xt,R as Yt,B as D,af as Oe,v as I,D as oe,k as ce,l as de,m as he,n as ue,L,I as K,o as me,a as J,ag as Bt,j as Ue,T as Kt,X as ge,P as Wt,ah as ee,a2 as Vt,a3 as qt,a7 as Qt,a5 as Gt,a6 as nt,ai as pe,aj as Zt,ak as Jt,Z as es,al as ts,am as ss,W as as,x as ns,F as rs,G as is,K as ls,z as rt,an as os,ao as cs,ap as ds,S as hs,aq as us}from"./index-wYNPRVrc.js";import{C as ms,c as xs}from"./card-10FqkZPA.js";import{C as Ie}from"./checkbox-fC1QPb_4.js";import{S as fe,a as we,b as je,c as ve,d as te}from"./select-BV3jemT6.js";import{s as ps,t as gs,u as fs,v as ws,w as js,A as vs}from"./radix-C1kb_NqW.js";import{b as ht,d as ys,u as bs,a as Cs,D as Ns,e as Ds,P as ks}from"./core.esm-B_kcYf6n.js";import{b as ye,a as Le,f as He}from"./format-C88SDH8g.js";import{m as W}from"./media-url-DIg_vSyf.js";import{T as Ss,a as Ts,b as ut,c as X,d as Is,e as Y}from"./table-WkEcC9MH.js";import{T as Pe,A as Xe,h as Ms,a as Ye,b as Be,c as Ke,d as We,e as Ve,f as qe,g as Qe}from"./TagInput-CDkKZboX.js";import{u as Rs}from"./usePageTitle-Bwf-MpTD.js";function Ne({delayDuration:a=0,...t}){return e.jsx(ps,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function De({...a}){return e.jsx(gs,{"data-slot":"tooltip",...a})}function ke({...a}){return e.jsx(fs,{"data-slot":"tooltip-trigger",...a})}function Se({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(ws,{children:e.jsxs(js,{"data-slot":"tooltip-content",sideOffset:t,className:P("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",a),...l,children:[s,e.jsx(vs,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Me({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(dt,{className:P("text-blue-500",t)}):a.startsWith("video/")?e.jsx(Ut,{className:P("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Lt,{className:P("text-green-500",t)}):a==="image/svg+xml"?e.jsx(Ht,{className:P("text-orange-500",t)}):e.jsx(Xt,{className:P("text-muted-foreground",t)})}function _s(a){return a==="application/pdf"?"PDF":a==="image/svg+xml"?"SVG":a.startsWith("image/")?"Image":a.startsWith("video/")?"Video":a.startsWith("audio/")?"Audio":a.split("/")[1]?.toUpperCase()??"File"}function As({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:i}){const{attributes:d,listeners:h,setNodeRef:o,isDragging:r}=ht({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(ut,{ref:o,className:P("cursor-pointer",r&&"opacity-50"),onClick:l,children:[e.jsx(Y,{onPointerDown:p=>p.stopPropagation(),onClick:p=>p.stopPropagation(),children:e.jsx(Ie,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(Y,{className:"w-6 p-1 hidden md:table-cell",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...d,...h,children:e.jsx(Yt,{className:"h-4 w-4"})})}),e.jsx(Y,{className:"p-1",children:x?e.jsx("img",{src:W(a.urls?.thumb_sm??a.url),alt:a.alt||a.filename,className:P("h-8 w-8 rounded object-cover",n&&"cursor-zoom-in"),onClick:n?p=>{p.stopPropagation(),n()}:void 0}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(Y,{className:"max-w-[200px]",children:[i&&e.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:i}),e.jsx("span",{className:"block truncate text-sm font-medium",children:a.filename})]}),e.jsx(Y,{className:"hidden md:table-cell",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:_s(a.mimeType)})}),e.jsx(Y,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:ye(a.size)})}),e.jsx(Y,{className:"hidden lg:table-cell",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:a.width&&a.height?`${a.width}×${a.height}`:"—"})}),e.jsx(Y,{className:"hidden lg:table-cell",children:a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(p=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px]",children:p},p)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})}),e.jsx(Y,{className:"hidden md:table-cell",children:e.jsx(Ne,{children:e.jsxs(De,{children:[e.jsx(ke,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Le(a.uploadedAt)})}),e.jsx(Se,{children:He(a.uploadedAt)})]})})}),e.jsx(Y,{onPointerDown:p=>p.stopPropagation(),onClick:p=>p.stopPropagation(),children:e.jsx(D,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),I.success("URL copied to clipboard")},children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})})]})}function Es({items:a,host:t,onSelect:s,selectedIds:l,onToggle:n,onToggleAll:i,allSelected:d,onLightbox:h,folderMap:o}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ss,{children:[e.jsx(Ts,{children:e.jsxs(ut,{children:[e.jsx(X,{className:"w-10",children:e.jsx(Ie,{checked:d,onCheckedChange:i,"aria-label":"Select all"})}),e.jsx(X,{className:"w-6 hidden md:table-cell"}),e.jsx(X,{className:"w-12"}),e.jsx(X,{children:"Filename"}),e.jsx(X,{className:"w-20 hidden md:table-cell",children:"Type"}),e.jsx(X,{className:"w-24 text-right",children:"Size"}),e.jsx(X,{className:"w-28 hidden lg:table-cell",children:"Dimensions"}),e.jsx(X,{className:"w-40 hidden lg:table-cell",children:"Tags"}),e.jsx(X,{className:"w-32 hidden md:table-cell",children:"Uploaded"}),e.jsx(X,{className:"w-10"})]})}),e.jsx(Is,{children:a.map(r=>e.jsx(As,{item:r,host:t,selected:l.has(r.mediaId),onToggle:()=>n(r.mediaId),onSelect:()=>s(r),folderName:o?.get(r.folderId??""),onLightbox:h&&r.mimeType.startsWith("image/")&&r.mimeType!=="image/svg+xml"?()=>h(r):void 0},r.mediaId))})]})})}var Fs=Object.defineProperty,zs=(a,t,s)=>t in a?Fs(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,_=(a,t,s)=>zs(a,typeof t!="symbol"?t+"":t,s);const Te={x:0,y:0,width:0,height:0,unit:"px"},re=(a,t,s)=>Math.min(Math.max(a,t),s),$s=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),it=(a,t)=>a===t||a.width===t.width&&a.height===t.height&&a.x===t.x&&a.y===t.y&&a.unit===t.unit;function ie(a,t,s){return a.unit==="%"?{...Te,...a,unit:"%"}:{unit:"%",x:a.x?a.x/t*100:0,y:a.y?a.y/s*100:0,width:a.width?a.width/t*100:0,height:a.height?a.height/s*100:0}}function G(a,t,s){return a.unit?a.unit==="px"?{...Te,...a,unit:"px"}:{unit:"px",x:a.x?a.x*t/100:0,y:a.y?a.y*s/100:0,width:a.width?a.width*t/100:0,height:a.height?a.height*s/100:0}:{...Te,...a,unit:"px"}}function lt(a,t,s,l,n,i=0,d=0,h=l,o=n){const r={...a};let x=Math.min(i,l),p=Math.min(d,n),f=Math.min(h,l),c=Math.min(o,n);t&&(t>1?(x=d?d*t:x,p=x/t,f=h*t):(p=i?i/t:p,x=p*t,c=o/t)),r.y<0&&(r.height=Math.max(r.height+r.y,p),r.y=0),r.x<0&&(r.width=Math.max(r.width+r.x,x),r.x=0);const b=l-(r.x+r.width);b<0&&(r.x=Math.min(r.x,l-x),r.width+=b);const m=n-(r.y+r.height);if(m<0&&(r.y=Math.min(r.y,n-p),r.height+=m),r.width<x&&((s==="sw"||s=="nw")&&(r.x-=x-r.width),r.width=x),r.height<p&&((s==="nw"||s=="ne")&&(r.y-=p-r.height),r.height=p),r.width>f&&((s==="sw"||s=="nw")&&(r.x-=f-r.width),r.width=f),r.height>c&&((s==="nw"||s=="ne")&&(r.y-=c-r.height),r.height=c),t){const N=r.width/r.height;if(N<t){const w=Math.max(r.width/t,p);(s==="nw"||s=="ne")&&(r.y-=w-r.height),r.height=w}else if(N>t){const w=Math.max(r.height*t,x);(s==="sw"||s=="nw")&&(r.x-=w-r.width),r.width=w}}return r}function Ps(a,t,s,l){const n={...a};return t==="ArrowLeft"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="w"?(n.x-=s,n.width+=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="e"?n.width-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowRight"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="w"?(n.x+=s,n.width-=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="e"?n.width+=s:l==="se"&&(n.width+=s,n.height+=s)),t==="ArrowUp"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="n"?(n.y-=s,n.height+=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="s"?n.height-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowDown"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="n"?(n.y+=s,n.height-=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="s"?n.height+=s:l==="se"&&(n.width+=s,n.height+=s)),n}const le={capture:!0,passive:!1};let Os=0;const Z=class U extends g.PureComponent{constructor(){super(...arguments),_(this,"docMoveBound",!1),_(this,"mouseDownOnCrop",!1),_(this,"dragStarted",!1),_(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),_(this,"componentRef",g.createRef()),_(this,"mediaRef",g.createRef()),_(this,"resizeObserver"),_(this,"initChangeCalled",!1),_(this,"instanceId",`rc-${Os++}`),_(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),_(this,"onCropPointerDown",t=>{const{crop:s,disabled:l}=this.props,n=this.getBox();if(!s)return;const i=G(s,n.width,n.height);if(l)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const d=t.target.dataset.ord,h=!!d;let o=t.clientX,r=t.clientY,x=i.x,p=i.y;if(d){const f=t.clientX-n.x,c=t.clientY-n.y;let b=0,m=0;d==="ne"||d=="e"?(b=f-(i.x+i.width),m=c-i.y,x=i.x,p=i.y+i.height):d==="se"||d==="s"?(b=f-(i.x+i.width),m=c-(i.y+i.height),x=i.x,p=i.y):d==="sw"||d=="w"?(b=f-i.x,m=c-(i.y+i.height),x=i.x+i.width,p=i.y):(d==="nw"||d=="n")&&(b=f-i.x,m=c-i.y,x=i.x+i.width,p=i.y+i.height),o=x+n.x+b,r=p+n.y+m}this.evData={startClientX:o,startClientY:r,startCropX:x,startCropY:p,clientX:t.clientX,clientY:t.clientY,isResize:h,ord:d},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),_(this,"onComponentPointerDown",t=>{const{crop:s,disabled:l,locked:n,keepSelection:i,onChange:d}=this.props,h=this.getBox();if(l||n||i&&s)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=t.clientX-h.x,r=t.clientY-h.y,x={unit:"px",x:o,y:r,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:o,startCropY:r,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,d(G(x,h.width,h.height),ie(x,h.width,h.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),_(this,"onDocPointerMove",t=>{const{crop:s,disabled:l,onChange:n,onDragStart:i}=this.props,d=this.getBox();if(l||!s||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,i&&i(t));const{evData:h}=this;h.clientX=t.clientX,h.clientY=t.clientY;let o;h.isResize?o=this.resizeCrop():o=this.dragCrop(),it(s,o)||n(G(o,d.width,d.height),ie(o,d.width,d.height))}),_(this,"onComponentKeyDown",t=>{const{crop:s,disabled:l,onChange:n,onComplete:i}=this.props;if(l)return;const d=t.key;let h=!1;if(!s)return;const o=this.getBox(),r=this.makePixelCrop(o),x=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep;if(d==="ArrowLeft"?(r.x-=x,h=!0):d==="ArrowRight"?(r.x+=x,h=!0):d==="ArrowUp"?(r.y-=x,h=!0):d==="ArrowDown"&&(r.y+=x,h=!0),h){t.cancelable&&t.preventDefault(),r.x=re(r.x,0,o.width-r.width),r.y=re(r.y,0,o.height-r.height);const p=G(r,o.width,o.height),f=ie(r,o.width,o.height);n(p,f),i&&i(p,f)}}),_(this,"onHandlerKeyDown",(t,s)=>{const{aspect:l=0,crop:n,disabled:i,minWidth:d=0,minHeight:h=0,maxWidth:o,maxHeight:r,onChange:x,onComplete:p}=this.props,f=this.getBox();if(i||!n)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const c=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep,b=G(n,f.width,f.height),m=Ps(b,t.key,c,s),N=lt(m,l,s,f.width,f.height,d,h,o,r);if(!it(n,N)){const w=ie(N,f.width,f.height);x(N,w),p&&p(N,w)}}),_(this,"onDocPointerDone",t=>{const{crop:s,disabled:l,onComplete:n,onDragEnd:i}=this.props,d=this.getBox();this.unbindDocMove(),!(l||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,i&&i(t),n&&n(G(s,d.width,d.height),ie(s,d.width,d.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),_(this,"onDragFocus",()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)})}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:s,y:l,width:n,height:i}=t.getBoundingClientRect();return{x:s,y:l,width:n,height:i}}componentDidUpdate(t){const{crop:s,onComplete:l}=this.props;if(l&&!t.crop&&s){const{width:n,height:i}=this.getBox();n&&i&&l(G(s,n,i),ie(s,n,i))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,le),this.document.addEventListener("pointerup",this.onDocPointerDone,le),this.document.addEventListener("pointercancel",this.onDocPointerDone,le),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,le),this.document.removeEventListener("pointerup",this.onDocPointerDone,le),this.document.removeEventListener("pointercancel",this.onDocPointerDone,le),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,s=this.getBox(),l=this.makePixelCrop(s),n=t.clientX-t.startClientX,i=t.clientY-t.startClientY;return l.x=re(t.startCropX+n,0,s.width-l.width),l.y=re(t.startCropY+i,0,s.height-l.height),l}getPointRegion(t,s,l,n){const{evData:i}=this,d=i.clientX-t.x,h=i.clientY-t.y;let o;n&&s?o=s==="nw"||s==="n"||s==="ne":o=h<i.startCropY;let r;return l&&s?r=s==="nw"||s==="w"||s==="sw":r=d<i.startCropX,r?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(t,s,l=0,n=0){const i=Math.min(l,t.width),d=Math.min(n,t.height);return!s||!i&&!d?[i,d]:s>1?i?[i,i/s]:[d*s,d]:d?[d*s,d]:[i,i/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:l,maxHeight:n}=this.props,i=this.getBox(),[d,h]=this.resolveMinDimensions(i,s,this.props.minWidth,this.props.minHeight);let o=this.makePixelCrop(i);const r=this.getPointRegion(i,t.ord,d,h),x=t.ord||r;let p=t.clientX-t.startClientX,f=t.clientY-t.startClientY;(d&&x==="nw"||x==="w"||x==="sw")&&(p=Math.min(p,-d)),(h&&x==="nw"||x==="n"||x==="ne")&&(f=Math.min(f,-h));const c={unit:"px",x:0,y:0,width:0,height:0};r==="ne"?(c.x=t.startCropX,c.width=p,s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(f),c.y=t.startCropY-c.height)):r==="se"?(c.x=t.startCropX,c.y=t.startCropY,c.width=p,s?c.height=c.width/s:c.height=f):r==="sw"?(c.x=t.startCropX+p,c.y=t.startCropY,c.width=Math.abs(p),s?c.height=c.width/s:c.height=f):r==="nw"&&(c.x=t.startCropX+p,c.width=Math.abs(p),s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(f),c.y=t.startCropY+f));const b=lt(c,s,r,i.width,i.height,d,h,l,n);return s||U.xyOrds.indexOf(x)>-1?o=b:U.xOrds.indexOf(x)>-1?(o.x=b.x,o.width=b.width):U.yOrds.indexOf(x)>-1&&(o.y=b.y,o.height=b.height),o.x=re(o.x,0,i.width-o.width),o.y=re(o.y,0,i.height-o.height),o}renderCropSelection(){const{ariaLabels:t=U.defaultProps.ariaLabels,disabled:s,locked:l,renderSelectionAddon:n,ruleOfThirds:i,crop:d}=this.props,h=this.getCropStyle();if(d)return T.createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!l&&T.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},T.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),T.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),T.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),T.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":t.nwDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"nw"),role:"button"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":t.nDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"n"),role:"button"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":t.neDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"ne"),role:"button"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":t.eDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"e"),role:"button"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":t.seDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"se"),role:"button"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":t.sDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"s"),role:"button"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":t.swDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"sw"),role:"button"}),T.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":t.wDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"w"),role:"button"})),n&&T.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:o=>o.stopPropagation()},n(this.state)),i&&T.createElement(T.Fragment,null,T.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),T.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const s={...Te,...this.props.crop||{}};return G(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:l,className:n,crop:i,disabled:d,locked:h,style:o,ruleOfThirds:r}=this.props,{cropIsActive:x,newCropIsBeingDrawn:p}=this.state,f=i?this.renderCropSelection():null,c=$s("ReactCrop",n,x&&"ReactCrop--active",d&&"ReactCrop--disabled",h&&"ReactCrop--locked",p&&"ReactCrop--new-crop",i&&t&&"ReactCrop--fixed-aspect",i&&l&&"ReactCrop--circular-crop",i&&r&&"ReactCrop--rule-of-thirds",!this.dragStarted&&i&&!i.width&&!i.height&&"ReactCrop--invisible-crop",l&&"ReactCrop--no-animate");return T.createElement("div",{ref:this.componentRef,className:c,style:o},T.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},s),i?T.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},T.createElement("defs",null,T.createElement("mask",{id:`hole-${this.instanceId}`},T.createElement("rect",{width:"100%",height:"100%",fill:"white"}),l?T.createElement("ellipse",{cx:`${i.x+i.width/2}${i.unit}`,cy:`${i.y+i.height/2}${i.unit}`,rx:`${i.width/2}${i.unit}`,ry:`${i.height/2}${i.unit}`,fill:"black"}):T.createElement("rect",{x:`${i.x}${i.unit}`,y:`${i.y}${i.unit}`,width:`${i.width}${i.unit}`,height:`${i.height}${i.unit}`,fill:"black"}))),T.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,f)}};_(Z,"xOrds",["e","w"]),_(Z,"yOrds",["n","s"]),_(Z,"xyOrds",["nw","ne","se","sw"]),_(Z,"nudgeStep",1),_(Z,"nudgeStepMedium",10),_(Z,"nudgeStepLarge",100),_(Z,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let Us=Z;const Ls=[{label:"Free",value:""},{label:"1:1 Square",value:"1"},{label:"4:3",value:"4/3"},{label:"3:2",value:"3/2"},{label:"16:9",value:"16/9"},{label:"2:3",value:"2/3"},{label:"3:4",value:"3/4"}],mt=[{label:"Original",value:"",ext:""},{label:"JPEG",value:"jpeg",ext:".jpg"},{label:"PNG",value:"png",ext:".png"},{label:"WebP",value:"webp",ext:".webp"},{label:"AVIF",value:"avif",ext:".avif"}],Hs={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function ze(a,t){return a?mt.find(s=>s.value===a)?.ext||`.${a}`:Hs[t]||".jpg"}function Xs(a,t){const s=a.lastIndexOf(".");return(s>0?a.substring(0,s):a)+t}function Ys({host:a,media:t,onClose:s,onSaved:l}){const n=g.useRef(null),[i,d]=g.useState(),[h,o]=g.useState(),[r,x]=g.useState(""),[p,f]=g.useState(""),[c,b]=g.useState(""),[m,N]=g.useState(""),[w,S]=g.useState("80"),[R,A]=g.useState(()=>{const y=ze("",t.mimeType),M=t.filename.lastIndexOf(".");return`${M>0?t.filename.substring(0,M):t.filename}-transformed${y}`});function F(y){const M=y==="__original__"?"":y;N(M);const q=ze(M,t.mimeType);A(ae=>Xs(ae,q))}const z=Tt(a,t.mediaId),[j,v]=g.useState(null),$=g.useCallback(()=>{if(!h||!j)return null;const y=(t.width??j.width)/j.width,M=(t.height??j.height)/j.height;return{cropX:Math.round(h.x*y),cropY:Math.round(h.y*M),cropW:Math.round(h.width*y),cropH:Math.round(h.height*M)}},[h,t.width,t.height,j]),B=g.useMemo(()=>$(),[$]);async function se(){const y=B,M=p?parseInt(p):void 0,q=c?parseInt(c):void 0;if(!y&&!M&&!q&&!m){I.error("Please specify a crop, resize, or format change");return}if(!R.trim()){I.error("Filename is required");return}const ae=ze(m,t.mimeType);if(!R.trim().toLowerCase().endsWith(ae)){I.error(`Filename must end with ${ae} to match the output format`);return}try{const ne=await z.mutateAsync({...y??{},...M?{width:M}:{},...q?{height:q}:{},...m?{format:m}:{},...w?{quality:parseInt(w)}:{},filename:R.trim()});I.success("Transform saved as new media"),l?.(ne),s()}catch(ne){I.error("Transform failed",{description:ne instanceof Error?ne.message:void 0})}}function xe(y){x(y==="__free__"?"":y),d(void 0),o(void 0)}function V(y){if(!y)return;const M=y.split("/");return M.length===2?Number(M[0])/Number(M[1]):Number(y)||void 0}const Ge=V(r);return e.jsx(oe,{open:!0,onOpenChange:()=>s(),children:e.jsxs(ce,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(de,{children:[e.jsx(he,{children:"Transform Image"}),e.jsx(ue,{className:"sr-only",children:"Crop, resize, or convert image format"})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_280px] gap-6",children:[e.jsx("div",{className:"min-h-0 overflow-hidden rounded border bg-muted/30 flex items-center justify-center",children:e.jsx(Us,{crop:i,onChange:y=>d(y),onComplete:y=>o(y),aspect:Ge,children:e.jsx("img",{ref:n,src:W(t.url),alt:t.alt||t.filename,className:"max-h-[60vh] max-w-full object-contain",onLoad:y=>{const M=y.currentTarget;v({width:M.naturalWidth,height:M.naturalHeight})}})})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:["Original: ",t.width,"×",t.height]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Crop aspect ratio"}),e.jsxs(fe,{value:r||"__free__",onValueChange:xe,children:[e.jsx(we,{children:e.jsx(je,{placeholder:"Free"})}),e.jsx(ve,{children:Ls.map(y=>e.jsx(te,{value:y.value||"__free__",children:y.label},y.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",B?.cropW,"×",B?.cropH," at (",B?.cropX,", ",B?.cropY,")"]}),h&&e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>{d(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Resize (optional)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Width",value:p,onChange:y=>f(y.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Height",value:c,onChange:y=>b(y.target.value),min:1,max:2048})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Output format"}),e.jsxs(fe,{value:m||"__original__",onValueChange:F,children:[e.jsx(we,{children:e.jsx(je,{placeholder:"Original"})}),e.jsx(ve,{children:mt.map(y=>e.jsx(te,{value:y.value||"__original__",children:y.label},y.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Quality (1-100)"}),e.jsx(K,{type:"number",value:w,onChange:y=>S(y.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Save as filename"}),e.jsx(K,{value:R,onChange:y=>A(y.target.value)})]})]})]}),e.jsxs(me,{children:[e.jsx(D,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(D,{onClick:se,disabled:z.isPending,children:[z.isPending&&e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as New Image"]})]})]})})}const Bs=new Set(["image/jpeg","image/png","image/gif","image/webp","image/avif","image/tiff"]);function Ks({host:a,media:t,onClose:s,onDeleted:l,folders:n,tagSuggestions:i}){const[d,h]=g.useState(t.alt??""),[o,r]=g.useState(t.caption??""),[x,p]=g.useState(t.userTags??[]),[f,c]=g.useState(t.folderId||"__none__"),[b,m]=g.useState(!1),N=Bs.has(t.mimeType),w=It(a,t.mediaId),S=Mt(a,t.mediaId),{data:R,isLoading:A}=Rt(a,t.mediaId),F=t.tags.filter(v=>!t.userTags?.includes(v));async function z(){try{await w.mutateAsync({alt:d,caption:o,userTags:x,folderId:f==="__none__"?"":f}),I.success("Media updated"),s()}catch(v){I.error("Failed to update",{description:v instanceof Error?v.message:void 0})}}async function j(){try{await S.mutateAsync(),I.success("Media deleted"),l?.(t.mediaId),s()}catch(v){I.error("Failed to delete",{description:v instanceof Error?v.message:void 0})}}return e.jsxs(oe,{open:!0,onOpenChange:()=>s(),children:[e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsx(he,{children:t.filename}),e.jsx(ue,{className:"sr-only",children:"View and edit media details"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:[t.mimeType," · ",ye(t.size),t.width&&t.height&&` · ${t.width}×${t.height}`," · ",He(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[N&&e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[e.jsx(Bt,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),I.success("URL copied to clipboard")},children:[e.jsx(Oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),F.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(L,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:F.map(v=>e.jsx(Ue,{variant:"outline",className:"text-xs",children:v},v))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Tags"}),e.jsx(Pe,{tags:x,onChange:p,placeholder:"Add tags...",suggestions:i})]}),n&&n.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{children:"Folder"}),e.jsxs(fe,{value:f,onValueChange:c,children:[e.jsx(we,{children:e.jsx(je,{placeholder:"No folder"})}),e.jsxs(ve,{children:[e.jsx(te,{value:"__none__",children:"No folder"}),n.map(v=>e.jsx(te,{value:v.folderId,children:v.name},v.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"alt",children:"Alt text"}),e.jsx(K,{id:"alt",value:d,onChange:v=>h(v.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"caption",children:"Caption"}),e.jsx(K,{id:"caption",value:o,onChange:v=>r(v.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{className:"text-xs text-muted-foreground",children:"Used in"}),A?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(J,{className:"h-3.5 w-3.5 animate-spin"}),"Checking usage..."]}):R?.references.length?e.jsxs("div",{className:"space-y-1",children:[R.references.map(v=>e.jsxs(Dt,{to:`/sites/${a}/content/${v.collection}/${v.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:v.title||v.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",v.collection,")"]})]},v.contentId)),R.note&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:R.note})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Not referenced in any content."})]})]}),e.jsxs(me,{className:"flex justify-between",children:[e.jsxs(Xe,{children:[e.jsx(Ms,{asChild:!0,children:e.jsxs(D,{variant:"destructive",size:"sm",children:[e.jsx(Kt,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(Ye,{children:[e.jsxs(Be,{children:[e.jsx(Ke,{children:"Delete media?"}),e.jsxs(We,{children:["This will permanently delete “",t.filename,"”. This action cannot be undone."]})]}),e.jsxs(Ve,{children:[e.jsx(qe,{children:"Cancel"}),e.jsx(Qe,{onClick:j,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(D,{onClick:z,children:"Save"})]})]})]}),b&&e.jsx(Ys,{host:a,media:t,onClose:()=>m(!1),onSaved:()=>s()})]})}function Ws({tags:a,activeTag:t,onTagChange:s}){return a.length===0?null:e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-1.5",children:[a.map(l=>e.jsx(Ue,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(D,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s(void 0),children:[e.jsx(ge,{className:"mr-1 h-3 w-3"}),"Clear"]})]})}function $e({id:a,children:t}){const{setNodeRef:s,isOver:l}=ys({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function ot({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=ct(a),n=_t(a),i=At(a),d=Et(a),[h,o]=g.useState(!1),[r,x]=g.useState(""),[p,f]=g.useState(null),[c,b]=g.useState(""),[m,N]=g.useState(null),w=g.useRef(null),S=g.useRef(null),R=l?.items??[];g.useEffect(()=>{h&&w.current?.focus()},[h]),g.useEffect(()=>{p&&S.current?.focus()},[p]);async function A(){const j=r.trim();if(!j){o(!1),x("");return}try{await n.mutateAsync(j),I.success("Folder created")}catch(v){I.error("Failed to create folder",{description:v instanceof Error?v.message:void 0})}o(!1),x("")}async function F(j){const v=c.trim();if(!v){f(null);return}try{await i.mutateAsync({folderId:j,name:v}),I.success("Folder renamed")}catch($){I.error("Failed to rename folder",{description:$ instanceof Error?$.message:void 0})}f(null)}async function z(){if(m){try{await d.mutateAsync(m.folderId),I.success("Folder deleted"),t===m.folderId&&s(null)}catch(j){I.error("Failed to delete folder",{description:j instanceof Error?j.message:void 0})}N(null)}}return e.jsxs("div",{className:"flex w-48 shrink-0 flex-col border-r",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Folders"}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(Wt,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[e.jsx($e,{id:"all-media",children:j=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t===null&&"bg-accent font-medium",j&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s(null),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-4 w-4"}),"All Media"]})})}),R.map(j=>e.jsx($e,{id:j.folderId,children:v=>e.jsx("div",{className:P("group flex w-full items-center justify-between px-3 py-1.5 text-sm hover:bg-accent/50",t===j.folderId&&"bg-accent font-medium",v&&"ring-2 ring-primary bg-primary/10"),children:p===j.folderId?e.jsx(K,{ref:S,value:c,onChange:$=>b($.target.value),onKeyDown:$=>{$.key==="Enter"&&F(j.folderId),$.key==="Escape"&&f(null)},onBlur:()=>F(j.folderId),className:"h-6 text-sm"}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"flex flex-1 items-center gap-2 text-left",onClick:()=>s(j.folderId),children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:j.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:j.count}),e.jsxs(Vt,{children:[e.jsx(qt,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100",children:e.jsx(Qt,{className:"h-3.5 w-3.5"})})}),e.jsxs(Gt,{align:"end",children:[e.jsx(nt,{onClick:()=>{f(j.folderId),b(j.name)},children:"Rename"}),e.jsx(nt,{disabled:j.count>0,onClick:()=>N(j),children:"Delete"})]})]})]})]})})},j.folderId)),e.jsx($e,{id:"unfiled",children:j=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t==="unfiled"&&"bg-accent font-medium",j&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s("unfiled"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(K,{ref:w,value:r,onChange:j=>x(j.target.value),onKeyDown:j=>{j.key==="Enter"&&A(),j.key==="Escape"&&(o(!1),x(""))},onBlur:A,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(Xe,{open:!!m,onOpenChange:()=>N(null),children:e.jsxs(Ye,{children:[e.jsxs(Be,{children:[e.jsx(Ke,{children:"Delete folder?"}),e.jsxs(We,{children:["This will delete the folder “",m?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(Ve,{children:[e.jsx(qe,{children:"Cancel"}),e.jsx(Qe,{onClick:z,children:"Delete"})]})]})})]})}function Vs({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:i,onClear:d,isPending:h}){const[o,r]=g.useState(null),[x,p]=g.useState(""),[f,c]=g.useState([]);function b(){r(null),p(""),c([])}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 min-w-0",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:[a," selected"]}),e.jsx(D,{size:"sm",variant:"ghost",onClick:d,disabled:h,children:e.jsx(ge,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto rounded-md border bg-muted/50 px-3 py-2 max-w-[calc(100vw-1.5rem)]",children:[e.jsx(D,{size:"sm",variant:"destructive",onClick:()=>r("delete"),disabled:h,className:"shrink-0",children:"Delete"}),e.jsx(D,{size:"sm",variant:"outline",onClick:()=>r("move"),disabled:h,className:"shrink-0",children:"Move to…"}),e.jsx(D,{size:"sm",variant:"outline",onClick:()=>r("addTags"),disabled:h,className:"shrink-0",children:"Add tags"}),e.jsx(D,{size:"sm",variant:"outline",onClick:()=>r("removeTags"),disabled:h,className:"shrink-0",children:"Remove tags"})]})]}),e.jsx(oe,{open:o==="delete",onOpenChange:m=>!m&&b(),children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsxs(he,{children:["Delete ",a," item",a!==1?"s":"","?"]}),e.jsx(ue,{children:"This action cannot be undone. The selected media items will be permanently deleted."})]}),e.jsxs(me,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{variant:"destructive",onClick:async()=>{b(),await s()},disabled:h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(oe,{open:o==="move",onOpenChange:m=>!m&&b(),children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsxs(he,{children:["Move ",a," item",a!==1?"s":""]}),e.jsx(ue,{children:"Choose a destination folder."})]}),e.jsxs(fe,{value:x,onValueChange:p,children:[e.jsx(we,{children:e.jsx(je,{placeholder:"Select folder..."})}),e.jsxs(ve,{children:[e.jsx(te,{value:"__unfiled__",children:"Unfiled"}),t.map(m=>e.jsx(te,{value:m.folderId,children:m.name},m.folderId))]})]}),e.jsxs(me,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{onClick:async()=>{const m=x==="__unfiled__"?"":x;b(),await l(m)},disabled:!x||h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(oe,{open:o==="addTags",onOpenChange:m=>!m&&b(),children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsxs(he,{children:["Add tags to ",a," item",a!==1?"s":""]}),e.jsx(ue,{className:"sr-only",children:"Select tags to add to the selected items"})]}),e.jsx(Pe,{tags:f,onChange:c,placeholder:"Add tags..."}),e.jsxs(me,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{onClick:async()=>{const m=[...f];b(),await n(m)},disabled:f.length===0||h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(oe,{open:o==="removeTags",onOpenChange:m=>!m&&b(),children:e.jsxs(ce,{children:[e.jsxs(de,{children:[e.jsxs(he,{children:["Remove tags from ",a," item",a!==1?"s":""]}),e.jsx(ue,{className:"sr-only",children:"Select tags to remove from the selected items"})]}),e.jsx(Pe,{tags:f,onChange:c,placeholder:"Tags to remove..."}),e.jsxs(me,{children:[e.jsx(D,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(D,{onClick:async()=>{const m=[...f];b(),await i(m)},disabled:f.length===0||h,children:[h&&e.jsx(J,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function qs({onFiles:a,children:t}){const[s,l]=g.useState(!1),n=g.useRef(0),i=g.useCallback(r=>{r.preventDefault(),r.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),d=g.useCallback(r=>{r.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=g.useCallback(r=>{r.preventDefault(),r.dataTransfer.dropEffect="copy"},[]),o=g.useCallback(r=>{r.preventDefault(),n.current=0,l(!1);const x=Array.from(r.dataTransfer.files);x.length>0&&a(x)},[a]);return e.jsxs("div",{className:"relative flex-1",onDragEnter:i,onDragLeave:d,onDragOver:h,onDrop:o,children:[t,s&&e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-primary/5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg bg-background/90 px-6 py-4 shadow-lg",children:[e.jsx(pe,{className:"h-8 w-8 text-primary"}),e.jsx("p",{className:"text-lg font-medium",children:"Drop files to upload"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Files will be uploaded to the current folder"})]})})]})}function Qs({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[i,d]=g.useState(!1),h=t.filter(c=>c.status==="uploading").length,o=t.filter(c=>c.status==="pending").length,r=t.filter(c=>c.status==="complete").length,x=t.filter(c=>c.status==="error").length,p=h===0&&o===0;if(g.useEffect(()=>{if(p&&t.length>0){const c=setTimeout(()=>d(!0),2e3);return()=>clearTimeout(c)}},[p,t.length]),t.length===0)return null;const f=p?`${r} uploaded${x?`, ${x} failed`:""}`:`Uploading ${h+o} file${h+o!==1?"s":""}`;return e.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-80 rounded-lg border bg-background shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:f}),e.jsxs("div",{className:"flex items-center gap-1",children:[p&&e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>d(!i),children:i?e.jsx(Zt,{className:"h-4 w-4"}):e.jsx(Jt,{className:"h-4 w-4"})})]})]}),!i&&e.jsx("div",{className:"max-h-60 overflow-y-auto",children:t.map(c=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm",children:[c.status==="uploading"&&e.jsx(J,{className:"h-4 w-4 shrink-0 animate-spin"}),c.status==="complete"&&e.jsx(es,{className:"h-4 w-4 shrink-0 text-green-500"}),c.status==="error"&&e.jsx(ge,{className:"h-4 w-4 shrink-0 text-destructive"}),c.status==="pending"&&e.jsx("div",{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate",children:c.file.name}),c.status==="uploading"&&e.jsx("div",{className:"bg-muted mt-0.5 h-1 w-full rounded-full",children:e.jsx("div",{className:"bg-primary h-full rounded-full transition-all",style:{width:`${c.progress}%`}})}),c.status==="error"&&e.jsx("p",{className:"text-destructive truncate text-xs",children:c.error})]}),c.status==="error"&&e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(c.id),children:e.jsx(ts,{className:"h-3 w-3"})}),(c.status==="complete"||c.status==="error")&&e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>l(c.id),children:e.jsx(ge,{className:"h-3 w-3"})})]},c.id))})]})}const Gs=3;let Zs=0;function Js(a,t){const[s,l]=g.useState([]),n=Ft(a),i=zt(a),d=g.useRef(0),h=g.useRef(s);h.current=s;const o=g.useRef(new Map),r=g.useCallback(async m=>{d.current++,l(N=>N.map(w=>w.id===m.id?{...w,status:"uploading",progress:0}:w));try{const{uploadUrl:N,mediaId:w}=await n.mutateAsync({filename:m.file.name,contentType:m.file.type,size:m.file.size});await new Promise((S,R)=>{const A=new XMLHttpRequest;o.current.set(m.id,A),A.upload.onprogress=F=>{if(F.lengthComputable){const z=Math.round(F.loaded/F.total*100);l(j=>j.map(v=>v.id===m.id?{...v,progress:z}:v))}},A.onload=()=>{o.current.delete(m.id),A.status>=200&&A.status<300?S():R(new Error(`Upload failed: ${A.status}`))},A.onerror=()=>{o.current.delete(m.id),R(new Error("Network error"))},A.onabort=()=>{o.current.delete(m.id),R(new Error("Upload aborted"))},A.open("PUT",N),A.setRequestHeader("Content-Type",m.file.type),A.send(m.file)}),await i.mutateAsync({mediaId:w,filename:m.file.name,folderId:m.folderId}),l(S=>S.map(R=>R.id===m.id?{...R,status:"complete",progress:100}:R))}catch(N){l(w=>w.map(S=>S.id===m.id?{...S,status:"error",error:N instanceof Error?N.message:"Upload failed"}:S))}finally{d.current--}},[n,i]),x=g.useRef(r);x.current=r,g.useEffect(()=>{const m=s.filter(w=>w.status==="pending"),N=Gs-d.current;for(let w=0;w<Math.min(m.length,N);w++)x.current(m[w])},[s]),g.useEffect(()=>{const m=o.current;return()=>{m.forEach(N=>N.abort())}},[]);const p=g.useCallback(m=>{const N=Array.from(m).map(w=>({id:`upload-${Zs++}`,file:w,folderId:t||void 0,status:"pending",progress:0}));l(w=>[...w,...N])},[t]),f=g.useCallback(m=>{l(N=>N.map(w=>w.id===m?{...w,status:"pending",progress:0,error:void 0}:w))},[]),c=g.useCallback(m=>{l(N=>N.filter(w=>w.id!==m))},[]),b=g.useCallback(()=>{l(m=>m.filter(N=>N.status!=="complete"&&N.status!=="error"))},[]);return{items:s,addFiles:p,retry:f,dismiss:c,clearCompleted:b}}function ea({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],i=t>0,d=t<a.length-1,h=g.useRef(null),o=g.useCallback(r=>{r.key==="Escape"?s():r.key==="ArrowLeft"&&i?l(t-1):r.key==="ArrowRight"&&d&&l(t+1)},[s,l,t,i,d]);return g.useEffect(()=>(document.addEventListener("keydown",o),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",o),document.body.style.overflow=""}),[o]),n?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/90",onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 pt-[max(0.75rem,env(safe-area-inset-top,0px))] pl-[max(1rem,env(safe-area-inset-left,0px))] pr-[max(1rem,env(safe-area-inset-right,0px))] text-white",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"min-w-0 flex-1 text-sm",children:[e.jsx("span",{className:"font-medium truncate block",children:n.filename}),e.jsxs("span",{className:"opacity-70 text-xs",children:[n.width&&n.height&&`${n.width}×${n.height} · `,ye(n.size)]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("span",{className:"text-sm opacity-70",children:[t+1," / ",a.length]}),e.jsx(D,{variant:"ghost",size:"icon",className:"text-white hover:bg-white/20",onClick:s,children:e.jsx(ge,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative flex min-h-0 flex-1 items-center justify-center px-4 md:px-16",onClick:r=>r.stopPropagation(),onTouchStart:r=>{h.current=r.touches[0].clientX},onTouchEnd:r=>{if(h.current===null)return;const x=r.changedTouches[0].clientX-h.current;h.current=null,x>50&&i?l(t-1):x<-50&&d&&l(t+1)},children:[e.jsx("img",{src:W(n.url),alt:n.alt||n.filename,className:"max-h-full max-w-full object-contain"}),i&&e.jsx(D,{variant:"ghost",size:"icon",className:"absolute left-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t-1),children:e.jsx(ss,{className:"h-8 w-8"})}),d&&e.jsx(D,{variant:"ghost",size:"icon",className:"absolute right-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t+1),children:e.jsx(as,{className:"h-8 w-8"})})]})]}):null}function ta({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(Xe,{open:a,onOpenChange:i=>!i&&n(),children:e.jsxs(Ye,{children:[e.jsxs(Be,{children:[e.jsx(Ke,{children:"Possible duplicates found"}),e.jsx(We,{children:s===1?"A file with the same name and size already exists:":`${t.length} of ${s} files may already exist:`})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:t.map(i=>e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[i.mimeType.startsWith("image/")&&i.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(i.urls?.thumb_sm??i.url),alt:i.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:i.mimeType,className:"h-6 w-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:i.filename}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[ye(i.size)," ·"," ",Le(i.uploadedAt)]})]})]},i.mediaId))}),e.jsxs(Ve,{children:[e.jsx(qe,{onClick:n,children:"Cancel"}),e.jsx(Qe,{onClick:l,children:"Upload Anyway"})]})]})})}const sa=({activatorEvent:a,draggingNodeRect:t,transform:s})=>{if(a&&t){const l=a;if(l.clientX!==void 0)return{...s,x:s.x+l.clientX-t.left-t.width/2,y:s.y+l.clientY-t.top-t.height/2}}return s},aa=[{value:"date_desc",label:"Newest first"},{value:"date_asc",label:"Oldest first"},{value:"name_asc",label:"Name A-Z"},{value:"name_desc",label:"Name Z-A"},{value:"size_desc",label:"Size (largest)"},{value:"size_asc",label:"Size (smallest)"}];function na({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:i}){const{attributes:d,listeners:h,setNodeRef:o,isDragging:r}=ht({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function p(f){f.stopPropagation(),navigator.clipboard.writeText(W(a.url)),I.success("URL copied to clipboard")}return e.jsx(ms,{ref:o,...d,...h,className:P("group relative cursor-pointer overflow-hidden",r&&"opacity-50",t&&"ring-2 ring-primary"),onClick:l,children:e.jsxs(xs,{className:"p-0",children:[e.jsx("div",{className:P("absolute left-2 top-2 z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:rounded [@media(hover:none)]:bg-black/30 [@media(hover:none)]:p-0.5",t&&"opacity-100"),onPointerDown:f=>f.stopPropagation(),onClick:f=>f.stopPropagation(),children:e.jsx(Ie,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100",onPointerDown:f=>f.stopPropagation(),onClick:f=>f.stopPropagation(),children:[e.jsx(Ne,{children:e.jsxs(De,{children:[e.jsx(ke,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:p,children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})}),e.jsx(Se,{children:"Copy URL"})]})}),x&&i&&e.jsx(Ne,{children:e.jsxs(De,{children:[e.jsx(ke,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:f=>{f.stopPropagation(),i()},children:e.jsx(us,{className:"h-3.5 w-3.5"})})}),e.jsx(Se,{children:"View full size"})]})})]}),x?e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx("img",{src:W(a.urls?.thumb_md??a.url),alt:a.alt||a.filename,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-12 w-12"})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a.filename}),n&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ee,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate text-xs",children:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:ye(a.size)}),e.jsx(Ne,{children:e.jsxs(De,{children:[e.jsx(ke,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Le(a.uploadedAt)})}),e.jsx(Se,{children:He(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(f=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-0.5 text-[10px]",children:f},f)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})]})]})})}function va(){const{host:a}=kt(),t=ns(),[s,l]=St([{key:"tag",defaultValue:""},{key:"folder",defaultValue:""},{key:"q",defaultValue:""},{key:"sort",defaultValue:"date_desc"},{key:"view",defaultValue:"grid"}]),n=s.view,i=u=>l({view:u}),d=s.sort,h=u=>l({sort:u}),o=s.tag||void 0,r=s.folder===""?null:s.folder,x=u=>l({folder:u??""}),[p,f]=g.useState(s.q),[c,b]=g.useState(s.q),[m,N]=g.useState(null),[w,S]=g.useState(new Set),[R,A]=g.useState(null),[F,z]=g.useState(null),[j,v]=g.useState(null),[$,B]=g.useState([]),[se,xe]=g.useState(!1),V=g.useRef(null);Rs({title:"Media",actions:e.jsx(D,{size:"sm",onClick:()=>V.current?.click(),children:e.jsx(pe,{className:"h-4 w-4"})})});const y=Js(a,r&&r!=="unfiled"?r:void 0),M=$t(a),q=Pt(a),ae=bs(Cs(ks,{activationConstraint:{distance:t?1e5:8}}));g.useEffect(()=>{const u=setTimeout(()=>{b(C=>{const k=p;return C!==k&&(S(new Set),l({q:k})),k})},300);return()=>clearTimeout(u)},[p,l]);const ne=r===null?void 0:r==="unfiled"?"":r,{data:O,isLoading:xt}=Ot(a,{sort:d,q:c||void 0,folderId:ne,tag:o}),{data:Ze}=ct(a),be=g.useMemo(()=>Ze?.items??[],[Ze?.items]),Re=g.useMemo(()=>{const u=new Map;for(const C of be)u.set(C.folderId,C.name);return u},[be]),Ce=g.useMemo(()=>(O?.items??[]).filter(u=>u.mimeType.startsWith("image/")&&u.mimeType!=="image/svg+xml"),[O?.items]),_e=g.useMemo(()=>{const u=new Map;return Ce.forEach((C,k)=>u.set(C.mediaId,k)),u},[Ce]),{allTags:pt,allUserTags:gt}=g.useMemo(()=>{const u=O?.items??[],C=new Set,k=new Set;for(const E of u){for(const H of E.tags)C.add(H);for(const H of E.userTags??[])k.add(H)}return{allTags:Array.from(C).sort(),allUserTags:Array.from(k).sort()}},[O?.items]),Ae=O?.items.map(u=>u.mediaId)??[],Ee=Ae.length>0&&Ae.every(u=>w.has(u));function Je(u){S(C=>{const k=new Set(C);return k.has(u)?k.delete(u):k.add(u),k})}function et(){S(Ee?new Set:new Set(Ae))}async function ft(){const u=[...w],k=(await M.mutateAsync({mediaIds:u,action:"delete"})).failed.length;k?I.error(`${k} of ${u.length} failed to delete`):I.success(`${u.length} item(s) deleted`),S(new Set)}async function wt(u){const C=[...w],E=(await M.mutateAsync({mediaIds:C,action:"move",folderId:u})).failed.length;E?I.error(`${E} of ${C.length} failed to move`):I.success(`${C.length} item(s) moved`),S(new Set)}async function jt(u){const C=[...w],E=(await M.mutateAsync({mediaIds:C,action:"addTags",tags:u})).failed.length;E?I.error(`${E} of ${C.length} failed`):I.success(`Tags added to ${C.length} item(s)`),S(new Set)}async function vt(u){const C=[...w],E=(await M.mutateAsync({mediaIds:C,action:"removeTags",tags:u})).failed.length;E?I.error(`${E} of ${C.length} failed`):I.success(`Tags removed from ${C.length} item(s)`),S(new Set)}async function tt(u){const C=Array.from(u),k=C.slice(0,5),E=[];for(const H of k)try{const Fe=await q.mutateAsync({filename:H.name,size:H.size});E.push(...Fe.duplicates)}catch{}E.length>0?(v(C),B(E)):y.addFiles(C)}function yt(u){u.target.files&&tt(u.target.files),V.current&&(V.current.value="")}function bt(u){A(String(u.active.id))}function Ct(u){A(null);const{active:C,over:k}=u;if(!k||k.data.current?.type!=="folder")return;const E=k.id==="unfiled"||k.id==="all-media"?"":String(k.id),H=w.has(String(C.id))?[...w]:[String(C.id)];M.mutateAsync({mediaIds:H,action:"move",folderId:E}).then(Fe=>{const at=Fe.failed.length;at?I.error(`${at} of ${H.length} failed to move`):I.success(`${H.length} item(s) moved`)})}function Nt(){A(null)}const Q=R?O?.items.find(u=>u.mediaId===R):null,st=R&&w.has(R)?w.size:1;return e.jsxs(Ns,{sensors:ae,modifiers:[sa],onDragStart:bt,onDragEnd:Ct,onDragCancel:Nt,children:[e.jsxs("div",{className:"-m-2 md:-m-6 relative flex min-h-[calc(100dvh-3.5rem)] md:h-[calc(100vh-3.5rem)]",children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(ot,{host:a,selectedFolderId:r,onSelect:u=>{x(u),S(new Set)}})}),e.jsx(rs,{open:se,onOpenChange:xe,children:e.jsxs(is,{side:"left",className:"w-64 p-0 pt-[env(safe-area-inset-top,0px)] pl-[env(safe-area-inset-left,0px)] [&_[data-slot=sheet-close]]:top-[calc(1rem+env(safe-area-inset-top,0px))]","data-testid":"folder-overlay-backdrop",children:[e.jsx(ls,{className:"sr-only",children:"Folders"}),e.jsx(ot,{host:a,selectedFolderId:r,onSelect:u=>{x(u),S(new Set),xe(!1)}})]})}),e.jsxs(qs,{onFiles:u=>tt(u),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 md:p-6",children:[!t&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Media"}),e.jsx("div",{children:e.jsxs(D,{onClick:()=>V.current?.click(),children:[e.jsx(pe,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),e.jsx("input",{ref:V,type:"file",multiple:!0,className:"hidden",onChange:yt}),w.size>0?e.jsx(Vs,{selectedCount:w.size,folders:be,onDelete:ft,onMove:wt,onAddTags:jt,onRemoveTags:vt,onClear:()=>S(new Set),isPending:M.isPending}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative min-w-[200px] max-w-sm flex-1",children:[e.jsx(rt,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(K,{placeholder:"Search media...",value:p,onChange:u=>f(u.target.value),className:"pl-9"})]}),e.jsxs(fe,{value:d,onValueChange:h,children:[e.jsx(we,{className:"w-[160px]",children:e.jsx(je,{})}),e.jsx(ve,{children:aa.map(u=>e.jsx(te,{value:u.value,children:u.label},u.value))})]}),e.jsx(D,{variant:se?"secondary":"ghost",size:"sm",className:"md:hidden px-2",onClick:()=>xe(!se),"aria-label":"Toggle folders",children:e.jsx(os,{className:"h-4 w-4"})}),!se&&r!==null&&t&&e.jsxs(Ue,{variant:"secondary",className:"gap-1 md:hidden",children:[e.jsx(ee,{className:"h-3 w-3"}),r==="unfiled"?"Unfiled":Re.get(r)??"All Media"]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(D,{variant:n==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>i("grid"),children:e.jsx(cs,{className:"h-4 w-4"})}),e.jsx(D,{variant:n==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>i("list"),children:e.jsx(ds,{className:"h-4 w-4"})})]})]}),e.jsx(Ws,{tags:pt,activeTag:o,onTagChange:u=>{l({tag:u??""}),S(new Set)}}),n==="grid"&&(O?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Ie,{checked:Ee,onCheckedChange:et,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:w.size>0?`${w.size} of ${O.items.length} selected`:"Select all"})]}),xt?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6",children:Array.from({length:8}).map((u,C)=>e.jsx(hs,{className:"aspect-square"},C))}):O?.items.length?n==="list"?e.jsx(Es,{items:O.items,host:a,onSelect:N,selectedIds:w,onToggle:Je,onToggleAll:et,allSelected:Ee,folderMap:r===null?Re:void 0,onLightbox:u=>{const C=_e.get(u.mediaId);C!==void 0&&z(C)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6",children:O.items.map(u=>e.jsx(na,{item:u,selected:w.has(u.mediaId),onToggle:()=>Je(u.mediaId),onClick:()=>N(u),folderName:r===null?Re.get(u.folderId??""):void 0,onLightbox:_e.has(u.mediaId)?()=>z(_e.get(u.mediaId)):void 0},u.mediaId))}):e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:c||o?e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No results found"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Try adjusting your search or filters."})]}):r==="unfiled"?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No unfiled media"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"All media items are organized in folders."})]}):r?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"This folder is empty"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload files or drag media into this folder."})]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No media yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload your first file to get started."}),e.jsxs(D,{className:"mt-4",onClick:()=>V.current?.click(),children:[e.jsx(pe,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),m&&e.jsx(Ks,{host:a,media:m,onClose:()=>N(null),onDeleted:u=>{S(C=>{if(!C.has(u))return C;const k=new Set(C);return k.delete(u),k})},folders:be,tagSuggestions:gt})]}),e.jsx(Qs,{queue:y})]})]}),F!==null&&Ce.length>0&&e.jsx(ea,{items:Ce,currentIndex:F,host:a,onClose:()=>z(null),onNavigate:z}),e.jsx(ta,{open:$.length>0,host:a,duplicates:$,fileCount:j?Array.from(j).length:0,onContinue:()=>{j&&y.addFiles(j),v(null),B([])},onCancel:()=>{v(null),B([])}}),e.jsx(Ds,{children:R&&Q&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-background p-2 shadow-lg",children:[Q.mimeType.startsWith("image/")&&Q.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(Q.urls?.thumb_sm??Q.url),alt:Q.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:st>1?`Moving ${st} items`:Q.filename})]})})]})}export{va as MediaPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as b,u as B}from"./react-vendor-C2CvUxFh.js";import{C as L,u as w,a as P,P as R,D as k,c as O}from"./core.esm-B_kcYf6n.js";import{u as M,S as D,v as F,a as E}from"./sortable.esm-QyXA6fio.js";import{R as V,aa as f,j as C,B as h,X as y,P as z}from"./index-wYNPRVrc.js";import{C as A,a as G,b as Q,c as _}from"./card-10FqkZPA.js";import{P as q,a as H,b as X}from"./popover-BJDj8C6y.js";import{C as J,a as K,b as U,c as W,d as Y,e as Z}from"./command-BeacdV75.js";import{u as $}from"./useContentSearch-B-_p0_QX.js";import{u as ee}from"./useDebouncedValue-C-cQUcLG.js";function pe({field:i,value:t,onChange:a}){const{host:o}=B(),s=i.options,c=!!s?.multiple,d=s?.collections;return c?e.jsx(ne,{host:o,collections:d,value:t??[],onChange:a}):e.jsx(te,{host:o,collections:d,value:t,onChange:a})}function te({host:i,collections:t,value:a,onChange:o}){const[s,c]=b.useState(!1),d=a?[a.contentId]:[];function r(x){o(x),c(!1)}return e.jsx("div",{children:a?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[e.jsx(f,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:a.title}),e.jsx(C,{variant:"secondary",children:a.collection}),e.jsx(h,{type:"button",variant:"ghost",size:"sm",onClick:()=>o(null),children:e.jsx(y,{className:"h-3 w-3"})})]}):e.jsx(N,{host:i,collections:t,selectedIds:d,open:s,onOpenChange:c,onSelect:r,trigger:e.jsxs(h,{type:"button",variant:"outline",children:[e.jsx(f,{className:"mr-2 h-4 w-4"}),"Select Content"]})})})}function ne({host:i,collections:t,value:a,onChange:o}){const s=w(P(R)),[c,d]=b.useState(!1),r=a??[],x=r.map(n=>n.contentId),g=r.map(n=>n.contentId);function p(n){o([...r,n]),d(!1)}function I(n){o(r.filter((m,u)=>u!==n))}function l(n){const{active:m,over:u}=n;if(u&&m.id!==u.id){const S=r.findIndex(v=>v.contentId===String(m.id)),j=r.findIndex(v=>v.contentId===String(u.id));S!==-1&&j!==-1&&o(E(r,S,j))}}return e.jsx(k,{sensors:s,collisionDetection:O,onDragEnd:l,children:e.jsx(D,{items:x,strategy:F,children:e.jsxs("div",{className:"space-y-2",children:[r.map(n=>e.jsx(T,{id:n.contentId,contentRef:n,onRemove:()=>I(r.indexOf(n))},n.contentId)),e.jsx(N,{host:i,collections:t,selectedIds:g,open:c,onOpenChange:d,onSelect:p,trigger:e.jsxs(h,{type:"button",variant:"outline",size:"sm",children:[e.jsx(z,{className:"mr-2 h-3 w-3"}),"Add Content"]})})]})})})}function T({id:i,contentRef:t,onRemove:a}){const{attributes:o,listeners:s,setNodeRef:c,transform:d,transition:r}=M({id:i}),x={transform:L.Transform.toString(d),transition:r};return e.jsxs("div",{ref:c,style:x,className:"flex items-center gap-2 rounded-md border p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...o,...s,children:e.jsx(V,{className:"h-4 w-4"})}),e.jsx(f,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:t.title}),e.jsx(C,{variant:"secondary",children:t.collection}),e.jsx(h,{type:"button",variant:"ghost",size:"sm",onClick:a,className:"text-destructive",children:e.jsx(y,{className:"h-3 w-3"})})]})}function N({host:i,collections:t,selectedIds:a,open:o,onOpenChange:s,onSelect:c,trigger:d,status:r}){const[x,g]=b.useState(""),p=ee(x,300),{data:I,isLoading:l}=$(i,p,t,r);return e.jsxs(q,{open:o,onOpenChange:s,children:[e.jsx(H,{asChild:!0,children:d}),e.jsx(X,{className:"w-80 p-0",align:"start",children:e.jsxs(J,{shouldFilter:!1,children:[e.jsx(K,{placeholder:"Search content...",value:x,onValueChange:g}),e.jsx(U,{children:l?e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}):e.jsxs(e.Fragment,{children:[e.jsx(W,{children:"No content found."}),e.jsx(Y,{heading:p.length===0?"Recent":void 0,children:I?.items.map(n=>{const m=a.includes(n.contentId);return e.jsxs(Z,{value:n.contentId,disabled:m,onSelect:()=>c({contentId:n.contentId,collection:n.collection,slug:n.slug??"",title:n.title}),children:[e.jsx(f,{className:"h-4 w-4"}),e.jsx("span",{className:"flex-1 truncate",children:n.title}),e.jsx(C,{variant:"outline",className:"text-xs",children:n.collection})]},n.contentId)})})]})})]})})]})}function je({relationships:i,values:t,onChange:a,host:o}){return e.jsxs(A,{children:[e.jsx(G,{children:e.jsx(Q,{children:"Relationships"})}),e.jsx(_,{className:"space-y-4",children:i.map(s=>s.multiple?e.jsx(oe,{rel:s,items:t[s.name]??[],host:o,onChange:c=>a({...t,[s.name]:c})},s.name):e.jsx(se,{rel:s,value:t[s.name]?.[0]??null,host:o,onChange:c=>a({...t,[s.name]:c?[c]:[]})},s.name))})]})}function se({rel:i,value:t,host:a,onChange:o}){const[s,c]=b.useState(!1),d=t?[t.contentId]:[];return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",children:i.label}),t?e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[e.jsx(f,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"flex-1 truncate text-sm",children:t.title}),e.jsx(C,{variant:"secondary",children:t.collection}),e.jsx(h,{type:"button",variant:"ghost",size:"sm",onClick:()=>o(null),children:e.jsx(y,{className:"h-3 w-3"})})]}):e.jsx(N,{host:a,collections:[i.targetCollection],selectedIds:d,open:s,onOpenChange:c,onSelect:r=>{o(r),c(!1)},status:"published",trigger:e.jsxs(h,{type:"button",variant:"outline",size:"sm",children:[e.jsx(f,{className:"mr-2 h-4 w-4"}),"Select ",i.label]})})]})}function oe({rel:i,items:t,host:a,onChange:o}){const s=w(P(R)),[c,d]=b.useState(!1),r=t.map(l=>l.contentId),x=t.map(l=>l.contentId);function g(l){o([...t,l]),d(!1)}function p(l){o(t.filter((n,m)=>m!==l))}function I(l){const{active:n,over:m}=l;if(m&&n.id!==m.id){const u=t.findIndex(j=>j.contentId===String(n.id)),S=t.findIndex(j=>j.contentId===String(m.id));u!==-1&&S!==-1&&o(E(t,u,S))}}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",children:i.label}),e.jsx(k,{sensors:s,collisionDetection:O,onDragEnd:I,children:e.jsx(D,{items:r,strategy:F,children:e.jsxs("div",{className:"space-y-2",children:[t.map(l=>e.jsx(T,{id:l.contentId,contentRef:l,onRemove:()=>p(t.indexOf(l))},l.contentId)),e.jsx(N,{host:a,collections:[i.targetCollection],selectedIds:x,open:c,onOpenChange:d,onSelect:g,status:"published",trigger:e.jsxs(h,{type:"button",variant:"outline",size:"sm",children:[e.jsx(z,{className:"mr-2 h-3 w-3"}),"Add ",i.label]})})]})})})]})}export{pe as C,je as R,N as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,a as V}from"./tanstack-Bs3zYPPV.js";import{r as m,u as X,f as z}from"./react-vendor-C2CvUxFh.js";import{L as r,I as o,B as d,v as l,aG as J,S as D,aX as W,aY as $,aZ as ee,aF as se,x as ae,j as te,a as S,aM as ie,D as P,k,l as L,m as B,n as M,o as O}from"./index-wYNPRVrc.js";import{C as N,a as C,b,d as ne,c as w}from"./card-10FqkZPA.js";import{f as re}from"./format-C88SDH8g.js";import{u as le}from"./usePageTitle-Bwf-MpTD.js";import{u as ce,a as de,b as oe}from"./useSiteUsers-QbiItSH1.js";import{C as q}from"./checkbox-fC1QPb_4.js";import{T as U}from"./textarea-CHQ9tT69.js";import"./radix-C1kb_NqW.js";function me({host:a}){const{data:c,isLoading:n}=ce(a),x=de(a),j=oe(a),[i,h]=m.useState({}),[u,g]=m.useState("");m.useEffect(()=>{c&&h(c)},[c]);async function p(){try{await x.mutateAsync(i),l.success("Auth settings saved")}catch(s){l.error("Failed to save",{description:s instanceof Error?s.message:void 0})}}async function A(){if(u)try{await j.mutateAsync(u),l.success("Test email sent")}catch(s){l.error("Failed to send test email",{description:s instanceof Error?s.message:void 0})}}return n||!c?null:e.jsxs(N,{children:[e.jsxs(C,{children:[e.jsx(b,{children:"Site Authentication"}),e.jsx(ne,{children:"Enable email OTP authentication for site visitors."})]}),e.jsxs(w,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{id:"auth-enabled",checked:i.enabled??!1,onCheckedChange:s=>h({...i,enabled:s})}),e.jsx(r,{htmlFor:"auth-enabled",children:"Enable site auth"})]}),i.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{id:"allow-signup",checked:i.allowSignup??!1,onCheckedChange:s=>h({...i,allowSignup:s})}),e.jsx(r,{htmlFor:"allow-signup",children:"Allow self-registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"session-ttl",children:"Session duration (days)"}),e.jsx(o,{id:"session-ttl",type:"number",min:1,value:Math.round((i.sessionTtl??2592e3)/86400),onChange:s=>h({...i,sessionTtl:parseInt(s.target.value)*86400})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-subject",children:"Email subject (Liquid)"}),e.jsx(o,{id:"email-subject",placeholder:"Your login code for {{ site_name }}",value:i.emailSubject??"",onChange:s=>h({...i,emailSubject:s.target.value})}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Variables: ","{{ code }}",", ","{{ site_name }}",", ","{{ user_email }}",", ","{{ user_name }}",", ","{{ expires_minutes }}"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-body",children:"Email HTML body (Liquid)"}),e.jsx(U,{id:"email-body",rows:5,placeholder:"<p>Your code: <strong>{{ code }}</strong></p>",value:i.emailBody??"",onChange:s=>h({...i,emailBody:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"email-text",children:"Email text body (Liquid)"}),e.jsx(U,{id:"email-text",rows:3,placeholder:"Your code: {{ code }}",value:i.emailTextBody??"",onChange:s=>h({...i,emailTextBody:s.target.value})})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(r,{htmlFor:"test-email",children:"Send test email"}),e.jsx(o,{id:"test-email",type:"email",placeholder:"admin@example.com",value:u,onChange:s=>g(s.target.value)})]}),e.jsx(d,{variant:"outline",onClick:A,disabled:j.isPending||!u,children:"Send"})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(d,{onClick:p,disabled:x.isPending,children:"Save"})})]})]})}function Ce(){const{host:a}=X(),{data:c,isLoading:n}=J(a);return n?e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-8 w-64"}),e.jsx(D,{className:"h-48 w-full"})]}):c?e.jsx(he,{site:c},c.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function he({site:a}){const c=V(),n=W(a.host),x=$(a.host),j=ee(a.host),i=z(),u=se()==="admin",g=a.status==="archived",[p,A]=m.useState(a.name),[s,_]=m.useState(a.fromEmail??""),[F,H]=m.useState(a.fromName??""),[I,v]=m.useState(!1),[Y,f]=m.useState(!1),[E,y]=m.useState(""),G=ae();le({title:"Configuration"});async function Q(t){t.preventDefault();try{await n.mutateAsync({name:p,fromEmail:s,fromName:F}),l.success("Site updated")}catch(T){l.error("Failed to update site",{description:T instanceof Error?T.message:void 0})}}async function R(){try{await n.mutateAsync({status:"archived"}),l.success("Site archived"),v(!1),i("/sites")}catch(t){l.error("Failed to archive site",{description:t instanceof Error?t.message:void 0})}}async function Z(){try{await n.mutateAsync({status:"active"}),l.success("Site unarchived")}catch(t){l.error("Failed to unarchive site",{description:t instanceof Error?t.message:void 0})}}async function K(){try{await x.mutateAsync(),await j.mutateAsync(),await c.invalidateQueries({queryKey:["sites"]}),l.success("Site deleted"),f(!1),y(""),i("/sites")}catch(t){l.error("Failed to delete site",{description:t instanceof Error?t.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[!G&&e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(N,{children:[e.jsx(C,{children:e.jsx(b,{children:"General"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:Q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"name",children:"Site Name"}),e.jsx(o,{id:"name",value:p,onChange:t=>A(t.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fromEmail",children:"Sender email (optional)"}),e.jsx(o,{id:"fromEmail",type:"email",placeholder:"Uses global default",value:s,onChange:t=>_(t.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'"From" address for emails sent by this site. Must be verified in SES.'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fromName",children:"Sender name (optional)"}),e.jsx(o,{id:"fromName",placeholder:"My Site",value:F,onChange:t=>H(t.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display name shown alongside the sender email address."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Host"}),e.jsx(o,{value:a.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:g?e.jsx(te,{variant:"outline",children:"Archived"}):e.jsx(o,{value:a.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Created"}),e.jsx(o,{value:re(a.createdAt),disabled:!0})]}),e.jsxs(d,{type:"submit",disabled:n.isPending,children:[n.isPending&&e.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),u&&e.jsxs(N,{className:"mt-6",children:[e.jsx(C,{children:e.jsx(b,{children:"Site Status"})}),e.jsx(w,{className:"space-y-4",children:g?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(d,{variant:"outline",onClick:Z,disabled:n.isPending,children:[n.isPending&&e.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(d,{variant:"outline",onClick:()=>v(!0),children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(P,{open:I,onOpenChange:v,children:e.jsxs(k,{children:[e.jsxs(L,{children:[e.jsx(B,{children:"Archive Site"}),e.jsxs(M,{children:["Are you sure you want to archive ",e.jsx("strong",{children:a.host}),"? The site will become read-only."]})]}),e.jsxs(O,{children:[e.jsx(d,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsxs(d,{onClick:R,disabled:n.isPending,children:[n.isPending&&e.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),u&&e.jsx("div",{className:"mt-6",children:e.jsx(me,{host:a.host})}),u&&g&&e.jsxs(N,{className:"border-destructive mt-6",children:[e.jsx(C,{children:e.jsx(b,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(w,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(d,{variant:"destructive",onClick:()=>f(!0),children:"Delete Site"}),e.jsx(P,{open:Y,onOpenChange:t=>{f(t),t||y("")},children:e.jsxs(k,{children:[e.jsxs(L,{children:[e.jsx(B,{children:"Delete Site"}),e.jsxs(M,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:a.host})," to confirm."]})]}),e.jsx(o,{placeholder:a.host,value:E,onChange:t=>y(t.target.value)}),e.jsxs(O,{children:[e.jsx(d,{variant:"outline",onClick:()=>{f(!1),y("")},children:"Cancel"}),e.jsxs(d,{variant:"destructive",onClick:K,disabled:E!==a.host||x.isPending||j.isPending,children:[(x.isPending||j.isPending)&&e.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{Ce as SiteSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as $,r as i}from"./react-vendor-C2CvUxFh.js";import{c as G,d as J,e as K,f as Q}from"./useSiteUsers-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as $,r as i}from"./react-vendor-C2CvUxFh.js";import{c as G,d as J,e as K,f as Q}from"./useSiteUsers-QbiItSH1.js";import{x as V,B as t,P as S,I as x,S as W,j as w,T as X,D as T,k as U,l as D,m as k,n as E,L as F,o as I,v as r}from"./index-wYNPRVrc.js";import{T as Y,a as Z,b as P,c as n,d as _,e as l}from"./table-WkEcC9MH.js";import{f as ee}from"./format-C88SDH8g.js";import{u as se}from"./usePageTitle-Bwf-MpTD.js";import"./radix-C1kb_NqW.js";function oe(){const{host:c}=$(),[j,A]=i.useState(""),[M,p]=i.useState(),{data:m,isLoading:B}=G(c,{cursor:M,tag:j||void 0}),g=J(c),v=K(c),L=Q(c),[O,d]=i.useState(!1),[u,f]=i.useState(""),[N,y]=i.useState(""),[h,o]=i.useState(null),H=V();se({title:"Site Users",actions:e.jsx(t,{size:"sm",onClick:()=>d(!0),children:e.jsx(S,{className:"h-4 w-4"})})});async function z(s){s.preventDefault();try{await g.mutateAsync({email:u,name:N||void 0}),d(!1),f(""),y(""),r.success("User created")}catch(a){r.error("Failed to create user",{description:a instanceof Error?a.message:void 0})}}async function R(){if(h)try{await v.mutateAsync(h),o(null),r.success("User deleted")}catch(s){r.error("Failed to delete user",{description:s instanceof Error?s.message:void 0})}}async function q(s){const a=s.status==="active"?"disabled":"active";try{await L.mutateAsync({userId:s.userId,status:a}),r.success(`User ${a==="active"?"enabled":"disabled"}`)}catch(C){r.error("Failed to update user",{description:C instanceof Error?C.message:void 0})}}const b=m?.items??[];return e.jsxs("div",{children:[!H&&e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Site Users"}),e.jsxs(t,{onClick:()=>d(!0),children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),"Add User"]})]}),e.jsx("div",{className:"mb-4",children:e.jsx(x,{placeholder:"Filter by tag...",value:j,onChange:s=>{A(s.target.value),p(void 0)},className:"max-w-xs"})}),B?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(s=>e.jsx(W,{className:"h-12 w-full"},s))}):b.length===0?e.jsx("p",{className:"text-muted-foreground py-8 text-center",children:"No site users yet"}):e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(P,{children:[e.jsx(n,{children:"Email"}),e.jsx(n,{children:"Name"}),e.jsx(n,{children:"Status"}),e.jsx(n,{children:"Tags"}),e.jsx(n,{children:"Created"}),e.jsx(n,{className:"w-10"})]})}),e.jsx(_,{children:b.map(s=>e.jsxs(P,{children:[e.jsx(l,{className:"font-medium",children:s.email}),e.jsx(l,{children:s.name||"—"}),e.jsx(l,{children:e.jsx(w,{variant:s.status==="active"?"default":"secondary",className:"cursor-pointer",onClick:()=>q(s),children:s.status})}),e.jsx(l,{children:s.tags?.map(a=>e.jsx(w,{variant:"outline",className:"mr-1",children:a},a))}),e.jsx(l,{children:ee(s.createdAt)}),e.jsx(l,{children:e.jsx(t,{variant:"ghost",size:"icon",onClick:()=>o(s.userId),children:e.jsx(X,{className:"h-4 w-4"})})})]},s.userId))})]}),m?.cursor&&e.jsx("div",{className:"mt-4 flex justify-center",children:e.jsx(t,{variant:"outline",onClick:()=>p(m.cursor),children:"Load more"})}),e.jsx(T,{open:O,onOpenChange:d,children:e.jsxs(U,{children:[e.jsxs(D,{children:[e.jsx(k,{children:"Add Site User"}),e.jsx(E,{children:"Create a new user for this site."})]}),e.jsxs("form",{onSubmit:z,children:[e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"email",children:"Email"}),e.jsx(x,{id:"email",type:"email",value:u,onChange:s=>f(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{htmlFor:"name",children:"Name (optional)"}),e.jsx(x,{id:"name",value:N,onChange:s=>y(s.target.value)})]})]}),e.jsx(I,{children:e.jsx(t,{type:"submit",disabled:g.isPending||!u,children:"Create"})})]})]})}),e.jsx(T,{open:!!h,onOpenChange:()=>o(null),children:e.jsxs(U,{children:[e.jsxs(D,{children:[e.jsx(k,{children:"Delete User"}),e.jsx(E,{children:"This will permanently delete this user and all their identities."})]}),e.jsxs(I,{children:[e.jsx(t,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:R,disabled:v.isPending,children:"Delete"})]})]})})]})}export{oe as SiteUsersPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as u,f as V}from"./react-vendor-C2CvUxFh.js";import{b as X,u as Z,d as ee,e as te,g as se,h as ae,H as U,D as G,i as J,B as k,P as R,U as ne,j as oe,k as ie,l as le,m as re,n as ce,L as W,I as Y,o as de}from"./index-b-u0-VCO.js";import{C as me,a as he,b as ue,d as ge}from"./card-uKxSQehY.js";import{C as b}from"./checkbox-z1kYnX5o.js";import"./radix-C1kb_NqW.js";const pe={name:"pages",label:"Pages",labelSingular:"Page",slug:"pages",singleton:!1,fields:[{name:"content",label:"Content",type:"blocks",options:{}}]},xe={name:"posts",label:"Blog Posts",labelSingular:"Blog Post",slug:"/blog",singleton:!1,fields:[{name:"author",label:"Author",type:"text",options:{}},{name:"content",label:"Content",type:"blocks",options:{}}]},fe={name:"site-settings",label:"Site Settings",labelSingular:"Site Settings",slug:"site-settings",singleton:!0,fields:[{name:"siteName",label:"Site Name",type:"text",options:{}},{name:"tagline",label:"Tagline",type:"text",options:{}},{name:"footerText",label:"Footer Text",type:"text",options:{}},{name:"menuItems",label:"Menu Items",type:"array",options:{itemFields:[{name:"label",label:"Label",type:"text",options:{}},{name:"href",label:"URL",type:"text",options:{}}]}}]};function C(s,o){return{id:o,type:"paragraph",props:{textColor:"default",backgroundColor:"default",textAlignment:"left"},content:[{type:"text",text:s}],children:[]}}function $(s,o,d){return{id:d,type:"heading",props:{textColor:"default",backgroundColor:"default",textAlignment:"left",level:o},content:[{type:"text",text:s}],children:[]}}const z=[{title:"Home",slug:"home",body:{content:[$("Welcome to Headroom",1,"home-h1"),C("This is your new site powered by Headroom CMS. Edit this page to add your own content.","home-p1"),$("Getting Started",2,"home-h2"),C("Head over to the admin panel to manage your content, collections, and media.","home-p2")]}},{title:"About",slug:"about",body:{content:[$("About Us",1,"about-h1"),C("Tell your visitors about your company, team, or project. This is a great place to share your story.","about-p1")]}},{title:"Contact",slug:"contact",body:{content:[$("Contact",1,"contact-h1"),C("Get in touch with us. Replace this with your contact information or a contact form.","contact-p1")]}}],K=[{title:"Welcome to Headroom",slug:"welcome-to-headroom",body:{author:"Admin",content:[C("This is your first blog post. You can edit or delete it and start writing your own content.","post-p1"),C("Headroom makes it easy to create and manage your content with a powerful block editor, media library, and flexible collections.","post-p2")]}}],Se={siteName:"Headroom Site",tagline:"A site powered by Headroom CMS",footerText:"© 2026 Headroom Site. Built with Headroom CMS.",menuItems:[{label:"Home",href:"/"},{label:"About",href:"/about"},{label:"Blog",href:"/blog"},{label:"Contact",href:"/contact"}]};function Q(s){const d=[s.createPages,s.createPosts,s.createSettings].filter(Boolean).length;if(!s.addSampleContent)return d;let g=0;return s.createPages&&(g+=z.length*2),s.createPosts&&(g+=K.length*2),s.createSettings&&(g+=3),d+g}async function be(s,o,d,g){const r={collectionsCreated:[],contentCreated:[],errors:[]},x=Q(d);let a=0;const m=t=>{g?.({completed:a,total:x,label:t})},y=[{key:"pages",enabled:d.createPages,schema:pe},{key:"posts",enabled:d.createPosts,schema:xe},{key:"site-settings",enabled:d.createSettings,schema:fe}],p=new Set;for(const{key:t,enabled:n,schema:f}of y)if(n){m(`Creating ${t} collection...`);try{await s.apiFetch(`/v1/admin/sites/${o}/collections`,{method:"POST",body:JSON.stringify(f)}),r.collectionsCreated.push(t),p.add(t)}catch(h){r.errors.push(`Failed to create ${t} collection: ${h instanceof Error?h.message:String(h)}`)}a++}if(!d.addSampleContent)return m("Done"),r;if(p.has("pages"))for(const t of z){m(`Creating page "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"pages",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing page "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`pages/${t.slug}`)}catch(n){r.errors.push(`Failed to create page "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("posts"))for(const t of K){m(`Creating post "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"posts",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing post "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`posts/${t.slug}`)}catch(n){r.errors.push(`Failed to create post "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("site-settings")){m("Configuring settings...");try{const t=await s.apiFetch(`/v1/admin/sites/${o}/collections/site-settings`);a++,t.singletonContentId?(m("Saving settings draft..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/draft`,{method:"PUT",body:JSON.stringify({title:"Site Settings",slug:"site-settings",body:Se})}),a++,m("Publishing settings..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/publish`,{method:"POST"}),a++,r.contentCreated.push("site-settings")):a+=2}catch(t){r.errors.push(`Failed to populate settings: ${t instanceof Error?t.message:String(t)}`),a+=3}}return m("Done"),r}function Pe(){const[s,o]=u.useState(!1),{data:d,isLoading:g}=X(s),r=V(),x=u.useMemo(()=>[...d?.items??[]].sort((l,A)=>(l.name||l.host).localeCompare(A.name||A.host)),[d]),{user:a}=Z(),{data:m}=ee(),y=a?(m?.superAdminIds??[]).includes(a.sub):!1,p=te(),t=se(),[n,f]=u.useState(!1),[h,j]=u.useState(""),[S,c]=u.useState(""),[N,i]=u.useState(!0),[v,D]=u.useState(!0),[w,O]=u.useState(!0),[P,E]=u.useState(!0),[F,L]=u.useState(!1),[H,T]=u.useState(null),I=()=>{j(""),c(""),i(!0),D(!0),O(!0),E(!0),L(!1),T(null)},B=l=>{f(l),l||I()};if(g)return e.jsx(ae,{});const _=async()=>{if(h.trim())try{await t.mutateAsync({host:h.trim(),name:S.trim()||h.trim()});const l={createPages:v,createPosts:w,createSettings:P,addSampleContent:F};if(N&&(v||w||P)){const A=Q(l);T({completed:0,total:A,label:"Setting up collections..."});const M=await be(p,h.trim(),l,T);M.errors.length>0&&console.warn("Scaffold warnings:",M.errors)}f(!1),I()}catch{T(null)}};return x.length===0?e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No sites available."}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]}):e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex-1 p-4 sm:p-8",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:s,onCheckedChange:l=>o(l===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{variant:"outline",onClick:()=>r("/users"),children:[e.jsx(ne,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"All Users"})]}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Create Site"})]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:x.map(l=>e.jsx(me,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>r(`/sites/${l.host}/content`),children:e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{children:l.name||l.host}),l.status==="archived"&&e.jsx(oe,{variant:"outline",children:"Archived"})]}),e.jsx(ge,{children:l.host})]})},l.host))})]})]})}function q({newHost:s,setNewHost:o,newName:d,setNewName:g,createDefaults:r,setCreateDefaults:x,createPages:a,setCreatePages:m,createPosts:y,setCreatePosts:p,createSettings:t,setCreateSettings:n,addSampleContent:f,setAddSampleContent:h,onSubmit:j,isPending:S,scaffoldProgress:c}){const N=S||!!c;return e.jsxs(ie,{children:[e.jsxs(le,{children:[e.jsx(re,{children:"Create Site"}),e.jsx(ce,{className:"sr-only",children:"Enter details for the new site"})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"host",children:"Host"}),e.jsx(Y,{id:"host",placeholder:"example.com",value:s,onChange:i=>o(i.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"name",children:"Display Name"}),e.jsx(Y,{id:"name",placeholder:"My Site",value:d,onChange:i=>g(i.target.value)})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(b,{checked:r,onCheckedChange:i=>x(i===!0)}),"Create Default Collections"]}),r&&e.jsxs("div",{className:"ml-6 mt-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:a,onCheckedChange:i=>m(i===!0)}),"Pages"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:y,onCheckedChange:i=>p(i===!0)}),"Posts"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:t,onCheckedChange:i=>n(i===!0)}),"Site Settings"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(b,{checked:f,onCheckedChange:i=>h(i===!0)}),"Add Sample Content"]})]})]})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300",style:{width:`${c.total>0?c.completed/c.total*100:0}%`},role:"progressbar","aria-valuenow":c.completed,"aria-valuemin":0,"aria-valuemax":c.total})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.label," ","(",c.completed,"/",c.total,")"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Please wait while your site is being set up. Do not close this tab."})]}),e.jsx(de,{children:e.jsx(k,{onClick:j,disabled:!s.trim()||N,children:c?c.label:S?"Creating...":"Create"})})]})}export{Pe as SitesPage};
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as u,f as V}from"./react-vendor-C2CvUxFh.js";import{b as X,u as Z,d as ee,e as te,g as se,h as ae,H as U,D as G,i as J,B as k,P as R,U as ne,j as oe,k as ie,l as le,m as re,n as ce,L as W,I as Y,o as de}from"./index-wYNPRVrc.js";import{C as me,a as he,b as ue,d as ge}from"./card-10FqkZPA.js";import{C as b}from"./checkbox-fC1QPb_4.js";import"./radix-C1kb_NqW.js";const pe={name:"pages",label:"Pages",labelSingular:"Page",slug:"pages",singleton:!1,fields:[{name:"content",label:"Content",type:"blocks",options:{}}]},xe={name:"posts",label:"Blog Posts",labelSingular:"Blog Post",slug:"/blog",singleton:!1,fields:[{name:"author",label:"Author",type:"text",options:{}},{name:"content",label:"Content",type:"blocks",options:{}}]},fe={name:"site-settings",label:"Site Settings",labelSingular:"Site Settings",slug:"site-settings",singleton:!0,fields:[{name:"siteName",label:"Site Name",type:"text",options:{}},{name:"tagline",label:"Tagline",type:"text",options:{}},{name:"footerText",label:"Footer Text",type:"text",options:{}},{name:"menuItems",label:"Menu Items",type:"array",options:{itemFields:[{name:"label",label:"Label",type:"text",options:{}},{name:"href",label:"URL",type:"text",options:{}}]}}]};function C(s,o){return{id:o,type:"paragraph",props:{textColor:"default",backgroundColor:"default",textAlignment:"left"},content:[{type:"text",text:s}],children:[]}}function $(s,o,d){return{id:d,type:"heading",props:{textColor:"default",backgroundColor:"default",textAlignment:"left",level:o},content:[{type:"text",text:s}],children:[]}}const z=[{title:"Home",slug:"home",body:{content:[$("Welcome to Headroom",1,"home-h1"),C("This is your new site powered by Headroom CMS. Edit this page to add your own content.","home-p1"),$("Getting Started",2,"home-h2"),C("Head over to the admin panel to manage your content, collections, and media.","home-p2")]}},{title:"About",slug:"about",body:{content:[$("About Us",1,"about-h1"),C("Tell your visitors about your company, team, or project. This is a great place to share your story.","about-p1")]}},{title:"Contact",slug:"contact",body:{content:[$("Contact",1,"contact-h1"),C("Get in touch with us. Replace this with your contact information or a contact form.","contact-p1")]}}],K=[{title:"Welcome to Headroom",slug:"welcome-to-headroom",body:{author:"Admin",content:[C("This is your first blog post. You can edit or delete it and start writing your own content.","post-p1"),C("Headroom makes it easy to create and manage your content with a powerful block editor, media library, and flexible collections.","post-p2")]}}],Se={siteName:"Headroom Site",tagline:"A site powered by Headroom CMS",footerText:"© 2026 Headroom Site. Built with Headroom CMS.",menuItems:[{label:"Home",href:"/"},{label:"About",href:"/about"},{label:"Blog",href:"/blog"},{label:"Contact",href:"/contact"}]};function Q(s){const d=[s.createPages,s.createPosts,s.createSettings].filter(Boolean).length;if(!s.addSampleContent)return d;let g=0;return s.createPages&&(g+=z.length*2),s.createPosts&&(g+=K.length*2),s.createSettings&&(g+=3),d+g}async function be(s,o,d,g){const r={collectionsCreated:[],contentCreated:[],errors:[]},x=Q(d);let a=0;const m=t=>{g?.({completed:a,total:x,label:t})},y=[{key:"pages",enabled:d.createPages,schema:pe},{key:"posts",enabled:d.createPosts,schema:xe},{key:"site-settings",enabled:d.createSettings,schema:fe}],p=new Set;for(const{key:t,enabled:n,schema:f}of y)if(n){m(`Creating ${t} collection...`);try{await s.apiFetch(`/v1/admin/sites/${o}/collections`,{method:"POST",body:JSON.stringify(f)}),r.collectionsCreated.push(t),p.add(t)}catch(h){r.errors.push(`Failed to create ${t} collection: ${h instanceof Error?h.message:String(h)}`)}a++}if(!d.addSampleContent)return m("Done"),r;if(p.has("pages"))for(const t of z){m(`Creating page "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"pages",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing page "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`pages/${t.slug}`)}catch(n){r.errors.push(`Failed to create page "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("posts"))for(const t of K){m(`Creating post "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"posts",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing post "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`posts/${t.slug}`)}catch(n){r.errors.push(`Failed to create post "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("site-settings")){m("Configuring settings...");try{const t=await s.apiFetch(`/v1/admin/sites/${o}/collections/site-settings`);a++,t.singletonContentId?(m("Saving settings draft..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/draft`,{method:"PUT",body:JSON.stringify({title:"Site Settings",slug:"site-settings",body:Se})}),a++,m("Publishing settings..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/publish`,{method:"POST"}),a++,r.contentCreated.push("site-settings")):a+=2}catch(t){r.errors.push(`Failed to populate settings: ${t instanceof Error?t.message:String(t)}`),a+=3}}return m("Done"),r}function Pe(){const[s,o]=u.useState(!1),{data:d,isLoading:g}=X(s),r=V(),x=u.useMemo(()=>[...d?.items??[]].sort((l,A)=>(l.name||l.host).localeCompare(A.name||A.host)),[d]),{user:a}=Z(),{data:m}=ee(),y=a?(m?.superAdminIds??[]).includes(a.sub):!1,p=te(),t=se(),[n,f]=u.useState(!1),[h,j]=u.useState(""),[S,c]=u.useState(""),[N,i]=u.useState(!0),[v,D]=u.useState(!0),[w,O]=u.useState(!0),[P,E]=u.useState(!0),[F,L]=u.useState(!1),[H,T]=u.useState(null),I=()=>{j(""),c(""),i(!0),D(!0),O(!0),E(!0),L(!1),T(null)},B=l=>{f(l),l||I()};if(g)return e.jsx(ae,{});const _=async()=>{if(h.trim())try{await t.mutateAsync({host:h.trim(),name:S.trim()||h.trim()});const l={createPages:v,createPosts:w,createSettings:P,addSampleContent:F};if(N&&(v||w||P)){const A=Q(l);T({completed:0,total:A,label:"Setting up collections..."});const M=await be(p,h.trim(),l,T);M.errors.length>0&&console.warn("Scaffold warnings:",M.errors)}f(!1),I()}catch{T(null)}};return x.length===0?e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No sites available."}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]}):e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex-1 p-4 sm:p-8",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:s,onCheckedChange:l=>o(l===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{variant:"outline",onClick:()=>r("/users"),children:[e.jsx(ne,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"All Users"})]}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Create Site"})]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:x.map(l=>e.jsx(me,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>r(`/sites/${l.host}/content`),children:e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{children:l.name||l.host}),l.status==="archived"&&e.jsx(oe,{variant:"outline",children:"Archived"})]}),e.jsx(ge,{children:l.host})]})},l.host))})]})]})}function q({newHost:s,setNewHost:o,newName:d,setNewName:g,createDefaults:r,setCreateDefaults:x,createPages:a,setCreatePages:m,createPosts:y,setCreatePosts:p,createSettings:t,setCreateSettings:n,addSampleContent:f,setAddSampleContent:h,onSubmit:j,isPending:S,scaffoldProgress:c}){const N=S||!!c;return e.jsxs(ie,{children:[e.jsxs(le,{children:[e.jsx(re,{children:"Create Site"}),e.jsx(ce,{className:"sr-only",children:"Enter details for the new site"})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"host",children:"Host"}),e.jsx(Y,{id:"host",placeholder:"example.com",value:s,onChange:i=>o(i.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"name",children:"Display Name"}),e.jsx(Y,{id:"name",placeholder:"My Site",value:d,onChange:i=>g(i.target.value)})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(b,{checked:r,onCheckedChange:i=>x(i===!0)}),"Create Default Collections"]}),r&&e.jsxs("div",{className:"ml-6 mt-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:a,onCheckedChange:i=>m(i===!0)}),"Pages"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:y,onCheckedChange:i=>p(i===!0)}),"Posts"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:t,onCheckedChange:i=>n(i===!0)}),"Site Settings"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(b,{checked:f,onCheckedChange:i=>h(i===!0)}),"Add Sample Content"]})]})]})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300",style:{width:`${c.total>0?c.completed/c.total*100:0}%`},role:"progressbar","aria-valuenow":c.completed,"aria-valuemin":0,"aria-valuemax":c.total})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.label," ","(",c.completed,"/",c.total,")"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Please wait while your site is being set up. Do not close this tab."})]}),e.jsx(de,{children:e.jsx(k,{onClick:j,disabled:!s.trim()||N,children:c?c.label:S?"Creating...":"Create"})})]})}export{Pe as SitesPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as A,f as F,r as B,L}from"./react-vendor-C2CvUxFh.js";import{j as C,m as O}from"./useContent-D8yDRTTy.js";import{x as E,w as M,S as b,B as r,a$ as P,$ as U,a9 as z,D as H,i as V,T as Y,k as _,l as q,m as G,n as J,o as K,aa as Q,j as W,v as g}from"./index-wYNPRVrc.js";import{u as X}from"./usePageTitle-Bwf-MpTD.js";import{C as y,a as v,b as D,c as w}from"./card-10FqkZPA.js";import{f as Z}from"./format-C88SDH8g.js";import{M as ss}from"./MediaField-Du7_gRse.js";import"./radix-C1kb_NqW.js";import"./useMedia-m6zKB__r.js";import"./select-BV3jemT6.js";import"./media-url-DIg_vSyf.js";function es({host:a,ref:t}){const c=!t.title&&!!t.contentId,{data:o}=C(a,c?t.contentId:""),d=c&&o?.content?o.content:null,h=t.title||d?.title||t.contentId,i=t.collection||d?.collection||"";return s.jsxs(L,{to:`/sites/${a}/content/${i}/${t.contentId}`,className:"flex items-center gap-3 rounded-md border p-2 transition-colors hover:bg-muted",children:[s.jsx(Q,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"flex-1 truncate text-sm",children:h}),i&&s.jsx(W,{variant:"secondary",children:i})]})}function us(){const{host:a,collection:t,id:c}=A(),o=F(),d=E(),{collections:h}=M(),{data:i,isLoading:S}=C(a,c),$=O(a,c),[k,p]=B.useState(!1),m=h.find(e=>e.name===t),f=m?.relationships??[];if(X({title:"Submission Detail",showBack:!0,backTo:`/sites/${a}/submissions/${t}`}),S)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(b,{className:"h-8 w-64"}),s.jsx(b,{className:"h-64 w-full"})]});if(!i?.content)return s.jsx("p",{className:"text-muted-foreground",children:"Submission not found."});const l=i.content,x=i.body??l.body,u=l.siteUser,j=l.relationships;function T(e,n){return n==null?"—":typeof n=="boolean"?n?"Yes":"No":Array.isArray(n)?n.join(", "):String(n)}async function I(){try{await $.mutateAsync(),g.success("Submission deleted"),o(`/sites/${a}/submissions/${t}`)}catch(e){g.error("Failed to delete",{description:e instanceof Error?e.message:void 0})}}const R=f.length>0&&j&&Object.keys(j).length>0;return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[!d&&s.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[s.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>o(`/sites/${a}/submissions/${t}`),children:[s.jsx(P,{className:"mr-1.5 h-4 w-4"}),"Back"]}),s.jsx("h1",{className:"text-2xl font-semibold",children:"Submission Detail"}),s.jsx("div",{className:"ml-auto",children:s.jsxs(r,{variant:"outline",size:"sm",onClick:()=>o(`/sites/${a}/submissions/${t}/${c}/edit`),children:[s.jsx(U,{className:"mr-1.5 h-4 w-4"}),"Edit"]})})]}),s.jsxs(y,{children:[s.jsx(v,{children:s.jsx(D,{children:l.title||"Untitled"})}),s.jsxs(w,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2 text-sm",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"ID"}),s.jsx("span",{className:"font-mono text-xs",children:l.contentId})]}),!!l.publishedAt&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"Submitted"}),s.jsx("span",{children:Z(l.publishedAt)})]}),u&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-muted-foreground",children:"Submitted by"}),s.jsx("span",{children:u.name||u.email})]})]}),s.jsx(z,{}),s.jsxs("div",{className:"space-y-3",children:[m?.fields?.map(e=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:e.label||e.name}),e.type==="media"?s.jsx(ss,{field:e,value:x?.[e.name],onChange:()=>{},disabled:!0}):s.jsx("p",{className:"text-sm whitespace-pre-wrap",children:T(e,x?.[e.name])})]},e.name)),(!m?.fields||m.fields.length===0)&&x&&s.jsx("div",{className:"space-y-3",children:Object.entries(x).map(([e,n])=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:e}),s.jsx("p",{className:"text-sm whitespace-pre-wrap",children:n==null?"—":String(n)})]},e))})]})]})]}),R&&s.jsxs(y,{className:"mt-6",children:[s.jsx(v,{children:s.jsx(D,{children:"Relationships"})}),s.jsx(w,{className:"space-y-4",children:f.map(e=>{const n=j?.[e.name]??[];return n.length===0?null:s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-sm font-medium",children:e.label}),s.jsx("div",{className:"space-y-2",children:n.map(N=>s.jsx(es,{host:a,ref:N},N.contentId))})]},e.name)})})]}),s.jsx("div",{className:"mt-6",children:s.jsxs(H,{open:k,onOpenChange:p,children:[s.jsx(V,{asChild:!0,children:s.jsxs(r,{variant:"destructive",children:[s.jsx(Y,{className:"mr-2 h-4 w-4"}),"Delete Submission"]})}),s.jsxs(_,{children:[s.jsxs(q,{children:[s.jsx(G,{children:"Delete submission?"}),s.jsx(J,{children:"This will permanently delete this submission."})]}),s.jsxs(K,{children:[s.jsx(r,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),s.jsx(r,{variant:"destructive",onClick:I,children:"Delete"})]})]})]})})]})}export{us as SubmissionDetailPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as O,f as z,r as u}from"./react-vendor-C2CvUxFh.js";import{x as U,w as V,e as D,S as E,B as P,a$ as H,L as q,b0 as G,I as x,v as j}from"./index-wYNPRVrc.js";import{j as J,s as K,t as Q}from"./useContent-D8yDRTTy.js";import{u as W}from"./usePageTitle-Bwf-MpTD.js";import{T as X}from"./textarea-CHQ9tT69.js";import{C as Y}from"./checkbox-fC1QPb_4.js";import{S as Z,a as _,b as ee,c as se,d as te}from"./select-BV3jemT6.js";import{C as ae,a as ne,b as ie,c as oe}from"./card-10FqkZPA.js";import{M as re}from"./MediaField-Du7_gRse.js";import{R as ce}from"./RelationshipPicker-D7dFI43Q.js";import"./radix-C1kb_NqW.js";import"./useMedia-m6zKB__r.js";import"./media-url-DIg_vSyf.js";import"./core.esm-B_kcYf6n.js";import"./sortable.esm-QyXA6fio.js";import"./popover-BJDj8C6y.js";import"./command-BeacdV75.js";import"./useContentSearch-B-_p0_QX.js";import"./useDebouncedValue-C-cQUcLG.js";function Fe(){const{host:i,collection:c,id:m}=O(),b=z(),R=U(),{collections:A}=V(),o=!!m,d=A.find(t=>t.name===c),v=u.useMemo(()=>d?.relationships??[],[d?.relationships]),h=v.length>0,{data:p,isLoading:T}=J(i,m??""),S=D(),C=K(i),f=Q(i,m??""),[$,y]=u.useState({}),[w,N]=u.useState({}),[k,L]=u.useState(!o);W({title:o?"Edit Submission":"New Submission",showBack:!0,backTo:o?`/sites/${i}/submissions/${c}/${m}`:`/sites/${i}/submissions/${c}`});const I=u.useCallback(async t=>{const a={};for(const[e,n]of Object.entries(t))a[e]=await Promise.all(n.map(async r=>{if(r.title)return r;try{const g=await S.apiFetch(`/v1/admin/sites/${i}/content/${r.contentId}`);return{contentId:r.contentId,collection:g.content.collection??r.collection??"",slug:g.content.slug??r.slug??"",title:g.content.title??r.contentId}}catch{return r}}));return a},[S,i]);if(u.useEffect(()=>{if(o&&p&&!k){const t=p.body;t&&y({...t});const e=p.content?.relationships;e&&Object.keys(e).length>0&&I(e).then(N),L(!0)}},[o,p,k,I]),o&&T)return s.jsxs("div",{className:"space-y-4",children:[s.jsx(E,{className:"h-8 w-64"}),s.jsx(E,{className:"h-64 w-full"})]});function l(t,a){y(e=>({...e,[t]:a}))}function M(t){const a=$[t.name];switch(t.type){case"text":return s.jsx(x,{value:a??"",onChange:e=>l(t.name,e.target.value)});case"textarea":return s.jsx(X,{value:a??"",onChange:e=>l(t.name,e.target.value),rows:4});case"number":return s.jsx(x,{type:"number",value:a!=null?String(a):"",onChange:e=>l(t.name,e.target.value===""?void 0:Number(e.target.value))});case"boolean":return s.jsx(Y,{checked:!!a,onCheckedChange:e=>l(t.name,!!e)});case"select":{const e=t.options?.choices??[];return s.jsxs(Z,{value:a??"",onValueChange:n=>l(t.name,n),children:[s.jsx(_,{children:s.jsx(ee,{placeholder:"Select..."})}),s.jsx(se,{children:e.map(n=>s.jsx(te,{value:n,children:n},n))})]})}case"array":return s.jsx(x,{value:Array.isArray(a)?a.join(", "):a??"",onChange:e=>l(t.name,e.target.value?e.target.value.split(",").map(n=>n.trim()):[]),placeholder:"Comma-separated values"});case"media":return s.jsx(re,{field:t,value:a,onChange:()=>{},disabled:!0});default:return s.jsx(x,{value:a??"",onChange:e=>l(t.name,e.target.value)})}}async function B(){const t={};for(const[e,n]of Object.entries($))n!==void 0&&n!==""&&(t[e]=n);const a={};if(h)for(const[e,n]of Object.entries(w))a[e]=n.map(r=>({contentId:r.contentId}));try{if(o)await f.mutateAsync({fields:t,...h?{relationships:a}:{}}),j.success("Submission updated"),b(`/sites/${i}/submissions/${c}/${m}`);else{const e=await C.mutateAsync({collection:c,fields:t,...h?{relationships:a}:{}});j.success("Submission created"),b(`/sites/${i}/submissions/${c}/${e.contentId}`)}}catch(e){const n=e instanceof Error?e.message:typeof e=="object"&&e!==null&&"message"in e?String(e.message):String(e);j.error(o?"Failed to update":"Failed to create",{description:n})}}const F=C.isPending||f.isPending;return s.jsxs("div",{className:"mx-auto max-w-2xl",children:[!R&&s.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[s.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>b(o?`/sites/${i}/submissions/${c}/${m}`:`/sites/${i}/submissions/${c}`),children:[s.jsx(H,{className:"mr-1.5 h-4 w-4"}),"Back"]}),s.jsx("h1",{className:"text-2xl font-semibold",children:o?"Edit Submission":"New Submission"})]}),s.jsxs(ae,{children:[s.jsx(ne,{children:s.jsx(ie,{children:d?.label??c})}),s.jsxs(oe,{className:"space-y-4",children:[d?.fields?.map(t=>s.jsxs("div",{className:"space-y-2",children:[s.jsx(q,{htmlFor:`field-${t.name}`,children:t.label||t.name}),s.jsx("div",{id:`field-${t.name}`,children:M(t)})]},t.name)),s.jsx("div",{className:"pt-4",children:s.jsxs(P,{onClick:B,disabled:F,children:[s.jsx(G,{className:"mr-1.5 h-4 w-4"}),F?"Saving...":o?"Update":"Create"]})})]})]}),h&&s.jsx("div",{className:"mt-6",children:s.jsx(ce,{relationships:v,values:w,onChange:N,host:i})})]})}export{Fe as SubmissionEditPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as E,f as H,r as u}from"./react-vendor-C2CvUxFh.js";import{u as Y}from"./useFilterParams-DYdEuWPE.js";import{w as G,x as J,B as y,P as K,T as Q,v as V,S as W,y as X}from"./index-wYNPRVrc.js";import{d as Z,c as ee}from"./useContent-D8yDRTTy.js";import{u as se}from"./usePageTitle-Bwf-MpTD.js";import{u as te,F as le}from"./FilterBar-JCp03kkK.js";import{C as ae,c as ne}from"./card-10FqkZPA.js";import{C as k}from"./checkbox-fC1QPb_4.js";import{S as re,a as ie,b as oe,c as ce,d as de}from"./select-BV3jemT6.js";import{T as ue,a as me,b as L,c as b,d as he,e as j}from"./table-WkEcC9MH.js";import{a as R,f as xe}from"./format-C88SDH8g.js";import"./radix-C1kb_NqW.js";import"./popover-BJDj8C6y.js";import"./command-BeacdV75.js";import"./useContentSearch-B-_p0_QX.js";import"./useDebouncedValue-C-cQUcLG.js";const fe=[{value:"created_desc",label:"Newest first"},{value:"created_asc",label:"Oldest first"}];function Me(){const{host:c,collection:r}=E(),g=H(),{collections:_}=G(),[v,N]=Y([{key:"sort",defaultValue:"created_desc"},{key:"relatedTo",defaultValue:""},{key:"relField",defaultValue:""}]),m=v.sort,i=v.relatedTo,l=v.relField,[B,h]=u.useState(),[o,x]=u.useState(new Set),I=J(),d=_.find(e=>e.name===r),f=d?.relationships??[];se({title:d?.label??r??""});const{data:F}=te(c,i||void 0),$=u.useMemo(()=>{if(!i||!l)return null;const e=f.find(t=>t.name===l);return{type:"relationship",relName:l,relLabel:e?.label??l,contentId:i,contentTitle:F??"Loading..."}},[i,l,f,F]),D=u.useMemo(()=>{const e={};return m!=="created_desc"&&(e.sort=m),i&&(e.relatedTo=i),l&&(e.relField=l),e},[m,i,l]),{data:S,isLoading:O}=Z(c,r,D,B),A=ee(c),p=S?.items,C=d?.fields,P=u.useMemo(()=>C?C.filter(e=>["text","number","boolean","select"].includes(e.type)).slice(0,4):[],[C]),w=p?.map(e=>e.contentId)??[],M=w.length>0&&w.every(e=>o.has(e));function U(e){x(t=>{const a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})}function z(){x(M?new Set:new Set(w))}function q(e,t){const n=e.fields?.[t];if(n==null)return"—";if(typeof n=="boolean")return n?"Yes":"No";if(typeof n=="number")return String(n);const T=String(n);return T.length>60?T.slice(0,60)+"…":T}return s.jsxs("div",{children:[!I&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:d?.label??r}),s.jsxs(y,{onClick:()=>g(`/sites/${c}/submissions/${r}/new`),children:[s.jsx(K,{className:"mr-1.5 h-4 w-4"}),"New Submission"]})]}),s.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[f.length>0&&s.jsx(le,{relationships:f,activeFilters:$?[$]:[],onFilterAdd:e=>{N({relatedTo:e.contentId,relField:e.relName}),h(void 0)},onFilterRemove:()=>{N({relatedTo:"",relField:""}),h(void 0)}}),s.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[o.size>0&&s.jsxs(y,{variant:"destructive",size:"sm",onClick:async()=>{const e=[...o],a=(await A.mutateAsync(e)).filter(n=>n.status==="rejected").length;a?V.error(`${a} of ${e.length} failed to delete`):V.success(`${e.length} submission(s) deleted`),x(new Set)},disabled:A.isPending,children:[s.jsx(Q,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete (",o.size,")"]}),s.jsxs(re,{value:m,onValueChange:e=>{N({sort:e}),h(void 0)},children:[s.jsx(ie,{className:"w-[150px]",children:s.jsx(oe,{})}),s.jsx(ce,{children:fe.map(e=>s.jsx(de,{value:e.value,children:e.label},e.value))})]})]})]}),O?s.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((e,t)=>s.jsx(W,{className:"h-12 w-full"},t))}):p?.length?s.jsxs(s.Fragment,{children:[I?s.jsx("div",{className:"grid gap-3","data-testid":"submission-card-view",children:p.map(e=>s.jsx(ae,{className:X("cursor-pointer gap-0 overflow-hidden py-0 transition-shadow hover:shadow-md",o.has(e.contentId)&&"ring-2 ring-primary"),onClick:()=>g(`/sites/${c}/submissions/${r}/${e.contentId}`),children:s.jsx(ne,{className:"p-3",children:s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"font-medium truncate",children:["Submission ",e.contentId.slice(-6)]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:e.publishedAt?R(e.publishedAt):"—"}),e.siteUser&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["by ",e.siteUser.name||e.siteUser.email]})]}),s.jsx(k,{checked:o.has(e.contentId),onCheckedChange:()=>U(e.contentId),onClick:t=>t.stopPropagation(),className:"mt-1"})]})})},e.contentId))}):s.jsxs(ue,{children:[s.jsx(me,{children:s.jsxs(L,{children:[s.jsx(b,{className:"w-10",children:s.jsx(k,{checked:M,onCheckedChange:z,"aria-label":"Select all"})}),P.map(e=>s.jsx(b,{children:e.label||e.name},e.name)),d?.requireAuth&&s.jsx(b,{children:"Submitted by"}),s.jsx(b,{children:"Submitted"})]})}),s.jsx(he,{children:p.map(e=>s.jsxs(L,{className:"cursor-pointer",onClick:()=>g(`/sites/${c}/submissions/${r}/${e.contentId}`),children:[s.jsx(j,{onClick:t=>t.stopPropagation(),children:s.jsx(k,{checked:o.has(e.contentId),onCheckedChange:()=>U(e.contentId),"aria-label":`Select submission ${e.contentId.slice(-6)}`})}),P.map(t=>s.jsx(j,{className:"text-muted-foreground text-sm",children:q(e,t.name)},t.name)),d?.requireAuth&&s.jsx(j,{className:"text-muted-foreground text-sm",children:e.siteUser?e.siteUser.name||e.siteUser.email:"—"}),s.jsx(j,{className:"text-muted-foreground",children:e.publishedAt?s.jsx("span",{title:xe(e.publishedAt),children:R(e.publishedAt)}):"—"})]},e.contentId))})]}),S?.hasMore&&s.jsx("div",{className:"mt-4 flex justify-center",children:s.jsx(y,{variant:"outline",onClick:()=>h(S.cursor??void 0),children:"Load More"})})]}):s.jsx("p",{className:"text-muted-foreground",children:"No submissions yet."})]})}export{Me as SubmissionListPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as g}from"./react-vendor-C2CvUxFh.js";import{y as r,B as x,j as b,X as y,I as A}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as g}from"./react-vendor-C2CvUxFh.js";import{y as r,B as x,j as b,X as y,I as A}from"./index-wYNPRVrc.js";import{x as z,y as N,z as k,B as C,E as T,F as S,G as B,H as I,J as E}from"./radix-C1kb_NqW.js";function K({...t}){return e.jsx(z,{"data-slot":"alert-dialog",...t})}function O({...t}){return e.jsx(B,{"data-slot":"alert-dialog-trigger",...t})}function R({...t}){return e.jsx(I,{"data-slot":"alert-dialog-portal",...t})}function _({className:t,...o}){return e.jsx(E,{"data-slot":"alert-dialog-overlay",className:r("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...o})}function P({className:t,size:o="default",...s}){return e.jsxs(R,{children:[e.jsx(_,{}),e.jsx(N,{"data-slot":"alert-dialog-content","data-size":o,className:r("bg-background 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 group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg",t),...s})]})}function G({className:t,...o}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:r("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...o})}function J({className:t,...o}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:r("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),...o})}function U({className:t,...o}){return e.jsx(k,{"data-slot":"alert-dialog-title",className:r("text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...o})}function W({className:t,...o}){return e.jsx(C,{"data-slot":"alert-dialog-description",className:r("text-muted-foreground text-sm",t),...o})}function X({className:t,variant:o="default",size:s="default",...i}){return e.jsx(x,{variant:o,size:s,asChild:!0,children:e.jsx(S,{"data-slot":"alert-dialog-action",className:r(t),...i})})}function $({className:t,variant:o="outline",size:s="default",...i}){return e.jsx(x,{variant:o,size:s,asChild:!0,children:e.jsx(T,{"data-slot":"alert-dialog-cancel",className:r(t),...i})})}function q({tags:t,onChange:o,placeholder:s,suggestions:i}){const[d,p]=g.useState(""),[f,u]=g.useState(-1),[h,c]=g.useState(!1),w=g.useRef(null),n=d&&i?i.filter(a=>a.toLowerCase().startsWith(d.toLowerCase())&&!t.includes(a)):[];function m(a){const l=a.trim().toLowerCase();l&&!t.includes(l)&&o([...t,l]),p(""),u(-1),c(!1)}function j(a){if(a.key==="ArrowDown"&&n.length>0){a.preventDefault(),u(l=>Math.min(l+1,n.length-1));return}if(a.key==="ArrowUp"&&n.length>0){a.preventDefault(),u(l=>Math.max(l-1,0));return}if(a.key==="Enter"||a.key===","){a.preventDefault(),f>=0&&f<n.length?m(n[f]):m(d);return}if(a.key==="Escape"){c(!1),u(-1);return}a.key==="Backspace"&&!d&&t.length>0&&o(t.slice(0,-1))}function v(a){o(t.filter(l=>l!==a))}return e.jsxs("div",{className:"relative",ref:w,children:[e.jsxs("div",{className:"flex flex-wrap gap-1 rounded-md border p-2 focus-within:ring-1 focus-within:ring-ring",children:[t.map(a=>e.jsxs(b,{variant:"secondary",className:"gap-1",children:[a,e.jsx("button",{type:"button",onClick:()=>v(a),className:"ml-0.5 rounded-full hover:bg-muted",children:e.jsx(y,{className:"h-3 w-3"})})]},a)),e.jsx(A,{value:d,onChange:a=>{p(a.target.value),u(-1),c(!0)},onKeyDown:j,onFocus:()=>c(!0),onBlur:()=>{setTimeout(()=>c(!1),150)},placeholder:t.length===0?s??"Add tags...":"",className:"min-w-[80px] flex-1 border-0 p-0 shadow-none focus-visible:ring-0"})]}),h&&n.length>0&&e.jsx("div",{className:"absolute z-10 mt-1 max-h-48 w-full overflow-auto rounded-md border bg-popover p-1 shadow-md",children:n.map((a,l)=>e.jsx("button",{type:"button",className:`w-full rounded-sm px-2 py-1.5 text-left text-sm ${l===f?"bg-accent text-accent-foreground":"hover:bg-accent/50"}`,onMouseDown:D=>{D.preventDefault(),m(a)},children:a},a))})]})}export{K as A,q as T,P as a,G as b,U as c,W as d,J as e,$ as f,X as g,O as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as b,r as x}from"./react-vendor-C2CvUxFh.js";import{u as D,a as y,b as v}from"./useTags-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as b,r as x}from"./react-vendor-C2CvUxFh.js";import{u as D,a as y,b as v}from"./useTags-CLPWVUB3.js";import{x as w,I as N,B as c,P as C,S as P,T as S,v as d,D as k,k as A,l as E,m as B,n as F,o as H}from"./index-wYNPRVrc.js";import{T as I,a as M,b as j,c as m,d as $,e as u}from"./table-WkEcC9MH.js";import{u as L}from"./usePageTitle-Bwf-MpTD.js";import"./radix-C1kb_NqW.js";function Q(){const{host:t}=b(),{data:s,isLoading:n}=D(t),o=y(t),[l,r]=x.useState(""),[T,g]=x.useState(null),f=w();L({title:"Tags"});async function p(a){a.preventDefault();const i=l.trim().toLowerCase();if(i)try{await o.mutateAsync(i),r(""),d.success(`Tag "${i}" created`)}catch(h){d.error("Failed to create tag",{description:h instanceof Error?h.message:void 0})}}return e.jsxs("div",{children:[!f&&e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsxs("h1",{className:"text-2xl font-semibold",children:["Tags",s?` (${s.length})`:""]})}),e.jsxs("form",{onSubmit:p,className:"mb-6 flex gap-2",children:[e.jsx(N,{value:l,onChange:a=>r(a.target.value),placeholder:"New tag name...",className:"max-w-xs"}),e.jsxs(c,{type:"submit",disabled:o.isPending||!l.trim(),children:[e.jsx(C,{className:"mr-2 h-4 w-4"}),"Add Tag"]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((a,i)=>e.jsx(P,{className:"h-12 w-full"},i))}):s?.length?e.jsxs(I,{children:[e.jsx(M,{children:e.jsxs(j,{children:[e.jsx(m,{children:"Tag"}),e.jsx(m,{children:"Published Content"}),e.jsx(m,{})]})}),e.jsx($,{children:s.map(a=>e.jsxs(j,{children:[e.jsx(u,{className:"font-medium",children:a.tag}),e.jsx(u,{className:"text-muted-foreground",children:a.count}),e.jsx(u,{children:e.jsx(c,{variant:"ghost",size:"sm",disabled:a.count>0,title:a.count>0?"Cannot delete a tag that is in use":"Delete tag",onClick:()=>g(a.tag),children:e.jsx(S,{className:"h-4 w-4"})})})]},a.tag))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No tags yet. Tags are created automatically when you publish content with tags, or you can create them manually above."}),e.jsx(R,{host:t,tag:T,onClose:()=>g(null)})]})}function R({host:t,tag:s,onClose:n}){const o=v(t);async function l(){if(s)try{await o.mutateAsync(s),d.success(`Tag "${s}" deleted`),n()}catch(r){d.error("Failed to delete tag",{description:r instanceof Error?r.message:void 0})}}return e.jsx(k,{open:!!s,onOpenChange:()=>n(),children:e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(B,{children:"Delete tag?"}),e.jsxs(F,{children:["This will remove the tag “",s,"” from the tag list. This action cannot be undone."]})]}),e.jsxs(H,{children:[e.jsx(c,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(c,{variant:"destructive",onClick:l,children:"Delete"})]})]})})}export{Q as TagsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as p}from"./react-vendor-C2CvUxFh.js";import{u as P,p as B,d as L,q as z,r as O,s as q,H as R,I as _,S as G,j as J,B as l,t as K,D as g,i as Q,T as V,k as D,l as v,m as A,n as C,o as N,v as n}from"./index-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{r as p}from"./react-vendor-C2CvUxFh.js";import{u as P,p as B,d as L,q as z,r as O,s as q,H as R,I as _,S as G,j as J,B as l,t as K,D as g,i as Q,T as V,k as D,l as v,m as A,n as C,o as N,v as n}from"./index-wYNPRVrc.js";import{C as W}from"./checkbox-fC1QPb_4.js";import{T as X,a as Y,b as w,c as r,d as Z,e as c}from"./table-WkEcC9MH.js";import"./radix-C1kb_NqW.js";function le(){const{user:S}=P(),{data:y,isLoading:T}=B(),{data:U}=L(),k=z(),u=O(),h=q(),m=y?.items??[],x=U?.superAdminIds??[],[j,F]=p.useState(""),[E,f]=p.useState(null),[d,o]=p.useState(null),b=j?m.filter(s=>s.email.toLowerCase().includes(j.toLowerCase())):m;async function M(s){try{await u.mutateAsync(s),n.success("User deleted"),f(null)}catch(a){n.error("Failed to delete user",{description:a instanceof Error?a.message:void 0})}}async function H(s){try{await h.mutateAsync(s),n.success("Two-factor authentication disabled"),o(null)}catch(a){n.error("Failed to disable 2FA",{description:a instanceof Error?a.message:void 0})}}async function I(s,a){const t=a?x.filter(i=>i!==s):[...x,s];if(t.length===0){n.error("At least one super admin is required");return}try{await k.mutateAsync({superAdminIds:t}),n.success(a?"Super admin removed":"Super admin added")}catch(i){n.error("Failed to update super admins",{description:i instanceof Error?i.message:void 0})}}return e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(R,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-semibold",children:"All Users"})}),e.jsx("div",{className:"mb-4",children:e.jsx(_,{placeholder:"Search by email...",value:j,onChange:s=>F(s.target.value),className:"max-w-sm"})}),T?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,a)=>e.jsx(G,{className:"h-12 w-full"},a))}):b.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No users found."}):e.jsxs(X,{children:[e.jsx(Y,{children:e.jsxs(w,{children:[e.jsx(r,{children:"Email"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"2FA"}),e.jsx(r,{children:"Super Admin"}),e.jsx(r,{})]})}),e.jsx(Z,{children:b.map(s=>{const a=s.sub===S?.sub,t=x.includes(s.sub);return e.jsxs(w,{children:[e.jsxs(c,{className:"text-sm",children:[s.email,a&&e.jsx("span",{className:"text-muted-foreground ml-2",children:"(you)"})]}),e.jsx(c,{className:"text-sm capitalize",children:s.status}),e.jsx(c,{children:s.mfaEnabled?e.jsx(J,{variant:"outline",className:"border-green-500 text-green-700",children:"Enabled"}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(c,{children:e.jsx(W,{checked:t,onCheckedChange:()=>I(s.sub,t)})}),e.jsx(c,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[!a&&s.mfaEnabled&&e.jsx(l,{variant:"ghost",size:"sm",title:"Disable 2FA",onClick:()=>o(s.sub),children:e.jsx(K,{className:"h-4 w-4"})}),!a&&e.jsxs(g,{open:E===s.sub,onOpenChange:i=>f(i?s.sub:null),children:[e.jsx(Q,{asChild:!0,children:e.jsx(l,{variant:"ghost",size:"sm",className:"text-destructive",title:"Delete account",children:e.jsx(V,{className:"h-4 w-4"})})}),e.jsxs(D,{children:[e.jsxs(v,{children:[e.jsx(A,{children:"Delete User Account"}),e.jsx(C,{className:"sr-only",children:"Confirm permanent deletion of this user account"})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This will permanently delete the account for"," ",e.jsx("strong",{children:s.email}),". They will lose access to all sites."]}),e.jsxs(N,{children:[e.jsx(l,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:()=>M(s.sub),disabled:u.isPending,children:u.isPending?"Deleting...":"Delete Account"})]})]})]})]})})]},s.sub)})})]}),e.jsx(g,{open:d!==null,onOpenChange:s=>{s||o(null)},children:e.jsxs(D,{children:[e.jsxs(v,{children:[e.jsx(A,{children:"Disable Two-Factor Authentication"}),e.jsxs(C,{children:["This will disable 2FA for"," ",e.jsx("strong",{children:m.find(s=>s.sub===d)?.email}),". They will be able to log in with just their password."]})]}),e.jsxs(N,{children:[e.jsx(l,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:()=>{d&&H(d)},disabled:h.isPending,children:h.isPending?"Disabling...":"Disable 2FA"})]})]})})]})]})}export{le as UsersPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as R,f as U,r as d}from"./react-vendor-C2CvUxFh.js";import{a as M,b as q,c as K,d as V,e as Y,f as _}from"./useWebhooks-
|
|
1
|
+
import{j as e}from"./tanstack-Bs3zYPPV.js";import{u as R,f as U,r as d}from"./react-vendor-C2CvUxFh.js";import{a as M,b as q,c as K,d as V,e as Y,f as _}from"./useWebhooks-no0l3-mF.js";import{S as v,x as z,L as W,I as G,j as y,B as l,a as J,aE as Q,D as X,i as Z,T as ee,k as se,l as te,m as ae,n as ne,o as re,v as i}from"./index-wYNPRVrc.js";import{C as b,c as j,a as T,b as w}from"./card-10FqkZPA.js";import{T as oe,a as ie,b as C,c as p,d as le,e as f}from"./table-WkEcC9MH.js";import{f as ce}from"./format-C88SDH8g.js";import{u as de}from"./usePageTitle-Bwf-MpTD.js";import"./radix-C1kb_NqW.js";const he=["content.published","content.unpublished","content.deleted"];function ve(){const{host:t,id:a}=R(),n=a==="new",{data:o,isLoading:c}=M(t,n?"":a);return!n&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{className:"h-8 w-64"}),e.jsx(v,{className:"h-64 w-full"})]}):n?e.jsx(N,{host:t,isNew:!0}):o?e.jsx(N,{host:t,isNew:!1,webhook:o},o.webhookId):e.jsx("p",{className:"text-muted-foreground",children:"Webhook not found."})}function N({host:t,isNew:a,webhook:n}){const o=U(),c=q(t),h=K(t,n?.webhookId??""),D=V(t,n?.webhookId??""),S=Y(t,n?.webhookId??""),{data:u}=_(t,a?"":n?.webhookId??""),[m,E]=d.useState(n?.url??""),[x,I]=d.useState(n?.events??[]),[g,P]=d.useState(null),[B,k]=d.useState(!1),F=z();de({title:a?"New Webhook":"Edit Webhook",showBack:!0,backTo:`/sites/${t}/settings/webhooks`});function A(s){I(r=>r.includes(s)?r.filter($=>$!==s):[...r,s])}async function H(s){s.preventDefault();try{if(a){const r=await c.mutateAsync({url:m,events:x,enabled:!0});P(r.secret??null),i.success("Webhook created"),o(`/sites/${t}/settings/webhooks/${r.webhookId}`,{replace:!0})}else await h.mutateAsync({url:m,events:x,enabled:n?.enabled}),i.success("Webhook updated")}catch(r){i.error(a?"Failed to create":"Failed to update",{description:r instanceof Error?r.message:void 0})}}async function L(){try{await S.mutateAsync(),i.success("Test webhook sent")}catch(s){i.error("Test failed",{description:s instanceof Error?s.message:void 0})}}async function O(){try{await D.mutateAsync(),i.success("Webhook deleted"),o(`/sites/${t}/settings/webhooks`)}catch(s){i.error("Failed to delete",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[!F&&e.jsx("h1",{className:"text-2xl font-semibold",children:a?"New Webhook":"Edit Webhook"}),g&&e.jsx(b,{className:"border-yellow-500",children:e.jsxs(j,{className:"pt-6",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Webhook Secret"}),e.jsx("p",{className:"text-muted-foreground mb-2 text-sm",children:"Save this secret now. You won't see it again."}),e.jsx("code",{className:"bg-muted rounded px-2 py-1 text-sm",children:g})]})}),e.jsxs(b,{children:[e.jsx(T,{children:e.jsx(w,{children:"Webhook Settings"})}),e.jsx(j,{children:e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"url",children:"URL"}),e.jsx(G,{id:"url",type:"url",value:m,onChange:s=>E(s.target.value),required:!0,placeholder:"https://example.com/webhook"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{children:"Events"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:he.map(s=>e.jsx(y,{variant:x.includes(s)?"default":"outline",className:"cursor-pointer",onClick:()=>A(s),children:s},s))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{type:"submit",disabled:c.isPending||h.isPending,children:[(c.isPending||h.isPending)&&e.jsx(J,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Create":"Save"]}),!a&&e.jsxs(l,{type:"button",variant:"outline",onClick:L,children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),"Test"]}),e.jsx(l,{type:"button",variant:"outline",onClick:()=>o(`/sites/${t}/settings/webhooks`),children:"Cancel"})]})]})})]}),!a&&u?.items&&u.items.length>0&&e.jsxs(b,{children:[e.jsx(T,{children:e.jsx(w,{children:"Recent Deliveries"})}),e.jsx(j,{children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsxs(C,{children:[e.jsx(p,{children:"Event"}),e.jsx(p,{children:"Status"}),e.jsx(p,{children:"Time"})]})}),e.jsx(le,{children:u.items.map(s=>e.jsxs(C,{children:[e.jsx(f,{children:s.event}),e.jsx(f,{children:e.jsx(y,{variant:s.status==="success"?"default":"destructive",children:s.responseStatus??"Error"})}),e.jsx(f,{className:"text-muted-foreground",children:ce(s.createdAt)})]},s.deliveryId))})]})})]}),!a&&e.jsxs(X,{open:B,onOpenChange:k,children:[e.jsx(Z,{asChild:!0,children:e.jsxs(l,{variant:"destructive",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Delete Webhook"]})}),e.jsxs(se,{children:[e.jsxs(te,{children:[e.jsx(ae,{children:"Delete webhook?"}),e.jsx(ne,{children:"This action cannot be undone."})]}),e.jsxs(re,{children:[e.jsx(l,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:O,children:"Delete"})]})]})]})]})}export{ve as WebhookEditPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as j,f as b}from"./react-vendor-C2CvUxFh.js";import{u}from"./useWebhooks-
|
|
1
|
+
import{j as s}from"./tanstack-Bs3zYPPV.js";import{u as j,f as b}from"./react-vendor-C2CvUxFh.js";import{u}from"./useWebhooks-no0l3-mF.js";import{x as f,B as r,P as c,S as p,j as d}from"./index-wYNPRVrc.js";import{T as k,a as g,b as m,c as i,d as N,e as l}from"./table-WkEcC9MH.js";import{u as v}from"./usePageTitle-Bwf-MpTD.js";import"./radix-C1kb_NqW.js";function I(){const{host:a}=j(),t=b(),{data:n,isLoading:x}=u(a),h=f();return v({title:"Webhooks",actions:s.jsx(r,{size:"sm",onClick:()=>t(`/sites/${a}/settings/webhooks/new`),children:s.jsx(c,{className:"h-4 w-4"})})}),s.jsxs("div",{children:[!h&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsx("h1",{className:"text-2xl font-semibold",children:"Webhooks"}),s.jsxs(r,{onClick:()=>t(`/sites/${a}/settings/webhooks/new`),children:[s.jsx(c,{className:"mr-2 h-4 w-4"}),"New Webhook"]})]}),x?s.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((e,o)=>s.jsx(p,{className:"h-12 w-full"},o))}):n?.items.length?s.jsxs(k,{children:[s.jsx(g,{children:s.jsxs(m,{children:[s.jsx(i,{children:"URL"}),s.jsx(i,{children:"Events"}),s.jsx(i,{children:"Status"})]})}),s.jsx(N,{children:n.items.map(e=>s.jsxs(m,{className:"cursor-pointer",onClick:()=>t(`/sites/${a}/settings/webhooks/${e.webhookId}`),children:[s.jsx(l,{className:"max-w-xs truncate font-mono text-sm",children:e.url}),s.jsx(l,{children:s.jsx("div",{className:"flex flex-wrap gap-1",children:e.events.map(o=>s.jsx(d,{variant:"secondary",className:"text-xs",children:o},o))})}),s.jsx(l,{children:s.jsx(d,{variant:e.enabled?"default":"secondary",children:e.enabled?"Active":"Inactive"})})]},e.webhookId))})]}):s.jsx("p",{className:"text-muted-foreground",children:"No webhooks configured."})]})}export{I as WebhooksPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{y as d}from"./index-
|
|
1
|
+
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{y as d}from"./index-wYNPRVrc.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("leading-none font-semibold",a),...t})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-6",a),...t})}export{n as C,i as a,c as b,u as c,l as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{
|
|
1
|
+
import{j as r}from"./tanstack-Bs3zYPPV.js";import"./react-vendor-C2CvUxFh.js";import{Z as i,y as t}from"./index-wYNPRVrc.js";import{$ as s,a0 as o}from"./radix-C1kb_NqW.js";function b({className:e,...a}){return r.jsx(s,{"data-slot":"checkbox",className:t("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(o,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(i,{className:"size-3.5"})})})}export{b as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as o}from"./tanstack-Bs3zYPPV.js";import{K as t,M as s,N as a}from"./radix-C1kb_NqW.js";function i({...l}){return o.jsx(t,{"data-slot":"collapsible",...l})}function n({...l}){return o.jsx(s,{"data-slot":"collapsible-trigger",...l})}function p({...l}){return o.jsx(a,{"data-slot":"collapsible-content",...l})}export{i as C,n as a,p as b};
|