@blinkk/root-cms 3.0.4 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/app.js +4 -2
  2. package/dist/{chunk-RLZFZT42.js → chunk-7L5OI5ES.js} +9 -9
  3. package/dist/core/plugin.d.ts +17 -0
  4. package/dist/core/schema.d.ts +20 -0
  5. package/dist/plugin.js +12 -1
  6. package/dist/shared/auto-slug-words.d.ts +7 -0
  7. package/dist/shared/auto-slug.d.ts +14 -0
  8. package/dist/ui/AIPage-JPZ4QUB4.js +1 -0
  9. package/dist/ui/{AssetsPage-4JNAOFYF.js → AssetsPage-GDJMKS3M.js} +1 -1
  10. package/dist/ui/{CollectionPage-JWHH5G55.js → CollectionPage-5DVXJEET.js} +1 -1
  11. package/dist/ui/ComparePage-LIXA6G66.js +1 -0
  12. package/dist/ui/{DataPage-VRCQSZZG.js → DataPage-AP4Z5JPS.js} +1 -1
  13. package/dist/ui/{DataSourcePage-WMSPBZ3W.js → DataSourcePage-WO3ZKMFI.js} +1 -1
  14. package/dist/ui/DocTranslationsPage-QKYFIVHP.js +1 -0
  15. package/dist/ui/DocumentPage-ON43I5KM.js +1 -0
  16. package/dist/ui/{EditDataSourcePage-LLCX6K4J.js → EditDataSourcePage-XVMEV2LJ.js} +1 -1
  17. package/dist/ui/{EditReleasePage-WQYXXMZQ.js → EditReleasePage-A2NB5TFG.js} +1 -1
  18. package/dist/ui/{ImageEditorDialog-4H665KK2.js → ImageEditorDialog-QEULJAT2.js} +2 -2
  19. package/dist/ui/LogsPage-4LZJX3O4.js +1 -0
  20. package/dist/ui/{NewDataSourcePage-RDYJC4DH.js → NewDataSourcePage-4YWX7IOG.js} +1 -1
  21. package/dist/ui/NewReleasePage-HWLVTEXX.js +1 -0
  22. package/dist/ui/{NotFoundPage-WDZ2K7EF.js → NotFoundPage-72AXQAYX.js} +1 -1
  23. package/dist/ui/{ProjectPage-HYJOQUWR.js → ProjectPage-L4GYDIA5.js} +1 -1
  24. package/dist/ui/ReleasePage-43BSWL5B.js +1 -0
  25. package/dist/ui/{ReleasesPage-NZIBBXU4.js → ReleasesPage-CJXAZBP6.js} +1 -1
  26. package/dist/ui/SettingsPage-SYXAMKSF.js +1 -0
  27. package/dist/ui/{SidebarToolsPage-5C6YBWJ7.js → SidebarToolsPage-OFF5BOXP.js} +1 -1
  28. package/dist/ui/TaskPage-HBDLHFI5.js +1 -0
  29. package/dist/ui/TasksPage-OLCDTQNB.js +1 -0
  30. package/dist/ui/{TranslationsArbPage-UHANA7JD.js → TranslationsArbPage-E3NCMAMS.js} +1 -1
  31. package/dist/ui/{TranslationsEditPage-PQY6W5YG.js → TranslationsEditPage-IWOI7Y5G.js} +1 -1
  32. package/dist/ui/{TranslationsPage-V2PQFCN5.js → TranslationsPage-OBN6CQZZ.js} +31 -31
  33. package/dist/ui/{ai-tools-5E5ELLZX.js → ai-tools-4DWMFQS6.js} +1 -1
  34. package/dist/ui/{chunk-KYDOSLTO.js → chunk-2225WAJ2.js} +1 -1
  35. package/dist/ui/chunk-32LRQ5MJ.js +1 -0
  36. package/dist/ui/{chunk-HKINZLMW.js → chunk-344GZOGG.js} +45 -45
  37. package/dist/ui/{chunk-FBJURT7Z.js → chunk-3HVDIPSS.js} +1 -1
  38. package/dist/ui/{chunk-BZIRGB4W.js → chunk-3IDOZ4MG.js} +1 -1
  39. package/dist/ui/{chunk-HHMG665Z.js → chunk-3XYCOR6Z.js} +1 -1
  40. package/dist/ui/chunk-4CUWZQXT.js +7 -0
  41. package/dist/ui/{chunk-3IYZCUPI.js → chunk-4IXGYXA2.js} +1 -1
  42. package/dist/ui/{chunk-PHBMVORG.js → chunk-6E7PGMZX.js} +1 -1
  43. package/dist/ui/{chunk-VMT7JFAM.js → chunk-6GPTGBA7.js} +1 -1
  44. package/dist/ui/{chunk-767BAQ53.js → chunk-6MOPIV5T.js} +1 -1
  45. package/dist/ui/{chunk-E2RCCK2T.js → chunk-AOCBDKLV.js} +1 -1
  46. package/dist/ui/chunk-AXETBZ6T.js +1 -0
  47. package/dist/ui/{chunk-54DVDYU6.js → chunk-BEDUTYQP.js} +1 -1
  48. package/dist/ui/{chunk-62UWGWON.js → chunk-CVGYBXVH.js} +1 -1
  49. package/dist/ui/{chunk-L4RHGQUG.js → chunk-D37DCENS.js} +1 -1
  50. package/dist/ui/{chunk-4W73RW5I.js → chunk-DXKEDMEI.js} +1 -1
  51. package/dist/ui/{chunk-C5NH23G4.js → chunk-EMYXSVTD.js} +1 -1
  52. package/dist/ui/{chunk-PWKJDYE2.js → chunk-GDSSFO5R.js} +1 -1
  53. package/dist/ui/{chunk-KFAZBEPV.js → chunk-HYARD7BK.js} +1 -1
  54. package/dist/ui/chunk-IDYKCAAL.js +1 -0
  55. package/dist/ui/chunk-IKED2IGU.js +1 -0
  56. package/dist/ui/{chunk-KKEWCXVV.js → chunk-J3EGGI57.js} +1 -1
  57. package/dist/ui/{chunk-HRGYNHZ3.js → chunk-KPJ53X55.js} +1 -1
  58. package/dist/ui/{chunk-W3BJ2EZX.js → chunk-KYKFNAX4.js} +1 -1
  59. package/dist/ui/{chunk-TJBVMFNQ.js → chunk-MZP6RIG2.js} +1 -1
  60. package/dist/ui/chunk-N4DFAIC5.js +7 -0
  61. package/dist/ui/{chunk-HLMBCVRX.js → chunk-N5Y5OWTV.js} +1 -1
  62. package/dist/ui/chunk-NMBXHKIJ.js +81 -0
  63. package/dist/ui/chunk-NQ5ARARP.js +1 -0
  64. package/dist/ui/{chunk-X2WHBGTP.js → chunk-NQB37NMX.js} +1 -1
  65. package/dist/ui/chunk-OVRTVMO5.js +1 -0
  66. package/dist/ui/{chunk-JT5L6GPZ.js → chunk-RI2JWWU3.js} +53 -53
  67. package/dist/ui/{chunk-AL3TN2KI.js → chunk-RPOP6MVJ.js} +1 -1
  68. package/dist/ui/{chunk-JHBAMPGB.js → chunk-RQKL4KXY.js} +1 -1
  69. package/dist/ui/{chunk-P3NETZZP.js → chunk-SEUH7LN2.js} +1 -1
  70. package/dist/ui/{chunk-V7S4IAGB.js → chunk-T47V6AGW.js} +1 -1
  71. package/dist/ui/{chunk-ONTGW2VA.js → chunk-TDKVKTW4.js} +1 -1
  72. package/dist/ui/chunk-TZEZEMRQ.js +1 -0
  73. package/dist/ui/{chunk-RSVO46S3.js → chunk-UA7UCTX5.js} +1 -1
  74. package/dist/ui/chunk-UFQSZ6J2.js +3 -0
  75. package/dist/ui/{chunk-DEGMKEHP.js → chunk-UHWNLNP4.js} +1 -1
  76. package/dist/ui/{chunk-CGCKJFL4.js → chunk-V7RAXP2W.js} +1 -1
  77. package/dist/ui/{chunk-JYFLU7DM.js → chunk-WKOX3VFN.js} +1 -1
  78. package/dist/ui/{chunk-SQRKKWRG.js → chunk-XYBHH5L4.js} +1 -1
  79. package/dist/ui/ui.css +1 -1
  80. package/dist/ui/ui.js +1 -1
  81. package/package.json +10 -10
  82. package/dist/ui/AIPage-YI3RFK5F.js +0 -1
  83. package/dist/ui/ComparePage-YZE3EMU4.js +0 -1
  84. package/dist/ui/DocTranslationsPage-RY2LOZBX.js +0 -1
  85. package/dist/ui/DocumentPage-EEGTJMIW.js +0 -1
  86. package/dist/ui/LogsPage-IP2DKEYR.js +0 -1
  87. package/dist/ui/NewReleasePage-DGMFU2JN.js +0 -1
  88. package/dist/ui/ReleasePage-2KSF23TK.js +0 -1
  89. package/dist/ui/SettingsPage-36XFWV62.js +0 -1
  90. package/dist/ui/TaskPage-SPIFPGPP.js +0 -1
  91. package/dist/ui/TasksPage-ZOXRPBQV.js +0 -1
  92. package/dist/ui/chunk-AFWBSIPL.js +0 -1
  93. package/dist/ui/chunk-GXSAEPU3.js +0 -1
  94. package/dist/ui/chunk-I6ICVKEC.js +0 -1
  95. package/dist/ui/chunk-JZFTZ4X4.js +0 -87
  96. package/dist/ui/chunk-MDUBCXU2.js +0 -1
  97. package/dist/ui/chunk-NXQVLOTK.js +0 -1
  98. package/dist/ui/chunk-NZHF733K.js +0 -7
  99. package/dist/ui/chunk-PJA7YP4A.js +0 -1
  100. package/dist/ui/chunk-XOQ3KDSR.js +0 -3
  101. package/dist/ui/chunk-YFA6U2CV.js +0 -1
  102. /package/dist/ui/{ImageEditorDialog-4H665KK2.js.LEGAL.txt → ImageEditorDialog-QEULJAT2.js.LEGAL.txt} +0 -0
  103. /package/dist/ui/{chunk-NZHF733K.js.LEGAL.txt → chunk-4CUWZQXT.js.LEGAL.txt} +0 -0
  104. /package/dist/ui/{chunk-JZFTZ4X4.js.LEGAL.txt → chunk-NMBXHKIJ.js.LEGAL.txt} +0 -0
  105. /package/dist/ui/{chunk-JT5L6GPZ.js.LEGAL.txt → chunk-RI2JWWU3.js.LEGAL.txt} +0 -0
  106. /package/dist/ui/{prerender-Q4YSDCPB.js → prerender-M47IWV5Q.js} +0 -0
