@blinkk/root-cms 3.0.2 → 3.0.4

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 (161) hide show
  1. package/dist/app.js +5 -5
  2. package/dist/{chunk-2BSW7SIH.js → chunk-N4K6ICFR.js} +4 -4
  3. package/dist/{chunk-BGTUWIV6.js → chunk-PNLLZXVY.js} +4 -4
  4. package/dist/{chunk-3HARN4U6.js → chunk-RLZFZT42.js} +176 -83
  5. package/dist/{chunk-C245C557.js → chunk-RXWDB3K4.js} +3 -3
  6. package/dist/{chunk-XLX37FRL.js → chunk-TEKMLYXS.js} +3 -4
  7. package/dist/cli/cli.d.ts +12 -0
  8. package/dist/cli/docs.d.ts +49 -0
  9. package/dist/cli/export.d.ts +11 -0
  10. package/dist/cli/generate-types.d.ts +6 -0
  11. package/dist/cli/import.d.ts +13 -0
  12. package/dist/cli/init-firebase.d.ts +7 -0
  13. package/dist/cli/utils.d.ts +27 -0
  14. package/dist/cli.js +10 -10
  15. package/dist/client.js +1 -1
  16. package/dist/core/ai-tools.d.ts +156 -0
  17. package/dist/core/ai.d.ts +330 -0
  18. package/dist/core/api.d.ts +21 -0
  19. package/dist/core/app.d.ts +16 -0
  20. package/dist/core/checks-translations.d.ts +13 -0
  21. package/dist/core/checks.d.ts +48 -0
  22. package/dist/core/client.d.ts +715 -0
  23. package/dist/core/core.d.ts +5 -0
  24. package/dist/core/cron.d.ts +19 -0
  25. package/dist/core/csv.d.ts +5 -0
  26. package/dist/core/functions.d.ts +9 -0
  27. package/dist/core/plugin.d.ts +357 -0
  28. package/dist/{project.d.ts → core/project.d.ts} +8 -12
  29. package/dist/core/richtext.d.ts +101 -0
  30. package/dist/{core.d.ts → core/route.d.ts} +13 -66
  31. package/dist/core/runtime.d.ts +46 -0
  32. package/dist/{schema-Db_xODoi.d.ts → core/schema.d.ts} +47 -100
  33. package/dist/core/search-extract.d.ts +70 -0
  34. package/dist/core/search-index.d.ts +182 -0
  35. package/dist/core/search-query.d.ts +68 -0
  36. package/dist/core/security.d.ts +6 -0
  37. package/dist/core/server-version.d.ts +5 -0
  38. package/dist/core/services-notifications.d.ts +57 -0
  39. package/dist/core/services.d.ts +44 -0
  40. package/dist/core/sse.d.ts +10 -0
  41. package/dist/core/translations-manager.d.ts +187 -0
  42. package/dist/core/translations.d.ts +83 -0
  43. package/dist/core/url-safety.d.ts +19 -0
  44. package/dist/core/validation.d.ts +30 -0
  45. package/dist/core/values.d.ts +9 -0
  46. package/dist/core/versions.d.ts +48 -0
  47. package/dist/core.js +1 -1
  48. package/dist/edit-M4PN4SGX.js +7 -0
  49. package/dist/functions.js +4 -4
  50. package/dist/{generate-types-SPV7I3A5.js → generate-types-JWIG4QVI.js} +1 -1
  51. package/dist/plugin.js +128 -133
  52. package/dist/shared/marshal.d.ts +68 -0
  53. package/dist/shared/objects.d.ts +9 -0
  54. package/dist/shared/richtext.d.ts +74 -0
  55. package/dist/shared/safe-json.d.ts +11 -0
  56. package/dist/shared/sanitize.d.ts +12 -0
  57. package/dist/shared/slug.d.ts +19 -0
  58. package/dist/shared/sse.d.ts +16 -0
  59. package/dist/shared/strings.d.ts +23 -0
  60. package/dist/ui/AIPage-YI3RFK5F.js +1 -0
  61. package/dist/ui/AssetsPage-4JNAOFYF.js +1 -0
  62. package/dist/ui/CollectionPage-JWHH5G55.js +1 -0
  63. package/dist/ui/ComparePage-YZE3EMU4.js +1 -0
  64. package/dist/ui/DataPage-VRCQSZZG.js +1 -0
  65. package/dist/ui/DataSourcePage-WMSPBZ3W.js +1 -0
  66. package/dist/ui/DocTranslationsPage-RY2LOZBX.js +1 -0
  67. package/dist/ui/DocumentPage-EEGTJMIW.js +1 -0
  68. package/dist/ui/EditDataSourcePage-LLCX6K4J.js +1 -0
  69. package/dist/ui/EditReleasePage-WQYXXMZQ.js +1 -0
  70. package/dist/ui/ImageEditorDialog-4H665KK2.js +81 -0
  71. package/dist/ui/ImageEditorDialog-4H665KK2.js.LEGAL.txt +17 -0
  72. package/dist/ui/LogsPage-IP2DKEYR.js +1 -0
  73. package/dist/ui/NewDataSourcePage-RDYJC4DH.js +1 -0
  74. package/dist/ui/NewReleasePage-DGMFU2JN.js +1 -0
  75. package/dist/ui/NotFoundPage-WDZ2K7EF.js +1 -0
  76. package/dist/ui/ProjectPage-HYJOQUWR.js +1 -0
  77. package/dist/ui/ReleasePage-2KSF23TK.js +1 -0
  78. package/dist/ui/ReleasesPage-NZIBBXU4.js +1 -0
  79. package/dist/ui/SettingsPage-36XFWV62.js +1 -0
  80. package/dist/ui/SidebarToolsPage-5C6YBWJ7.js +1 -0
  81. package/dist/ui/TaskPage-SPIFPGPP.js +1 -0
  82. package/dist/ui/TasksPage-ZOXRPBQV.js +1 -0
  83. package/dist/ui/TranslationsArbPage-UHANA7JD.js +2 -0
  84. package/dist/ui/TranslationsEditPage-PQY6W5YG.js +1 -0
  85. package/dist/ui/TranslationsPage-V2PQFCN5.js +162 -0
  86. package/dist/ui/ai-tools-5E5ELLZX.js +1 -0
  87. package/dist/ui/chunk-3IYZCUPI.js +1 -0
  88. package/dist/ui/chunk-4KE2SZKH.js +1 -0
  89. package/dist/ui/chunk-4W73RW5I.js +1 -0
  90. package/dist/ui/chunk-54DVDYU6.js +1 -0
  91. package/dist/ui/chunk-5MV6XVGA.js +1 -0
  92. package/dist/ui/chunk-62UWGWON.js +1 -0
  93. package/dist/ui/chunk-767BAQ53.js +1 -0
  94. package/dist/ui/chunk-AFWBSIPL.js +1 -0
  95. package/dist/ui/chunk-AL3TN2KI.js +1 -0
  96. package/dist/ui/chunk-BZIRGB4W.js +1 -0
  97. package/dist/ui/chunk-C5NH23G4.js +3 -0
  98. package/dist/ui/chunk-CGCKJFL4.js +1 -0
  99. package/dist/ui/chunk-DEGMKEHP.js +1 -0
  100. package/dist/ui/chunk-DTMZLUNY.js +15 -0
  101. package/dist/ui/chunk-DTMZLUNY.js.LEGAL.txt +237 -0
  102. package/dist/ui/chunk-DUJYIOLE.js +5 -0
  103. package/dist/ui/chunk-E2RCCK2T.js +1 -0
  104. package/dist/ui/chunk-EGEB6N4J.js +22 -0
  105. package/dist/ui/chunk-EGEB6N4J.js.LEGAL.txt +1059 -0
  106. package/dist/ui/chunk-FBJURT7Z.js +1 -0
  107. package/dist/ui/chunk-GXSAEPU3.js +1 -0
  108. package/dist/ui/chunk-HHMG665Z.js +1 -0
  109. package/dist/ui/chunk-HKINZLMW.js +84 -0
  110. package/dist/ui/chunk-HLMBCVRX.js +1 -0
  111. package/dist/ui/chunk-HRGYNHZ3.js +1 -0
  112. package/dist/ui/chunk-I6ICVKEC.js +1 -0
  113. package/dist/ui/chunk-JDW4UORS.js +1 -0
  114. package/dist/ui/chunk-JHBAMPGB.js +1 -0
  115. package/dist/ui/chunk-JT5L6GPZ.js +141 -0
  116. package/dist/ui/chunk-JT5L6GPZ.js.LEGAL.txt +106 -0
  117. package/dist/ui/chunk-JYFLU7DM.js +19 -0
  118. package/dist/ui/chunk-JZFTZ4X4.js +87 -0
  119. package/dist/ui/chunk-JZFTZ4X4.js.LEGAL.txt +9 -0
  120. package/dist/ui/chunk-KFAZBEPV.js +1 -0
  121. package/dist/ui/chunk-KKEWCXVV.js +1 -0
  122. package/dist/ui/chunk-KUCVLANF.js +1 -0
  123. package/dist/ui/chunk-KYDOSLTO.js +1 -0
  124. package/dist/ui/chunk-L4RHGQUG.js +1 -0
  125. package/dist/ui/chunk-MDUBCXU2.js +1 -0
  126. package/dist/ui/chunk-NXQVLOTK.js +1 -0
  127. package/dist/ui/chunk-NZHF733K.js +7 -0
  128. package/dist/ui/chunk-NZHF733K.js.LEGAL.txt +146 -0
  129. package/dist/ui/chunk-ONTGW2VA.js +1 -0
  130. package/dist/ui/chunk-ORXEMIQC.js +1 -0
  131. package/dist/ui/chunk-P3NETZZP.js +1 -0
  132. package/dist/ui/chunk-PHBMVORG.js +1 -0
  133. package/dist/ui/chunk-PJA7YP4A.js +1 -0
  134. package/dist/ui/chunk-PVAE643M.js +1 -0
  135. package/dist/ui/chunk-PWKJDYE2.js +1 -0
  136. package/dist/ui/chunk-RSVO46S3.js +1 -0
  137. package/dist/ui/chunk-SKEP5WYH.js +10 -0
  138. package/dist/ui/chunk-SKEP5WYH.js.LEGAL.txt +176 -0
  139. package/dist/ui/chunk-SQRKKWRG.js +3 -0
  140. package/dist/ui/chunk-TJBVMFNQ.js +1 -0
  141. package/dist/ui/chunk-V7S4IAGB.js +1 -0
  142. package/dist/ui/chunk-VMT7JFAM.js +1 -0
  143. package/dist/ui/chunk-W3BJ2EZX.js +1 -0
  144. package/dist/ui/chunk-W3HIZQ4Z.js +1 -0
  145. package/dist/ui/chunk-X2WHBGTP.js +1 -0
  146. package/dist/ui/chunk-XOQ3KDSR.js +3 -0
  147. package/dist/ui/chunk-YDO2EDVY.js +1 -0
  148. package/dist/ui/chunk-YFA6U2CV.js +1 -0
  149. package/dist/ui/gcs-L33FIRZU.js +1 -0
  150. package/dist/ui/prerender-Q4YSDCPB.js +1 -0
  151. package/dist/ui/signin.js +1 -1
  152. package/dist/ui/ui.css +1 -1
  153. package/dist/ui/ui.js +1 -630
  154. package/dist/ui/ui.js.LEGAL.txt +19 -732
  155. package/package.json +20 -20
  156. package/dist/client-1puwLgNx.d.ts +0 -1552
  157. package/dist/client.d.ts +0 -5
  158. package/dist/edit-MT4B37QK.js +0 -7
  159. package/dist/functions.d.ts +0 -13
  160. package/dist/plugin.d.ts +0 -5
  161. package/dist/richtext.d.ts +0 -104
