@blinkk/root-cms 3.0.6 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) 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-7L5OI5ES.js → chunk-GXV4UQ6Z.js} +8 -4
  11. package/dist/chunk-J72JK4KR.js +8 -0
  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.js +4 -2
  16. package/dist/functions.js +4 -3
  17. package/dist/plugin.js +5 -4
  18. package/dist/shared/embed-protocol.d.ts +72 -0
  19. package/dist/ui/AIPage-EL6DQYII.js +1 -0
  20. package/dist/ui/AssetsPage-5S6PNMF6.js +1 -0
  21. package/dist/ui/CollectionPage-CU3VDEXA.js +1 -0
  22. package/dist/ui/ComparePage-FTZLYO2O.js +1 -0
  23. package/dist/ui/DataPage-XIXFKXDN.js +1 -0
  24. package/dist/ui/DataSourcePage-ORIEQH3Y.js +1 -0
  25. package/dist/ui/DocTranslationsPage-4OVBIPSG.js +1 -0
  26. package/dist/ui/DocumentPage-3JPFJF3E.js +1 -0
  27. package/dist/ui/EditDataSourcePage-HIGZZQJC.js +1 -0
  28. package/dist/ui/EditReleasePage-KUHBU2HQ.js +1 -0
  29. package/dist/ui/EmbeddedAIPage-CJWZE5FC.js +1 -0
  30. package/dist/ui/EmbeddedDocumentPage-6XQHYIAO.js +1 -0
  31. package/dist/ui/{ImageEditorDialog-QEULJAT2.js → ImageEditorDialog-GGS4VFEA.js} +2 -2
  32. package/dist/ui/LogsPage-4DVGYXZY.js +1 -0
  33. package/dist/ui/NewDataSourcePage-7TUUE6ZL.js +1 -0
  34. package/dist/ui/NewReleasePage-6UT36HDW.js +1 -0
  35. package/dist/ui/NotFoundPage-AW6UC6II.js +1 -0
  36. package/dist/ui/ProjectPage-US5FJGFK.js +1 -0
  37. package/dist/ui/ReleasePage-W2R3DIFX.js +1 -0
  38. package/dist/ui/ReleasesPage-HBBUGE7D.js +1 -0
  39. package/dist/ui/SettingsPage-7JQQILUV.js +1 -0
  40. package/dist/ui/SidebarToolsPage-MIYXKHF2.js +1 -0
  41. package/dist/ui/TaskPage-JYUQEGRB.js +1 -0
  42. package/dist/ui/TasksPage-4VFQF243.js +1 -0
  43. package/dist/ui/TranslationsArbPage-AJLM5VSD.js +2 -0
  44. package/dist/ui/TranslationsEditPage-RTTGTIGI.js +1 -0
  45. package/dist/ui/{TranslationsPage-OBN6CQZZ.js → TranslationsPage-HPYAJQ4Q.js} +2 -2
  46. package/dist/ui/{chunk-WKOX3VFN.js → chunk-2KSMCQ6H.js} +2 -2
  47. package/dist/ui/{chunk-V7RAXP2W.js → chunk-3E6CASIN.js} +1 -1
  48. package/dist/ui/{chunk-N4DFAIC5.js → chunk-3T4ZWQR4.js} +1 -1
  49. package/dist/ui/chunk-4ISFTE2G.js +5 -0
  50. package/dist/ui/chunk-5AVRMJVW.js +1 -0
  51. package/dist/ui/chunk-764W6634.js +1 -0
  52. package/dist/ui/chunk-76ZGLKLT.js +1 -0
  53. package/dist/ui/{chunk-SKEP5WYH.js → chunk-7SK47HHZ.js} +3 -3
  54. package/dist/ui/chunk-AZCGXQTL.js +1 -0
  55. package/dist/ui/{chunk-KYKFNAX4.js → chunk-B6M55OFE.js} +1 -1
  56. package/dist/ui/{chunk-2225WAJ2.js → chunk-CAY5NM4Z.js} +1 -1
  57. package/dist/ui/{chunk-4KE2SZKH.js → chunk-D3UIZHRK.js} +1 -1
  58. package/dist/ui/{chunk-NMBXHKIJ.js → chunk-E76ECIOX.js} +1 -1
  59. package/dist/ui/chunk-FBSBL476.js +1 -0
  60. package/dist/ui/chunk-FFHV5S6A.js +1 -0
  61. package/dist/ui/{chunk-NQB37NMX.js → chunk-FJLNXXE3.js} +1 -1
  62. package/dist/ui/chunk-FSVNOZ6F.js +1 -0
  63. package/dist/ui/{chunk-3IDOZ4MG.js → chunk-GDXNSFLE.js} +1 -1
  64. package/dist/ui/{chunk-EMYXSVTD.js → chunk-GQ5IRK43.js} +1 -1
  65. package/dist/ui/{chunk-UHWNLNP4.js → chunk-GU24U5RM.js} +1 -1
  66. package/dist/ui/{chunk-KPJ53X55.js → chunk-HARRKJFZ.js} +1 -1
  67. package/dist/ui/{chunk-6E7PGMZX.js → chunk-HO3W4RVG.js} +1 -1
  68. package/dist/ui/{chunk-CVGYBXVH.js → chunk-J5E457OI.js} +1 -1
  69. package/dist/ui/{chunk-W3HIZQ4Z.js → chunk-JS6TK4OP.js} +1 -1
  70. package/dist/ui/{chunk-BEDUTYQP.js → chunk-JTIQBW33.js} +1 -1
  71. package/dist/ui/{chunk-ORXEMIQC.js → chunk-KRNQ6L35.js} +1 -1
  72. package/dist/ui/chunk-LROR6N3B.js +7 -0
  73. package/dist/ui/{chunk-4CUWZQXT.js.LEGAL.txt → chunk-LROR6N3B.js.LEGAL.txt} +6 -1
  74. package/dist/ui/{chunk-AOCBDKLV.js → chunk-M3T56ZRP.js} +1 -1
  75. package/dist/ui/chunk-MXGHX55S.js +141 -0
  76. package/dist/ui/{chunk-HYARD7BK.js → chunk-MZTOPPWQ.js} +1 -1
  77. package/dist/ui/{chunk-RQKL4KXY.js → chunk-N3JSLTMV.js} +1 -1
  78. package/dist/ui/{chunk-D37DCENS.js → chunk-NSOTG64N.js} +1 -1
  79. package/dist/ui/{chunk-N5Y5OWTV.js → chunk-O5P3CPJ4.js} +1 -1
  80. package/dist/ui/chunk-OWQL5DVE.js +1 -0
  81. package/dist/ui/{chunk-SEUH7LN2.js → chunk-OXVYTSIZ.js} +1 -1
  82. package/dist/ui/chunk-P2Z66DHV.js +1 -0
  83. package/dist/ui/{chunk-TZEZEMRQ.js → chunk-QEE7XS6O.js} +1 -1
  84. package/dist/ui/{chunk-AXETBZ6T.js → chunk-QHJOTXYB.js} +1 -1
  85. package/dist/ui/{chunk-4IXGYXA2.js → chunk-R6B3W5AJ.js} +1 -1
  86. package/dist/ui/{chunk-T47V6AGW.js → chunk-RAXWL656.js} +1 -1
  87. package/dist/ui/chunk-SRX7EWL4.js +1 -0
  88. package/dist/ui/{chunk-OVRTVMO5.js → chunk-TDUBSLEC.js} +1 -1
  89. package/dist/ui/chunk-TFB3VGWP.js +1 -0
  90. package/dist/ui/{chunk-6MOPIV5T.js → chunk-U7PWJV6F.js} +1 -1
  91. package/dist/ui/{chunk-GDSSFO5R.js → chunk-UUVAD4U4.js} +1 -1
  92. package/dist/ui/chunk-V4CTOC6E.js +1 -0
  93. package/dist/ui/{chunk-EGEB6N4J.js → chunk-VD6G5NV4.js} +11 -11
  94. package/dist/ui/chunk-W5DOO6ID.js +1 -0
  95. package/dist/ui/{chunk-3XYCOR6Z.js → chunk-WFQU7V3W.js} +1 -1
  96. package/dist/ui/{chunk-XYBHH5L4.js → chunk-WKF7CSWS.js} +1 -1
  97. package/dist/ui/{chunk-DXKEDMEI.js → chunk-WXT7LTQM.js} +1 -1
  98. package/dist/ui/{chunk-6GPTGBA7.js → chunk-XT5FNJCX.js} +1 -1
  99. package/dist/ui/chunk-YLSRRNSE.js +1 -0
  100. package/dist/ui/{chunk-UFQSZ6J2.js → chunk-ZN2Y5OUF.js} +1 -1
  101. package/dist/ui/gcs-ECSDFCIU.js +1 -0
  102. package/dist/ui/ui.css +1 -1
  103. package/dist/ui/ui.js +1 -1
  104. package/package.json +7 -3
  105. package/dist/ui/AIPage-JPZ4QUB4.js +0 -1
  106. package/dist/ui/AssetsPage-GDJMKS3M.js +0 -1
  107. package/dist/ui/CollectionPage-5DVXJEET.js +0 -1
  108. package/dist/ui/ComparePage-LIXA6G66.js +0 -1
  109. package/dist/ui/DataPage-AP4Z5JPS.js +0 -1
  110. package/dist/ui/DataSourcePage-WO3ZKMFI.js +0 -1
  111. package/dist/ui/DocTranslationsPage-QKYFIVHP.js +0 -1
  112. package/dist/ui/DocumentPage-ON43I5KM.js +0 -1
  113. package/dist/ui/EditDataSourcePage-XVMEV2LJ.js +0 -1
  114. package/dist/ui/EditReleasePage-A2NB5TFG.js +0 -1
  115. package/dist/ui/LogsPage-4LZJX3O4.js +0 -1
  116. package/dist/ui/NewDataSourcePage-4YWX7IOG.js +0 -1
  117. package/dist/ui/NewReleasePage-HWLVTEXX.js +0 -1
  118. package/dist/ui/NotFoundPage-72AXQAYX.js +0 -1
  119. package/dist/ui/ProjectPage-L4GYDIA5.js +0 -1
  120. package/dist/ui/ReleasePage-43BSWL5B.js +0 -1
  121. package/dist/ui/ReleasesPage-CJXAZBP6.js +0 -1
  122. package/dist/ui/SettingsPage-SYXAMKSF.js +0 -1
  123. package/dist/ui/SidebarToolsPage-OFF5BOXP.js +0 -1
  124. package/dist/ui/TaskPage-HBDLHFI5.js +0 -1
  125. package/dist/ui/TasksPage-OLCDTQNB.js +0 -1
  126. package/dist/ui/TranslationsArbPage-E3NCMAMS.js +0 -2
  127. package/dist/ui/TranslationsEditPage-IWOI7Y5G.js +0 -1
  128. package/dist/ui/chunk-32LRQ5MJ.js +0 -1
  129. package/dist/ui/chunk-3HVDIPSS.js +0 -1
  130. package/dist/ui/chunk-4CUWZQXT.js +0 -7
  131. package/dist/ui/chunk-DUJYIOLE.js +0 -5
  132. package/dist/ui/chunk-IDYKCAAL.js +0 -1
  133. package/dist/ui/chunk-IKED2IGU.js +0 -1
  134. package/dist/ui/chunk-J3EGGI57.js +0 -1
  135. package/dist/ui/chunk-MZP6RIG2.js +0 -1
  136. package/dist/ui/chunk-NQ5ARARP.js +0 -1
  137. package/dist/ui/chunk-RI2JWWU3.js +0 -141
  138. package/dist/ui/chunk-RPOP6MVJ.js +0 -1
  139. package/dist/ui/chunk-TDKVKTW4.js +0 -1
  140. package/dist/ui/chunk-UA7UCTX5.js +0 -1
  141. package/dist/ui/gcs-L33FIRZU.js +0 -1
  142. /package/dist/ui/{ImageEditorDialog-QEULJAT2.js.LEGAL.txt → ImageEditorDialog-GGS4VFEA.js.LEGAL.txt} +0 -0
  143. /package/dist/ui/{chunk-SKEP5WYH.js.LEGAL.txt → chunk-7SK47HHZ.js.LEGAL.txt} +0 -0
  144. /package/dist/ui/{chunk-NMBXHKIJ.js.LEGAL.txt → chunk-E76ECIOX.js.LEGAL.txt} +0 -0
  145. /package/dist/ui/{chunk-RI2JWWU3.js.LEGAL.txt → chunk-MXGHX55S.js.LEGAL.txt} +0 -0
  146. /package/dist/ui/{chunk-EGEB6N4J.js.LEGAL.txt → chunk-VD6G5NV4.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as p,d as U,e as g}from"./chunk-2225WAJ2.js";import{f as u}from"./chunk-RPOP6MVJ.js";import{Fa as d,Ga as t,a as f,aa as v,j as x}from"./chunk-4CUWZQXT.js";import{d as c}from"./chunk-KUCVLANF.js";x();function A(e){let a=e.size||30,l=e.withTooltip!==!1,{profile:_}=g(e.profile===void 0?e.email:null),s=e.profile!==void 0?e.profile:_,r=s?.email||e.email||"",i=s?.displayName||"",o=s?.photoURL||"",[n,h]=f(!1),m=t(v,{className:u("UserAvatar",e.inactive&&"UserAvatar--inactive",e.className),src:!n&&o?o:void 0,alt:i||r,size:a,radius:"xl",style:!o||n?{backgroundColor:U(r||i||"?"),color:"#fff",fontWeight:600,fontSize:Math.max(10,Math.round(a*.4))}:void 0,imageProps:{onError:()=>h(!0)},children:!o||n?p(r,i):null});return l?t(A.Tooltip,{email:r,displayName:i,children:m}):m}A.Tooltip=function(a){if(!a.email&&!a.displayName)return t(c,{children:a.children});let l=t("div",{className:"UserAvatar__tooltip",children:[a.displayName&&t("div",{className:"UserAvatar__tooltip__name",children:a.displayName}),a.email&&t("div",{className:"UserAvatar__tooltip__email",children:a.email})]});return t(d,{label:l,position:"bottom",withArrow:!0,transition:"pop",children:a.children})};export{A as a};
