@blinkk/root-cms 3.0.6 → 3.1.2

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.
Files changed (153) hide show
  1. package/README.md +77 -0
  2. package/dist/app.js +6 -4
  3. package/dist/browser-client/browser-client.d.ts +148 -0
  4. package/dist/browser-client/embed-window.d.ts +66 -0
  5. package/dist/browser-client/emitter.d.ts +11 -0
  6. package/dist/browser-client.js +377 -0
  7. package/dist/{chunk-RXWDB3K4.js → chunk-4VZTYUQ7.js} +1 -1
  8. package/dist/{chunk-N4K6ICFR.js → chunk-AFBSITEO.js} +4 -6
  9. package/dist/{chunk-PNLLZXVY.js → chunk-AJDMNTZQ.js} +2 -2
  10. package/dist/chunk-J72JK4KR.js +8 -0
  11. package/dist/{chunk-7L5OI5ES.js → chunk-X5CNR4CK.js} +8 -4
  12. package/dist/cli.js +2 -1
  13. package/dist/client.js +2 -1
  14. package/dist/core/client.d.ts +5 -0
  15. package/dist/core/plugin.d.ts +1 -1
  16. package/dist/core/translations.d.ts +19 -4
  17. package/dist/core.js +4 -2
  18. package/dist/functions.js +4 -3
  19. package/dist/plugin.js +38 -7
  20. package/dist/shared/embed-protocol.d.ts +72 -0
  21. package/dist/shared/translation-languages.d.ts +67 -0
  22. package/dist/ui/AIPage-2N5UYBRX.js +1 -0
  23. package/dist/ui/AssetsPage-KLGNE6D6.js +1 -0
  24. package/dist/ui/CollectionPage-D7IG6526.js +1 -0
  25. package/dist/ui/ComparePage-726NIJW5.js +1 -0
  26. package/dist/ui/DataPage-YMSQCIVK.js +1 -0
  27. package/dist/ui/DataSourcePage-7VPFUG3K.js +1 -0
  28. package/dist/ui/DocTranslationsPage-FO7O76VK.js +1 -0
  29. package/dist/ui/DocumentPage-M7SJ4ITQ.js +1 -0
  30. package/dist/ui/EditDataSourcePage-Y7YK6IWT.js +1 -0
  31. package/dist/ui/EditReleasePage-XZ4RHHRT.js +1 -0
  32. package/dist/ui/EmbeddedAIPage-RJOUIPF2.js +1 -0
  33. package/dist/ui/EmbeddedDocumentPage-4TLMCDSO.js +1 -0
  34. package/dist/ui/{ImageEditorDialog-QEULJAT2.js → ImageEditorDialog-GGS4VFEA.js} +2 -2
  35. package/dist/ui/LogsPage-IGDDZGEI.js +1 -0
  36. package/dist/ui/NewDataSourcePage-YUPRHL7F.js +1 -0
  37. package/dist/ui/NewReleasePage-6HHLYOQP.js +1 -0
  38. package/dist/ui/NotFoundPage-A6OCYREA.js +1 -0
  39. package/dist/ui/ProjectPage-UHRXNN7O.js +1 -0
  40. package/dist/ui/ReleasePage-V2JMPWX7.js +1 -0
  41. package/dist/ui/ReleasesPage-SCR4SVKN.js +1 -0
  42. package/dist/ui/SettingsPage-5XKHPG6K.js +1 -0
  43. package/dist/ui/SidebarToolsPage-VXVRZ2C3.js +1 -0
  44. package/dist/ui/TaskPage-LDPRN3G6.js +1 -0
  45. package/dist/ui/TasksPage-DIXUWYXM.js +1 -0
  46. package/dist/ui/TranslationsArbPage-QPD3ZBT4.js +2 -0
  47. package/dist/ui/TranslationsEditPage-475Z7UPC.js +1 -0
  48. package/dist/ui/{TranslationsPage-OBN6CQZZ.js → TranslationsPage-674JU6L4.js} +32 -32
  49. package/dist/ui/{chunk-N4DFAIC5.js → chunk-2EPQJUGM.js} +1 -1
  50. package/dist/ui/{chunk-WKOX3VFN.js → chunk-2RAVKX2Z.js} +2 -2
  51. package/dist/ui/chunk-2S5HMST6.js +1 -0
  52. package/dist/ui/{chunk-V7RAXP2W.js → chunk-3E6CASIN.js} +1 -1
  53. package/dist/ui/chunk-4ALFT4ES.js +141 -0
  54. package/dist/ui/{chunk-KYKFNAX4.js → chunk-4FGASIIX.js} +1 -1
  55. package/dist/ui/chunk-4ISFTE2G.js +5 -0
  56. package/dist/ui/{chunk-SKEP5WYH.js → chunk-7SK47HHZ.js} +3 -3
  57. package/dist/ui/chunk-AAHM6RYJ.js +1 -0
  58. package/dist/ui/chunk-AGFPVTBA.js +1 -0
  59. package/dist/ui/chunk-BUNR5EU3.js +1 -0
  60. package/dist/ui/{chunk-N5Y5OWTV.js → chunk-BW2MKGNP.js} +1 -1
  61. package/dist/ui/{chunk-2225WAJ2.js → chunk-CAY5NM4Z.js} +1 -1
  62. package/dist/ui/{chunk-4KE2SZKH.js → chunk-D3UIZHRK.js} +1 -1
  63. package/dist/ui/{chunk-HYARD7BK.js → chunk-ENQKSLGJ.js} +1 -1
  64. package/dist/ui/chunk-FBSBL476.js +1 -0
  65. package/dist/ui/{chunk-NQB37NMX.js → chunk-FJLNXXE3.js} +1 -1
  66. package/dist/ui/chunk-GT5EQSEX.js +1 -0
  67. package/dist/ui/{chunk-KPJ53X55.js → chunk-HARRKJFZ.js} +1 -1
  68. package/dist/ui/{chunk-6E7PGMZX.js → chunk-HO3W4RVG.js} +1 -1
  69. package/dist/ui/{chunk-CVGYBXVH.js → chunk-J5E457OI.js} +1 -1
  70. package/dist/ui/{chunk-SEUH7LN2.js → chunk-JBHRZ4EX.js} +1 -1
  71. package/dist/ui/{chunk-W3HIZQ4Z.js → chunk-JS6TK4OP.js} +1 -1
  72. package/dist/ui/{chunk-BEDUTYQP.js → chunk-JTIQBW33.js} +1 -1
  73. package/dist/ui/{chunk-ORXEMIQC.js → chunk-KRNQ6L35.js} +1 -1
  74. package/dist/ui/chunk-LROR6N3B.js +7 -0
  75. package/dist/ui/{chunk-4CUWZQXT.js.LEGAL.txt → chunk-LROR6N3B.js.LEGAL.txt} +6 -1
  76. package/dist/ui/{chunk-6GPTGBA7.js → chunk-MSYTAJBV.js} +1 -1
  77. package/dist/ui/{chunk-RQKL4KXY.js → chunk-N3JSLTMV.js} +1 -1
  78. package/dist/ui/{chunk-NMBXHKIJ.js → chunk-NJMNOITA.js} +1 -1
  79. package/dist/ui/{chunk-D37DCENS.js → chunk-NSOTG64N.js} +1 -1
  80. package/dist/ui/chunk-NWHGT476.js +1 -0
  81. package/dist/ui/chunk-P2Z66DHV.js +1 -0
  82. package/dist/ui/{chunk-4IXGYXA2.js → chunk-PTPYMVFW.js} +1 -1
  83. package/dist/ui/{chunk-OVRTVMO5.js → chunk-Q7IU4QCY.js} +1 -1
  84. package/dist/ui/{chunk-XYBHH5L4.js → chunk-QF3GPZTI.js} +1 -1
  85. package/dist/ui/{chunk-AXETBZ6T.js → chunk-QHJOTXYB.js} +1 -1
  86. package/dist/ui/{chunk-UHWNLNP4.js → chunk-RHAJNURN.js} +1 -1
  87. package/dist/ui/chunk-SENZVSVZ.js +1 -0
  88. package/dist/ui/chunk-SKQECSUR.js +1 -0
  89. package/dist/ui/chunk-TOGLZDK3.js +1 -0
  90. package/dist/ui/chunk-TPJCPCRR.js +1 -0
  91. package/dist/ui/{chunk-EMYXSVTD.js → chunk-TVYAZN2Q.js} +1 -1
  92. package/dist/ui/{chunk-GDSSFO5R.js → chunk-UUVAD4U4.js} +1 -1
  93. package/dist/ui/{chunk-EGEB6N4J.js → chunk-VD6G5NV4.js} +11 -11
  94. package/dist/ui/{chunk-DXKEDMEI.js → chunk-VJUMFJIX.js} +1 -1
  95. package/dist/ui/chunk-W5DOO6ID.js +1 -0
  96. package/dist/ui/{chunk-6MOPIV5T.js → chunk-W6LP22IK.js} +1 -1
  97. package/dist/ui/{chunk-3XYCOR6Z.js → chunk-WFQU7V3W.js} +1 -1
  98. package/dist/ui/chunk-WMICEDOT.js +1 -0
  99. package/dist/ui/chunk-XMESZUC5.js +1 -0
  100. package/dist/ui/{chunk-T47V6AGW.js → chunk-XWX2622O.js} +1 -1
  101. package/dist/ui/chunk-YMBBWVBB.js +3 -0
  102. package/dist/ui/chunk-YXSXWFLZ.js +1 -0
  103. package/dist/ui/chunk-ZMS6NIGG.js +1 -0
  104. package/dist/ui/gcs-ECSDFCIU.js +1 -0
  105. package/dist/ui/ui.css +1 -1
  106. package/dist/ui/ui.js +1 -1
  107. package/package.json +7 -3
  108. package/dist/ui/AIPage-JPZ4QUB4.js +0 -1
  109. package/dist/ui/AssetsPage-GDJMKS3M.js +0 -1
  110. package/dist/ui/CollectionPage-5DVXJEET.js +0 -1
  111. package/dist/ui/ComparePage-LIXA6G66.js +0 -1
  112. package/dist/ui/DataPage-AP4Z5JPS.js +0 -1
  113. package/dist/ui/DataSourcePage-WO3ZKMFI.js +0 -1
  114. package/dist/ui/DocTranslationsPage-QKYFIVHP.js +0 -1
  115. package/dist/ui/DocumentPage-ON43I5KM.js +0 -1
  116. package/dist/ui/EditDataSourcePage-XVMEV2LJ.js +0 -1
  117. package/dist/ui/EditReleasePage-A2NB5TFG.js +0 -1
  118. package/dist/ui/LogsPage-4LZJX3O4.js +0 -1
  119. package/dist/ui/NewDataSourcePage-4YWX7IOG.js +0 -1
  120. package/dist/ui/NewReleasePage-HWLVTEXX.js +0 -1
  121. package/dist/ui/NotFoundPage-72AXQAYX.js +0 -1
  122. package/dist/ui/ProjectPage-L4GYDIA5.js +0 -1
  123. package/dist/ui/ReleasePage-43BSWL5B.js +0 -1
  124. package/dist/ui/ReleasesPage-CJXAZBP6.js +0 -1
  125. package/dist/ui/SettingsPage-SYXAMKSF.js +0 -1
  126. package/dist/ui/SidebarToolsPage-OFF5BOXP.js +0 -1
  127. package/dist/ui/TaskPage-HBDLHFI5.js +0 -1
  128. package/dist/ui/TasksPage-OLCDTQNB.js +0 -1
  129. package/dist/ui/TranslationsArbPage-E3NCMAMS.js +0 -2
  130. package/dist/ui/TranslationsEditPage-IWOI7Y5G.js +0 -1
  131. package/dist/ui/chunk-32LRQ5MJ.js +0 -1
  132. package/dist/ui/chunk-3HVDIPSS.js +0 -1
  133. package/dist/ui/chunk-3IDOZ4MG.js +0 -1
  134. package/dist/ui/chunk-4CUWZQXT.js +0 -7
  135. package/dist/ui/chunk-AOCBDKLV.js +0 -1
  136. package/dist/ui/chunk-DUJYIOLE.js +0 -5
  137. package/dist/ui/chunk-IDYKCAAL.js +0 -1
  138. package/dist/ui/chunk-IKED2IGU.js +0 -1
  139. package/dist/ui/chunk-J3EGGI57.js +0 -1
  140. package/dist/ui/chunk-MZP6RIG2.js +0 -1
  141. package/dist/ui/chunk-NQ5ARARP.js +0 -1
  142. package/dist/ui/chunk-RI2JWWU3.js +0 -141
  143. package/dist/ui/chunk-RPOP6MVJ.js +0 -1
  144. package/dist/ui/chunk-TDKVKTW4.js +0 -1
  145. package/dist/ui/chunk-TZEZEMRQ.js +0 -1
  146. package/dist/ui/chunk-UA7UCTX5.js +0 -1
  147. package/dist/ui/chunk-UFQSZ6J2.js +0 -3
  148. package/dist/ui/gcs-L33FIRZU.js +0 -1
  149. /package/dist/ui/{ImageEditorDialog-QEULJAT2.js.LEGAL.txt → ImageEditorDialog-GGS4VFEA.js.LEGAL.txt} +0 -0
  150. /package/dist/ui/{chunk-RI2JWWU3.js.LEGAL.txt → chunk-4ALFT4ES.js.LEGAL.txt} +0 -0
  151. /package/dist/ui/{chunk-SKEP5WYH.js.LEGAL.txt → chunk-7SK47HHZ.js.LEGAL.txt} +0 -0
  152. /package/dist/ui/{chunk-NMBXHKIJ.js.LEGAL.txt → chunk-NJMNOITA.js.LEGAL.txt} +0 -0
  153. /package/dist/ui/{chunk-EGEB6N4J.js.LEGAL.txt → chunk-VD6G5NV4.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as b,c as w}from"./chunk-KPJ53X55.js";import{b as z,e as I,f as C}from"./chunk-UFQSZ6J2.js";import{a as p}from"./chunk-AXETBZ6T.js";import{a}from"./chunk-N5Y5OWTV.js";import{Ga as n,V as v,a as c,c as y,da as m,j as L,yc as N}from"./chunk-4CUWZQXT.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