@@ -0,0 +1,9 @@
1
+ Bundled license information:
2
+
3
+ is-plain-object/dist/is-plain-object.js:
4
+ /*!
5
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
6
+ *
7
+ * Copyright (c) 2014-2017, Jon Schlinkert.
8
+ * Released under the MIT License.
9
+ */
@@ -0,0 +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};
@@ -0,0 +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};
@@ -0,0 +1 @@
1
+ import{a as ce}from"./chunk-PVAE643M.js";function k(_,e){for(var t in e)_[t]=e[t];return _}function z(_){_&&_.parentNode&&_.parentNode.removeChild(_)}function ae(_,e,t){var o,l,n,i={};for(n in e)n=="key"?o=e[n]:n=="ref"?l=e[n]:i[n]=e[n];if(arguments.length>2&&(i.children=arguments.length>3?D.call(arguments,2):t),typeof _=="function"&&_.defaultProps!=null)for(n in _.defaultProps)i[n]===void 0&&(i[n]=_.defaultProps[n]);return E(_,i,o,l,null)}function E(_,e,t,o,l){var n={type:_,props:e,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:l??++Y,__i:-1,__u:0};return l==null&&d.vnode!=null&&d.vnode(n),n}function we(){return{current:null}}function I(_){return _.children}function N(_,e){this.props=_,this.context=e}function S(_,e){if(e==null)return _.__?S(_.__,_.__i+1):null;for(var t;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null)return t.__e;return typeof _.type=="function"?S(_):null}function re(_){var e,t;if((_=_.__)!=null&&_.__c!=null){for(_.__e=_.__c.base=null,e=0;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null){_.__e=_.__c.base=t.__e;break}return re(_)}}function B(_){(!_.__d&&(_.__d=!0)&&C.push(_)&&!H.__r++||K!=d.debounceRendering)&&((K=d.debounceRendering)||Z)(H)}function H(){for(var _,e,t,o,l,n,i,u=1;C.length;)C.length>u&&C.sort(ee),_=C.shift(),u=C.length,_.__d&&(t=void 0,l=(o=(e=_).__v).__e,n=[],i=[],e.__P&&((t=k({},o)).__v=o.__v+1,d.vnode&&d.vnode(t),q(e.__P,t,o,e.__n,e.__P.namespaceURI,32&o.__u?[l]:null,n,l??S(o),!!(32&o.__u),i),t.__v=o.__v,t.__.__k[t.__i]=t,ie(n,t,i),t.__e!=l&&re(t)));H.__r=0}function oe(_,e,t,o,l,n,i,u,f,s,p){var r,v,c,m,g,y,a,h=o&&o.__k||ne,w=e.length;for(f=he(t,e,h,f,w),r=0;r<w;r++)(c=t.__k[r])!=null&&(v=c.__i==-1?M:h[c.__i]||M,c.__i=r,y=q(_,c,v,l,n,i,u,f,s,p),m=c.__e,c.ref&&v.ref!=c.ref&&(v.ref&&G(v.ref,null,c),p.push(c.ref,c.__c||m,c)),g==null&&m!=null&&(g=m),(a=!!(4&c.__u))||v.__k===c.__k?f=le(c,f,_,a):typeof c.type=="function"&&y!==void 0?f=y:m&&(f=m.nextSibling),c.__u&=-7);return t.__e=g,f}function he(_,e,t,o,l){var n,i,u,f,s,p=t.length,r=p,v=0;for(_.__k=new Array(l),n=0;n<l;n++)(i=e[n])!=null&&typeof i!="boolean"&&typeof i!="function"?(f=n+v,(i=_.__k[n]=typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?E(null,i,null,null,null):L(i)?E(I,{children:i},null,null,null):i.constructor==null&&i.__b>0?E(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=_,i.__b=_.__b+1,u=null,(s=i.__i=ve(i,t,f,r))!=-1&&(r--,(u=t[s])&&(u.__u|=2)),u==null||u.__v==null?(s==-1&&(l>p?v--:l<p&&v++),typeof i.type!="function"&&(i.__u|=4)):s!=f&&(s==f-1?v--:s==f+1?v++:(s>f?v--:v++,i.__u|=4))):_.__k[n]=null;if(r)for(n=0;n<p;n++)(u=t[n])!=null&&(2&u.__u)==0&&(u.__e==o&&(o=S(u)),ue(u,u));return o}function le(_,e,t,o){var l,n;if(typeof _.type=="function"){for(l=_.__k,n=0;l&&n<l.length;n++)l[n]&&(l[n].__=_,e=le(l[n],e,t,o));return e}_.__e!=e&&(o&&(e&&_.type&&!e.parentNode&&(e=S(_)),t.insertBefore(_.__e,e||null)),e=_.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function de(_,e){return e=e||[],_==null||typeof _=="boolean"||(L(_)?_.some(function(t){de(t,e)}):e.push(_)),e}function ve(_,e,t,o){var l,n,i,u=_.key,f=_.type,s=e[t],p=s!=null&&(2&s.__u)==0;if(s===null&&_.key==null||p&&u==s.key&&f==s.type)return t;if(o>(p?1:0)){for(l=t-1,n=t+1;l>=0||n<e.length;)if((s=e[i=l>=0?l--:n++])!=null&&(2&s.__u)==0&&u==s.key&&f==s.type)return i}return-1}function Q(_,e,t){e[0]=="-"?_.setProperty(e,t??""):_[e]=t==null?"":typeof t!="number"||fe.test(e)?t:t+"px"}function F(_,e,t,o,l){var n,i;e:if(e=="style")if(typeof t=="string")_.style.cssText=t;else{if(typeof o=="string"&&(_.style.cssText=o=""),o)for(e in o)t&&e in t||Q(_.style,e,"");if(t)for(e in t)o&&t[e]==o[e]||Q(_.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")n=e!=(e=e.replace(_e,"$1")),i=e.toLowerCase(),e=i in _||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),_.l||(_.l={}),_.l[e+n]=t,t?o?t.u=o.u:(t.u=V,_.addEventListener(e,n?j:$,n)):_.removeEventListener(e,n?j:$,n);else{if(l=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in _)try{_[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?_.removeAttribute(e):_.setAttribute(e,e=="popover"&&t==1?"":t))}}function X(_){return function(e){if(this.l){var t=this.l[e.type+_];if(e.t==null)e.t=V++;else if(e.t<t.u)return;return t(d.event?d.event(e):e)}}}function q(_,e,t,o,l,n,i,u,f,s){var p,r,v,c,m,g,y,a,h,w,x,W,U,J,A,T,R,b=e.type;if(e.constructor!=null)return null;128&t.__u&&(f=!!(32&t.__u),n=[u=e.__e=t.__e]),(p=d.__b)&&p(e);e:if(typeof b=="function")try{if(a=e.props,h="prototype"in b&&b.prototype.render,w=(p=b.contextType)&&o[p.__c],x=p?w?w.props.value:p.__:o,t.__c?y=(r=e.__c=t.__c).__=r.__E:(h?e.__c=r=new b(a,x):(e.__c=r=new N(a,x),r.constructor=b,r.render=ye),w&&w.sub(r),r.props=a,r.state||(r.state={}),r.context=x,r.__n=o,v=r.__d=!0,r.__h=[],r._sb=[]),h&&r.__s==null&&(r.__s=r.state),h&&b.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=k({},r.__s)),k(r.__s,b.getDerivedStateFromProps(a,r.__s))),c=r.props,m=r.state,r.__v=e,v)h&&b.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),h&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(h&&b.getDerivedStateFromProps==null&&a!==c&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(a,x),!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(a,r.__s,x)===!1||e.__v==t.__v){for(e.__v!=t.__v&&(r.props=a,r.state=r.__s,r.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(P){P&&(P.__=e)}),W=0;W<r._sb.length;W++)r.__h.push(r._sb[W]);r._sb=[],r.__h.length&&i.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(a,r.__s,x),h&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(c,m,g)})}if(r.context=x,r.props=a,r.__P=_,r.__e=!1,U=d.__r,J=0,h){for(r.state=r.__s,r.__d=!1,U&&U(e),p=r.render(r.props,r.state,r.context),A=0;A<r._sb.length;A++)r.__h.push(r._sb[A]);r._sb=[]}else do r.__d=!1,U&&U(e),p=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++J<25);r.state=r.__s,r.getChildContext!=null&&(o=k(k({},o),r.getChildContext())),h&&!v&&r.getSnapshotBeforeUpdate!=null&&(g=r.getSnapshotBeforeUpdate(c,m)),T=p,p!=null&&p.type===I&&p.key==null&&(T=se(p.props.children)),u=oe(_,L(T)?T:[T],e,t,o,l,n,i,u,f,s),r.base=e.__e,e.__u&=-161,r.__h.length&&i.push(r),y&&(r.__E=r.__=null)}catch(P){if(e.__v=null,f||n!=null)if(P.then){for(e.__u|=f?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;n[n.indexOf(u)]=null,e.__e=u}else{for(R=n.length;R--;)z(n[R]);O(e)}else e.__e=t.__e,e.__k=t.__k,P.then||O(e);d.__e(P,e,t)}else n==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):u=e.__e=me(t.__e,e,t,o,l,n,i,f,s);return(p=d.diffed)&&p(e),128&e.__u?void 0:u}function O(_){_&&_.__c&&(_.__c.__e=!0),_&&_.__k&&_.__k.forEach(O)}function ie(_,e,t){for(var o=0;o<t.length;o++)G(t[o],t[++o],t[++o]);d.__c&&d.__c(e,_),_.some(function(l){try{_=l.__h,l.__h=[],_.some(function(n){n.call(l)})}catch(n){d.__e(n,l.__v)}})}function se(_){return typeof _!="object"||_==null||_.__b&&_.__b>0?_:L(_)?_.map(se):k({},_)}function me(_,e,t,o,l,n,i,u,f){var s,p,r,v,c,m,g,y=t.props,a=e.props,h=e.type;if(h=="svg"?l="http://www.w3.org/2000/svg":h=="math"?l="http://www.w3.org/1998/Math/MathML":l||(l="http://www.w3.org/1999/xhtml"),n!=null){for(s=0;s<n.length;s++)if((c=n[s])&&"setAttribute"in c==!!h&&(h?c.localName==h:c.nodeType==3)){_=c,n[s]=null;break}}if(_==null){if(h==null)return document.createTextNode(a);_=document.createElementNS(l,h,a.is&&a),u&&(d.__m&&d.__m(e,n),u=!1),n=null}if(h==null)y===a||u&&_.data==a||(_.data=a);else{if(n=n&&D.call(_.childNodes),y=t.props||M,!u&&n!=null)for(y={},s=0;s<_.attributes.length;s++)y[(c=_.attributes[s]).name]=c.value;for(s in y)if(c=y[s],s!="children"){if(s=="dangerouslySetInnerHTML")r=c;else if(!(s in a)){if(s=="value"&&"defaultValue"in a||s=="checked"&&"defaultChecked"in a)continue;F(_,s,null,c,l)}}for(s in a)c=a[s],s=="children"?v=c:s=="dangerouslySetInnerHTML"?p=c:s=="value"?m=c:s=="checked"?g=c:u&&typeof c!="function"||y[s]===c||F(_,s,c,y[s],l);if(p)u||r&&(p.__html==r.__html||p.__html==_.innerHTML)||(_.innerHTML=p.__html),e.__k=[];else if(r&&(_.innerHTML=""),oe(e.type=="template"?_.content:_,L(v)?v:[v],e,t,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":l,n,i,n?n[0]:t.__k&&S(t,0),u,f),n!=null)for(s=n.length;s--;)z(n[s]);u||(s="value",h=="progress"&&m==null?_.removeAttribute("value"):m!=null&&(m!==_[s]||h=="progress"&&!m||h=="option"&&m!=y[s])&&F(_,s,m,y[s],l),s="checked",g!=null&&g!=_[s]&&F(_,s,g,y[s],l))}return _}function G(_,e,t){try{if(typeof _=="function"){var o=typeof _.__u=="function";o&&_.__u(),o&&e==null||(_.__u=_(e))}else _.current=e}catch(l){d.__e(l,t)}}function ue(_,e,t){var o,l;if(d.unmount&&d.unmount(_),(o=_.ref)&&(o.current&&o.current!=_.__e||G(o,null,e)),(o=_.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(n){d.__e(n,e)}o.base=o.__P=null}if(o=_.__k)for(l=0;l<o.length;l++)o[l]&&ue(o[l],e,t||typeof _.type!="function");t||z(_.__e),_.__c=_.__=_.__e=void 0}function ye(_,e,t){return this.constructor(_,t)}function ge(_,e,t){var o,l,n,i;e==document&&(e=document.documentElement),d.__&&d.__(_,e),l=(o=typeof t=="function")?null:t&&t.__k||e.__k,n=[],i=[],q(e,_=(!o&&t||e).__k=ae(I,null,[_]),l||M,M,e.namespaceURI,!o&&t?[t]:l?null:e.firstChild?D.call(e.childNodes):null,n,!o&&t?t:l?l.__e:e.firstChild,o,i),ie(n,_,i)}function be(_,e){ge(_,e,be)}function xe(_,e,t){var o,l,n,i,u=k({},_.props);for(n in _.type&&_.type.defaultProps&&(i=_.type.defaultProps),e)n=="key"?o=e[n]:n=="ref"?l=e[n]:u[n]=e[n]===void 0&&i!=null?i[n]:e[n];return arguments.length>2&&(u.children=arguments.length>3?D.call(arguments,2):t),E(_.type,u,o||_.key,l||_.ref,null)}function Ce(_){function e(t){var o,l;return this.getChildContext||(o=new Set,(l={})[e.__c]=this,this.getChildContext=function(){return l},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(n){this.props.value!=n.value&&o.forEach(function(i){i.__e=!0,B(i)})},this.sub=function(n){o.add(n);var i=n.componentWillUnmount;n.componentWillUnmount=function(){o&&o.delete(n),i&&i.call(n)}}),t.children}return e.__c="__cC"+te++,e.__=_,e.Provider=e.__l=(e.Consumer=function(t,o){return t.children(o)}).contextType=e,e}var D,d,Y,pe,C,K,Z,ee,_e,V,$,j,te,M,ne,fe,L,ke=ce(()=>{"use strict";M={},ne=[],fe=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,L=Array.isArray;D=ne.slice,d={__e:function(_,e,t,o){for(var l,n,i;e=e.__;)if((l=e.__c)&&!l.__)try{if((n=l.constructor)&&n.getDerivedStateFromError!=null&&(l.setState(n.getDerivedStateFromError(_)),i=l.__d),l.componentDidCatch!=null&&(l.componentDidCatch(_,o||{}),i=l.__d),i)return l.__E=l}catch(u){_=u}throw _}},Y=0,pe=function(_){return _!=null&&_.constructor==null},N.prototype.setState=function(_,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=k({},this.state),typeof _=="function"&&(_=_(k({},t),this.props)),_&&k(t,_),_!=null&&this.__v&&(e&&this._sb.push(e),B(this))},N.prototype.forceUpdate=function(_){this.__v&&(this.__e=!0,_&&this.__h.push(_),B(this))},N.prototype.render=I,C=[],Z=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ee=function(_,e){return _.__v.__b-e.__v.__b},H.__r=0,_e=/(PointerCapture)$|Capture$/i,V=0,$=X(!1),j=X(!0),te=0});export{d as a,ae as b,we as c,I as d,N as e,de as f,ge as g,be as h,xe as i,Ce as j,ke as k};
@@ -0,0 +1 @@
1
+ import{c as x,n as y}from"./chunk-EGEB6N4J.js";import{a as d,c as g,j as R}from"./chunk-NZHF733K.js";var v=3600*1e3,p=new Map,P=new Map,h=new Set;function A(e){return e.trim().toLowerCase()}function E(e){let r=p.get(e);if(r){if(Date.now()-r.fetchedAt>v){p.delete(e);return}return r}}function M(){h.forEach(e=>e())}function T(e){let r=window.firebase.db,s=window.__ROOT_CTX.rootConfig.projectId;return x(r,"Projects",s,"UserProfiles",e)}function a(e){if(!e)return null;let r=E(A(e));return r?r.value:void 0}async function U(e){if(!e)return null;let r=A(e),s=E(r);if(s)return s.value;let n=P.get(r);if(n)return n;let i=(async()=>{try{let t=await y(T(r)),l=t.exists()?t.data():null;return p.set(r,{value:l,fetchedAt:Date.now()}),M(),l}catch(t){return console.error("failed to fetch user profile:",e,t),p.set(r,{value:null,fetchedAt:Date.now()}),null}finally{P.delete(r)}})();return P.set(r,i),i}function b(e){return h.add(e),()=>{h.delete(e)}}function O(e,r){if(!(r||e||"").trim())return"?";if(r){let t=r.trim().split(/\s+/).map(l=>l.replace(/[^a-zA-Z0-9]/g,"")).filter(Boolean);if(t.length>=2)return(t[0][0]+t[1][0]).toUpperCase();if(t.length===1&&t[0].length>0)return t[0].slice(0,2).toUpperCase()}let i=(e.split("@")[0]||e).replace(/[^a-zA-Z0-9]/g,"");return i.length===0?"?":i.slice(0,2).toUpperCase()}function S(e){let r=e.trim();if(!r)return"?";let[s,n=""]=r.split("@"),t=(_(r)?n:s||r).replace(/[^a-zA-Z0-9]/g,"");return t.length===0?"?":t[0].toUpperCase()}function _(e){return e.trim().startsWith("*@")}function z(e){let r=["#1f6feb","#0e7490","#0f766e","#15803d","#9333ea","#c026d3","#db2777","#dc2626","#ea580c","#b45309"],s=0;for(let n=0;n<e.length;n++)s=s*31+e.charCodeAt(n)>>>0;return r[s%r.length]}R();function H(e){let r=e?a(e):null,[s,n]=d(r??null),[i,t]=d(!!e&&r===void 0);return g(()=>{if(!e){n(null),t(!1);return}let l=!1,o=a(e);o!==void 0?(n(o),t(!1)):(t(!0),U(e).then(f=>{l||(n(f),t(!1))}));let c=b(()=>{if(l||!e)return;let f=a(e);f!==void 0&&n(f)});return()=>{l=!0,c()}},[e]),{profile:s,loading:i}}function W(e){let r=e.filter(o=>!!o).map(o=>o.toLowerCase()),s=r.slice().sort().join(","),[n,i]=d(()=>{let o=new Map;return r.forEach(c=>{let f=a(c);f!==void 0&&o.set(c,f)}),o}),[t,l]=d(r.length>0);return g(()=>{if(r.length===0){i(new Map),l(!1);return}let o=!1;function c(){let u=new Map,w=!1;r.forEach(C=>{let m=a(C);m===void 0?w=!0:u.set(C,m)}),i(u),l(w)}c(),Promise.all(r.filter(u=>a(u)===void 0).map(u=>U(u))).then(()=>{o||c()});let f=b(()=>{o||c()});return()=>{o=!0,f()}},[s]),{profiles:n,loading:t}}export{O as a,S as b,_ as c,z as d,H as e,W as f};
@@ -0,0 +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};
@@ -0,0 +1 @@
1
+ import{a as $}from"./chunk-JHBAMPGB.js";import{a as W}from"./chunk-V7S4IAGB.js";import{f as U}from"./chunk-3IYZCUPI.js";import{a as B,c as L,d as O,i as A}from"./chunk-RSVO46S3.js";import{a as j,c as q}from"./chunk-ONTGW2VA.js";import{a as H}from"./chunk-L4RHGQUG.js";import{a as T}from"./chunk-JDW4UORS.js";import{b as M}from"./chunk-62UWGWON.js";import{a as v}from"./chunk-I6ICVKEC.js";import{d as k}from"./chunk-AL3TN2KI.js";import{Ga as I,Ha as e,Pc as F,Ra as V,W as p,a as c,aa as D,c as N,e as P,ea as f,j as ie,oa as y,qa as z,va as E}from"./chunk-NZHF733K.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 ie}from"./chunk-54DVDYU6.js";import{a as ee,b as M,c as D}from"./chunk-JDW4UORS.js";import{a as se}from"./chunk-YDO2EDVY.js";import{c as oe,s as ne}from"./chunk-AFWBSIPL.js";import{b as te}from"./chunk-62UWGWON.js";import{a as $}from"./chunk-I6ICVKEC.js";import{a as j}from"./chunk-HLMBCVRX.js";import{a as L}from"./chunk-5MV6XVGA.js";import{b as K,f as U,g as _,i as y,o as Y}from"./chunk-EGEB6N4J.js";import{d as Z,f as re}from"./chunk-AL3TN2KI.js";import{A as G,Aa as J,Ha as d,a as p,c as w,e as C,ea as P,g as B,h as R,i as W,j as T,sa as Q,va as q}from"./chunk-NZHF733K.js";import{j as X,k as pe}from"./chunk-KUCVLANF.js";function z(e){let t=window.__ROOT_CTX.collections[e.collectionId];if(!t)throw new Error(`collection not found: ${e.collectionId}`);if(!t.url)return"";let n=t.domain||window.__ROOT_CTX.rootConfig.domain||"https://example.com",s=he(e);return`${n}${s}`}function he(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:s}=e,r=o[t];if(!r)throw new Error(`collection not found: ${t}`);if(!r.url)return"";let c=window.__ROOT_CTX.rootConfig,g=c.base||"/",u="/[base]/[path]";s&&(u=c.i18n.urlFormat||"/[locale]/[base]/[path]");let m="",a=r?.url;if(a)if(n){let l=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");l==="/index"&&(l="/"),m=l}else m=a;return ce(u,{base:g,path:m,locale:s||"",slug:n})}function we(e){let o=window.__ROOT_CTX.collections,{collectionId:t,slug:n,locale:s}=e,r=o[t];if(!r)throw new Error(`collection not found: ${t}`);let c=window.__ROOT_CTX.rootConfig,g=c.base||"/",u="/[base]/[path]";s&&(u=c.i18n.urlFormat||"/[locale]/[base]/[path]");let m="",a=r?.previewUrl||r?.url;if(a)if(n){let l=a.replace(/\[.*slug\]/,n).replaceAll("--","/").replace(/\/+/g,"/");l==="/index"&&(l="/"),m=l}else m=a;return ce(u,{base:g,path:m,locale:s||"",slug:n})}function ce(e,o){let t=e.replaceAll(/\[\[?(\.\.\.)?([\w\-_]*)\]?\]/g,(n,s,r)=>o[r]??n);return Se(t,{trailingSlash:window.__ROOT_CTX.rootConfig.server.trailingSlash})}function Se(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}T();function Ne(e,o){let[t,n]=p([]),[s,r]=p(!0),g=ie().db,u=window.__ROOT_CTX.rootConfig.projectId||"default",m=o.includeArchived??!1,a=async()=>{r(!0);let l=K(g,"Projects",u,"Collections",e,"Drafts"),i=l,f=o.orderBy;if(f==="modifiedAt")i=_(l,y("sys.modifiedAt","desc"));else if(f==="newest")i=_(l,y("sys.createdAt","desc"));else if(f==="oldest")i=_(l,y("sys.createdAt"));else if(f==="slug")i=_(l,y(U()));else if(f==="slugDesc")i=_(l,y(U(),"desc"));else{let h=window.__ROOT_CTX.collections[e]?.sortOptions?.find(v=>v.id===f);h&&(i=h.direction==="desc"?_(l,y(h.field,"desc")):_(l,y(h.field)))}await te(async()=>{let S=await Y(i),h=[];S.docs.forEach(v=>{let E=v.data(),b=v.id,x=`${e}/${b}`,O={...E,id:x,slug:b};oe(x,O),!(!m&&O?.sys?.archivedAt)&&h.push(O)}),n(h)}),r(!1)};return w(()=>{r(!0),a()},[e,o.orderBy,m]),[s,a,t]}pe();T();var N={CONNECTED:"connected",SCHEMA_CHANGED:"schemaChanged"};function le(e){let t=new URLSearchParams(window.location.search).get("e");return t?t.split(",").includes(e):!1}var Ee="/cms/api/sse.connect",A=le("EnableVerboseLogging"),ae=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(s=>s(t,n)),this.map.get("*")?.forEach(s=>s({type:o,data:t},n))}},de=X(null);function je(e){let t=C(new F).current,n=C(null),s=C(!1),r=C({attempt:0,timer:0}),c=C(""),g=()=>{n.current&&(n.current.close(),n.current=null)},u=R(()=>{A&&console.log("[sse] connecting..."),g();let a=new EventSource(Ee);n.current=a,a.addEventListener(N.CONNECTED,i=>{if(A&&console.log("[sse] connected"),s.current=!1,r.current.attempt=0,ae){let S=ue(i.data)?.serverVersion||"";c.current?c.current!==S&&(console.log(`server version changed: ${c.current} -> ${S}`),console.log("reloading..."),window.location.reload()):c.current=S}});let l=i=>{if(!i||!i.type)return;let f=ue(i.data);A&&console.log("[sse] event:",i.type,f),t.emit(i.type,f,i)};Object.values(N).forEach(i=>{a.addEventListener(i,l)}),a.addEventListener("error",()=>{A&&console.log("[sse] disconnected"),a.readyState===EventSource.CLOSED&&!s.current&&(s.current=!0,(()=>{let f=++r.current.attempt,S=Math.min(3e4,Math.pow(2,f)*500),h=Math.random()*.3*S,v=S+h;window.clearTimeout(r.current.timer),r.current.timer=window.setTimeout(()=>{s.current=!1,u()},v)})())})},[t]);w(()=>{if(!ae)return;u();let a=()=>{document.visibilityState==="visible"&&n.current?.readyState!==EventSource.OPEN&&u()};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a),window.clearTimeout(r.current.timer),g()}},[u]);let m=B(()=>({emitter:t}),[t]);return d(de.Provider,{value:m,children:e.children})}function ue(e){try{return JSON.parse(e)}catch{return e}}function fe(e,o){let t=W(de);if(!t)throw new Error("useSSE() must be used within an <SSEProvider>");let n=C(o);w(()=>{n.current=o},[o]),w(()=>t.emitter.on(e,(s,r)=>n.current(s,r)),[t,e])}T();T();function ge(e){let[o,t]=p(!0),[n,s]=p(null),r=R(async()=>{try{let c=await se(e);s(c)}catch(c){console.error(c),$({title:`Failed to load collection: ${e}`,message:String(c),color:"red",autoClose:!1})}t(!1)},[e]);return w(()=>{r()},[e]),fe(N.SCHEMA_CHANGED,async c=>{await r();let g=c.file?`Applied updates from changes to ${c.file}.`:"Applied updates from changes to a .schema.ts file.";$({title:"Updated schema!",message:g})}),{loading:o,schema:n}}function H(e){let o={_array:[]};return e.forEach(t=>{let n=Ce();o._array.push(n),o[n]=t}),o}function Ce(){let e=[],o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=o.length;for(let n=0;n<6;n++)e.push(o.charAt(Math.floor(Math.random()*t)));return e.join("")}function V(e){let o={};return e.fields.forEach(t=>{t.id&&(t.type==="array"&&t.default&&Array.isArray(t.default)?o[t.id]=H(t.default):t.default?o[t.id]=t.default:t.type==="object"&&(o[t.id]=V(t)))}),o}function k(e,o,t){let n={...o};return e.fields.forEach(s=>{if(!s.id)return;let r=n[s.id];if(r!=null){if(s.type==="array"&&Array.isArray(r)){let c=r.map(g=>ve(s.of,g,t));n[s.id]=H(c)}else if(s.type==="object"&&L(r))n[s.id]=k(s,r,t);else if(s.type==="oneof"&&L(r)&&typeof r._type=="string"&&t){let c=t[r._type];c&&(n[s.id]=k(c,r,t))}}}),n}function ve(e,o,t){if(!L(o))return o;if(e.type==="object")return k(e,o,t);if(e.type==="oneof"&&typeof o._type=="string"&&t){let n=t[o._type];if(n)return k(n,o,t)}return o}T();function me(e){let[o,t]=p(e.collectionId||""),n=C(null),[s,r]=p(""),c=window.__ROOT_CTX.collections[o],g=[];e.collectionId&&e.collectionDisabled?g.push({value:e.collectionId,label:e.collectionId}):Object.keys(window.__ROOT_CTX.collections).forEach(i=>{g.push({value:i,label:i})});let u="",m="";if(c?.url){if(s){let i=D(s),f=c?.slugRegex;ee(i,f)?u=z({collectionId:o,slug:i}):m=M(i,f)}else u=z({collectionId:o,slug:"[slug]"});u.endsWith("/index")&&(u=u.replace(/\/index$/,"/"))}function a(i){t(i),e.onChange&&e.onChange({collectionId:i,slug:s})}function l(i){r(i),e.onChange&&e.onChange({collectionId:o,slug:i})}return d("div",{className:re(e.className,"SlugInput"),children:[d("div",{className:"SlugInput__inputs",children:[d(J,{className:"SlugInput__collection",placeholder:"Collection",size:"xs",data:g,onChange:i=>a(i),value:o,disabled:!!e.collectionDisabled}),d("div",{className:"SlugInput__divider",children:"/"}),d(q,{className:"SlugInput__slug",name:"slug",ref:n,value:s,onChange:i=>{l(i.currentTarget.value)},placeholder:"slug",autoComplete:"off",size:"xs"})]}),u&&d(j,{className:"SlugInput__urlHelp",size:"body-sm",children:u}),m&&d(j,{className:"SlugInput__slugError",size:"body-sm",children:m})]})}function wt(e){let{route:o}=Z(),[t,n]=p(""),[s,r]=p(!1),[c,g]=p(""),[u,m]=p(""),a=G(),l=e.collection,i=window.__ROOT_CTX.collections[l];if(!i)throw new Error(`collection not found: ${l}`);let f=ge(l);function S(E){let b=D(E);return b?M(b,i.slugRegex):""}function h(){e.onClose&&e.onClose()}async function v(E){if(E.preventDefault(),r(!0),g(""),S(t)){r(!1);return}let x=D(t),O=`${l}/${x}`;try{let I={};!f.loading&&f.schema&&(I=await V(f.schema)),await ne(O,{fields:I})}catch(I){m(String(I)),r(!1);return}r(!1),e.skipNavigation?h():o(`/cms/content/${e.collection}/${x}`)}return d(Q,{className:"NewDocModal",opened:e.opened||!1,onClose:()=>h(),title:"New",size:"500px",overlayColor:a.colorScheme==="dark"?a.colors.dark[9]:a.colors.gray[2],children:[d("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."}),d("form",{onSubmit:E=>v(E),children:[d(me,{className:"NewDocModal__slug",collectionId:l,onChange:E=>{n(E.slug),g(S(E.slug)),m("")}}),u&&d("div",{className:"NewDocModal__slugError",children:u}),d("div",{className:"NewDocModal__buttons",children:[d(P,{variant:"outline",onClick:()=>h(),type:"button",size:"xs",color:"dark",children:"Cancel"}),d(P,{variant:"filled",type:"submit",size:"xs",color:"dark",loading:f.loading||s,disabled:!!c||!!u,children:"Submit"})]})]})]})}export{z as a,he as b,we as c,me as d,Ne as e,je as f,ge as g,V as h,k as i,wt as j};