1
+ import{a as p,d as U,e as g}from"./chunk-CAY5NM4Z.js";import{f as u}from"./chunk-YLSRRNSE.js";import{Fa as d,Ga as t,a as f,aa as v,j as x}from"./chunk-LROR6N3B.js";import{d as c}from"./chunk-KUCVLANF.js";x();function A(e){let a=e.size||30,l=e.withTooltip!==!1,{profile:_}=g(e.profile===void 0?e.email:null),s=e.profile!==void 0?e.profile:_,r=s?.email||e.email||"",i=s?.displayName||"",o=s?.photoURL||"",[n,h]=f(!1),m=t(v,{className:u("UserAvatar",e.inactive&&"UserAvatar--inactive",e.className),src:!n&&o?o:void 0,alt:i||r,size:a,radius:"xl",style:!o||n?{backgroundColor:U(r||i||"?"),color:"#fff",fontWeight:600,fontSize:Math.max(10,Math.round(a*.4))}:void 0,imageProps:{onError:()=>h(!0)},children:!o||n?p(r,i):null});return l?t(A.Tooltip,{email:r,displayName:i,children:m}):m}A.Tooltip=function(a){if(!a.email&&!a.displayName)return t(c,{children:a.children});let l=t("div",{className:"UserAvatar__tooltip",children:[a.displayName&&t("div",{className:"UserAvatar__tooltip__name",children:a.displayName}),a.email&&t("div",{className:"UserAvatar__tooltip__email",children:a.email})]});return t(d,{label:l,position:"bottom",withArrow:!0,transition:"pop",children:a.children})};export{A as a};
@@ -1 +1 @@
1
- import{b as _}from"./chunk-4KE2SZKH.js";import{a as S,c as u}from"./chunk-KPJ53X55.js";import{Ga as e,V as n,a as l,c as d,da as c,j as x}from"./chunk-4CUWZQXT.js";x();var r="DataSourceSelectModal";function L(){let a=S(),t=u();return{open:i=>{a.openContextModal(r,{...t,innerProps:i,size:"600px",overflow:"inside"})},close:()=>{a.closeModal(r)}}}function h(a){let{innerProps:t}=a,[i,m]=l(!0),[s,p]=l([]),D=t.selectedDataSourceIds||[];d(()=>{async function o(){let v=await _();p(v.filter(g=>!g.archivedAt)),m(!1)}o()},[]);function f(o){t.onChange&&t.onChange(o,!0)}function M(o){t.onChange&&t.onChange(o,!1)}return e("div",{className:"DataSourceSelectModal",children:i?e("div",{className:"DataSourceSelectModal__loading",children:e(n,{color:"gray",size:"xl"})}):s.length===0?e("div",{className:"DataSourceSelectModal__empty",children:"No data sources."}):e("div",{className:"DataSourceSelectModal__list",children:s.map(o=>e("div",{className:"DataSourceSelectModal__item",children:[e("div",{className:"DataSourceSelectModal__item__info",children:[e("div",{className:"DataSourceSelectModal__item__id",children:o.id}),e("div",{className:"DataSourceSelectModal__item__description",children:o.description||""})]}),e("div",{className:"DataSourceSelectModal__item__action",children:D.includes(o.id)?e(c,{variant:"light",color:"blue",size:"xs",onClick:()=>M(o.id),children:"Unselect"}):e(c,{variant:"filled",color:"blue",size:"xs",onClick:()=>f(o.id),children:"Select"})})]},o.id))})})}h.id=r;export{L as a,h as b};
1
+ import{b as _}from"./chunk-D3UIZHRK.js";import{a as S,c as u}from"./chunk-HARRKJFZ.js";import{Ga as e,V as n,a as l,c as d,da as c,j as x}from"./chunk-LROR6N3B.js";x();var r="DataSourceSelectModal";function L(){let a=S(),t=u();return{open:i=>{a.openContextModal(r,{...t,innerProps:i,size:"600px",overflow:"inside"})},close:()=>{a.closeModal(r)}}}function h(a){let{innerProps:t}=a,[i,m]=l(!0),[s,p]=l([]),D=t.selectedDataSourceIds||[];d(()=>{async function o(){let v=await _();p(v.filter(g=>!g.archivedAt)),m(!1)}o()},[]);function f(o){t.onChange&&t.onChange(o,!0)}function M(o){t.onChange&&t.onChange(o,!1)}return e("div",{className:"DataSourceSelectModal",children:i?e("div",{className:"DataSourceSelectModal__loading",children:e(n,{color:"gray",size:"xl"})}):s.length===0?e("div",{className:"DataSourceSelectModal__empty",children:"No data sources."}):e("div",{className:"DataSourceSelectModal__list",children:s.map(o=>e("div",{className:"DataSourceSelectModal__item",children:[e("div",{className:"DataSourceSelectModal__item__info",children:[e("div",{className:"DataSourceSelectModal__item__id",children:o.id}),e("div",{className:"DataSourceSelectModal__item__description",children:o.description||""})]}),e("div",{className:"DataSourceSelectModal__item__action",children:D.includes(o.id)?e(c,{variant:"light",color:"blue",size:"xs",onClick:()=>M(o.id),children:"Unselect"}):e(c,{variant:"filled",color:"blue",size:"xs",onClick:()=>f(o.id),children:"Select"})})]},o.id))})})}h.id=r;export{L as a,h as b};
@@ -1 +1 @@
1
- import{c as a,n as d}from"./chunk-EGEB6N4J.js";import{a as s,c as i,j as l}from"./chunk-4CUWZQXT.js";l();var r=null;function R(){return r||(r=(async()=>{let o=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",t=a(o,"Projects",e);return((await d(t)).data()||{}).roles||{}})()),r}function m(){let[o,e]=s({}),[t,n]=s(!0);return i(()=>{R().then(c=>{e(c),n(!1)})},[]),{roles:o,loading:t}}export{m as a};
1
+ import{c as a,n as d}from"./chunk-VD6G5NV4.js";import{a as s,c as i,j as l}from"./chunk-LROR6N3B.js";l();var r=null;function R(){return r||(r=(async()=>{let o=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId||"default",t=a(o,"Projects",e);return((await d(t)).data()||{}).roles||{}})()),r}function m(){let[o,e]=s({}),[t,n]=s(!0);return i(()=>{R().then(c=>{e(c),n(!1)})},[]),{roles:o,loading:t}}export{m as a};
@@ -1 +1 @@
1
- import{f as r}from"./chunk-RPOP6MVJ.js";import{Ga as i}from"./chunk-4CUWZQXT.js";function f(n){let{className:a,as:l,size:t,weight:e,color:o,children:s,...x}=n;return i(l||"div",{...x,className:r(a,"text",t&&`size:${t}`,e&&`weight:${e}`,o&&`color:${o}`),children:s})}export{f as a};
1
+ import{f as r}from"./chunk-YLSRRNSE.js";import{Ga as i}from"./chunk-LROR6N3B.js";function f(n){let{className:a,as:l,size:t,weight:e,color:o,children:s,...x}=n;return i(l||"div",{...x,className:r(a,"text",t&&`size:${t}`,e&&`weight:${e}`,o&&`color:${o}`),children:s})}export{f as a};
@@ -0,0 +1 @@
1
+ import{b as le}from"./chunk-JTIQBW33.js";import{a as oe}from"./chunk-AZCGXQTL.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-TFB3VGWP.js";import{b as te}from"./chunk-J5E457OI.js";import{a as $}from"./chunk-QHJOTXYB.js";import{a as j}from"./chunk-O5P3CPJ4.js";import{b as K,f as U,g as _,i as y,o as Y}from"./chunk-VD6G5NV4.js";import{d as Z,f as se}from"./chunk-YLSRRNSE.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};
@@ -1 +1 @@
1
- import{a as h}from"./chunk-YDO2EDVY.js";import{g as y}from"./chunk-UFQSZ6J2.js";import{a as x}from"./chunk-5MV6XVGA.js";import{c as f,n as g}from"./chunk-EGEB6N4J.js";async function b(e){let t=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,a]=e.split("/",2),i=await h(o),n=f(t,"Projects",r,"Collections",o,"Drafts",a),c=(await g(n)).data()||{},p=new Set;return m(p,i.fields,c.fields||{},i.types||{}),Array.from(p)}async function C(e){let t=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,a]=e.split("/",2),i=await h(o),n=f(t,"Projects",r,"Collections",o,"Drafts",a),c=(await g(n)).data()||{},p=new Map;return d(p,i.fields,c.fields||{},i.types||{}),p}function m(e,t,r,o={}){t.forEach(a=>{if(!a.id)return;let i=r[a.id],n=`@${a.id}`,s=r[n];s?.translate===!1||s?.disableTranslations||R(e,a,i,o,s)})}function d(e,t,r,o={}){t.forEach(a=>{if(!a.id)return;let i=r[a.id],n=`@${a.id}`,s=r[n];if(s?.translate===!1||s?.disableTranslations)return;let c=s?.description;S(e,a,i,o,c,s)})}function R(e,t,r,o={},a){if(!r)return;function i(n){let s=y(n);s&&e.add(s)}if(t.type==="object")m(e,t.fields||[],r,o);else if(t.type==="array"){let n=r._array||[];for(let s of n)R(e,t.of,r[s],o)}else if(t.type==="string"||t.type==="select")t.translate&&i(r);else if(t.type==="image")t.translate&&r&&r.alt&&t.alt!==!1&&a?.alt!==!1&&i(r.alt);else if(t.type==="multiselect"){if(t.translate&&Array.isArray(r))for(let n of r)i(n)}else if(t.type==="oneof"){let n=t.types||[],s;typeof n[0]=="string"?n.includes(r._type)&&(s=o[r._type]):s=n.find(c=>c.name===r._type),s&&m(e,s.fields||[],r,o)}else t.type==="richtext"?t.translate&&T(e,r):console.log(`extract: ignoring field, id=${t.id}, type=${t.type}`)}function S(e,t,r,o={},a,i){if(!r)return;function n(s){let c=y(s);if(c){let p=e.get(c);(!p||!p.description)&&e.set(c,{description:a})}}if(t.type==="object")d(e,t.fields||[],r,o);else if(t.type==="array"){let s=r._array||[];for(let c of s)S(e,t.of,r[c],o,a)}else if(t.type==="string"||t.type==="select")t.translate&&n(r);else if(t.type==="image")t.translate&&r&&r.alt&&t.alt!==!1&&i?.alt!==!1&&n(r.alt);else if(t.type==="multiselect"){if(t.translate&&Array.isArray(r))for(let s of r)n(s)}else if(t.type==="oneof"){let s=t.types||[],c;typeof s[0]=="string"?s.includes(r._type)&&(c=o[r._type]):c=s.find(p=>p.name===r._type),c&&d(e,c.fields||[],r,o)}else if(t.type==="richtext"&&t.translate){let s=new Set;T(s,r),s.forEach(c=>n(c))}}function T(e,t){(t?.blocks||[]).forEach(o=>{l(e,o)})}function l(e,t){if(!t?.type)return;function r(n){if(!n)return;let s=y(n);s&&e.add(s)}function o(n){n&&Object.values(n).forEach(s=>{a(s)})}function a(n){if(typeof n=="string"){r(n);return}if(Array.isArray(n)){n.forEach(s=>a(s));return}x(n)&&Object.values(n).forEach(s=>a(s))}function i(n){n&&n.forEach(s=>{r(s.content),o(s.components),i(s.items)})}t.type==="heading"||t.type==="paragraph"?(r(t.data?.text),o(t.data?.components)):t.type==="orderedList"||t.type==="unorderedList"?i(t.data?.items):t.type==="html"?r(t.data?.html):t.type==="table"&&(t.data?.rows||[]).forEach(s=>{(s.cells||[]).forEach(p=>{(p.blocks||[]).forEach(w=>{l(e,w)})})})}export{b as a,C as b,R as c};
1
+ import{a as h}from"./chunk-YDO2EDVY.js";import{a as x}from"./chunk-5MV6XVGA.js";import{g as y}from"./chunk-ZN2Y5OUF.js";import{c as f,n as g}from"./chunk-VD6G5NV4.js";async function b(e){let t=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,a]=e.split("/",2),i=await h(o),n=f(t,"Projects",r,"Collections",o,"Drafts",a),c=(await g(n)).data()||{},p=new Set;return m(p,i.fields,c.fields||{},i.types||{}),Array.from(p)}async function C(e){let t=window.firebase.db,r=window.__ROOT_CTX.rootConfig.projectId,[o,a]=e.split("/",2),i=await h(o),n=f(t,"Projects",r,"Collections",o,"Drafts",a),c=(await g(n)).data()||{},p=new Map;return d(p,i.fields,c.fields||{},i.types||{}),p}function m(e,t,r,o={}){t.forEach(a=>{if(!a.id)return;let i=r[a.id],n=`@${a.id}`,s=r[n];s?.translate===!1||s?.disableTranslations||R(e,a,i,o,s)})}function d(e,t,r,o={}){t.forEach(a=>{if(!a.id)return;let i=r[a.id],n=`@${a.id}`,s=r[n];if(s?.translate===!1||s?.disableTranslations)return;let c=s?.description;S(e,a,i,o,c,s)})}function R(e,t,r,o={},a){if(!r)return;function i(n){let s=y(n);s&&e.add(s)}if(t.type==="object")m(e,t.fields||[],r,o);else if(t.type==="array"){let n=r._array||[];for(let s of n)R(e,t.of,r[s],o)}else if(t.type==="string"||t.type==="select")t.translate&&i(r);else if(t.type==="image")t.translate&&r&&r.alt&&t.alt!==!1&&a?.alt!==!1&&i(r.alt);else if(t.type==="multiselect"){if(t.translate&&Array.isArray(r))for(let n of r)i(n)}else if(t.type==="oneof"){let n=t.types||[],s;typeof n[0]=="string"?n.includes(r._type)&&(s=o[r._type]):s=n.find(c=>c.name===r._type),s&&m(e,s.fields||[],r,o)}else t.type==="richtext"?t.translate&&T(e,r):console.log(`extract: ignoring field, id=${t.id}, type=${t.type}`)}function S(e,t,r,o={},a,i){if(!r)return;function n(s){let c=y(s);if(c){let p=e.get(c);(!p||!p.description)&&e.set(c,{description:a})}}if(t.type==="object")d(e,t.fields||[],r,o);else if(t.type==="array"){let s=r._array||[];for(let c of s)S(e,t.of,r[c],o,a)}else if(t.type==="string"||t.type==="select")t.translate&&n(r);else if(t.type==="image")t.translate&&r&&r.alt&&t.alt!==!1&&i?.alt!==!1&&n(r.alt);else if(t.type==="multiselect"){if(t.translate&&Array.isArray(r))for(let s of r)n(s)}else if(t.type==="oneof"){let s=t.types||[],c;typeof s[0]=="string"?s.includes(r._type)&&(c=o[r._type]):c=s.find(p=>p.name===r._type),c&&d(e,c.fields||[],r,o)}else if(t.type==="richtext"&&t.translate){let s=new Set;T(s,r),s.forEach(c=>n(c))}}function T(e,t){(t?.blocks||[]).forEach(o=>{l(e,o)})}function l(e,t){if(!t?.type)return;function r(n){if(!n)return;let s=y(n);s&&e.add(s)}function o(n){n&&Object.values(n).forEach(s=>{a(s)})}function a(n){if(typeof n=="string"){r(n);return}if(Array.isArray(n)){n.forEach(s=>a(s));return}x(n)&&Object.values(n).forEach(s=>a(s))}function i(n){n&&n.forEach(s=>{r(s.content),o(s.components),i(s.items)})}t.type==="heading"||t.type==="paragraph"?(r(t.data?.text),o(t.data?.components)):t.type==="orderedList"||t.type==="unorderedList"?i(t.data?.items):t.type==="html"?r(t.data?.html):t.type==="table"&&(t.data?.rows||[]).forEach(s=>{(s.cells||[]).forEach(p=>{(p.blocks||[]).forEach(w=>{l(e,w)})})})}export{b as a,C as b,R as c};
@@ -0,0 +1 @@
1
+ import{c as e,j as c}from"./chunk-LROR6N3B.js";c();function s(o){e(()=>{let n=window.__ROOT_CTX?.rootConfig,t=n?.projectName||"Root CMS",i=n?.minimalBranding?t:`${t} \u2013 Root CMS`;document.title=o?`${o} \u2013 ${i}`:i},[o])}export{s as a};
@@ -1 +1 @@
1
- import{a as k}from"./chunk-N4DFAIC5.js";import{c as z}from"./chunk-NMBXHKIJ.js";import{B as A,C as I,x as y}from"./chunk-NQ5ARARP.js";import{a as b}from"./chunk-N5Y5OWTV.js";import{f as h}from"./chunk-5MV6XVGA.js";import{f as u}from"./chunk-RPOP6MVJ.js";import{Dc as N,Ga as e,U as p,Uc as C,V as g,a as n,c as v,da as S,e as w,j as V}from"./chunk-4CUWZQXT.js";import{d as _}from"./chunk-KUCVLANF.js";V();V();function P(o){let r=o.docId,[i,d]=n("idle"),[c,f]=n(""),[s,l]=n(""),m=w(!1);async function x(){d("loading");try{let t=await I(r,{beforeVersion:o.beforeVersion,afterVersion:o.afterVersion});f(t),d("success")}catch(t){console.error(t),l(t instanceof Error?t.message:"Unknown error"),d("error")}}function D(){m.current||(m.current=!0,x())}let a;return i==="idle"||i==="loading"?a=e("div",{className:"AiSummary__loading",children:e(g,{size:"md",color:"gray"})}):i==="error"?a=e(b,{className:"AiSummary__content",size:"body-sm",color:"gray",children:["Failed to load AI summary.",s&&e(_,{children:[e("br",{}),s]})]}):c?a=e(z,{className:"AiSummary__content",code:c}):a=e(b,{className:"AiSummary__content",size:"body-sm",color:"gray",children:"No AI summary available for this draft yet."}),e("div",{className:u(o.className,"AiSummary"),children:e(p,{iconPosition:"right",onChange:()=>D(),disableIconRotation:!0,children:e(p.Item,{label:"Summarize changes",icon:e(N,{stroke:"1.5"}),iconPosition:"left",children:a})})})}function se(o){let r=o.left,i=o.right,[d,c]=n(!1),[f,s]=n(null),[l,m]=n(null),D=(window.__ROOT_CTX?.experiments||{}).ai&&r.docId===i.docId&&o.showAiSummary!==!1,a=h(T(f?.fields||{})),t=h(T(l?.fields||{})),F=!d&&f&&l&&a===t,M=`/cms/compare?left=${B(r)}&right=${B(i)}`;async function $(){c(!0);let[j,E]=await Promise.all([y(r.docId,r.versionId),y(i.docId,i.versionId)]);s(j),m(E),c(!1)}return v(()=>{$()},[]),d?e("div",{className:"DocDiffViewer DocDiffViewer--loading",children:e(g,{size:"md",color:"gray"})}):e(_,{children:[D&&e(P,{className:"DocDiffViewer__aiSummary",docId:r.docId,beforeVersion:String(r.versionId),afterVersion:String(i.versionId)}),e("div",{className:u(o.className,"DocDiffViewer"),children:[o.showExpandButton&&e("div",{className:"DocDiffViewer__expand",children:e(S,{component:"a",variant:"default",size:"xs",compact:!0,href:M,target:"_blank",children:"Open in new tab"})}),e("div",{className:"DocDiffViewer__header",children:[e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.left.docId,"@",o.left.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:R(f)})]}),e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.right.docId,"@",o.right.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:R(l)})]})]}),e("div",{className:"DocDiffViewer__diff",children:F?e("div",{className:"DocDiffViewer__identical",children:[e(C,{size:20}),e("span",{children:"No changes. Both versions are identical."})]}):e(k,{oldCode:a,newCode:t})})]})]})}function R(o){if(!o?.sys?.modifiedAt)return"never";let r=o.sys.modifiedAt.toDate();return`${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)} by ${o.sys.modifiedBy}`}function T(o){return A(o,{removeArrayKey:!0})}function B(o){return encodeURIComponent(`${o.docId}@${o.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}export{P as a,se as b};
1
+ import{a as k}from"./chunk-3T4ZWQR4.js";import{c as z}from"./chunk-E76ECIOX.js";import{f as h}from"./chunk-5MV6XVGA.js";import{U as y,Y as A,Z as I}from"./chunk-TFB3VGWP.js";import{a as b}from"./chunk-O5P3CPJ4.js";import{f as u}from"./chunk-YLSRRNSE.js";import{Ga as e,Gc as N,U as p,V as g,Zc as C,a as n,c as v,da as S,e as w,j as V}from"./chunk-LROR6N3B.js";import{d as _}from"./chunk-KUCVLANF.js";V();V();function P(o){let r=o.docId,[i,d]=n("idle"),[c,f]=n(""),[s,l]=n(""),m=w(!1);async function x(){d("loading");try{let t=await I(r,{beforeVersion:o.beforeVersion,afterVersion:o.afterVersion});f(t),d("success")}catch(t){console.error(t),l(t instanceof Error?t.message:"Unknown error"),d("error")}}function D(){m.current||(m.current=!0,x())}let a;return i==="idle"||i==="loading"?a=e("div",{className:"AiSummary__loading",children:e(g,{size:"md",color:"gray"})}):i==="error"?a=e(b,{className:"AiSummary__content",size:"body-sm",color:"gray",children:["Failed to load AI summary.",s&&e(_,{children:[e("br",{}),s]})]}):c?a=e(z,{className:"AiSummary__content",code:c}):a=e(b,{className:"AiSummary__content",size:"body-sm",color:"gray",children:"No AI summary available for this draft yet."}),e("div",{className:u(o.className,"AiSummary"),children:e(p,{iconPosition:"right",onChange:()=>D(),disableIconRotation:!0,children:e(p.Item,{label:"Summarize changes",icon:e(N,{stroke:"1.5"}),iconPosition:"left",children:a})})})}function se(o){let r=o.left,i=o.right,[d,c]=n(!1),[f,s]=n(null),[l,m]=n(null),D=(window.__ROOT_CTX?.experiments||{}).ai&&r.docId===i.docId&&o.showAiSummary!==!1,a=h(T(f?.fields||{})),t=h(T(l?.fields||{})),F=!d&&f&&l&&a===t,M=`/cms/compare?left=${B(r)}&right=${B(i)}`;async function $(){c(!0);let[j,E]=await Promise.all([y(r.docId,r.versionId),y(i.docId,i.versionId)]);s(j),m(E),c(!1)}return v(()=>{$()},[]),d?e("div",{className:"DocDiffViewer DocDiffViewer--loading",children:e(g,{size:"md",color:"gray"})}):e(_,{children:[D&&e(P,{className:"DocDiffViewer__aiSummary",docId:r.docId,beforeVersion:String(r.versionId),afterVersion:String(i.versionId)}),e("div",{className:u(o.className,"DocDiffViewer"),children:[o.showExpandButton&&e("div",{className:"DocDiffViewer__expand",children:e(S,{component:"a",variant:"default",size:"xs",compact:!0,href:M,target:"_blank",children:"Open in new tab"})}),e("div",{className:"DocDiffViewer__header",children:[e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.left.docId,"@",o.left.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:R(f)})]}),e("div",{className:"DocDiffViewer__header__label",children:[e("div",{className:"DocDiffViewer__header__label__title",children:[o.right.docId,"@",o.right.versionId]}),e("div",{className:"DocDiffViewer__header__label__meta",children:R(l)})]})]}),e("div",{className:"DocDiffViewer__diff",children:F?e("div",{className:"DocDiffViewer__identical",children:[e(C,{size:20}),e("span",{children:"No changes. Both versions are identical."})]}):e(k,{oldCode:a,newCode:t})})]})]})}function R(o){if(!o?.sys?.modifiedAt)return"never";let r=o.sys.modifiedAt.toDate();return`${new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)} by ${o.sys.modifiedBy}`}function T(o){return A(o,{removeArrayKey:!0})}function B(o){return encodeURIComponent(`${o.docId}@${o.versionId}`).replaceAll("%2F","/").replaceAll("%40","@")}export{P as a,se as b};
@@ -1 +1 @@
1
- import{C as at,D as st,G as pt,J as ut,K as ft,M as lt,N as ct,R as dt,X as mt,c as T,e as w,ma as M,n as ot,s as S,t as C,ta as ht,v as l,y as h,z as it}from"./chunk-4CUWZQXT.js";import{j as rt}from"./chunk-KUCVLANF.js";h();var R={show:"mantine:show-notification",hide:"mantine:hide-notification",update:"mantine:update-notification",clean:"mantine:clean-notifications",cleanQueue:"mantine:clean-notifications-queue"};function G(t,e){return new CustomEvent(t,{detail:e})}function $t(t){window.dispatchEvent(G(R.show,t))}function Yt(t){window.dispatchEvent(G(R.update,t))}function Bt(t){window.dispatchEvent(G(R.hide,t))}function Et(t){let e={show:n=>t.showNotification(n.detail),hide:n=>t.hideNotification(n.detail),update:n=>t.updateNotification(n.detail.id,n.detail),clean:t.clean,cleanQueue:t.cleanQueue};T(()=>(Object.keys(e).forEach(n=>{window.addEventListener(R[n],e[n])}),()=>{Object.keys(e).forEach(n=>{window.removeEventListener(R[n],e[n])})}),[])}h();function j(t,e){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},j(t,e)}function L(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,j(t,e)}h();h();var W={disabled:!1};h();var O=l.createContext(null);var vt=function(e){return e.scrollTop};var D="unmounted",y="exited",_="entering",b="entered",Q="exiting",E=(function(t){L(e,t);function e(i,o){var r;r=t.call(this,i,o)||this;var a=o,s=a&&!a.isMounting?i.enter:i.appear,p;return r.appearStatus=null,i.in?s?(p=y,r.appearStatus=_):p=b:i.unmountOnExit||i.mountOnEnter?p=D:p=y,r.state={status:p},r.nextCallback=null,r}e.getDerivedStateFromProps=function(o,r){var a=o.in;return a&&r.status===D?{status:y}:null};var n=e.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var r=null;if(o!==this.props){var a=this.state.status;this.props.in?a!==_&&a!==b&&(r=_):(a===_||a===b)&&(r=Q)}this.updateStatus(!1,r)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,r,a,s;return r=a=s=o,o!=null&&typeof o!="number"&&(r=o.exit,a=o.enter,s=o.appear!==void 0?o.appear:a),{exit:r,enter:a,appear:s}},n.updateStatus=function(o,r){if(o===void 0&&(o=!1),r!==null)if(this.cancelNextCallback(),r===_){if(this.props.unmountOnExit||this.props.mountOnEnter){var a=this.props.nodeRef?this.props.nodeRef.current:l.findDOMNode(this);a&&vt(a)}this.performEnter(o)}else this.performExit();else this.props.unmountOnExit&&this.state.status===y&&this.setState({status:D})},n.performEnter=function(o){var r=this,a=this.props.enter,s=this.context?this.context.isMounting:o,p=this.props.nodeRef?[s]:[l.findDOMNode(this),s],u=p[0],f=p[1],c=this.getTimeouts(),d=s?c.appear:c.enter;if(!o&&!a||W.disabled){this.safeSetState({status:b},function(){r.props.onEntered(u)});return}this.props.onEnter(u,f),this.safeSetState({status:_},function(){r.props.onEntering(u,f),r.onTransitionEnd(d,function(){r.safeSetState({status:b},function(){r.props.onEntered(u,f)})})})},n.performExit=function(){var o=this,r=this.props.exit,a=this.getTimeouts(),s=this.props.nodeRef?void 0:l.findDOMNode(this);if(!r||W.disabled){this.safeSetState({status:y},function(){o.props.onExited(s)});return}this.props.onExit(s),this.safeSetState({status:Q},function(){o.props.onExiting(s),o.onTransitionEnd(a.exit,function(){o.safeSetState({status:y},function(){o.props.onExited(s)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,r){r=this.setNextCallback(r),this.setState(o,r)},n.setNextCallback=function(o){var r=this,a=!0;return this.nextCallback=function(s){a&&(a=!1,r.nextCallback=null,o(s))},this.nextCallback.cancel=function(){a=!1},this.nextCallback},n.onTransitionEnd=function(o,r){this.setNextCallback(r);var a=this.props.nodeRef?this.props.nodeRef.current:l.findDOMNode(this),s=o==null&&!this.props.addEndListener;if(!a||s){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var p=this.props.nodeRef?[this.nextCallback]:[a,this.nextCallback],u=p[0],f=p[1];this.props.addEndListener(u,f)}o!=null&&setTimeout(this.nextCallback,o)},n.render=function(){var o=this.state.status;if(o===D)return null;var r=this.props,a=r.children,s=r.in,p=r.mountOnEnter,u=r.unmountOnExit,f=r.appear,c=r.enter,d=r.exit,v=r.timeout,m=r.addEndListener,U=r.onEnter,N=r.onEntering,Y=r.onEntered,B=r.onExit,Z=r.onExiting,H=r.onExited,J=r.nodeRef,I=M(r,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return l.createElement(O.Provider,{value:null},typeof a=="function"?a(o,I):l.cloneElement(l.Children.only(a),I))},e})(l.Component);E.contextType=O;E.propTypes={};function P(){}E.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:P,onEntering:P,onEntered:P,onExit:P,onExiting:P,onExited:P};E.UNMOUNTED=D;E.EXITED=y;E.ENTERING=_;E.ENTERED=b;E.EXITING=Q;var X=E;function xt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}h();h();function k(t,e){var n=function(r){return e&&S(r)?e(r):r},i=Object.create(null);return t&&ot.map(t,function(o){return o}).forEach(function(o){i[o.key]=n(o)}),i}function Zt(t,e){t=t||{},e=e||{};function n(f){return f in e?e[f]:t[f]}var i=Object.create(null),o=[];for(var r in t)r in e?o.length&&(i[r]=o,o=[]):o.push(r);var a,s={};for(var p in e){if(i[p])for(a=0;a<i[p].length;a++){var u=i[p][a];s[i[p][a]]=n(u)}s[p]=n(p)}for(a=0;a<o.length;a++)s[o[a]]=n(o[a]);return s}function g(t,e,n){return n[e]!=null?n[e]:t.props[e]}function yt(t,e){return k(t.children,function(n){return C(n,{onExited:e.bind(null,n),in:!0,appear:g(n,"appear",t),enter:g(n,"enter",t),exit:g(n,"exit",t)})})}function _t(t,e,n){var i=k(t.children),o=Zt(e,i);return Object.keys(o).forEach(function(r){var a=o[r];if(S(a)){var s=r in e,p=r in i,u=e[r],f=S(u)&&!u.props.in;p&&(!s||f)?o[r]=C(a,{onExited:n.bind(null,a),in:!0,exit:g(a,"exit",t),enter:g(a,"enter",t)}):!p&&s&&!f?o[r]=C(a,{in:!1}):p&&s&&S(u)&&(o[r]=C(a,{onExited:n.bind(null,a),in:u.props.in,exit:g(a,"exit",t),enter:g(a,"enter",t)}))}}),o}var Jt=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},Kt={component:"div",childFactory:function(e){return e}},q=(function(t){L(e,t);function e(i,o){var r;r=t.call(this,i,o)||this;var a=r.handleExited.bind(xt(r));return r.state={contextValue:{isMounting:!0},handleExited:a,firstRender:!0},r}var n=e.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},e.getDerivedStateFromProps=function(o,r){var a=r.children,s=r.handleExited,p=r.firstRender;return{children:p?yt(o,s):_t(o,a,s),firstRender:!1}},n.handleExited=function(o,r){var a=k(this.props.children);o.key in a||(o.props.onExited&&o.props.onExited(r),this.mounted&&this.setState(function(s){var p=it({},s.children);return delete p[o.key],{children:p}}))},n.render=function(){var o=this.props,r=o.component,a=o.childFactory,s=M(o,["component","childFactory"]),p=this.state.contextValue,u=Jt(this.state.children).map(a);return delete s.appear,delete s.enter,delete s.exit,r===null?l.createElement(O.Provider,{value:p},u):l.createElement(O.Provider,{value:p},l.createElement(r,s,u))},e})(l.Component);q.propTypes={};q.defaultProps=Kt;var z=q;h();var A=rt(null);A.displayName="@mantine/notifications/NotificationsContext";function te([t,e],n,i){let o={};return t==="top"&&(o.top=i),t==="bottom"&&(o.bottom=i),e==="left"&&(o.left=i),e==="right"&&(o.right=i),e==="center"&&(o.left="50%",o.transform="translateX(-50%)"),o}var gt=te;var ee=Object.defineProperty,Nt=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,Ot=(t,e,n)=>e in t?ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Pt=(t,e)=>{for(var n in e||(e={}))ne.call(e,n)&&Ot(t,n,e[n]);if(Nt)for(var n of Nt(e))re.call(e,n)&&Ot(t,n,e[n]);return t},bt={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},oe={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function ie({state:t,maxHeight:e,positioning:n,transitionDuration:i}){let[o,r]=n,a=r==="center"?`${o}-center`:r,s={opacity:0,maxHeight:e,transform:bt[a],transitionDuration:`${i}ms, ${i}ms, ${i}ms`,transitionTimingFunction:"cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear",transitionProperty:"opacity, transform, max-height"},p={opacity:1,transform:oe[a]},u={opacity:0,maxHeight:0,transform:bt[a]},f={entering:p,entered:p,exiting:u,exited:u};return Pt(Pt({},s),f[t])}var Tt=ie;h();function ae(t,e){return typeof e=="number"?e:e===!1||t===!1?!1:t}var wt=ae;var se=Object.defineProperty,pe=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,St=(t,e,n)=>e in t?se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ct=(t,e)=>{for(var n in e||(e={}))Dt.call(e,n)&&St(t,n,e[n]);if(V)for(var n of V(e))It.call(e,n)&&St(t,n,e[n]);return t},fe=(t,e)=>pe(t,ue(e)),Rt=(t,e)=>{var n={};for(var i in t)Dt.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&V)for(var i of V(t))e.indexOf(i)<0&&It.call(t,i)&&(n[i]=t[i]);return n};function Mt(t){var e=t,{notification:n,autoClose:i,onHide:o,innerRef:r}=e,a=Rt(e,["notification","autoClose","onHide","innerRef"]);let s=n,{autoClose:p}=s,u=Rt(s,["autoClose"]),f=wt(i,p),c=w(),d=()=>{o(n.id),window.clearTimeout(c.current)},v=()=>{clearTimeout(c.current)},m=()=>{typeof f=="number"&&(c.current=window.setTimeout(d,f))};return T(()=>{typeof n.onOpen=="function"&&n.onOpen(n)},[]),T(()=>(m(),v),[i,n.autoClose]),l.createElement(ht,fe(Ct(Ct({},u),a),{onClose:d,onMouseEnter:v,onMouseLeave:m,ref:r}),n.message)}Mt.displayName="@mantine/notifications/NotificationContainer";var jt=Mt;var le=st(t=>({notifications:{width:`calc(100% - ${t.spacing.md*2}px)`,boxSizing:"border-box",position:"fixed",zIndex:1e3},notification:{"&:not(:first-of-type)":{marginTop:t.spacing.sm}}})),Lt=le;var ce=Object.defineProperty,de=Object.defineProperties,me=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Vt=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ve=(t,e)=>{for(var n in e||(e={}))he.call(e,n)&&Vt(t,n,e[n]);if(kt)for(var n of kt(e))Ee.call(e,n)&&Vt(t,n,e[n]);return t},xe=(t,e)=>de(t,me(e));function ye({limit:t}){let{state:e,queue:n,update:i,cleanQueue:o}=lt({initialValues:[],limit:t});return{notifications:e,queue:n,showNotification:u=>{let f=u.id||ft();return i(c=>u.id&&c.some(d=>d.id===u.id)?c:[...c,xe(ve({},u),{id:f})]),f},updateNotification:(u,f)=>i(c=>{let d=c.findIndex(m=>m.id===u);if(d===-1)return c;let v=[...c];return v[d]=f,v}),hideNotification:u=>i(f=>f.filter(c=>c.id===u?(typeof c.onClose=="function"&&c.onClose(c),!1):!0)),cleanQueue:o,clean:()=>i(()=>[])}}var Ft=ye;var _e=Object.defineProperty,F=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,Ut=(t,e,n)=>e in t?_e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e)=>{for(var n in e||(e={}))Ht.call(e,n)&&Ut(t,n,e[n]);if(F)for(var n of F(e))Gt.call(e,n)&&Ut(t,n,e[n]);return t},ge=(t,e)=>{var n={};for(var i in t)Ht.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Gt.call(t,i)&&(n[i]=t[i]);return n},Ne=["top-left","top-right","top-center","bottom-left","bottom-right","bottom-center"];function Wt(t){var e=t,{className:n,position:i="bottom-right",autoClose:o=4e3,transitionDuration:r=250,containerWidth:a=440,notificationMaxHeight:s=200,limit:p=5,zIndex:u=at("overlay"),style:f,children:c}=e,d=ge(e,["className","position","autoClose","transitionDuration","containerWidth","notificationMaxHeight","limit","zIndex","style","children"]);let v=ut(),m=w({}),U=w(0),{notifications:N,queue:Y,showNotification:B,updateNotification:Z,hideNotification:H,clean:J,cleanQueue:I}=Ft({limit:p}),K=ct()?1:r,{classes:tt,cx:Qt,theme:Xt}=Lt(),et=(Ne.includes(i)?i:"bottom-right").split("-"),nt={notifications:N,queue:Y,showNotification:B,hideNotification:H,updateNotification:Z,clean:J,cleanQueue:I};pt(()=>{N.length>U.current&&setTimeout(()=>v(),0),U.current=N.length},[N]),Et(nt);let qt=N.map(x=>l.createElement(X,{key:x.id,timeout:K,onEnter:()=>m.current[x.id].offsetHeight,nodeRef:{current:m.current[x.id]}},zt=>l.createElement(jt,{innerRef:At=>{m.current[x.id]=At},notification:x,onHide:H,className:tt.notification,autoClose:o,sx:[$({},Tt({state:zt,positioning:et,transitionDuration:K,maxHeight:s})),...Array.isArray(x.sx)?x.sx:[x.sx]]})));return l.createElement(A.Provider,{value:nt},l.createElement(mt,{zIndex:u},l.createElement(dt,$({className:Qt(tt.notifications,n),style:f,sx:$({maxWidth:a},gt(et,a,Xt.spacing.md))},d),l.createElement(z,null,qt))),c)}Wt.displayName="@mantine/notifications/NotificationsProvider";export{$t as a,Yt as b,Bt as c,Wt as d};
1
+ import{C as at,D as st,G as pt,J as ut,K as ft,M as lt,N as ct,R as dt,X as mt,c as T,e as w,ma as M,n as ot,s as S,t as C,ta as ht,v as l,y as h,z as it}from"./chunk-LROR6N3B.js";import{j as rt}from"./chunk-KUCVLANF.js";h();var R={show:"mantine:show-notification",hide:"mantine:hide-notification",update:"mantine:update-notification",clean:"mantine:clean-notifications",cleanQueue:"mantine:clean-notifications-queue"};function G(t,e){return new CustomEvent(t,{detail:e})}function $t(t){window.dispatchEvent(G(R.show,t))}function Yt(t){window.dispatchEvent(G(R.update,t))}function Bt(t){window.dispatchEvent(G(R.hide,t))}function Et(t){let e={show:n=>t.showNotification(n.detail),hide:n=>t.hideNotification(n.detail),update:n=>t.updateNotification(n.detail.id,n.detail),clean:t.clean,cleanQueue:t.cleanQueue};T(()=>(Object.keys(e).forEach(n=>{window.addEventListener(R[n],e[n])}),()=>{Object.keys(e).forEach(n=>{window.removeEventListener(R[n],e[n])})}),[])}h();function j(t,e){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},j(t,e)}function L(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,j(t,e)}h();h();var W={disabled:!1};h();var O=l.createContext(null);var vt=function(e){return e.scrollTop};var D="unmounted",y="exited",_="entering",b="entered",Q="exiting",E=(function(t){L(e,t);function e(i,o){var r;r=t.call(this,i,o)||this;var a=o,s=a&&!a.isMounting?i.enter:i.appear,p;return r.appearStatus=null,i.in?s?(p=y,r.appearStatus=_):p=b:i.unmountOnExit||i.mountOnEnter?p=D:p=y,r.state={status:p},r.nextCallback=null,r}e.getDerivedStateFromProps=function(o,r){var a=o.in;return a&&r.status===D?{status:y}:null};var n=e.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var r=null;if(o!==this.props){var a=this.state.status;this.props.in?a!==_&&a!==b&&(r=_):(a===_||a===b)&&(r=Q)}this.updateStatus(!1,r)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,r,a,s;return r=a=s=o,o!=null&&typeof o!="number"&&(r=o.exit,a=o.enter,s=o.appear!==void 0?o.appear:a),{exit:r,enter:a,appear:s}},n.updateStatus=function(o,r){if(o===void 0&&(o=!1),r!==null)if(this.cancelNextCallback(),r===_){if(this.props.unmountOnExit||this.props.mountOnEnter){var a=this.props.nodeRef?this.props.nodeRef.current:l.findDOMNode(this);a&&vt(a)}this.performEnter(o)}else this.performExit();else this.props.unmountOnExit&&this.state.status===y&&this.setState({status:D})},n.performEnter=function(o){var r=this,a=this.props.enter,s=this.context?this.context.isMounting:o,p=this.props.nodeRef?[s]:[l.findDOMNode(this),s],u=p[0],f=p[1],c=this.getTimeouts(),d=s?c.appear:c.enter;if(!o&&!a||W.disabled){this.safeSetState({status:b},function(){r.props.onEntered(u)});return}this.props.onEnter(u,f),this.safeSetState({status:_},function(){r.props.onEntering(u,f),r.onTransitionEnd(d,function(){r.safeSetState({status:b},function(){r.props.onEntered(u,f)})})})},n.performExit=function(){var o=this,r=this.props.exit,a=this.getTimeouts(),s=this.props.nodeRef?void 0:l.findDOMNode(this);if(!r||W.disabled){this.safeSetState({status:y},function(){o.props.onExited(s)});return}this.props.onExit(s),this.safeSetState({status:Q},function(){o.props.onExiting(s),o.onTransitionEnd(a.exit,function(){o.safeSetState({status:y},function(){o.props.onExited(s)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,r){r=this.setNextCallback(r),this.setState(o,r)},n.setNextCallback=function(o){var r=this,a=!0;return this.nextCallback=function(s){a&&(a=!1,r.nextCallback=null,o(s))},this.nextCallback.cancel=function(){a=!1},this.nextCallback},n.onTransitionEnd=function(o,r){this.setNextCallback(r);var a=this.props.nodeRef?this.props.nodeRef.current:l.findDOMNode(this),s=o==null&&!this.props.addEndListener;if(!a||s){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var p=this.props.nodeRef?[this.nextCallback]:[a,this.nextCallback],u=p[0],f=p[1];this.props.addEndListener(u,f)}o!=null&&setTimeout(this.nextCallback,o)},n.render=function(){var o=this.state.status;if(o===D)return null;var r=this.props,a=r.children,s=r.in,p=r.mountOnEnter,u=r.unmountOnExit,f=r.appear,c=r.enter,d=r.exit,v=r.timeout,m=r.addEndListener,U=r.onEnter,N=r.onEntering,Y=r.onEntered,B=r.onExit,Z=r.onExiting,H=r.onExited,J=r.nodeRef,I=M(r,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return l.createElement(O.Provider,{value:null},typeof a=="function"?a(o,I):l.cloneElement(l.Children.only(a),I))},e})(l.Component);E.contextType=O;E.propTypes={};function P(){}E.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:P,onEntering:P,onEntered:P,onExit:P,onExiting:P,onExited:P};E.UNMOUNTED=D;E.EXITED=y;E.ENTERING=_;E.ENTERED=b;E.EXITING=Q;var X=E;function xt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}h();h();function k(t,e){var n=function(r){return e&&S(r)?e(r):r},i=Object.create(null);return t&&ot.map(t,function(o){return o}).forEach(function(o){i[o.key]=n(o)}),i}function Zt(t,e){t=t||{},e=e||{};function n(f){return f in e?e[f]:t[f]}var i=Object.create(null),o=[];for(var r in t)r in e?o.length&&(i[r]=o,o=[]):o.push(r);var a,s={};for(var p in e){if(i[p])for(a=0;a<i[p].length;a++){var u=i[p][a];s[i[p][a]]=n(u)}s[p]=n(p)}for(a=0;a<o.length;a++)s[o[a]]=n(o[a]);return s}function g(t,e,n){return n[e]!=null?n[e]:t.props[e]}function yt(t,e){return k(t.children,function(n){return C(n,{onExited:e.bind(null,n),in:!0,appear:g(n,"appear",t),enter:g(n,"enter",t),exit:g(n,"exit",t)})})}function _t(t,e,n){var i=k(t.children),o=Zt(e,i);return Object.keys(o).forEach(function(r){var a=o[r];if(S(a)){var s=r in e,p=r in i,u=e[r],f=S(u)&&!u.props.in;p&&(!s||f)?o[r]=C(a,{onExited:n.bind(null,a),in:!0,exit:g(a,"exit",t),enter:g(a,"enter",t)}):!p&&s&&!f?o[r]=C(a,{in:!1}):p&&s&&S(u)&&(o[r]=C(a,{onExited:n.bind(null,a),in:u.props.in,exit:g(a,"exit",t),enter:g(a,"enter",t)}))}}),o}var Jt=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},Kt={component:"div",childFactory:function(e){return e}},q=(function(t){L(e,t);function e(i,o){var r;r=t.call(this,i,o)||this;var a=r.handleExited.bind(xt(r));return r.state={contextValue:{isMounting:!0},handleExited:a,firstRender:!0},r}var n=e.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},e.getDerivedStateFromProps=function(o,r){var a=r.children,s=r.handleExited,p=r.firstRender;return{children:p?yt(o,s):_t(o,a,s),firstRender:!1}},n.handleExited=function(o,r){var a=k(this.props.children);o.key in a||(o.props.onExited&&o.props.onExited(r),this.mounted&&this.setState(function(s){var p=it({},s.children);return delete p[o.key],{children:p}}))},n.render=function(){var o=this.props,r=o.component,a=o.childFactory,s=M(o,["component","childFactory"]),p=this.state.contextValue,u=Jt(this.state.children).map(a);return delete s.appear,delete s.enter,delete s.exit,r===null?l.createElement(O.Provider,{value:p},u):l.createElement(O.Provider,{value:p},l.createElement(r,s,u))},e})(l.Component);q.propTypes={};q.defaultProps=Kt;var z=q;h();var A=rt(null);A.displayName="@mantine/notifications/NotificationsContext";function te([t,e],n,i){let o={};return t==="top"&&(o.top=i),t==="bottom"&&(o.bottom=i),e==="left"&&(o.left=i),e==="right"&&(o.right=i),e==="center"&&(o.left="50%",o.transform="translateX(-50%)"),o}var gt=te;var ee=Object.defineProperty,Nt=Object.getOwnPropertySymbols,ne=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,Ot=(t,e,n)=>e in t?ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Pt=(t,e)=>{for(var n in e||(e={}))ne.call(e,n)&&Ot(t,n,e[n]);if(Nt)for(var n of Nt(e))re.call(e,n)&&Ot(t,n,e[n]);return t},bt={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},oe={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function ie({state:t,maxHeight:e,positioning:n,transitionDuration:i}){let[o,r]=n,a=r==="center"?`${o}-center`:r,s={opacity:0,maxHeight:e,transform:bt[a],transitionDuration:`${i}ms, ${i}ms, ${i}ms`,transitionTimingFunction:"cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear",transitionProperty:"opacity, transform, max-height"},p={opacity:1,transform:oe[a]},u={opacity:0,maxHeight:0,transform:bt[a]},f={entering:p,entered:p,exiting:u,exited:u};return Pt(Pt({},s),f[t])}var Tt=ie;h();function ae(t,e){return typeof e=="number"?e:e===!1||t===!1?!1:t}var wt=ae;var se=Object.defineProperty,pe=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable,St=(t,e,n)=>e in t?se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ct=(t,e)=>{for(var n in e||(e={}))Dt.call(e,n)&&St(t,n,e[n]);if(V)for(var n of V(e))It.call(e,n)&&St(t,n,e[n]);return t},fe=(t,e)=>pe(t,ue(e)),Rt=(t,e)=>{var n={};for(var i in t)Dt.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&V)for(var i of V(t))e.indexOf(i)<0&&It.call(t,i)&&(n[i]=t[i]);return n};function Mt(t){var e=t,{notification:n,autoClose:i,onHide:o,innerRef:r}=e,a=Rt(e,["notification","autoClose","onHide","innerRef"]);let s=n,{autoClose:p}=s,u=Rt(s,["autoClose"]),f=wt(i,p),c=w(),d=()=>{o(n.id),window.clearTimeout(c.current)},v=()=>{clearTimeout(c.current)},m=()=>{typeof f=="number"&&(c.current=window.setTimeout(d,f))};return T(()=>{typeof n.onOpen=="function"&&n.onOpen(n)},[]),T(()=>(m(),v),[i,n.autoClose]),l.createElement(ht,fe(Ct(Ct({},u),a),{onClose:d,onMouseEnter:v,onMouseLeave:m,ref:r}),n.message)}Mt.displayName="@mantine/notifications/NotificationContainer";var jt=Mt;var le=st(t=>({notifications:{width:`calc(100% - ${t.spacing.md*2}px)`,boxSizing:"border-box",position:"fixed",zIndex:1e3},notification:{"&:not(:first-of-type)":{marginTop:t.spacing.sm}}})),Lt=le;var ce=Object.defineProperty,de=Object.defineProperties,me=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Vt=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ve=(t,e)=>{for(var n in e||(e={}))he.call(e,n)&&Vt(t,n,e[n]);if(kt)for(var n of kt(e))Ee.call(e,n)&&Vt(t,n,e[n]);return t},xe=(t,e)=>de(t,me(e));function ye({limit:t}){let{state:e,queue:n,update:i,cleanQueue:o}=lt({initialValues:[],limit:t});return{notifications:e,queue:n,showNotification:u=>{let f=u.id||ft();return i(c=>u.id&&c.some(d=>d.id===u.id)?c:[...c,xe(ve({},u),{id:f})]),f},updateNotification:(u,f)=>i(c=>{let d=c.findIndex(m=>m.id===u);if(d===-1)return c;let v=[...c];return v[d]=f,v}),hideNotification:u=>i(f=>f.filter(c=>c.id===u?(typeof c.onClose=="function"&&c.onClose(c),!1):!0)),cleanQueue:o,clean:()=>i(()=>[])}}var Ft=ye;var _e=Object.defineProperty,F=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,Ut=(t,e,n)=>e in t?_e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,$=(t,e)=>{for(var n in e||(e={}))Ht.call(e,n)&&Ut(t,n,e[n]);if(F)for(var n of F(e))Gt.call(e,n)&&Ut(t,n,e[n]);return t},ge=(t,e)=>{var n={};for(var i in t)Ht.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&F)for(var i of F(t))e.indexOf(i)<0&&Gt.call(t,i)&&(n[i]=t[i]);return n},Ne=["top-left","top-right","top-center","bottom-left","bottom-right","bottom-center"];function Wt(t){var e=t,{className:n,position:i="bottom-right",autoClose:o=4e3,transitionDuration:r=250,containerWidth:a=440,notificationMaxHeight:s=200,limit:p=5,zIndex:u=at("overlay"),style:f,children:c}=e,d=ge(e,["className","position","autoClose","transitionDuration","containerWidth","notificationMaxHeight","limit","zIndex","style","children"]);let v=ut(),m=w({}),U=w(0),{notifications:N,queue:Y,showNotification:B,updateNotification:Z,hideNotification:H,clean:J,cleanQueue:I}=Ft({limit:p}),K=ct()?1:r,{classes:tt,cx:Qt,theme:Xt}=Lt(),et=(Ne.includes(i)?i:"bottom-right").split("-"),nt={notifications:N,queue:Y,showNotification:B,hideNotification:H,updateNotification:Z,clean:J,cleanQueue:I};pt(()=>{N.length>U.current&&setTimeout(()=>v(),0),U.current=N.length},[N]),Et(nt);let qt=N.map(x=>l.createElement(X,{key:x.id,timeout:K,onEnter:()=>m.current[x.id].offsetHeight,nodeRef:{current:m.current[x.id]}},zt=>l.createElement(jt,{innerRef:At=>{m.current[x.id]=At},notification:x,onHide:H,className:tt.notification,autoClose:o,sx:[$({},Tt({state:zt,positioning:et,transitionDuration:K,maxHeight:s})),...Array.isArray(x.sx)?x.sx:[x.sx]]})));return l.createElement(A.Provider,{value:nt},l.createElement(mt,{zIndex:u},l.createElement(dt,$({className:Qt(tt.notifications,n),style:f,sx:$({maxWidth:a},gt(et,a,Xt.spacing.md))},d),l.createElement(z,null,qt))),c)}Wt.displayName="@mantine/notifications/NotificationsProvider";export{$t as a,Yt as b,Bt as c,Wt as d};
@@ -1 +1 @@
1
- import{b as F}from"./chunk-UA7UCTX5.js";import{b as S,q as T}from"./chunk-NQ5ARARP.js";import{b as $}from"./chunk-CVGYBXVH.js";import{b as p,d as b}from"./chunk-ORXEMIQC.js";import{b as P}from"./chunk-5MV6XVGA.js";import{f as w}from"./chunk-RPOP6MVJ.js";import{Fa as g,Ga as t,V as N,a as f,ba as l,c as h,e as k,i as R,j as B,la as I}from"./chunk-4CUWZQXT.js";import{d as y,j as x,k as M}from"./chunk-KUCVLANF.js";M();B();var L=x(null);function W(e){let[i,n]=f([]),[o,a]=f(!1),r=k("idle");function u(){r.current==="idle"&&(r.current="fetching",a(!0),F().then(s=>{let c=s.filter(m=>!m.publishedAt&&!m.archivedAt);n(c)}).catch(s=>{console.error("Failed to fetch pending releases:",s)}).finally(()=>{r.current="done",a(!1)}))}function d(s){return i.filter(c=>c.docIds?.includes(s))}return t(L.Provider,{value:{releases:i,getReleasesForDoc:d,loading:o,fetchReleases:u},children:e.children})}function A(){let e=R(L);if(!e)throw new Error("usePendingReleases must be used within a <PendingReleasesProvider>");let{fetchReleases:i,...n}=e;return h(()=>{i()},[]),n}function z(e){let i={transition:"pop"},n=e.doc,o=n.sys;return t("div",{className:"DocStatusBadges",children:[(!o.publishedAt||!o.modifiedAt||o.modifiedAt>o.publishedAt)&&t(g,{...i,label:`Modified ${_(o.modifiedAt)} by ${o.modifiedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Draft"})}),!!o.publishedAt&&t(g,{...i,label:`Published ${_(o.publishedAt)} by ${o.publishedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}),!!o.scheduledAt&&t(g,{...i,label:`Scheduled ${b(o.scheduledAt)} by ${o.scheduledBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}),!e.hideReleases&&t(K,{docId:e.docId||n.id,tooltipProps:i}),T(n)&&t(g,{...i,label:O(n),children:t(l,{size:"xs",variant:"gradient",gradient:{from:"orange",to:"red"},className:e.onPublishingLockClick?"DocStatusBadges__badge--clickable":void 0,style:e.onPublishingLockClick?{cursor:"pointer"}:void 0,role:e.onPublishingLockClick?"button":void 0,tabIndex:e.onPublishingLockClick?0:void 0,onClick:e.onPublishingLockClick,onKeyDown:e.onPublishingLockClick?a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e.onPublishingLockClick())}:void 0,children:"Locked"})}),!!o.archivedAt&&t(g,{...i,label:`Archived ${_(o.archivedAt)} by ${o.archivedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"gray",to:"dark"},children:"Archived"})})]})}function O(e){let i=e.sys?.publishingLocked;return i?i.until?`Locked until ${b(i.until)} by ${i.lockedBy}: "${i.reason}"`:`Locked by ${i.lockedBy}: "${i.reason}"`:""}function K(e){let{getReleasesForDoc:i}=A(),n=i(e.docId);return n.length===0?null:t(y,{children:n.map(o=>t(g,{...e.tooltipProps,label:`In release: ${o.id}`,children:t(l,{component:"a",href:`/cms/releases/${o.id}`,size:"xs",variant:"gradient",gradient:{from:"violet",to:"grape"},style:{cursor:"pointer"},children:o.id})},o.id))})}function _(e){return e?p(e.toMillis()):p(new Date().getTime())}function E(e){let{file:i,width:n,height:o,withPlaceholder:a,className:r,alt:u}=e,d=typeof i=="string"?i:i?.src;return U(i)?t(X,{className:r,src:d,width:n,height:o}):t(I,{className:r,src:d,width:n,height:o,withPlaceholder:a,alt:u})}function U(e){if(!e)return!1;if(typeof e=="string")return/\.mp4($|\?)/i.test(e);if(typeof e.mimeType=="string")return e.mimeType.toLowerCase()==="video/mp4";let i=e.src;return typeof i!="string"?!1:/\.mp4($|\?)/i.test(i)}function X(e){return t("video",{className:e.className,src:e.src,width:e.width,height:e.height,muted:!0,playsInline:!0,preload:"metadata",style:{width:`${e.width}px`,height:`${e.height}px`,backgroundColor:"#f1f3f5",objectFit:"cover",display:"block"}})}B();function De(e){let i=e.docId,[n,o]=f(e.doc),[a,r]=f(!e.doc);async function u(){r(!0),await $(async()=>{let V=await S(i);o(V)}),r(!1)}if(h(()=>{u()},[i]),a)return t("div",{className:w(e.className,"DocPreviewCard","DocPreviewCard--loading",e.variant&&`DocPreviewCard--${e.variant}`),children:t(N,{color:"gray",size:"sm"})});if(!n)return;let[d]=i.split("/"),s=n.fields||{},c=window.__ROOT_CTX.collections[d];if(!c)return console.error(`could not find collection: ${d}`),t("div",{className:"DocPreviewCard",children:["Collection ",t("b",{children:d})," not found."]});let m=P(s,c.preview?.title||"meta.title"),C=P(s,c.preview?.image||"meta.image")||c.preview?.defaultImage,D="div",v={};return e.clickable&&(D="a",v.href=`/cms/content/${e.docId}`,v.target="_blank"),t(D,{className:w(e.className,"DocPreviewCard",e.variant&&`DocPreviewCard--${e.variant}`),...v,children:[t("div",{className:"DocPreviewCard__image",children:t(E,{file:C,width:80,height:60,withPlaceholder:!C?.src})}),t("div",{className:"DocPreviewCard__content",children:[t("div",{className:"DocPreviewCard__content__header",children:t("div",{className:"DocPreviewCard__content__header__docId",children:n.id})}),t("div",{className:"DocPreviewCard__content__title",children:m||"[UNTITLED]"}),e.statusBadges&&n&&t("div",{className:"DocPreviewCard__content__badges",children:t(z,{doc:n,hideReleases:e.hideReleases})})]})]})}export{W as a,A as b,z as c,O as d,E as e,De as f};
1
+ import{c as F}from"./chunk-AZCGXQTL.js";import{b as P}from"./chunk-5MV6XVGA.js";import{N as T,b as S}from"./chunk-TFB3VGWP.js";import{b as $}from"./chunk-J5E457OI.js";import{b as p,d as b}from"./chunk-KRNQ6L35.js";import{f as w}from"./chunk-YLSRRNSE.js";import{Fa as g,Ga as t,V as N,a as f,ba as l,c as h,e as k,i as R,j as B,la as I}from"./chunk-LROR6N3B.js";import{d as y,j as x,k as M}from"./chunk-KUCVLANF.js";M();B();var L=x(null);function W(e){let[i,n]=f([]),[o,a]=f(!1),r=k("idle");function u(){r.current==="idle"&&(r.current="fetching",a(!0),F().then(s=>{let c=s.filter(m=>!m.publishedAt&&!m.archivedAt);n(c)}).catch(s=>{console.error("Failed to fetch pending releases:",s)}).finally(()=>{r.current="done",a(!1)}))}function d(s){return i.filter(c=>c.docIds?.includes(s))}return t(L.Provider,{value:{releases:i,getReleasesForDoc:d,loading:o,fetchReleases:u},children:e.children})}function A(){let e=R(L);if(!e)throw new Error("usePendingReleases must be used within a <PendingReleasesProvider>");let{fetchReleases:i,...n}=e;return h(()=>{i()},[]),n}function z(e){let i={transition:"pop"},n=e.doc,o=n.sys;return t("div",{className:"DocStatusBadges",children:[(!o.publishedAt||!o.modifiedAt||o.modifiedAt>o.publishedAt)&&t(g,{...i,label:`Modified ${_(o.modifiedAt)} by ${o.modifiedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Draft"})}),!!o.publishedAt&&t(g,{...i,label:`Published ${_(o.publishedAt)} by ${o.publishedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}),!!o.scheduledAt&&t(g,{...i,label:`Scheduled ${b(o.scheduledAt)} by ${o.scheduledBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}),!e.hideReleases&&t(K,{docId:e.docId||n.id,tooltipProps:i}),T(n)&&t(g,{...i,label:O(n),children:t(l,{size:"xs",variant:"gradient",gradient:{from:"orange",to:"red"},className:e.onPublishingLockClick?"DocStatusBadges__badge--clickable":void 0,style:e.onPublishingLockClick?{cursor:"pointer"}:void 0,role:e.onPublishingLockClick?"button":void 0,tabIndex:e.onPublishingLockClick?0:void 0,onClick:e.onPublishingLockClick,onKeyDown:e.onPublishingLockClick?a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e.onPublishingLockClick())}:void 0,children:"Locked"})}),!!o.archivedAt&&t(g,{...i,label:`Archived ${_(o.archivedAt)} by ${o.archivedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"gray",to:"dark"},children:"Archived"})})]})}function O(e){let i=e.sys?.publishingLocked;return i?i.until?`Locked until ${b(i.until)} by ${i.lockedBy}: "${i.reason}"`:`Locked by ${i.lockedBy}: "${i.reason}"`:""}function K(e){let{getReleasesForDoc:i}=A(),n=i(e.docId);return n.length===0?null:t(y,{children:n.map(o=>t(g,{...e.tooltipProps,label:`In release: ${o.id}`,children:t(l,{component:"a",href:`/cms/releases/${o.id}`,size:"xs",variant:"gradient",gradient:{from:"violet",to:"grape"},style:{cursor:"pointer"},children:o.id})},o.id))})}function _(e){return e?p(e.toMillis()):p(new Date().getTime())}function E(e){let{file:i,width:n,height:o,withPlaceholder:a,className:r,alt:u}=e,d=typeof i=="string"?i:i?.src;return U(i)?t(X,{className:r,src:d,width:n,height:o}):t(I,{className:r,src:d,width:n,height:o,withPlaceholder:a,alt:u})}function U(e){if(!e)return!1;if(typeof e=="string")return/\.mp4($|\?)/i.test(e);if(typeof e.mimeType=="string")return e.mimeType.toLowerCase()==="video/mp4";let i=e.src;return typeof i!="string"?!1:/\.mp4($|\?)/i.test(i)}function X(e){return t("video",{className:e.className,src:e.src,width:e.width,height:e.height,muted:!0,playsInline:!0,preload:"metadata",style:{width:`${e.width}px`,height:`${e.height}px`,backgroundColor:"#f1f3f5",objectFit:"cover",display:"block"}})}B();function De(e){let i=e.docId,[n,o]=f(e.doc),[a,r]=f(!e.doc);async function u(){r(!0),await $(async()=>{let V=await S(i);o(V)}),r(!1)}if(h(()=>{u()},[i]),a)return t("div",{className:w(e.className,"DocPreviewCard","DocPreviewCard--loading",e.variant&&`DocPreviewCard--${e.variant}`),children:t(N,{color:"gray",size:"sm"})});if(!n)return;let[d]=i.split("/"),s=n.fields||{},c=window.__ROOT_CTX.collections[d];if(!c)return console.error(`could not find collection: ${d}`),t("div",{className:"DocPreviewCard",children:["Collection ",t("b",{children:d})," not found."]});let m=P(s,c.preview?.title||"meta.title"),C=P(s,c.preview?.image||"meta.image")||c.preview?.defaultImage,D="div",v={};return e.clickable&&(D="a",v.href=`/cms/content/${e.docId}`,v.target="_blank"),t(D,{className:w(e.className,"DocPreviewCard",e.variant&&`DocPreviewCard--${e.variant}`),...v,children:[t("div",{className:"DocPreviewCard__image",children:t(E,{file:C,width:80,height:60,withPlaceholder:!C?.src})}),t("div",{className:"DocPreviewCard__content",children:[t("div",{className:"DocPreviewCard__content__header",children:t("div",{className:"DocPreviewCard__content__header__docId",children:n.id})}),t("div",{className:"DocPreviewCard__content__title",children:m||"[UNTITLED]"}),e.statusBadges&&n&&t("div",{className:"DocPreviewCard__content__badges",children:t(z,{doc:n,hideReleases:e.hideReleases})})]})]})}export{W as a,A as b,z as c,O as d,E as e,De as f};
@@ -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-OWQL5DVE.js";import{c as N,e as L}from"./chunk-R6B3W5AJ.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 @@
1
+ import{f as e}from"./chunk-YLSRRNSE.js";import{Ga as o}from"./chunk-LROR6N3B.js";function n(r){return o("div",{className:e(r.className,"Surface"),children:r.children})}export{n as a};
@@ -1 +1 @@
1
- import{d as Xe}from"./chunk-IKED2IGU.js";import{f as He}from"./chunk-4IXGYXA2.js";import{a as Le,b as $e,d as Ve,i as Se}from"./chunk-UA7UCTX5.js";import{a as Ke,b as eo}from"./chunk-TDKVKTW4.js";import{a as Je}from"./chunk-D37DCENS.js";import{a as N,c as H}from"./chunk-KPJ53X55.js";import{a as _e,b as ge,c as ae}from"./chunk-JDW4UORS.js";import{d as ye,h as ve,i as xe,j as Ce,k as Ie,l as le,m as ke,n as Ae,o as we,p as De,q as Te,r as Re,s as Pe,v as de,w as Ne,x as ze}from"./chunk-NQ5ARARP.js";import{b as be,e as Me}from"./chunk-UFQSZ6J2.js";import{b as U}from"./chunk-CVGYBXVH.js";import{a as _,b as F}from"./chunk-AXETBZ6T.js";import{a as M}from"./chunk-N5Y5OWTV.js";import{e as he}from"./chunk-ORXEMIQC.js";import{d as fe}from"./chunk-RPOP6MVJ.js";import{$ as ue,$b as Y,Da as pe,Ga as e,Ha as Ee,Ka as Ue,La as Be,Lb as je,Na as Oe,Oc as Ge,Qa as Fe,V as J,W as Q,a as c,ac as ee,c as j,da as b,e as ce,ea as ie,fc as Qe,hc as Ye,ib as qe,j as X,lb as K,qa as P,tb as We,ua as me,vc as Ze,xa as ne}from"./chunk-4CUWZQXT.js";import{d as S}from"./chunk-KUCVLANF.js";X();var oo="AddToReleaseModal";function so(s){let t=N(),u=H();return{open:()=>{t.openContextModal(oo,{...u,title:"Add docs to a release",innerProps:s,size:"600px"})}}}function mo(s){let{innerProps:t,context:u,id:l}=s,d=N(),[o,y]=c(""),[p,v]=c(!1),[m,k]=c(!1),[g,A]=c([]),[a,D]=c(""),[x,T]=c(Se()),[w,f]=c("");j(()=>{async function n(){v(!0),await U(async()=>{let E=(await $e()).filter(R=>!R.publishedAt&&!R.archivedAt);A(E)}),v(!1)}n()},[]);async function I(){o==="new"?await L():o==="existing"&&await $()}async function L(){if(!x){_({title:"Missing ID",message:"Please enter a release ID.",color:"red",autoClose:5e3});return}if(!_e(x)){_({title:"Invalid ID",message:"Release ID must use alphanumeric characters and dashes only.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let n={docIds:t.docIds};w&&(n.description=w),await Le(x,n),_({title:`Release created: ${x}`,message:e("span",{children:["Created release with ",t.docIds.length," doc(s)."," ",e("a",{href:`/cms/releases/${x}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}async function $(){if(!a){_({title:"No release selected",message:"Please select a release.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let C=g.find(z=>z.id===a)?.docIds||[],E=Array.from(new Set([...C,...t.docIds])).sort();await Ve(a,{docIds:E});let R=E.length-C.length;_({title:`Docs added to release: ${a}`,message:e("span",{children:["Added ",R," new doc(s) to release."," ",e("a",{href:`/cms/releases/${a}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}let r=!0;return(o==="new"&&x||o==="existing"&&a)&&(r=!1),e("div",{className:"AddToReleaseModal",children:e("div",{className:"AddToReleaseModal__content",children:[e("div",{className:"AddToReleaseModal__docs",children:[e("div",{className:"AddToReleaseModal__docs__label",children:["Docs to add (",t.docIds.length,")"]}),e("div",{className:"AddToReleaseModal__docs__list",children:t.docIds.map(n=>e(He,{docId:n,variant:"compact",statusBadges:!0},n))})]}),e("div",{className:"AddToReleaseModal__mode",children:[e("label",{className:`AddToReleaseModal__mode__option${o==="new"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"new",checked:o==="new",onChange:()=>y("new")})," ","New release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Create a new release with these docs."})]}),e("label",{className:`AddToReleaseModal__mode__option${o==="existing"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"existing",checked:o==="existing",onChange:()=>y("existing")})," ","Existing release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Add to an existing release."})]})]}),o==="new"&&e("div",{className:"AddToReleaseModal__form",children:[e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Release ID"}),e("input",{type:"text",placeholder:"e.g. my-release",value:x,onInput:n=>{T(n.target.value)}})]}),e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Description (optional)"}),e("textarea",{rows:2,placeholder:"Describe this release",value:w,onInput:n=>{f(n.target.value)}})]})]}),o==="existing"&&e("div",{className:"AddToReleaseModal__releases",children:p?e("div",{className:"AddToReleaseModal__releases__empty",children:e(J,{color:"gray",size:"sm"})}):g.length===0?e("div",{className:"AddToReleaseModal__releases__empty",children:"No unpublished releases found. Create a new one instead."}):g.map(n=>e("div",{className:`AddToReleaseModal__release${a===n.id?" AddToReleaseModal__release--selected":""}`,onClick:()=>D(n.id),children:[e("input",{type:"radio",name:"existing-release",checked:a===n.id,onChange:()=>D(n.id)}),e("div",{className:"AddToReleaseModal__release__info",children:[e("div",{className:"AddToReleaseModal__release__info__id",children:n.id}),n.description&&e("div",{className:"AddToReleaseModal__release__info__description",children:n.description})]}),e("div",{className:"AddToReleaseModal__release__docCount",children:[n.docIds?.length||0," doc(s)"]})]},n.id))}),e("div",{className:"AddToReleaseModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",disabled:r,loading:m,onClick:I,children:o==="new"?"Create release":"Add to release"})]})]})})}mo.id=oo;X();var to="CopyDocModal";function oe(s){let t=N(),u=H();return{open:l=>{t.openContextModal(to,{...u,innerProps:{...s,...l}})}}}function po(s){let{innerProps:t,context:u,id:l}=s,{route:d}=fe(),[o,y]=c(""),[p,v]=c(""),[m,k]=c(""),[g,A]=c(""),[a,D]=c(!1),[x,T]=c(!1),[w,f]=c({}),I=t.fromDocId,L=I.split("/")[0],$=t.fromLabel||I;j(()=>{be({tags:[I]}).then(f)},[I]);function r(C,E){let R=ae(C),z=window.__ROOT_CTX.collections[E]?.slugRegex;return R?ge(R,z):""}async function n(C){if(C.preventDefault(),T(!0),A(""),!L){A("Please select a collection."),T(!1);return}if(r(p,o)){T(!1);return}let R=ae(p),z=`${o}/${R}`;try{t.fields?await Pe(z,{fields:t.fields,overwrite:a}):await Re(I,z,{overwrite:a});let O=Object.keys(w);if(O.length>0){let i=O.map(h=>({hash:h,tags:[z]}));await Me(i,{mode:"union"})}u.closeModal(l);let q=`/cms/content/${o}/${R}`;_({title:"Copied!",message:e("div",{children:[e("div",{children:`Successfully copied ${$} to ${z}.`}),e(b,{className:"CopyDocModal__notificationButton",component:"a",href:q,size:"xs",compact:!0,variant:"default",children:"Open doc"})]}),autoClose:1e4}),t.onSuccess&&t.onSuccess(z)}catch(O){let q=String(O);A(q),q.includes("already exists")&&D(!0),T(!1);return}T(!1),d(`/cms/content/${o}/${R}`)}return e("div",{className:"CopyDocModal",children:e("form",{onSubmit:C=>n(C),children:[e("div",{className:"CopyDocModal__from",children:[e(M,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),e(M,{className:"CopyDocModal__from__value",size:"body-sm",children:e("code",{children:$})})]}),e("div",{className:"CopyDocModal__to",children:[e(M,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),e(Xe,{className:"CopyDocModal__slug",collectionId:L,onChange:C=>{y(C.collectionId),v(C.slug),k(r(C.slug,C.collectionId)),A(""),D(!1)}})]}),g&&e("div",{className:"CopyDocModal__error",children:g}),e("div",{className:"CopyDocModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:x,disabled:!!m||!!g&&!a,children:a?"Overwrite?":"Submit"})]})]})})}po.id=to;X();function B(s){return e("div",{className:"DocIdBadge",children:e("code",{"data-testid":"doc-id",children:s.docId})})}var io="LockPublishingModal";function no(s){let t=N(),u=H();return{open:l=>{let d={...s,...l},o;d.unlock?o=`Unlock publishing for ${s.docId}`:d.existingLock?o=`Edit publishing lock for ${s.docId}`:o=`Lock publishing for ${s.docId}`,t.openContextModal(io,{...u,title:o,innerProps:{...s,...l},size:"600px"})}}}function fo(s){let t=l=>l<10?"0"+l:l,u=new Date(s);return`${u.getFullYear()}-${t(u.getMonth()+1)}-${t(u.getDate())}T${t(u.getHours())}:${t(u.getMinutes())}`}function Z(s){let{innerProps:t}=s;return t.unlock?e(Z.Unlock,{...s}):e(Z.Lock,{...s})}Z.Lock=s=>{let{innerProps:t,context:u,id:l}=s,d=!!t.existingLock,[o,y]=c(t.existingLock?.reason||""),[p,v]=c(t.existingLock?.until||0),[m,k]=c(!1),[g,A]=c(!1),a=N();function D(f){return f?Math.floor(new Date(f).getTime()):0}async function x(f){f.preventDefault(),k(!0),await U(async()=>{await Ie(t.docId,{reason:o,until:p}),_({title:d?"Updated!":"Locked!",message:d?`Publishing lock updated for ${t.docId}.`:`Publishing is locked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("locked")}),k(!1)}async function T(){A(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("unlocked")}),A(!1)}return e("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[e(M,{className:"LockPublishingModal__body",size:"body-sm",children:d?"Publishing is currently locked. Update the publishing lock details below, or remove the lock to re\u2011enable publishing.":"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),e("form",{className:"LockPublishingModal__form",onSubmit:f=>x(f),children:[e("div",{className:"LockPublishingModal__form__section",children:e(me,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,value:o,onChange:f=>{y(f.currentTarget.value)}})}),e("div",{className:"LockPublishingModal__form__section",children:e(ue,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:e("div",{className:"DocEditor__DateTimeField",children:[e("input",{name:"until",type:"datetime-local",min:he(),defaultValue:p?fo(p):"",onChange:f=>{let L=f.target.value;v(D(L))}}),e("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),e("div",{className:"LockPublishingModal__buttons",children:[d&&e(b,{variant:"filled",size:"xs",color:"red",type:"button",leftIcon:e(Y,{size:14}),loading:g,disabled:m,onClick:()=>T(),className:"LockPublishingModal__buttons__unlock",children:"Unlock"}),e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(ee,{size:14}),disabled:!o||g,type:"submit",loading:m,children:d?"Save":"Lock"})]})]})]})};Z.Unlock=s=>{let{innerProps:t,context:u,id:l}=s,[d,o]=c(!1),y=N();async function p(){o(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),y.closeModal(l),t.onChange&&t.onChange("unlocked")})}return e("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[e(M,{className:"LockPublishingModal__body",children:"Are you sure you want to unlock publishing for the following doc? This will re-enable content editors to publish the doc."}),e(B,{docId:t.docId}),e("div",{className:"LockPublishingModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(Y,{size:14}),loading:d,onClick:()=>p(),children:"Unlock"})]})]})};Z.id=io;X();var ro="VersionHistoryModal",ao=50;function co(s){let t=N(),u=H();return{open:()=>{t.openContextModal(ro,{...u,title:`Version history: ${s.docId}`,innerProps:s,overflow:"inside",size:"min(calc(100% - 32px), 720px)"})}}}function _o(s){let{innerProps:t,context:u,id:l}=s,d=t.docId,[o,y]=c(!0),[p,v]=c(!1),[m,k]=c([]),[g,A]=c(!1),[a,D]=c([]),[x,T]=c(!1),[w,f]=c(null),I=ce(null),L=oe({fromDocId:d}),$=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function r(){y(!0);let[i,h]=await Promise.all([de(d,{limit:ao}),ze(d,"draft")]);I.current=i.lastDoc,A(i.hasMore);let V={_versionId:"draft",sys:{modifiedAt:h?.sys?.modifiedAt||{toDate:()=>new Date},modifiedBy:h?.sys?.modifiedBy||"Unknown"}};k([V,...i.versions]),D(["draft"]),y(!1)}async function n(){if(!g||p)return;v(!0);let i=await de(d,{limit:ao,cursor:I.current});I.current=i.lastDoc,A(i.hasMore),k(h=>[...h,...i.versions]),v(!1)}async function C(i){await Ne(d,i),_({title:"Saved!",message:`Restored ${d} to ${$.format(i.sys.modifiedAt.toDate())}.`,autoClose:5e3}),t.onRestore&&t.onRestore({version:i})}function E(i){let h=`${d}@${i._versionId}`,V=i.sys?.modifiedAt?.toDate();if(V){let W=go(V);h=`${d}@${W}`}L.open({fields:i.fields||{},fromLabel:h,onSuccess:()=>{u.closeModal(l)}})}function R(i){a.includes(i)?D(a.filter(h=>h!==i)):a.length<2&&D([...a,i])}function z(){if(a.length!==2)return"#";let i=m.find(te=>te._versionId===a[0]),h=m.find(te=>te._versionId===a[1]);if(!i||!h)return"#";let V=m.indexOf(i),W=m.indexOf(h),re=V>W?i:h,G=V>W?h:i,se=lo(d,re._versionId),uo=lo(d,G._versionId);return`/cms/compare?left=${se}&right=${uo}`}j(()=>{r()},[]);let O=m.filter(i=>i._versionId==="draft"||!x?!0:i.tags?.includes("published")),q=m.some(i=>i.tags?.includes("published"));return o?e(J,{}):e("div",{className:"VersionHistoryModal",children:[e("div",{className:"VersionHistoryModal__actions",children:[e(b,{component:a.length===2?"a":"button",variant:"filled",size:"xs",disabled:a.length!==2,href:a.length===2?z():void 0,target:a.length===2?"_blank":void 0,rightIcon:e(Fe,{size:16}),children:"Compare"}),q&&e(ie,{size:"xs",label:"Published versions only",checked:x,onChange:i=>T(i.currentTarget.checked)})]}),O.length===0?e(M,{className:"VersionHistoryModal__versionsEmpty",size:"body",children:[e("p",{children:"No versions found."}),e("p",{className:"VersionHistoryModal__versionsEmpty__developer",children:"For developers: Configure the Root CMS cron job to populate versions."})]}):e(S,{children:[e(pe,{className:"VersionHistoryModal__versions",children:[e("thead",{children:e("tr",{children:[e("th",{children:e("span",{className:"VersionHistoryModal__versions__selectLabel",children:"Select"})}),e("th",{children:"modified at"}),e("th",{children:"modified by"}),e("th",{children:"actions"})]})}),e("tbody",{children:O.map(i=>{let h=i._versionId==="draft",V=a.includes(i._versionId),W=!V&&a.length>=2;return e("tr",{children:[e("td",{children:e(ie,{size:"xs",checked:V,disabled:W,onChange:()=>R(i._versionId),className:"VersionHistoryModal__versions__checkbox"})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__modifiedAt",children:[e(M,{size:"body-sm",className:"VersionHistoryModal__versions__modifiedAt__text",children:h?e("span",{title:"Current Draft",children:[$.format(i.sys.modifiedAt.toDate())," ","(Latest)"]}):e(S,{children:[$.format(i.sys.modifiedAt.toDate()),i.tags?.includes("published")&&e("span",{className:"VersionHistoryModal__publishedLabel",children:"(Published)"})]})}),i.publishMessage&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-message`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,classNames:{body:"VersionHistoryModal__popover__body",arrow:"VersionHistoryModal__popover__arrow",close:"VersionHistoryModal__popover__close"},target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-message`?null:`${i._versionId}-message`),children:e(Qe,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:i.publishMessage})}),(()=>{let G=i.tags?.find(se=>se.startsWith("release:"))?.replace("release:","");return G&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-release`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-release`?null:`${i._versionId}-release`),children:e(Ze,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:[e("strong",{children:"Release:"})," ",G]})})})()]})}),e("td",{children:e(M,{size:"body-sm",children:i.sys.modifiedBy})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__buttons",children:!h&&e(S,{children:[e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>C(i),children:"restore"}),e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>E(i),leftIcon:e(K,{size:12}),children:"copy to doc"})]})})})]},i._versionId)})})]}),g&&e("div",{className:"VersionHistoryModal__loadMore",children:e(b,{variant:"subtle",size:"xs",loading:p,onClick:n,children:"Load more versions"})})]})]})}function lo(s,t){return encodeURIComponent(`${s}@${t}`).replaceAll("%2F","/").replaceAll("%40","@")}function go(s){let t=s.getFullYear(),u=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),d=String(s.getHours()).padStart(2,"0"),o=String(s.getMinutes()).padStart(2,"0");return`${t}-${u}-${l}T${d}:${o}`}_o.id=ro;function Js(s){let{roles:t}=Je(),u=window.firebase.user.email||"",l=eo(t,u),d=Ke(t,u),o=s.docId,y=s.data||{},p=y.sys||{},v=we(y),m=N(),k=oe({fromDocId:o,onSuccess:r=>{s.onAction&&s.onAction({action:"copy",newDocId:r})}}),g=H(),A=co({docId:o}),a=no({docId:o}),D=so({docIds:[o]}),x=()=>{let r=`revert-draft-${o}`,n=m.openConfirmModal({...g,title:`Discard draft edits for ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to discard draft changes for the following doc? The doc data will revert to the published version. There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Discard draft edits",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Discarding draft edits",message:`Discarding draft edits of ${o}...`,loading:!0,autoClose:!1}),await xe(o),F({id:r,title:"Discarded draft edits",message:`Successfully reverted ${o} back to its published version`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"revert-draft"})}})},T=()=>{let r=`unpublish-doc-${o}`,n=m.openConfirmModal({...g,title:`Unpublish ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unpublish the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unpublishing doc",message:`Requesting unpublish of ${o}...`,loading:!0,autoClose:!1}),await ve(o),F({id:r,title:"Unpublished!",message:`Successfully unpublished ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unpublish"})}})},w=r=>{s.onAction&&s.onAction({action:r})},f=()=>{let r=`unschedule-doc-${o}`,n=m.openConfirmModal({...g,title:`Unschedule ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unschedule the following doc?"}),e(B,{docId:o})]}),labels:{confirm:"Unschedule",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unschedule doc",message:`Requesting unschedule of ${o}...`,loading:!0,autoClose:!1}),await Ce(o),F({id:r,title:"Unscheduled!",message:`Successfully unscheduled ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unschedule"})}})},I=()=>{let r=`archive-doc-${o}`,n=m.openConfirmModal({...g,title:`Archive ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to archive the following doc? Archived docs are hidden from the collection list by default but can be restored later."}),e(B,{docId:o})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Archiving doc",message:`Requesting archive of ${o}...`,loading:!0,autoClose:!1}),await ke(o),F({id:r,title:"Archived!",message:`Successfully archived ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"archive"})}})},L=async()=>{let r=`unarchive-doc-${o}`;_({id:r,title:"Unarchiving doc",message:`Requesting unarchive of ${o}...`,loading:!0,autoClose:!1}),await Ae(o),F({id:r,title:"Unarchived!",message:`Successfully unarchived ${o}!`,loading:!1,autoClose:5e3}),s.onAction&&s.onAction({action:"unarchive"})},$=()=>{let r=`delete-doc-${o}`,n=m.openConfirmModal({...g,title:"Delete doc",children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to delete the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Deleting doc",message:`Requesting deletion of ${o}...`,loading:!0,autoClose:!1}),await ye(o),F({id:r,title:"Deleted!",message:`Successfully deleted ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onDelete&&s.onDelete(),s.onAction&&s.onAction({action:"delete"})}})};return e(P,{className:"CollectionPage__collection__docsList__doc__controls__menu",position:"bottom",control:e(Q,{className:"DocEditor__ArrayField__item__header__controls__dots",children:e(We,{size:16})}),children:[!v&&e(P.Item,{icon:e(Ye,{size:20}),onClick:()=>D.open(),disabled:!d,children:"Add to release"}),e(P.Item,{icon:e(je,{size:20}),onClick:()=>A.open(),children:"Version history"}),e(P.Item,{icon:e(K,{size:20}),onClick:()=>k.open(),disabled:!l,children:"Copy"}),!v&&p.modifiedAt&&p.publishedAt&&p.modifiedAt>p.publishedAt&&e(P.Item,{icon:e(Oe,{size:20}),onClick:()=>x(),disabled:!l,children:"Discard draft edits"}),!v&&p.firstPublishedAt&&e(P.Item,{icon:e(qe,{size:20}),onClick:()=>T(),disabled:!d,children:"Unpublish"}),!v&&p.scheduledAt&&e(P.Item,{icon:e(Ee,{size:20}),onClick:()=>f(),disabled:!d,children:"Unschedule"}),!v&&(Te(y)?e(P.Item,{icon:e(Y,{size:20}),onClick:()=>a.open({unlock:!0,onChange:w}),disabled:!l,children:"Unlock publishing"}):e(P.Item,{icon:e(ee,{size:20}),onClick:()=>a.open({unlock:!1,onChange:w}),disabled:!l||De(y),children:"Lock publishing"})),v?e(P.Item,{icon:e(Ue,{size:20}),onClick:()=>L(),disabled:!l,children:"Unarchive"}):!p.publishedAt&&e(P.Item,{icon:e(Be,{size:20}),onClick:()=>I(),disabled:!l,children:"Archive"}),e(P.Item,{icon:e(Ge,{size:20}),onClick:()=>$(),disabled:!l,children:"Delete"})]})}export{so as a,mo as b,po as c,B as d,no as e,Z as f,_o as g,Js as h};
1
+ import{d as eo}from"./chunk-OWQL5DVE.js";import{f as He}from"./chunk-R6B3W5AJ.js";import{b as Le,c as $e,e as Ve,j as Se}from"./chunk-AZCGXQTL.js";import{a as N,c as H}from"./chunk-HARRKJFZ.js";import{a as _e,b as ge,c as ae}from"./chunk-JDW4UORS.js";import{A as ye,E as ve,F as xe,G as Ce,H as Ie,I as le,J as ke,K as Ae,L as we,M as De,N as Te,O as Re,P as Pe,S as de,T as Ne,U as ze}from"./chunk-TFB3VGWP.js";import{b as be,e as Me}from"./chunk-ZN2Y5OUF.js";import{a as Je,b as Ke}from"./chunk-W5DOO6ID.js";import{a as Xe}from"./chunk-NSOTG64N.js";import{b as U}from"./chunk-J5E457OI.js";import{a as _,b as F}from"./chunk-QHJOTXYB.js";import{a as M}from"./chunk-O5P3CPJ4.js";import{e as he}from"./chunk-KRNQ6L35.js";import{d as fe}from"./chunk-YLSRRNSE.js";import{$ as ue,Da as pe,Ga as e,Ha as Ee,Ka as Ue,La as Be,Na as Oe,Nb as je,Qa as Fe,Rc as Ge,V as J,W as Q,a as c,c as j,cc as Y,da as b,dc as ee,e as ce,ea as ie,ib as qe,ic as Qe,j as X,kc as Ye,lb as K,qa as P,tb as We,ua as me,xa as ne,yc as Ze}from"./chunk-LROR6N3B.js";import{d as S}from"./chunk-KUCVLANF.js";X();var oo="AddToReleaseModal";function so(s){let t=N(),u=H();return{open:()=>{t.openContextModal(oo,{...u,title:"Add docs to a release",innerProps:s,size:"600px"})}}}function mo(s){let{innerProps:t,context:u,id:l}=s,d=N(),[o,y]=c(""),[p,v]=c(!1),[m,k]=c(!1),[g,A]=c([]),[a,D]=c(""),[x,T]=c(Se()),[w,f]=c("");j(()=>{async function n(){v(!0),await U(async()=>{let E=(await $e()).filter(R=>!R.publishedAt&&!R.archivedAt);A(E)}),v(!1)}n()},[]);async function I(){o==="new"?await L():o==="existing"&&await $()}async function L(){if(!x){_({title:"Missing ID",message:"Please enter a release ID.",color:"red",autoClose:5e3});return}if(!_e(x)){_({title:"Invalid ID",message:"Release ID must use alphanumeric characters and dashes only.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let n={docIds:t.docIds};w&&(n.description=w),await Le(x,n),_({title:`Release created: ${x}`,message:e("span",{children:["Created release with ",t.docIds.length," doc(s)."," ",e("a",{href:`/cms/releases/${x}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}async function $(){if(!a){_({title:"No release selected",message:"Please select a release.",color:"red",autoClose:5e3});return}k(!0),await U(async()=>{let C=g.find(z=>z.id===a)?.docIds||[],E=Array.from(new Set([...C,...t.docIds])).sort();await Ve(a,{docIds:E});let R=E.length-C.length;_({title:`Docs added to release: ${a}`,message:e("span",{children:["Added ",R," new doc(s) to release."," ",e("a",{href:`/cms/releases/${a}`,children:"View release"})]}),autoClose:1e4}),d.closeAll()}),k(!1)}let r=!0;return(o==="new"&&x||o==="existing"&&a)&&(r=!1),e("div",{className:"AddToReleaseModal",children:e("div",{className:"AddToReleaseModal__content",children:[e("div",{className:"AddToReleaseModal__docs",children:[e("div",{className:"AddToReleaseModal__docs__label",children:["Docs to add (",t.docIds.length,")"]}),e("div",{className:"AddToReleaseModal__docs__list",children:t.docIds.map(n=>e(He,{docId:n,variant:"compact",statusBadges:!0},n))})]}),e("div",{className:"AddToReleaseModal__mode",children:[e("label",{className:`AddToReleaseModal__mode__option${o==="new"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"new",checked:o==="new",onChange:()=>y("new")})," ","New release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Create a new release with these docs."})]}),e("label",{className:`AddToReleaseModal__mode__option${o==="existing"?" AddToReleaseModal__mode__option--selected":o?" AddToReleaseModal__mode__option--unselected":""}`,children:[e("div",{className:"AddToReleaseModal__mode__option__input",children:[e("input",{type:"radio",name:"release-mode",value:"existing",checked:o==="existing",onChange:()=>y("existing")})," ","Existing release"]}),e("div",{className:"AddToReleaseModal__mode__option__help",children:"Add to an existing release."})]})]}),o==="new"&&e("div",{className:"AddToReleaseModal__form",children:[e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Release ID"}),e("input",{type:"text",placeholder:"e.g. my-release",value:x,onInput:n=>{T(n.target.value)}})]}),e("div",{className:"AddToReleaseModal__form__field",children:[e("label",{children:"Description (optional)"}),e("textarea",{rows:2,placeholder:"Describe this release",value:w,onInput:n=>{f(n.target.value)}})]})]}),o==="existing"&&e("div",{className:"AddToReleaseModal__releases",children:p?e("div",{className:"AddToReleaseModal__releases__empty",children:e(J,{color:"gray",size:"sm"})}):g.length===0?e("div",{className:"AddToReleaseModal__releases__empty",children:"No unpublished releases found. Create a new one instead."}):g.map(n=>e("div",{className:`AddToReleaseModal__release${a===n.id?" AddToReleaseModal__release--selected":""}`,onClick:()=>D(n.id),children:[e("input",{type:"radio",name:"existing-release",checked:a===n.id,onChange:()=>D(n.id)}),e("div",{className:"AddToReleaseModal__release__info",children:[e("div",{className:"AddToReleaseModal__release__info__id",children:n.id}),n.description&&e("div",{className:"AddToReleaseModal__release__info__description",children:n.description})]}),e("div",{className:"AddToReleaseModal__release__docCount",children:[n.docIds?.length||0," doc(s)"]})]},n.id))}),e("div",{className:"AddToReleaseModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",disabled:r,loading:m,onClick:I,children:o==="new"?"Create release":"Add to release"})]})]})})}mo.id=oo;X();var to="CopyDocModal";function oe(s){let t=N(),u=H();return{open:l=>{t.openContextModal(to,{...u,innerProps:{...s,...l}})}}}function po(s){let{innerProps:t,context:u,id:l}=s,{route:d}=fe(),[o,y]=c(""),[p,v]=c(""),[m,k]=c(""),[g,A]=c(""),[a,D]=c(!1),[x,T]=c(!1),[w,f]=c({}),I=t.fromDocId,L=I.split("/")[0],$=t.fromLabel||I;j(()=>{be({tags:[I]}).then(f)},[I]);function r(C,E){let R=ae(C),z=window.__ROOT_CTX.collections[E]?.slugRegex;return R?ge(R,z):""}async function n(C){if(C.preventDefault(),T(!0),A(""),!L){A("Please select a collection."),T(!1);return}if(r(p,o)){T(!1);return}let R=ae(p),z=`${o}/${R}`;try{t.fields?await Pe(z,{fields:t.fields,overwrite:a}):await Re(I,z,{overwrite:a});let O=Object.keys(w);if(O.length>0){let i=O.map(h=>({hash:h,tags:[z]}));await Me(i,{mode:"union"})}u.closeModal(l);let q=`/cms/content/${o}/${R}`;_({title:"Copied!",message:e("div",{children:[e("div",{children:`Successfully copied ${$} to ${z}.`}),e(b,{className:"CopyDocModal__notificationButton",component:"a",href:q,size:"xs",compact:!0,variant:"default",children:"Open doc"})]}),autoClose:1e4}),t.onSuccess&&t.onSuccess(z)}catch(O){let q=String(O);A(q),q.includes("already exists")&&D(!0),T(!1);return}T(!1),d(`/cms/content/${o}/${R}`)}return e("div",{className:"CopyDocModal",children:e("form",{onSubmit:C=>n(C),children:[e("div",{className:"CopyDocModal__from",children:[e(M,{className:"CopyDocModal__from__label",size:"body",weight:"bold",children:"From:"}),e(M,{className:"CopyDocModal__from__value",size:"body-sm",children:e("code",{children:$})})]}),e("div",{className:"CopyDocModal__to",children:[e(M,{className:"CopyDocModal__to__label",size:"body",weight:"bold",children:"To:"}),e(eo,{className:"CopyDocModal__slug",collectionId:L,onChange:C=>{y(C.collectionId),v(C.slug),k(r(C.slug,C.collectionId)),A(""),D(!1)}})]}),g&&e("div",{className:"CopyDocModal__error",children:g}),e("div",{className:"CopyDocModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:x,disabled:!!m||!!g&&!a,children:a?"Overwrite?":"Submit"})]})]})})}po.id=to;X();function B(s){return e("div",{className:"DocIdBadge",children:e("code",{"data-testid":"doc-id",children:s.docId})})}var io="LockPublishingModal";function no(s){let t=N(),u=H();return{open:l=>{let d={...s,...l},o;d.unlock?o=`Unlock publishing for ${s.docId}`:d.existingLock?o=`Edit publishing lock for ${s.docId}`:o=`Lock publishing for ${s.docId}`,t.openContextModal(io,{...u,title:o,innerProps:{...s,...l},size:"600px"})}}}function fo(s){let t=l=>l<10?"0"+l:l,u=new Date(s);return`${u.getFullYear()}-${t(u.getMonth()+1)}-${t(u.getDate())}T${t(u.getHours())}:${t(u.getMinutes())}`}function Z(s){let{innerProps:t}=s;return t.unlock?e(Z.Unlock,{...s}):e(Z.Lock,{...s})}Z.Lock=s=>{let{innerProps:t,context:u,id:l}=s,d=!!t.existingLock,[o,y]=c(t.existingLock?.reason||""),[p,v]=c(t.existingLock?.until||0),[m,k]=c(!1),[g,A]=c(!1),a=N();function D(f){return f?Math.floor(new Date(f).getTime()):0}async function x(f){f.preventDefault(),k(!0),await U(async()=>{await Ie(t.docId,{reason:o,until:p}),_({title:d?"Updated!":"Locked!",message:d?`Publishing lock updated for ${t.docId}.`:`Publishing is locked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("locked")}),k(!1)}async function T(){A(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),a.closeModal(l),t.onChange&&t.onChange("unlocked")}),A(!1)}return e("div",{className:"LockPublishingModal LockPublishingModal--lock",children:[e(M,{className:"LockPublishingModal__body",size:"body-sm",children:d?"Publishing is currently locked. Update the publishing lock details below, or remove the lock to re\u2011enable publishing.":"Are you sure you want to lock publishing? Content editors will not be able to publish until publishing is unlocked."}),e("form",{className:"LockPublishingModal__form",onSubmit:f=>x(f),children:[e("div",{className:"LockPublishingModal__form__section",children:e(me,{name:"reason",label:"Reason",description:"Specify a short reason so other content editors know why publishing is locked.",size:"xs",radius:0,value:o,onChange:f=>{y(f.currentTarget.value)}})}),e("div",{className:"LockPublishingModal__form__section",children:e(ue,{label:"Lock until",description:"Optional. Publishing is unlocked at the specified time. If not provided, publishing will be locked indefinitely.",size:"xs",children:e("div",{className:"DocEditor__DateTimeField",children:[e("input",{name:"until",type:"datetime-local",min:he(),defaultValue:p?fo(p):"",onChange:f=>{let L=f.target.value;v(D(L))}}),e("div",{className:"DocEditor__DateTimeField__timezone",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]})})}),e("div",{className:"LockPublishingModal__buttons",children:[d&&e(b,{variant:"filled",size:"xs",color:"red",type:"button",leftIcon:e(Y,{size:14}),loading:g,disabled:m,onClick:()=>T(),className:"LockPublishingModal__buttons__unlock",children:"Unlock"}),e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(ee,{size:14}),disabled:!o||g,type:"submit",loading:m,children:d?"Save":"Lock"})]})]})]})};Z.Unlock=s=>{let{innerProps:t,context:u,id:l}=s,[d,o]=c(!1),y=N();async function p(){o(!0),await U(async()=>{await le(t.docId),_({title:"Unlocked!",message:`Publishing is unlocked for ${t.docId}.`,autoClose:1e4}),y.closeModal(l),t.onChange&&t.onChange("unlocked")})}return e("div",{className:"LockPublishingModal LockPublishingModal--unlock",children:[e(M,{className:"LockPublishingModal__body",children:"Are you sure you want to unlock publishing for the following doc? This will re-enable content editors to publish the doc."}),e(B,{docId:t.docId}),e("div",{className:"LockPublishingModal__buttons",children:[e(b,{variant:"outline",onClick:()=>u.closeModal(l),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(b,{variant:"filled",size:"xs",color:"dark",leftIcon:e(Y,{size:14}),loading:d,onClick:()=>p(),children:"Unlock"})]})]})};Z.id=io;X();var ro="VersionHistoryModal",ao=50;function co(s){let t=N(),u=H();return{open:()=>{t.openContextModal(ro,{...u,title:`Version history: ${s.docId}`,innerProps:s,overflow:"inside",size:"min(calc(100% - 32px), 720px)"})}}}function _o(s){let{innerProps:t,context:u,id:l}=s,d=t.docId,[o,y]=c(!0),[p,v]=c(!1),[m,k]=c([]),[g,A]=c(!1),[a,D]=c([]),[x,T]=c(!1),[w,f]=c(null),I=ce(null),L=oe({fromDocId:d}),$=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function r(){y(!0);let[i,h]=await Promise.all([de(d,{limit:ao}),ze(d,"draft")]);I.current=i.lastDoc,A(i.hasMore);let V={_versionId:"draft",sys:{modifiedAt:h?.sys?.modifiedAt||{toDate:()=>new Date},modifiedBy:h?.sys?.modifiedBy||"Unknown"}};k([V,...i.versions]),D(["draft"]),y(!1)}async function n(){if(!g||p)return;v(!0);let i=await de(d,{limit:ao,cursor:I.current});I.current=i.lastDoc,A(i.hasMore),k(h=>[...h,...i.versions]),v(!1)}async function C(i){await Ne(d,i),_({title:"Saved!",message:`Restored ${d} to ${$.format(i.sys.modifiedAt.toDate())}.`,autoClose:5e3}),t.onRestore&&t.onRestore({version:i})}function E(i){let h=`${d}@${i._versionId}`,V=i.sys?.modifiedAt?.toDate();if(V){let W=go(V);h=`${d}@${W}`}L.open({fields:i.fields||{},fromLabel:h,onSuccess:()=>{u.closeModal(l)}})}function R(i){a.includes(i)?D(a.filter(h=>h!==i)):a.length<2&&D([...a,i])}function z(){if(a.length!==2)return"#";let i=m.find(te=>te._versionId===a[0]),h=m.find(te=>te._versionId===a[1]);if(!i||!h)return"#";let V=m.indexOf(i),W=m.indexOf(h),re=V>W?i:h,G=V>W?h:i,se=lo(d,re._versionId),uo=lo(d,G._versionId);return`/cms/compare?left=${se}&right=${uo}`}j(()=>{r()},[]);let O=m.filter(i=>i._versionId==="draft"||!x?!0:i.tags?.includes("published")),q=m.some(i=>i.tags?.includes("published"));return o?e(J,{}):e("div",{className:"VersionHistoryModal",children:[e("div",{className:"VersionHistoryModal__actions",children:[e(b,{component:a.length===2?"a":"button",variant:"filled",size:"xs",disabled:a.length!==2,href:a.length===2?z():void 0,target:a.length===2?"_blank":void 0,rightIcon:e(Fe,{size:16}),children:"Compare"}),q&&e(ie,{size:"xs",label:"Published versions only",checked:x,onChange:i=>T(i.currentTarget.checked)})]}),O.length===0?e(M,{className:"VersionHistoryModal__versionsEmpty",size:"body",children:[e("p",{children:"No versions found."}),e("p",{className:"VersionHistoryModal__versionsEmpty__developer",children:"For developers: Configure the Root CMS cron job to populate versions."})]}):e(S,{children:[e(pe,{className:"VersionHistoryModal__versions",children:[e("thead",{children:e("tr",{children:[e("th",{children:e("span",{className:"VersionHistoryModal__versions__selectLabel",children:"Select"})}),e("th",{children:"modified at"}),e("th",{children:"modified by"}),e("th",{children:"actions"})]})}),e("tbody",{children:O.map(i=>{let h=i._versionId==="draft",V=a.includes(i._versionId),W=!V&&a.length>=2;return e("tr",{children:[e("td",{children:e(ie,{size:"xs",checked:V,disabled:W,onChange:()=>R(i._versionId),className:"VersionHistoryModal__versions__checkbox"})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__modifiedAt",children:[e(M,{size:"body-sm",className:"VersionHistoryModal__versions__modifiedAt__text",children:h?e("span",{title:"Current Draft",children:[$.format(i.sys.modifiedAt.toDate())," ","(Latest)"]}):e(S,{children:[$.format(i.sys.modifiedAt.toDate()),i.tags?.includes("published")&&e("span",{className:"VersionHistoryModal__publishedLabel",children:"(Published)"})]})}),i.publishMessage&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-message`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,classNames:{body:"VersionHistoryModal__popover__body",arrow:"VersionHistoryModal__popover__arrow",close:"VersionHistoryModal__popover__close"},target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-message`?null:`${i._versionId}-message`),children:e(Qe,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:i.publishMessage})}),(()=>{let G=i.tags?.find(se=>se.startsWith("release:"))?.replace("release:","");return G&&e(ne,{withCloseButton:!0,opened:w===`${i._versionId}-release`,onClose:()=>f(null),position:"right",withArrow:!0,shadow:"md",width:320,target:e(Q,{size:"xs",variant:"light",className:"VersionHistoryModal__messageIcon",onClick:()=>f(w===`${i._versionId}-release`?null:`${i._versionId}-release`),children:e(Ze,{size:18})}),children:e("div",{className:"VersionHistoryModal__message",children:[e("strong",{children:"Release:"})," ",G]})})})()]})}),e("td",{children:e(M,{size:"body-sm",children:i.sys.modifiedBy})}),e("td",{children:e("div",{className:"VersionHistoryModal__versions__buttons",children:!h&&e(S,{children:[e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>C(i),children:"restore"}),e(b,{variant:"default",size:"xs",compact:!0,onClick:()=>E(i),leftIcon:e(K,{size:12}),children:"copy to doc"})]})})})]},i._versionId)})})]}),g&&e("div",{className:"VersionHistoryModal__loadMore",children:e(b,{variant:"subtle",size:"xs",loading:p,onClick:n,children:"Load more versions"})})]})]})}function lo(s,t){return encodeURIComponent(`${s}@${t}`).replaceAll("%2F","/").replaceAll("%40","@")}function go(s){let t=s.getFullYear(),u=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),d=String(s.getHours()).padStart(2,"0"),o=String(s.getMinutes()).padStart(2,"0");return`${t}-${u}-${l}T${d}:${o}`}_o.id=ro;function Js(s){let{roles:t}=Xe(),u=window.firebase.user.email||"",l=Ke(t,u),d=Je(t,u),o=s.docId,y=s.data||{},p=y.sys||{},v=we(y),m=N(),k=oe({fromDocId:o,onSuccess:r=>{s.onAction&&s.onAction({action:"copy",newDocId:r})}}),g=H(),A=co({docId:o}),a=no({docId:o}),D=so({docIds:[o]}),x=()=>{let r=`revert-draft-${o}`,n=m.openConfirmModal({...g,title:`Discard draft edits for ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to discard draft changes for the following doc? The doc data will revert to the published version. There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Discard draft edits",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Discarding draft edits",message:`Discarding draft edits of ${o}...`,loading:!0,autoClose:!1}),await xe(o),F({id:r,title:"Discarded draft edits",message:`Successfully reverted ${o} back to its published version`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"revert-draft"})}})},T=()=>{let r=`unpublish-doc-${o}`,n=m.openConfirmModal({...g,title:`Unpublish ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unpublish the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Unpublish",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unpublishing doc",message:`Requesting unpublish of ${o}...`,loading:!0,autoClose:!1}),await ve(o),F({id:r,title:"Unpublished!",message:`Successfully unpublished ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unpublish"})}})},w=r=>{s.onAction&&s.onAction({action:r})},f=()=>{let r=`unschedule-doc-${o}`,n=m.openConfirmModal({...g,title:`Unschedule ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to unschedule the following doc?"}),e(B,{docId:o})]}),labels:{confirm:"Unschedule",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Unschedule doc",message:`Requesting unschedule of ${o}...`,loading:!0,autoClose:!1}),await Ce(o),F({id:r,title:"Unscheduled!",message:`Successfully unscheduled ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"unschedule"})}})},I=()=>{let r=`archive-doc-${o}`,n=m.openConfirmModal({...g,title:`Archive ${o}`,children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to archive the following doc? Archived docs are hidden from the collection list by default but can be restored later."}),e(B,{docId:o})]}),labels:{confirm:"Archive",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Archiving doc",message:`Requesting archive of ${o}...`,loading:!0,autoClose:!1}),await ke(o),F({id:r,title:"Archived!",message:`Successfully archived ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onAction&&s.onAction({action:"archive"})}})},L=async()=>{let r=`unarchive-doc-${o}`;_({id:r,title:"Unarchiving doc",message:`Requesting unarchive of ${o}...`,loading:!0,autoClose:!1}),await Ae(o),F({id:r,title:"Unarchived!",message:`Successfully unarchived ${o}!`,loading:!1,autoClose:5e3}),s.onAction&&s.onAction({action:"unarchive"})},$=()=>{let r=`delete-doc-${o}`,n=m.openConfirmModal({...g,title:"Delete doc",children:e(S,{children:[e(M,{size:"body-sm",weight:"semi-bold",className:"DocActionsMenu__confirmText",children:"Are you sure you want to delete the following doc? There is no undo."}),e(B,{docId:o})]}),labels:{confirm:"Delete",cancel:"Cancel"},cancelProps:{size:"xs"},confirmProps:{color:"red",size:"xs"},onCancel:()=>console.log("Cancel"),closeOnConfirm:!1,onConfirm:async()=>{_({id:r,title:"Deleting doc",message:`Requesting deletion of ${o}...`,loading:!0,autoClose:!1}),await ye(o),F({id:r,title:"Deleted!",message:`Successfully deleted ${o}!`,loading:!1,autoClose:5e3}),m.closeModal(n),s.onDelete&&s.onDelete(),s.onAction&&s.onAction({action:"delete"})}})};return e(P,{className:"CollectionPage__collection__docsList__doc__controls__menu",position:"bottom",control:e(Q,{className:"DocEditor__ArrayField__item__header__controls__dots",children:e(We,{size:16})}),children:[!v&&e(P.Item,{icon:e(Ye,{size:20}),onClick:()=>D.open(),disabled:!d,children:"Add to release"}),e(P.Item,{icon:e(je,{size:20}),onClick:()=>A.open(),children:"Version history"}),e(P.Item,{icon:e(K,{size:20}),onClick:()=>k.open(),disabled:!l,children:"Copy"}),!v&&p.modifiedAt&&p.publishedAt&&p.modifiedAt>p.publishedAt&&e(P.Item,{icon:e(Oe,{size:20}),onClick:()=>x(),disabled:!l,children:"Discard draft edits"}),!v&&p.firstPublishedAt&&e(P.Item,{icon:e(qe,{size:20}),onClick:()=>T(),disabled:!d,children:"Unpublish"}),!v&&p.scheduledAt&&e(P.Item,{icon:e(Ee,{size:20}),onClick:()=>f(),disabled:!d,children:"Unschedule"}),!v&&(Te(y)?e(P.Item,{icon:e(Y,{size:20}),onClick:()=>a.open({unlock:!0,onChange:w}),disabled:!l,children:"Unlock publishing"}):e(P.Item,{icon:e(ee,{size:20}),onClick:()=>a.open({unlock:!1,onChange:w}),disabled:!l||De(y),children:"Lock publishing"})),v?e(P.Item,{icon:e(Ue,{size:20}),onClick:()=>L(),disabled:!l,children:"Unarchive"}):!p.publishedAt&&e(P.Item,{icon:e(Be,{size:20}),onClick:()=>I(),disabled:!l,children:"Archive"}),e(P.Item,{icon:e(Ge,{size:20}),onClick:()=>$(),disabled:!l,children:"Delete"})]})}export{so as a,mo as b,po as c,B as d,no as e,Z as f,_o as g,Js as h};
@@ -0,0 +1 @@
1
+ import{a as te,f as se,g as U,h as oe}from"./chunk-ZN2Y5OUF.js";import{f as m}from"./chunk-KRNQ6L35.js";import{a as k,b as v,c as l,f as W,g as D,h as C,i as J,j as P,l as Y,n as B,o as j,p as M,q as w,r as Z,t as $,u as x,v as u,w as ee,x as T}from"./chunk-VD6G5NV4.js";import{k as V}from"./chunk-7SK47HHZ.js";function ne(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function ie(e){return ne(e)&&Array.isArray(e.blocks)&&e.blocks.length>0}var X=new Map;function be(e){return X.get(e)||null}async function Ne(e){let t=be(e);if(t)return t;let s=A(e),o=(await B(s)).data();return Ae(e,o),o}function Ae(e,t){X.set(e,t)}function N(e){X.delete(e)}function O(e){for(let t of e)N(t)}function re(e){e||(e=6);let t=[],s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=s.length;for(let o=0;o<e;o++)t.push(s.charAt(Math.floor(Math.random()*n)));return t.join("")}var F=class extends Error{},ce=200,xe=/[/\\\u0000-\u001f]/;function R(){let e=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db;return v(t,"Projects",e,"Assets")}var Re="root-cms:assetPicker:lastFolder";function de(){let e=window.__ROOT_CTX.rootConfig.projectId;return`${Re}:${e}`}function Ze(){try{return localStorage.getItem(de())||""}catch{return""}}function et(e){try{localStorage.setItem(de(),e||"")}catch{}}function G(e){let t=(e||"").trim();if(!t)throw new F("Name is required.");if(t.length>ce)throw new F(`Name is too long (max ${ce} chars).`);if(xe.test(t))throw new F("Name cannot contain slashes.");if(t==="."||t==="..")throw new F("Invalid name.");return t}function _(e,t){return e?`${e}/${t}`:t}function tt(e){return e?e.split("/").filter(Boolean):[]}function L(e){return`folder-${encodeURIComponent(e)}`}function fe(e){return e.sort((t,s)=>t.type!==s.type?t.type==="folder"?-1:1:(t.name||"").localeCompare(s.name||"",void 0,{numeric:!0,sensitivity:"base"}))}function ue(e){return!!e&&typeof e.name=="string"&&(e.type==="file"||e.type==="folder")}async function De(e){let t=R(),s=D(t,C("parent","==",e||"")),n=await j(s),o=[];return n.forEach(i=>{let r=i.data();ue(r)&&o.push(r)}),fe(o)}var ae=1e3;async function st(e){let t=R(),s;e?s=D(t,C("parent",">=",e),C("parent","<=",`${e}\uF8FF`),P(ae)):s=D(t,P(ae));let n=await j(s),o=[];return n.forEach(i=>{let r=i.data();ue(r)&&(!e||H(r.parent,e))&&o.push(r)}),fe(o)}function ot(e,t){return t?e===t?"":e.startsWith(`${t}/`)?e.slice(t.length+1):e:e}async function S(e){let t=l(R(),e),s=await B(t);return s.exists()?s.data():null}async function nt(e,t){let s=G(t),n=_(e,s),o=L(n),i=l(R(),o),r={id:o,type:"folder",parent:e||"",name:s,createdAt:u(),createdBy:window.firebase.user.email,modifiedAt:u(),modifiedBy:window.firebase.user.email};return await M(i,r,{merge:!0}),m("asset.folder_create",{metadata:{folder:n}}),await S(o)}async function it(e){let t=z(e.file),s=G(e.name||t.filename||_e(t.src)),n=re(12),o=l(R(),n);return await M(o,{id:n,type:"file",parent:e.parent||"",name:s,file:t,createdAt:u(),createdBy:window.firebase.user.email,modifiedAt:u(),modifiedBy:window.firebase.user.email}),m("asset.upload",{metadata:{assetId:n,name:s}}),await S(n)}async function rt(e,t){let s=G(t);if(s===e.name)return;if(e.type==="folder"){let o=_(e.parent,e.name),i=_(e.parent,s);await me(e,i,s,e.parent),m("asset.rename",{metadata:{from:o,to:i}});return}let n=l(R(),e.id);await w(n,{name:s,modifiedAt:u(),modifiedBy:window.firebase.user.email}),m("asset.rename",{metadata:{assetId:e.id,from:e.name,to:s}})}async function ct(e,t){let s=t||"";if(s===e.parent)return;if(e.type==="folder"){let o=_(e.parent,e.name),i=_(s,e.name);if(i===o||H(i,o))throw new Error("Cannot move a folder into itself.");await me(e,i,e.name,s),m("asset.move",{metadata:{from:o,to:i}});return}let n=l(R(),e.id);await w(n,{parent:s,modifiedAt:u(),modifiedBy:window.firebase.user.email}),m("asset.move",{metadata:{assetId:e.id,from:e.parent,to:s}})}function H(e,t){return e===t||e.startsWith(`${t}/`)}async function me(e,t,s,n){let o=_(e.parent,e.name),i=R(),r=window.firebase.db,c=D(i,C("parent",">=",o),C("parent","<=",`${o}\uF8FF`)),a=await j(c),p=[];a.forEach(y=>{let b=y.data();H(b.parent,o)&&p.push(b)});let f=T(r),g=0,h=async()=>{g+=1,g>=400&&(await f.commit(),f=T(r),g=0)},d=L(t);f.set(l(i,d),{id:d,type:"folder",parent:n,name:s,createdAt:e.createdAt??u(),createdBy:e.createdBy??window.firebase.user.email,modifiedAt:u(),modifiedBy:window.firebase.user.email}),await h();for(let y of p){let b=t+y.parent.slice(o.length);if(y.type==="folder"){let I=_(b,y.name);f.set(l(i,L(I)),{...y,id:L(I),parent:b,modifiedAt:u(),modifiedBy:window.firebase.user.email}),await h(),f.delete(l(i,y.id)),await h()}else f.update(l(i,y.id),{parent:b,modifiedAt:u(),modifiedBy:window.firebase.user.email}),await h()}d!==e.id&&(f.delete(l(i,e.id)),g+=1),g>0&&await f.commit()}async function at(e){if(e.type==="folder"){let t=_(e.parent,e.name);if((await De(t)).length>0)throw new Error("Folder is not empty.")}await Z(l(R(),e.id)),m("asset.delete",{metadata:{assetId:e.id,name:e.name}})}async function lt(e,t){let s=z(t);!s.alt&&e.file?.alt&&(s.alt=e.file.alt),e.file?.altDisabled&&(s.altDisabled=!0);let n=l(R(),e.id),o={file:s,modifiedAt:u(),modifiedBy:window.firebase.user.email},i=V(s.filename||s.src||""),r=Ce(e.name,i);return r!==e.name&&(o.name=r),await w(n,o),m("asset.replace",{metadata:{assetId:e.id,name:e.name}}),await S(e.id)}function Ce(e,t){let s=(e||"").lastIndexOf(".");return!t||s<=0||V(e)===t?e:`${e.slice(0,s)}.${t}`}async function dt(e,t){let s=l(R(),e.id);return await w(s,{"file.alt":t||"",modifiedAt:u(),modifiedBy:window.firebase.user.email}),await S(e.id)}async function ft(e,t){let s=l(R(),e.id);return await w(s,{"file.altDisabled":t?!0:x(),modifiedAt:u(),modifiedBy:window.firebase.user.email}),m("asset.alt_disabled",{metadata:{assetId:e.id,name:e.name,disabled:t}}),await S(e.id)}function Te(e){let t={...z(e.file),assetId:e.id};return t.altDisabled&&(t.alt=""),t}function K(e){let t=new Set;return q(e,t),Array.from(t).sort()}function q(e,t){if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let s of e)q(s,t);return}if(typeof e.toMillis!="function"){if(Q(e)){t.add(e.assetId);return}for(let s of Object.keys(e))q(e[s],t)}}}function Q(e){return typeof e?.assetId=="string"&&typeof e?.src=="string"}function le(e){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(le(t))return!0;return!1}if(typeof e.toMillis=="function")return!1;if(Q(e))return!0;for(let t of Object.keys(e))if(le(e[t]))return!0;return!1}async function Be(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,n=Object.keys(window.__ROOT_CTX.collections||{});return(await Promise.all(n.map(async r=>{let c=v(s,"Projects",t,"Collections",r,"Drafts"),a=D(c,C("sys.assets","array-contains",e)),p=await j(a),f=[];return p.forEach(g=>{f.push(g.data())}),f}))).flat().sort((r,c)=>r.id.localeCompare(c.id))}async function ut(e,t={}){let s=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,o=t.docs??await Be(e.id),i=[],r=[];for(let c of o){let a=[];if(pe(c.fields,e.id,"fields",a),a.length===0)continue;let p={};for(let d of a)p[d.path]=je(e,d.value,t.previousFile);p["sys.modifiedAt"]=u(),p["sys.modifiedBy"]=window.firebase.user.email;let[f,g]=c.id.split("/"),h=l(n,"Projects",s,"Collections",f,"Drafts",g);try{await w(h,p),i.push(c.id)}catch(d){console.error(`failed to sync asset ${e.id} to ${c.id}:`,d),r.push(c.id)}}return i.length>0&&(O(i),m("asset.sync",{metadata:{assetId:e.id,name:e.name,docIds:i}})),{updatedDocIds:i,failedDocIds:r}}function pe(e,t,s,n){if(!(!e||typeof e!="object")&&!Array.isArray(e)&&typeof e.toMillis!="function"){if(Q(e)){e.assetId===t&&n.push({path:s,value:e});return}for(let o of Object.keys(e))pe(e[o],t,`${s}.${o}`,n)}}function je(e,t,s){let n=Te(e);if(!e.file?.altDisabled){let i=s?.alt??e.file?.alt??"",r=t?.alt||"";r&&r!==i&&(n.alt=r)}let o=s?.canvasBgColor??e.file?.canvasBgColor;return t?.canvasBgColor&&t.canvasBgColor!==o&&(n.canvasBgColor=t.canvasBgColor),n}function z(e){let t={};return Object.entries(e||{}).forEach(([s,n])=>{n!==void 0&&(t[s]=n)}),t}function _e(e){return(e||"").split("?")[0].split("/").pop()||"untitled"}async function Ct(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Published",o),c=l(s,"Projects",t,"Collections",n,"Scheduled",o),a=T(s);a.delete(i),a.delete(r),a.delete(c),await a.commit(),console.log(`deleted doc: ${e}`),m("doc.delete",{metadata:{docId:e}})}async function Tt(e,t){await ke([e],t)}async function ke(e,t){if(e.length===0){console.log("no docs to publish");return}let s=window.firebase.db;if(e.length>100)throw new Error("publish docs exceeds limit of 100 docs. break up your request into multiple calls.");let n=await Oe(e),o=t?.batch||T(s),i=["published"];t?.releaseId&&i.push(`release:${t.releaseId}`),e.forEach(r=>{let c=n[r];if(!c)throw new Error(`doc does not exist: ${r}`);ve(o,r,c,i,t?.publishMessage)}),await o.commit(),e.length===1?console.log(`published ${e[0]}`):console.log(`published ${e.length} docs: ${e.join(", ")}`);for(let r of e){let c={docId:r};t?.publishMessage&&(c.publishMessage=t.publishMessage),m("doc.publish",{metadata:c})}O(e)}function ve(e,t,s,n,o){if(Ie(s))throw new Error(`publishing is locked for doc: ${s.id}`);if(Fe(s))throw new Error(`cannot publish archived doc: ${s.id}`);let i=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,[c,a]=t.split("/"),p=l(r,"Projects",i,"Collections",c,"Drafts",a),f=l(r,"Projects",i,"Collections",c,"Scheduled",a),g=l(r,"Projects",i,"Collections",c,"Published",a),h={...s},d=h.sys??{};d.modifiedAt=u(),d.modifiedBy=window.firebase.user.email,d.publishedAt=u(),d.publishedBy=window.firebase.user.email,d.firstPublishedAt??=u(),d.firstPublishedBy??=window.firebase.user.email,delete d.scheduledAt,delete d.scheduledBy,e.update(p,{sys:d}),e.set(g,{...h,sys:d}),e.delete(f);let y=l(r,"Projects",i,"Collections",c,"Drafts",a,"Versions",String(Date.now())),b={id:t,collection:c,slug:a,fields:h.fields||{},sys:d};n?.length&&(b.tags=n),o&&(b.publishMessage=o),e.set(y,b)}async function Bt(e,t,s){let n=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[i,r]=e.split("/"),c=l(o,"Projects",n,"Collections",i,"Drafts",r),a=l(o,"Projects",n,"Collections",i,"Scheduled",r);await $(o,async f=>{let g=await f.get(c);if(!g.exists())throw new Error(`${c.id} does not exist`);let h={...g.data()},d=h.sys??{};d.modifiedAt=u(),d.modifiedBy=window.firebase.user.email,d.scheduledAt=k.fromMillis(t),d.scheduledBy=window.firebase.user.email,f.update(c,{sys:d});let y={...h,sys:d};s?.publishMessage&&(y.scheduledPublishMessage=s.publishMessage),f.set(a,y)}),console.log(`saved ${a.id}`);let p={docId:e,scheduledAt:t};s?.publishMessage&&(p.publishMessage=s.publishMessage),m("doc.schedule",{metadata:p})}async function jt(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Scheduled",o),c=l(s,"Projects",t,"Collections",n,"Published",o),a=T(s);a.update(i,{"sys.modifiedAt":u(),"sys.modifiedBy":window.firebase.user.email,"sys.publishedAt":x(),"sys.publishedBy":x(),"sys.firstPublishedAt":x(),"sys.firstPublishedBy":x()}),a.delete(r),a.delete(c),await a.commit(),console.log(`unpublished ${e}`),m("doc.unpublish",{metadata:{docId:e}}),N(e)}async function _t(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Published",o);await $(s,async c=>{let a=await c.get(r);if(!a.exists())throw new Error(`${r.id} does not exist`);let p=a.data();c.set(i,p)}),console.log(`reverted draft ${e}`),m("doc.revert",{metadata:{docId:e}})}async function kt(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),i=l(s,"Projects",t,"Collections",n,"Drafts",o),r=l(s,"Projects",t,"Collections",n,"Scheduled",o),c=T(s);c.update(i,{"sys.modifiedAt":u(),"sys.modifiedBy":window.firebase.user.email,"sys.scheduledAt":x(),"sys.scheduledBy":x()}),c.delete(r),await c.commit(),console.log(`unscheduled ${e}`),m("doc.unschedule",{metadata:{docId:e}})}async function vt(e,t){let s={lockedAt:u(),lockedBy:window.firebase.user.email,reason:t.reason||`Locked by ${window.firebase.user.email}.`};t.until&&(s.until=k.fromMillis(t.until));let n=A(e);await w(n,{"sys.publishingLocked":s});let i={docId:e,reason:t.reason};t.until&&(i.until=t.until),m("doc.lock_publishing",{metadata:i})}async function Ft(e){let t=A(e),s={"sys.publishingLocked":x()};await w(t,s),m("doc.unlock_publishing",{metadata:{docId:e}})}async function It(e){let t=A(e);await w(t,{"sys.archivedAt":u(),"sys.archivedBy":window.firebase.user.email}),m("doc.archive",{metadata:{docId:e}})}async function Pt(e){let t=A(e);await w(t,{"sys.archivedAt":x(),"sys.archivedBy":x()}),m("doc.unarchive",{metadata:{docId:e}})}function Fe(e){return!!e?.sys?.archivedAt}function Mt(e){let t=k.now().toMillis();return(e?.sys?.scheduledAt?.toMillis()||0)>t}function Ie(e){if(e?.sys?.publishingLocked){if(e.sys.publishingLocked.until){let t=k.now().toMillis(),s=e.sys.publishingLocked.until.toMillis();return t<s}return!0}return!1}async function St(e,t,s){let n=A(e),o=await B(n);if(!o.exists())throw new Error(`doc ${e} does not exist`);let i=o.data(),r=i.fields??{},c=i.sys?.locales;await Pe(t,{fields:r,locales:c,overwrite:s?.overwrite})}async function Pe(e,t){let[s,n]=e.split("/"),o=A(e),i=await B(o);if(i.exists()&&!t?.overwrite)throw new Error(`${e} already exists`);let r=t?.fields??{},c={id:e,collection:s,slug:n,sys:{createdAt:u(),createdBy:window.firebase.user.email,modifiedAt:u(),modifiedBy:window.firebase.user.email,locales:t?.locales??["en"]},fields:r};if(i.exists()&&t?.overwrite){let p=i.data();c.sys={...p.sys,locales:t?.locales??p.sys.locales,modifiedAt:u(),modifiedBy:window.firebase.user.email}}let a=K(r);a.length>0?c.sys.assets=a:delete c.sys.assets,await M(o,c),m("doc.create",{metadata:{docId:e}})}async function Ot(e,t,s){let o=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];function i(d){for(let y of o)if(String(y).toLowerCase()===d.toLowerCase())return y;return null}let r={};for(let d of t){if(!d.source)continue;let y={source:U(d.source)};Object.entries(d).forEach(([I,we])=>{if(I==="source")return;let E=i(I);E&&!oe(E)&&(y[E]=U(we||""))});let b=await se(y.source);r[b]=y}let a=[e.split("/")[0],e];s?.tags&&a.push(...s.tags);let p=te(),f=window.firebase.db,g=T(f),h=0;for(let d in r){let y=r[d],b=l(p,d);g.set(b,{...y,tags:ee(...a)},{merge:!0}),h+=1,h>=500&&(await g.commit(),g=T(f),console.log(`saved ${h} strings`),h=0)}return h>0&&(await g.commit(),console.log(`saved ${h} strings`)),m("doc.import_translations",{metadata:{docId:e,...s?.actionMetadata},links:s?.actionLinks}),r}function A(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return l(s,"Projects",t,"Collections",n,"Drafts",o)}function Me(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return l(s,"Projects",t,"Collections",n,"Published",o)}function Se(e,t){let s=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,[o,i]=e.split("/");return l(n,"Projects",s,"Collections",o,"Drafts",i,"Versions",t)}async function Oe(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,n={};e.forEach(i=>{let[r,c]=i.split("/");r in n?n[r].push(c):n[r]=[c]});let o={};return await Promise.all(Object.entries(n).map(async([i,r])=>{let c=v(s,"Projects",t,"Collections",i,"Drafts"),a=D(c,C(W(),"in",r));(await j(a)).forEach(f=>{let g=`${i}/${f.id}`;o[g]=f.data()})})),o}async function Lt(e,t){let s=window.firebase.db,n=A(e),o=v(s,n.path,"Versions"),i=t?.limit??50,r=D(o,J("sys.modifiedAt","desc"),P(i));t?.tags&&(r=D(r,C("tags","array-contains-any",t.tags))),t?.cursor&&(r=D(r,Y(t.cursor)));let c=await j(r),a=[],p=null;return c.forEach(f=>{let g={...f.data(),_versionId:f.id};a.push(g),p=f}),{versions:a,lastDoc:p,hasMore:c.size===i}}async function Et(e,t){let s=A(e),n={"sys.modifiedAt":u(),"sys.modifiedBy":window.firebase.user.email,"sys.assets":K(t.fields||{}),fields:t.fields||{}};await w(s,n),m("doc.restore_version",{metadata:{docId:e,versionModifiedAt:t.sys?.modifiedAt,versionModifiedBy:t.sys?.modifiedBy}})}async function $t(e,t){let s;t==="draft"?s=A(e):t==="published"?s=Me(e):s=Se(e,t);let n=await B(s);return n.exists()?n.data():null}async function Vt(e,t){if(!t?.spreadsheetId)throw new Error("no spreadsheet id");let s=A(e),n={"sys.l10nSheet":{spreadsheetId:t.spreadsheetId,gid:t.gid||0,linkedAt:u(),linkedBy:window.firebase.user.email}};await w(s,n),m("doc.link_sheet",{metadata:{docId:e,sheetId:t}})}async function Ut(e){let t=A(e),s={"sys.l10nSheet":x()};await w(t,s),m("doc.unlink_sheet",{metadata:{docId:e}})}async function Xt(e){let t=A(e),o=(await B(t)).data()?.sys?.l10nSheet||{};return o?.spreadsheetId?{spreadsheetId:o.spreadsheetId,gid:o.gid||0}:null}function ge(e,t){let s={};for(let n in e){let o=e[n];if(he(o))if(o.toMillis)s[n]=o.toMillis();else if(Object.hasOwn(o,"_array")&&Array.isArray(o._array)){let i=o._array.map(r=>{let c={...ge(o[r]||{},t),_arrayKey:r};return t?.removeArrayKey&&delete c._arrayKey,c});s[n]=i}else s[n]=ge(o,t);else s[n]=o}return s}async function Nt(e,t){let s=await window.fetch("/cms/api/ai.diff",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({docId:e,beforeVersion:t?.beforeVersion||"published",afterVersion:t?.afterVersion||"draft"})}),n=await s.text(),o=null;try{o=JSON.parse(n)}catch{}if(!s.ok||o?.success===!1){let i=o&&(o.error||o.message)||n;throw new Error(i||"Failed to fetch AI summary")}return typeof o?.summary=="string"?o.summary:typeof o?.data?.summary=="string"?o.data.summary:!o&&n?n:""}function he(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function qt(e){let[t,s]=e.split("/");return{id:e,collection:t,slug:s}}function ye(e){if(Le(e))return k.fromMillis(e.seconds*1e3);if(ie(e))return e.time=Date.now(),e;if(Array.isArray(e))return e.map(t=>ye(t));if(he(e)){let t={};return Object.keys(e).forEach(s=>{t[s]=ye(e[s])}),t}return e}function Le(e){return e?.type==="firestore/timestamp/1.0"}export{ie as a,Ne as b,Ae as c,re as d,Ze as e,et as f,_ as g,tt as h,De as i,st as j,ot as k,S as l,nt as m,it as n,rt as o,ct as p,at as q,lt as r,Ce as s,dt as t,ft as u,Te as v,K as w,le as x,Be as y,ut as z,Ct as A,Tt as B,ke as C,Bt as D,jt as E,_t as F,kt as G,vt as H,Ft as I,It as J,Pt as K,Fe as L,Mt as M,Ie as N,St as O,Pe as P,Ot as Q,Oe as R,Lt as S,Et as T,$t as U,Vt as V,Ut as W,Xt as X,ge as Y,Nt as Z,qt as _,ye as $};
@@ -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-YLSRRNSE.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 o}from"./chunk-ORXEMIQC.js";import{Fa as r,Ga as i,ba as a}from"./chunk-4CUWZQXT.js";var l={transition:"pop"};function g(t){let e=t.release;return n(e.archivedAt)?i(r,{...l,label:`Archived ${d(e.archivedAt)} by ${e.archivedBy}`,children:i(a,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):n(e.scheduledAt)?i(r,{...l,label:`Scheduled ${s(e.scheduledAt)} by ${e.scheduledBy}`,wrapLines:!0,width:240,children:i(a,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}):n(e.publishedAt)?i(r,{...l,label:`Published ${d(e.publishedAt)} by ${e.publishedBy}`,children:i(a,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):i(a,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function n(t){return!!(t&&t.toMillis)}function d(t){return t?.toMillis?o(t.toMillis()):o(new Date().getTime())}function s(t){return new Date(t.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}export{g as a};
1
+ import{b as o}from"./chunk-KRNQ6L35.js";import{Fa as r,Ga as i,ba as a}from"./chunk-LROR6N3B.js";var l={transition:"pop"};function g(t){let e=t.release;return n(e.archivedAt)?i(r,{...l,label:`Archived ${d(e.archivedAt)} by ${e.archivedBy}`,children:i(a,{size:"xs",color:"gray",variant:"filled",children:"Archived"})}):n(e.scheduledAt)?i(r,{...l,label:`Scheduled ${s(e.scheduledAt)} by ${e.scheduledBy}`,wrapLines:!0,width:240,children:i(a,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}):n(e.publishedAt)?i(r,{...l,label:`Published ${d(e.publishedAt)} by ${e.publishedBy}`,children:i(a,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}):i(a,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Unpublished"})}function n(t){return!!(t&&t.toMillis)}function d(t){return t?.toMillis?o(t.toMillis()):o(new Date().getTime())}function s(t){return new Date(t.toMillis()).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}export{g as a};
@@ -0,0 +1 @@
1
+ import{a as P}from"./chunk-3E6CASIN.js";import{a as $}from"./chunk-76ZGLKLT.js";import{h as w,i as A}from"./chunk-D3UIZHRK.js";import{a as C}from"./chunk-W5DOO6ID.js";import{a as B}from"./chunk-NSOTG64N.js";import{a as v,b as S}from"./chunk-QHJOTXYB.js";import{b as l}from"./chunk-KRNQ6L35.js";import{a as D}from"./chunk-VD6G5NV4.js";import{Fa as c,Ga as o,a as e,c as y,da as T,j as g}from"./chunk-LROR6N3B.js";g();g();function x(t){let i=k(t.timestamp),[s,a]=e(i>0?l(i,{style:"short"}):"never");return i?(y(()=>{let u=window.setInterval(()=>{a(l(i,{style:"short"}))},6e4);return()=>window.clearInterval(u)},[]),o(c,{transition:"pop",label:`${U(i)} by ${t.email}`,children:l(i,{style:"short"})})):o("div",{children:s})}function U(t){return new Date(t).toLocaleDateString("en",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function k(t){return typeof t=="number"?t:t?.toMillis?t.toMillis():0}function et(t){let i=t.dataSource,[s,a]=e(!1),[u,N]=e(t.action==="sync"?i.syncedAt:i.publishedAt),[I,L]=e(t.action==="sync"?i.syncedBy:i.publishedBy),b=P(),{roles:_}=B(),E=window.firebase.user.email||"",m=C(_,E),d=t.action==="publish",r=!!i.archivedAt;async function M(){a(!0);let p=`data-source-${t.action}-${i.id}`;v({id:p,loading:!0,title:`Running Data Source ${t.action}`,message:`Updating ${i.id}...`,autoClose:!1,disallowClose:!0});try{t.action==="sync"?(i.type==="gsheet"&&!b.isLoggedIn()&&await b.login(),await w(i.id)):t.action==="publish"&&await A(i.id),N(D.now()),L(window.firebase.user.email),a(!1),t.onAction&&t.onAction(),S({id:p,title:"Success",message:`Updated Data Source ${i.id}`,autoClose:!1})}catch(n){console.error(n);let h=n;typeof n=="object"&&n.body&&(h=String(n.body)),a(!1),S({id:p,title:`Data Source ${t.action} failed`,message:String(h),color:"red",autoClose:!1})}}let f="";return t.action==="sync"?f="Sync data to a draft state":t.action==="publish"&&(f="Publish synced data to prod"),o("div",{className:"DataSourceStatusButton",children:[o("div",{className:"DataSourceStatusButton__label",children:!s&&o(x,{timestamp:u,email:I})}),o("div",{className:"DataSourceStatusButton__button",children:o($,{label:r?"Data source is archived":"You don't have access to publish this data source",condition:r||d&&!m,children:o(c,{transition:"pop",label:f,disabled:r||d&&!m,children:o(T,{variant:"default",size:"xs",compact:!0,onClick:()=>M(),loading:s,disabled:r||d&&!m,children:t.action})})})})]})}export{et as a};