1
+ import{a as b,c as w}from"./chunk-HARRKJFZ.js";import{b as z,e as I,f as C}from"./chunk-YMBBWVBB.js";import{a as p}from"./chunk-QHJOTXYB.js";import{a}from"./chunk-BW2MKGNP.js";import{Bc as N,Ga as n,V as v,a as c,c as y,da as m,j as L}from"./chunk-LROR6N3B.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
@@ -0,0 +1 @@
1
+ function e(n,t){if(t in n)return n[t];let o=`*@${t.split("@").at(-1)}`;return o in n?n[o]:null}function i(n,t){let r=e(n,t);return r==="ADMIN"||r==="EDITOR"}function s(n,t){let r=e(n,t);return r==="ADMIN"||r==="EDITOR"||r==="CONTRIBUTOR"}export{i as a,s as b};
@@ -1 +1 @@
1
- import{d as Q}from"./chunk-RPOP6MVJ.js";import{a as z,c as d,e as i,h as c,j as h}from"./chunk-4CUWZQXT.js";h();function R(r,t,n={}){let{query:l,route:g}=Q(),{replace:m=!1,serialize:y=e=>String(e),deserialize:f=e=>e}=n,a=i(t),T=i(y),P=i(f);a.current=t,T.current=y,P.current=f;let o=c(()=>{let e=l[r];return e!==void 0?P.current(e):a.current},[l,r]),[S,p]=z(o);d(()=>{p(o())},[o]);let b=c(e=>{p(e);let s=new URL(window.location.href),u=T.current(e);u===String(a.current)||u===""?s.searchParams.delete(r):s.searchParams.set(r,u);let k=s.pathname+s.search;g(k,m)},[r,m,g]);return[S,b]}function O(r,t=""){return R(r,t)}function w(r,t=[]){return R(r,t,{serialize:n=>Array.isArray(n)?n.join(","):"",deserialize:n=>n?n.split(",").filter(Boolean):t})}export{O as a,w as b};
1
+ import{d as Q}from"./chunk-BUNR5EU3.js";import{a as z,c as d,e as i,h as c,j as h}from"./chunk-LROR6N3B.js";h();function R(r,t,n={}){let{query:l,route:g}=Q(),{replace:m=!1,serialize:y=e=>String(e),deserialize:f=e=>e}=n,a=i(t),T=i(y),P=i(f);a.current=t,T.current=y,P.current=f;let o=c(()=>{let e=l[r];return e!==void 0?P.current(e):a.current},[l,r]),[S,p]=z(o);d(()=>{p(o())},[o]);let b=c(e=>{p(e);let s=new URL(window.location.href),u=T.current(e);u===String(a.current)||u===""?s.searchParams.delete(r):s.searchParams.set(r,u);let k=s.pathname+s.search;g(k,m)},[r,m,g]);return[S,b]}function O(r,t=""){return R(r,t)}function w(r,t=[]){return R(r,t,{serialize:n=>Array.isArray(n)?n.join(","):"",deserialize:n=>n?n.split(",").filter(Boolean):t})}export{R as a,O as b,w as c};
@@ -1 +1 @@
1
- import{b as C}from"./chunk-BEDUTYQP.js";import{e as F}from"./chunk-W3HIZQ4Z.js";import{c,e as y,p as w,q as U,r as m}from"./chunk-EGEB6N4J.js";import{Ga as d,a as f,c as g,da as v,h as S,i as p,j as b,wb as k}from"./chunk-4CUWZQXT.js";import{j as a,k as h}from"./chunk-KUCVLANF.js";h();b();var z=[{name:"Google Drive Folder",key:"googleDriveFolder",placeholder:"https://drive.google.com/drive/folders/...",description:`Where Google Sheets created by Root CMS's localization process are stored. If unspecified, they will be created in your "My Drive".`,ui:e=>d(v,{disabled:!e,variant:"default",size:"xs",compact:!0,rightIcon:d(k,{size:14}),onClick:()=>{e&&window.open(e,F(e))},children:"Open"})}],D=a(null);function X(e){let{db:r,user:s}=C(),o=window.__ROOT_CTX.rootConfig.projectId,[P,u]=f({});g(()=>{let n=c(r,"Projects",o),i=m(n,t=>{if(t.exists()){let l=t.data()||{};u(l.settings||{})}else u({})},t=>{console.error("Failed to subscribe to site settings:",t)});return()=>i()},[r,o,s.uid]);let x=S(async(n,i)=>{let t=c(r,"Projects",o);try{await U(t,new y("settings",n),i)}catch(l){console.error("Failed to set setting",n,l)}},[r,o,s.uid]);return d(D.Provider,{value:{settings:P,setSettings:x},children:e.children})}function B(){let e=p(D);if(!e)throw new Error("useSiteSettings must be used within a <SiteSettingsProvider>");return e}h();b();var I=a(null);function H(e){let{db:r,user:s}=C(),o=window.__ROOT_CTX.rootConfig.projectId,[P,u]=f({});g(()=>{let n=c(r,"Projects",o,"Users",s.uid),i=m(n,t=>{t.exists()?u(t.data()):u({})},t=>{console.error("Failed to subscribe to user preferences:",t)});return()=>i()},[r,o,s.uid]);let x=S(async(n,i)=>{let t=c(r,"Projects",o,"Users",s.uid);try{await w(t,{[n]:i},{merge:!0})}catch(l){console.error("Failed to set user preference",n,l)}},[r,o,s.uid]);return d(I.Provider,{value:{preferences:P,setPreference:x},children:e.children})}function K(){let e=p(I);if(!e)throw new Error("useUserPreferences must be used within a <UserPreferencesProvider>");return e}export{z as a,X as b,B as c,H as d,K as e};
1
+ import{b as C}from"./chunk-JTIQBW33.js";import{e as F}from"./chunk-JS6TK4OP.js";import{c,e as y,p as w,q as U,s as m}from"./chunk-VD6G5NV4.js";import{Ga as d,a as f,c as g,da as v,h as S,i as p,j as b,wb as k}from"./chunk-LROR6N3B.js";import{j as a,k as h}from"./chunk-KUCVLANF.js";h();b();var z=[{name:"Google Drive Folder",key:"googleDriveFolder",placeholder:"https://drive.google.com/drive/folders/...",description:`Where Google Sheets created by Root CMS's localization process are stored. If unspecified, they will be created in your "My Drive".`,ui:e=>d(v,{disabled:!e,variant:"default",size:"xs",compact:!0,rightIcon:d(k,{size:14}),onClick:()=>{e&&window.open(e,F(e))},children:"Open"})}],D=a(null);function X(e){let{db:r,user:s}=C(),o=window.__ROOT_CTX.rootConfig.projectId,[P,u]=f({});g(()=>{let n=c(r,"Projects",o),i=m(n,t=>{if(t.exists()){let l=t.data()||{};u(l.settings||{})}else u({})},t=>{console.error("Failed to subscribe to site settings:",t)});return()=>i()},[r,o,s.uid]);let x=S(async(n,i)=>{let t=c(r,"Projects",o);try{await U(t,new y("settings",n),i)}catch(l){console.error("Failed to set setting",n,l)}},[r,o,s.uid]);return d(D.Provider,{value:{settings:P,setSettings:x},children:e.children})}function B(){let e=p(D);if(!e)throw new Error("useSiteSettings must be used within a <SiteSettingsProvider>");return e}h();b();var I=a(null);function H(e){let{db:r,user:s}=C(),o=window.__ROOT_CTX.rootConfig.projectId,[P,u]=f({});g(()=>{let n=c(r,"Projects",o,"Users",s.uid),i=m(n,t=>{t.exists()?u(t.data()):u({})},t=>{console.error("Failed to subscribe to user preferences:",t)});return()=>i()},[r,o,s.uid]);let x=S(async(n,i)=>{let t=c(r,"Projects",o,"Users",s.uid);try{await w(t,{[n]:i},{merge:!0})}catch(l){console.error("Failed to set user preference",n,l)}},[r,o,s.uid]);return d(I.Provider,{value:{preferences:P,setPreference:x},children:e.children})}function K(){let e=p(I);if(!e)throw new Error("useUserPreferences must be used within a <UserPreferencesProvider>");return e}export{z as a,X as b,B as c,H as d,K as e};
@@ -0,0 +1 @@
1
+ import{a as Vt}from"./chunk-AAHM6RYJ.js";import{d as Y,e as N}from"./chunk-BUNR5EU3.js";import{C as dt,Cc as zt,D as j,E as ut,Fa as Et,Fb as Bt,Fc as Wt,G as U,Ga as r,H as mt,I as gt,K as ft,O as ht,Ob as It,P as _t,Q as vt,S as Q,T as yt,Tb as Tt,Y as S,Ya as Pt,Z as bt,_ as Ct,a as x,aa as xt,c as O,e as pt,ec as Mt,fa as wt,fb as At,ha as St,ia as kt,j as je,ja as Lt,ka as Ot,ob as Nt,pc as Dt,qa as Z,ua as jt,v as n,xc as Ht,y as w,yc as Rt}from"./chunk-LROR6N3B.js";import{d as V,j as ct}from"./chunk-KUCVLANF.js";var tt={name:"@blinkk/root-cms",version:"3.1.2",author:"s@blinkk.com",license:"MIT",engines:{node:">=22.0.0"},repository:{type:"git",url:"git+https://github.com/blinkk/rootjs.git",directory:"packages/root-cms"},files:["dist/**/*"],bin:{"root-cms":"./bin/root-cms.js"},type:"module",module:"./dist/core.js",types:"./dist/core/core.d.ts",exports:{".":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./browser-client":{types:"./dist/browser-client/browser-client.d.ts",import:"./dist/browser-client.js"},"./client":{types:"./dist/core/client.d.ts",import:"./dist/client.js"},"./core":{types:"./dist/core/core.d.ts",import:"./dist/core.js"},"./functions":{types:"./dist/core/functions.d.ts",import:"./dist/functions.js"},"./plugin":{types:"./dist/core/plugin.d.ts",import:"./dist/plugin.js"},"./project":{types:"./dist/core/project.d.ts",import:"./dist/project.js"},"./richtext":{types:"./dist/core/richtext.d.ts",import:"./dist/richtext.js"}},scripts:{build:'rm -rf dist && concurrently -n "core,signin,ui" npm:build:core npm:build:signin npm:build:ui',"build:core":"node ../../scripts/build-esbuild.mjs ./esbuild.config.json","build:ui":"pnpm build:ui:bundle && pnpm build:ui:clean","build:ui:bundle":"esbuild ui/ui.tsx --bundle --minify --alias:react=@preact/compat --alias:react-dom=@preact/compat --tsconfig=ui/tsconfig.json --outdir=dist/ui --legal-comments=external --splitting --format=esm","build:ui:clean":"rm -f dist/ui/*-*.css","build:signin":"esbuild signin/signin.tsx --bundle --minify --tsconfig=signin/tsconfig.json --outdir=dist/ui --legal-comments=external",dev:'rm -rf dist && concurrently -k -n "core,ui" npm:dev:core npm:dev:signin npm:dev:ui',"dev:core":"pnpm build:core --watch","dev:signin":"pnpm build:signin --watch","dev:ui":"pnpm build:ui:bundle --watch",test:"pnpm build && firebase emulators:exec 'vitest run --exclude=**/*.visual.test.tsx'","test:visual":"vitest run --config=vitest.config.visual.ts","test:watch":"pnpm build && firebase emulators:exec 'vitest'"},dependencies:{"@ag-grid-community/client-side-row-model":"32.3.9","@ag-grid-community/core":"32.3.9","@ag-grid-community/react":"32.3.9","@ag-grid-community/styles":"32.3.9","@ai-sdk/anthropic":"3.0.74","@ai-sdk/google":"3.0.67","@ai-sdk/openai":"3.0.60","@ai-sdk/openai-compatible":"2.0.46","@ai-sdk/react":"3.0.177","@google-cloud/firestore":"7.11.3","@hello-pangea/dnd":"18.0.1","@mantine/spotlight":"4.2.12","@types/cli-progress":"3.11.6",ai:"6.0.175","body-parser":"1.20.2","cli-progress":"3.12.0",commander:"11.0.0","csv-parse":"5.5.2","csv-stringify":"6.4.4","date-fns":"4.1.0","date-fns-tz":"3.2.0",diff:"8.0.2","dts-dom":"3.7.0","fnv-plus":"1.3.1",jsonwebtoken:"9.0.2",kleur:"4.1.5",minisearch:"7.2.0","sanitize-html":"2.13.1",sirv:"2.0.3","tiny-glob":"0.2.9",zod:"4.4.3"},"//":"NOTE(stevenle): due to compat issues with mantine and preact, mantine is pinned to v4.2.12",devDependencies:{"@babel/core":"7.17.9","@blinkk/root":"workspace:*","@editorjs/editorjs":"2.30.8","@editorjs/header":"2.8.8","@editorjs/image":"2.10.2","@editorjs/list":"2.0.6","@editorjs/nested-list":"1.4.3","@editorjs/raw":"2.5.1","@editorjs/table":"2.4.4","@editorjs/underline":"1.2.1","@emotion/react":"11.10.5","@firebase/app-compat":"0.5.2","@firebase/app-types":"0.9.3","@firebase/rules-unit-testing":"5.0.0","@lexical/code":"0.33.1","@lexical/html":"0.33.1","@lexical/link":"0.33.1","@lexical/list":"0.33.1","@lexical/markdown":"0.33.1","@lexical/react":"0.33.1","@lexical/rich-text":"0.33.1","@lexical/selection":"0.33.1","@lexical/table":"0.33.1","@lexical/utils":"0.33.1","@mantine/core":"4.2.12","@mantine/hooks":"4.2.12","@mantine/modals":"4.2.12","@mantine/notifications":"4.2.12","@preact/compat":"18.3.1","@tabler/icons-preact":"3.35.0","@testing-library/preact":"3.2.4","@testing-library/user-event":"14.6.1","@types/body-parser":"1.19.3","@types/fnv-plus":"1.3.2","@types/gapi":"0.0.47","@types/gapi.client.drive-v3":"0.0.4","@types/gapi.client.sheets-v4":"0.0.4","@types/google.accounts":"0.0.14","@types/jsonwebtoken":"9.0.1","@types/node":"24.3.1","@types/sanitize-html":"2.13.0","@vitest/browser":"4.1.8","@vitest/browser-playwright":"4.1.8",concurrently:"7.6.0",esbuild:"0.28.0",firebase:"12.2.1","firebase-admin":"13.5.0","firebase-functions":"6.4.0","firebase-tools":"14.15.2","highlight.js":"11.6.0",jsdom:"27.2.0","json-diff-kit":"1.0.29",lexical:"0.33.1",marked:"9.1.1","mdast-util-from-markdown":"2.0.1","mdast-util-gfm":"3.0.0","micromark-extension-gfm":"3.0.0",playwright:"1.60.0",preact:"10.27.1","preact-iso":"2.11.1","preact-render-to-string":"6.6.7",react:"npm:@preact/compat@18.3.1","react-dom":"npm:@preact/compat@18.3.1","react-easy-crop":"5.5.6","react-json-view-compare":"2.0.2",typescript:"6.0.3",vite:"8.0.13",vitest:"4.1.6",yjs:"13.6.27"},peerDependencies:{"@blinkk/root":"3.1.2","firebase-admin":">=11","firebase-functions":">=4"},peerDependenciesMeta:{"firebase-functions":{optional:!0}}};function Ut(){return r("svg",{width:"100",height:"23",viewBox:"0 0 100 23",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("g",{"clip-path":"url(#clip0_1_318)",children:[r("path",{d:"M7.82998 5.01802C3.12925 5.6479 0.833937 18.1194 2.62578 19.6731C5.64773 22.2934 16.6441 14.1722 15.6786 9.46913C15.3009 6.61371 11.2717 4.28377 7.82998 5.01802Z",fill:"black"}),r("path",{d:"M13.9782 0.720147C12.6553 0.896474 12.0093 4.38767 12.5136 4.8226C13.364 5.55611 16.4587 3.28271 16.187 1.96616C16.0807 1.16683 14.9468 0.514607 13.9782 0.720147Z",fill:"black"}),r("path",{d:"M92.7383 17.6275C90.9681 17.6275 89.3816 17.0263 88.3796 16.0744C87.9955 15.7237 87.8953 15.3396 88.246 14.9555L88.8305 14.2541C89.1645 13.87 89.5486 13.7865 89.9327 14.1205C90.6007 14.6883 91.7029 15.1726 92.5713 15.1726C93.5232 15.1726 94.1244 14.8219 94.1244 14.2875C94.1244 13.5193 93.2059 13.4358 91.9868 13.0684C90.417 12.6008 88.5132 11.7324 88.5132 9.64493C88.5132 7.70773 90.25 6.37173 92.7383 6.37173C94.2413 6.37173 95.5272 6.87273 96.4123 7.57413C96.8131 7.90813 96.9467 8.27553 96.596 8.67633L96.0282 9.37773C95.7109 9.76183 95.3435 9.82863 94.926 9.51133C94.3916 9.09383 93.6568 8.69303 92.7884 8.69303C92.0202 8.69303 91.5192 9.01033 91.5192 9.51133C91.5192 10.1292 92.3041 10.4131 93.1224 10.6636C94.9761 11.2314 97.1304 11.8326 97.1304 14.2708C97.1304 16.4585 95.1264 17.6275 92.7383 17.6275Z",fill:"black"}),r("path",{d:"M87.0008 16.6756C87.0843 17.1766 86.8171 17.4271 86.2994 17.4271H85.097C84.596 17.4271 84.3789 17.1766 84.3121 16.6756L83.7443 11.9161L81.757 16.7424C81.5399 17.2434 81.1892 17.5106 80.6882 17.5106H80.5212C80.0202 17.5106 79.6695 17.2434 79.4524 16.7424L77.4651 11.8994L76.8973 16.6756C76.8472 17.1766 76.6301 17.4271 76.1291 17.4271H74.7263C74.2086 17.4271 73.9414 17.1766 74.0082 16.6756L75.4945 7.24013C75.5613 6.75583 75.8786 6.48863 76.3796 6.48863H76.5466C77.0476 6.48863 77.3315 6.75583 77.5486 7.24013L80.6047 13.8032L83.4938 7.24013C83.7109 6.75583 84.0115 6.48863 84.4958 6.48863H84.6795C85.1638 6.48863 85.4811 6.75583 85.5646 7.24013L87.0008 16.6756Z",fill:"black"}),r("path",{d:"M68.6496 17.6275C65.3096 17.6275 62.7211 15.2227 62.7211 11.9996C62.7211 8.77653 65.3096 6.37173 68.683 6.37173C70.3029 6.37173 71.7558 6.97293 72.7745 7.99163C73.1419 8.34233 73.1419 8.77653 72.7745 9.09383L71.9228 9.81193C71.5554 10.1292 71.2047 10.1125 70.8206 9.79523C70.2361 9.31093 69.5013 9.01033 68.683 9.01033C67.013 9.01033 65.7104 10.2628 65.7104 11.9996C65.7104 13.7364 67.013 14.9889 68.683 14.9889C69.5013 14.9889 70.2528 14.6883 70.8206 14.204C71.2047 13.8867 71.5554 13.87 71.9228 14.1873L72.7745 14.9054C73.1419 15.2227 73.1419 15.6569 72.7745 16.0076C71.7558 17.0263 70.3029 17.6275 68.6496 17.6275Z",fill:"black"}),r("path",{d:"M58.575 16.2915C58.7587 16.6923 58.4581 16.8927 58.241 17.0597C57.7233 17.4271 56.9384 17.6442 56.1201 17.6442C54.4501 17.6442 52.8469 16.6923 52.8469 14.4044V11.0978H52.1121C51.6111 11.0978 51.3439 10.8139 51.3439 10.3296V9.76183C51.3439 9.26083 51.6111 8.99363 52.1121 8.99363H52.8469V7.05643C52.8469 6.57213 53.1308 6.38843 53.6151 6.28823L54.9511 6.05443C55.4521 5.95423 55.7193 6.30493 55.7193 6.80593V8.99363H57.3726C57.8569 8.99363 58.1408 9.26083 58.1408 9.76183V10.3296C58.1408 10.8139 57.8569 11.0978 57.3726 11.0978H55.7193V14.1038C55.7193 14.9221 56.1368 15.1893 56.6545 15.1893C56.905 15.1893 57.1555 15.0724 57.3392 14.9555C57.7567 14.6883 57.9571 14.8887 58.1074 15.206L58.575 16.2915Z",fill:"black"}),r("path",{d:"M46.2592 17.6442C43.5538 17.6442 41.5999 15.7738 41.5999 13.2521C41.5999 10.7304 43.5538 8.86003 46.2592 8.86003C48.9646 8.86003 50.9185 10.7304 50.9185 13.2521C50.9185 15.7738 48.9646 17.6442 46.2592 17.6442ZM46.2592 15.1726C47.3113 15.1726 48.0628 14.3543 48.0628 13.2521C48.0628 12.1499 47.3113 11.3316 46.2592 11.3316C45.2071 11.3316 44.4389 12.1499 44.4389 13.2521C44.4389 14.3543 45.2071 15.1726 46.2592 15.1726Z",fill:"black"}),r("path",{d:"M36.052 17.6442C33.3466 17.6442 31.3927 15.7738 31.3927 13.2521C31.3927 10.7304 33.3466 8.86003 36.052 8.86003C38.7574 8.86003 40.7113 10.7304 40.7113 13.2521C40.7113 15.7738 38.7574 17.6442 36.052 17.6442ZM36.052 15.1726C37.1041 15.1726 37.8556 14.3543 37.8556 13.2521C37.8556 12.1499 37.1041 11.3316 36.052 11.3316C34.9999 11.3316 34.2317 12.1499 34.2317 13.2521C34.2317 14.3543 34.9999 15.1726 36.052 15.1726Z",fill:"black"}),r("path",{d:"M28.7099 13.0851L30.6805 16.6422C30.9644 17.1599 30.6638 17.4271 30.1628 17.4271H28.4594C27.9417 17.4271 27.8081 17.1766 27.5242 16.6589L25.7707 13.4859H24.6351V16.6422C24.6351 17.1432 24.3512 17.4271 23.8502 17.4271H22.4808C21.9798 17.4271 21.6959 17.1432 21.6959 16.6422V7.35703C21.6959 6.85603 21.9798 6.57213 22.4808 6.57213H26.5222C29.3111 6.57213 30.8141 7.92483 30.8141 10.1125C30.8141 11.5654 29.9791 12.5841 28.7099 13.0851ZM24.6351 8.96023V11.5153H26.4721C27.2236 11.5153 27.8248 11.0644 27.8248 10.2628C27.8248 9.44453 27.2236 8.96023 26.4721 8.96023H24.6351Z",fill:"black"})]}),r("defs",{children:r("clipPath",{id:"clip0_1_318",children:r("rect",{width:"99",height:"22",fill:"white",transform:"translate(0.0175781 0.177246)"})})})]})}w();var Qt=ct(null);w();w();var Pe=Object.defineProperty,Ae=Object.defineProperties,Ne=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,Gt=(t,e,o)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Te=(t,e)=>{for(var o in e||(e={}))Be.call(e,o)&&Gt(t,o,e[o]);if(Zt)for(var o of Zt(e))Ie.call(e,o)&&Gt(t,o,e[o]);return t},Me=(t,e)=>Ae(t,Ne(e));function De(t){return Me(Te({},t),{id:t.id||ft()})}function He(t){let e=[];return t.reduceRight((o,i)=>(e.includes(i.id)||(e.push(i.id),o.push(i)),o),[]).reverse()}function G(t){return He(t.map(e=>De(e)))}function Ft(t,e){let[o,i]=x(G(typeof t=="function"?t(e):t));return O(()=>{typeof t=="function"&&i(G(t(e)))},[e]),[o,{registerActions:s=>i(a=>G([...a,...s])),updateActions:s=>i(G(typeof s=="function"?s(e):s)),removeActions:s=>i(a=>a.filter(d=>!s.includes(d.id))),triggerAction:s=>{var a;let d=o.find(g=>g.id===s);(a=d?.onTrigger)==null||a.call(d,d)}}]}function Re(t,e){return t===null?[]:Array.isArray(t)?t.map(o=>[o,e]):[[t,e]]}function Kt(t,e){_t(Re(t,e))}w();w();var ze=j((t,{radius:e})=>({action:{position:"relative",display:"block",width:"100%",padding:"10px 12px",borderRadius:t.fn.radius(e)},actionHovered:{backgroundColor:t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[1]},actionIcon:{color:t.colorScheme==="dark"?t.colors.dark[2]:t.colors.gray[6]},actionBody:{flex:1}})),$t=ze;var We=Object.defineProperty,F=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Xt=(t,e,o)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ve=(t,e)=>{for(var o in e||(e={}))qt.call(e,o)&&Xt(t,o,e[o]);if(F)for(var o of F(e))Jt.call(e,o)&&Xt(t,o,e[o]);return t},Ue=(t,e)=>{var o={};for(var i in t)qt.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Jt.call(t,i)&&(o[i]=t[i]);return o};function et(t){var e=t,{action:o,styles:i,classNames:l,hovered:c,onTrigger:m,highlightQuery:_,highlightColor:s,query:a,radius:d}=e,g=Ue(e,["action","styles","classNames","hovered","onTrigger","highlightQuery","highlightColor","query","radius"]);let{classes:u,cx:h}=$t({radius:d},{styles:i,classNames:l,name:"Spotlight"});return n.createElement(Q,Ve({className:h(u.action,{[u.actionHovered]:c}),tabIndex:-1,onMouseDown:b=>b.preventDefault(),onClick:m},g),n.createElement(wt,{noWrap:!0},o.icon&&n.createElement(yt,{className:u.actionIcon},o.icon),n.createElement("div",{className:u.actionBody},n.createElement(Ot,{highlightColor:s,highlight:_?a:null},o.title),o.description&&n.createElement(S,{color:"dimmed",size:"xs"},o.description))))}et.displayName="@mantine/spotlight/DefaultAction";w();var Qe=j(t=>({nothingFound:{},actions:{padding:t.spacing.xs/2,borderTop:`1px solid ${t.colorScheme==="dark"?t.colors.dark[4]:t.colors.gray[2]}`},actionsGroup:{textTransform:"uppercase",fontSize:t.spacing.xs,fontWeight:700,padding:"10px 12px",paddingBottom:0,paddingTop:15}})),Yt=Qe;function ot({actions:t,styles:e,classNames:o,actionComponent:i,hovered:l,onActionHover:c,onActionTrigger:m,query:_,nothingFoundMessage:s,highlightQuery:a,highlightColor:d,radius:g}){let{classes:u}=Yt(null,{classNames:o,styles:e,name:"Spotlight"}),h=t.map(v=>v.type==="item"?n.createElement(i,{query:_,key:v.item.id,action:v.item,hovered:v.index===l,onMouseEnter:()=>c(v.index),classNames:o,styles:e,radius:g,onTrigger:()=>m(v.item),highlightQuery:a,highlightColor:d}):n.createElement(S,{className:u.actionsGroup,color:"dimmed",key:v.label},v.label)),b=h.length>0||!!s&&_.trim().length>0;return n.createElement(n.Fragment,null,b&&n.createElement("div",{className:u.actions},h.length>0?h:n.createElement(S,{color:"dimmed",className:u.nothingFound,align:"center",size:"lg",py:"md"},s)))}ot.displayName="@mantine/spotlight/ActionsList";function Ze(t){return Array.isArray(t)?t.map(e=>e.trim()).join(",").toLowerCase().trim():typeof t=="string"?t.toLowerCase().trim():""}function te(t,e){let o=t.trim().toLowerCase(),i=[[],[]];return e.forEach(l=>{var c,m;(c=l.title)!=null&&c.toLowerCase().includes(o)?i[0].push(l):((m=l.description)!=null&&m.toLowerCase().includes(o)||Ze(l.keywords).includes(o))&&i[1].push(l)}),i.flat()}var Ge=Object.defineProperty,Fe=Object.defineProperties,Ke=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,oe=(t,e,o)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,re=(t,e)=>{for(var o in e||(e={}))$e.call(e,o)&&oe(t,o,e[o]);if(ee)for(var o of ee(e))Xe.call(e,o)&&oe(t,o,e[o]);return t},ie=(t,e)=>Fe(t,Ke(e)),qe=j((t,{centered:e,maxWidth:o,topOffset:i,radius:l})=>({root:ie(re({},t.fn.cover()),{position:"fixed"}),spotlight:{position:"relative",zIndex:2,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white,borderRadius:t.fn.radius(l),width:"100%",maxWidth:o,overflow:"hidden",marginLeft:"calc(var(--removed-scroll-width, 0px) * -1)"},overlay:ie(re({},t.fn.cover()),{position:"fixed"}),inner:{height:"100vh",display:"flex",flexDirection:"column",paddingTop:e?t.spacing.md:i,justifyContent:e?"center":"flex-start",alignItems:"center"},searchInput:{border:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,backgroundColor:t.colorScheme==="dark"?t.colors.dark[6]:t.white}})),ne=qe;var Je=Object.defineProperty,K=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ae=(t,e,o)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,Ye=(t,e)=>{for(var o in e||(e={}))se.call(e,o)&&ae(t,o,e[o]);if(K)for(var o of K(e))le.call(e,o)&&ae(t,o,e[o]);return t},to=(t,e)=>{var o={};for(var i in t)se.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&K)for(var i of K(t))e.indexOf(i)<0&&le.call(t,i)&&(o[i]=t[i]);return o};function rt(t){var e=t,{query:o,onQueryChange:i,actions:l,onClose:c,opened:m,withinPortal:_,transition:s="pop",transitionDuration:a,classNames:d,styles:g,overlayColor:u="#000",overlayOpacity:h=.25,overlayBlur:b=3,shadow:v="md",radius:E="sm",centered:X=!1,closeOnActionTrigger:B=!0,highlightQuery:I=!1,highlightColor:T,maxWidth:M=600,topOffset:D=120,className:q,searchPlaceholder:H,searchIcon:R,filter:fe=te,nothingFoundMessage:he,limit:_e=10,actionComponent:ve=et,actionsWrapperComponent:ye="div",zIndex:be=dt("modal")}=e,Ce=to(e,["query","onQueryChange","actions","onClose","opened","withinPortal","transition","transitionDuration","classNames","styles","overlayColor","overlayOpacity","overlayBlur","shadow","radius","centered","closeOnActionTrigger","highlightQuery","highlightColor","maxWidth","topOffset","className","searchPlaceholder","searchIcon","filter","nothingFoundMessage","limit","actionComponent","actionsWrapperComponent","zIndex"]);let[z,k]=x(-1),[xe,at]=x(!1),{classes:P,cx:we}=ne({centered:X,maxWidth:M,topOffset:D,radius:E},{classNames:d,styles:g,name:"Spotlight"}),[,st]=ht(),Se=gt(m),J=()=>k(-1),W=()=>{J(),c()};mt({transitionDuration:0,opened:m});let ke=fe(o,l).slice(0,_e),lt=ut(ke).items,L=lt.map(f=>f.type==="item"?f.item:void 0).filter(f=>f);U(()=>{L.length-1<z&&k(L.length-1)},[L.length]);let Le=f=>{var A;if(!xe)switch(f.code){case"ArrowDown":{f.preventDefault(),k(y=>y<L.length-1?y+1:0);break}case"ArrowUp":{f.preventDefault(),k(y=>y>0?y-1:L.length-1);break}case"Enter":{f.preventDefault();let y=L[z];(A=y?.onTrigger)==null||A.call(y,y),B&&y?.onTrigger&&W();break}case"Escape":f.preventDefault(),W()}},Oe=f=>{i(f.currentTarget.value),z===-1&&k(0)};return n.createElement(St,{withinPortal:_,zIndex:be},n.createElement(kt,{onExited:()=>st(!1),onEntered:()=>st(!0),mounted:m,transitions:{spotlight:{duration:a,transition:s,timingFunction:"ease"},overlay:{duration:a/2,transition:"fade",timingFunction:"ease"}}},f=>n.createElement("div",Ye({className:we(P.root,q)},Ce),n.createElement("div",{className:P.inner,ref:Se},n.createElement(bt,{style:f.spotlight,className:P.spotlight,shadow:v,radius:E,onMouseLeave:J},n.createElement(jt,{value:o,onChange:Oe,onKeyDown:Le,onCompositionStart:()=>at(!0),onCompositionEnd:()=>at(!1),classNames:{input:P.searchInput},size:"lg",placeholder:H,icon:R,onMouseEnter:J,autoComplete:"chrome-please-just-do-not-show-it-thanks"}),n.createElement(ye,null,n.createElement(ot,{highlightQuery:I,highlightColor:T,actions:lt,actionComponent:ve,hovered:z,query:o,nothingFoundMessage:he,onActionHover:k,onActionTrigger:A=>{A.onTrigger(A),B&&W()},styles:g,classNames:d,radius:E}))),n.createElement("div",{style:f.overlay},n.createElement(Lt,{className:P.overlay,zIndex:1,onMouseDown:W,color:u,opacity:h,blur:b}))))))}rt.displayName="@mantine/spotlight/Spotlight";w();var it={open:"mantine:open-spotlight",close:"mantine:close-spotlight",toggle:"mantine:toggle-spotlight",triggerAction:"mantine:trigger-spotlight-action",registerActions:"mantine:register-spotlight-actions",removeActions:"mantine:remove-spotlight-actions"};function eo(t,e){return new CustomEvent(t,{detail:e})}function nt(){window.dispatchEvent(eo(it.open))}function ce(t){let e={registerActions:o=>t.registerActions(o.detail),removeActions:o=>t.removeActions(o.detail),triggerAction:o=>t.triggerAction(o.detail),open:t.openSpotlight,close:t.closeSpotlight,toggle:t.toggleSpotlight};O(()=>(Object.keys(e).forEach(o=>{window.addEventListener(it[o],e[o])}),()=>{Object.keys(e).forEach(o=>{window.removeEventListener(it[o],e[o])})}),[])}var oo=Object.defineProperty,$=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,pe=(t,e,o)=>e in t?oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,ro=(t,e)=>{for(var o in e||(e={}))de.call(e,o)&&pe(t,o,e[o]);if($)for(var o of $(e))ue.call(e,o)&&pe(t,o,e[o]);return t},io=(t,e)=>{var o={};for(var i in t)de.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&$)for(var i of $(t))e.indexOf(i)<0&&ue.call(t,i)&&(o[i]=t[i]);return o};function me(t){var e=t,{actions:o,children:i,shortcut:l="mod + K",onSpotlightClose:c,onSpotlightOpen:m,onQueryChange:_,cleanQueryOnClose:s=!0,transitionDuration:a=150}=e,d=io(e,["actions","children","shortcut","onSpotlightClose","onSpotlightOpen","onQueryChange","cleanQueryOnClose","transitionDuration"]);let g=pt(-1),[u,h]=x(""),[b,{registerActions:v,updateActions:E,removeActions:X,triggerAction:B}]=Ft(o,u);U(()=>{E(o)},[o]);let I=R=>{h(R),_?.(R)},[T,{open:M,close:D,toggle:q}]=vt(!1,{onClose:()=>{c?.(),s&&(g.current=window.setTimeout(()=>{I("")},a))},onOpen:()=>{m?.(),window.clearTimeout(g.current)}}),H={openSpotlight:M,closeSpotlight:D,toggleSpotlight:q,registerActions:v,removeActions:X,triggerAction:B,opened:T,actions:b,query:u};return Kt(l,M),ce(H),n.createElement(Qt.Provider,{value:H},n.createElement(rt,ro({actions:b,onClose:D,opened:T,query:u,onQueryChange:I,transitionDuration:a},d)),i)}me.displayName="@mantine/spotlight/SpotlightProvider";je();function ge(t){let[e,o]=x(!1);O(()=>{let l=navigator.userAgentData?.platform??navigator.platform;o(/mac/i.test(l||""))},[]);let i=()=>{nt()};return r("button",{type:"button",className:N("SearchBar",t.className),onClick:i,"aria-label":"Open search",children:[r(zt,{className:"SearchBar__icon",size:16,stroke:1.5}),r("span",{className:"SearchBar__placeholder",children:"Search"}),r("span",{className:"SearchBar__shortcut","aria-hidden":"true",children:e?"\u2318 + K":"Ctrl + K"})]})}var C="1.5";function p(t){return r("div",{className:"Layout",children:[r(p.Top,{}),r(p.Side,{}),r(p.Main,{...t,children:t.children}),r(p.Bottom,{})]})}function no(t){let o=t.split("?")[0].replace(/\/+$/g,"").split("/").filter(Boolean);return o.length===4&&o[0]==="cms"&&o[1]==="content"}p.Top=()=>{let t=window.__ROOT_CTX.rootConfig,e=t.projectName||t.projectId,o=t.minimalBranding,{url:i}=Y(),l=!no(i);return r("div",{className:"Layout__top",children:[o?r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:e}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]})]}):r(V,{children:[r("a",{className:"Layout__top__logo",href:"/cms",children:r(Ut,{})}),r("a",{className:"Layout__top__version",href:"https://github.com/blinkk/rootjs/blob/main/packages/root-cms/CHANGELOG.md",target:"_blank",rel:"noreferrer noopener",children:["v",tt.version]}),r("div",{className:"Layout__top__project",children:e})]}),l&&r("div",{className:"Layout__top__search",children:r(ge,{})})]})};p.Side=()=>{let{url:t}=Y(),e=t.replace(/\/*$/g,""),o=window.firebase.user,i=window.__ROOT_CTX.sidebar?.tools,l=new Set(window.__ROOT_CTX.sidebar?.hiddenBuiltInTools||[]),c=s=>l.has(s),m=window.__ROOT_CTX.experiments||{},_=async()=>{await window.firebase.auth.signOut(),window.location.href="/cms/login"};return r("div",{className:"Layout__side",children:[r("div",{className:"Layout__side__buttons",children:[!c("home")&&r(p.SideButton,{label:"Home",url:"/cms",active:e==="/cms",children:r(It,{stroke:C})}),!c("content")&&r(p.SideButton,{label:"Content",url:"/cms/content",active:e.startsWith("/cms/content"),children:r(Bt,{stroke:C})}),m.taskManager&&r(p.SideButton,{label:"Tasks",url:"/cms/tasks",active:e.startsWith("/cms/tasks"),children:r(At,{stroke:C})}),!c("releases")&&r(p.SideButton,{label:"Releases",url:"/cms/releases",active:e.startsWith("/cms/releases"),children:r(Rt,{stroke:C})}),!c("data")&&r(p.SideButton,{label:"Data",url:"/cms/data",active:e.startsWith("/cms/data"),children:r(Nt,{stroke:C})}),!c("assets")&&r(p.SideButton,{label:"Asset Library",url:"/cms/assets",active:e.startsWith("/cms/assets"),children:r(Dt,{stroke:C})}),!c("translations")&&r(p.SideButton,{label:"Translations",url:"/cms/translations",active:e.startsWith("/cms/translations"),children:r(Tt,{stroke:C})}),Vt()&&!c("ai")&&r(p.SideButton,{label:"Root AI",url:"/cms/ai",active:e.startsWith("/cms/ai"),children:r(Ht,{stroke:C})}),i&&r(V,{children:[r("div",{className:"Layout__side__divider"}),Object.entries(i).map(([s,a])=>{let d=a.cmsUrl?.startsWith("/cms/")?a.cmsUrl:void 0,g=a.externalUrl,u=g??d??`/cms/tools/${s}`,h=g?void 0:u.replace(/\/*$/g,""),b=!g&&!!h&&(e===h||e.startsWith(`${h}/`));return r(p.SideButton,{className:"Layout__side__tool",label:a.label||"",url:u,active:b,external:!!g,children:a.icon?r("img",{className:"Layout__side__tool__icon",src:a.icon,alt:a.label||""}):r(Pt,{stroke:C})},s)}),r("div",{className:"Layout__side__divider"})]}),!c("settings")&&r(p.SideButton,{label:"Settings",url:"/cms/settings",active:e.startsWith("/cms/settings"),children:r(Wt,{stroke:C})})]}),r("div",{className:"Layout__side__user",children:r(Z,{shadow:"md",position:"right",control:r(Q,{children:r(xt,{src:o.photoURL,alt:o.email,size:30,radius:"xl"})}),children:[r(Z.Label,{children:r(S,{size:"xs",color:"dimmed",truncate:!0,children:["Signed in as ",o.email]})}),r(Ct,{}),r(Z.Item,{color:"red",icon:r(Mt,{style:{width:14,height:14}}),onClick:_,children:"Sign out"})]})})]})};p.SideButton=t=>r(Et,{className:N("Layout__side__button",t.className),label:t.label,position:"right",withArrow:!0,children:r("a",{className:N(t.active&&"active"),href:t.url,target:t.external?"_blank":void 0,rel:t.external?"noreferrer noopener":void 0,children:t.children})});p.Main=t=>r("div",{className:"Layout__main",children:t.children});p.Bottom=()=>r("div",{className:"Layout__bottom"});export{me as a,p as b};
@@ -0,0 +1 @@
1
+ import{a as _t}from"./chunk-ENQKSLGJ.js";import{g as oe,h as Xe,i as ke,j as qe,k as Ke,l as Je,m as Qe,n as Ye,o as Ze,p as et,q as de,r as tt,s as Me,t as st,u as ce,y as _e,z as me}from"./chunk-AGFPVTBA.js";import{a as ct}from"./chunk-W5DOO6ID.js";import{a as dt}from"./chunk-NSOTG64N.js";import{b as M}from"./chunk-J5E457OI.js";import{a as b,b as je,c as Ge}from"./chunk-QHJOTXYB.js";import{b as He,d as ye}from"./chunk-KRNQ6L35.js";import{e as fe}from"./chunk-BUNR5EU3.js";import{$a as Fe,Ab as pe,Cc as it,Da as ie,Db as lt,Eb as he,Fa as Le,Fb as De,Ga as e,Pb as nt,Rc as O,Uc as rt,V as te,W as se,a as i,c as T,da as g,ea as L,g as Se,j as Ee,lb as ue,mc as ze,na as Pe,qa as k,ra as U,tb as Ne,ua as j,vb as ge,wb as ot,zb as at}from"./chunk-LROR6N3B.js";import{d as C}from"./chunk-KUCVLANF.js";import{g as Oe,h as re,k as D,l as G,m as Ce,n as H,o as Ve,p as We}from"./chunk-7SK47HHZ.js";Ee();Ee();function mt(t){let o=t.file||{},a=o.src||"",l=o.filename||a,r={"--asset-thumb-size":`${t.size}px`};if(a&&G(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("img",{src:Ie(o,t.size*2),alt:o.alt||"",loading:"lazy"})});if(a&&H(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("video",{src:a,muted:!0,playsInline:!0,preload:"metadata"})});let _=D(l);return e("div",{className:"AssetBrowser__thumb",style:r,children:_&&_.length<=4?e("div",{className:"AssetBrowser__thumb__ext",children:_}):e(pe,{size:20,stroke:"1.5"})})}function Ie(t,o){let a=t?.src||"";return a.startsWith(Oe)&&o?`${a}=s${o}`:a}function ve(t){let o=t?.src||"";Ce(o)&&(o=o.split("=")[0]+"=s0"),navigator.clipboard.writeText(o).then(()=>{b({message:"Copied URL to clipboard.",autoClose:2e3})})}function we(t){let o=t?.src||"";if(o)if(Ce(o)){let a=document.createElement("a");a.href=We(o),t.filename&&(a.download=t.filename),document.body.appendChild(a),a.click(),document.body.removeChild(a)}else window.open(o,"_blank")}function ft(t){let[o,a]=i(t.asset),[l,r]=i(t.asset.file?.alt||""),[_,d]=i(!1),[x,v]=i(!1),[m,B]=i(null),[h,F]=i(null),n=o.file||{},f=n.filename||o.name,N=G(f),S=H(f),V=l!==(n.alt||""),W=n.altDisabled===!0;T(()=>{_e(o.id).then(c=>F(c)).catch(c=>{console.error("failed to fetch asset usage:",c),F([])})},[o.id]);async function z(c,w){let p=await me(c,{previousFile:w});p.failedDocIds.length>0?b({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&&b({message:`Updated ${p.updatedDocIds.length} doc(s) that use this asset.`,color:"green"})}async function X(){d(!0),await M(async()=>{let c={...n},w=await st(o,l);a(w),t.onChanged(w),await z(w,c)}),d(!1)}function R(){let c=document.createElement("input");c.type="file",c.onchange=()=>{let w=c.files?.[0];if(!w)return;let p=D(f),y=D(w.name);if(p&&y&&p!==y){B(w);return}E(w)},c.click(),c.remove()}async function E(c){B(null),d(!0),await M(async()=>{let w={...n},p=await re(c),y=await tt(o,p);a(y),r(y.file?.alt||""),t.onChanged(y),await z(y,w)}),d(!1)}async function $(c){d(!0),await M(async()=>{let w={...n},p=await ce(o,c);a(p),r(p.file?.alt||""),t.onChanged(p),await z(p,w)}),d(!1)}async function q(){d(!0),await M(async()=>{await de(o),b({message:`Deleted "${o.name}".`,color:"green"}),t.onDeleted()}),d(!1)}return e(U,{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:Ie(n,800),alt:n.alt||"",style:n.canvasBgColor==="dark"?{background:"#000"}:{}}):S?e("video",{src:n.src,controls:!0,muted:!0,preload:"metadata"}):e("div",{className:"AssetBrowser__details__preview__placeholder",children:[e(pe,{size:48,stroke:"1"}),e("div",{children:f})]})}),e(ie,{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:f})]}),!!(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:[ye(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:[ye(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(j,{readOnly:!0,value:n.src||"",size:"xs",radius:"xs",onClick:c=>c.target.select(),styles:{root:{flex:1,minWidth:0}}}),e(Le,{label:"Copy URL",transition:"pop",children:e(se,{size:"sm",onClick:()=>ve(n),children:e(ue,{size:16})})})]})})]})]})}),(N||S)&&e("div",{className:"AssetBrowser__details__alt",children:[W?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(Pe,{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||_,onChange:c=>r(c.currentTarget.value)}),t.canManage&&V&&e(g,{size:"xs",color:"dark",mt:8,loading:_,onClick:()=>X(),children:"Save alt text"})]}),t.canManage&&e(L,{className:"AssetBrowser__details__alt__disableCheckbox",label:"Disable alt text (e.g. decorative images)",size:"xs",mt:8,checked:W,disabled:_,onChange:c=>$(c.currentTarget.checked)})]}),e("div",{className:"AssetBrowser__details__usage",children:[e("div",{className:"AssetBrowser__details__usage__title",children:"Used in"}),h===null?e(te,{color:"gray",size:"sm"}):h.length===0?e("div",{className:"AssetBrowser__details__usage__empty",children:"No docs use this asset."}):e("div",{className:"AssetBrowser__details__usage__list",children:h.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(ot,{size:14})]},c.id))})]}),e("div",{className:"AssetBrowser__details__buttons",children:[e(g,{variant:"default",size:"xs",leftIcon:e(ge,{size:14}),onClick:()=>we(n),children:"Download"}),t.canManage&&e(C,{children:[e(g,{variant:"default",size:"xs",leftIcon:e(at,{size:14}),loading:_,onClick:()=>R(),children:"Replace file"}),e(g,{className:"AssetBrowser__details__buttons__delete",color:"red",variant:"filled",size:"xs",leftIcon:e(O,{size:14}),disabled:_,onClick:()=>v(!0),children:"Delete"})]})]}),m&&e("div",{className:"AssetBrowser__details__confirmReplace",children:[e("div",{children:["The new file has a different type (",e("b",{children:[".",D(f)]})," ","\u2192 ",e("b",{children:[".",D(m.name)]}),"). Replacing will change the asset's file extension and serving URL",Me(o.name,D(m.name))!==o.name&&e(C,{children:[", and the asset will be renamed to"," ",e("b",{children:Me(o.name,D(m.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:_,children:"Cancel"}),e(g,{color:"dark",size:"xs",loading:_,onClick:()=>E(m),children:"Replace"})]})]}),x&&e("div",{className:"AssetBrowser__details__confirmDelete",children:[e("div",{children:["Delete ",e("b",{children:o.name})," from the asset library?",h&&h.length>0&&e(C,{children:[" ","This asset is used in ",h.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:_,children:"Cancel"}),e(g,{color:"red",size:"xs",loading:_,onClick:()=>q(),children:"Delete"})]})]})]})})}function Te(t){let[o,a]=i(t.folder??t.initialFolder??""),l=t.folder??o,[r,_]=i([]),[d,x]=i(!0),[v,m]=i(""),[B,h]=i(!1),[F,n]=i(!1),[f,N]=i(null),[S,V]=i(!1),[W,z]=i(null),[X,R]=i(null),[E,$]=i(null),[q,c]=i(null),[w,p]=i(null),[y,K]=i(new Map),{roles:pt}=dt(),ht=window.firebase.user.email||"",J=ct(pt,ht),Q=v.trim().length>0;function P(s){a(s),m(""),t.onFolderChange&&t.onFolderChange(s)}async function I(s){x(!0),N(null),K(new Map),await M(async()=>{let u=await ke(s);_(u)}),x(!1)}T(()=>{I(l)},[l]),T(()=>{if(!Q||f!==null)return;let s=!1;return(async()=>{let u=[];await M(async()=>{u=await qe(l)}),s||N(u)})(),()=>{s=!0}},[Q,f,l]);let be=t.mode==="manage"?t.initialAssetId:"";T(()=>{be&&M(async()=>{let s=await Je(be);s&&s.type==="file"&&(P(s.parent),p(s))})},[be]);let Y=Se(()=>{let s=v.trim().toLowerCase(),u=s?f||[]:r;return t.mode==="pick"&&(u=u.filter(A=>A.type==="folder"||Ve(A.file?.filename||A.name,t.accept))),s&&(u=u.filter(A=>A.name.toLowerCase().includes(s))),u},[r,f,v,t.mode,t.accept]);async function Ue(s){if(s.length===0||F)return;let u="asset-browser-upload";n(!0),b({id:u,message:`Uploading ${s.length} file(s)...`,loading:!0,autoClose:!1,disallowClose:!0});let A=[],xe=[];for(let le=0;le<s.length;le++){let ne=s[le];je({id:u,message:`Uploading ${ne.name} (${le+1} of ${s.length})...`,loading:!0,autoClose:!1,disallowClose:!0});try{let Be=await re(ne),At=await Ye({parent:l,file:Be});A.push(At)}catch(Be){console.error(`failed to upload ${ne.name}:`,Be),xe.push(ne.name)}}Ge(u),n(!1),xe.length>0?b({title:"Upload failed",message:`Failed to upload: ${xe.join(", ")}`,color:"red",autoClose:!1}):b({message:`Uploaded ${A.length} file(s).`,color:"green"}),await I(l),t.mode==="pick"&&A.length===1&&s.length===1&&t.onPickFile&&t.onPickFile(A[0])}function vt(){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=()=>{Ue(Array.from(s.files||[]))},s.click(),s.remove()}function wt(s){t.onPickFile&&t.onPickFile(s)}let Z=J,ae=t.mode==="manage"&&J,ee=Array.from(y.values()),Re=ee.filter(s=>s.type==="file"&&!s.file?.altDisabled&&(G(s.file?.filename||s.name)||H(s.file?.filename||s.name))),Ae=Y.length>0&&Y.every(s=>y.has(s.id));function $e(s){K(u=>{let A=new Map(u);return A.has(s.id)?A.delete(s.id):A.set(s.id,s),A})}function bt(){K(Ae?new Map:new Map(Y.map(s=>[s.id,s])))}return e("div",{className:fe("AssetBrowser",t.className,`AssetBrowser--${t.mode}`),children:[e("div",{className:"AssetBrowser__toolbar",children:[e(Te.Breadcrumbs,{folder:l,onNavigate:P}),e("div",{className:"AssetBrowser__toolbar__actions",children:[e(j,{className:"AssetBrowser__toolbar__filter",placeholder:"Search by name",size:"xs",icon:e(it,{size:14}),value:v,onChange:s=>m(s.currentTarget.value)}),Z&&t.mode==="manage"&&e(g,{variant:"default",size:"xs",leftIcon:e(lt,{size:16}),onClick:()=>V(!0),children:"New folder"}),Z&&e(g,{color:"dark",size:"xs",leftIcon:e(rt,{size:16}),loading:F,onClick:()=>vt(),children:"Upload"})]})]}),ae&&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(he,{size:14}),onClick:()=>R(ee),children:"Move"}),Re.length>0&&e(g,{variant:"default",size:"xs",onClick:()=>c(Re),children:"Disable alt text"}),e(g,{color:"red",size:"xs",leftIcon:e(O,{size:14}),onClick:()=>$(ee),children:"Delete"}),e(g,{variant:"subtle",color:"gray",size:"xs",onClick:()=>K(new Map),children:"Clear"})]})]}),e("div",{className:fe("AssetBrowser__listing",B&&"dragging"),onDragOver:s=>{Z&&(s.preventDefault(),h(!0))},onDragLeave:s=>{s.preventDefault(),h(!1)},onDrop:s=>{s.preventDefault(),h(!1),Z&&Ue(Array.from(s.dataTransfer?.files||[]))},children:d||Q&&f===null?e("div",{className:"AssetBrowser__loading",children:e(te,{color:"gray",size:"lg"})}):Y.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."}),Z&&e("div",{className:"AssetBrowser__empty__hint",children:'Drop files here or click "Upload" to add assets.'})]})}):e(ie,{className:"AssetBrowser__table",verticalSpacing:"xs",fontSize:"xs",highlightOnHover:!0,children:[e("thead",{children:e("tr",{children:[ae&&e("th",{className:"AssetBrowser__table__checkboxCol",children:e(L,{size:"xs","aria-label":"Select all",checked:Ae,indeterminate:!Ae&&y.size>0,onChange:()=>bt()})}),e("th",{children:"name"}),e("th",{className:"AssetBrowser__table__modifiedCol",children:"modified"}),e("th",{className:"AssetBrowser__table__actionsCol"})]})}),e("tbody",{children:Y.map(s=>s.type==="folder"?e("tr",{className:"AssetBrowser__row AssetBrowser__row--folder",onClick:()=>P(oe(s.parent,s.name)),children:[ae&&e("td",{className:"AssetBrowser__checkboxCell",onClick:u=>u.stopPropagation(),children:e(L,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>$e(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e("div",{className:"AssetBrowser__thumb",children:e(De,{size:24,stroke:"1.5"})}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:s.name}),e(ut,{asset:s,folder:l,searching:Q,onNavigate:P})]})]})}),e("td",{children:e(gt,{asset:s})}),e("td",{onClick:u=>u.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(Ne,{size:16})}),children:[e(k.Item,{icon:e(ze,{size:14}),onClick:()=>z(s),children:"Rename"}),e(k.Item,{icon:e(he,{size:14}),onClick:()=>R([s]),children:"Move"}),e(k.Item,{color:"red",icon:e(O,{size:14}),onClick:()=>$([s]),children:"Delete"})]})})})]},s.id):e("tr",{className:"AssetBrowser__row AssetBrowser__row--file",onClick:()=>{t.mode==="pick"?wt(s):p(s)},children:[ae&&e("td",{className:"AssetBrowser__checkboxCell",onClick:u=>u.stopPropagation(),children:e(L,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>$e(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e(mt,{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(ut,{asset:s,folder:l,searching:Q,onNavigate:P})]})]})}),e("td",{children:e(gt,{asset:s})}),e("td",{onClick:u=>u.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode!=="pick"&&e(xt,{asset:s,canManage:J,onDetails:()=>p(s),onRename:()=>z(s),onMove:()=>R([s]),onDelete:()=>$([s])})})})]},s.id))})]})}),e(Bt,{opened:S,parent:l,onClose:()=>V(!1),onCreated:s=>{V(!1),P(oe(l,s))}}),W&&e(yt,{asset:W,onClose:()=>z(null),onRenamed:()=>{z(null),I(l)}}),X&&X.length>0&&e(Ct,{assets:X,onClose:()=>R(null),onMoved:()=>{R(null),I(l)}}),E&&E.length>0&&e(Mt,{assets:E,onClose:()=>$(null),onDeleted:()=>{$(null),I(l)}}),q&&q.length>0&&e(Ft,{assets:q,onClose:()=>c(null),onDone:()=>{c(null),I(l)}}),w&&e(ft,{asset:w,canManage:J,onClose:()=>p(null),onChanged:()=>I(l),onDeleted:()=>{p(null),I(l)}})]})}Te.Breadcrumbs=t=>{let o=Xe(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(Fe,{className:"AssetBrowser__breadcrumbs__divider",size:14}),e("button",{className:fe("AssetBrowser__breadcrumbs__link",r===a.length-1&&"active"),disabled:r===a.length-1,onClick:()=>t.onNavigate(l.path),children:l.label})]},l.path))})};function xt(t){let o=t.asset;return e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(Ne,{size:16})}),children:[e(k.Item,{icon:e(nt,{size:14}),onClick:t.onDetails,children:"Details"}),e(k.Item,{icon:e(ue,{size:14}),onClick:()=>ve(o.file),children:"Copy URL"}),e(k.Item,{icon:e(ge,{size:14}),onClick:()=>we(o.file),children:"Download"}),t.canManage&&e(C,{children:[e(k.Item,{icon:e(ze,{size:14}),onClick:t.onRename,children:"Rename"}),e(k.Item,{icon:e(he,{size:14}),onClick:t.onMove,children:"Move"}),e(k.Item,{color:"red",icon:e(O,{size:14}),onClick:t.onDelete,children:"Delete"})]})]})}function ut(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 ",Ke(o.parent,t.folder)]})}function gt(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(_t,{email:a,size:20}),e("span",{children:l?He(l):"\u2014"})]})}function Bt(t){let[o,a]=i(""),[l,r]=i(!1);async function _(){r(!0),await M(async()=>{let d=await Qe(t.parent,o);a(""),t.onCreated(d.name)}),r(!1)}return e(U,{opened:t.opened,onClose:t.onClose,title:"New folder",size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),_()},children:[e(j,{"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 yt(t){let[o,a]=i(t.asset.name),[l,r]=i(!1);async function _(){r(!0),await M(async()=>{await Ze(t.asset,o),t.onRenamed()}),r(!1)}return e(U,{opened:!0,onClose:t.onClose,title:`Rename ${t.asset.type}`,size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),_()},children:[e(j,{"data-autofocus":!0,value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Rename"})]})})}function Ct(t){let o=t.assets,[a,l]=i(o[0]?.parent||""),[r,_]=i([]),[d,x]=i(!0),[v,m]=i(!1);T(()=>{x(!0),M(async()=>{let n=await ke(a);_(n.filter(f=>f.type==="folder"))}).then(()=>x(!1))},[a]);let B=o.filter(n=>n.type==="folder").map(n=>oe(n.parent,n.name));function h(n){return B.some(f=>n===f||n.startsWith(`${f}/`))}async function F(){m(!0);let n=[],f=0;for(let N of o)try{await et(N,a),f+=1}catch(S){console.error(`failed to move ${N.name}:`,S),n.push(N.name)}m(!1),n.length>0&&b({title:"Move failed",message:`Failed to move: ${n.join(", ")}`,color:"red",autoClose:!1}),f>0&&b({message:o.length===1?`Moved "${o[0].name}" to ${a||"Assets"}.`:`Moved ${f} item(s) to ${a||"Assets"}.`,color:"green"}),t.onMoved()}return e(U,{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(Te.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 f=oe(n.parent,n.name);return e("button",{className:"AssetBrowser__moveModal__folder",disabled:h(f),onClick:()=>l(f),children:[e(De,{size:16,stroke:"1.5"}),e("span",{children:n.name}),e(Fe,{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 kt=20;function Mt(t){let o=t.assets,[a,l]=i(!1),[r,_]=i(null),d=o.filter(m=>m.type==="file"),x=o.some(m=>m.type==="folder");T(()=>{d.length===0||d.length>kt||Promise.all(d.map(m=>_e(m.id))).then(m=>{let B=new Set(m.flat().map(h=>h.id));_(B.size)}).catch(()=>_(null))},[o.map(m=>m.id).join(",")]);async function v(){l(!0);let m=[],B=0;for(let h of o)try{await de(h),B+=1}catch(F){console.error(`failed to delete ${h.name}:`,F),m.push(h.name)}l(!1),m.length>0&&b({title:"Delete failed",message:`Failed to delete: ${m.join(", ")}. Note that folders must be empty before they can be deleted.`,color:"red",autoClose:!1}),B>0&&b({message:o.length===1?`Deleted "${o[0].name}".`:`Deleted ${B} item(s).`,color:"green"}),t.onDeleted()}return e(U,{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 Ft(t){let o=t.assets,[a,l]=i(!1);async function r(){l(!0);let _=[],d=0;for(let x of o)try{let v=x.file,m=await ce(x,!0);await me(m,{previousFile:v}),d+=1}catch(v){console.error(`failed to disable alt text for ${x.name}:`,v),_.push(x.name)}l(!1),_.length>0&&b({title:"Failed to disable alt text",message:`Failed to update: ${_.join(", ")}`,color:"red",autoClose:!1}),d>0&&b({message:`Disabled alt text for ${d} file(s).`,color:"green"}),t.onDone()}return e(U,{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{Te as a};
@@ -1 +1 @@
1
- import{e as z,j as I}from"./chunk-IKED2IGU.js";import{c as N,e as L}from"./chunk-4IXGYXA2.js";import{a as C}from"./chunk-NQB37NMX.js";import{a as w,c as y}from"./chunk-KPJ53X55.js";import{b as v}from"./chunk-5MV6XVGA.js";import{Ga as e,V as P,a as g,da as p,g as M,j as x,ua as S,za as f,zc as B}from"./chunk-4CUWZQXT.js";x();x();function O(o,t){return M(()=>{if(!t.trim())return o;let l=t.toLowerCase();return o.filter(c=>{let[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],s=v(r,n.preview?.title||"meta.title")||"";return c.id.toLowerCase().includes(l)||s.toLowerCase().includes(l)||u.toLowerCase().includes(l)})},[o,t])}var h="DocPickerModal";function ee(){let o=w(),t=y();return{open:l=>{o.openContextModal(h,{...t,innerProps:l,size:"700px",overflow:"inside"})},close:()=>{o.closeModal(h)}}}function k(o){let{innerProps:t}=o,l=Object.keys(window.__ROOT_CTX.collections);t.collections?.length&&(l=l.filter(i=>t.collections?.includes(i)));let c=[{value:"",label:"Select"}];l.forEach(i=>{c.push({value:i,label:i})});let[a,u]=C("DocPickerModal.lastSelectedCollection",""),r=()=>t.initialCollection?t.initialCollection:a&&l.includes(a)?a:l.length===1?l[0]:"",[n,D]=g(r()),s=i=>{D(i),u(i)};function m(i){t.multiSelect&&t.onChangeMulti?t.onChangeMulti(i.id,!0):t.onChange&&t.onChange(i.id)}function b(i){t.multiSelect&&t.onChangeMulti&&t.onChangeMulti(i.id,!1)}return e("div",{className:"DocPickerModal",children:[l.length===0&&e("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),l.length>0&&e(k.DocsList,{collection:n,onDocSelected:m,onDocUnselected:b,onCollectionChange:s,multiSelect:t.multiSelect,selectedDocIds:t.selectedDocIds,options:{enableSearch:t.enableSearch??!0,enableSort:t.enableSort??!0,enableCreate:t.enableCreate??!0,enableStatusBadges:t.enableStatusBadges??!0,showCollectionSelect:l.length>1,collectionSelectValue:n,collectionSelectOptions:c}})]})}k.DocsList=o=>{let[t,l]=g(""),[c,a]=C(`root::DocPickerModal:${o.collection}:sortBy`,"modifiedAt"),[u,r]=g(!1),[n,D,s]=z(o.collection||"",{orderBy:c}),m=O(s,t),b=[{value:"modifiedAt",label:"Last Modified"},{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"}],i=o.selectedDocIds||[],d=o.options||{};return e("div",{className:"DocPickerModal__DocsList",children:[e("div",{className:"DocPickerModal__DocsList__stickyHeader",children:[d.showCollectionSelect&&e("div",{className:"DocPickerModal__collection__select",children:[e("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),e(f,{data:d.collectionSelectOptions||[],value:d.collectionSelectValue,placeholder:"Select",onChange:_=>{o.onCollectionChange?.(_||"")},size:"xs",radius:0,searchable:!0,autoFocus:!0,dropdownComponent:"div"}),d.collectionSelectValue&&e(p,{variant:"outline",color:"dark",size:"xs",onClick:()=>r(!0),children:"New"})]}),d.enableSearch&&d.collectionSelectValue&&e("div",{className:"DocPickerModal__DocsList__controls",children:[e(S,{placeholder:"Search documents...",value:t,onChange:_=>l(_.target.value),icon:e(B,{size:16}),size:"xs",className:"DocPickerModal__DocsList__controls__search"}),d.enableSort&&e(f,{data:b,value:c,onChange:_=>a(_||"modifiedAt"),size:"xs",className:"DocPickerModal__DocsList__controls__sort"})]}),!n&&s.length>0&&e("div",{className:"DocPickerModal__DocsList__count",children:["Showing ",m.length," of ",s.length," documents"]})]}),e("div",{className:"DocPickerModal__DocsList__docsContainer",children:o.collection?n?e("div",{className:"DocPickerModal__DocsList__loading",children:e(P,{color:"gray",size:"xl"})}):m.length===0?e("div",{className:"DocPickerModal__DocsList__empty",children:s.length===0?"Collection is empty.":"No documents match your search."}):e("div",{className:"DocPickerModal__DocsList__docs",children:m.map(_=>e(k.DocCard,{doc:_,onDocSelected:o.onDocSelected,onDocUnselected:o.onDocUnselected,multiSelect:o.multiSelect,selected:i.includes(_.id),enableStatusBadges:d.enableStatusBadges},_.id))}):e("div",{className:"DocPickerModal__DocsList__empty",children:"Select a content type to view documents"})}),d.collectionSelectValue&&e(I,{collection:d.collectionSelectValue,opened:u,skipNavigation:!0,onClose:()=>{r(!1),D()}})]})};k.DocCard=o=>{let[t,l]=g(!!o.selected),c=o.doc,[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],D=`/cms/content/${a}/${u}`,s=v(r,n.preview?.title||"meta.title"),m=v(r,n.preview?.image||"meta.image")||n.preview?.defaultImage;return e("div",{className:"DocPickerModal__DocCard",children:[e("div",{className:"DocPickerModal__DocCard__image",onClick:()=>window.open(D,"_blank"),children:e(L,{file:m,width:120,height:90,withPlaceholder:!m?.src})}),e("div",{className:"DocPickerModal__DocCard__content",children:[e("div",{className:"DocPickerModal__DocCard__content__header",children:e("div",{className:"DocPickerModal__DocCard__content__header__docId",onClick:()=>window.open(D,"_blank"),children:c.id})}),e("div",{className:"DocPickerModal__DocCard__content__title",children:e("div",{className:"DocPickerModal__DocCard__content__link",onClick:()=>window.open(D,"_blank"),children:s||"[UNTITLED]"})}),o.enableStatusBadges&&e("div",{className:"DocPickerModal__DocCard__content__badges",children:e(N,{doc:c})})]}),e("div",{className:"DocPickerModal__DocCard__controls",children:e("div",{className:"DocPickerModal__DocCard__controls__buttons",children:o.multiSelect?t?e(p,{variant:"light",color:"blue",size:"xs",onClick:()=>{l(!1),o.onDocUnselected(o.doc)},children:"Unselect"}):e(p,{variant:"filled",color:"blue",size:"xs",onClick:()=>{l(!0),o.onDocSelected(o.doc)},children:"Select"}):e(p,{color:"blue",size:"xs",onClick:()=>o.onDocSelected(o.doc),children:"Select"})})})]})};k.id=h;export{ee as a,k as b};
1
+ import{e as z,j as I}from"./chunk-YXSXWFLZ.js";import{c as N,e as L}from"./chunk-PTPYMVFW.js";import{a as C}from"./chunk-FJLNXXE3.js";import{a as w,c as y}from"./chunk-HARRKJFZ.js";import{b as v}from"./chunk-5MV6XVGA.js";import{Cc as B,Ga as e,V as P,a as g,da as p,g as M,j as x,ua as S,za as f}from"./chunk-LROR6N3B.js";x();x();function O(o,t){return M(()=>{if(!t.trim())return o;let l=t.toLowerCase();return o.filter(c=>{let[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],s=v(r,n.preview?.title||"meta.title")||"";return c.id.toLowerCase().includes(l)||s.toLowerCase().includes(l)||u.toLowerCase().includes(l)})},[o,t])}var h="DocPickerModal";function ee(){let o=w(),t=y();return{open:l=>{o.openContextModal(h,{...t,innerProps:l,size:"700px",overflow:"inside"})},close:()=>{o.closeModal(h)}}}function k(o){let{innerProps:t}=o,l=Object.keys(window.__ROOT_CTX.collections);t.collections?.length&&(l=l.filter(i=>t.collections?.includes(i)));let c=[{value:"",label:"Select"}];l.forEach(i=>{c.push({value:i,label:i})});let[a,u]=C("DocPickerModal.lastSelectedCollection",""),r=()=>t.initialCollection?t.initialCollection:a&&l.includes(a)?a:l.length===1?l[0]:"",[n,D]=g(r()),s=i=>{D(i),u(i)};function m(i){t.multiSelect&&t.onChangeMulti?t.onChangeMulti(i.id,!0):t.onChange&&t.onChange(i.id)}function b(i){t.multiSelect&&t.onChangeMulti&&t.onChangeMulti(i.id,!1)}return e("div",{className:"DocPickerModal",children:[l.length===0&&e("div",{className:"DocPickerModal__noCollections",children:"No collections matching schema field definition."}),l.length>0&&e(k.DocsList,{collection:n,onDocSelected:m,onDocUnselected:b,onCollectionChange:s,multiSelect:t.multiSelect,selectedDocIds:t.selectedDocIds,options:{enableSearch:t.enableSearch??!0,enableSort:t.enableSort??!0,enableCreate:t.enableCreate??!0,enableStatusBadges:t.enableStatusBadges??!0,showCollectionSelect:l.length>1,collectionSelectValue:n,collectionSelectOptions:c}})]})}k.DocsList=o=>{let[t,l]=g(""),[c,a]=C(`root::DocPickerModal:${o.collection}:sortBy`,"modifiedAt"),[u,r]=g(!1),[n,D,s]=z(o.collection||"",{orderBy:c}),m=O(s,t),b=[{value:"modifiedAt",label:"Last Modified"},{value:"slug",label:"A-Z"},{value:"slugDesc",label:"Z-A"},{value:"newest",label:"Newest"},{value:"oldest",label:"Oldest"}],i=o.selectedDocIds||[],d=o.options||{};return e("div",{className:"DocPickerModal__DocsList",children:[e("div",{className:"DocPickerModal__DocsList__stickyHeader",children:[d.showCollectionSelect&&e("div",{className:"DocPickerModal__collection__select",children:[e("div",{className:"DocPickerModal__collection__select__label",children:"Content Type:"}),e(f,{data:d.collectionSelectOptions||[],value:d.collectionSelectValue,placeholder:"Select",onChange:_=>{o.onCollectionChange?.(_||"")},size:"xs",radius:0,searchable:!0,autoFocus:!0,dropdownComponent:"div"}),d.collectionSelectValue&&e(p,{variant:"outline",color:"dark",size:"xs",onClick:()=>r(!0),children:"New"})]}),d.enableSearch&&d.collectionSelectValue&&e("div",{className:"DocPickerModal__DocsList__controls",children:[e(S,{placeholder:"Search documents...",value:t,onChange:_=>l(_.target.value),icon:e(B,{size:16}),size:"xs",className:"DocPickerModal__DocsList__controls__search"}),d.enableSort&&e(f,{data:b,value:c,onChange:_=>a(_||"modifiedAt"),size:"xs",className:"DocPickerModal__DocsList__controls__sort"})]}),!n&&s.length>0&&e("div",{className:"DocPickerModal__DocsList__count",children:["Showing ",m.length," of ",s.length," documents"]})]}),e("div",{className:"DocPickerModal__DocsList__docsContainer",children:o.collection?n?e("div",{className:"DocPickerModal__DocsList__loading",children:e(P,{color:"gray",size:"xl"})}):m.length===0?e("div",{className:"DocPickerModal__DocsList__empty",children:s.length===0?"Collection is empty.":"No documents match your search."}):e("div",{className:"DocPickerModal__DocsList__docs",children:m.map(_=>e(k.DocCard,{doc:_,onDocSelected:o.onDocSelected,onDocUnselected:o.onDocUnselected,multiSelect:o.multiSelect,selected:i.includes(_.id),enableStatusBadges:d.enableStatusBadges},_.id))}):e("div",{className:"DocPickerModal__DocsList__empty",children:"Select a content type to view documents"})}),d.collectionSelectValue&&e(I,{collection:d.collectionSelectValue,opened:u,skipNavigation:!0,onClose:()=>{r(!1),D()}})]})};k.DocCard=o=>{let[t,l]=g(!!o.selected),c=o.doc,[a,u]=c.id.split("/"),r=c.fields||{},n=window.__ROOT_CTX.collections[a],D=`/cms/content/${a}/${u}`,s=v(r,n.preview?.title||"meta.title"),m=v(r,n.preview?.image||"meta.image")||n.preview?.defaultImage;return e("div",{className:"DocPickerModal__DocCard",children:[e("div",{className:"DocPickerModal__DocCard__image",onClick:()=>window.open(D,"_blank"),children:e(L,{file:m,width:120,height:90,withPlaceholder:!m?.src})}),e("div",{className:"DocPickerModal__DocCard__content",children:[e("div",{className:"DocPickerModal__DocCard__content__header",children:e("div",{className:"DocPickerModal__DocCard__content__header__docId",onClick:()=>window.open(D,"_blank"),children:c.id})}),e("div",{className:"DocPickerModal__DocCard__content__title",children:e("div",{className:"DocPickerModal__DocCard__content__link",onClick:()=>window.open(D,"_blank"),children:s||"[UNTITLED]"})}),o.enableStatusBadges&&e("div",{className:"DocPickerModal__DocCard__content__badges",children:e(N,{doc:c})})]}),e("div",{className:"DocPickerModal__DocCard__controls",children:e("div",{className:"DocPickerModal__DocCard__controls__buttons",children:o.multiSelect?t?e(p,{variant:"light",color:"blue",size:"xs",onClick:()=>{l(!1),o.onDocUnselected(o.doc)},children:"Unselect"}):e(p,{variant:"filled",color:"blue",size:"xs",onClick:()=>{l(!0),o.onDocSelected(o.doc)},children:"Select"}):e(p,{color:"blue",size:"xs",onClick:()=>o.onDocSelected(o.doc),children:"Select"})})})]})};k.id=h;export{ee as a,k as b};
@@ -0,0 +1,3 @@
1
+ import{a as y,f as L}from"./chunk-KRNQ6L35.js";import{b as R,c as l,g as d,h as C,n as m,o as x,q as _,w as T,x as p}from"./chunk-VD6G5NV4.js";function f(n,o){let t=n.translationLanguages||{},a=String(o).toLowerCase();for(let[e,s]of Object.entries(t))if(e.toLowerCase()===a)return s;return o}function b(n,o){let t=[];for(let a of o){let e=f(n,a);t.includes(e)||t.push(e)}return t}function w(n,o){let t=n.locales||["en"],a=String(o).toLowerCase(),e=[];for(let s of t)(String(s).toLowerCase()===a||f(n,s).toLowerCase()===a)&&e.push(s);return e}function O(n,o,t){for(let a of w(n,t)){let e=o[a];if(typeof e=="string"&&e)return e}return""}function A(){let n=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db;return R(o,"Projects",n,"Translations")}async function B(n){let o=A(),t=n?.tags?d(o,C("tags","array-contains-any",n.tags)):d(o),a=await x(t),e={};return a.forEach(s=>{let r=s.id;e[r]=s.data()}),e}async function D(n){let o=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db,a=l(t,"Projects",o,"Translations",n);return(await m(a)).data()}async function G(n,o){let t=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,e=l(a,"Projects",t,"Translations",n),s={};for(let r in o){if(r==="tags"){s.tags=o.tags;continue}for(let i of S(r))s[i]=o[r]}console.log("updating translations: ",s),await _(e,s),L("translations.save",{metadata:{hash:n},throttle:5*y.minute,throttleId:n})}async function N(n,o){let t=o?.mode??"replace",a=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=500;for(let r=0;r<n.length;r+=s){let i=p(e);n.slice(r,r+s).forEach(({hash:g,tags:u})=>{let c=l(e,"Projects",a,"Translations",g);t==="union"?i.update(c,{tags:T(...u)}):i.update(c,{tags:u})}),await i.commit()}}async function P(n){return k(I(n))}async function k(n){let t=new TextEncoder().encode(n),a=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(a)).map(r=>r.toString(16).padStart(2,"0")).join("")}function I(n){return String(n).trim().split(`
2
+ `).map(t=>v(t)).join(`
3
+ `)}function v(n){return String(n).trimEnd().replace(/&nbsp;$/,"")}var j=new Map;function M(n){let o=j.get(n);if(o)return o;let t=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),a=new RegExp(`^${t}$`,"i");return j.set(n,a),a}function W(n){return(window.__ROOT_CTX.excludeLocalesFromTranslations||[]).some(t=>M(t).test(n))}function J(n){let t=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];for(let a of t)if(String(a).toLowerCase()===n.toLowerCase())return a;return null}function K(n){let o=window.__ROOT_CTX.rootConfig.i18n||{};return f(o,n)}function Q(n){let o=window.__ROOT_CTX.rootConfig.i18n||{};return b(o,n)}function S(n){let o=window.__ROOT_CTX.rootConfig.i18n||{};return w(o,n)}function V(n,o){let t=window.__ROOT_CTX.rootConfig.i18n||{};return O(t,n,o)}async function Y(n,o){let t=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,e=500,s=await Promise.all(n.map(async r=>({hash:await P(r.source),locales:r.locales,source:r.source})));for(let r=0;r<s.length;r+=e){let i=p(a),h=s.slice(r,r+e);for(let g of h){let u=l(a,"Projects",t,"Translations",g.hash),c={source:g.source};for(let[E,X]of Object.entries(g.locales))for(let F of S(E))c[F]=I(X);o?.tags?.length&&(c.tags=T(...o.tags)),i.set(u,c,{merge:!0})}await i.commit()}L("translations.batch_save",{metadata:{count:n.length}})}export{A as a,B as b,D as c,G as d,N as e,P as f,I as g,W as h,J as i,K as j,Q as k,S as l,V as m,Y as n};
@@ -0,0 +1 @@
1
+ import{b as le}from"./chunk-JTIQBW33.js";import{a as oe}from"./chunk-2S5HMST6.js";import{a as ee,b as R,c as T}from"./chunk-JDW4UORS.js";import{a as ie}from"./chunk-YDO2EDVY.js";import{a as M}from"./chunk-5MV6XVGA.js";import{P as re,c as ne}from"./chunk-AGFPVTBA.js";import{b as te}from"./chunk-J5E457OI.js";import{a as $}from"./chunk-QHJOTXYB.js";import{a as j}from"./chunk-BW2MKGNP.js";import{b as K,f as U,g as _,i as y,o as Y}from"./chunk-VD6G5NV4.js";import{d as Z,e as se}from"./chunk-BUNR5EU3.js";import{A as G,Ga as f,a as p,c as w,da as P,e as v,g as B,h as I,i as W,j as O,ra as Q,ua as q,za as J}from"./chunk-LROR6N3B.js";import{j as X,k as Se}from"./chunk-KUCVLANF.js";function z(e){let t=window.__ROOT_CTX.collections[e.collectionId];if(!t)throw new Error(`collection not found: ${e.collectionId}`);if(!t.url)return"";let n=t.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",r=Ee(e);return`${n}${r}`}function Ee(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,s=o[t];if(!s)throw new Error(`collection not found: ${t}`);if(!s.url)return"";let l=window.__ROOT_CTX.rootConfig,g=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let d="",a=s?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),d=c}else d=a;return ce(u,{base:g,path:d,locale:r||"",slug:n})}function ye(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,s=o[t];if(!s)throw new Error(`collection not found: ${t}`);let l=window.__ROOT_CTX.rootConfig,g=l.base||"/",u="/[base]/[path]";r&&(u=l.i18n.urlFormat||"/[locale]/[base]/[path]");let d="",a=s?.previewUrl||s?.url;if(a)if(n){let c=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),d=c}else d=a;return ce(u,{base:g,path:d,locale:r||"",slug:n})}function ce(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,r,s)=>o[s]??n);return Ce(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function Ce(e,o){return e=e.replace(/\/+/g,"/"),o?.trailingSlash===!1&&e!=="/"&&e.endsWith("/")&&(e=e.replace(/\/*$/g,"")),(e.endsWith("/index")||e.endsWith("/index/"))&&(e=e.slice(0,-6)),e.startsWith("/")||(e=`/${e}`),o?.trailingSlash&&!e.endsWith("/")&&(e=`${e}/`),e}O();function Re(e,o){let[t,n]=p([]),[r,s]=p(!0),g=le().db,u=window.__ROOT_CTX.rootConfig.projectId||"default",d=o.includeArchived??!1,a=async()=>{s(!0);let c=K(g,"Projects",u,"Collections",e,"Drafts"),i=c,m=o.orderBy;if(m==="modifiedAt")i=_(c,y("sys.modifiedAt","desc"));else if(m==="newest")i=_(c,y("sys.createdAt","desc"));else if(m==="oldest")i=_(c,y("sys.createdAt"));else if(m==="slug")i=_(c,y(U()));else if(m==="slugDesc")i=_(c,y(U(),"desc"));else{let S=window.__ROOT_CTX.collections[e]?.sortOptions?.find(C=>C.id===m);S&&(i=S.direction==="desc"?_(c,y(S.field,"desc")):_(c,y(S.field)))}await te(async()=>{let h=await Y(i),S=[];h.docs.forEach(C=>{let k=C.data(),E=C.id,b=`${e}/${E}`,x={...k,id:b,slug:E};ne(b,x),!(!d&&x?.sys?.archivedAt)&&S.push(x)}),n(S)}),s(!1)};return w(()=>{s(!0),a()},[e,o.orderBy,d]),[r,a,t]}Se();O();var D={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function ae(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var ve="/cms/api/sse.connect",L=ae("EnableVerboseLogging"),ue=window.location.hostname==="localhost",F=class{constructor(){this.map=new Map}on(o,t){return this.map.has(o)||this.map.set(o,new Set),this.map.get(o).add(t),()=>{this.map.get(o)?.delete(t)}}emit(o,t,n){this.map.get(o)?.forEach(r=>r(t,n)),this.map.get("*")?.forEach(r=>r({type:o,data:t},n))}},fe=X(null);function Fe(e){let t=v(new F).current,n=v(null),r=v(!1),s=v({attempt:0,timer:0}),l=v(""),g=()=>{n.current&&(n.current.close(),n.current=null)},u=I(()=>{L&&console.log("[sse] connecting..."),g();let a=new EventSource(ve);n.current=a,a.addEventListener(D.CONNECTED,i=>{if(L&&console.log("[sse] connected"),r.current=!1,s.current.attempt=0,ue){let h=de(i.data)?.serverVersion||"";l.current?l.current!==h&&(console.log(`server version changed: ${l.current} -> ${h}`),console.log("reloading..."),window.location.reload()):l.current=h}});let c=i=>{if(!i||!i.type)return;let m=de(i.data);L&&console.log("[sse] event:",i.type,m),t.emit(i.type,m,i)};Object.values(D).forEach(i=>{a.addEventListener(i,c)}),a.addEventListener("error",()=>{L&&console.log("[sse] disconnected"),a.readyState===EventSource.CLOSED&&!r.current&&(r.current=!0,(()=>{let m=++s.current.attempt,h=Math.min(3e4,Math.pow(2,m)*500),S=Math.random()*.3*h,C=h+S;window.clearTimeout(s.current.timer),s.current.timer=window.setTimeout(()=>{r.current=!1,u()},C)})())})},[t]);w(()=>{if(!ue)return;u();let a=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&u()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a),window.clearTimeout(s.current.timer),g()}},[u]);let d=B(()=>({emitter:t}),[t]);return f(fe.Provider,{value:d,children:e.children})}function de(e){try{return JSON.parse(e)}catch{return e}}function ge(e,o){let t=W(fe);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=v(o);w(()=>{n.current=o},[o]),w(()=>t.emitter.on(e,(r,s)=>n.current(r,s)),[t,e])}O();O();function me(e){let[o,t]=p(!0),[n,r]=p(null),s=I(async()=>{try{let l=await ie(e);r(l)}catch(l){console.error(l),$({title:`Failed to load collection: ${e}`,message:String(l),color:"red",autoClose:!1})}t(!1)},[e]);return w(()=>{s()},[e]),ge(D.SCHEMA_CHANGED,async l=>{await s();let g=l.file?`Applied updates from changes to ${l.file}.`:"Applied updates from changes to a .schema.ts file.";$({title:"Updated schema!",message:g})}),{loading:o,schema:n}}function H(e){let o={_array:[]};return e.forEach(t=>{let n=we();o._array.push(n),o[n]=t}),o}function we(){let e=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=o.length;for(let n=0;n<6;n++)e.push(o.charAt(Math.floor(Math.random()*t)));return e.join("")}function V(e){let o={};return e.fields.forEach(t=>{t.id&&(t.type==="array"&&t.default&&Array.isArray(t.default)?o[t.id]=H(t.default):t.default?o[t.id]=t.default:t.type==="object"&&(o[t.id]=V(t)))}),o}function A(e,o,t){let n={...o};return e.fields.forEach(r=>{if(!r.id)return;let s=n[r.id];if(s!=null){if(r.type==="array"&&Array.isArray(s)){let l=s.map(g=>_e(r.of,g,t));n[r.id]=H(l)}else if(r.type==="object"&&M(s))n[r.id]=A(r,s,t);else if(r.type==="oneof"&&M(s)&&typeof s._type=="string"&&t){let l=t[s._type];l&&(n[r.id]=A(l,s,t))}}}),n}function _e(e,o,t){if(!M(o))return o;if(e.type==="object")return A(e,o,t);if(e.type==="oneof"&&typeof o._type=="string"&&t){let n=t[o._type];if(n)return A(n,o,t)}return o}O();function pe(e){let[o,t]=p(e.collectionId||""),n=v(null),[r,s]=p(e.initialSlug||""),l=window.__ROOT_CTX.collections[o],g=[];e.collectionId&&e.collectionDisabled?g.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(i=>{g.push({value:i,label:i})});let u="",d="";if(l?.url){if(r){let i=T(r),m=l?.slugRegex;ee(i,m)?u=z({collectionId:o,slug:i}):d=R(i,m)}else u=z({collectionId:o,slug:"[slug]"});u.endsWith("/index")&&(u=u.replace(/\/index$/,"/"))}function a(i){t(i),e.onChange&&e.onChange({collectionId:i,slug:r})}function c(i){s(i),e.onChange&&e.onChange({collectionId:o,slug:i})}return f("div",{className:se(e.className,"SlugInput"),children:[f("div",{className:"SlugInput__inputs",children:[f(J,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:g,onChange:i=>a(i),value:o,disabled:!!e.collectionDisabled}),f("div",{className:"SlugInput__divider",children:"/"}),f(q,{className:"SlugInput__slug",name:"slug",ref:n,value:r,onChange:i=>{c(i.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),u&&f(j,{className:"SlugInput__urlHelp",size:"body-sm",children:u}),d&&f(j,{className:"SlugInput__slugError",size:"body-sm",children:d})]})}function bt(e){let{route:o}=Z(),t=G(),n=e.collection,r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);let[s]=p(()=>r.autoSlug?oe(r.autoSlug):""),[l,g]=p(s),[u,d]=p(!1),[a,c]=p(()=>S(s)),[i,m]=p(""),h=me(n);function S(E){let b=T(E);return b?R(b,r.slugRegex):""}function C(){e.onClose&&e.onClose()}async function k(E){if(E.preventDefault(),d(!0),c(""),S(l)){d(!1);return}let x=T(l),he=`${n}/${x}`;try{let N={};!h.loading&&h.schema&&(N=await V(h.schema)),await re(he,{fields:N})}catch(N){m(String(N)),d(!1);return}d(!1),e.skipNavigation?C():o(`/cms/content/${e.collection}/${x}`)}return f(Q,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>C(),title:"New",size:"500px",overlayColor:t.colorScheme==="dark"?t.colors.dark[9]:t.colors.gray[2],children:[f("div",{className:"NewDocModal__body",children:"Enter a slug for the new doc. The slug is the ID of the page and is what's used in the URL. Use only lowercase letters, numbers, and dashes."}),f("form",{onSubmit:E=>k(E),children:[f(pe,{className:"NewDocModal__slug",collectionId:n,initialSlug:s,onChange:E=>{g(E.slug),c(S(E.slug)),m("")}}),i&&f("div",{className:"NewDocModal__slugError",children:i}),f("div",{className:"NewDocModal__buttons",children:[f(P,{variant:"outline",onClick:()=>C(),type:"button",size:"xs",color:"dark",children:"Cancel"}),f(P,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:h.loading||u,disabled:!!a||!!i,children:"Submit"})]})]})]})}export{z as a,Ee as b,ye as c,pe as d,Re as e,Fe as f,me as g,V as h,A as i,bt as j};
@@ -0,0 +1 @@
1
+ import{b as N,f as R,g as U,i as H,j as O,k as P,m as j,o as M}from"./chunk-VD6G5NV4.js";import{a as u,c as C,e as G,h as A,j as F}from"./chunk-LROR6N3B.js";F();var X=200,Y=25,J=2;function ot(t,n={}){let[s,r]=u([]),[g,e]=u(!1),[o,h]=u(null),[y,a]=u(null),i=G(null),x=n.limit??Y,L=n.minQueryLength??J;return C(()=>{let m=t.trim();if(m.length<L){i.current?.abort(),i.current=null,r([]),e(!1),h(null);return}e(!0),h(null);let S=window.setTimeout(async()=>{i.current?.abort();let l=new AbortController;i.current=l;try{let c=await fetch("/cms/api/search.query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:m,limit:x}),signal:l.signal});if(!c.ok)throw new Error(`search.query returned ${c.status}`);let d=await c.json();if(!d?.success)throw new Error(d?.error||"search failed");if(l.signal.aborted)return;r(Array.isArray(d.hits)?d.hits:[]),a(d.meta||null),e(!1)}catch(c){if(l.signal.aborted)return;console.error("global search failed:",c),h(String(c?.message||c)),r([]),e(!1)}},X);return()=>{window.clearTimeout(S)}},[t,x,L]),{hits:s,loading:g,error:o,status:y}}function st(){let[t,n]=u({status:{lastRun:null,docCount:0,fieldCount:0,shardCount:0},running:!1}),[s,r]=u(!0),g=A(async()=>{try{let e=await fetch("/cms/api/search.status",{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)return;let o=await e.json();if(!o?.success)return;n({status:o.status,running:!!o.running})}catch(e){console.error("search.status failed:",e)}finally{r(!1)}},[]);return C(()=>{g()},[g]),{...t,loading:s,refresh:g}}var V=200,W=5,z=2;function at(t,n={}){let[s,r]=u([]),[g,e]=u(!1),o=G(null),h=n.limit??10,y=n.minQueryLength??z;return C(()=>{let a=t.trim(),i=a.indexOf("/");if((i>=0?a.slice(i+1):a).length<y){o.current&&(o.current.aborted=!0),o.current=null,r([]),e(!1);return}e(!0);let L=window.setTimeout(async()=>{o.current&&(o.current.aborted=!0);let m={aborted:!1};o.current=m;let S=null,l=a;i>=0&&(S=a.slice(0,i),l=a.slice(i+1));let c=window.__ROOT_CTX?.rootConfig?.projectId,d=window.firebase?.db;if(!c||!d){r([]),e(!1);return}let v=Object.keys(window.__ROOT_CTX.collections||{}),$=S?v.filter(p=>p.toLowerCase()===S.toLowerCase()):v,q=l,B=`${l}\uF8FF`;try{let p=$.map(async f=>{let w=N(d,"Projects",c,"Collections",f,"Drafts"),E=U(w,H(R()),P(q),j(B),O(W));try{let b=await M(E),_=[];return b.forEach(D=>{_.push({collection:f,slug:D.id,docId:`${f}/${D.id}`})}),_}catch(b){return console.error(`docSlugSearch failed for ${f}:`,b),[]}}),K=(await Promise.all(p)).flat();if(m.aborted)return;let Q=K.sort((f,w)=>{let E=f.slug===l||f.docId===a?0:1,b=w.slug===l||w.docId===a?0:1;return E!==b?E-b:f.docId.localeCompare(w.docId)});r(Q.slice(0,h)),e(!1)}catch(p){if(m.aborted)return;console.error("docSlugSearch failed:",p),r([]),e(!1)}},V);return()=>{window.clearTimeout(L)}},[t,h,y]),{hits:s,loading:g}}var T=new Set,k=!1;function I(){return T.values().next().value}function Z(t){I()&&(t.preventDefault(),t.returnValue="")}function tt(t){let n=I();if(!n||t.defaultPrevented||t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||t.button!==0)return;let s=t.composedPath().find(r=>r instanceof HTMLAnchorElement&&!!r.href);!s||(s.getAttribute("href")||"").startsWith("#")||s.download||s.origin!==window.location.origin||!/^(_?self)?$/i.test(s.target)||window.confirm(n.message)||(t.preventDefault(),t.stopImmediatePropagation())}function et(t){let n=I();n&&(window.confirm(n.message)||(t.stopImmediatePropagation(),window.history.pushState(null,"",n.url)))}function lt(){k||(k=!0,window.addEventListener("beforeunload",Z),window.addEventListener("click",tt,{capture:!0}),window.addEventListener("popstate",et))}function ct(t){return T.add(t),()=>T.delete(t)}export{ot as a,st as b,at as c,lt as d,ct as e};
@@ -0,0 +1 @@
1
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p}from"./chunk-7SK47HHZ.js";import"./chunk-DTMZLUNY.js";import"./chunk-PVAE643M.js";export{a as GCI_SUPPORTED_EXTS,f as GCI_URL_PREFIX,b as IMAGE_EXTS,c as OPT_IN_IMAGE_EXTS,d as PREVIEW_IMAGE_EXTS,e as VIDEO_EXTS,o as buildDownloadURL,i as checkFileExists,h as deleteFileFromGCS,j as getFileExt,p as shouldImageUseDarkBg,n as testFileMatchesAccept,l as testIsGoogleCloudImageFile,k as testIsImageFile,m as testIsVideoFile,g as uploadFileToGCS};