@blinkk/root-cms 3.1.4 → 3.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/dist/app.js +3 -2
- package/dist/{chunk-AFBSITEO.js → chunk-PLSNGCYU.js} +200 -22
- package/dist/{chunk-MYN76V3L.js → chunk-U4TMO2LI.js} +2 -2
- package/dist/{chunk-NC3CRIFA.js → chunk-Z2CTQVYR.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/client.js +1 -1
- package/dist/core/client.d.ts +30 -2
- package/dist/core/cron-schedule.d.ts +63 -0
- package/dist/core/plugin.d.ts +6 -1
- package/dist/core/schema.d.ts +88 -3
- package/dist/core.js +1 -1
- package/dist/functions.js +2 -2
- package/dist/plugin.js +7 -5
- package/dist/richtext.js +1 -1
- package/dist/shared/embed-protocol.d.ts +19 -0
- package/dist/ui/AIPage-EO5WH25R.js +1 -0
- package/dist/ui/{AssetsPage-QUL2NBWK.js → AssetsPage-ESLB4R3I.js} +1 -1
- package/dist/ui/CollectionPage-MXN7XKUX.js +1 -0
- package/dist/ui/{ComparePage-DCP5QHDE.js → ComparePage-TY7VJVE3.js} +1 -1
- package/dist/ui/{DataPage-TUVFBALT.js → DataPage-YEIS7HBN.js} +1 -1
- package/dist/ui/{DataSourcePage-YE2ZOHYI.js → DataSourcePage-VD6YBDRW.js} +1 -1
- package/dist/ui/{DocTranslationsPage-3ILTQOP2.js → DocTranslationsPage-6XLREBPQ.js} +1 -1
- package/dist/ui/DocumentPage-2HNNEGRI.js +1 -0
- package/dist/ui/{EditDataSourcePage-WHPZDMD4.js → EditDataSourcePage-E4PSKSG3.js} +1 -1
- package/dist/ui/EditReleasePage-DOMXJXCU.js +1 -0
- package/dist/ui/EmbeddedAIPage-U5LONYH2.js +1 -0
- package/dist/ui/EmbeddedDocumentPage-HYV5GPK6.js +1 -0
- package/dist/ui/{ImageEditorDialog-Q44YTLB5.js → ImageEditorDialog-YDKOGVJV.js} +1 -1
- package/dist/ui/LogsPage-6KV3CQLH.js +1 -0
- package/dist/ui/NewDataSourcePage-NJJDHGPX.js +1 -0
- package/dist/ui/NewReleasePage-FXHPFUVG.js +1 -0
- package/dist/ui/{NotFoundPage-RMNPVSD3.js → NotFoundPage-CA7XVXUO.js} +1 -1
- package/dist/ui/{ProjectPage-VY4EJX6J.js → ProjectPage-XUBJSCWB.js} +1 -1
- package/dist/ui/ReleasePage-NLGRYJX7.js +1 -0
- package/dist/ui/{ReleasesPage-A4BLUNJE.js → ReleasesPage-OY7OKC3C.js} +1 -1
- package/dist/ui/{SettingsPage-MP3YHQDP.js → SettingsPage-5EQUY52A.js} +1 -1
- package/dist/ui/SidebarToolsPage-FWG6TIDI.js +1 -0
- package/dist/ui/TaskPage-APNRUOYG.js +1 -0
- package/dist/ui/TasksPage-FTEELXVZ.js +1 -0
- package/dist/ui/{TranslationsArbPage-B7TIRREV.js → TranslationsArbPage-PG5USRYB.js} +1 -1
- package/dist/ui/{TranslationsEditPage-VQG4YHA6.js → TranslationsEditPage-GV3ZJXTY.js} +1 -1
- package/dist/ui/{TranslationsPage-6VCVMNXI.js → TranslationsPage-3AKSMCNF.js} +1 -1
- package/dist/ui/{chunk-5SY2SVEX.js → chunk-235TRWJF.js} +2 -2
- package/dist/ui/{chunk-EYVQCOAD.js → chunk-2PTLQRTU.js} +1 -1
- package/dist/ui/{chunk-FF4CLAZS.js → chunk-2RRM4HEQ.js} +1 -1
- package/dist/ui/{chunk-MAZJRNAL.js → chunk-34W6H4YG.js} +1 -1
- package/dist/ui/{chunk-AZ2SK2ZK.js → chunk-3LEYSXZP.js} +1 -1
- package/dist/ui/{chunk-L3O3CLWO.js → chunk-44ZU5WMI.js} +1 -1
- package/dist/ui/{chunk-MYKJ6VAM.js → chunk-535JU7FU.js} +1 -1
- package/dist/ui/chunk-56NMZYX6.js +19 -0
- package/dist/ui/{chunk-3WQCVKK4.js → chunk-6WJQBFN5.js} +1 -1
- package/dist/ui/{chunk-UHK5N75L.js → chunk-75NMQ3LW.js} +1 -1
- package/dist/ui/{chunk-4N6CPIOQ.js → chunk-A7IZAHBZ.js} +1 -1
- package/dist/ui/{chunk-2PDMFZBF.js → chunk-C5FRMXDS.js} +1 -1
- package/dist/ui/chunk-EYJ6GKZR.js +1 -0
- package/dist/ui/{chunk-VB5VMEN7.js → chunk-F7RQT4XN.js} +1 -1
- package/dist/ui/chunk-G5647K25.js +1 -0
- package/dist/ui/{chunk-74OB6FM4.js → chunk-H37RXS4R.js} +1 -1
- package/dist/ui/{chunk-LC6WLVRS.js → chunk-HV3JJ5UT.js} +1 -1
- package/dist/ui/{chunk-K3UM5OQF.js → chunk-HXSB6YB2.js} +1 -1
- package/dist/ui/chunk-ISUGBMXC.js +1 -0
- package/dist/ui/{chunk-WN7HUDGY.js → chunk-JBLSUM6W.js} +1 -1
- package/dist/ui/chunk-LAXQZPE3.js +31 -0
- package/dist/ui/chunk-MYPLMHFW.js +1 -0
- package/dist/ui/{chunk-KBJ4AK5O.js → chunk-NCZD5IWS.js} +1 -1
- package/dist/ui/{chunk-XJUQOX4E.js → chunk-O7ESOZQO.js} +1 -1
- package/dist/ui/chunk-OWYV43BT.js +1 -0
- package/dist/ui/{chunk-XM35ZJBQ.js → chunk-PIJ3E47R.js} +1 -1
- package/dist/ui/{chunk-WAT22UHZ.js → chunk-PLYSJ7W5.js} +1 -1
- package/dist/ui/{chunk-H3PYPGNR.js → chunk-QFDU6FXP.js} +1 -1
- package/dist/ui/{chunk-JSWRHHTZ.js → chunk-QGAPMQEJ.js} +1 -1
- package/dist/ui/{chunk-W3ICOHMF.js → chunk-QLIIVG5Q.js} +1 -1
- package/dist/ui/{chunk-ELKXEMOU.js → chunk-QRAFYIAW.js} +1 -1
- package/dist/ui/{chunk-VRRRFAIV.js → chunk-QWB6MAPJ.js} +1 -1
- package/dist/ui/{chunk-GCMX5V3P.js → chunk-RB23LLKL.js} +1 -1
- package/dist/ui/{chunk-W2ZAVRAT.js → chunk-ST6QNIWT.js} +57 -57
- package/dist/ui/{chunk-76PG55CM.js → chunk-U7LSFUHT.js} +1 -1
- package/dist/ui/{chunk-HVYNDEA7.js → chunk-UCYWQEAS.js} +1 -1
- package/dist/ui/{chunk-6P75AZ3B.js → chunk-UJX25CXD.js} +1 -1
- package/dist/ui/chunk-UOKVF54Y.js +3 -0
- package/dist/ui/{chunk-CSUKZZK5.js → chunk-VJRMR2JM.js} +1 -1
- package/dist/ui/{chunk-WS37MDM3.js → chunk-WASID5UU.js} +1 -1
- package/dist/ui/chunk-WRA24P66.js +7 -0
- package/dist/ui/{chunk-ETPZ3TXX.js.LEGAL.txt → chunk-WRA24P66.js.LEGAL.txt} +4 -1
- package/dist/ui/{chunk-QHOZXW7Y.js → chunk-Y5EOMMNI.js} +1 -1
- package/dist/ui/{chunk-EIMRPYCD.js → chunk-YBHFGQ3Z.js} +1 -1
- package/dist/ui/{chunk-62VPTZJL.js → chunk-YP6ZH3MT.js} +1 -1
- package/dist/ui/chunk-Z2CRNO3I.js +1 -0
- package/dist/ui/{chunk-PR7NB5VK.js → chunk-Z3ZJJWFT.js} +1 -1
- package/dist/ui/{chunk-F4F5MH7A.js → chunk-ZAJPNVYS.js} +1 -1
- package/dist/ui/ui.css +1 -1
- package/dist/ui/ui.js +1 -1
- package/package.json +3 -3
- package/dist/ui/AIPage-4W4MFELY.js +0 -1
- package/dist/ui/CollectionPage-7VU6SUUP.js +0 -1
- package/dist/ui/DocumentPage-JFQ3Y2GH.js +0 -1
- package/dist/ui/EditReleasePage-QKWHIURV.js +0 -1
- package/dist/ui/EmbeddedAIPage-SQLOV4IT.js +0 -1
- package/dist/ui/EmbeddedDocumentPage-6FYHUHTE.js +0 -1
- package/dist/ui/LogsPage-RC5O722W.js +0 -1
- package/dist/ui/NewDataSourcePage-QXW54CHQ.js +0 -1
- package/dist/ui/NewReleasePage-TKYWVTOH.js +0 -1
- package/dist/ui/ReleasePage-VZAL4KUI.js +0 -1
- package/dist/ui/SidebarToolsPage-S5DMIEQ6.js +0 -1
- package/dist/ui/TaskPage-LCBDMA4I.js +0 -1
- package/dist/ui/TasksPage-72KVSUQY.js +0 -1
- package/dist/ui/chunk-ETPZ3TXX.js +0 -7
- package/dist/ui/chunk-IMXZTYAA.js +0 -3
- package/dist/ui/chunk-J5KDO4RM.js +0 -1
- package/dist/ui/chunk-NEA3XU6N.js +0 -19
- package/dist/ui/chunk-RN4XVVWD.js +0 -1
- package/dist/ui/chunk-SLLTYDVX.js +0 -1
- package/dist/ui/chunk-SWTNOWNE.js +0 -1
- package/dist/ui/chunk-V3G3554T.js +0 -31
- package/dist/ui/chunk-YV5SGR24.js +0 -1
- /package/dist/ui/{ImageEditorDialog-Q44YTLB5.js.LEGAL.txt → ImageEditorDialog-YDKOGVJV.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-5SY2SVEX.js.LEGAL.txt → chunk-235TRWJF.js.LEGAL.txt} +0 -0
- /package/dist/ui/{chunk-W2ZAVRAT.js.LEGAL.txt → chunk-ST6QNIWT.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as mt,b as ut,c as gt}from"./chunk-FF4CLAZS.js";import{a as pt}from"./chunk-WAT22UHZ.js";import{a as ft}from"./chunk-W5DOO6ID.js";import{a as _t}from"./chunk-EIMRPYCD.js";import{b as M}from"./chunk-EYVQCOAD.js";import{a as A,b as He,c as Oe}from"./chunk-XM35ZJBQ.js";import{g as oe,h as Ke,i as Me,j as Ze,k as Je,l as Qe,m as Ye,n as et,o as tt,p as st,q as ce,r as ot,s as Fe,t as at,u as me,y as _e,z as fe}from"./chunk-YV5SGR24.js";import{B as Ce,z as Ve}from"./chunk-XOWWPE7X.js";import{e as ue}from"./chunk-WS37MDM3.js";import{$a as Ne,Ab as nt,Bb as he,Da as re,Dc as dt,Eb as it,Fa as Ge,Fb as ve,Ga as e,Gb as ze,Qb as rt,Sc as W,V as te,Vc as ct,W as se,a as i,c as U,da as g,ea as G,g as $e,j as Le,mb as ge,na as je,nc as Ie,qa as k,ra as S,ua as H,ub as De,wb as pe,xb as lt}from"./chunk-ETPZ3TXX.js";import{d as C}from"./chunk-KUCVLANF.js";import{g as We,h as de,k as D,l as O,m as ke,n as V,o as Xe,p as qe}from"./chunk-7SK47HHZ.js";Le();Le();function ht(t){let o=t.file||{},a=o.src||"",l=o.filename||a,r={"--asset-thumb-size":`${t.size}px`};if(a&&O(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("img",{src:Te(o,t.size*2),alt:o.alt||"",loading:"lazy"})});if(a&&V(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("video",{src:a,muted:!0,playsInline:!0,preload:"metadata"})});let m=D(l);return e("div",{className:"AssetBrowser__thumb",style:r,children:m&&m.length<=4?e("div",{className:"AssetBrowser__thumb__ext",children:m}):e(he,{size:20,stroke:"1.5"})})}function Te(t,o){let a=t?.src||"";return a.startsWith(We)&&o?`${a}=s${o}`:a}function we(t){let o=t?.src||"";ke(o)&&(o=o.split("=")[0]+"=s0"),navigator.clipboard.writeText(o).then(()=>{A({message:"Copied URL to clipboard.",autoClose:2e3})})}function be(t){let o=t?.src||"";if(o)if(ke(o)){let a=document.createElement("a");a.href=qe(o),t.filename&&(a.download=t.filename),document.body.appendChild(a),a.click(),document.body.removeChild(a)}else window.open(o,"_blank")}function vt(t){let[o,a]=i(t.asset),[l,r]=i(t.asset.file?.alt||""),[m,d]=i(!1),[x,v]=i(!1),[f,B]=i(null),[w,F]=i(null),n=o.file||{},u=n.filename||o.name,N=O(u),R=V(u),X=l!==(n.alt||""),q=n.altDisabled===!0;U(()=>{_e(o.id).then(c=>F(c)).catch(c=>{console.error("failed to fetch asset usage:",c),F([])})},[o.id]);async function z(c,b){let p=await fe(c,{previousFile:b});p.failedDocIds.length>0?A({title:"Some docs failed to update",message:`Failed to update: ${p.failedDocIds.join(", ")}. Re-save the asset to retry.`,color:"red",autoClose:!1}):p.updatedDocIds.length>0&&A({message:`Updated ${p.updatedDocIds.length} doc(s) that use this asset.`,color:"green"})}async function K(){d(!0),await M(async()=>{let c={...n},b=await at(o,l);a(b),t.onChanged(b),await z(b,c)}),d(!1)}function E(){let c=document.createElement("input");c.type="file",c.onchange=()=>{let b=c.files?.[0];if(!b)return;let p=D(u),y=D(b.name);if(p&&y&&p!==y){B(b);return}$(b)},c.click(),c.remove()}async function $(c){B(null),d(!0),await M(async()=>{let b={...n},p=await de(c),y=await ot(o,p);a(y),r(y.file?.alt||""),t.onChanged(y),await z(y,b)}),d(!1)}async function P(c){d(!0),await M(async()=>{let b={...n},p=await me(o,c);a(p),r(p.file?.alt||""),t.onChanged(p),await z(p,b)}),d(!1)}async function Z(){d(!0),await M(async()=>{await ce(o),A({message:`Deleted "${o.name}".`,color:"green"}),t.onDeleted()}),d(!1)}return e(S,{className:"AssetBrowser__detailsModal",opened:!0,onClose:t.onClose,title:o.name,size:720,overflow:"outside",centered:!0,children:e("div",{className:"AssetBrowser__details",children:[e("div",{className:"AssetBrowser__details__preview",children:N?e("img",{src:Te(n,800),alt:n.alt||"",style:n.canvasBgColor==="dark"?{background:"#000"}:{}}):R?e("video",{src:n.src,controls:!0,muted:!0,preload:"metadata"}):e("div",{className:"AssetBrowser__details__preview__placeholder",children:[e(he,{size:48,stroke:"1"}),e("div",{children:u})]})}),e(re,{className:"AssetBrowser__details__table",verticalSpacing:"xs",fontSize:"xs",children:e("tbody",{children:[e("tr",{children:[e("td",{children:e("b",{children:"Filename"})}),e("td",{children:u})]}),!!(n.width&&n.height)&&e("tr",{children:[e("td",{children:e("b",{children:"Dimensions"})}),e("td",{children:[n.width,"x",n.height]})]}),o.createdAt&&e("tr",{children:[e("td",{children:e("b",{children:"Uploaded"})}),e("td",{children:[Ce(o.createdAt),o.createdBy&&e(C,{children:[" by ",o.createdBy]})]})]}),o.modifiedAt&&e("tr",{children:[e("td",{children:e("b",{children:"Modified"})}),e("td",{children:[Ce(o.modifiedAt),o.modifiedBy&&e(C,{children:[" by ",o.modifiedBy]})]})]}),e("tr",{children:[e("td",{children:e("b",{children:"URL"})}),e("td",{children:e("div",{className:"AssetBrowser__details__url",children:[e(H,{readOnly:!0,value:n.src||"",size:"xs",radius:"xs",onClick:c=>c.target.select(),styles:{root:{flex:1,minWidth:0}}}),e(Ge,{label:"Copy URL",transition:"pop",children:e(se,{size:"sm",onClick:()=>we(n),children:e(ge,{size:16})})})]})})]})]})}),(N||R)&&e("div",{className:"AssetBrowser__details__alt",children:[q?e("div",{className:"AssetBrowser__details__alt__disabledNote",children:"Alt text is disabled for this asset. Docs that use it hide the alt text input and render no alt text."}):e(C,{children:[e(je,{label:"Alt text",description:"Used as the default alt text when the asset is selected in a doc. Updating it syncs docs that use this asset.",autosize:!0,minRows:1,size:"xs",value:l,disabled:!t.canManage||m,onChange:c=>r(c.currentTarget.value)}),t.canManage&&X&&e(g,{size:"xs",color:"dark",mt:8,loading:m,onClick:()=>K(),children:"Save alt text"})]}),t.canManage&&e(G,{className:"AssetBrowser__details__alt__disableCheckbox",label:"Disable alt text (e.g. decorative images)",size:"xs",mt:8,checked:q,disabled:m,onChange:c=>P(c.currentTarget.checked)})]}),e("div",{className:"AssetBrowser__details__usage",children:[e("div",{className:"AssetBrowser__details__usage__title",children:"Used in"}),w===null?e(te,{color:"gray",size:"sm"}):w.length===0?e("div",{className:"AssetBrowser__details__usage__empty",children:"No docs use this asset."}):e("div",{className:"AssetBrowser__details__usage__list",children:w.map(c=>e("a",{className:"AssetBrowser__details__usage__doc",href:`/cms/content/${c.id}`,target:"_blank",rel:"noreferrer",children:[e("span",{children:c.id}),e(lt,{size:14})]},c.id))})]}),e("div",{className:"AssetBrowser__details__buttons",children:[e(g,{variant:"default",size:"xs",leftIcon:e(pe,{size:14}),onClick:()=>be(n),children:"Download"}),t.canManage&&e(C,{children:[e(g,{variant:"default",size:"xs",leftIcon:e(nt,{size:14}),loading:m,onClick:()=>E(),children:"Replace file"}),e(g,{className:"AssetBrowser__details__buttons__delete",color:"red",variant:"filled",size:"xs",leftIcon:e(W,{size:14}),disabled:m,onClick:()=>v(!0),children:"Delete"})]})]}),f&&e("div",{className:"AssetBrowser__details__confirmReplace",children:[e("div",{children:["The new file has a different type (",e("b",{children:[".",D(u)]})," ","\u2192 ",e("b",{children:[".",D(f.name)]}),"). Replacing will change the asset's file extension and serving URL",Fe(o.name,D(f.name))!==o.name&&e(C,{children:[", and the asset will be renamed to"," ",e("b",{children:Fe(o.name,D(f.name))})]}),". Docs that use this asset will be updated."]}),e("div",{className:"AssetBrowser__details__confirmReplace__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>B(null),disabled:m,children:"Cancel"}),e(g,{color:"dark",size:"xs",loading:m,onClick:()=>$(f),children:"Replace"})]})]}),x&&e("div",{className:"AssetBrowser__details__confirmDelete",children:[e("div",{children:["Delete ",e("b",{children:o.name})," from the asset library?",w&&w.length>0&&e(C,{children:[" ","This asset is used in ",w.length," doc(s); those docs keep their copy of the file but will no longer receive updates."]})]}),e("div",{className:"AssetBrowser__details__confirmDelete__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>v(!1),disabled:m,children:"Cancel"}),e(g,{color:"red",size:"xs",loading:m,onClick:()=>Z(),children:"Delete"})]})]})]})})}var Mt=100;function Ue(t){let[o,a]=i(t.folder??t.initialFolder??""),l=t.folder??o,[r,m]=i([]),[d,x]=i(!0),[v,f]=i(""),[B,w]=i(!1),[F,n]=i(!1),[u,N]=i(null),[R,X]=i(!1),[q,z]=i(null),[K,E]=i(null),[$,P]=i(null),[Z,c]=i(null),[b,p]=i(null),[y,ae]=i(new Map),{roles:At}=_t(),xt=window.firebase.user.email||"",J=ft(At,xt),Q=v.trim().length>0;function L(s){a(s),f(""),t.onFolderChange&&t.onFolderChange(s)}async function I(s){x(!0),N(null),ae(new Map),await M(async()=>{let _=await Me(s);m(_)}),x(!1)}U(()=>{I(l)},[l]),U(()=>{if(!Q||u!==null)return;let s=!1;return(async()=>{let _=[];await M(async()=>{_=await Ze(l)}),s||N(_)})(),()=>{s=!0}},[Q,u,l]);let Ae=t.mode==="manage"?t.initialAssetId:"";U(()=>{Ae&&M(async()=>{let s=await Qe(Ae);s&&s.type==="file"&&(L(s.parent),p(s))})},[Ae]);let Se=$e(()=>{let s=v.trim().toLowerCase(),_=s?u||[]:r;return t.mode==="pick"&&(_=_.filter(h=>h.type==="folder"||Xe(h.file?.filename||h.name,t.accept))),s&&(_=_.filter(h=>h.name.toLowerCase().includes(s))),_},[r,u,v,t.mode,t.accept]),T=mt(Se,{pageSize:Mt,resetDeps:[l,v]}),j=T.pageItems;async function Ee(s){if(s.length===0||F)return;let _="asset-browser-upload";n(!0),A({id:_,message:`Uploading ${s.length} file(s)...`,loading:!0,autoClose:!1,disallowClose:!0});let h=[],Be=[];for(let ne=0;ne<s.length;ne++){let ie=s[ne];He({id:_,message:`Uploading ${ie.name} (${ne+1} of ${s.length})...`,loading:!0,autoClose:!1,disallowClose:!0});try{let ye=await de(ie),kt=await et({parent:l,file:ye});h.push(kt)}catch(ye){console.error(`failed to upload ${ie.name}:`,ye),Be.push(ie.name)}}Oe(_),n(!1),Be.length>0?A({title:"Upload failed",message:`Failed to upload: ${Be.join(", ")}`,color:"red",autoClose:!1}):A({message:`Uploaded ${h.length} file(s).`,color:"green"}),await I(l),t.mode==="pick"&&h.length===1&&s.length===1&&t.onPickFile&&t.onPickFile(h[0])}function Bt(){let s=document.createElement("input");s.type="file",s.multiple=!0,t.mode==="pick"&&t.accept&&t.accept.length>0&&(s.accept=t.accept.join(",")),s.onchange=()=>{Ee(Array.from(s.files||[]))},s.click(),s.remove()}function yt(s){t.onPickFile&&t.onPickFile(s)}let Y=J,le=t.mode==="manage"&&J,ee=Array.from(y.values()),Pe=ee.filter(s=>s.type==="file"&&!s.file?.altDisabled&&(O(s.file?.filename||s.name)||V(s.file?.filename||s.name))),xe=j.length>0&&j.every(s=>y.has(s.id));function Re(s){ae(_=>{let h=new Map(_);return h.has(s.id)?h.delete(s.id):h.set(s.id,s),h})}function Ct(){ae(s=>{let _=new Map(s);return xe?j.forEach(h=>_.delete(h.id)):j.forEach(h=>_.set(h.id,h)),_})}return e("div",{className:ue("AssetBrowser",t.className,`AssetBrowser--${t.mode}`),children:[e("div",{className:"AssetBrowser__toolbar",children:[e(Ue.Breadcrumbs,{folder:l,onNavigate:L}),e("div",{className:"AssetBrowser__toolbar__actions",children:[e(H,{className:"AssetBrowser__toolbar__filter",placeholder:"Search by name",size:"xs",icon:e(dt,{size:14}),value:v,onChange:s=>f(s.currentTarget.value)}),Y&&t.mode==="manage"&&e(g,{variant:"default",size:"xs",leftIcon:e(it,{size:16}),onClick:()=>X(!0),children:"New folder"}),Y&&e(g,{color:"dark",size:"xs",leftIcon:e(ct,{size:16}),loading:F,onClick:()=>Bt(),children:"Upload"})]})]}),le&&ee.length>0&&e("div",{className:"AssetBrowser__selectionBar",children:[e("div",{className:"AssetBrowser__selectionBar__count",children:[ee.length," selected"]}),e("div",{className:"AssetBrowser__selectionBar__actions",children:[e(g,{variant:"default",size:"xs",leftIcon:e(ve,{size:14}),onClick:()=>E(ee),children:"Move"}),Pe.length>0&&e(g,{variant:"default",size:"xs",onClick:()=>c(Pe),children:"Disable alt text"}),e(g,{color:"red",size:"xs",leftIcon:e(W,{size:14}),onClick:()=>P(ee),children:"Delete"}),e(g,{variant:"subtle",color:"gray",size:"xs",onClick:()=>ae(new Map),children:"Clear"})]})]}),e("div",{className:ue("AssetBrowser__listing",B&&"dragging"),onDragOver:s=>{Y&&(s.preventDefault(),w(!0))},onDragLeave:s=>{s.preventDefault(),w(!1)},onDrop:s=>{s.preventDefault(),w(!1),Y&&Ee(Array.from(s.dataTransfer?.files||[]))},children:d||Q&&u===null?e("div",{className:"AssetBrowser__loading",children:e(te,{color:"gray",size:"lg"})}):Se.length===0?e("div",{className:"AssetBrowser__empty","data-testid":"asset-browser-empty",children:v?e("div",{children:['No assets match "',v,'" in this folder or its subfolders.']}):e(C,{children:[e("div",{children:"This folder is empty."}),Y&&e("div",{className:"AssetBrowser__empty__hint",children:'Drop files here or click "Upload" to add assets.'})]})}):e(re,{className:"AssetBrowser__table",verticalSpacing:"xs",fontSize:"xs",highlightOnHover:!0,children:[e("thead",{children:e("tr",{children:[le&&e("th",{className:"AssetBrowser__table__checkboxCol",children:e(G,{size:"xs","aria-label":"Select all",checked:xe,indeterminate:!xe&&j.some(s=>y.has(s.id)),onChange:()=>Ct()})}),e("th",{children:"name"}),e("th",{className:"AssetBrowser__table__modifiedCol",children:"modified"}),e("th",{className:"AssetBrowser__table__actionsCol"})]})}),e("tbody",{children:j.map(s=>s.type==="folder"?e("tr",{className:"AssetBrowser__row AssetBrowser__row--folder",onClick:()=>L(oe(s.parent,s.name)),children:[le&&e("td",{className:"AssetBrowser__checkboxCell",onClick:_=>_.stopPropagation(),children:e(G,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>Re(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e("div",{className:"AssetBrowser__thumb",children:e(ze,{size:24,stroke:"1.5"})}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:s.name}),e(wt,{asset:s,folder:l,searching:Q,onNavigate:L})]})]})}),e("td",{children:e(bt,{asset:s})}),e("td",{onClick:_=>_.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode==="manage"&&J&&e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(De,{size:16})}),children:[e(k.Item,{icon:e(Ie,{size:14}),onClick:()=>z(s),children:"Rename"}),e(k.Item,{icon:e(ve,{size:14}),onClick:()=>E([s]),children:"Move"}),e(k.Item,{color:"red",icon:e(W,{size:14}),onClick:()=>P([s]),children:"Delete"})]})})})]},s.id):e("tr",{className:"AssetBrowser__row AssetBrowser__row--file",onClick:()=>{t.mode==="pick"?yt(s):p(s)},children:[le&&e("td",{className:"AssetBrowser__checkboxCell",onClick:_=>_.stopPropagation(),children:e(G,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>Re(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e(ht,{file:s.file,size:36}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:[s.name,!!(s.file?.width&&s.file?.height)&&e("span",{className:"AssetBrowser__nameCell__dimens",children:[" ","(",s.file.width,"x",s.file.height,")"]})]}),e(wt,{asset:s,folder:l,searching:Q,onNavigate:L})]})]})}),e("td",{children:e(bt,{asset:s})}),e("td",{onClick:_=>_.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode!=="pick"&&e(Ft,{asset:s,canManage:J,onDetails:()=>p(s),onRename:()=>z(s),onMove:()=>E([s]),onDelete:()=>P([s])})})})]},s.id))})]})}),T.totalPages>1&&e("div",{className:"AssetBrowser__footer",children:[e(gt,{start:T.start,end:T.end,total:T.totalItems,noun:"asset"}),e(ut,{total:T.totalPages,page:T.page,onChange:T.setPage})]}),e(Nt,{opened:R,parent:l,onClose:()=>X(!1),onCreated:s=>{X(!1),L(oe(l,s))}}),q&&e(Dt,{asset:q,onClose:()=>z(null),onRenamed:()=>{z(null),I(l)}}),K&&K.length>0&&e(zt,{assets:K,onClose:()=>E(null),onMoved:()=>{E(null),I(l)}}),$&&$.length>0&&e(Tt,{assets:$,onClose:()=>P(null),onDeleted:()=>{P(null),I(l)}}),Z&&Z.length>0&&e(Ut,{assets:Z,onClose:()=>c(null),onDone:()=>{c(null),I(l)}}),b&&e(vt,{asset:b,canManage:J,onClose:()=>p(null),onChanged:()=>I(l),onDeleted:()=>{p(null),I(l)}})]})}Ue.Breadcrumbs=t=>{let o=Ke(t.folder),a=[{label:"Assets",path:""}];return o.forEach((l,r)=>{a.push({label:l,path:o.slice(0,r+1).join("/")})}),e("div",{className:"AssetBrowser__breadcrumbs",children:a.map((l,r)=>e("div",{className:"AssetBrowser__breadcrumbs__crumb",children:[r>0&&e(Ne,{className:"AssetBrowser__breadcrumbs__divider",size:14}),e("button",{className:ue("AssetBrowser__breadcrumbs__link",r===a.length-1&&"active"),disabled:r===a.length-1,onClick:()=>t.onNavigate(l.path),children:l.label})]},l.path))})};function Ft(t){let o=t.asset;return e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(De,{size:16})}),children:[e(k.Item,{icon:e(rt,{size:14}),onClick:t.onDetails,children:"Details"}),e(k.Item,{icon:e(ge,{size:14}),onClick:()=>we(o.file),children:"Copy URL"}),e(k.Item,{icon:e(pe,{size:14}),onClick:()=>be(o.file),children:"Download"}),t.canManage&&e(C,{children:[e(k.Item,{icon:e(Ie,{size:14}),onClick:t.onRename,children:"Rename"}),e(k.Item,{icon:e(ve,{size:14}),onClick:t.onMove,children:"Move"}),e(k.Item,{color:"red",icon:e(W,{size:14}),onClick:t.onDelete,children:"Delete"})]})]})}function wt(t){let o=t.asset;return!t.searching||o.parent===t.folder?null:e("button",{className:"AssetBrowser__nameCell__path",title:"Go to folder",onClick:a=>{a.stopPropagation(),t.onNavigate(o.parent)},children:["in ",Je(o.parent,t.folder)]})}function bt(t){let o=t.asset.modifiedAt||t.asset.createdAt,a=t.asset.modifiedBy||t.asset.createdBy||"",l=o&&typeof o.toMillis=="function"?o.toMillis():0;return e("div",{className:"AssetBrowser__modifiedCell",children:[a&&e(pt,{email:a,size:20}),e("span",{children:l?Ve(l):"\u2014"})]})}function Nt(t){let[o,a]=i(""),[l,r]=i(!1);async function m(){r(!0),await M(async()=>{let d=await Ye(t.parent,o);a(""),t.onCreated(d.name)}),r(!1)}return e(S,{opened:t.opened,onClose:t.onClose,title:"New folder",size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),m()},children:[e(H,{"data-autofocus":!0,placeholder:"Folder name",value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Create"})]})})}function Dt(t){let[o,a]=i(t.asset.name),[l,r]=i(!1);async function m(){r(!0),await M(async()=>{await tt(t.asset,o),t.onRenamed()}),r(!1)}return e(S,{opened:!0,onClose:t.onClose,title:`Rename ${t.asset.type}`,size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),m()},children:[e(H,{"data-autofocus":!0,value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Rename"})]})})}function zt(t){let o=t.assets,[a,l]=i(o[0]?.parent||""),[r,m]=i([]),[d,x]=i(!0),[v,f]=i(!1);U(()=>{x(!0),M(async()=>{let n=await Me(a);m(n.filter(u=>u.type==="folder"))}).then(()=>x(!1))},[a]);let B=o.filter(n=>n.type==="folder").map(n=>oe(n.parent,n.name));function w(n){return B.some(u=>n===u||n.startsWith(`${u}/`))}async function F(){f(!0);let n=[],u=0;for(let N of o)try{await st(N,a),u+=1}catch(R){console.error(`failed to move ${N.name}:`,R),n.push(N.name)}f(!1),n.length>0&&A({title:"Move failed",message:`Failed to move: ${n.join(", ")}`,color:"red",autoClose:!1}),u>0&&A({message:o.length===1?`Moved "${o[0].name}" to ${a||"Assets"}.`:`Moved ${u} item(s) to ${a||"Assets"}.`,color:"green"}),t.onMoved()}return e(S,{opened:!0,onClose:t.onClose,title:o.length===1?`Move "${o[0].name}"`:`Move ${o.length} items`,size:"md",centered:!0,children:e("div",{className:"AssetBrowser__moveModal",children:[e(Ue.Breadcrumbs,{folder:a,onNavigate:l}),e("div",{className:"AssetBrowser__moveModal__folders",children:d?e(te,{color:"gray",size:"sm"}):r.length===0?e("div",{className:"AssetBrowser__moveModal__empty",children:"No subfolders."}):r.map(n=>{let u=oe(n.parent,n.name);return e("button",{className:"AssetBrowser__moveModal__folder",disabled:w(u),onClick:()=>l(u),children:[e(ze,{size:16,stroke:"1.5"}),e("span",{children:n.name}),e(Ne,{size:14})]},n.id)})}),e(g,{color:"dark",fullWidth:!0,loading:v,disabled:o.every(n=>n.parent===a),onClick:()=>F(),children:"Move here"})]})})}var It=20;function Tt(t){let o=t.assets,[a,l]=i(!1),[r,m]=i(null),d=o.filter(f=>f.type==="file"),x=o.some(f=>f.type==="folder");U(()=>{d.length===0||d.length>It||Promise.all(d.map(f=>_e(f.id))).then(f=>{let B=new Set(f.flat().map(w=>w.id));m(B.size)}).catch(()=>m(null))},[o.map(f=>f.id).join(",")]);async function v(){l(!0);let f=[],B=0;for(let w of o)try{await ce(w),B+=1}catch(F){console.error(`failed to delete ${w.name}:`,F),f.push(w.name)}l(!1),f.length>0&&A({title:"Delete failed",message:`Failed to delete: ${f.join(", ")}. Note that folders must be empty before they can be deleted.`,color:"red",autoClose:!1}),B>0&&A({message:o.length===1?`Deleted "${o[0].name}".`:`Deleted ${B} item(s).`,color:"green"}),t.onDeleted()}return e(S,{opened:!0,onClose:t.onClose,title:o.length===1?`Delete ${o[0].type}?`:`Delete ${o.length} items?`,size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Are you sure you want to delete"," ",o.length===1?e("b",{children:o[0].name}):e("b",{children:[o.length," items"]})," ","from the asset manager?",d.length>0&&e(C,{children:[" ","The underlying files are not deleted from GCS, and docs that currently use the assets keep their copy of the files."]}),x&&e(C,{children:" Folders must be empty before they can be deleted."})]}),r!==null&&r>0&&e("div",{className:"AssetBrowser__deleteModal__warning",children:[o.length===1?"This asset is":"These assets are"," ","currently used in ",r," doc(s). Those docs will no longer receive updates when the asset changes."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"red",loading:a,onClick:()=>v(),children:"Delete"})]})]})})}function Ut(t){let o=t.assets,[a,l]=i(!1);async function r(){l(!0);let m=[],d=0;for(let x of o)try{let v=x.file,f=await me(x,!0);await fe(f,{previousFile:v}),d+=1}catch(v){console.error(`failed to disable alt text for ${x.name}:`,v),m.push(x.name)}l(!1),m.length>0&&A({title:"Failed to disable alt text",message:`Failed to update: ${m.join(", ")}`,color:"red",autoClose:!1}),d>0&&A({message:`Disabled alt text for ${d} file(s).`,color:"green"}),t.onDone()}return e(S,{opened:!0,onClose:t.onClose,title:"Disable alt text?",size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Disable alt text for ",e("b",{children:[o.length," file(s)"]}),"? The alt text input is hidden in docs that use these assets and their embedded alt text is cleared. Alt text can be re-enabled per asset from its details."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"dark",loading:a,onClick:()=>r(),children:"Disable alt text"})]})]})})}export{Ue as a};
|
|
1
|
+
import{a as _t,b as gt,c as pt}from"./chunk-2RRM4HEQ.js";import{a as lt}from"./chunk-PLYSJ7W5.js";import{a as ut}from"./chunk-W5DOO6ID.js";import{a as ft}from"./chunk-YBHFGQ3Z.js";import{b as M}from"./chunk-2PTLQRTU.js";import{a as A,b as He,c as Oe}from"./chunk-PIJ3E47R.js";import{g as oe,h as Ke,i as Me,j as Ze,k as Je,l as Qe,m as Ye,n as et,o as tt,p as st,q as ce,r as ot,s as Fe,t as at,u as me,y as _e,z as fe}from"./chunk-ISUGBMXC.js";import{B as Ce,z as Ve}from"./chunk-XOWWPE7X.js";import{e as ue}from"./chunk-WASID5UU.js";import{Ab as nt,Da as re,Db as it,Eb as he,Fa as Ge,Ga as e,Gc as ct,Hb as rt,Ib as ve,Jb as ze,Tb as dt,V as te,Vc as W,W as se,Yc as mt,a as i,bb as Ne,c as U,da as g,ea as G,g as $e,j as Le,na as je,pb as ge,qa as k,qc as Ie,ra as S,ua as H,xb as De,zb as pe}from"./chunk-WRA24P66.js";import{d as C}from"./chunk-KUCVLANF.js";import{g as We,h as de,k as D,l as O,m as ke,n as V,o as Xe,p as qe}from"./chunk-7SK47HHZ.js";Le();Le();function ht(t){let o=t.file||{},a=o.src||"",l=o.filename||a,r={"--asset-thumb-size":`${t.size}px`};if(a&&O(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("img",{src:Te(o,t.size*2),alt:o.alt||"",loading:"lazy"})});if(a&&V(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("video",{src:a,muted:!0,playsInline:!0,preload:"metadata"})});let m=D(l);return e("div",{className:"AssetBrowser__thumb",style:r,children:m&&m.length<=4?e("div",{className:"AssetBrowser__thumb__ext",children:m}):e(he,{size:20,stroke:"1.5"})})}function Te(t,o){let a=t?.src||"";return a.startsWith(We)&&o?`${a}=s${o}`:a}function we(t){let o=t?.src||"";ke(o)&&(o=o.split("=")[0]+"=s0"),navigator.clipboard.writeText(o).then(()=>{A({message:"Copied URL to clipboard.",autoClose:2e3})})}function be(t){let o=t?.src||"";if(o)if(ke(o)){let a=document.createElement("a");a.href=qe(o),t.filename&&(a.download=t.filename),document.body.appendChild(a),a.click(),document.body.removeChild(a)}else window.open(o,"_blank")}function vt(t){let[o,a]=i(t.asset),[l,r]=i(t.asset.file?.alt||""),[m,d]=i(!1),[x,v]=i(!1),[f,B]=i(null),[w,F]=i(null),n=o.file||{},u=n.filename||o.name,N=O(u),R=V(u),X=l!==(n.alt||""),q=n.altDisabled===!0;U(()=>{_e(o.id).then(c=>F(c)).catch(c=>{console.error("failed to fetch asset usage:",c),F([])})},[o.id]);async function z(c,b){let p=await fe(c,{previousFile:b});p.failedDocIds.length>0?A({title:"Some docs failed to update",message:`Failed to update: ${p.failedDocIds.join(", ")}. Re-save the asset to retry.`,color:"red",autoClose:!1}):p.updatedDocIds.length>0&&A({message:`Updated ${p.updatedDocIds.length} doc(s) that use this asset.`,color:"green"})}async function K(){d(!0),await M(async()=>{let c={...n},b=await at(o,l);a(b),t.onChanged(b),await z(b,c)}),d(!1)}function E(){let c=document.createElement("input");c.type="file",c.onchange=()=>{let b=c.files?.[0];if(!b)return;let p=D(u),y=D(b.name);if(p&&y&&p!==y){B(b);return}$(b)},c.click(),c.remove()}async function $(c){B(null),d(!0),await M(async()=>{let b={...n},p=await de(c),y=await ot(o,p);a(y),r(y.file?.alt||""),t.onChanged(y),await z(y,b)}),d(!1)}async function P(c){d(!0),await M(async()=>{let b={...n},p=await me(o,c);a(p),r(p.file?.alt||""),t.onChanged(p),await z(p,b)}),d(!1)}async function Z(){d(!0),await M(async()=>{await ce(o),A({message:`Deleted "${o.name}".`,color:"green"}),t.onDeleted()}),d(!1)}return e(S,{className:"AssetBrowser__detailsModal",opened:!0,onClose:t.onClose,title:o.name,size:720,overflow:"outside",centered:!0,children:e("div",{className:"AssetBrowser__details",children:[e("div",{className:"AssetBrowser__details__preview",children:N?e("img",{src:Te(n,800),alt:n.alt||"",style:n.canvasBgColor==="dark"?{background:"#000"}:{}}):R?e("video",{src:n.src,controls:!0,muted:!0,preload:"metadata"}):e("div",{className:"AssetBrowser__details__preview__placeholder",children:[e(he,{size:48,stroke:"1"}),e("div",{children:u})]})}),e(re,{className:"AssetBrowser__details__table",verticalSpacing:"xs",fontSize:"xs",children:e("tbody",{children:[e("tr",{children:[e("td",{children:e("b",{children:"Filename"})}),e("td",{children:u})]}),!!(n.width&&n.height)&&e("tr",{children:[e("td",{children:e("b",{children:"Dimensions"})}),e("td",{children:[n.width,"x",n.height]})]}),o.createdAt&&e("tr",{children:[e("td",{children:e("b",{children:"Uploaded"})}),e("td",{children:[Ce(o.createdAt),o.createdBy&&e(C,{children:[" by ",o.createdBy]})]})]}),o.modifiedAt&&e("tr",{children:[e("td",{children:e("b",{children:"Modified"})}),e("td",{children:[Ce(o.modifiedAt),o.modifiedBy&&e(C,{children:[" by ",o.modifiedBy]})]})]}),e("tr",{children:[e("td",{children:e("b",{children:"URL"})}),e("td",{children:e("div",{className:"AssetBrowser__details__url",children:[e(H,{readOnly:!0,value:n.src||"",size:"xs",radius:"xs",onClick:c=>c.target.select(),styles:{root:{flex:1,minWidth:0}}}),e(Ge,{label:"Copy URL",transition:"pop",children:e(se,{size:"sm",onClick:()=>we(n),children:e(ge,{size:16})})})]})})]})]})}),(N||R)&&e("div",{className:"AssetBrowser__details__alt",children:[q?e("div",{className:"AssetBrowser__details__alt__disabledNote",children:"Alt text is disabled for this asset. Docs that use it hide the alt text input and render no alt text."}):e(C,{children:[e(je,{label:"Alt text",description:"Used as the default alt text when the asset is selected in a doc. Updating it syncs docs that use this asset.",autosize:!0,minRows:1,size:"xs",value:l,disabled:!t.canManage||m,onChange:c=>r(c.currentTarget.value)}),t.canManage&&X&&e(g,{size:"xs",color:"dark",mt:8,loading:m,onClick:()=>K(),children:"Save alt text"})]}),t.canManage&&e(G,{className:"AssetBrowser__details__alt__disableCheckbox",label:"Disable alt text (e.g. decorative images)",size:"xs",mt:8,checked:q,disabled:m,onChange:c=>P(c.currentTarget.checked)})]}),e("div",{className:"AssetBrowser__details__usage",children:[e("div",{className:"AssetBrowser__details__usage__title",children:"Used in"}),w===null?e(te,{color:"gray",size:"sm"}):w.length===0?e("div",{className:"AssetBrowser__details__usage__empty",children:"No docs use this asset."}):e("div",{className:"AssetBrowser__details__usage__list",children:w.map(c=>e("a",{className:"AssetBrowser__details__usage__doc",href:`/cms/content/${c.id}`,target:"_blank",rel:"noreferrer",children:[e("span",{children:c.id}),e(nt,{size:14})]},c.id))})]}),e("div",{className:"AssetBrowser__details__buttons",children:[e(g,{variant:"default",size:"xs",leftIcon:e(pe,{size:14}),onClick:()=>be(n),children:"Download"}),t.canManage&&e(C,{children:[e(g,{variant:"default",size:"xs",leftIcon:e(it,{size:14}),loading:m,onClick:()=>E(),children:"Replace file"}),e(g,{className:"AssetBrowser__details__buttons__delete",color:"red",variant:"filled",size:"xs",leftIcon:e(W,{size:14}),disabled:m,onClick:()=>v(!0),children:"Delete"})]})]}),f&&e("div",{className:"AssetBrowser__details__confirmReplace",children:[e("div",{children:["The new file has a different type (",e("b",{children:[".",D(u)]})," ","\u2192 ",e("b",{children:[".",D(f.name)]}),"). Replacing will change the asset's file extension and serving URL",Fe(o.name,D(f.name))!==o.name&&e(C,{children:[", and the asset will be renamed to"," ",e("b",{children:Fe(o.name,D(f.name))})]}),". Docs that use this asset will be updated."]}),e("div",{className:"AssetBrowser__details__confirmReplace__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>B(null),disabled:m,children:"Cancel"}),e(g,{color:"dark",size:"xs",loading:m,onClick:()=>$(f),children:"Replace"})]})]}),x&&e("div",{className:"AssetBrowser__details__confirmDelete",children:[e("div",{children:["Delete ",e("b",{children:o.name})," from the asset library?",w&&w.length>0&&e(C,{children:[" ","This asset is used in ",w.length," doc(s); those docs keep their copy of the file but will no longer receive updates."]})]}),e("div",{className:"AssetBrowser__details__confirmDelete__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>v(!1),disabled:m,children:"Cancel"}),e(g,{color:"red",size:"xs",loading:m,onClick:()=>Z(),children:"Delete"})]})]})]})})}var Mt=100;function Ue(t){let[o,a]=i(t.folder??t.initialFolder??""),l=t.folder??o,[r,m]=i([]),[d,x]=i(!0),[v,f]=i(""),[B,w]=i(!1),[F,n]=i(!1),[u,N]=i(null),[R,X]=i(!1),[q,z]=i(null),[K,E]=i(null),[$,P]=i(null),[Z,c]=i(null),[b,p]=i(null),[y,ae]=i(new Map),{roles:At}=ft(),xt=window.firebase.user.email||"",J=ut(At,xt),Q=v.trim().length>0;function L(s){a(s),f(""),t.onFolderChange&&t.onFolderChange(s)}async function I(s){x(!0),N(null),ae(new Map),await M(async()=>{let _=await Me(s);m(_)}),x(!1)}U(()=>{I(l)},[l]),U(()=>{if(!Q||u!==null)return;let s=!1;return(async()=>{let _=[];await M(async()=>{_=await Ze(l)}),s||N(_)})(),()=>{s=!0}},[Q,u,l]);let Ae=t.mode==="manage"?t.initialAssetId:"";U(()=>{Ae&&M(async()=>{let s=await Qe(Ae);s&&s.type==="file"&&(L(s.parent),p(s))})},[Ae]);let Se=$e(()=>{let s=v.trim().toLowerCase(),_=s?u||[]:r;return t.mode==="pick"&&(_=_.filter(h=>h.type==="folder"||Xe(h.file?.filename||h.name,t.accept))),s&&(_=_.filter(h=>h.name.toLowerCase().includes(s))),_},[r,u,v,t.mode,t.accept]),T=_t(Se,{pageSize:Mt,resetDeps:[l,v]}),j=T.pageItems;async function Ee(s){if(s.length===0||F)return;let _="asset-browser-upload";n(!0),A({id:_,message:`Uploading ${s.length} file(s)...`,loading:!0,autoClose:!1,disallowClose:!0});let h=[],Be=[];for(let ne=0;ne<s.length;ne++){let ie=s[ne];He({id:_,message:`Uploading ${ie.name} (${ne+1} of ${s.length})...`,loading:!0,autoClose:!1,disallowClose:!0});try{let ye=await de(ie),kt=await et({parent:l,file:ye});h.push(kt)}catch(ye){console.error(`failed to upload ${ie.name}:`,ye),Be.push(ie.name)}}Oe(_),n(!1),Be.length>0?A({title:"Upload failed",message:`Failed to upload: ${Be.join(", ")}`,color:"red",autoClose:!1}):A({message:`Uploaded ${h.length} file(s).`,color:"green"}),await I(l),t.mode==="pick"&&h.length===1&&s.length===1&&t.onPickFile&&t.onPickFile(h[0])}function Bt(){let s=document.createElement("input");s.type="file",s.multiple=!0,t.mode==="pick"&&t.accept&&t.accept.length>0&&(s.accept=t.accept.join(",")),s.onchange=()=>{Ee(Array.from(s.files||[]))},s.click(),s.remove()}function yt(s){t.onPickFile&&t.onPickFile(s)}let Y=J,le=t.mode==="manage"&&J,ee=Array.from(y.values()),Pe=ee.filter(s=>s.type==="file"&&!s.file?.altDisabled&&(O(s.file?.filename||s.name)||V(s.file?.filename||s.name))),xe=j.length>0&&j.every(s=>y.has(s.id));function Re(s){ae(_=>{let h=new Map(_);return h.has(s.id)?h.delete(s.id):h.set(s.id,s),h})}function Ct(){ae(s=>{let _=new Map(s);return xe?j.forEach(h=>_.delete(h.id)):j.forEach(h=>_.set(h.id,h)),_})}return e("div",{className:ue("AssetBrowser",t.className,`AssetBrowser--${t.mode}`),children:[e("div",{className:"AssetBrowser__toolbar",children:[e(Ue.Breadcrumbs,{folder:l,onNavigate:L}),e("div",{className:"AssetBrowser__toolbar__actions",children:[e(H,{className:"AssetBrowser__toolbar__filter",placeholder:"Search by name",size:"xs",icon:e(ct,{size:14}),value:v,onChange:s=>f(s.currentTarget.value)}),Y&&t.mode==="manage"&&e(g,{variant:"default",size:"xs",leftIcon:e(rt,{size:16}),onClick:()=>X(!0),children:"New folder"}),Y&&e(g,{color:"dark",size:"xs",leftIcon:e(mt,{size:16}),loading:F,onClick:()=>Bt(),children:"Upload"})]})]}),le&&ee.length>0&&e("div",{className:"AssetBrowser__selectionBar",children:[e("div",{className:"AssetBrowser__selectionBar__count",children:[ee.length," selected"]}),e("div",{className:"AssetBrowser__selectionBar__actions",children:[e(g,{variant:"default",size:"xs",leftIcon:e(ve,{size:14}),onClick:()=>E(ee),children:"Move"}),Pe.length>0&&e(g,{variant:"default",size:"xs",onClick:()=>c(Pe),children:"Disable alt text"}),e(g,{color:"red",size:"xs",leftIcon:e(W,{size:14}),onClick:()=>P(ee),children:"Delete"}),e(g,{variant:"subtle",color:"gray",size:"xs",onClick:()=>ae(new Map),children:"Clear"})]})]}),e("div",{className:ue("AssetBrowser__listing",B&&"dragging"),onDragOver:s=>{Y&&(s.preventDefault(),w(!0))},onDragLeave:s=>{s.preventDefault(),w(!1)},onDrop:s=>{s.preventDefault(),w(!1),Y&&Ee(Array.from(s.dataTransfer?.files||[]))},children:d||Q&&u===null?e("div",{className:"AssetBrowser__loading",children:e(te,{color:"gray",size:"lg"})}):Se.length===0?e("div",{className:"AssetBrowser__empty","data-testid":"asset-browser-empty",children:v?e("div",{children:['No assets match "',v,'" in this folder or its subfolders.']}):e(C,{children:[e("div",{children:"This folder is empty."}),Y&&e("div",{className:"AssetBrowser__empty__hint",children:'Drop files here or click "Upload" to add assets.'})]})}):e(re,{className:"AssetBrowser__table",verticalSpacing:"xs",fontSize:"xs",highlightOnHover:!0,children:[e("thead",{children:e("tr",{children:[le&&e("th",{className:"AssetBrowser__table__checkboxCol",children:e(G,{size:"xs","aria-label":"Select all",checked:xe,indeterminate:!xe&&j.some(s=>y.has(s.id)),onChange:()=>Ct()})}),e("th",{children:"name"}),e("th",{className:"AssetBrowser__table__modifiedCol",children:"modified"}),e("th",{className:"AssetBrowser__table__actionsCol"})]})}),e("tbody",{children:j.map(s=>s.type==="folder"?e("tr",{className:"AssetBrowser__row AssetBrowser__row--folder",onClick:()=>L(oe(s.parent,s.name)),children:[le&&e("td",{className:"AssetBrowser__checkboxCell",onClick:_=>_.stopPropagation(),children:e(G,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>Re(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e("div",{className:"AssetBrowser__thumb",children:e(ze,{size:24,stroke:"1.5"})}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:s.name}),e(wt,{asset:s,folder:l,searching:Q,onNavigate:L})]})]})}),e("td",{children:e(bt,{asset:s})}),e("td",{onClick:_=>_.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode==="manage"&&J&&e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(De,{size:16})}),children:[e(k.Item,{icon:e(Ie,{size:14}),onClick:()=>z(s),children:"Rename"}),e(k.Item,{icon:e(ve,{size:14}),onClick:()=>E([s]),children:"Move"}),e(k.Item,{color:"red",icon:e(W,{size:14}),onClick:()=>P([s]),children:"Delete"})]})})})]},s.id):e("tr",{className:"AssetBrowser__row AssetBrowser__row--file",onClick:()=>{t.mode==="pick"?yt(s):p(s)},children:[le&&e("td",{className:"AssetBrowser__checkboxCell",onClick:_=>_.stopPropagation(),children:e(G,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>Re(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e(ht,{file:s.file,size:36}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:[s.name,!!(s.file?.width&&s.file?.height)&&e("span",{className:"AssetBrowser__nameCell__dimens",children:[" ","(",s.file.width,"x",s.file.height,")"]})]}),e(wt,{asset:s,folder:l,searching:Q,onNavigate:L})]})]})}),e("td",{children:e(bt,{asset:s})}),e("td",{onClick:_=>_.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode!=="pick"&&e(Ft,{asset:s,canManage:J,onDetails:()=>p(s),onRename:()=>z(s),onMove:()=>E([s]),onDelete:()=>P([s])})})})]},s.id))})]})}),T.totalPages>1&&e("div",{className:"AssetBrowser__footer",children:[e(pt,{start:T.start,end:T.end,total:T.totalItems,noun:"asset"}),e(gt,{total:T.totalPages,page:T.page,onChange:T.setPage})]}),e(Nt,{opened:R,parent:l,onClose:()=>X(!1),onCreated:s=>{X(!1),L(oe(l,s))}}),q&&e(Dt,{asset:q,onClose:()=>z(null),onRenamed:()=>{z(null),I(l)}}),K&&K.length>0&&e(zt,{assets:K,onClose:()=>E(null),onMoved:()=>{E(null),I(l)}}),$&&$.length>0&&e(Tt,{assets:$,onClose:()=>P(null),onDeleted:()=>{P(null),I(l)}}),Z&&Z.length>0&&e(Ut,{assets:Z,onClose:()=>c(null),onDone:()=>{c(null),I(l)}}),b&&e(vt,{asset:b,canManage:J,onClose:()=>p(null),onChanged:()=>I(l),onDeleted:()=>{p(null),I(l)}})]})}Ue.Breadcrumbs=t=>{let o=Ke(t.folder),a=[{label:"Assets",path:""}];return o.forEach((l,r)=>{a.push({label:l,path:o.slice(0,r+1).join("/")})}),e("div",{className:"AssetBrowser__breadcrumbs",children:a.map((l,r)=>e("div",{className:"AssetBrowser__breadcrumbs__crumb",children:[r>0&&e(Ne,{className:"AssetBrowser__breadcrumbs__divider",size:14}),e("button",{className:ue("AssetBrowser__breadcrumbs__link",r===a.length-1&&"active"),disabled:r===a.length-1,onClick:()=>t.onNavigate(l.path),children:l.label})]},l.path))})};function Ft(t){let o=t.asset;return e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(De,{size:16})}),children:[e(k.Item,{icon:e(dt,{size:14}),onClick:t.onDetails,children:"Details"}),e(k.Item,{icon:e(ge,{size:14}),onClick:()=>we(o.file),children:"Copy URL"}),e(k.Item,{icon:e(pe,{size:14}),onClick:()=>be(o.file),children:"Download"}),t.canManage&&e(C,{children:[e(k.Item,{icon:e(Ie,{size:14}),onClick:t.onRename,children:"Rename"}),e(k.Item,{icon:e(ve,{size:14}),onClick:t.onMove,children:"Move"}),e(k.Item,{color:"red",icon:e(W,{size:14}),onClick:t.onDelete,children:"Delete"})]})]})}function wt(t){let o=t.asset;return!t.searching||o.parent===t.folder?null:e("button",{className:"AssetBrowser__nameCell__path",title:"Go to folder",onClick:a=>{a.stopPropagation(),t.onNavigate(o.parent)},children:["in ",Je(o.parent,t.folder)]})}function bt(t){let o=t.asset.modifiedAt||t.asset.createdAt,a=t.asset.modifiedBy||t.asset.createdBy||"",l=o&&typeof o.toMillis=="function"?o.toMillis():0;return e("div",{className:"AssetBrowser__modifiedCell",children:[a&&e(lt,{email:a,size:20}),e("span",{children:l?Ve(l):"\u2014"})]})}function Nt(t){let[o,a]=i(""),[l,r]=i(!1);async function m(){r(!0),await M(async()=>{let d=await Ye(t.parent,o);a(""),t.onCreated(d.name)}),r(!1)}return e(S,{opened:t.opened,onClose:t.onClose,title:"New folder",size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),m()},children:[e(H,{"data-autofocus":!0,placeholder:"Folder name",value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Create"})]})})}function Dt(t){let[o,a]=i(t.asset.name),[l,r]=i(!1);async function m(){r(!0),await M(async()=>{await tt(t.asset,o),t.onRenamed()}),r(!1)}return e(S,{opened:!0,onClose:t.onClose,title:`Rename ${t.asset.type}`,size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),m()},children:[e(H,{"data-autofocus":!0,value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Rename"})]})})}function zt(t){let o=t.assets,[a,l]=i(o[0]?.parent||""),[r,m]=i([]),[d,x]=i(!0),[v,f]=i(!1);U(()=>{x(!0),M(async()=>{let n=await Me(a);m(n.filter(u=>u.type==="folder"))}).then(()=>x(!1))},[a]);let B=o.filter(n=>n.type==="folder").map(n=>oe(n.parent,n.name));function w(n){return B.some(u=>n===u||n.startsWith(`${u}/`))}async function F(){f(!0);let n=[],u=0;for(let N of o)try{await st(N,a),u+=1}catch(R){console.error(`failed to move ${N.name}:`,R),n.push(N.name)}f(!1),n.length>0&&A({title:"Move failed",message:`Failed to move: ${n.join(", ")}`,color:"red",autoClose:!1}),u>0&&A({message:o.length===1?`Moved "${o[0].name}" to ${a||"Assets"}.`:`Moved ${u} item(s) to ${a||"Assets"}.`,color:"green"}),t.onMoved()}return e(S,{opened:!0,onClose:t.onClose,title:o.length===1?`Move "${o[0].name}"`:`Move ${o.length} items`,size:"md",centered:!0,children:e("div",{className:"AssetBrowser__moveModal",children:[e(Ue.Breadcrumbs,{folder:a,onNavigate:l}),e("div",{className:"AssetBrowser__moveModal__folders",children:d?e(te,{color:"gray",size:"sm"}):r.length===0?e("div",{className:"AssetBrowser__moveModal__empty",children:"No subfolders."}):r.map(n=>{let u=oe(n.parent,n.name);return e("button",{className:"AssetBrowser__moveModal__folder",disabled:w(u),onClick:()=>l(u),children:[e(ze,{size:16,stroke:"1.5"}),e("span",{children:n.name}),e(Ne,{size:14})]},n.id)})}),e(g,{color:"dark",fullWidth:!0,loading:v,disabled:o.every(n=>n.parent===a),onClick:()=>F(),children:"Move here"})]})})}var It=20;function Tt(t){let o=t.assets,[a,l]=i(!1),[r,m]=i(null),d=o.filter(f=>f.type==="file"),x=o.some(f=>f.type==="folder");U(()=>{d.length===0||d.length>It||Promise.all(d.map(f=>_e(f.id))).then(f=>{let B=new Set(f.flat().map(w=>w.id));m(B.size)}).catch(()=>m(null))},[o.map(f=>f.id).join(",")]);async function v(){l(!0);let f=[],B=0;for(let w of o)try{await ce(w),B+=1}catch(F){console.error(`failed to delete ${w.name}:`,F),f.push(w.name)}l(!1),f.length>0&&A({title:"Delete failed",message:`Failed to delete: ${f.join(", ")}. Note that folders must be empty before they can be deleted.`,color:"red",autoClose:!1}),B>0&&A({message:o.length===1?`Deleted "${o[0].name}".`:`Deleted ${B} item(s).`,color:"green"}),t.onDeleted()}return e(S,{opened:!0,onClose:t.onClose,title:o.length===1?`Delete ${o[0].type}?`:`Delete ${o.length} items?`,size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Are you sure you want to delete"," ",o.length===1?e("b",{children:o[0].name}):e("b",{children:[o.length," items"]})," ","from the asset manager?",d.length>0&&e(C,{children:[" ","The underlying files are not deleted from GCS, and docs that currently use the assets keep their copy of the files."]}),x&&e(C,{children:" Folders must be empty before they can be deleted."})]}),r!==null&&r>0&&e("div",{className:"AssetBrowser__deleteModal__warning",children:[o.length===1?"This asset is":"These assets are"," ","currently used in ",r," doc(s). Those docs will no longer receive updates when the asset changes."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"red",loading:a,onClick:()=>v(),children:"Delete"})]})]})})}function Ut(t){let o=t.assets,[a,l]=i(!1);async function r(){l(!0);let m=[],d=0;for(let x of o)try{let v=x.file,f=await me(x,!0);await fe(f,{previousFile:v}),d+=1}catch(v){console.error(`failed to disable alt text for ${x.name}:`,v),m.push(x.name)}l(!1),m.length>0&&A({title:"Failed to disable alt text",message:`Failed to update: ${m.join(", ")}`,color:"red",autoClose:!1}),d>0&&A({message:`Disabled alt text for ${d} file(s).`,color:"green"}),t.onDone()}return e(S,{opened:!0,onClose:t.onClose,title:"Disable alt text?",size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Disable alt text for ",e("b",{children:[o.length," file(s)"]}),"? The alt text input is hidden in docs that use these assets and their embedded alt text is cleared. Alt text can be re-enabled per asset from its details."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"dark",loading:a,onClick:()=>r(),children:"Disable alt text"})]})]})})}export{Ue as a};
|