@@ -1 +1 @@
1
- import{b as F}from"./chunk-RSVO46S3.js";import{b as S,q as T}from"./chunk-AFWBSIPL.js";import{b as $}from"./chunk-62UWGWON.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-AL3TN2KI.js";import{Ga as g,Ha as t,V as N,a as f,c as h,ca as l,e as k,i as R,j as B,ma as I}from"./chunk-NZHF733K.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{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 +1 @@
1
- import{c as Q,e as z,f as N,g as Z}from"./chunk-HKINZLMW.js";import{a as ee}from"./chunk-YDO2EDVY.js";import{a as G,c as K,n as g,p as P,q as B,u as b}from"./chunk-EGEB6N4J.js";import{c as V,e as O,h as S,k as L,y as j}from"./chunk-NZHF733K.js";import{b as ie,d as ne}from"./chunk-PVAE643M.js";var re=ie((ke,te)=>{"use strict";function fe(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,o=0;return function(...a){clearTimeout(r);let n=Date.now(),c=n-o,d=t-c;d<=0?(o=n,e.apply(this,a)):r=setTimeout(()=>{o=Date.now(),e.apply(this,a)},d)}}te.exports=fe});j();var se=ne(re(),1);j();j();var oe=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},i=(e,t,r)=>(oe(e,t,"read from private field"),r?r.call(e):t.get(e)),p=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},C=(e,t,r,o)=>(oe(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);function me(e,t){return t!=null?(0,se.default)(e,t):e}var y,U,W,$,k,R,A,J,X,Ie=class{constructor(e=[]){p(this,y,void 0),p(this,U,"ready"),p(this,W,void 0),p(this,$,new Set),p(this,k,new Set),p(this,R,new Set),this.pushMessage=t=>{C(this,y,i(this,y).concat(t)),i(this,A).call(this)},this.popMessage=()=>{C(this,y,i(this,y).slice(0,-1)),i(this,A).call(this)},this.replaceMessage=(t,r)=>{C(this,y,[...i(this,y).slice(0,t),this.snapshot(r),...i(this,y).slice(t+1)]),i(this,A).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{let o=r?me(t,r):t;return i(this,$).add(o),()=>{i(this,$).delete(o)}},this["~registerStatusCallback"]=t=>(i(this,k).add(t),()=>{i(this,k).delete(t)}),this["~registerErrorCallback"]=t=>(i(this,R).add(t),()=>{i(this,R).delete(t)}),p(this,A,()=>{i(this,$).forEach(t=>t())}),p(this,J,()=>{i(this,k).forEach(t=>t())}),p(this,X,()=>{i(this,R).forEach(t=>t())}),C(this,y,e)}get status(){return i(this,U)}set status(e){C(this,U,e),i(this,J).call(this)}get error(){return i(this,W)}set error(e){C(this,W,e),i(this,X).call(this)}get messages(){return i(this,y)}set messages(e){C(this,y,[...e]),i(this,A).call(this)}};y=new WeakMap;U=new WeakMap;W=new WeakMap;$=new WeakMap;k=new WeakMap;R=new WeakMap;A=new WeakMap;J=new WeakMap;X=new WeakMap;var x,ae=class extends Q{constructor({messages:e,...t}){let r=new Ie(e);super({...t,state:r}),p(this,x,void 0),this["~registerMessagesCallback"]=(o,s)=>i(this,x)["~registerMessagesCallback"](o,s),this["~registerStatusCallback"]=o=>i(this,x)["~registerStatusCallback"](o),this["~registerErrorCallback"]=o=>i(this,x)["~registerErrorCallback"](o),C(this,x,r)}};x=new WeakMap;function Le({experimental_throttle:e,resume:t=!1,...r}={}){let o=O("chat"in r?{}:{onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});"chat"in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});let s={...r,onToolCall:u=>{var h,m;return(m=(h=o.current).onToolCall)==null?void 0:m.call(h,u)},onData:u=>{var h,m;return(m=(h=o.current).onData)==null?void 0:m.call(h,u)},onFinish:u=>{var h,m;return(m=(h=o.current).onFinish)==null?void 0:m.call(h,u)},onError:u=>{var h,m;return(m=(h=o.current).onError)==null?void 0:m.call(h,u)},sendAutomaticallyWhen:u=>{var h,m,H;return(H=(m=(h=o.current).sendAutomaticallyWhen)==null?void 0:m.call(h,u))!=null?H:!1}},a=O("chat"in r?r.chat:new ae(s));("chat"in r&&r.chat!==a.current||"id"in r&&a.current.id!==r.id)&&(a.current="chat"in r?r.chat:new ae(s));let c=S(u=>a.current["~registerMessagesCallback"](u,e),[e,a.current.id]),d=L(c,()=>a.current.messages,()=>a.current.messages),f=L(a.current["~registerStatusCallback"],()=>a.current.status,()=>a.current.status),l=L(a.current["~registerErrorCallback"],()=>a.current.error,()=>a.current.error),I=S(u=>{typeof u=="function"&&(u=u(a.current.messages)),a.current.messages=u},[a]);return V(()=>{t&&a.current.resumeStream()},[t,a]),{id:a.current.id,messages:d,setMessages:I,sendMessage:a.current.sendMessage,regenerate:a.current.regenerate,clearError:a.current.clearError,stop:a.current.stop,error:l,resumeStream:a.current.resumeStream,status:f,addToolResult:a.current.addToolOutput,addToolOutput:a.current.addToolOutput,addToolApprovalResponse:a.current.addToolApprovalResponse}}var Y=null;function _(){return Y||(Y=import("./ai-tools-5E5ELLZX.js")),Y}var ge=["doc_set","doc_create","doc_updateField","doc_edit","doc_duplicate"];function ye(e){return ge.includes(e)}function E(){let e=window;return{rootConfig:e.__ROOT_CTX.rootConfig,firebase:e.firebase}}function ve(e){let{collection:t,slug:r}=D(e);return`/cms/content/${encodeURIComponent(t)}/${encodeURIComponent(r)}`}function D(e){let t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`invalid docId: "${e}" (expected "Collection/slug")`);return{collection:e.slice(0,t),slug:e.slice(t+1).replace(/\//g,"--")}}function w(e){let{collection:t,slug:r}=D(e),{firebase:o,rootConfig:s}=E();return K(o.db,"Projects",s.projectId,"Collections",t,"Drafts",r)}function M(e){return Z(e,{isTimestamp:t=>t instanceof G,timestampToValue:t=>t.toMillis()})}function we(e){return JSON.parse(JSON.stringify(e??null))}function q(e){if(typeof e!="string")return e;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function ce(e){return Array.isArray(e)?e.map(t=>{let r={op:t?.op,path:t?.path};return t&&"value"in t&&(r.value=q(t.value)),t&&t.index!==void 0&&t.index!==null&&(r.index=t.index),r}):[]}function de(e){switch(e.op){case"set":return`Set ${e.path}`;case"insert_item":return e.index===void 0?`Insert into ${e.path} (append)`:`Insert into ${e.path} at ${e.index}`;case"remove_item":return`Remove ${e.path}[${e.index}]`;default:return`${e.op} ${e.path}`}}function De(e,t,r){let o=t.split("."),s=e;for(let c=0;c<o.length-1;c++){let d=o[c],f=Array.isArray(s)?Number(d):d,l=o[c+1];(s[f]===void 0||s[f]===null)&&(s[f]=/^\d+$/.test(l)?[]:{}),s=s[f]}let a=o[o.length-1],n=Array.isArray(s)?Number(a):a;s[n]=r}async function le(e){let t=await g(w(e));if(!t.exists())return{found:!1,fields:{}};let r=t.data();return{found:!0,fields:M(r.fields||{}),raw:r}}function F(e){return{type:"cms-write-receipt",title:e.title,summary:e.summary,docId:e.docId,adminUrl:e.docId?ve(e.docId):void 0,details:[...e.details||[],{label:"Status",value:"Saved to draft"},{label:"Publishing",value:"Manual publish still required"}]}}function v(e){return{toolName:e.toolName,title:e.title,summary:e.summary,docId:e.docId,path:e.path,details:e.details||[],error:e.error,errors:e.errors,hint:e.hint}}async function Xe(e,t){if(!ye(e))throw new Error(`not a write tool: ${e}`);switch(e){case"doc_set":return pe(t);case"doc_create":return be(t);case"doc_updateField":return Ce(t);case"doc_edit":return _e(t);case"doc_duplicate":return Te(t)}}async function pe(e){let{collection:t}=D(e.docId),r=await T(t),{validateFields:o}=await _(),s=o(e.fields,r);if(s.length>0)return v({toolName:"doc_set",title:"Replace draft fields",summary:`Could not validate the replacement fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:s,hint:"The fields payload does not match the collection schema. Read the doc and schema, then retry with a valid payload."});let a=await le(e.docId);return{toolName:"doc_set",title:"Replace draft fields",summary:`Replace all draft fields for ${e.docId}.`,docId:e.docId,before:a.found?a.fields:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:a.found?"Replace draft":"Create draft"}]}}async function be(e){let{collection:t}=D(e.docId);if((await g(w(e.docId))).exists())return v({toolName:"doc_create",title:"Create draft document",summary:`${e.docId} already exists.`,docId:e.docId,error:"ALREADY_EXISTS",hint:"Use an unused slug, or use an update tool for the existing draft."});if(e.fields){let o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return v({toolName:"doc_create",title:"Create draft document",summary:`Could not validate the initial fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload does not match the collection schema."})}return{toolName:"doc_create",title:"Create draft document",summary:`Create ${e.docId} as a new draft document.`,docId:e.docId,before:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]}}async function Ce(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not validate ${e.path} for ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value does not match the field schema. Inspect the doc and schema, then retry with a valid value."});let n=w(e.docId),c=await g(n);if(!c.exists())return v({toolName:"doc_updateField",title:"Update draft field",summary:`${e.docId} does not exist.`,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`});let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not resolve ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."});let l=M(d.fields||{}),I=we(l);return De(I,e.path,t),{toolName:"doc_updateField",title:"Update draft field",summary:`Update ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,before:l,after:I,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]}}async function _e(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=await le(e.docId);if(!s.found)return v({toolName:"doc_edit",title:"Edit draft document",summary:`${e.docId} does not exist.`,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist. Create it with \`doc_create\` first.`});let{applyDocEdits:a,validateFields:n}=await _(),c=a(s.fields,t);if(!c.ok)return v({toolName:"doc_edit",title:"Edit draft document",summary:`Operation ${c.error.opIndex+1} (${c.error.op}) could not be applied to ${e.docId}.`,docId:e.docId,error:"INVALID_OPERATION",errors:[c.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."});let d=n(c.fields,o);return d.length>0?v({toolName:"doc_edit",title:"Edit draft document",summary:`The edits to ${e.docId} did not match the collection schema.`,docId:e.docId,error:"VALIDATION_FAILED",errors:d,hint:"The resulting fields do not match the collection schema. Inspect the doc and schema, then retry with valid values."}):{toolName:"doc_edit",title:"Edit draft document",summary:`Apply ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,before:s.fields,after:c.fields,details:[{label:"Document",value:e.docId},...t.map((f,l)=>({label:`Operation ${l+1}`,value:de(f)}))]}}async function Te(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.fromDocId} does not exist.`,docId:e.toDocId,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`,details:[{label:"Source",value:e.fromDocId}]});let o=w(e.toDocId);if((await g(o)).exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.toDocId} already exists.`,docId:e.toDocId,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId}]});let a=r.data(),n=M(a.fields||{});return{toolName:"doc_duplicate",title:"Duplicate draft document",summary:`Duplicate ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,before:{},after:n,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]}}async function T(e){return await ee(e)}async function Ae(e){let{collection:t,slug:r}=D(e.docId),o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload did not match the collection schema. Read the doc with `doc_get` for an example of the expected shape, then retry with a valid payload."};let{firebase:n}=E(),c=w(e.docId),d=await g(c),l=(d.exists()?d.data():{}).sys||{},I=n.user?.email||"root-cms-ai",u={id:e.docId,collection:t,slug:r,sys:{...l,createdAt:l.createdAt??b(),createdBy:l.createdBy??I,modifiedAt:b(),modifiedBy:I,locales:l.locales??["en"]},fields:N(e.fields)};return await P(c,u),{success:!0,docId:e.docId,receipt:F({title:"Updated draft document",summary:`Replaced all draft fields for ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Replace draft fields"}]})}}async function xe(e){let{collection:t,slug:r}=D(e.docId),o=w(e.docId);if((await g(o)).exists())return{success:!1,docId:e.docId,error:"ALREADY_EXISTS",hint:"A doc with this id already exists. Use `doc_set` to overwrite."};if(e.fields){let d=await T(t),{validateFields:f}=await _(),l=f(e.fields,d);if(l.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:l,hint:"The fields payload did not match the collection schema."}}let{firebase:a}=E(),n=a.user?.email||"root-cms-ai",c={id:e.docId,collection:t,slug:r,sys:{createdAt:b(),createdBy:n,modifiedAt:b(),modifiedBy:n,locales:["en"]},fields:e.fields?N(e.fields):{}};return await P(o,c),{success:!0,docId:e.docId,receipt:F({title:"Created draft document",summary:`Created ${e.docId} as a new draft document.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]})}}async function Ee(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value did not match the field schema. Inspect the doc with `doc_get` to see the expected shape, then retry with a valid value."};let n=w(e.docId),c=await g(n);if(!c.exists())return{success:!1,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"The path could not be resolved against the current draft. Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."};let{firebase:l}=E(),I=`fields.${f.path}`,u=N(t);return await B(n,{[I]:u,"sys.modifiedAt":b(),"sys.modifiedBy":l.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,path:e.path,receipt:F({title:"Updated draft field",summary:`Updated ${e.path} in ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]})}}async function Oe(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=w(e.docId),a=await g(s);if(!a.exists())return{success:!1,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let n=a.data(),c=M(n.fields||{}),{applyDocEdits:d,validateFields:f}=await _(),l=d(c,t);if(!l.ok)return{success:!1,docId:e.docId,error:"INVALID_OPERATION",errors:[l.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."};let I=f(l.fields,o);if(I.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:I,hint:"The resulting fields did not match the collection schema. Inspect the doc with `doc_get`, then retry with valid values."};let{firebase:u}=E();return await B(s,{fields:N(l.fields),"sys.modifiedAt":b(),"sys.modifiedBy":u.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,receipt:F({title:"Edited draft document",summary:`Applied ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operations",value:String(t.length)},...t.map((h,m)=>({label:`Operation ${m+1}`,value:de(h)}))]})}}async function Se(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return{success:!1,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`};let o=w(e.toDocId);if((await g(o)).exists())return{success:!1,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`};let{collection:a,slug:n}=D(e.toDocId),{firebase:c}=E(),d=c.user?.email||"root-cms-ai",f=r.data(),l={id:e.toDocId,collection:a,slug:n,sys:{createdAt:b(),createdBy:d,modifiedAt:b(),modifiedBy:d,locales:f.sys?.locales??["en"]},fields:f.fields||{}};return await P(o,l),{success:!0,fromDocId:e.fromDocId,toDocId:e.toDocId,receipt:F({title:"Duplicated draft document",summary:`Duplicated ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]})}}async function Ne(e){let t=await fetch("/cms/api/ai.translate",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:e.sourceText,targetLocales:e.targetLocales,description:e.description})});if(!t.ok)throw new Error(`ai.translate failed: ${t.status}`);let r=await t.json();if(!r.success)throw new Error(r.error||"translation failed");return{translations:r.translations}}var $e={doc_set:Ae,doc_create:xe,doc_updateField:Ee,doc_edit:Oe,doc_duplicate:Se,doc_translateField:Ne};async function Ye(e,t){let r=$e[e];if(!r)return{error:"UNKNOWN_TOOL",toolName:e};try{return await r(t)}catch(o){return console.error(`tool ${e} failed:`,o),{error:"TOOL_EXECUTION_FAILED",message:o?.message||String(o)}}}export{Le as a,ye as b,Xe as c,Ye as d};
1
+ import{c as Q,e as z,f as N,g as Z}from"./chunk-344GZOGG.js";import{a as ee}from"./chunk-YDO2EDVY.js";import{a as G,c as K,n as g,p as P,q as B,u as b}from"./chunk-EGEB6N4J.js";import{c as V,e as O,h as S,k as L,y as j}from"./chunk-4CUWZQXT.js";import{b as ie,d as ne}from"./chunk-PVAE643M.js";var re=ie((ke,te)=>{"use strict";function fe(e,t){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let r,o=0;return function(...a){clearTimeout(r);let n=Date.now(),c=n-o,d=t-c;d<=0?(o=n,e.apply(this,a)):r=setTimeout(()=>{o=Date.now(),e.apply(this,a)},d)}}te.exports=fe});j();var se=ne(re(),1);j();j();var oe=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},i=(e,t,r)=>(oe(e,t,"read from private field"),r?r.call(e):t.get(e)),p=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},C=(e,t,r,o)=>(oe(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);function me(e,t){return t!=null?(0,se.default)(e,t):e}var y,U,W,$,k,R,A,J,X,Ie=class{constructor(e=[]){p(this,y,void 0),p(this,U,"ready"),p(this,W,void 0),p(this,$,new Set),p(this,k,new Set),p(this,R,new Set),this.pushMessage=t=>{C(this,y,i(this,y).concat(t)),i(this,A).call(this)},this.popMessage=()=>{C(this,y,i(this,y).slice(0,-1)),i(this,A).call(this)},this.replaceMessage=(t,r)=>{C(this,y,[...i(this,y).slice(0,t),this.snapshot(r),...i(this,y).slice(t+1)]),i(this,A).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{let o=r?me(t,r):t;return i(this,$).add(o),()=>{i(this,$).delete(o)}},this["~registerStatusCallback"]=t=>(i(this,k).add(t),()=>{i(this,k).delete(t)}),this["~registerErrorCallback"]=t=>(i(this,R).add(t),()=>{i(this,R).delete(t)}),p(this,A,()=>{i(this,$).forEach(t=>t())}),p(this,J,()=>{i(this,k).forEach(t=>t())}),p(this,X,()=>{i(this,R).forEach(t=>t())}),C(this,y,e)}get status(){return i(this,U)}set status(e){C(this,U,e),i(this,J).call(this)}get error(){return i(this,W)}set error(e){C(this,W,e),i(this,X).call(this)}get messages(){return i(this,y)}set messages(e){C(this,y,[...e]),i(this,A).call(this)}};y=new WeakMap;U=new WeakMap;W=new WeakMap;$=new WeakMap;k=new WeakMap;R=new WeakMap;A=new WeakMap;J=new WeakMap;X=new WeakMap;var x,ae=class extends Q{constructor({messages:e,...t}){let r=new Ie(e);super({...t,state:r}),p(this,x,void 0),this["~registerMessagesCallback"]=(o,s)=>i(this,x)["~registerMessagesCallback"](o,s),this["~registerStatusCallback"]=o=>i(this,x)["~registerStatusCallback"](o),this["~registerErrorCallback"]=o=>i(this,x)["~registerErrorCallback"](o),C(this,x,r)}};x=new WeakMap;function Le({experimental_throttle:e,resume:t=!1,...r}={}){let o=O("chat"in r?{}:{onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});"chat"in r||(o.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen});let s={...r,onToolCall:u=>{var h,m;return(m=(h=o.current).onToolCall)==null?void 0:m.call(h,u)},onData:u=>{var h,m;return(m=(h=o.current).onData)==null?void 0:m.call(h,u)},onFinish:u=>{var h,m;return(m=(h=o.current).onFinish)==null?void 0:m.call(h,u)},onError:u=>{var h,m;return(m=(h=o.current).onError)==null?void 0:m.call(h,u)},sendAutomaticallyWhen:u=>{var h,m,H;return(H=(m=(h=o.current).sendAutomaticallyWhen)==null?void 0:m.call(h,u))!=null?H:!1}},a=O("chat"in r?r.chat:new ae(s));("chat"in r&&r.chat!==a.current||"id"in r&&a.current.id!==r.id)&&(a.current="chat"in r?r.chat:new ae(s));let c=S(u=>a.current["~registerMessagesCallback"](u,e),[e,a.current.id]),d=L(c,()=>a.current.messages,()=>a.current.messages),f=L(a.current["~registerStatusCallback"],()=>a.current.status,()=>a.current.status),l=L(a.current["~registerErrorCallback"],()=>a.current.error,()=>a.current.error),I=S(u=>{typeof u=="function"&&(u=u(a.current.messages)),a.current.messages=u},[a]);return V(()=>{t&&a.current.resumeStream()},[t,a]),{id:a.current.id,messages:d,setMessages:I,sendMessage:a.current.sendMessage,regenerate:a.current.regenerate,clearError:a.current.clearError,stop:a.current.stop,error:l,resumeStream:a.current.resumeStream,status:f,addToolResult:a.current.addToolOutput,addToolOutput:a.current.addToolOutput,addToolApprovalResponse:a.current.addToolApprovalResponse}}var Y=null;function _(){return Y||(Y=import("./ai-tools-4DWMFQS6.js")),Y}var ge=["doc_set","doc_create","doc_updateField","doc_edit","doc_duplicate"];function ye(e){return ge.includes(e)}function E(){let e=window;return{rootConfig:e.__ROOT_CTX.rootConfig,firebase:e.firebase}}function ve(e){let{collection:t,slug:r}=D(e);return`/cms/content/${encodeURIComponent(t)}/${encodeURIComponent(r)}`}function D(e){let t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`invalid docId: "${e}" (expected "Collection/slug")`);return{collection:e.slice(0,t),slug:e.slice(t+1).replace(/\//g,"--")}}function w(e){let{collection:t,slug:r}=D(e),{firebase:o,rootConfig:s}=E();return K(o.db,"Projects",s.projectId,"Collections",t,"Drafts",r)}function M(e){return Z(e,{isTimestamp:t=>t instanceof G,timestampToValue:t=>t.toMillis()})}function we(e){return JSON.parse(JSON.stringify(e??null))}function q(e){if(typeof e!="string")return e;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t)}catch{return e}return e}function ce(e){return Array.isArray(e)?e.map(t=>{let r={op:t?.op,path:t?.path};return t&&"value"in t&&(r.value=q(t.value)),t&&t.index!==void 0&&t.index!==null&&(r.index=t.index),r}):[]}function de(e){switch(e.op){case"set":return`Set ${e.path}`;case"insert_item":return e.index===void 0?`Insert into ${e.path} (append)`:`Insert into ${e.path} at ${e.index}`;case"remove_item":return`Remove ${e.path}[${e.index}]`;default:return`${e.op} ${e.path}`}}function De(e,t,r){let o=t.split("."),s=e;for(let c=0;c<o.length-1;c++){let d=o[c],f=Array.isArray(s)?Number(d):d,l=o[c+1];(s[f]===void 0||s[f]===null)&&(s[f]=/^\d+$/.test(l)?[]:{}),s=s[f]}let a=o[o.length-1],n=Array.isArray(s)?Number(a):a;s[n]=r}async function le(e){let t=await g(w(e));if(!t.exists())return{found:!1,fields:{}};let r=t.data();return{found:!0,fields:M(r.fields||{}),raw:r}}function F(e){return{type:"cms-write-receipt",title:e.title,summary:e.summary,docId:e.docId,adminUrl:e.docId?ve(e.docId):void 0,details:[...e.details||[],{label:"Status",value:"Saved to draft"},{label:"Publishing",value:"Manual publish still required"}]}}function v(e){return{toolName:e.toolName,title:e.title,summary:e.summary,docId:e.docId,path:e.path,details:e.details||[],error:e.error,errors:e.errors,hint:e.hint}}async function Xe(e,t){if(!ye(e))throw new Error(`not a write tool: ${e}`);switch(e){case"doc_set":return pe(t);case"doc_create":return be(t);case"doc_updateField":return Ce(t);case"doc_edit":return _e(t);case"doc_duplicate":return Te(t)}}async function pe(e){let{collection:t}=D(e.docId),r=await T(t),{validateFields:o}=await _(),s=o(e.fields,r);if(s.length>0)return v({toolName:"doc_set",title:"Replace draft fields",summary:`Could not validate the replacement fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:s,hint:"The fields payload does not match the collection schema. Read the doc and schema, then retry with a valid payload."});let a=await le(e.docId);return{toolName:"doc_set",title:"Replace draft fields",summary:`Replace all draft fields for ${e.docId}.`,docId:e.docId,before:a.found?a.fields:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:a.found?"Replace draft":"Create draft"}]}}async function be(e){let{collection:t}=D(e.docId);if((await g(w(e.docId))).exists())return v({toolName:"doc_create",title:"Create draft document",summary:`${e.docId} already exists.`,docId:e.docId,error:"ALREADY_EXISTS",hint:"Use an unused slug, or use an update tool for the existing draft."});if(e.fields){let o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return v({toolName:"doc_create",title:"Create draft document",summary:`Could not validate the initial fields for ${e.docId}.`,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload does not match the collection schema."})}return{toolName:"doc_create",title:"Create draft document",summary:`Create ${e.docId} as a new draft document.`,docId:e.docId,before:{},after:e.fields||{},details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]}}async function Ce(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not validate ${e.path} for ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value does not match the field schema. Inspect the doc and schema, then retry with a valid value."});let n=w(e.docId),c=await g(n);if(!c.exists())return v({toolName:"doc_updateField",title:"Update draft field",summary:`${e.docId} does not exist.`,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`});let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return v({toolName:"doc_updateField",title:"Update draft field",summary:`Could not resolve ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."});let l=M(d.fields||{}),I=we(l);return De(I,e.path,t),{toolName:"doc_updateField",title:"Update draft field",summary:`Update ${e.path} in ${e.docId}.`,docId:e.docId,path:e.path,before:l,after:I,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]}}async function _e(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=await le(e.docId);if(!s.found)return v({toolName:"doc_edit",title:"Edit draft document",summary:`${e.docId} does not exist.`,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist. Create it with \`doc_create\` first.`});let{applyDocEdits:a,validateFields:n}=await _(),c=a(s.fields,t);if(!c.ok)return v({toolName:"doc_edit",title:"Edit draft document",summary:`Operation ${c.error.opIndex+1} (${c.error.op}) could not be applied to ${e.docId}.`,docId:e.docId,error:"INVALID_OPERATION",errors:[c.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."});let d=n(c.fields,o);return d.length>0?v({toolName:"doc_edit",title:"Edit draft document",summary:`The edits to ${e.docId} did not match the collection schema.`,docId:e.docId,error:"VALIDATION_FAILED",errors:d,hint:"The resulting fields do not match the collection schema. Inspect the doc and schema, then retry with valid values."}):{toolName:"doc_edit",title:"Edit draft document",summary:`Apply ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,before:s.fields,after:c.fields,details:[{label:"Document",value:e.docId},...t.map((f,l)=>({label:`Operation ${l+1}`,value:de(f)}))]}}async function Te(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.fromDocId} does not exist.`,docId:e.toDocId,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`,details:[{label:"Source",value:e.fromDocId}]});let o=w(e.toDocId);if((await g(o)).exists())return v({toolName:"doc_duplicate",title:"Duplicate draft document",summary:`${e.toDocId} already exists.`,docId:e.toDocId,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId}]});let a=r.data(),n=M(a.fields||{});return{toolName:"doc_duplicate",title:"Duplicate draft document",summary:`Duplicate ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,before:{},after:n,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]}}async function T(e){return await ee(e)}async function Ae(e){let{collection:t,slug:r}=D(e.docId),o=await T(t),{validateFields:s}=await _(),a=s(e.fields,o);if(a.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:a,hint:"The fields payload did not match the collection schema. Read the doc with `doc_get` for an example of the expected shape, then retry with a valid payload."};let{firebase:n}=E(),c=w(e.docId),d=await g(c),l=(d.exists()?d.data():{}).sys||{},I=n.user?.email||"root-cms-ai",u={id:e.docId,collection:t,slug:r,sys:{...l,createdAt:l.createdAt??b(),createdBy:l.createdBy??I,modifiedAt:b(),modifiedBy:I,locales:l.locales??["en"]},fields:N(e.fields)};return await P(c,u),{success:!0,docId:e.docId,receipt:F({title:"Updated draft document",summary:`Replaced all draft fields for ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Replace draft fields"}]})}}async function xe(e){let{collection:t,slug:r}=D(e.docId),o=w(e.docId);if((await g(o)).exists())return{success:!1,docId:e.docId,error:"ALREADY_EXISTS",hint:"A doc with this id already exists. Use `doc_set` to overwrite."};if(e.fields){let d=await T(t),{validateFields:f}=await _(),l=f(e.fields,d);if(l.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:l,hint:"The fields payload did not match the collection schema."}}let{firebase:a}=E(),n=a.user?.email||"root-cms-ai",c={id:e.docId,collection:t,slug:r,sys:{createdAt:b(),createdBy:n,modifiedAt:b(),modifiedBy:n,locales:["en"]},fields:e.fields?N(e.fields):{}};return await P(o,c),{success:!0,docId:e.docId,receipt:F({title:"Created draft document",summary:`Created ${e.docId} as a new draft document.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operation",value:"Create draft"}]})}}async function Ee(e){let t=q(e.value),{collection:r}=D(e.docId),o=await T(r),{validateValueAtPath:s}=await _(),a=s(o,e.path,t);if(a.length>0)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:a,hint:"The value did not match the field schema. Inspect the doc with `doc_get` to see the expected shape, then retry with a valid value."};let n=w(e.docId),c=await g(n);if(!c.exists())return{success:!1,docId:e.docId,path:e.path,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let d=c.data(),f=z(d.fields||{},e.path);if(!f.ok)return{success:!1,docId:e.docId,path:e.path,error:"VALIDATION_FAILED",errors:[f.error],hint:"The path could not be resolved against the current draft. Use zero-based array indices for existing array items, or set the whole array field when appending or removing items."};let{firebase:l}=E(),I=`fields.${f.path}`,u=N(t);return await B(n,{[I]:u,"sys.modifiedAt":b(),"sys.modifiedBy":l.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,path:e.path,receipt:F({title:"Updated draft field",summary:`Updated ${e.path} in ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Field path",value:e.path},{label:"Operation",value:"Update draft field"}]})}}async function Oe(e){let t=ce(e.operations),{collection:r}=D(e.docId),o=await T(r),s=w(e.docId),a=await g(s);if(!a.exists())return{success:!1,docId:e.docId,error:"NOT_FOUND",hint:`Doc "${e.docId}" does not exist.`};let n=a.data(),c=M(n.fields||{}),{applyDocEdits:d,validateFields:f}=await _(),l=d(c,t);if(!l.ok)return{success:!1,docId:e.docId,error:"INVALID_OPERATION",errors:[l.error],hint:"Fix the failing operation. Use zero-based array indices, target arrays for insert_item/remove_item, and read the doc with `doc_get` to confirm the current shape."};let I=f(l.fields,o);if(I.length>0)return{success:!1,docId:e.docId,error:"VALIDATION_FAILED",errors:I,hint:"The resulting fields did not match the collection schema. Inspect the doc with `doc_get`, then retry with valid values."};let{firebase:u}=E();return await B(s,{fields:N(l.fields),"sys.modifiedAt":b(),"sys.modifiedBy":u.user?.email||"root-cms-ai"}),{success:!0,docId:e.docId,receipt:F({title:"Edited draft document",summary:`Applied ${t.length} edit${t.length===1?"":"s"} to ${e.docId}.`,docId:e.docId,details:[{label:"Document",value:e.docId},{label:"Operations",value:String(t.length)},...t.map((h,m)=>({label:`Operation ${m+1}`,value:de(h)}))]})}}async function Se(e){let t=w(e.fromDocId),r=await g(t);if(!r.exists())return{success:!1,error:"NOT_FOUND",hint:`Source doc "${e.fromDocId}" does not exist.`};let o=w(e.toDocId);if((await g(o)).exists())return{success:!1,error:"ALREADY_EXISTS",hint:`Target doc "${e.toDocId}" already exists.`};let{collection:a,slug:n}=D(e.toDocId),{firebase:c}=E(),d=c.user?.email||"root-cms-ai",f=r.data(),l={id:e.toDocId,collection:a,slug:n,sys:{createdAt:b(),createdBy:d,modifiedAt:b(),modifiedBy:d,locales:f.sys?.locales??["en"]},fields:f.fields||{}};return await P(o,l),{success:!0,fromDocId:e.fromDocId,toDocId:e.toDocId,receipt:F({title:"Duplicated draft document",summary:`Duplicated ${e.fromDocId} to ${e.toDocId}.`,docId:e.toDocId,details:[{label:"Source",value:e.fromDocId},{label:"Target",value:e.toDocId},{label:"Operation",value:"Create draft copy"}]})}}async function Ne(e){let t=await fetch("/cms/api/ai.translate",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({sourceText:e.sourceText,targetLocales:e.targetLocales,description:e.description})});if(!t.ok)throw new Error(`ai.translate failed: ${t.status}`);let r=await t.json();if(!r.success)throw new Error(r.error||"translation failed");return{translations:r.translations}}var $e={doc_set:Ae,doc_create:xe,doc_updateField:Ee,doc_edit:Oe,doc_duplicate:Se,doc_translateField:Ne};async function Ye(e,t){let r=$e[e];if(!r)return{error:"UNKNOWN_TOOL",toolName:e};try{return await r(t)}catch(o){return console.error(`tool ${e} failed:`,o),{error:"TOOL_EXECUTION_FAILED",message:o?.message||String(o)}}}export{Le as a,ye as b,Xe as c,Ye as d};
@@ -1 +1 @@
1
- import{f as n}from"./chunk-AL3TN2KI.js";import{Ha as t}from"./chunk-NZHF733K.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};
1
+ import{f as n}from"./chunk-RPOP6MVJ.js";import{Ga as t}from"./chunk-4CUWZQXT.js";function f(a){let{className:r,as:h,size:e,weight:o,color:i,children:g,...s}=a;return t(h||"h2",{...s,className:n(r,"heading",e&&`size:${e}`,o&&`weight:${o}`,i&&`color:${i}`),children:g})}export{f as a};
@@ -1 +1 @@
1
- import{d as Q}from"./chunk-AL3TN2KI.js";import{a as z,c as d,e as i,h as c,j as h}from"./chunk-NZHF733K.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-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 +1 @@
1
- import{a as k}from"./chunk-KFAZBEPV.js";import{b as B}from"./chunk-W3HIZQ4Z.js";import{a as H}from"./chunk-PJA7YP4A.js";import{g as D}from"./chunk-ORXEMIQC.js";import{a as b}from"./chunk-EGEB6N4J.js";import{f as C}from"./chunk-AL3TN2KI.js";import{Aa as E,Ac as U,Ea as F,F as M,Ga as L,Ha as t,U as w,V as N,a as d,c as v,ea as p,g as A,j as Y,ta as I,va as j,xa as O}from"./chunk-NZHF733K.js";import{d as z}from"./chunk-KUCVLANF.js";Y();var S=50,tt=[{value:"all",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function Q(e){let[a,o]=d(!0),[n,i]=d([]);return v(()=>{D(e?{limit:e}:void 0).then(r=>{i(r),o(!1)})},[e]),{loading:a,actions:n}}function xt(e){if(e.compact)return t(ot,{...e});let[a,o]=d(""),[n]=M(a,300),[i,r]=d([]),[m,q]=d([]),[g,G]=d("all"),[h,T]=d(1),{actions:l,loading:R}=Q(),X=A(()=>{let s=new Set;return l.forEach(c=>s.add(c.action)),Array.from(s).sort()},[l]),Z=A(()=>{let s=new Set;return l.forEach(c=>{c.by&&s.add(c.by)}),Array.from(s).sort()},[l]),u=A(()=>{let s=Date.now();return l.filter(c=>{if(n){let f=n.toLowerCase(),x=c.action.toLowerCase().includes(f),_=c.by?.toLowerCase().includes(f),K=ct(c.metadata).toLowerCase().includes(f);if(!x&&!_&&!K)return!1}if(i.length>0&&!i.includes(c.action)||m.length>0&&(!c.by||!m.includes(c.by)))return!1;if(g&&g!=="all"){let f=J(c.timestamp);if(!f)return!1;let x=f.toMillis(),_=0;switch(g){case"1h":_=s-3600*1e3;break;case"24h":_=s-1440*60*1e3;break;case"7d":_=s-10080*60*1e3;break;case"30d":_=s-720*60*60*1e3;break}if(x<_)return!1}return!0})},[l,n,i,m,g]),$=e.compact?1:Math.ceil(u.length/S),y=A(()=>{if(e.compact)return u;let s=(h-1)*S;return u.slice(s,s+S)},[u,h,e.compact]);return v(()=>{T(1)},[n,i,m,g]),R?t("div",{className:`ActionsLog ActionsLog--loading ${e.className||""}`,children:t(N,{color:"gray",size:"xl"})}):t("div",{className:`ActionsLog ${e.className||""}`,children:[!e.compact&&t("div",{className:"ActionsLog__tableHeader",children:[t("div",{className:"ActionsLog__filters",children:[t(j,{className:"ActionsLog__filters__search",placeholder:"Search actions...",icon:t(U,{size:16}),value:a,onChange:s=>o(s.target.value)}),t(I,{className:"ActionsLog__filters__select",placeholder:"Filter by action",clearable:!0,searchable:!0,data:X,value:i,onChange:r}),t(I,{className:"ActionsLog__filters__select",placeholder:"Filter by user",clearable:!0,searchable:!0,data:Z,value:m,onChange:q}),t(E,{className:"ActionsLog__filters__select",placeholder:"Filter by time",data:tt,value:g,onChange:G})]}),t("div",{className:"ActionsLog__summary",children:["Showing ",y.length," of ",u.length," ","actions",u.length!==l.length&&` (filtered from ${l.length} total)`]})]}),t(H,{className:"ActionsLog__tableSurface",children:t(F,{className:"ActionsLog__table",children:[t("thead",{children:t("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[t("th",{className:"ActionsLogs__table__header",children:"Timestamp"}),t("th",{className:"ActionsLogs__table__header",children:"User"}),t("th",{className:"ActionsLogs__table__header",children:"Action"}),t("th",{className:"ActionsLogs__table__header",children:"Details"}),t("th",{className:"ActionsLogs__table__header",children:"Links"})]})}),t("tbody",{children:[y.map((s,c)=>t("tr",{className:"ActionsLogs__table__row",children:[t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:V(s.timestamp)}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t("span",{className:"ActionsLogs__user",children:s.by?t(z,{children:[t(k,{email:s.by,size:20}),t("span",{className:"ActionsLogs__user__email",children:s.by})]}):"\u2014"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--action",children:t("span",{className:"ActionsLogs__action",children:s.action})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--metadata",children:t(W,{metadata:s.metadata})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--links",children:t(P,{action:s})})]},c)),y.length===0&&t("tr",{children:t("td",{colSpan:5,className:"ActionsLogs__table__col ActionsLogs__table__col--empty",children:"No actions found matching your filters."})})]})]})}),!e.compact&&$>1&&t("div",{className:"ActionsLog__pagination",children:t(O,{total:$,value:h,onChange:T,size:"sm"})})]})}function W(e){let{metadata:a}=e;if(!a||Object.keys(a).length===0)return t("span",{className:"ActionsLogs__metadata--empty",children:"\u2014"});let o=Object.entries(a);return t("div",{className:"ActionsLogs__metadata",children:o.map(([n,i])=>t("div",{className:"ActionsLogs__metadata__item",children:[t("span",{className:"ActionsLogs__metadata__key",children:[n,":"]})," ",t("span",{className:"ActionsLogs__metadata__value",children:et(i)})]},n))})}function et(e){if(e==null)return"\u2014";if(Array.isArray(e))return e.length===0?"[]":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")} (+${e.length-3} more)`;if(typeof e=="object"){let a=at(e);try{return JSON.stringify(a)}catch(o){console.error(o),console.error("failed to stringify json:",a)}}return String(e)}function at(e){let a={};return Object.entries(e).forEach(([o,n])=>{o.startsWith("_")||(a[o]=n)}),a}function P(e){let{action:a}=e,o=[];function n(i){return e.label||i}return a.action!=="doc.delete"&&a.metadata?.docId&&o.push(t(L,{transition:"pop",label:a.metadata.docId,children:t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${a.metadata.docId}`,children:n("Open doc")})},"doc")),a.action!=="datasource.delete"&&a.metadata?.datasourceId&&o.push(t(L,{transition:"pop",label:a.metadata.datasourceId,children:t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${a.metadata.datasourceId}`,children:n("Open data source")})},"datasource")),a.action!=="release.delete"&&a.metadata?.releaseId&&o.push(t(L,{transition:"pop",label:a.metadata.releaseId,children:t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${a.metadata.releaseId}`,children:n("Open release")})},"release")),a.metadata?.sheetId&&o.push(t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:B(a.metadata.sheetId),target:"_blank",children:n("Open sheet")},"sheet")),a.action.startsWith("acls.")&&o.push(t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:n("Open settings")},"settings")),a.links&&a.links.forEach((i,r)=>{o.push(t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:i.url,target:i.target,children:i.label},`link-${r}`))}),o.length===0?t("span",{className:"ActionsLogs__links--empty"}):(e.limit&&(o=o.slice(0,e.limit)),t("div",{className:"ActionsLogs__table__buttons",children:o}))}function ot(e){let{actions:a,loading:o}=Q(e.limit||10);return o?t("div",{className:C(e.className,"ActionLogsCompact","ActionLogsCompact--loading"),children:t(N,{color:"gray",size:"xl"})}):t("div",{className:C(e.className,"ActionLogsCompact"),children:t(w,{className:"ActionLogsCompact__table",multiple:!0,children:a.map((n,i)=>t(w.Item,{label:t(nt,{action:n}),children:t(st,{action:n})},i))})})}function nt(e){let a=e.action,o=it(a),n=e.action.by||"";return t("div",{className:"ActionLogsCompactItemPreview",children:[t("div",{className:"ActionLogsCompactItemPreview__user",children:t(k,{email:n,size:20})}),t("div",{className:"ActionLogsCompactItemPreview__timestamp",children:V(a.timestamp)}),t("div",{className:"ActionLogsCompactItemPreview__action",children:a.action}),t("div",{className:"ActionLogsCompactItemPreview__actionMetaId",children:o}),t("div",{className:"ActionLogsCompactItemPreview__buttons",children:t(P,{action:a,label:"Open",limit:1})})]})}function st(e){let a=e.action,o={user:a.by,...a.metadata};return t("div",{className:"ActionLogsCompactItemDetails",children:[t(W,{metadata:o}),t(P,{action:a})]})}function it(e){for(let a of Object.keys(e.metadata||{}))if(a.toLowerCase().endsWith("id"))return e.metadata[a];return""}function J(e){return e?e instanceof b?e:typeof e=="object"&&typeof e._seconds=="number"?new b(e._seconds,e._nanoseconds||0):typeof e=="object"&&typeof e.seconds=="number"?new b(e.seconds,e.nanoseconds||0):typeof e=="number"?b.fromMillis(e):null:null}function V(e){let a=J(e);if(!a)return"Invalid date";let o=a.toDate(),n=String(o.getMonth()+1).padStart(2,"0"),i=String(o.getDate()).padStart(2,"0"),r=String(o.getHours()).padStart(2,"0"),m=String(o.getMinutes()).padStart(2,"0");return`${n}/${i} ${r}:${m}`}function ct(e){function a(o){return o===null?"null":typeof o>"u"?"undefined":typeof o=="string"?`"${o.replaceAll('"','\\"')}"`:typeof o!="object"?String(o):Array.isArray(o)?`[${o.map(a).join(", ")}]`:`{${Object.entries(o).map(([i,r])=>`${i}: ${a(r)}`).join(", ")}}`}return a(e)}export{xt as a};
1
+ import{a as k}from"./chunk-HYARD7BK.js";import{b as B}from"./chunk-W3HIZQ4Z.js";import{a as H}from"./chunk-32LRQ5MJ.js";import{g as D}from"./chunk-ORXEMIQC.js";import{a as b}from"./chunk-EGEB6N4J.js";import{f as C}from"./chunk-RPOP6MVJ.js";import{Da as F,F as M,Fa as L,Ga as t,U as w,V as N,a as d,c as v,da as p,g as A,j as Y,sa as I,ua as j,wa as O,za as E,zc as U}from"./chunk-4CUWZQXT.js";import{d as z}from"./chunk-KUCVLANF.js";Y();var S=50,tt=[{value:"all",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function Q(e){let[a,o]=d(!0),[n,i]=d([]);return v(()=>{D(e?{limit:e}:void 0).then(r=>{i(r),o(!1)})},[e]),{loading:a,actions:n}}function xt(e){if(e.compact)return t(ot,{...e});let[a,o]=d(""),[n]=M(a,300),[i,r]=d([]),[m,q]=d([]),[g,G]=d("all"),[h,T]=d(1),{actions:l,loading:R}=Q(),X=A(()=>{let s=new Set;return l.forEach(c=>s.add(c.action)),Array.from(s).sort()},[l]),Z=A(()=>{let s=new Set;return l.forEach(c=>{c.by&&s.add(c.by)}),Array.from(s).sort()},[l]),u=A(()=>{let s=Date.now();return l.filter(c=>{if(n){let f=n.toLowerCase(),x=c.action.toLowerCase().includes(f),_=c.by?.toLowerCase().includes(f),K=ct(c.metadata).toLowerCase().includes(f);if(!x&&!_&&!K)return!1}if(i.length>0&&!i.includes(c.action)||m.length>0&&(!c.by||!m.includes(c.by)))return!1;if(g&&g!=="all"){let f=J(c.timestamp);if(!f)return!1;let x=f.toMillis(),_=0;switch(g){case"1h":_=s-3600*1e3;break;case"24h":_=s-1440*60*1e3;break;case"7d":_=s-10080*60*1e3;break;case"30d":_=s-720*60*60*1e3;break}if(x<_)return!1}return!0})},[l,n,i,m,g]),$=e.compact?1:Math.ceil(u.length/S),y=A(()=>{if(e.compact)return u;let s=(h-1)*S;return u.slice(s,s+S)},[u,h,e.compact]);return v(()=>{T(1)},[n,i,m,g]),R?t("div",{className:`ActionsLog ActionsLog--loading ${e.className||""}`,children:t(N,{color:"gray",size:"xl"})}):t("div",{className:`ActionsLog ${e.className||""}`,children:[!e.compact&&t("div",{className:"ActionsLog__tableHeader",children:[t("div",{className:"ActionsLog__filters",children:[t(j,{className:"ActionsLog__filters__search",placeholder:"Search actions...",icon:t(U,{size:16}),value:a,onChange:s=>o(s.target.value)}),t(I,{className:"ActionsLog__filters__select",placeholder:"Filter by action",clearable:!0,searchable:!0,data:X,value:i,onChange:r}),t(I,{className:"ActionsLog__filters__select",placeholder:"Filter by user",clearable:!0,searchable:!0,data:Z,value:m,onChange:q}),t(E,{className:"ActionsLog__filters__select",placeholder:"Filter by time",data:tt,value:g,onChange:G})]}),t("div",{className:"ActionsLog__summary",children:["Showing ",y.length," of ",u.length," ","actions",u.length!==l.length&&` (filtered from ${l.length} total)`]})]}),t(H,{className:"ActionsLog__tableSurface",children:t(F,{className:"ActionsLog__table",children:[t("thead",{children:t("tr",{className:"ActionsLogs__table__row ActionsLogs__table__row--header",children:[t("th",{className:"ActionsLogs__table__header",children:"Timestamp"}),t("th",{className:"ActionsLogs__table__header",children:"User"}),t("th",{className:"ActionsLogs__table__header",children:"Action"}),t("th",{className:"ActionsLogs__table__header",children:"Details"}),t("th",{className:"ActionsLogs__table__header",children:"Links"})]})}),t("tbody",{children:[y.map((s,c)=>t("tr",{className:"ActionsLogs__table__row",children:[t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:V(s.timestamp)}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--nowrap",children:t("span",{className:"ActionsLogs__user",children:s.by?t(z,{children:[t(k,{email:s.by,size:20}),t("span",{className:"ActionsLogs__user__email",children:s.by})]}):"\u2014"})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--action",children:t("span",{className:"ActionsLogs__action",children:s.action})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--metadata",children:t(W,{metadata:s.metadata})}),t("td",{className:"ActionsLogs__table__col ActionsLogs__table__col--links",children:t(P,{action:s})})]},c)),y.length===0&&t("tr",{children:t("td",{colSpan:5,className:"ActionsLogs__table__col ActionsLogs__table__col--empty",children:"No actions found matching your filters."})})]})]})}),!e.compact&&$>1&&t("div",{className:"ActionsLog__pagination",children:t(O,{total:$,value:h,onChange:T,size:"sm"})})]})}function W(e){let{metadata:a}=e;if(!a||Object.keys(a).length===0)return t("span",{className:"ActionsLogs__metadata--empty",children:"\u2014"});let o=Object.entries(a);return t("div",{className:"ActionsLogs__metadata",children:o.map(([n,i])=>t("div",{className:"ActionsLogs__metadata__item",children:[t("span",{className:"ActionsLogs__metadata__key",children:[n,":"]})," ",t("span",{className:"ActionsLogs__metadata__value",children:et(i)})]},n))})}function et(e){if(e==null)return"\u2014";if(Array.isArray(e))return e.length===0?"[]":e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")} (+${e.length-3} more)`;if(typeof e=="object"){let a=at(e);try{return JSON.stringify(a)}catch(o){console.error(o),console.error("failed to stringify json:",a)}}return String(e)}function at(e){let a={};return Object.entries(e).forEach(([o,n])=>{o.startsWith("_")||(a[o]=n)}),a}function P(e){let{action:a}=e,o=[];function n(i){return e.label||i}return a.action!=="doc.delete"&&a.metadata?.docId&&o.push(t(L,{transition:"pop",label:a.metadata.docId,children:t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/content/${a.metadata.docId}`,children:n("Open doc")})},"doc")),a.action!=="datasource.delete"&&a.metadata?.datasourceId&&o.push(t(L,{transition:"pop",label:a.metadata.datasourceId,children:t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/data/${a.metadata.datasourceId}`,children:n("Open data source")})},"datasource")),a.action!=="release.delete"&&a.metadata?.releaseId&&o.push(t(L,{transition:"pop",label:a.metadata.releaseId,children:t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:`/cms/releases/${a.metadata.releaseId}`,children:n("Open release")})},"release")),a.metadata?.sheetId&&o.push(t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:B(a.metadata.sheetId),target:"_blank",children:n("Open sheet")},"sheet")),a.action.startsWith("acls.")&&o.push(t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:"/cms/settings",children:n("Open settings")},"settings")),a.links&&a.links.forEach((i,r)=>{o.push(t(p,{component:"a",variant:"default",size:"xs",compact:!0,href:i.url,target:i.target,children:i.label},`link-${r}`))}),o.length===0?t("span",{className:"ActionsLogs__links--empty"}):(e.limit&&(o=o.slice(0,e.limit)),t("div",{className:"ActionsLogs__table__buttons",children:o}))}function ot(e){let{actions:a,loading:o}=Q(e.limit||10);return o?t("div",{className:C(e.className,"ActionLogsCompact","ActionLogsCompact--loading"),children:t(N,{color:"gray",size:"xl"})}):t("div",{className:C(e.className,"ActionLogsCompact"),children:t(w,{className:"ActionLogsCompact__table",multiple:!0,children:a.map((n,i)=>t(w.Item,{label:t(nt,{action:n}),children:t(st,{action:n})},i))})})}function nt(e){let a=e.action,o=it(a),n=e.action.by||"";return t("div",{className:"ActionLogsCompactItemPreview",children:[t("div",{className:"ActionLogsCompactItemPreview__user",children:t(k,{email:n,size:20})}),t("div",{className:"ActionLogsCompactItemPreview__timestamp",children:V(a.timestamp)}),t("div",{className:"ActionLogsCompactItemPreview__action",children:a.action}),t("div",{className:"ActionLogsCompactItemPreview__actionMetaId",children:o}),t("div",{className:"ActionLogsCompactItemPreview__buttons",children:t(P,{action:a,label:"Open",limit:1})})]})}function st(e){let a=e.action,o={user:a.by,...a.metadata};return t("div",{className:"ActionLogsCompactItemDetails",children:[t(W,{metadata:o}),t(P,{action:a})]})}function it(e){for(let a of Object.keys(e.metadata||{}))if(a.toLowerCase().endsWith("id"))return e.metadata[a];return""}function J(e){return e?e instanceof b?e:typeof e=="object"&&typeof e._seconds=="number"?new b(e._seconds,e._nanoseconds||0):typeof e=="object"&&typeof e.seconds=="number"?new b(e.seconds,e.nanoseconds||0):typeof e=="number"?b.fromMillis(e):null:null}function V(e){let a=J(e);if(!a)return"Invalid date";let o=a.toDate(),n=String(o.getMonth()+1).padStart(2,"0"),i=String(o.getDate()).padStart(2,"0"),r=String(o.getHours()).padStart(2,"0"),m=String(o.getMinutes()).padStart(2,"0");return`${n}/${i} ${r}:${m}`}function ct(e){function a(o){return o===null?"null":typeof o>"u"?"undefined":typeof o=="string"?`"${o.replaceAll('"','\\"')}"`:typeof o!="object"?String(o):Array.isArray(o)?`[${o.map(a).join(", ")}]`:`{${Object.entries(o).map(([i,r])=>`${i}: ${a(r)}`).join(", ")}}`}return a(e)}export{xt as a};
@@ -0,0 +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 +1 @@
1
- import{i as t,j as i}from"./chunk-NZHF733K.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
1
+ import{i as t,j as i}from"./chunk-4CUWZQXT.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
@@ -1 +1 @@
1
- import{a as t}from"./chunk-I6ICVKEC.js";function s(e){if(typeof e=="object"&&e!==null){let o=e;if(typeof o.code=="string"&&typeof o.message=="string")return`${o.code}: ${o.message}`;if(typeof o.body=="string")return o.body;if(typeof o.message=="string")return o.message}return String(e)}async function i(e){try{await e()}catch(o){console.error(o);let r=s(o);t({title:"Error",message:r,color:"red",autoClose:!1})}}export{s as a,i as b};
1
+ import{a as t}from"./chunk-AXETBZ6T.js";function s(e){if(typeof e=="object"&&e!==null){let o=e;if(typeof o.code=="string"&&typeof o.message=="string")return`${o.code}: ${o.message}`;if(typeof o.body=="string")return o.body;if(typeof o.message=="string")return o.message}return String(e)}async function i(e){try{await e()}catch(o){console.error(o);let r=s(o);t({title:"Error",message:r,color:"red",autoClose:!1})}}export{s as a,i 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-NZHF733K.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-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 +1 @@
1
- import{a as b,c as w}from"./chunk-HRGYNHZ3.js";import{b as z,e as I,f as C}from"./chunk-XOQ3KDSR.js";import{a as p}from"./chunk-I6ICVKEC.js";import{a}from"./chunk-HLMBCVRX.js";import{Ha as n,V as v,a as c,c as y,ea as m,j as L,zc as N}from"./chunk-NZHF733K.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
1
+ import{a as b,c as w}from"./chunk-KPJ53X55.js";import{b as z,e as I,f as C}from"./chunk-UFQSZ6J2.js";import{a as p}from"./chunk-AXETBZ6T.js";import{a}from"./chunk-N5Y5OWTV.js";import{Ga as n,V as v,a as c,c as y,da as m,j as L,yc as N}from"./chunk-4CUWZQXT.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
@@ -1,3 +1,3 @@
1
- import{a as Z}from"./chunk-CGCKJFL4.js";import{a as Q,c as X,e as Y}from"./chunk-4KE2SZKH.js";import{c as K}from"./chunk-W3HIZQ4Z.js";import{a as j}from"./chunk-JDW4UORS.js";import{b as J}from"./chunk-62UWGWON.js";import{a as x}from"./chunk-I6ICVKEC.js";import{d as W}from"./chunk-AL3TN2KI.js";import{Aa as S,Ha as e,a as s,c as q,e as B,ea as A,fa as P,j as re,oa as b,qa as $,va as F,wa as V}from"./chunk-NZHF733K.js";import{d as M}from"./chunk-KUCVLANF.js";re();var se="Enter the URL to make the HTTP request.",ne="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Ne(a){let{route:n}=W(),c=B(null),i=Z(),[h,d]=s(!1),[r,U]=s(i.enabled?"gsheet":"http"),[g,z]=s("map"),[v,ee]=s("GET"),[y,T]=s(!1),[w,N]=s(1),[E,H]=s("hours"),[R,C]=s(!1),[L,p]=s(""),[te,O]=s(!!a.dataSourceId),[_,G]=s(null),I="";r==="http"?I=se:r==="gsheet"&&(I=ne);async function ae(t){await J(async()=>{let o=await X(t);G(o),U(o?.type||"http"),z(o?.dataFormat||"map"),o?.cron?(T(o.cron.enabled||!1),N(o.cron.interval||1),H(o.cron.unit||"hours"),C(o.cron.autoPublish||!1)):(T(!1),N(1),H("hours"),C(!1))}),O(!1)}q(()=>{a.dataSourceId&&(O(!0),ae(a.dataSourceId))},[a.dataSourceId]);async function oe(){p("");let t=c.current;function o(l){let f=t.elements[l];return f?f.value.trim():""}let m=a.dataSourceId||o("id");if(!m){p("missing id");return}if(!j(m)){p("id is invalid (alphanumeric characters and dashes only)");return}let D=o("url");if(!D){p("missing url");return}let u={id:m,description:o("description"),type:r,url:D,previewUrl:o("previewUrl")};if(r==="http"){if(!ie(D)){p("invalid url");return}u.httpOptions={method:v};let l=o("httpHeaders");if(l&&(u.httpOptions.headers=ue(l)),v==="POST"){let f=o("httpBody");f&&(u.httpOptions.body=f)}}else if(r==="gsheet"){if(!K(D)?.spreadsheetId){p("failed to parse spreadsheet url");return}u.dataFormat=g||"map"}y?u.cron={enabled:!0,interval:w,unit:E,autoPublish:R}:u.cron={enabled:!1,interval:w,unit:E};try{G(u),d(!0),a.dataSourceId?(await Y(a.dataSourceId,u),x({title:"Saved data source",message:`Successfully updated ${m}`,autoClose:5e3}),d(!1)):(await Q(m,u),x({title:"Added data source",message:`Successfully added ${m}`,autoClose:5e3}),d(!1),n(`/cms/data/${m}`))}catch(l){console.error(l),x({title:"Failed to save data source",message:String(l),color:"red",autoClose:!1}),d(!1)}}let k=[{value:"http",label:"HTTP"}];return(i.enabled||r==="gsheet")&&k.push({value:"gsheet",label:"Google Sheet"}),e("form",{className:"DataSourceForm",ref:c,onSubmit:t=>{t.preventDefault(),oe()},children:[e($,{visible:te}),e("div",{className:"DataSourceForm__input",children:e(S,{name:"type",label:"Type",data:k,value:r,onChange:t=>U(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(F,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:a.dataSourceId,disabled:!!a.dataSourceId}),e(b,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:_?.description}),e(F,{className:"DataSourceForm__input",name:"url",label:"URL",description:I,size:"xs",radius:0,value:_?.url}),r==="http"&&e(M,{children:[e("div",{className:"DataSourceForm__input",children:e(S,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:v,onChange:t=>ee(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(b,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ce(_?.httpOptions?.headers||{})}),v==="POST"&&e(b,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:_?.httpOptions?.body})]}),r==="gsheet"&&e("div",{className:"DataSourceForm__input",children:[e(S,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:g,onChange:t=>z(t),size:"xs",radius:0,dropdownComponent:"div"}),g==="array"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",e("code",{children:"[[header1, header2], [foo, bar]]"})]}),g==="map"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",e("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),e("div",{className:"DataSourceForm__section",children:[e("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),e(P,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:y,onChange:t=>T(t.currentTarget.checked),size:"xs"}),y&&e("div",{className:"DataSourceForm__cron",children:[e("div",{className:"DataSourceForm__cron__row",children:[e("span",{children:"Run every"}),e(V,{className:"DataSourceForm__cron__interval",value:w,onChange:t=>N(Number(t)||1),min:1,size:"xs",radius:0}),e(S,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:E,onChange:t=>H(t),size:"xs",radius:0,dropdownComponent:"div"})]}),e(P,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:R,onChange:t=>C(t.currentTarget.checked),size:"xs"})]})]}),e(F,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:_?.previewUrl}),e(A,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:h,children:a.buttonLabel||"Save"}),L&&e("div",{className:"DataSourceForm__error",children:["Error: ",L]})]})}function ie(a){let n,c=a.startsWith("/")?"http://localhost":void 0;try{n=new URL(a,c)}catch(i){return console.error(i),!1}return n.protocol==="http:"||n.protocol==="https:"}function ue(a){let n={};return a.split(`
1
+ import{a as Z}from"./chunk-V7RAXP2W.js";import{a as Q,c as X,e as Y}from"./chunk-4KE2SZKH.js";import{c as K}from"./chunk-W3HIZQ4Z.js";import{a as j}from"./chunk-JDW4UORS.js";import{b as J}from"./chunk-CVGYBXVH.js";import{a as x}from"./chunk-AXETBZ6T.js";import{d as W}from"./chunk-RPOP6MVJ.js";import{Ga as e,a as s,c as q,da as A,e as B,ea as P,j as re,na as b,pa as $,ua as F,va as V,za as S}from"./chunk-4CUWZQXT.js";import{d as M}from"./chunk-KUCVLANF.js";re();var se="Enter the URL to make the HTTP request.",ne="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Ne(a){let{route:n}=W(),c=B(null),i=Z(),[h,d]=s(!1),[r,U]=s(i.enabled?"gsheet":"http"),[g,z]=s("map"),[v,ee]=s("GET"),[y,T]=s(!1),[w,N]=s(1),[E,H]=s("hours"),[R,C]=s(!1),[L,p]=s(""),[te,O]=s(!!a.dataSourceId),[_,G]=s(null),I="";r==="http"?I=se:r==="gsheet"&&(I=ne);async function ae(t){await J(async()=>{let o=await X(t);G(o),U(o?.type||"http"),z(o?.dataFormat||"map"),o?.cron?(T(o.cron.enabled||!1),N(o.cron.interval||1),H(o.cron.unit||"hours"),C(o.cron.autoPublish||!1)):(T(!1),N(1),H("hours"),C(!1))}),O(!1)}q(()=>{a.dataSourceId&&(O(!0),ae(a.dataSourceId))},[a.dataSourceId]);async function oe(){p("");let t=c.current;function o(l){let f=t.elements[l];return f?f.value.trim():""}let m=a.dataSourceId||o("id");if(!m){p("missing id");return}if(!j(m)){p("id is invalid (alphanumeric characters and dashes only)");return}let D=o("url");if(!D){p("missing url");return}let u={id:m,description:o("description"),type:r,url:D,previewUrl:o("previewUrl")};if(r==="http"){if(!ie(D)){p("invalid url");return}u.httpOptions={method:v};let l=o("httpHeaders");if(l&&(u.httpOptions.headers=ue(l)),v==="POST"){let f=o("httpBody");f&&(u.httpOptions.body=f)}}else if(r==="gsheet"){if(!K(D)?.spreadsheetId){p("failed to parse spreadsheet url");return}u.dataFormat=g||"map"}y?u.cron={enabled:!0,interval:w,unit:E,autoPublish:R}:u.cron={enabled:!1,interval:w,unit:E};try{G(u),d(!0),a.dataSourceId?(await Y(a.dataSourceId,u),x({title:"Saved data source",message:`Successfully updated ${m}`,autoClose:5e3}),d(!1)):(await Q(m,u),x({title:"Added data source",message:`Successfully added ${m}`,autoClose:5e3}),d(!1),n(`/cms/data/${m}`))}catch(l){console.error(l),x({title:"Failed to save data source",message:String(l),color:"red",autoClose:!1}),d(!1)}}let k=[{value:"http",label:"HTTP"}];return(i.enabled||r==="gsheet")&&k.push({value:"gsheet",label:"Google Sheet"}),e("form",{className:"DataSourceForm",ref:c,onSubmit:t=>{t.preventDefault(),oe()},children:[e($,{visible:te}),e("div",{className:"DataSourceForm__input",children:e(S,{name:"type",label:"Type",data:k,value:r,onChange:t=>U(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(F,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:a.dataSourceId,disabled:!!a.dataSourceId}),e(b,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:_?.description}),e(F,{className:"DataSourceForm__input",name:"url",label:"URL",description:I,size:"xs",radius:0,value:_?.url}),r==="http"&&e(M,{children:[e("div",{className:"DataSourceForm__input",children:e(S,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:v,onChange:t=>ee(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(b,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ce(_?.httpOptions?.headers||{})}),v==="POST"&&e(b,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:_?.httpOptions?.body})]}),r==="gsheet"&&e("div",{className:"DataSourceForm__input",children:[e(S,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:g,onChange:t=>z(t),size:"xs",radius:0,dropdownComponent:"div"}),g==="array"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",e("code",{children:"[[header1, header2], [foo, bar]]"})]}),g==="map"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",e("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),e("div",{className:"DataSourceForm__section",children:[e("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),e(P,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:y,onChange:t=>T(t.currentTarget.checked),size:"xs"}),y&&e("div",{className:"DataSourceForm__cron",children:[e("div",{className:"DataSourceForm__cron__row",children:[e("span",{children:"Run every"}),e(V,{className:"DataSourceForm__cron__interval",value:w,onChange:t=>N(Number(t)||1),min:1,size:"xs",radius:0}),e(S,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:E,onChange:t=>H(t),size:"xs",radius:0,dropdownComponent:"div"})]}),e(P,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:R,onChange:t=>C(t.currentTarget.checked),size:"xs"})]})]}),e(F,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:_?.previewUrl}),e(A,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:h,children:a.buttonLabel||"Save"}),L&&e("div",{className:"DataSourceForm__error",children:["Error: ",L]})]})}function ie(a){let n,c=a.startsWith("/")?"http://localhost":void 0;try{n=new URL(a,c)}catch(i){return console.error(i),!1}return n.protocol==="http:"||n.protocol==="https:"}function ue(a){let n={};return a.split(`
2
2
  `).forEach(i=>{let h=i.indexOf(":");if(h===-1)return;let d=i.slice(0,h).trim(),r=i.slice(h+1).trim();d&&r&&(n[d]=r)}),n}function ce(a){let n=[];for(let c in a){let i=a[c];n.push(`${c}: ${i}`)}return n.join(`
3
3
  `)}export{Ne as a};
@@ -1 +1 @@
1
- import{b as o}from"./chunk-ORXEMIQC.js";import{Ga as r,Ha as i,ca as a}from"./chunk-NZHF733K.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-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 +1 @@
1
- import{a as p,d as U,e as g}from"./chunk-KYDOSLTO.js";import{f as u}from"./chunk-AL3TN2KI.js";import{Ga as d,Ha as t,a as f,ba as v,j as x}from"./chunk-NZHF733K.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-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};
@@ -0,0 +1 @@
1
+ import{a as $}from"./chunk-RQKL4KXY.js";import{a as W}from"./chunk-T47V6AGW.js";import{f as U}from"./chunk-4IXGYXA2.js";import{a as B,c as L,d as O,i as A}from"./chunk-UA7UCTX5.js";import{a as j,c as q}from"./chunk-TDKVKTW4.js";import{a as H}from"./chunk-D37DCENS.js";import{a as T}from"./chunk-JDW4UORS.js";import{b as M}from"./chunk-CVGYBXVH.js";import{a as v}from"./chunk-AXETBZ6T.js";import{d as k}from"./chunk-RPOP6MVJ.js";import{$ as D,Fa as I,Ga as e,Oc as F,Qa as V,W as p,a as c,c as N,da as f,e as P,j as ie,na as y,pa as z,ua as E}from"./chunk-4CUWZQXT.js";ie();function R(s){let{route:i}=k(),S=P(null),[Y,d]=c(!1),[w,g]=c(""),[G,h]=c(!!s.releaseId),[J,C]=c(null),[m,x]=c([]),[_,b]=c([]),K=W(),Q=$(),{roles:X}=H(),Z=window.firebase.user.email||"",n=j(X,Z);async function ee(r){console.log(r),await M(async()=>{let t=await L(r);C(t),x(t?.docIds||[]),b(t?.dataSourceIds||[])}),h(!1)}N(()=>{s.releaseId&&(h(!0),ee(s.releaseId))},[s.releaseId]);async function oe(){g("");let r=S.current;function t(l){let u=r.elements[l];return u?u.value.trim():""}let o=s.releaseId||t("id");if(!o){g("missing id");return}if(!T(o)){g("id is invalid (alphanumeric characters and dashes only)");return}let a={id:o,description:t("description"),docIds:m,dataSourceIds:_};try{C(a),d(!0),s.releaseId?(await O(s.releaseId,a),v({title:"Saved release",message:`Updated ${o}`,autoClose:5e3}),d(!1)):(await B(o,a),v({title:"Added release",message:`Successfully added ${o}`,autoClose:5e3}),d(!1)),i(`/cms/releases/${o}`)}catch(l){console.error(l),v({title:"Failed to save release",message:String(l),color:"red",autoClose:!1}),d(!1)}}function ae(){K.open({multiSelect:!0,selectedDocIds:m,onChangeMulti:(r,t)=>{x(o=>{let a=[...o];if(t)a.push(r);else{let l=a.findIndex(u=>u===r);l>-1&&a.splice(l,1)}return console.log(a),a.sort()})}})}function se(){Q.open({selectedDataSourceIds:_,onChange:(r,t)=>{b(o=>{let a=[...o];if(t)a.push(r);else{let l=a.indexOf(r);l>-1&&a.splice(l,1)}return a.sort()})}})}function re(r){console.log("onRemoveDoc()",r),x(t=>{let o=[...t],a=o.indexOf(r);return a!==-1&&o.splice(a,1),console.log(o),o})}function te(r){b(t=>{let o=[...t],a=o.indexOf(r);return a!==-1&&o.splice(a,1),o})}return e("form",{className:"ReleaseForm",ref:S,onSubmit:r=>{r.preventDefault(),oe()},children:[e(z,{visible:G}),e(E,{className:"ReleaseForm__input",name:"id",label:"ID",description:"Unique identifier for the release. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,defaultValue:s.releaseId||A(),disabled:!!s.releaseId}),e(y,{className:"ReleaseForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:J?.description,disabled:!n}),e(D,{className:"ReleaseForm__input",label:"Docs",description:"Select one or more docs to add to the release. Note: you can add or edit this list at a later time, if needed.",size:"xs",children:[m.length>0&&e(R.DocPreviewCards,{docIds:m,onRemoveDoc:re,canEdit:n}),e(f,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>ae(),disabled:!n,children:"Select"})]}),e(D,{className:"ReleaseForm__input",label:"Data Sources",description:"Optional. Data sources to publish with the release.",size:"xs",children:[_.length>0&&e(R.DataSourceIds,{ids:_,onRemove:te,canEdit:n}),e(f,{className:"ReleaseForm__docSelectButton",color:"dark",size:"xs",onClick:()=>se(),disabled:!n,children:"Select"})]}),e("div",{className:"ReleaseForm__submit__buttons",children:e(q,{label:"You don't have access to create or edit releases",condition:!n,children:e("span",{children:e(f,{className:"ReleaseForm__submit",color:"blue",size:"xs",type:"submit",loading:Y,disabled:!n,children:s.buttonLabel||"Save"})})})}),w&&e("div",{className:"ReleaseForm__error",children:["Error: ",w]})]})}R.DocPreviewCards=s=>e("div",{className:"ReleaseForm__DocPreviewCards",children:s.docIds.map(i=>e("div",{className:"ReleaseForm__DocPreviewCards__card",children:[e(U,{className:"ReleaseForm__DocPreviewCards__card__preview",docId:i}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls",children:[s.canEdit&&e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__remove",children:e(I,{label:"Remove",children:e(p,{className:"ReleaseForm__DocPreviewCards__card__controls__remove__icon",onClick:()=>s.onRemoveDoc(i),children:e(F,{size:16})})})}),e("div",{className:"ReleaseForm__DocPreviewCards__card__controls__open",children:e(I,{label:"Open",children:e(p,{component:"a",className:"ReleaseForm__DocPreviewCards__card__controls__open__icon",href:`/cms/content/${i}`,target:"_blank",children:e(V,{size:16})})})})]})]},i))});R.DataSourceIds=s=>e("div",{className:"ReleaseForm__DataSourceIds",children:s.ids.map(i=>e("div",{className:"ReleaseForm__DataSourceIds__item",children:[e("span",{className:"ReleaseForm__DataSourceIds__item__id",children:i}),s.canEdit&&e(p,{className:"ReleaseForm__DataSourceIds__item__remove",onClick:()=>s.onRemove(i),children:e(F,{size:16})})]},i))});export{R as a};
@@ -0,0 +1 @@
1
+ import{b as se}from"./chunk-BEDUTYQP.js";import{a as te,b as R,c as k}from"./chunk-JDW4UORS.js";import{a as ie}from"./chunk-YDO2EDVY.js";import{c as ne,s as re}from"./chunk-NQ5ARARP.js";import{b as oe}from"./chunk-CVGYBXVH.js";import{a as U}from"./chunk-AXETBZ6T.js";import{a as P}from"./chunk-N5Y5OWTV.js";import{a as z}from"./chunk-5MV6XVGA.js";import{b as K,f as H,g as E,i as C,o as Z}from"./chunk-EGEB6N4J.js";import{d as ee,f as ae}from"./chunk-RPOP6MVJ.js";import{A as W,Ga as g,a as p,c as v,da as j,e as S,g as X,h as N,i as B,j as D,ra as G,ua as J,za as Q}from"./chunk-4CUWZQXT.js";import{j as q,k as Ee}from"./chunk-KUCVLANF.js";function $(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=Ce(e);return`${n}${r}`}function Ce(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,a=o[t];if(!a)throw new Error(`collection not found: ${t}`);if(!a.url)return"";let s=window.__ROOT_CTX.rootConfig,f=s.base||"/",l="/[base]/[path]";r&&(l=s.i18n.urlFormat||"/[locale]/[base]/[path]");let d="",u=a?.url;if(u)if(n){let c=u.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),d=c}else d=u;return le(l,{base:f,path:d,locale:r||"",slug:n})}function ze(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:r}=e,a=o[t];if(!a)throw new Error(`collection not found: ${t}`);let s=window.__ROOT_CTX.rootConfig,f=s.base||"/",l="/[base]/[path]";r&&(l=s.i18n.urlFormat||"/[locale]/[base]/[path]");let d="",u=a?.previewUrl||a?.url;if(u)if(n){let c=u.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");c==="/index"&&(c="/"),d=c}else d=u;return le(l,{base:f,path:d,locale:r||"",slug:n})}function le(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,r,a)=>o[a]??n);return ke(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function ke(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}D();function $e(e,o){let[t,n]=p([]),[r,a]=p(!0),f=se().db,l=window.__ROOT_CTX.rootConfig.projectId||"default",d=o.includeArchived??!1,u=async()=>{a(!0);let c=K(f,"Projects",l,"Collections",e,"Drafts"),i=c,m=o.orderBy;if(m==="modifiedAt")i=E(c,C("sys.modifiedAt","desc"));else if(m==="newest")i=E(c,C("sys.createdAt","desc"));else if(m==="oldest")i=E(c,C("sys.createdAt"));else if(m==="slug")i=E(c,C(H()));else if(m==="slugDesc")i=E(c,C(H(),"desc"));else{let y=window.__ROOT_CTX.collections[e]?.sortOptions?.find(w=>w.id===m);y&&(i=y.direction==="desc"?E(c,C(y.field,"desc")):E(c,C(y.field)))}await oe(async()=>{let h=await Z(i),y=[];h.docs.forEach(w=>{let L=w.data(),b=w.id,_=`${e}/${b}`,x={...L,id:_,slug:b};ne(_,x),!(!d&&x?.sys?.archivedAt)&&y.push(x)}),n(y)}),a(!1)};return v(()=>{a(!0),u()},[e,o.orderBy,d]),[r,u,t]}Ee();D();var O={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function ce(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var _e="/cms/api/sse.connect",I=ce("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))}},ge=q(null);function Qe(e){let t=S(new F).current,n=S(null),r=S(!1),a=S({attempt:0,timer:0}),s=S(""),f=()=>{n.current&&(n.current.close(),n.current=null)},l=N(()=>{I&&console.log("[sse] connecting..."),f();let u=new EventSource(_e);n.current=u,u.addEventListener(O.CONNECTED,i=>{if(I&&console.log("[sse] connected"),r.current=!1,a.current.attempt=0,ue){let h=de(i.data)?.serverVersion||"";s.current?s.current!==h&&(console.log(`server version changed: ${s.current} -> ${h}`),console.log("reloading..."),window.location.reload()):s.current=h}});let c=i=>{if(!i||!i.type)return;let m=de(i.data);I&&console.log("[sse] event:",i.type,m),t.emit(i.type,m,i)};Object.values(O).forEach(i=>{u.addEventListener(i,c)}),u.addEventListener("error",()=>{I&&console.log("[sse] disconnected"),u.readyState===EventSource.CLOSED&&!r.current&&(r.current=!0,(()=>{let m=++a.current.attempt,h=Math.min(3e4,Math.pow(2,m)*500),y=Math.random()*.3*h,w=h+y;window.clearTimeout(a.current.timer),a.current.timer=window.setTimeout(()=>{r.current=!1,l()},w)})())})},[t]);v(()=>{if(!ue)return;l();let u=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&l()};return document.addEventListener("visibilitychange",u),()=>{document.removeEventListener("visibilitychange",u),window.clearTimeout(a.current.timer),f()}},[l]);let d=X(()=>({emitter:t}),[t]);return g(ge.Provider,{value:d,children:e.children})}function de(e){try{return JSON.parse(e)}catch{return e}}function fe(e,o){let t=B(ge);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=S(o);v(()=>{n.current=o},[o]),v(()=>t.emitter.on(e,(r,a)=>n.current(r,a)),[t,e])}D();var me=["agile","amber","amused","ancient","autumn","azure","balmy","beige","big","bitter","black","blue","bold","brave","breezy","bright","brisk","broad","bronze","brown","bubbly","busy","calm","candid","careful","caring","cheerful","cherry","chilly","classic","clean","clear","clever","cloudy","cobalt","cold","cool","cosmic","cosy","cozy","crimson","crisp","cuddly","curious","daring","dark","dawn","dazzling","dear","deep","delicate","dewy","dizzy","dreamy","dry","dusky","dusty","eager","early","earnest","easy","electric","elegant","emerald","empty","epic","even","every","faint","fair","falling","famous","fancy","fast","feisty","fierce","fiery","fine","firm","flat","fluffy","foggy","fond","forest","fragrant","fresh","friendly","frosty","funky","funny","fuzzy","gentle","giant","glad","gleaming","glossy","gold","golden","good","graceful","grand","grassy","gray","green","groovy","happy","hardy","hazy","hearty","heavy","helpful","hidden","high","holy","honest","hopeful","humble","humming","icy","ideal","idle","indigo","inky","iron","ivory","jade","jazzy","jolly","jovial","joyful","juicy","jumpy","keen","kind","lacy","late","lazy","lemon","light","lime","linen","little","lively","lone","long","loud","lovely","loyal","lucid","lucky","lush","magenta","magic","mango","marble","maroon","massive","mauve","mellow","merry","mighty","mild","milky","mindful","minty","misty","mocha","modest","morning","mossy","muddy","mysterious","narrow","navy","neat","neon","new","nimble","noble","noisy","noon","nosy","oaken","odd","old","olive","onyx","opal","open","orange","pale","patient","peach","peachy","pearly","peppy","perky","pink","placid","plain","playful","plucky","plum","plush","polite","proud","pure","purple","quaint","quick","quiet","quirky","rapid","rare","raven","ready","red","restless","rich","rosy","rough","round","royal","ruby","rugged","rustic","sable","safe","sage","salty","sandy","sapphire","savvy","scarlet","secret","sepia","serene","shaggy","sharp","shiny","short","shrewd","shy","silent","silky","silly","silver","simple","sleek","sleepy","slim","slow","small","smart","smoky","smooth","snappy","snowy","soft","solar","solid","spicy","spiffy","spry","square","steady","steel","sticky","still","stony","stormy","strong","sturdy","sunny","super","swank","sweet","swift","tame","tan","tart","teal","tender","thin","thirsty","tidy","tiny","tireless","topaz","tough","tranquil","trim","true","twinkly","umber","upbeat","urban","useful","vast","velvet","vibrant","vintage","violet","vivid","warm","watchful","wavy","wee","whimsical","whispering","white","wild","windy","winter","wise","witty","woody","wool","yellow","young","youthful","zealous","zen","zesty","zippy"],pe=["acorn","alpaca","anchor","apple","apricot","arrow","autumn","badger","bagel","bamboo","banana","bay","beach","bear","bee","beetle","bell","berry","bird","biscuit","blossom","boat","book","boot","bottle","boulder","branch","brass","breeze","bridge","brook","broom","brunch","bubble","bucket","bud","buffalo","bug","bunny","burrow","butter","button","cabin","cactus","cake","camel","candle","canyon","cape","cardinal","carrot","cat","cave","cedar","chair","cherry","chestnut","chickpea","cliff","cloud","clove","clover","cocoa","comet","compass","cookie","coral","cottage","cotton","cove","crane","crayon","creek","cricket","crow","crumpet","crystal","cup","cupcake","currant","cypress","daffodil","dahlia","daisy","dawn","deer","desert","dew","diamond","dingo","dock","dolphin","donut","dove","dragon","drizzle","drum","duck","dumpling","dune","eagle","echo","eel","egg","elder","elephant","elk","ember","ermine","estuary","falcon","fawn","feather","fern","field","fig","finch","fir","firefly","fish","flame","flamingo","flask","flax","fleece","flower","flute","fog","forest","fountain","fox","frog","frost","galaxy","garden","gecko","gem","ginger","glacier","globe","glow","goat","goose","gorge","grape","grass","grove","gull","hammock","hare","harp","harvest","hat","hawk","haystack","hazel","heather","hedge","heron","hill","honey","horizon","horse","iceberg","iris","island","ivy","jacket","jade","jaguar","jam","jar","jasmine","jay","jelly","juniper","kayak","kelp","kettle","key","kingfisher","kite","kitten","koala","ladybug","lagoon","lake","lamp","lantern","lark","lava","leaf","lemon","lemur","leopard","lighthouse","lilac","lily","lime","lion","llama","lobster","log","lotus","lynx","magnet","mango","maple","marble","marlin","meadow","melody","melon","mermaid","meteor","mint","mist","mitten","mole","monkey","moon","moose","morel","moss","moth","mountain","mouse","muffin","mushroom","mussel","nectar","needle","nest","newt","nimbus","noodle","north","note","oak","oasis","oats","ocean","octopus","olive","onion","opal","orange","orchid","otter","owl","oyster","paddle","palm","panda","pansy","panther","paper","parrot","partridge","pasture","path","peach","peacock","pear","pebble","pelican","penguin","peony","pepper","petal","phoenix","pie","pigeon","pine","pineapple","planet","plover","plum","pond","pony","poppy","pouch","prairie","puffin","pumpkin","quail","quartz","queen","quill","rabbit","raccoon","radish","rain","rainbow","raven","reef","reel","reindeer","rhino","ribbon","ridge","river","road","robin","rock","rose","rowan","sage","salmon","sand","sapphire","satellite","scarf","sea","seagull","seal","seed","shark","shell","shore","shrimp","silk","silo","sky","sleet","snail","snake","snow","sock","spark","sparrow","spider","spire","spoon","spring","spruce","squirrel","star","starling","stone","stork","storm","stream","summer","sun","sundial","swan","swift","tadpole","tea","teal","thicket","thistle","thrush","thunder","tide","tiger","toad","tooth","topaz","tortoise","totem","tower","tractor","trail","tree","truffle","tulip","tundra","turtle","twig","twilight","umbrella","unicorn","urchin","valley","vine","violet","volcano","vulture","wagon","walnut","walrus","wasp","water","wave","whale","wheat","whisker","wildcat","willow","wind","window","winter","wolf","wombat","wood","wren","yak","yam","zebra","zinnia"];var he="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",xe="YYYYMMDD";function be(e,o){let t=o?.now??new Date,n=o?.random??Math.random,r=e.replace(/\{([^{}]+?)\}/g,(a,s)=>{let[f,l]=De(s);switch(f){case"date":return Me(t,l||xe);case"adjective":return ye(me,n);case"noun":return ye(pe,n);case"random":return Te(Oe(l,6),n);default:return a}});return k(r.toLowerCase())}function De(e){let o=e.indexOf(":");return o===-1?[e.trim(),void 0]:[e.slice(0,o).trim(),e.slice(o+1)]}function Oe(e,o){if(!e)return o;let t=parseInt(e,10);return Number.isFinite(t)&&t>0?t:o}function ye(e,o){return e[Math.floor(o()*e.length)]}function Te(e,o){let t=[];for(let n=0;n<e;n++)t.push(he.charAt(Math.floor(o()*he.length)));return t.join("")}function Me(e,o){let t={YYYY:String(e.getFullYear()),YY:String(e.getFullYear()).slice(-2),MM:T(e.getMonth()+1),DD:T(e.getDate()),HH:T(e.getHours()),mm:T(e.getMinutes()),ss:T(e.getSeconds())};return o.replace(/YYYY|YY|MM|DD|HH|mm|ss/g,n=>t[n]??n)}function T(e){return e<10?`0${e}`:String(e)}D();function we(e){let[o,t]=p(!0),[n,r]=p(null),a=N(async()=>{try{let s=await ie(e);r(s)}catch(s){console.error(s),U({title:`Failed to load collection: ${e}`,message:String(s),color:"red",autoClose:!1})}t(!1)},[e]);return v(()=>{a()},[e]),fe(O.SCHEMA_CHANGED,async s=>{await a();let f=s.file?`Applied updates from changes to ${s.file}.`:"Applied updates from changes to a .schema.ts file.";U({title:"Updated schema!",message:f})}),{loading:o,schema:n}}function Y(e){let o={_array:[]};return e.forEach(t=>{let n=Ne();o._array.push(n),o[n]=t}),o}function Ne(){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]=Y(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 a=n[r.id];if(a!=null){if(r.type==="array"&&Array.isArray(a)){let s=a.map(f=>Re(r.of,f,t));n[r.id]=Y(s)}else if(r.type==="object"&&z(a))n[r.id]=A(r,a,t);else if(r.type==="oneof"&&z(a)&&typeof a._type=="string"&&t){let s=t[a._type];s&&(n[r.id]=A(s,a,t))}}}),n}function Re(e,o,t){if(!z(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}D();function Se(e){let[o,t]=p(e.collectionId||""),n=S(null),[r,a]=p(e.initialSlug||""),s=window.__ROOT_CTX.collections[o],f=[];e.collectionId&&e.collectionDisabled?f.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(i=>{f.push({value:i,label:i})});let l="",d="";if(s?.url){if(r){let i=k(r),m=s?.slugRegex;te(i,m)?l=$({collectionId:o,slug:i}):d=R(i,m)}else l=$({collectionId:o,slug:"[slug]"});l.endsWith("/index")&&(l=l.replace(/\/index$/,"/"))}function u(i){t(i),e.onChange&&e.onChange({collectionId:i,slug:r})}function c(i){a(i),e.onChange&&e.onChange({collectionId:o,slug:i})}return g("div",{className:ae(e.className,"SlugInput"),children:[g("div",{className:"SlugInput__inputs",children:[g(Q,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:f,onChange:i=>u(i),value:o,disabled:!!e.collectionDisabled}),g("div",{className:"SlugInput__divider",children:"/"}),g(J,{className:"SlugInput__slug",name:"slug",ref:n,value:r,onChange:i=>{c(i.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),l&&g(P,{className:"SlugInput__urlHelp",size:"body-sm",children:l}),d&&g(P,{className:"SlugInput__slugError",size:"body-sm",children:d})]})}function Ut(e){let{route:o}=ee(),t=W(),n=e.collection,r=window.__ROOT_CTX.collections[n];if(!r)throw new Error(`collection not found: ${n}`);let[a]=p(()=>r.autoSlug?be(r.autoSlug):""),[s,f]=p(a),[l,d]=p(!1),[u,c]=p(()=>y(a)),[i,m]=p(""),h=we(n);function y(b){let _=k(b);return _?R(_,r.slugRegex):""}function w(){e.onClose&&e.onClose()}async function L(b){if(b.preventDefault(),d(!0),c(""),y(s)){d(!1);return}let x=k(s),ve=`${n}/${x}`;try{let M={};!h.loading&&h.schema&&(M=await V(h.schema)),await re(ve,{fields:M})}catch(M){m(String(M)),d(!1);return}d(!1),e.skipNavigation?w():o(`/cms/content/${e.collection}/${x}`)}return g(G,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>w(),title:"New",size:"500px",overlayColor:t.colorScheme==="dark"?t.colors.dark[9]:t.colors.gray[2],children:[g("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."}),g("form",{onSubmit:b=>L(b),children:[g(Se,{className:"NewDocModal__slug",collectionId:n,initialSlug:a,onChange:b=>{f(b.slug),c(y(b.slug)),m("")}}),i&&g("div",{className:"NewDocModal__slugError",children:i}),g("div",{className:"NewDocModal__buttons",children:[g(j,{variant:"outline",onClick:()=>w(),type:"button",size:"xs",color:"dark",children:"Cancel"}),g(j,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:h.loading||l,disabled:!!u||!!i,children:"Submit"})]})]})]})}export{$ as a,Ce as b,ze as c,Se as d,$e as e,Qe as f,we as g,V as h,A as i,Ut as j};
@@ -1 +1 @@
1
- import{a as B}from"./chunk-CGCKJFL4.js";import{a as P,c as $}from"./chunk-ONTGW2VA.js";import{h as w,i as A}from"./chunk-4KE2SZKH.js";import{a as C}from"./chunk-L4RHGQUG.js";import{a as v,b as S}from"./chunk-I6ICVKEC.js";import{b as l}from"./chunk-ORXEMIQC.js";import{a as D}from"./chunk-EGEB6N4J.js";import{Ga as c,Ha as o,a as e,c as y,ea as T,j as g}from"./chunk-NZHF733K.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=B(),{roles:_}=C(),E=window.firebase.user.email||"",m=P(_,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};
1
+ import{a as B}from"./chunk-V7RAXP2W.js";import{a as P,c as $}from"./chunk-TDKVKTW4.js";import{h as w,i as A}from"./chunk-4KE2SZKH.js";import{a as C}from"./chunk-D37DCENS.js";import{a as v,b as S}from"./chunk-AXETBZ6T.js";import{b as l}from"./chunk-ORXEMIQC.js";import{a as D}from"./chunk-EGEB6N4J.js";import{Fa as c,Ga as o,a as e,c as y,da as T,j as g}from"./chunk-4CUWZQXT.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=B(),{roles:_}=C(),E=window.firebase.user.email||"",m=P(_,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};
@@ -1 +1 @@
1
- import{A as D,K as x,R as A,b as k,ea as L,ga as B,i as I,sa as F,v as d,y as M}from"./chunk-NZHF733K.js";import{j as R}from"./chunk-KUCVLANF.js";M();M();var h=R(null);h.displayName="@mantine/modals/ModalsContext";function j(){let o=I(h);if(!o)throw new Error("[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component");return o}M();M();var W=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,V=(o,r,e)=>r in o?W(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,S=(o,r)=>{for(var e in r||(r={}))Z.call(r,e)&&V(o,e,r[e]);if(T)for(var e of T(r))$.call(r,e)&&V(o,e,r[e]);return o},G=(o,r)=>X(o,Y(r));function q({id:o,cancelProps:r,confirmProps:e,labels:c={cancel:"",confirm:""},closeOnConfirm:n=!0,closeOnCancel:s=!0,groupProps:m,onCancel:u,onConfirm:f,children:v}){let{cancel:_,confirm:y}=c,P=j(),w=l=>{typeof r?.onClick=="function"&&r?.onClick(l),typeof u=="function"&&u(),s&&P.closeModal(o)},b=l=>{typeof e?.onClick=="function"&&e?.onClick(l),typeof f=="function"&&f(),n&&P.closeModal(o)};return d.createElement(d.Fragment,null,v&&d.createElement(A,{mb:"md"},v),d.createElement(B,S({position:"right"},m),d.createElement(L,G(S({variant:"default"},r),{onClick:w}),r?.children||_),d.createElement(L,G(S({},e),{onClick:b}),e?.children||y)))}function z(o,r){switch(r.type){case"OPEN":return{current:r.payload,modals:[...o.modals,r.payload]};case"CLOSE":return{current:o.modals[o.modals.length-2]||null,modals:o.modals.filter(e=>e.id!==r.payload)};case"CLOSE_ALL":return{current:o.current,modals:[]};default:return o}}var oo=Object.defineProperty,ro=Object.defineProperties,eo=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,H=(o,r,e)=>r in o?oo(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,E=(o,r)=>{for(var e in r||(r={}))K.call(r,e)&&H(o,e,r[e]);if(g)for(var e of g(r))Q.call(r,e)&&H(o,e,r[e]);return o},J=(o,r)=>ro(o,eo(r)),N=(o,r)=>{var e={};for(var c in o)K.call(o,c)&&r.indexOf(c)<0&&(e[c]=o[c]);if(o!=null&&g)for(var c of g(o))r.indexOf(c)<0&&Q.call(o,c)&&(e[c]=o[c]);return e};function to(o){if(!o)return{confirmProps:{},modalProps:{}};let r=o,{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y}=r,P=N(r,["id","children","onCancel","onConfirm","closeOnConfirm","closeOnCancel","cancelProps","confirmProps","groupProps","labels"]);return{confirmProps:{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y},modalProps:E({id:e},P)}}function no({children:o,modalProps:r,labels:e,modals:c}){let[n,s]=k(z,{modals:[],current:null}),m=l=>{n.modals.forEach(t=>{var a,p,i,O;t.type==="confirm"&&l&&((p=(a=t.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=t.props)==null?void 0:i.onClose)==null||O.call(i)}),s({type:"CLOSE_ALL"})},u=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"content",props:l}}),t},f=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"confirm",props:l}}),t},v=(l,t)=>{let a=t.id||x();return s({type:"OPEN",payload:{id:a,type:"context",props:t,ctx:l}}),a},_=(l,t)=>{var a,p,i,O;if(n.modals.length<=1){m(t);return}let C=n.modals.find(U=>U.id===l);C?.type==="confirm"&&t&&((p=(a=C.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=C?.props)==null?void 0:i.onClose)==null||O.call(i),s({type:"CLOSE",payload:C.id})},y={modals:n.modals,openModal:u,openConfirmModal:f,openContextModal:v,closeModal:_,closeAll:m},P=()=>{var l;switch((l=n.current)==null?void 0:l.type){case"context":{let t=n.current.props,{innerProps:a}=t,p=N(t,["innerProps"]),i=c[n.current.ctx];return{modalProps:p,content:d.createElement(i,{innerProps:a,context:y,id:n.current.id})}}case"confirm":{let{modalProps:t,confirmProps:a}=to(n.current.props);return{modalProps:t,content:d.createElement(q,J(E({},a),{id:n.current.id,labels:n.current.props.labels||e}))}}case"content":{let t=n.current.props,{children:a}=t;return{modalProps:N(t,["children"]),content:d.createElement(d.Fragment,null,a)}}default:return{modalProps:{},content:null}}},{modalProps:w,content:b}=P();return d.createElement(h.Provider,{value:y},d.createElement(F,J(E(E({},r),w),{opened:n.modals.length>0,onClose:()=>_(n.current.id)}),b),o)}function bo(){let o=D();return{overlayColor:o.colorScheme==="dark"?o.colors.dark[9]:o.colors.gray[2],overlayOpacity:.55,overlayBlur:3}}export{j as a,no as b,bo as c};
1
+ import{A as D,K as x,R as A,b as k,da as L,fa as B,i as I,ra as F,v as d,y as M}from"./chunk-4CUWZQXT.js";import{j as R}from"./chunk-KUCVLANF.js";M();M();var h=R(null);h.displayName="@mantine/modals/ModalsContext";function j(){let o=I(h);if(!o)throw new Error("[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component");return o}M();M();var W=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,V=(o,r,e)=>r in o?W(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,S=(o,r)=>{for(var e in r||(r={}))Z.call(r,e)&&V(o,e,r[e]);if(T)for(var e of T(r))$.call(r,e)&&V(o,e,r[e]);return o},G=(o,r)=>X(o,Y(r));function q({id:o,cancelProps:r,confirmProps:e,labels:c={cancel:"",confirm:""},closeOnConfirm:n=!0,closeOnCancel:s=!0,groupProps:m,onCancel:u,onConfirm:f,children:v}){let{cancel:_,confirm:y}=c,P=j(),w=l=>{typeof r?.onClick=="function"&&r?.onClick(l),typeof u=="function"&&u(),s&&P.closeModal(o)},b=l=>{typeof e?.onClick=="function"&&e?.onClick(l),typeof f=="function"&&f(),n&&P.closeModal(o)};return d.createElement(d.Fragment,null,v&&d.createElement(A,{mb:"md"},v),d.createElement(B,S({position:"right"},m),d.createElement(L,G(S({variant:"default"},r),{onClick:w}),r?.children||_),d.createElement(L,G(S({},e),{onClick:b}),e?.children||y)))}function z(o,r){switch(r.type){case"OPEN":return{current:r.payload,modals:[...o.modals,r.payload]};case"CLOSE":return{current:o.modals[o.modals.length-2]||null,modals:o.modals.filter(e=>e.id!==r.payload)};case"CLOSE_ALL":return{current:o.current,modals:[]};default:return o}}var oo=Object.defineProperty,ro=Object.defineProperties,eo=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,H=(o,r,e)=>r in o?oo(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e,E=(o,r)=>{for(var e in r||(r={}))K.call(r,e)&&H(o,e,r[e]);if(g)for(var e of g(r))Q.call(r,e)&&H(o,e,r[e]);return o},J=(o,r)=>ro(o,eo(r)),N=(o,r)=>{var e={};for(var c in o)K.call(o,c)&&r.indexOf(c)<0&&(e[c]=o[c]);if(o!=null&&g)for(var c of g(o))r.indexOf(c)<0&&Q.call(o,c)&&(e[c]=o[c]);return e};function to(o){if(!o)return{confirmProps:{},modalProps:{}};let r=o,{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y}=r,P=N(r,["id","children","onCancel","onConfirm","closeOnConfirm","closeOnCancel","cancelProps","confirmProps","groupProps","labels"]);return{confirmProps:{id:e,children:c,onCancel:n,onConfirm:s,closeOnConfirm:m,closeOnCancel:u,cancelProps:f,confirmProps:v,groupProps:_,labels:y},modalProps:E({id:e},P)}}function no({children:o,modalProps:r,labels:e,modals:c}){let[n,s]=k(z,{modals:[],current:null}),m=l=>{n.modals.forEach(t=>{var a,p,i,O;t.type==="confirm"&&l&&((p=(a=t.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=t.props)==null?void 0:i.onClose)==null||O.call(i)}),s({type:"CLOSE_ALL"})},u=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"content",props:l}}),t},f=l=>{let t=l.id||x();return s({type:"OPEN",payload:{id:t,type:"confirm",props:l}}),t},v=(l,t)=>{let a=t.id||x();return s({type:"OPEN",payload:{id:a,type:"context",props:t,ctx:l}}),a},_=(l,t)=>{var a,p,i,O;if(n.modals.length<=1){m(t);return}let C=n.modals.find(U=>U.id===l);C?.type==="confirm"&&t&&((p=(a=C.props)==null?void 0:a.onCancel)==null||p.call(a)),(O=(i=C?.props)==null?void 0:i.onClose)==null||O.call(i),s({type:"CLOSE",payload:C.id})},y={modals:n.modals,openModal:u,openConfirmModal:f,openContextModal:v,closeModal:_,closeAll:m},P=()=>{var l;switch((l=n.current)==null?void 0:l.type){case"context":{let t=n.current.props,{innerProps:a}=t,p=N(t,["innerProps"]),i=c[n.current.ctx];return{modalProps:p,content:d.createElement(i,{innerProps:a,context:y,id:n.current.id})}}case"confirm":{let{modalProps:t,confirmProps:a}=to(n.current.props);return{modalProps:t,content:d.createElement(q,J(E({},a),{id:n.current.id,labels:n.current.props.labels||e}))}}case"content":{let t=n.current.props,{children:a}=t;return{modalProps:N(t,["children"]),content:d.createElement(d.Fragment,null,a)}}default:return{modalProps:{},content:null}}},{modalProps:w,content:b}=P();return d.createElement(h.Provider,{value:y},d.createElement(F,J(E(E({},r),w),{opened:n.modals.length>0,onClose:()=>_(n.current.id)}),b),o)}function bo(){let o=D();return{overlayColor:o.colorScheme==="dark"?o.colors.dark[9]:o.colors.gray[2],overlayOpacity:.55,overlayBlur:3}}export{j as a,no as b,bo as c};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-X2WHBGTP.js";import{f as p}from"./chunk-AL3TN2KI.js";import{Eb as u,Ha as o,U as _,g,j as b}from"./chunk-NZHF733K.js";b();function m(s){let e={},t=[],r={};if(Object.entries(s).forEach(([n,i])=>{e[n]={id:n,name:i.name||n,description:i.description,isGroup:!1,collection:i,children:[]}}),Object.entries(s).forEach(([n,i])=>{let c=e[n],d=i.group||"Content";d?(r[d]||(r[d]={id:`group:${d}`,name:d,isGroup:!0,children:[]}),r[d].children.push(c)):t.push(c)}),Object.keys(r).length>0&&t.length>0){let n={id:"group:Content",name:"Content",isGroup:!0,children:t},i=Object.values(r).sort((c,d)=>c.name.localeCompare(d.name));return[n,...i]}Object.values(r).forEach(n=>{t.push(n)});let l=n=>{n.sort((i,c)=>i.name.localeCompare(c.name)),n.forEach(i=>{i.children.length>0&&l(i.children)})};return l(t),t}function O(s){let{collections:e,activeCollectionId:t,projectId:r}=s,[a,l]=C(`root-cms::${r}::closed_groups`,[]),n=g(()=>m(e),[]),i=(c,d)=>{d?l(a.filter(v=>v!==c)):a.includes(c)||l([...a,c])};return o("div",{className:p(s.className,"CollectionTree"),children:[n.map(c=>o(h,{node:c,depth:0,activeCollectionId:t,closedGroups:a,onAccordionChange:i},c.id)),n.length===0&&o("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function h(s){let{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l}=s,n=e.children.length>0;return e.isGroup?n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__group__label",children:o("span",{children:e.name})})}):o("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${t*16}px`},children:[o(u,{size:20,strokeWidth:"1.75"}),o("span",{children:e.name})]}):n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__collection__label",children:o("a",{className:p("CollectionTree__collection-link",e.id===r&&"active"),href:`/cms/content/${e.id}`,onClick:i=>i.stopPropagation(),children:e.name})})}):o("a",{className:p("CollectionTree__collection",e.id===r&&"active"),href:`/cms/content/${e.id}`,children:[o("div",{className:"CollectionTree__collection__icon",children:o(u,{size:20,strokeWidth:"1.75"})}),o("div",{className:"CollectionTree__collection__content",children:[o("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&o("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function f(s){let{node:e,depth:t,label:r,activeCollectionId:a,closedGroups:l,onAccordionChange:n}=s,i=!l.includes(e.id);return o("div",{className:"CollectionTree__accordion",children:o(_,{iconPosition:"left",initialItem:i?0:-1,offsetIcon:!1,onChange:()=>n(e.id,!i),children:o(_.Item,{label:r,children:o("div",{className:"CollectionTree__accordion__children",children:e.children.map(c=>o(h,{node:c,depth:t+1,activeCollectionId:a,closedGroups:l,onAccordionChange:n},c.id))})})})})}export{O as a};
1
+ import{a as C}from"./chunk-NQB37NMX.js";import{f as p}from"./chunk-RPOP6MVJ.js";import{Db as u,Ga as o,U as _,g,j as b}from"./chunk-4CUWZQXT.js";b();function m(s){let e={},t=[],r={};if(Object.entries(s).forEach(([n,i])=>{e[n]={id:n,name:i.name||n,description:i.description,isGroup:!1,collection:i,children:[]}}),Object.entries(s).forEach(([n,i])=>{let c=e[n],d=i.group||"Content";d?(r[d]||(r[d]={id:`group:${d}`,name:d,isGroup:!0,children:[]}),r[d].children.push(c)):t.push(c)}),Object.keys(r).length>0&&t.length>0){let n={id:"group:Content",name:"Content",isGroup:!0,children:t},i=Object.values(r).sort((c,d)=>c.name.localeCompare(d.name));return[n,...i]}Object.values(r).forEach(n=>{t.push(n)});let l=n=>{n.sort((i,c)=>i.name.localeCompare(c.name)),n.forEach(i=>{i.children.length>0&&l(i.children)})};return l(t),t}function O(s){let{collections:e,activeCollectionId:t,projectId:r}=s,[a,l]=C(`root-cms::${r}::closed_groups`,[]),n=g(()=>m(e),[]),i=(c,d)=>{d?l(a.filter(v=>v!==c)):a.includes(c)||l([...a,c])};return o("div",{className:p(s.className,"CollectionTree"),children:[n.map(c=>o(h,{node:c,depth:0,activeCollectionId:t,closedGroups:a,onAccordionChange:i},c.id)),n.length===0&&o("div",{className:"CollectionTree__collections__empty",children:"No collections match your query."})]})}function h(s){let{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l}=s,n=e.children.length>0;return e.isGroup?n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__group__label",children:o("span",{children:e.name})})}):o("div",{className:"CollectionTree__group-empty",style:{paddingLeft:`${t*16}px`},children:[o(u,{size:20,strokeWidth:"1.75"}),o("span",{children:e.name})]}):n?o(f,{node:e,depth:t,activeCollectionId:r,closedGroups:a,onAccordionChange:l,label:o("div",{className:"CollectionTree__collection__label",children:o("a",{className:p("CollectionTree__collection-link",e.id===r&&"active"),href:`/cms/content/${e.id}`,onClick:i=>i.stopPropagation(),children:e.name})})}):o("a",{className:p("CollectionTree__collection",e.id===r&&"active"),href:`/cms/content/${e.id}`,children:[o("div",{className:"CollectionTree__collection__icon",children:o(u,{size:20,strokeWidth:"1.75"})}),o("div",{className:"CollectionTree__collection__content",children:[o("div",{className:"CollectionTree__collection__name",children:e.name}),e.description&&o("div",{className:"CollectionTree__collection__desc",children:e.description})]})]})}function f(s){let{node:e,depth:t,label:r,activeCollectionId:a,closedGroups:l,onAccordionChange:n}=s,i=!l.includes(e.id);return o("div",{className:"CollectionTree__accordion",children:o(_,{iconPosition:"left",initialItem:i?0:-1,offsetIcon:!1,onChange:()=>n(e.id,!i),children:o(_.Item,{label:r,children:o("div",{className:"CollectionTree__accordion__children",children:e.children.map(c=>o(h,{node:c,depth:t+1,activeCollectionId:a,closedGroups:l,onAccordionChange:n},c.id))})})})})}export{O as a};