@blinkk/root-cms 3.0.6 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +77 -0
  2. package/dist/app.js +6 -4
  3. package/dist/browser-client/browser-client.d.ts +148 -0
  4. package/dist/browser-client/embed-window.d.ts +66 -0
  5. package/dist/browser-client/emitter.d.ts +11 -0
  6. package/dist/browser-client.js +377 -0
  7. package/dist/{chunk-RXWDB3K4.js → chunk-4VZTYUQ7.js} +1 -1
  8. package/dist/{chunk-N4K6ICFR.js → chunk-AFBSITEO.js} +4 -6
  9. package/dist/{chunk-PNLLZXVY.js → chunk-AJDMNTZQ.js} +2 -2
  10. package/dist/{chunk-7L5OI5ES.js → chunk-GXV4UQ6Z.js} +8 -4
  11. package/dist/chunk-J72JK4KR.js +8 -0
  12. package/dist/cli.js +2 -1
  13. package/dist/client.js +2 -1
  14. package/dist/core/client.d.ts +5 -0
  15. package/dist/core.js +4 -2
  16. package/dist/functions.js +4 -3
  17. package/dist/plugin.js +5 -4
  18. package/dist/shared/embed-protocol.d.ts +72 -0
  19. package/dist/ui/AIPage-EL6DQYII.js +1 -0
  20. package/dist/ui/AssetsPage-5S6PNMF6.js +1 -0
  21. package/dist/ui/CollectionPage-CU3VDEXA.js +1 -0
  22. package/dist/ui/ComparePage-FTZLYO2O.js +1 -0
  23. package/dist/ui/DataPage-XIXFKXDN.js +1 -0
  24. package/dist/ui/DataSourcePage-ORIEQH3Y.js +1 -0
  25. package/dist/ui/DocTranslationsPage-4OVBIPSG.js +1 -0
  26. package/dist/ui/DocumentPage-3JPFJF3E.js +1 -0
  27. package/dist/ui/EditDataSourcePage-HIGZZQJC.js +1 -0
  28. package/dist/ui/EditReleasePage-KUHBU2HQ.js +1 -0
  29. package/dist/ui/EmbeddedAIPage-CJWZE5FC.js +1 -0
  30. package/dist/ui/EmbeddedDocumentPage-6XQHYIAO.js +1 -0
  31. package/dist/ui/{ImageEditorDialog-QEULJAT2.js → ImageEditorDialog-GGS4VFEA.js} +2 -2
  32. package/dist/ui/LogsPage-4DVGYXZY.js +1 -0
  33. package/dist/ui/NewDataSourcePage-7TUUE6ZL.js +1 -0
  34. package/dist/ui/NewReleasePage-6UT36HDW.js +1 -0
  35. package/dist/ui/NotFoundPage-AW6UC6II.js +1 -0
  36. package/dist/ui/ProjectPage-US5FJGFK.js +1 -0
  37. package/dist/ui/ReleasePage-W2R3DIFX.js +1 -0
  38. package/dist/ui/ReleasesPage-HBBUGE7D.js +1 -0
  39. package/dist/ui/SettingsPage-7JQQILUV.js +1 -0
  40. package/dist/ui/SidebarToolsPage-MIYXKHF2.js +1 -0
  41. package/dist/ui/TaskPage-JYUQEGRB.js +1 -0
  42. package/dist/ui/TasksPage-4VFQF243.js +1 -0
  43. package/dist/ui/TranslationsArbPage-AJLM5VSD.js +2 -0
  44. package/dist/ui/TranslationsEditPage-RTTGTIGI.js +1 -0
  45. package/dist/ui/{TranslationsPage-OBN6CQZZ.js → TranslationsPage-HPYAJQ4Q.js} +2 -2
  46. package/dist/ui/{chunk-WKOX3VFN.js → chunk-2KSMCQ6H.js} +2 -2
  47. package/dist/ui/{chunk-V7RAXP2W.js → chunk-3E6CASIN.js} +1 -1
  48. package/dist/ui/{chunk-N4DFAIC5.js → chunk-3T4ZWQR4.js} +1 -1
  49. package/dist/ui/chunk-4ISFTE2G.js +5 -0
  50. package/dist/ui/chunk-5AVRMJVW.js +1 -0
  51. package/dist/ui/chunk-764W6634.js +1 -0
  52. package/dist/ui/chunk-76ZGLKLT.js +1 -0
  53. package/dist/ui/{chunk-SKEP5WYH.js → chunk-7SK47HHZ.js} +3 -3
  54. package/dist/ui/chunk-AZCGXQTL.js +1 -0
  55. package/dist/ui/{chunk-KYKFNAX4.js → chunk-B6M55OFE.js} +1 -1
  56. package/dist/ui/{chunk-2225WAJ2.js → chunk-CAY5NM4Z.js} +1 -1
  57. package/dist/ui/{chunk-4KE2SZKH.js → chunk-D3UIZHRK.js} +1 -1
  58. package/dist/ui/{chunk-NMBXHKIJ.js → chunk-E76ECIOX.js} +1 -1
  59. package/dist/ui/chunk-FBSBL476.js +1 -0
  60. package/dist/ui/chunk-FFHV5S6A.js +1 -0
  61. package/dist/ui/{chunk-NQB37NMX.js → chunk-FJLNXXE3.js} +1 -1
  62. package/dist/ui/chunk-FSVNOZ6F.js +1 -0
  63. package/dist/ui/{chunk-3IDOZ4MG.js → chunk-GDXNSFLE.js} +1 -1
  64. package/dist/ui/{chunk-EMYXSVTD.js → chunk-GQ5IRK43.js} +1 -1
  65. package/dist/ui/{chunk-UHWNLNP4.js → chunk-GU24U5RM.js} +1 -1
  66. package/dist/ui/{chunk-KPJ53X55.js → chunk-HARRKJFZ.js} +1 -1
  67. package/dist/ui/{chunk-6E7PGMZX.js → chunk-HO3W4RVG.js} +1 -1
  68. package/dist/ui/{chunk-CVGYBXVH.js → chunk-J5E457OI.js} +1 -1
  69. package/dist/ui/{chunk-W3HIZQ4Z.js → chunk-JS6TK4OP.js} +1 -1
  70. package/dist/ui/{chunk-BEDUTYQP.js → chunk-JTIQBW33.js} +1 -1
  71. package/dist/ui/{chunk-ORXEMIQC.js → chunk-KRNQ6L35.js} +1 -1
  72. package/dist/ui/chunk-LROR6N3B.js +7 -0
  73. package/dist/ui/{chunk-4CUWZQXT.js.LEGAL.txt → chunk-LROR6N3B.js.LEGAL.txt} +6 -1
  74. package/dist/ui/{chunk-AOCBDKLV.js → chunk-M3T56ZRP.js} +1 -1
  75. package/dist/ui/chunk-MXGHX55S.js +141 -0
  76. package/dist/ui/{chunk-HYARD7BK.js → chunk-MZTOPPWQ.js} +1 -1
  77. package/dist/ui/{chunk-RQKL4KXY.js → chunk-N3JSLTMV.js} +1 -1
  78. package/dist/ui/{chunk-D37DCENS.js → chunk-NSOTG64N.js} +1 -1
  79. package/dist/ui/{chunk-N5Y5OWTV.js → chunk-O5P3CPJ4.js} +1 -1
  80. package/dist/ui/chunk-OWQL5DVE.js +1 -0
  81. package/dist/ui/{chunk-SEUH7LN2.js → chunk-OXVYTSIZ.js} +1 -1
  82. package/dist/ui/chunk-P2Z66DHV.js +1 -0
  83. package/dist/ui/{chunk-TZEZEMRQ.js → chunk-QEE7XS6O.js} +1 -1
  84. package/dist/ui/{chunk-AXETBZ6T.js → chunk-QHJOTXYB.js} +1 -1
  85. package/dist/ui/{chunk-4IXGYXA2.js → chunk-R6B3W5AJ.js} +1 -1
  86. package/dist/ui/{chunk-T47V6AGW.js → chunk-RAXWL656.js} +1 -1
  87. package/dist/ui/chunk-SRX7EWL4.js +1 -0
  88. package/dist/ui/{chunk-OVRTVMO5.js → chunk-TDUBSLEC.js} +1 -1
  89. package/dist/ui/chunk-TFB3VGWP.js +1 -0
  90. package/dist/ui/{chunk-6MOPIV5T.js → chunk-U7PWJV6F.js} +1 -1
  91. package/dist/ui/{chunk-GDSSFO5R.js → chunk-UUVAD4U4.js} +1 -1
  92. package/dist/ui/chunk-V4CTOC6E.js +1 -0
  93. package/dist/ui/{chunk-EGEB6N4J.js → chunk-VD6G5NV4.js} +11 -11
  94. package/dist/ui/chunk-W5DOO6ID.js +1 -0
  95. package/dist/ui/{chunk-3XYCOR6Z.js → chunk-WFQU7V3W.js} +1 -1
  96. package/dist/ui/{chunk-XYBHH5L4.js → chunk-WKF7CSWS.js} +1 -1
  97. package/dist/ui/{chunk-DXKEDMEI.js → chunk-WXT7LTQM.js} +1 -1
  98. package/dist/ui/{chunk-6GPTGBA7.js → chunk-XT5FNJCX.js} +1 -1
  99. package/dist/ui/chunk-YLSRRNSE.js +1 -0
  100. package/dist/ui/{chunk-UFQSZ6J2.js → chunk-ZN2Y5OUF.js} +1 -1
  101. package/dist/ui/gcs-ECSDFCIU.js +1 -0
  102. package/dist/ui/ui.css +1 -1
  103. package/dist/ui/ui.js +1 -1
  104. package/package.json +7 -3
  105. package/dist/ui/AIPage-JPZ4QUB4.js +0 -1
  106. package/dist/ui/AssetsPage-GDJMKS3M.js +0 -1
  107. package/dist/ui/CollectionPage-5DVXJEET.js +0 -1
  108. package/dist/ui/ComparePage-LIXA6G66.js +0 -1
  109. package/dist/ui/DataPage-AP4Z5JPS.js +0 -1
  110. package/dist/ui/DataSourcePage-WO3ZKMFI.js +0 -1
  111. package/dist/ui/DocTranslationsPage-QKYFIVHP.js +0 -1
  112. package/dist/ui/DocumentPage-ON43I5KM.js +0 -1
  113. package/dist/ui/EditDataSourcePage-XVMEV2LJ.js +0 -1
  114. package/dist/ui/EditReleasePage-A2NB5TFG.js +0 -1
  115. package/dist/ui/LogsPage-4LZJX3O4.js +0 -1
  116. package/dist/ui/NewDataSourcePage-4YWX7IOG.js +0 -1
  117. package/dist/ui/NewReleasePage-HWLVTEXX.js +0 -1
  118. package/dist/ui/NotFoundPage-72AXQAYX.js +0 -1
  119. package/dist/ui/ProjectPage-L4GYDIA5.js +0 -1
  120. package/dist/ui/ReleasePage-43BSWL5B.js +0 -1
  121. package/dist/ui/ReleasesPage-CJXAZBP6.js +0 -1
  122. package/dist/ui/SettingsPage-SYXAMKSF.js +0 -1
  123. package/dist/ui/SidebarToolsPage-OFF5BOXP.js +0 -1
  124. package/dist/ui/TaskPage-HBDLHFI5.js +0 -1
  125. package/dist/ui/TasksPage-OLCDTQNB.js +0 -1
  126. package/dist/ui/TranslationsArbPage-E3NCMAMS.js +0 -2
  127. package/dist/ui/TranslationsEditPage-IWOI7Y5G.js +0 -1
  128. package/dist/ui/chunk-32LRQ5MJ.js +0 -1
  129. package/dist/ui/chunk-3HVDIPSS.js +0 -1
  130. package/dist/ui/chunk-4CUWZQXT.js +0 -7
  131. package/dist/ui/chunk-DUJYIOLE.js +0 -5
  132. package/dist/ui/chunk-IDYKCAAL.js +0 -1
  133. package/dist/ui/chunk-IKED2IGU.js +0 -1
  134. package/dist/ui/chunk-J3EGGI57.js +0 -1
  135. package/dist/ui/chunk-MZP6RIG2.js +0 -1
  136. package/dist/ui/chunk-NQ5ARARP.js +0 -1
  137. package/dist/ui/chunk-RI2JWWU3.js +0 -141
  138. package/dist/ui/chunk-RPOP6MVJ.js +0 -1
  139. package/dist/ui/chunk-TDKVKTW4.js +0 -1
  140. package/dist/ui/chunk-UA7UCTX5.js +0 -1
  141. package/dist/ui/gcs-L33FIRZU.js +0 -1
  142. /package/dist/ui/{ImageEditorDialog-QEULJAT2.js.LEGAL.txt → ImageEditorDialog-GGS4VFEA.js.LEGAL.txt} +0 -0
  143. /package/dist/ui/{chunk-SKEP5WYH.js.LEGAL.txt → chunk-7SK47HHZ.js.LEGAL.txt} +0 -0
  144. /package/dist/ui/{chunk-NMBXHKIJ.js.LEGAL.txt → chunk-E76ECIOX.js.LEGAL.txt} +0 -0
  145. /package/dist/ui/{chunk-RI2JWWU3.js.LEGAL.txt → chunk-MXGHX55S.js.LEGAL.txt} +0 -0
  146. /package/dist/ui/{chunk-EGEB6N4J.js.LEGAL.txt → chunk-VD6G5NV4.js.LEGAL.txt} +0 -0
@@ -1,8 +1,8 @@
1
- import{a as _t,b as ht,c as ut,d as tt}from"./chunk-6E7PGMZX.js";import{a as lt}from"./chunk-N4DFAIC5.js";import{a as mt,c as Z}from"./chunk-NMBXHKIJ.js";import{b as dt,d as ct}from"./chunk-344GZOGG.js";import{f as pt}from"./chunk-SKEP5WYH.js";import{f as K}from"./chunk-5MV6XVGA.js";import{d as at,f as M}from"./chunk-RPOP6MVJ.js";import{$a as Y,Ac as rt,Fa as O,Ga as t,Oc as st,Tc as B,V,W as E,Za as q,_a as X,a as p,ba as J,c as k,da as S,dc as G,e as N,g as ot,h as T,ic as Q,j as At,jc as it,lb as nt,qa as $,uc as j}from"./chunk-4CUWZQXT.js";import{d as et}from"./chunk-KUCVLANF.js";At();function ft(o){let{size:e=14}=o,a=e*3.57,i=e*2;return t("div",{className:"BouncingLoader",style:{"--dot-size":`${e}px`,width:`${a}px`,height:`${i}px`}})}var W=[{id:"read",label:"Read only",description:"Inspect CMS content without planning or applying writes."},{id:"approve",label:"Ask before writing",description:"Read freely, then pause for approval before draft edits."},{id:"auto",label:"Auto-apply draft edits",description:"Apply draft-only writes without approval in this chat."}],It="root-cms.ai.executionMode",vt="root-cms.ai.selectedModel";function bt(o){return W.some(e=>e.id===o)}function Rt(){if(typeof window>"u")return"approve";try{let o=window.localStorage.getItem(It);if(bt(o))return o}catch(o){console.error("failed to read AI execution mode preference",o)}return"approve"}function yt(o){if(typeof window>"u")return null;try{let e=window.localStorage.getItem(vt);if(e&&o.some(a=>a.id===e))return e}catch(e){console.error("failed to read AI model preference",e)}return null}function wt(o){if(!(typeof window>"u"))try{window.localStorage.setItem(vt,o)}catch(e){console.error("failed to save AI model preference",e)}}function kt(o){if(!(typeof window>"u"))try{window.localStorage.setItem(It,o)}catch(e){console.error("failed to save AI execution mode preference",e)}}var U="";function Ie(o){let[e,a]=p(null),[i,m]=p("");k(()=>{let r=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let g=await l.json();r&&a(g)}).catch(l=>{r&&m(String(l))}),()=>{r=!1}},[]);let h=!!e?.enabled&&(e.models?.length||0)>0;return t("div",{className:M("RootAIChat",`RootAIChat--${o.variant}`),children:!e&&!i?t("div",{className:"RootAIChat__loading",children:t(V,{size:"md",color:"gray"})}):h?t(Mt,{variant:o.variant,config:e,initialChatId:o.variant==="panel"?void 0:o.initialChatId,docContext:o.docContext,onClose:o.onClose}):t(Nt,{error:i,onClose:o.onClose})})}function Nt(o){return t("div",{className:"RootAIChat__notEnabled",children:[o.onClose&&t(E,{className:"RootAIChat__notEnabled__close",onClick:o.onClose,title:"Close",children:t(B,{size:16})}),t("div",{className:"RootAIChat__notEnabled__icon",children:t(j,{size:36})}),t("div",{className:"RootAIChat__notEnabled__title",children:"Root AI is not configured for this project."}),t("div",{className:"RootAIChat__notEnabled__body",children:["Add an ",t("code",{children:"ai.models"})," entry to ",t("code",{children:"cmsPlugin()"})," in"," ",t("code",{children:"root.config.ts"}),"."]}),o.error&&t("pre",{className:"RootAIChat__notEnabled__error",children:o.error})]})}function Mt(o){let e=o.variant==="panel",{route:a}=at(),i=o.config.models||[],m=()=>yt(i)||o.config.defaultModel||i[0]?.id||"",[h,r]=p(m),[l,g]=p(Rt),[u,I]=p(o.initialChatId||U),[P,y]=p(o.initialChatId||U),[D,s]=p([]),[f,x]=p([]),[v,w]=p(0),z=async()=>{if(!e)try{let R=await(await fetch("/cms/api/ai.chats.list",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({})})).json();R.success&&x(R.chats||[])}catch(d){console.error("failed to load chat list",d)}};k(()=>{z(),!e&&o.initialChatId&&n(o.initialChatId)},[]),k(()=>{kt(l)},[l]);let n=async d=>{try{let b=await(await fetch("/cms/api/ai.chats.get",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})})).json();if(!b.success)return;I(d),y(d),s(b.chat.messages||[]),b.chat.modelId&&i.find(F=>F.id===b.chat.modelId)&&r(b.chat.modelId),w(L=>L+1)}catch(R){console.error("failed to load chat",R)}},_=()=>{r(m()),I(U),y(U),s([]),w(d=>d+1),e||a("/cms/ai")},c=async d=>{if(d!==P)try{let b=await(await fetch("/cms/api/ai.chats.get",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})})).json();if(!b.success)return;I(d),y(d),s(b.chat.messages||[]),b.chat.modelId&&i.find(F=>F.id===b.chat.modelId)&&r(b.chat.modelId),w(L=>L+1),e||a(`/cms/ai/chat/${d}`)}catch(R){console.error("failed to load chat",R)}},C=async d=>{try{await fetch("/cms/api/ai.chats.delete",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})}),P===d&&_(),z()}catch(R){console.error("failed to delete chat",R)}},A=i.find(d=>d.id===h)||i[0],H=d=>{r(d),wt(d)};return t("div",{className:"RootAIChat__layout",children:[!e&&t(Tt,{chats:f,activeChatId:P,onSelect:c,onNew:_,onDelete:C}),t("div",{className:"RootAIChat__main",children:[e&&t(Pt,{onNewChat:_,onClose:o.onClose}),t(zt,{initialChatId:u,model:A,initialMessages:D,executionMode:l,models:i,selectedModel:A,docContext:o.docContext,onSelectModel:H,onSelectExecutionMode:g,onChatPersisted:d=>{y(d),z(),e||window.history.replaceState(null,"",`/cms/ai/chat/${d}`)}},v)]})]})}function Pt(o){return t("div",{className:"RootAIChat__panelHeader",children:[t("div",{className:"RootAIChat__panelHeader__title",children:[t(j,{size:14}),t("span",{children:"Root AI"})]}),t("div",{className:"RootAIChat__panelHeader__actions",children:[t(O,{label:"New chat",children:t(E,{size:"xs",onClick:o.onNewChat,children:t(G,{size:14})})}),o.onClose&&t(O,{label:"Close (\u2318 + i)",children:t(E,{size:"xs",onClick:o.onClose,children:t(B,{size:14})})})]})]})}function Tt(o){return t("aside",{className:"RootAIChat__sidebar",children:[t("button",{type:"button",className:"RootAIChat__sidebar__newButton",onClick:o.onNew,children:[t(G,{size:18}),t("span",{children:"New chat"})]}),t("div",{className:"RootAIChat__sidebar__list",children:[o.chats.length===0&&t("div",{className:"RootAIChat__sidebar__empty",children:"No chats yet."}),o.chats.map(e=>t("div",{className:M("RootAIChat__sidebar__item",e.id===o.activeChatId&&"RootAIChat__sidebar__item--active"),onClick:()=>o.onSelect(e.id),children:[t("div",{className:"RootAIChat__sidebar__item__title",title:e.title||"Untitled chat",children:e.title||"Untitled chat"}),t("button",{type:"button",className:"RootAIChat__sidebar__item__delete",title:"Delete chat",onClick:a=>{a.stopPropagation(),window.confirm("Delete this chat?")&&o.onDelete(e.id)},children:t(st,{size:14})})]},e.id))]})]})}function Et(o){let e=W.find(a=>a.id===o.executionMode)||W[0];return t("div",{className:"RootAIChat__options",children:[t($,{control:t(S,{type:"button",className:"RootAIChat__modePicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:t(it,{size:16}),children:e.label}),children:W.map(a=>t($.Item,{onClick:()=>o.onSelectExecutionMode(a.id),children:t("div",{className:"RootAIChat__modePicker__option",children:[t("div",{className:"RootAIChat__modePicker__option__label",children:a.label}),t("div",{className:"RootAIChat__modePicker__option__description",children:a.description})]})},a.id))}),t($,{control:t(S,{type:"button",className:"RootAIChat__modelPicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:t(j,{size:16}),children:o.selectedModel?.label||"Select model"}),children:o.models.map(a=>t($.Item,{onClick:()=>o.onSelectModel(a.id),children:t("div",{className:"RootAIChat__modelPicker__option",children:[t("div",{className:"RootAIChat__modelPicker__option__label",children:a.label}),a.description&&t("div",{className:"RootAIChat__modelPicker__option__description",children:a.description})]})},a.id))})]})}function zt(o){let[e]=p(()=>o.initialChatId||Gt()),a=N(o.model?.id);a.current=o.model?.id;let i=N(o.executionMode);i.current=o.executionMode;let m=N(o.docContext);m.current=o.docContext;let[h,r]=p({}),l=N({});k(()=>()=>{for(let n of Object.values(l.current))n("reject");l.current={}},[]);let g=T((n,_,c,C)=>new Promise(A=>{l.current[n]=A,r(H=>({...H,[n]:{toolCallId:n,toolName:_,input:c,preview:C,status:"pending"}}))}),[]),u=T(n=>{r(_=>{let c=_[n];return c?{..._,[n]:{...c,status:"executing"}}:_}),l.current[n]?.("approve"),delete l.current[n]},[]),I=T(n=>{r(_=>{let c={..._};return delete c[n],c}),l.current[n]?.("reject"),delete l.current[n]},[]),P=T(async n=>{if(!ht(n.toolName))return await tt(n.toolName,n.input);let _=i.current;if(_==="read")return{success:!1,error:"WRITE_BLOCKED_BY_MODE",message:"The current execution mode is read only. Do not call write tools."};let c;try{c=await ut(n.toolName,n.input)}catch(C){return{success:!1,error:"PREVIEW_FAILED",message:C?.message||String(C)}}if(c.error)return{success:!1,error:c.error,message:c.summary,errors:c.errors,hint:c.hint};if(_==="approve"&&await g(n.toolCallId,n.toolName,n.input,c)==="reject")return{success:!1,error:"USER_REJECTED",message:"The user rejected this draft change. Do not retry unless they ask for a revised version."};try{return await tt(n.toolName,n.input)}finally{r(C=>{if(!C[n.toolCallId])return C;let A={...C};return delete A[n.toolCallId],A})}},[g]),y=ot(()=>new dt({api:"/cms/api/ai.chat",credentials:"include",prepareSendMessagesRequest:({messages:n})=>({body:{message:n.at(-1),chatId:e,modelId:a.current,executionMode:i.current,docId:m.current?.docId}})}),[e]),{messages:D,sendMessage:s,status:f,error:x,stop:v,addToolOutput:w}=_t({id:e,messages:o.initialMessages,transport:y,sendAutomaticallyWhen:ct,onToolCall:async({toolCall:n})=>{let _=await P(n);w({tool:n.toolName,toolCallId:n.toolCallId,output:_})},onFinish:()=>{o.onChatPersisted(e)}}),z=f==="streaming"||f==="submitted";return t(et,{children:[t(St,{messages:D,isStreaming:z,emptyMessage:o.model?void 0:"Select a model to start.",toolApprovals:{approvals:h,onApprove:u,onReject:I}}),x&&t("div",{className:"RootAIChat__error",children:[t("strong",{children:"Error:"})," ",x.message]}),t(Vt,{disabled:!o.model,canAttach:o.model?.capabilities.attachments??!1,isStreaming:z,onStop:v,controls:t(Et,{models:o.models,selectedModel:o.selectedModel,onSelectModel:o.onSelectModel,executionMode:o.executionMode,onSelectExecutionMode:o.onSelectExecutionMode}),onSend:(n,_)=>{if(!n&&_.length===0)return;let c=Jt(_),C=[n,c.text].filter(Boolean).join(`
1
+ import{a as pt,b as ht,c as ut,d as tt}from"./chunk-HO3W4RVG.js";import{a as dt}from"./chunk-3T4ZWQR4.js";import{a as mt,c as Z}from"./chunk-E76ECIOX.js";import{b as ct,d as _t}from"./chunk-344GZOGG.js";import{f as K}from"./chunk-5MV6XVGA.js";import{d as at,f as M}from"./chunk-YLSRRNSE.js";import{$a as Y,Dc as st,Fa as O,Ga as t,Rc as lt,V,W as E,Yc as B,Za as q,_a as X,a as p,ba as J,c as k,da as S,e as N,g as ot,gc as G,h as T,j as At,lb as it,lc as Q,mc as rt,qa as $,xc as j}from"./chunk-LROR6N3B.js";import{d as et}from"./chunk-KUCVLANF.js";import{h as nt}from"./chunk-7SK47HHZ.js";At();function ft(o){let{size:e=14}=o,a=e*3.57,i=e*2;return t("div",{className:"BouncingLoader",style:{"--dot-size":`${e}px`,width:`${a}px`,height:`${i}px`}})}var W=[{id:"read",label:"Read only",description:"Inspect CMS content without planning or applying writes."},{id:"approve",label:"Ask before writing",description:"Read freely, then pause for approval before draft edits."},{id:"auto",label:"Auto-apply draft edits",description:"Apply draft-only writes without approval in this chat."}],It="root-cms.ai.executionMode",vt="root-cms.ai.selectedModel";function bt(o){return W.some(e=>e.id===o)}function Rt(){if(typeof window>"u")return"approve";try{let o=window.localStorage.getItem(It);if(bt(o))return o}catch(o){console.error("failed to read AI execution mode preference",o)}return"approve"}function yt(o){if(typeof window>"u")return null;try{let e=window.localStorage.getItem(vt);if(e&&o.some(a=>a.id===e))return e}catch(e){console.error("failed to read AI model preference",e)}return null}function wt(o){if(!(typeof window>"u"))try{window.localStorage.setItem(vt,o)}catch(e){console.error("failed to save AI model preference",e)}}function kt(o){if(!(typeof window>"u"))try{window.localStorage.setItem(It,o)}catch(e){console.error("failed to save AI execution mode preference",e)}}var U="";function Ie(o){let[e,a]=p(null),[i,m]=p("");k(()=>{let r=!0;return fetch("/cms/api/ai.config",{credentials:"include"}).then(async l=>{let g=await l.json();r&&a(g)}).catch(l=>{r&&m(String(l))}),()=>{r=!1}},[]);let h=!!e?.enabled&&(e.models?.length||0)>0;return t("div",{className:M("RootAIChat",`RootAIChat--${o.variant}`),children:!e&&!i?t("div",{className:"RootAIChat__loading",children:t(V,{size:"md",color:"gray"})}):h?t(Mt,{variant:o.variant,config:e,initialChatId:o.variant==="panel"?void 0:o.initialChatId,docContext:o.docContext,onClose:o.onClose}):t(Nt,{error:i,onClose:o.onClose})})}function Nt(o){return t("div",{className:"RootAIChat__notEnabled",children:[o.onClose&&t(E,{className:"RootAIChat__notEnabled__close",onClick:o.onClose,title:"Close",children:t(B,{size:16})}),t("div",{className:"RootAIChat__notEnabled__icon",children:t(j,{size:36})}),t("div",{className:"RootAIChat__notEnabled__title",children:"Root AI is not configured for this project."}),t("div",{className:"RootAIChat__notEnabled__body",children:["Add an ",t("code",{children:"ai.models"})," entry to ",t("code",{children:"cmsPlugin()"})," in"," ",t("code",{children:"root.config.ts"}),"."]}),o.error&&t("pre",{className:"RootAIChat__notEnabled__error",children:o.error})]})}function Mt(o){let e=o.variant==="panel",{route:a}=at(),i=o.config.models||[],m=()=>yt(i)||o.config.defaultModel||i[0]?.id||"",[h,r]=p(m),[l,g]=p(Rt),[u,I]=p(o.initialChatId||U),[P,y]=p(o.initialChatId||U),[D,s]=p([]),[f,x]=p([]),[v,w]=p(0),z=async()=>{if(!e)try{let R=await(await fetch("/cms/api/ai.chats.list",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({})})).json();R.success&&x(R.chats||[])}catch(d){console.error("failed to load chat list",d)}};k(()=>{z(),!e&&o.initialChatId&&n(o.initialChatId)},[]),k(()=>{kt(l)},[l]);let n=async d=>{try{let b=await(await fetch("/cms/api/ai.chats.get",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})})).json();if(!b.success)return;I(d),y(d),s(b.chat.messages||[]),b.chat.modelId&&i.find(F=>F.id===b.chat.modelId)&&r(b.chat.modelId),w(L=>L+1)}catch(R){console.error("failed to load chat",R)}},_=()=>{r(m()),I(U),y(U),s([]),w(d=>d+1),e||a("/cms/ai")},c=async d=>{if(d!==P)try{let b=await(await fetch("/cms/api/ai.chats.get",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})})).json();if(!b.success)return;I(d),y(d),s(b.chat.messages||[]),b.chat.modelId&&i.find(F=>F.id===b.chat.modelId)&&r(b.chat.modelId),w(L=>L+1),e||a(`/cms/ai/chat/${d}`)}catch(R){console.error("failed to load chat",R)}},C=async d=>{try{await fetch("/cms/api/ai.chats.delete",{method:"POST",credentials:"include",headers:{"content-type":"application/json"},body:JSON.stringify({id:d})}),P===d&&_(),z()}catch(R){console.error("failed to delete chat",R)}},A=i.find(d=>d.id===h)||i[0],H=d=>{r(d),wt(d)};return t("div",{className:"RootAIChat__layout",children:[!e&&t(Tt,{chats:f,activeChatId:P,onSelect:c,onNew:_,onDelete:C}),t("div",{className:"RootAIChat__main",children:[e&&t(Pt,{onNewChat:_,onClose:o.onClose}),t(zt,{initialChatId:u,model:A,initialMessages:D,executionMode:l,models:i,selectedModel:A,docContext:o.docContext,onSelectModel:H,onSelectExecutionMode:g,onChatPersisted:d=>{y(d),z(),e||window.history.replaceState(null,"",`/cms/ai/chat/${d}`)}},v)]})]})}function Pt(o){return t("div",{className:"RootAIChat__panelHeader",children:[t("div",{className:"RootAIChat__panelHeader__title",children:[t(j,{size:14}),t("span",{children:"Root AI"})]}),t("div",{className:"RootAIChat__panelHeader__actions",children:[t(O,{label:"New chat",children:t(E,{size:"xs",onClick:o.onNewChat,children:t(G,{size:14})})}),o.onClose&&t(O,{label:"Close (\u2318 + i)",children:t(E,{size:"xs",onClick:o.onClose,children:t(B,{size:14})})})]})]})}function Tt(o){return t("aside",{className:"RootAIChat__sidebar",children:[t("button",{type:"button",className:"RootAIChat__sidebar__newButton",onClick:o.onNew,children:[t(G,{size:18}),t("span",{children:"New chat"})]}),t("div",{className:"RootAIChat__sidebar__list",children:[o.chats.length===0&&t("div",{className:"RootAIChat__sidebar__empty",children:"No chats yet."}),o.chats.map(e=>t("div",{className:M("RootAIChat__sidebar__item",e.id===o.activeChatId&&"RootAIChat__sidebar__item--active"),onClick:()=>o.onSelect(e.id),children:[t("div",{className:"RootAIChat__sidebar__item__title",title:e.title||"Untitled chat",children:e.title||"Untitled chat"}),t("button",{type:"button",className:"RootAIChat__sidebar__item__delete",title:"Delete chat",onClick:a=>{a.stopPropagation(),window.confirm("Delete this chat?")&&o.onDelete(e.id)},children:t(lt,{size:14})})]},e.id))]})]})}function Et(o){let e=W.find(a=>a.id===o.executionMode)||W[0];return t("div",{className:"RootAIChat__options",children:[t($,{control:t(S,{type:"button",className:"RootAIChat__modePicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:t(rt,{size:16}),children:e.label}),children:W.map(a=>t($.Item,{onClick:()=>o.onSelectExecutionMode(a.id),children:t("div",{className:"RootAIChat__modePicker__option",children:[t("div",{className:"RootAIChat__modePicker__option__label",children:a.label}),t("div",{className:"RootAIChat__modePicker__option__description",children:a.description})]})},a.id))}),t($,{control:t(S,{type:"button",className:"RootAIChat__modelPicker",variant:"subtle",color:"dark",size:"xs",compact:!0,leftIcon:t(j,{size:16}),children:o.selectedModel?.label||"Select model"}),children:o.models.map(a=>t($.Item,{onClick:()=>o.onSelectModel(a.id),children:t("div",{className:"RootAIChat__modelPicker__option",children:[t("div",{className:"RootAIChat__modelPicker__option__label",children:a.label}),a.description&&t("div",{className:"RootAIChat__modelPicker__option__description",children:a.description})]})},a.id))})]})}function zt(o){let[e]=p(()=>o.initialChatId||Gt()),a=N(o.model?.id);a.current=o.model?.id;let i=N(o.executionMode);i.current=o.executionMode;let m=N(o.docContext);m.current=o.docContext;let[h,r]=p({}),l=N({});k(()=>()=>{for(let n of Object.values(l.current))n("reject");l.current={}},[]);let g=T((n,_,c,C)=>new Promise(A=>{l.current[n]=A,r(H=>({...H,[n]:{toolCallId:n,toolName:_,input:c,preview:C,status:"pending"}}))}),[]),u=T(n=>{r(_=>{let c=_[n];return c?{..._,[n]:{...c,status:"executing"}}:_}),l.current[n]?.("approve"),delete l.current[n]},[]),I=T(n=>{r(_=>{let c={..._};return delete c[n],c}),l.current[n]?.("reject"),delete l.current[n]},[]),P=T(async n=>{if(!ht(n.toolName))return await tt(n.toolName,n.input);let _=i.current;if(_==="read")return{success:!1,error:"WRITE_BLOCKED_BY_MODE",message:"The current execution mode is read only. Do not call write tools."};let c;try{c=await ut(n.toolName,n.input)}catch(C){return{success:!1,error:"PREVIEW_FAILED",message:C?.message||String(C)}}if(c.error)return{success:!1,error:c.error,message:c.summary,errors:c.errors,hint:c.hint};if(_==="approve"&&await g(n.toolCallId,n.toolName,n.input,c)==="reject")return{success:!1,error:"USER_REJECTED",message:"The user rejected this draft change. Do not retry unless they ask for a revised version."};try{return await tt(n.toolName,n.input)}finally{r(C=>{if(!C[n.toolCallId])return C;let A={...C};return delete A[n.toolCallId],A})}},[g]),y=ot(()=>new ct({api:"/cms/api/ai.chat",credentials:"include",prepareSendMessagesRequest:({messages:n})=>({body:{message:n.at(-1),chatId:e,modelId:a.current,executionMode:i.current,docId:m.current?.docId}})}),[e]),{messages:D,sendMessage:s,status:f,error:x,stop:v,addToolOutput:w}=pt({id:e,messages:o.initialMessages,transport:y,sendAutomaticallyWhen:_t,onToolCall:async({toolCall:n})=>{let _=await P(n);w({tool:n.toolName,toolCallId:n.toolCallId,output:_})},onFinish:()=>{o.onChatPersisted(e)}}),z=f==="streaming"||f==="submitted";return t(et,{children:[t(St,{messages:D,isStreaming:z,emptyMessage:o.model?void 0:"Select a model to start.",toolApprovals:{approvals:h,onApprove:u,onReject:I}}),x&&t("div",{className:"RootAIChat__error",children:[t("strong",{children:"Error:"})," ",x.message]}),t(Vt,{disabled:!o.model,canAttach:o.model?.capabilities.attachments??!1,isStreaming:z,onStop:v,controls:t(Et,{models:o.models,selectedModel:o.selectedModel,onSelectModel:o.onSelectModel,executionMode:o.executionMode,onSelectExecutionMode:o.onSelectExecutionMode}),onSend:(n,_)=>{if(!n&&_.length===0)return;let c=Jt(_),C=[n,c.text].filter(Boolean).join(`
2
2
 
3
3
  `);s({text:C,files:c.files.map(A=>({type:"file",mediaType:A.mediaType,url:A.url,filename:A.filename}))})}})]})}function St(o){let e=N(null);return k(()=>{let a=e.current;a&&(a.scrollTop=a.scrollHeight)},[o.messages]),o.messages.length===0?t("div",{className:"RootAIChat__transcript RootAIChat__transcript--empty",ref:e,children:t("div",{className:"RootAIChat__welcome",children:[t("div",{className:"RootAIChat__welcome__icon",children:t(j,{size:36})}),t("div",{className:"RootAIChat__welcome__title",children:"Root AI"}),t("div",{className:"RootAIChat__welcome__body",children:o.emptyMessage||"What are we going to get done today?"})]})}):t("div",{className:"RootAIChat__transcript",ref:e,children:t("div",{className:"RootAIChat__transcript__inner",children:[o.messages.map(a=>t(jt,{message:a,toolApprovals:o.toolApprovals},a.id)),o.isStreaming&&t("div",{className:"RootAIChat__streamingIndicator",children:t(ft,{size:6})})]})})}function jt(o){let e=o.message,a=e.role==="user",i=a?"You":"Root AI",m=a?window.firebase.user?.photoURL:null,[h,r]=p(!1),l=T(()=>(e.parts||[]).filter(u=>u.type==="text"&&u.text).map(u=>u.text).join(`
4
4
 
5
- `),[e.parts]),g=T(async()=>{let u=l();if(!u)return;let I=mt.parse(u);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([I],{type:"text/html"}),"text/plain":new Blob([u],{type:"text/plain"})})]),r(!0),setTimeout(()=>r(!1),2e3)}catch{await navigator.clipboard.writeText(u),r(!0),setTimeout(()=>r(!1),2e3)}},[l]);return t("div",{className:M("RootAIChat__message",`RootAIChat__message--${e.role}`),children:[t("div",{className:"RootAIChat__message__avatar",children:m?t("img",{src:m,alt:i}):t(j,{size:20})}),t("div",{className:"RootAIChat__message__body",children:[t("div",{className:"RootAIChat__message__username",children:i}),t("div",{className:"RootAIChat__message__parts",children:(e.parts||[]).map((u,I)=>t(Dt,{part:u,toolApprovals:o.toolApprovals},I))}),t("button",{type:"button",className:M("RootAIChat__message__copy",h&&"RootAIChat__message__copy--copied"),title:h?"Copied!":"Copy message",onClick:g,children:h?t(q,{size:14}):t(nt,{size:14})})]})]})}function Dt(o){let e=o.part;return e.type==="text"?e.text?t("div",{className:"RootAIChat__textPart",children:t(Z,{code:e.text})}):null:e.type==="reasoning"?t(Lt,{text:e.text}):e.type==="file"?t($t,{part:e}):e.type==="source-url"?t("a",{className:"RootAIChat__sourcePart",href:e.url,target:"_blank",rel:"noopener noreferrer",children:e.title||e.url}):typeof e.type=="string"&&e.type.startsWith("tool-")?t(gt,{part:e,toolApprovals:o.toolApprovals}):e.type==="dynamic-tool"?t(gt,{part:e,toolApprovals:o.toolApprovals}):e.type==="step-start"?null:t("div",{className:"RootAIChat__unknownPart",children:t("pre",{children:JSON.stringify(e,null,2)})})}function Lt(o){let[e,a]=p(!1);return o.text?t("div",{className:M("RootAIChat__reasoning",e&&"RootAIChat__reasoning--open"),children:[t("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>a(!e),children:[t(X,{size:14,style:{transform:e?"rotate(0deg)":"rotate(-90deg)"}}),t("span",{children:"Thinking"})]}),e&&t("div",{className:"RootAIChat__reasoning__body",children:t(Z,{code:o.text})})]}):null}function $t(o){let e=o.part;return e.mediaType?.startsWith("image/")?t("div",{className:"RootAIChat__filePart",children:t("img",{src:e.url,alt:e.filename||"attachment"})}):t("a",{className:"RootAIChat__filePart RootAIChat__filePart--link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[t(Q,{size:14}),t("span",{children:e.filename||e.url})]})}function gt(o){let e=o.part,a=typeof e.type=="string"&&e.type.startsWith("tool-")?e.type.slice(5):e.toolName||"tool",i=e.state||"",m=Bt(e),h=o.toolApprovals,r=m?h?.approvals[m]:void 0,[l,g]=p(!!r);return k(()=>{r&&g(!0)},[r]),t("div",{className:"RootAIChat__tool",children:[t("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>g(!l),children:[t(X,{className:M("RootAIChat__tool__header__icon",l&&"RootAIChat__tool__header__icon--open"),size:14}),t(J,{color:"dark",variant:"filled",size:"xs",children:a}),t("span",{className:"RootAIChat__tool__title",children:Ot(a,e.input)}),t("span",{className:"RootAIChat__tool__state",children:r?Ht(r.status):Ft(i)})]}),l&&t("div",{className:"RootAIChat__tool__body",children:[r&&h&&t(Ut,{approval:r,onApprove:()=>h.onApprove(r.toolCallId),onReject:()=>h.onReject(r.toolCallId)}),e.output?.receipt&&t(Wt,{output:e.output}),e.input&&t("details",{children:[t("summary",{children:[t(Y,{size:14,className:"RootAIChat__tool__json__icon"}),t("span",{children:"Input"})]}),t("pre",{children:JSON.stringify(e.input,null,2)})]}),e.output&&t("details",{children:[t("summary",{children:[t(Y,{size:14,className:"RootAIChat__tool__json__icon"}),t("span",{children:"Output"})]}),t("pre",{children:JSON.stringify(e.output,null,2)})]}),e.errorText&&t("div",{className:"RootAIChat__tool__error",children:e.errorText})]})]})}function Bt(o){return o.toolCallId||o.id||""}function Ot(o,e){switch(o){case"collections_list":return"List collections";case"docs_list":return`List ${e?.collectionId||"documents"}`;case"docs_search":return`Search docs${e?.query?` for "${e.query}"`:""}`;case"doc_get":return`Read ${e?.docId||"document"}`;case"doc_getVersion":return`Read ${e?.docId||"document"} version`;case"doc_set":return`Replace ${e?.docId||"draft fields"}`;case"doc_create":return`Create ${e?.docId||"draft document"}`;case"doc_updateField":return`Update ${e?.path||"field"}`;case"doc_edit":return`Edit ${e?.docId||"document"}`;case"doc_duplicate":return`Duplicate ${e?.fromDocId||"document"}`;case"doc_listVersions":return`List versions for ${e?.docId||"document"}`;case"doc_translateField":return"Translate field text";case"schema_get":return`Read ${e?.collectionId||"collection"} schema`;default:return o}}function Ut(o){let e=o.approval.preview,a=e.before!==void 0&&e.after!==void 0;return t("div",{className:"RootAIChat__approval",children:[t("div",{className:"RootAIChat__approval__header",children:[t("div",{children:[t("div",{className:"RootAIChat__approval__title",children:e.title}),t("div",{className:"RootAIChat__approval__summary",children:e.summary})]}),t(J,{className:"RootAIChat__approval__status",variant:"light",color:"gray",children:o.approval.status==="executing"?"Applying":"Review"})]}),e.details.length>0&&t("div",{className:"RootAIChat__approval__details",children:e.details.map(i=>t("div",{children:[t("span",{children:i.label}),t("strong",{children:i.value})]},`${i.label}:${i.value}`))}),a&&t(lt,{className:"RootAIChat__approval__diff",oldCode:K(e.before),newCode:K(e.after)}),t("div",{className:"RootAIChat__approval__actions",children:[t(S,{variant:"default",color:"dark",size:"xs",type:"button",className:"RootAIChat__approval__button",disabled:o.approval.status==="executing",onClick:o.onReject,children:"Reject"}),t(S,{variant:"filled",color:"green",size:"xs",type:"button",className:"RootAIChat__approval__button RootAIChat__approval__button--primary",disabled:o.approval.status==="executing",onClick:o.onApprove,children:"Approve draft edit"})]})]})}function Wt(o){let e=o.output.receipt;return t("div",{className:"RootAIChat__receipt",children:[t("div",{className:"RootAIChat__receipt__title",children:[t(q,{size:14}),t("span",{children:e.title})]}),t("div",{className:"RootAIChat__receipt__summary",children:e.summary}),e.details?.length>0&&t("div",{className:"RootAIChat__receipt__details",children:e.details.map(a=>t("div",{children:[t("span",{children:a.label}),t("strong",{children:a.value})]},`${a.label}:${a.value}`))}),e.adminUrl&&t(S,{component:"a",className:"RootAIChat__receipt__link",variant:"default",size:"xs",compact:!0,href:e.adminUrl,children:"Open document"})]})}function Ht(o){return o==="executing"?"applying\u2026":"waiting for approval"}function Ft(o){switch(o){case"input-streaming":return"preparing\u2026";case"input-available":return"running\u2026";case"output-available":return"done";case"output-error":return"error";default:return o}}function Vt(o){let[e,a]=p(""),[i,m]=p([]),[h,r]=p(!1),l=N(null),g=N(null);k(()=>{window.requestAnimationFrame(()=>{let s=g.current;s&&(s.style.height="auto",s.style.height=`${Math.min(s.scrollHeight,240)}px`)})},[e,i]);let I=()=>{o.disabled||o.isStreaming||!e&&i.length===0||(o.onSend(e,i),a(""),m([]),l.current&&(l.current.value=""))},P=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),I())},y=async s=>{r(!0);try{let f=s.type||Yt(s.name),x=await qt(s,f),v=await pt(s,{disableGci:!0});m(w=>[...w,{url:v.src,filename:v.filename||s.name,mediaType:f,textContent:x?.text,textTruncated:x?.truncated,width:v.width,height:v.height}])}catch(f){console.error("upload failed",f)}finally{r(!1),l.current&&(l.current.value="")}},D=s=>{let f=s.target;Array.from(f.files||[]).forEach(y)};return t("div",{className:"RootAIChat__composer",children:[i.length>0&&t("div",{className:"RootAIChat__composer__attachments",children:i.map((s,f)=>t("div",{className:"RootAIChat__composer__attachment",children:[s.mediaType.startsWith("image/")?t("img",{src:s.url,alt:s.filename}):t("span",{className:"RootAIChat__composer__attachment__name",children:s.filename}),t("button",{type:"button",className:"RootAIChat__composer__attachment__remove",onClick:()=>m(x=>x.filter((v,w)=>w!==f)),children:t(B,{size:12})})]},f))}),t("div",{className:"RootAIChat__composer__row",children:[t(O,{label:o.canAttach?"Attach file":"Model doesn't support attachments",className:"RootAIChat__composer__attachTooltip",children:t(E,{component:"label",radius:"xl",className:M("RootAIChat__composer__attach",!o.canAttach&&"RootAIChat__composer__attach--disabled"),disabled:!o.canAttach,children:[h?t(V,{size:"xs"}):t(Q,{size:18}),t("input",{ref:l,type:"file",style:{display:"none"},onChange:D})]})}),t("textarea",{ref:g,className:"RootAIChat__composer__textarea",placeholder:o.disabled?"Select a model\u2026":"Ask anything\u2026",value:e,rows:1,autofocus:!0,disabled:o.disabled,onKeyDown:P,onChange:s=>a(s.target.value),onPaste:s=>{let f=s.clipboardData?.items||[];for(let x of f)if(x.kind==="file"){let v=x.getAsFile();v&&o.canAttach&&y(v)}}}),o.isStreaming?t(E,{className:"RootAIChat__composer__button RootAIChat__composer__stopButton",radius:"xl",color:"dark",variant:"filled",onClick:o.onStop,title:"Stop",children:t(B,{size:18})}):t(E,{className:"RootAIChat__composer__button RootAIChat__composer__submitButton",radius:"xl",color:"dark",variant:"filled",disabled:o.disabled||h||!e&&i.length===0,onClick:I,title:"Send",children:t(rt,{size:18})})]}),o.controls]})}var xt=1e5;function Jt(o){let e=o.filter(Ct),a=o.filter(i=>!Ct(i)).map(Kt);return{files:e,text:a.length?`Attached files:
5
+ `),[e.parts]),g=T(async()=>{let u=l();if(!u)return;let I=mt.parse(u);try{await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([I],{type:"text/html"}),"text/plain":new Blob([u],{type:"text/plain"})})]),r(!0),setTimeout(()=>r(!1),2e3)}catch{await navigator.clipboard.writeText(u),r(!0),setTimeout(()=>r(!1),2e3)}},[l]);return t("div",{className:M("RootAIChat__message",`RootAIChat__message--${e.role}`),children:[t("div",{className:"RootAIChat__message__avatar",children:m?t("img",{src:m,alt:i}):t(j,{size:20})}),t("div",{className:"RootAIChat__message__body",children:[t("div",{className:"RootAIChat__message__username",children:i}),t("div",{className:"RootAIChat__message__parts",children:(e.parts||[]).map((u,I)=>t(Dt,{part:u,toolApprovals:o.toolApprovals},I))}),t("button",{type:"button",className:M("RootAIChat__message__copy",h&&"RootAIChat__message__copy--copied"),title:h?"Copied!":"Copy message",onClick:g,children:h?t(q,{size:14}):t(it,{size:14})})]})]})}function Dt(o){let e=o.part;return e.type==="text"?e.text?t("div",{className:"RootAIChat__textPart",children:t(Z,{code:e.text})}):null:e.type==="reasoning"?t(Lt,{text:e.text}):e.type==="file"?t($t,{part:e}):e.type==="source-url"?t("a",{className:"RootAIChat__sourcePart",href:e.url,target:"_blank",rel:"noopener noreferrer",children:e.title||e.url}):typeof e.type=="string"&&e.type.startsWith("tool-")?t(gt,{part:e,toolApprovals:o.toolApprovals}):e.type==="dynamic-tool"?t(gt,{part:e,toolApprovals:o.toolApprovals}):e.type==="step-start"?null:t("div",{className:"RootAIChat__unknownPart",children:t("pre",{children:JSON.stringify(e,null,2)})})}function Lt(o){let[e,a]=p(!1);return o.text?t("div",{className:M("RootAIChat__reasoning",e&&"RootAIChat__reasoning--open"),children:[t("button",{type:"button",className:"RootAIChat__reasoning__toggle",onClick:()=>a(!e),children:[t(X,{size:14,style:{transform:e?"rotate(0deg)":"rotate(-90deg)"}}),t("span",{children:"Thinking"})]}),e&&t("div",{className:"RootAIChat__reasoning__body",children:t(Z,{code:o.text})})]}):null}function $t(o){let e=o.part;return e.mediaType?.startsWith("image/")?t("div",{className:"RootAIChat__filePart",children:t("img",{src:e.url,alt:e.filename||"attachment"})}):t("a",{className:"RootAIChat__filePart RootAIChat__filePart--link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[t(Q,{size:14}),t("span",{children:e.filename||e.url})]})}function gt(o){let e=o.part,a=typeof e.type=="string"&&e.type.startsWith("tool-")?e.type.slice(5):e.toolName||"tool",i=e.state||"",m=Bt(e),h=o.toolApprovals,r=m?h?.approvals[m]:void 0,[l,g]=p(!!r);return k(()=>{r&&g(!0)},[r]),t("div",{className:"RootAIChat__tool",children:[t("button",{type:"button",className:"RootAIChat__tool__header",onClick:()=>g(!l),children:[t(X,{className:M("RootAIChat__tool__header__icon",l&&"RootAIChat__tool__header__icon--open"),size:14}),t(J,{color:"dark",variant:"filled",size:"xs",children:a}),t("span",{className:"RootAIChat__tool__title",children:Ot(a,e.input)}),t("span",{className:"RootAIChat__tool__state",children:r?Ht(r.status):Ft(i)})]}),l&&t("div",{className:"RootAIChat__tool__body",children:[r&&h&&t(Ut,{approval:r,onApprove:()=>h.onApprove(r.toolCallId),onReject:()=>h.onReject(r.toolCallId)}),e.output?.receipt&&t(Wt,{output:e.output}),e.input&&t("details",{children:[t("summary",{children:[t(Y,{size:14,className:"RootAIChat__tool__json__icon"}),t("span",{children:"Input"})]}),t("pre",{children:JSON.stringify(e.input,null,2)})]}),e.output&&t("details",{children:[t("summary",{children:[t(Y,{size:14,className:"RootAIChat__tool__json__icon"}),t("span",{children:"Output"})]}),t("pre",{children:JSON.stringify(e.output,null,2)})]}),e.errorText&&t("div",{className:"RootAIChat__tool__error",children:e.errorText})]})]})}function Bt(o){return o.toolCallId||o.id||""}function Ot(o,e){switch(o){case"collections_list":return"List collections";case"docs_list":return`List ${e?.collectionId||"documents"}`;case"docs_search":return`Search docs${e?.query?` for "${e.query}"`:""}`;case"doc_get":return`Read ${e?.docId||"document"}`;case"doc_getVersion":return`Read ${e?.docId||"document"} version`;case"doc_set":return`Replace ${e?.docId||"draft fields"}`;case"doc_create":return`Create ${e?.docId||"draft document"}`;case"doc_updateField":return`Update ${e?.path||"field"}`;case"doc_edit":return`Edit ${e?.docId||"document"}`;case"doc_duplicate":return`Duplicate ${e?.fromDocId||"document"}`;case"doc_listVersions":return`List versions for ${e?.docId||"document"}`;case"doc_translateField":return"Translate field text";case"schema_get":return`Read ${e?.collectionId||"collection"} schema`;default:return o}}function Ut(o){let e=o.approval.preview,a=e.before!==void 0&&e.after!==void 0;return t("div",{className:"RootAIChat__approval",children:[t("div",{className:"RootAIChat__approval__header",children:[t("div",{children:[t("div",{className:"RootAIChat__approval__title",children:e.title}),t("div",{className:"RootAIChat__approval__summary",children:e.summary})]}),t(J,{className:"RootAIChat__approval__status",variant:"light",color:"gray",children:o.approval.status==="executing"?"Applying":"Review"})]}),e.details.length>0&&t("div",{className:"RootAIChat__approval__details",children:e.details.map(i=>t("div",{children:[t("span",{children:i.label}),t("strong",{children:i.value})]},`${i.label}:${i.value}`))}),a&&t(dt,{className:"RootAIChat__approval__diff",oldCode:K(e.before),newCode:K(e.after)}),t("div",{className:"RootAIChat__approval__actions",children:[t(S,{variant:"default",color:"dark",size:"xs",type:"button",className:"RootAIChat__approval__button",disabled:o.approval.status==="executing",onClick:o.onReject,children:"Reject"}),t(S,{variant:"filled",color:"green",size:"xs",type:"button",className:"RootAIChat__approval__button RootAIChat__approval__button--primary",disabled:o.approval.status==="executing",onClick:o.onApprove,children:"Approve draft edit"})]})]})}function Wt(o){let e=o.output.receipt;return t("div",{className:"RootAIChat__receipt",children:[t("div",{className:"RootAIChat__receipt__title",children:[t(q,{size:14}),t("span",{children:e.title})]}),t("div",{className:"RootAIChat__receipt__summary",children:e.summary}),e.details?.length>0&&t("div",{className:"RootAIChat__receipt__details",children:e.details.map(a=>t("div",{children:[t("span",{children:a.label}),t("strong",{children:a.value})]},`${a.label}:${a.value}`))}),e.adminUrl&&t(S,{component:"a",className:"RootAIChat__receipt__link",variant:"default",size:"xs",compact:!0,href:e.adminUrl,children:"Open document"})]})}function Ht(o){return o==="executing"?"applying\u2026":"waiting for approval"}function Ft(o){switch(o){case"input-streaming":return"preparing\u2026";case"input-available":return"running\u2026";case"output-available":return"done";case"output-error":return"error";default:return o}}function Vt(o){let[e,a]=p(""),[i,m]=p([]),[h,r]=p(!1),l=N(null),g=N(null);k(()=>{window.requestAnimationFrame(()=>{let s=g.current;s&&(s.style.height="auto",s.style.height=`${Math.min(s.scrollHeight,240)}px`)})},[e,i]);let I=()=>{o.disabled||o.isStreaming||!e&&i.length===0||(o.onSend(e,i),a(""),m([]),l.current&&(l.current.value=""))},P=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),I())},y=async s=>{r(!0);try{let f=s.type||Yt(s.name),x=await qt(s,f),v=await nt(s,{disableGci:!0});m(w=>[...w,{url:v.src,filename:v.filename||s.name,mediaType:f,textContent:x?.text,textTruncated:x?.truncated,width:v.width,height:v.height}])}catch(f){console.error("upload failed",f)}finally{r(!1),l.current&&(l.current.value="")}},D=s=>{let f=s.target;Array.from(f.files||[]).forEach(y)};return t("div",{className:"RootAIChat__composer",children:[i.length>0&&t("div",{className:"RootAIChat__composer__attachments",children:i.map((s,f)=>t("div",{className:"RootAIChat__composer__attachment",children:[s.mediaType.startsWith("image/")?t("img",{src:s.url,alt:s.filename}):t("span",{className:"RootAIChat__composer__attachment__name",children:s.filename}),t("button",{type:"button",className:"RootAIChat__composer__attachment__remove",onClick:()=>m(x=>x.filter((v,w)=>w!==f)),children:t(B,{size:12})})]},f))}),t("div",{className:"RootAIChat__composer__row",children:[t(O,{label:o.canAttach?"Attach file":"Model doesn't support attachments",className:"RootAIChat__composer__attachTooltip",children:t(E,{component:"label",radius:"xl",className:M("RootAIChat__composer__attach",!o.canAttach&&"RootAIChat__composer__attach--disabled"),disabled:!o.canAttach,children:[h?t(V,{size:"xs"}):t(Q,{size:18}),t("input",{ref:l,type:"file",style:{display:"none"},onChange:D})]})}),t("textarea",{ref:g,className:"RootAIChat__composer__textarea",placeholder:o.disabled?"Select a model\u2026":"Ask anything\u2026",value:e,rows:1,autofocus:!0,disabled:o.disabled,onKeyDown:P,onChange:s=>a(s.target.value),onPaste:s=>{let f=s.clipboardData?.items||[];for(let x of f)if(x.kind==="file"){let v=x.getAsFile();v&&o.canAttach&&y(v)}}}),o.isStreaming?t(E,{className:"RootAIChat__composer__button RootAIChat__composer__stopButton",radius:"xl",color:"dark",variant:"filled",onClick:o.onStop,title:"Stop",children:t(B,{size:18})}):t(E,{className:"RootAIChat__composer__button RootAIChat__composer__submitButton",radius:"xl",color:"dark",variant:"filled",disabled:o.disabled||h||!e&&i.length===0,onClick:I,title:"Send",children:t(st,{size:18})})]}),o.controls]})}var xt=1e5;function Jt(o){let e=o.filter(Ct),a=o.filter(i=>!Ct(i)).map(Kt);return{files:e,text:a.length?`Attached files:
6
6
 
7
7
  ${a.join(`
8
8
 
@@ -1 +1 @@
1
- import{L as m,a,c as f,j as O}from"./chunk-4CUWZQXT.js";O();var G=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],P=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function R(){let o=window.__ROOT_CTX.rootConfig.projectId,t=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[e,n]=a(t),[i,w]=a(0),[s,h]=m({key:`root-cms::${o}::gapi-user-consent`,defaultValue:{}});async function C(){await Promise.all([E(),b()]),n(!1)}f(()=>{t&&C()},[]);function _(r){return new Promise(v=>{let g=window.__ROOT_CTX.gapi.clientId,c=Array.from(new Set([...G,...r?.scopes||[]])),u=google.accounts.oauth2.initTokenClient({client_id:g,scope:c.join(" "),callback:async I=>{let y=l()+parseInt(I.expires_in);w(y),h({at:l(),clientId:g,scopes:c}),v()}});s&&k(s,c)?(console.log("requesting token without prompt"),u.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),u.requestAccessToken({prompt:"consent"}))})}function S(){return l()<i}function T(r){return s?.scopes?.includes(r)||!1}return{enabled:t,loading:e,isLoggedIn:S,login:_,hasScope:T}}function k(o,t){if(!o||!o.at)return!1;let e=window.__ROOT_CTX.gapi?.clientId;if(o.clientId!==e)return!1;let n=o.scopes||[];return t.every(i=>n.includes(i))}function l(){return Math.floor(new Date().getTime()/1e3)}var p=null;async function E(){return p||(p=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://apis.google.com/js/api.js",e.onload=()=>{gapi.load("client",async()=>{try{await gapi.client.init({}),await Promise.all(P.map(n=>gapi.client.load(n))),console.log("gapi loaded"),o()}catch(n){console.error("Error initializing gapi:",n),t(n)}})},e.onerror=()=>{console.error("gapi script failed to load"),t(new Error("gapi script failed to load"))},document.head.appendChild(e)})),p}var d=null;async function b(){return d||(d=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://accounts.google.com/gsi/client",e.onload=()=>{o()},e.onerror=()=>{console.error("gis script failed to load"),t(new Error("gis script failed to load"))},document.head.appendChild(e)})),d}export{R as a};
1
+ import{L as m,a,c as f,j as O}from"./chunk-LROR6N3B.js";O();var G=["https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/spreadsheets"],P=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest","https://sheets.googleapis.com/$discovery/rest?version=v4"];function R(){let o=window.__ROOT_CTX.rootConfig.projectId,t=!!(window.__ROOT_CTX.gapi?.apiKey&&window.__ROOT_CTX.gapi?.clientId),[e,n]=a(t),[i,w]=a(0),[s,h]=m({key:`root-cms::${o}::gapi-user-consent`,defaultValue:{}});async function C(){await Promise.all([E(),b()]),n(!1)}f(()=>{t&&C()},[]);function _(r){return new Promise(v=>{let g=window.__ROOT_CTX.gapi.clientId,c=Array.from(new Set([...G,...r?.scopes||[]])),u=google.accounts.oauth2.initTokenClient({client_id:g,scope:c.join(" "),callback:async I=>{let y=l()+parseInt(I.expires_in);w(y),h({at:l(),clientId:g,scopes:c}),v()}});s&&k(s,c)?(console.log("requesting token without prompt"),u.requestAccessToken({prompt:""})):(console.log("requesting token with prompt"),u.requestAccessToken({prompt:"consent"}))})}function S(){return l()<i}function T(r){return s?.scopes?.includes(r)||!1}return{enabled:t,loading:e,isLoggedIn:S,login:_,hasScope:T}}function k(o,t){if(!o||!o.at)return!1;let e=window.__ROOT_CTX.gapi?.clientId;if(o.clientId!==e)return!1;let n=o.scopes||[];return t.every(i=>n.includes(i))}function l(){return Math.floor(new Date().getTime()/1e3)}var p=null;async function E(){return p||(p=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://apis.google.com/js/api.js",e.onload=()=>{gapi.load("client",async()=>{try{await gapi.client.init({}),await Promise.all(P.map(n=>gapi.client.load(n))),console.log("gapi loaded"),o()}catch(n){console.error("Error initializing gapi:",n),t(n)}})},e.onerror=()=>{console.error("gapi script failed to load"),t(new Error("gapi script failed to load"))},document.head.appendChild(e)})),p}var d=null;async function b(){return d||(d=new Promise((o,t)=>{let e=document.createElement("script");e.src="https://accounts.google.com/gsi/client",e.onload=()=>{o()},e.onerror=()=>{console.error("gis script failed to load"),t(new Error("gis script failed to load"))},document.head.appendChild(e)})),d}export{R as a};
@@ -1,4 +1,4 @@
1
- import{f as k}from"./chunk-5MV6XVGA.js";import{f as b}from"./chunk-RPOP6MVJ.js";import{Ga as a,a as M,c as y,e as z,g as P,j as O}from"./chunk-4CUWZQXT.js";var L=class{diff(e,o,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);let l=this.castInput(e,n),c=this.castInput(o,n),h=this.removeEmpty(this.tokenize(l,n)),r=this.removeEmpty(this.tokenize(c,n));return this.diffWithOptionsObj(h,r,n,i)}diffWithOptionsObj(e,o,n,i){var l;let c=t=>{if(t=this.postProcess(t,n),i){setTimeout(function(){i(t)},0);return}else return t},h=o.length,r=e.length,s=1,f=h+r;n.maxEditLength!=null&&(f=Math.min(f,n.maxEditLength));let m=(l=n.timeout)!==null&&l!==void 0?l:1/0,g=Date.now()+m,d=[{oldPos:-1,lastComponent:void 0}],u=this.extractCommon(d[0],o,e,0,n);if(d[0].oldPos+1>=r&&u+1>=h)return c(this.buildValues(d[0].lastComponent,o,e));let x=-1/0,p=1/0,_=()=>{for(let t=Math.max(x,-s);t<=Math.min(p,s);t+=2){let C,w=d[t-1],D=d[t+1];w&&(d[t-1]=void 0);let J=!1;if(D){let I=D.oldPos-t;J=D&&0<=I&&I<h}let T=w&&w.oldPos+1<r;if(!J&&!T){d[t]=void 0;continue}if(!T||J&&w.oldPos<D.oldPos?C=this.addToPath(D,!0,!1,0,n):C=this.addToPath(w,!1,!0,1,n),u=this.extractCommon(C,o,e,t,n),C.oldPos+1>=r&&u+1>=h)return c(this.buildValues(C.lastComponent,o,e))||!0;d[t]=C,C.oldPos+1>=r&&(p=Math.min(p,t-1)),u+1>=h&&(x=Math.max(x,t+1))}s++};if(i)(function t(){setTimeout(function(){if(s>f||Date.now()>g)return i(void 0);_()||t()},0)})();else for(;s<=f&&Date.now()<=g;){let t=_();if(t)return t}}addToPath(e,o,n,i,l){let c=e.lastComponent;return c&&!l.oneChangePerToken&&c.added===o&&c.removed===n?{oldPos:e.oldPos+i,lastComponent:{count:c.count+1,added:o,removed:n,previousComponent:c.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:o,removed:n,previousComponent:c}}}extractCommon(e,o,n,i,l){let c=o.length,h=n.length,r=e.oldPos,s=r-i,f=0;for(;s+1<c&&r+1<h&&this.equals(n[r+1],o[s+1],l);)s++,r++,f++,l.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return f&&!l.oneChangePerToken&&(e.lastComponent={count:f,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=r,s}equals(e,o,n){return n.comparator?n.comparator(e,o):e===o||!!n.ignoreCase&&e.toLowerCase()===o.toLowerCase()}removeEmpty(e){let o=[];for(let n=0;n<e.length;n++)e[n]&&o.push(e[n]);return o}castInput(e,o){return e}tokenize(e,o){return Array.from(e)}join(e){return e.join("")}postProcess(e,o){return e}get useLongestToken(){return!1}buildValues(e,o,n){let i=[],l;for(;e;)i.push(e),l=e.previousComponent,delete e.previousComponent,e=l;i.reverse();let c=i.length,h=0,r=0,s=0;for(;h<c;h++){let f=i[h];if(f.removed)f.value=this.join(n.slice(s,s+f.count)),s+=f.count;else{if(!f.added&&this.useLongestToken){let m=o.slice(r,r+f.count);m=m.map(function(g,d){let u=n[s+d];return u.length>g.length?u:g}),f.value=this.join(m)}else f.value=this.join(o.slice(r,r+f.count));r+=f.count,f.added||(s+=f.count)}}return i}};var N=class extends L{constructor(){super(...arguments),this.tokenize=A}equals(e,o,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
1
+ import{f as k}from"./chunk-5MV6XVGA.js";import{f as b}from"./chunk-YLSRRNSE.js";import{Ga as a,a as M,c as y,e as z,g as P,j as O}from"./chunk-LROR6N3B.js";var L=class{diff(e,o,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);let l=this.castInput(e,n),c=this.castInput(o,n),h=this.removeEmpty(this.tokenize(l,n)),r=this.removeEmpty(this.tokenize(c,n));return this.diffWithOptionsObj(h,r,n,i)}diffWithOptionsObj(e,o,n,i){var l;let c=t=>{if(t=this.postProcess(t,n),i){setTimeout(function(){i(t)},0);return}else return t},h=o.length,r=e.length,s=1,f=h+r;n.maxEditLength!=null&&(f=Math.min(f,n.maxEditLength));let m=(l=n.timeout)!==null&&l!==void 0?l:1/0,g=Date.now()+m,d=[{oldPos:-1,lastComponent:void 0}],u=this.extractCommon(d[0],o,e,0,n);if(d[0].oldPos+1>=r&&u+1>=h)return c(this.buildValues(d[0].lastComponent,o,e));let x=-1/0,p=1/0,_=()=>{for(let t=Math.max(x,-s);t<=Math.min(p,s);t+=2){let C,w=d[t-1],D=d[t+1];w&&(d[t-1]=void 0);let J=!1;if(D){let I=D.oldPos-t;J=D&&0<=I&&I<h}let T=w&&w.oldPos+1<r;if(!J&&!T){d[t]=void 0;continue}if(!T||J&&w.oldPos<D.oldPos?C=this.addToPath(D,!0,!1,0,n):C=this.addToPath(w,!1,!0,1,n),u=this.extractCommon(C,o,e,t,n),C.oldPos+1>=r&&u+1>=h)return c(this.buildValues(C.lastComponent,o,e))||!0;d[t]=C,C.oldPos+1>=r&&(p=Math.min(p,t-1)),u+1>=h&&(x=Math.max(x,t+1))}s++};if(i)(function t(){setTimeout(function(){if(s>f||Date.now()>g)return i(void 0);_()||t()},0)})();else for(;s<=f&&Date.now()<=g;){let t=_();if(t)return t}}addToPath(e,o,n,i,l){let c=e.lastComponent;return c&&!l.oneChangePerToken&&c.added===o&&c.removed===n?{oldPos:e.oldPos+i,lastComponent:{count:c.count+1,added:o,removed:n,previousComponent:c.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:o,removed:n,previousComponent:c}}}extractCommon(e,o,n,i,l){let c=o.length,h=n.length,r=e.oldPos,s=r-i,f=0;for(;s+1<c&&r+1<h&&this.equals(n[r+1],o[s+1],l);)s++,r++,f++,l.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return f&&!l.oneChangePerToken&&(e.lastComponent={count:f,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=r,s}equals(e,o,n){return n.comparator?n.comparator(e,o):e===o||!!n.ignoreCase&&e.toLowerCase()===o.toLowerCase()}removeEmpty(e){let o=[];for(let n=0;n<e.length;n++)e[n]&&o.push(e[n]);return o}castInput(e,o){return e}tokenize(e,o){return Array.from(e)}join(e){return e.join("")}postProcess(e,o){return e}get useLongestToken(){return!1}buildValues(e,o,n){let i=[],l;for(;e;)i.push(e),l=e.previousComponent,delete e.previousComponent,e=l;i.reverse();let c=i.length,h=0,r=0,s=0;for(;h<c;h++){let f=i[h];if(f.removed)f.value=this.join(n.slice(s,s+f.count)),s+=f.count;else{if(!f.added&&this.useLongestToken){let m=o.slice(r,r+f.count);m=m.map(function(g,d){let u=n[s+d];return u.length>g.length?u:g}),f.value=this.join(m)}else f.value=this.join(o.slice(r,r+f.count));r+=f.count,f.added||(s+=f.count)}}return i}};var N=class extends L{constructor(){super(...arguments),this.tokenize=A}equals(e,o,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
2
2
  `))&&(e=e.trim()),(!n.newlineIsToken||!o.includes(`
3
3
  `))&&(o=o.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
4
4
  `)&&(e=e.slice(0,-1)),o.endsWith(`
@@ -0,0 +1,5 @@
1
+ import{f as c}from"./chunk-KRNQ6L35.js";import{a as p,b,c as g,g as E,i as C,n as x,p as _,q as A,s as w,t as h,v as u,w as D}from"./chunk-VD6G5NV4.js";var q="tasks",H=20;function K(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId;return g(t,"Projects",e)}function T(t){let e=window.firebase.db,n=window.__ROOT_CTX.rootConfig.projectId;return g(e,"Projects",n,"Tasks",t)}function N(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId;return g(t,"Projects",e,"Counters",q)}function v(){let t=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId;return b(t,"Projects",e,"Tasks")}function O(t){let e=window.firebase.db,n=window.__ROOT_CTX.rootConfig.projectId;return b(e,"Projects",n,"Tasks",t,"Comments")}function P(t,e){let n=window.firebase.db,s=window.__ROOT_CTX.rootConfig.projectId;return g(n,"Projects",s,"Tasks",t,"Comments",e)}function R(t){let e=window.firebase.db,n=window.__ROOT_CTX.rootConfig.projectId;return b(e,"Projects",n,"Tasks",t,"Events")}function G(t){return g(R(t))}async function J(){let t=await x(K());return t.exists()&&(t.data()||{}).settings?.defaultAssignee||null}async function st(t){if(!t.title)throw new Error("missing task title");let e=window.firebase.db,n=t.assignee??await J(),s=t.priority||"normal",a="new",i=L(t.targetLaunchDate),d=await h(e,async r=>{let o=N(),l=(await r.get(o)).data()||{},f=typeof l.lastTaskId=="number"?l.lastTaskId:0,k=Math.floor(f)+1;for(let B=0;B<H;B++){let j=T(String(k));if(!(await r.get(j)).exists())return r.set(o,{lastTaskId:k,updatedAt:u()},{merge:!0}),r.set(j,{id:String(k),title:t.title,description:t.description||"",assignee:n??null,priority:s,status:a,targetLaunchDate:i,createdAt:u(),createdBy:window.firebase.user.email||"",updatedAt:u(),updatedBy:window.firebase.user.email||""}),String(k);k+=1}throw new Error("unable to allocate a task id")});return c("tasks.create",{metadata:{taskId:d}}),d}function L(t){return t instanceof Date?p.fromDate(t):t??null}function Q(t){let e=W(t);return!["closed","complete","completed","done","resolved"].includes(e)}function W(t){let e=(t||"new").trim().toLowerCase();return e==="open"?"new":e==="blocked"?"in-progress":["done","complete","completed","resolved"].includes(e)?"closed":e}function Y(t){return t.sort((e,n)=>{let s=e.createdAt?.toMillis?.()||0;return(n.createdAt?.toMillis?.()||0)-s})}function M(t){return Y(t.docs.map(e=>({...e.data(),id:e.id})))}function at(t,e){return w(v(),n=>{t(M(n))},e)}function it(t,e){return w(v(),n=>{t(M(n).filter(s=>Q(s.status)))},e)}function rt(t,e,n){return w(T(t),s=>{if(!s.exists()){e(null);return}e({...s.data(),id:s.id})},n)}function ot(t,e,n){return w(E(O(t),C("createdAt","asc")),s=>{e(s.docs.map(a=>({...a.data(),id:a.id})))},n)}function dt(t,e,n){return w(E(R(t),C("createdAt","asc")),s=>{e(s.docs.map(a=>({...a.data(),id:a.id})))},n)}async function ct(t,e){if(!t)throw new Error("missing task id");let n=e?.trim()||null;await y(t,"assignee",n)&&c("tasks.updateAssignee",{metadata:{taskId:t,assignee:n}})}async function ut(t,e){if(!t)throw new Error("missing task id");let n=e.trim();if(!n)throw new Error("missing title");await y(t,"title",n)&&c("tasks.updateTitle",{metadata:{taskId:t}})}async function mt(t,e){if(!t)throw new Error("missing task id");if(!e)throw new Error("missing status");let n=e.trim();await y(t,"status",n)&&c("tasks.updateStatus",{metadata:{taskId:t,status:e}})}async function lt(t,e){if(!t)throw new Error("missing task id");await y(t,"priority",e)&&c("tasks.updatePriority",{metadata:{taskId:t,priority:e}})}async function ft(t,e){if(!t)throw new Error("missing task id");let n=L(e);await y(t,"targetLaunchDate",n)&&c("tasks.updateTargetLaunchDate",{metadata:{taskId:t}})}async function pt(t,e){if(!t)throw new Error("missing task id");await A(T(t),{description:e,updatedAt:u(),updatedBy:window.firebase.user.email||""}),c("tasks.updateDescription",{metadata:{taskId:t}})}async function gt(t,e){if(!t)throw new Error("missing task id");if(!e?.src)throw new Error("missing attachment file");let n=window.firebase.db,s=T(t),a=window.firebase.user.email||"",i={...e,id:g(R(t)).id,attachedAt:p.now(),attachedBy:a};return await h(n,async d=>{let r=await d.get(s);if(!r.exists())throw new Error("task not found");let o=r.data(),m=S(o.attachments);d.update(s,{attachments:[...m,i],updatedAt:u(),updatedBy:a})}),c("tasks.attachment.add",{metadata:{taskId:t,attachmentId:i.id,filename:i.filename||i.src}}),i}async function wt(t,e){if(!t||!e)throw new Error("missing task or attachment id");let n=window.firebase.db,s=T(t),a=window.firebase.user.email||"",i;await h(n,async r=>{let o=await r.get(s);if(!o.exists())throw new Error("task not found");let m=o.data(),l=S(m.attachments);return i=l.find(f=>f.id===e),i?(r.update(s,{attachments:l.filter(f=>f.id!==e),updatedAt:u(),updatedBy:a}),!0):!1})&&c("tasks.attachment.remove",{metadata:{taskId:t,attachmentId:e,filename:i?.filename||i?.src||""}})}async function y(t,e,n){let s=window.firebase.db,a=T(t),i=G(t),d=window.firebase.user.email||"";return h(s,async r=>{let o=await r.get(a);if(!o.exists())throw new Error("task not found");let m=o.data(),l=U(m[e]),f=U(n);return Z(l,f)?!1:(r.update(a,{[e]:f,updatedAt:u(),updatedBy:d}),r.set(i,{id:i.id,taskId:t,type:"metadata",field:e,oldValue:l,newValue:f,createdAt:u(),createdBy:d}),!0)})}function U(t){return t instanceof p||typeof t=="string"?t:null}function Z(t,e){return t instanceof p&&e instanceof p?t.toMillis()===e.toMillis():t===e}function S(t){return Array.isArray(t)?t.filter(e=>!!(e?.id&&e?.src)):[]}async function Tt(t,e,n,s){if(!t)throw new Error("missing task id");if(!e)throw new Error("missing comment content");let a=z(e),i=typeof e=="string"?e:F(e);if(!i.trim()&&!a)throw new Error("missing comment content");let d=g(O(t)),r=d.id,o=(s?.mentions||[]).map(m=>m.toLowerCase());return await _(d,{id:r,taskId:t,parentId:n||null,content:i,body:a,mentions:o,createdAt:u(),createdBy:window.firebase.user.email||"",history:[]}),c("tasks.comment.add",{metadata:{taskId:t,commentId:r,parentId:n||null,mentions:o}}),r}async function kt(t,e,n,s){if(!t||!e)throw new Error("missing task or comment id");if(!n)throw new Error("missing comment content");let a=z(n),i=typeof n=="string"?n:F(n);if(!i.trim()&&!a)throw new Error("missing comment content");let d=P(t,e),r=await x(d);if(!r.exists())throw new Error("comment not found");let o=r.data(),m=(s?.mentions||[]).map(l=>l.toLowerCase());await A(d,{content:i,body:a,mentions:m,updatedAt:u(),updatedBy:window.firebase.user.email||"",isDeleted:!1,history:D({action:"edit",content:o.content,body:o.body||null,changedAt:p.now(),changedBy:window.firebase.user.email||""})}),c("tasks.comment.edit",{metadata:{taskId:t,commentId:e,mentions:m}})}function z(t){return typeof t=="string"?null:t}function F(t){return t?.blocks?.length?t.blocks.map(e=>$(e)).filter(Boolean).join(`
2
+ `).trim():""}function $(t){switch(t.type){case"paragraph":case"heading":case"quote":return V(t.data?.text||"");case"orderedList":case"unorderedList":return(t.data?.items||[]).map(e=>X(e)).filter(Boolean).join(`
3
+ `);case"image":return t.data?.file?.alt||t.data?.file?.url||"";default:return""}}function X(t){let e=[V(t.content||"")];return t.items?.length&&e.push(t.items.map(n=>X(n)).filter(Boolean).join(`
4
+ `)),e.filter(Boolean).join(`
5
+ `)}function V(t){return t.replace(/<[^>]+>/g,"")}async function ht(t,e){if(!t||!e)throw new Error("missing task or comment id");let n=P(t,e),s=await x(n);if(!s.exists())throw new Error("comment not found");let a=s.data();await A(n,{content:"",isDeleted:!0,deletedAt:u(),deletedBy:window.firebase.user.email||"",history:D({action:"delete",content:a.content,changedAt:p.now(),changedBy:window.firebase.user.email||""})}),c("tasks.comment.delete",{metadata:{taskId:t,commentId:e}})}export{st as a,Q as b,W as c,at as d,it as e,rt as f,ot as g,dt as h,ct as i,ut as j,mt as k,lt as l,ft as m,pt as n,gt as o,wt as p,Tt as q,kt as r,ht as s};
@@ -0,0 +1 @@
1
+ import{a as _t}from"./chunk-MZTOPPWQ.js";import{g as oe,h as Xe,i as ke,j as qe,k as Ke,l as Je,m as Qe,n as Ye,o as Ze,p as et,q as de,r as tt,s as Me,t as st,u as ce,y as _e,z as me}from"./chunk-TFB3VGWP.js";import{a as ct}from"./chunk-W5DOO6ID.js";import{a as dt}from"./chunk-NSOTG64N.js";import{b as M}from"./chunk-J5E457OI.js";import{a as b,b as je,c as Ge}from"./chunk-QHJOTXYB.js";import{b as He,d as ye}from"./chunk-KRNQ6L35.js";import{f as fe}from"./chunk-YLSRRNSE.js";import{$a as Fe,Ab as pe,Cc as it,Da as ie,Db as lt,Eb as he,Fa as Le,Fb as De,Ga as e,Pb as nt,Rc as O,Uc as rt,V as te,W as se,a as i,c as T,da as g,ea as L,g as Se,j as Ee,lb as ue,mc as ze,na as Pe,qa as k,ra as U,tb as Ne,ua as j,vb as ge,wb as ot,zb as at}from"./chunk-LROR6N3B.js";import{d as C}from"./chunk-KUCVLANF.js";import{g as Oe,h as re,k as D,l as G,m as Ce,n as H,o as Ve,p as We}from"./chunk-7SK47HHZ.js";Ee();Ee();function mt(t){let o=t.file||{},a=o.src||"",l=o.filename||a,r={"--asset-thumb-size":`${t.size}px`};if(a&&G(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("img",{src:Ie(o,t.size*2),alt:o.alt||"",loading:"lazy"})});if(a&&H(l))return e("div",{className:"AssetBrowser__thumb",style:r,children:e("video",{src:a,muted:!0,playsInline:!0,preload:"metadata"})});let _=D(l);return e("div",{className:"AssetBrowser__thumb",style:r,children:_&&_.length<=4?e("div",{className:"AssetBrowser__thumb__ext",children:_}):e(pe,{size:20,stroke:"1.5"})})}function Ie(t,o){let a=t?.src||"";return a.startsWith(Oe)&&o?`${a}=s${o}`:a}function ve(t){let o=t?.src||"";Ce(o)&&(o=o.split("=")[0]+"=s0"),navigator.clipboard.writeText(o).then(()=>{b({message:"Copied URL to clipboard.",autoClose:2e3})})}function we(t){let o=t?.src||"";if(o)if(Ce(o)){let a=document.createElement("a");a.href=We(o),t.filename&&(a.download=t.filename),document.body.appendChild(a),a.click(),document.body.removeChild(a)}else window.open(o,"_blank")}function ft(t){let[o,a]=i(t.asset),[l,r]=i(t.asset.file?.alt||""),[_,d]=i(!1),[x,v]=i(!1),[m,B]=i(null),[h,F]=i(null),n=o.file||{},f=n.filename||o.name,N=G(f),S=H(f),V=l!==(n.alt||""),W=n.altDisabled===!0;T(()=>{_e(o.id).then(c=>F(c)).catch(c=>{console.error("failed to fetch asset usage:",c),F([])})},[o.id]);async function z(c,w){let p=await me(c,{previousFile:w});p.failedDocIds.length>0?b({title:"Some docs failed to update",message:`Failed to update: ${p.failedDocIds.join(", ")}. Re-save the asset to retry.`,color:"red",autoClose:!1}):p.updatedDocIds.length>0&&b({message:`Updated ${p.updatedDocIds.length} doc(s) that use this asset.`,color:"green"})}async function X(){d(!0),await M(async()=>{let c={...n},w=await st(o,l);a(w),t.onChanged(w),await z(w,c)}),d(!1)}function R(){let c=document.createElement("input");c.type="file",c.onchange=()=>{let w=c.files?.[0];if(!w)return;let p=D(f),y=D(w.name);if(p&&y&&p!==y){B(w);return}E(w)},c.click(),c.remove()}async function E(c){B(null),d(!0),await M(async()=>{let w={...n},p=await re(c),y=await tt(o,p);a(y),r(y.file?.alt||""),t.onChanged(y),await z(y,w)}),d(!1)}async function $(c){d(!0),await M(async()=>{let w={...n},p=await ce(o,c);a(p),r(p.file?.alt||""),t.onChanged(p),await z(p,w)}),d(!1)}async function q(){d(!0),await M(async()=>{await de(o),b({message:`Deleted "${o.name}".`,color:"green"}),t.onDeleted()}),d(!1)}return e(U,{className:"AssetBrowser__detailsModal",opened:!0,onClose:t.onClose,title:o.name,size:720,overflow:"outside",centered:!0,children:e("div",{className:"AssetBrowser__details",children:[e("div",{className:"AssetBrowser__details__preview",children:N?e("img",{src:Ie(n,800),alt:n.alt||"",style:n.canvasBgColor==="dark"?{background:"#000"}:{}}):S?e("video",{src:n.src,controls:!0,muted:!0,preload:"metadata"}):e("div",{className:"AssetBrowser__details__preview__placeholder",children:[e(pe,{size:48,stroke:"1"}),e("div",{children:f})]})}),e(ie,{className:"AssetBrowser__details__table",verticalSpacing:"xs",fontSize:"xs",children:e("tbody",{children:[e("tr",{children:[e("td",{children:e("b",{children:"Filename"})}),e("td",{children:f})]}),!!(n.width&&n.height)&&e("tr",{children:[e("td",{children:e("b",{children:"Dimensions"})}),e("td",{children:[n.width,"x",n.height]})]}),o.createdAt&&e("tr",{children:[e("td",{children:e("b",{children:"Uploaded"})}),e("td",{children:[ye(o.createdAt),o.createdBy&&e(C,{children:[" by ",o.createdBy]})]})]}),o.modifiedAt&&e("tr",{children:[e("td",{children:e("b",{children:"Modified"})}),e("td",{children:[ye(o.modifiedAt),o.modifiedBy&&e(C,{children:[" by ",o.modifiedBy]})]})]}),e("tr",{children:[e("td",{children:e("b",{children:"URL"})}),e("td",{children:e("div",{className:"AssetBrowser__details__url",children:[e(j,{readOnly:!0,value:n.src||"",size:"xs",radius:"xs",onClick:c=>c.target.select(),styles:{root:{flex:1,minWidth:0}}}),e(Le,{label:"Copy URL",transition:"pop",children:e(se,{size:"sm",onClick:()=>ve(n),children:e(ue,{size:16})})})]})})]})]})}),(N||S)&&e("div",{className:"AssetBrowser__details__alt",children:[W?e("div",{className:"AssetBrowser__details__alt__disabledNote",children:"Alt text is disabled for this asset. Docs that use it hide the alt text input and render no alt text."}):e(C,{children:[e(Pe,{label:"Alt text",description:"Used as the default alt text when the asset is selected in a doc. Updating it syncs docs that use this asset.",autosize:!0,minRows:1,size:"xs",value:l,disabled:!t.canManage||_,onChange:c=>r(c.currentTarget.value)}),t.canManage&&V&&e(g,{size:"xs",color:"dark",mt:8,loading:_,onClick:()=>X(),children:"Save alt text"})]}),t.canManage&&e(L,{className:"AssetBrowser__details__alt__disableCheckbox",label:"Disable alt text (e.g. decorative images)",size:"xs",mt:8,checked:W,disabled:_,onChange:c=>$(c.currentTarget.checked)})]}),e("div",{className:"AssetBrowser__details__usage",children:[e("div",{className:"AssetBrowser__details__usage__title",children:"Used in"}),h===null?e(te,{color:"gray",size:"sm"}):h.length===0?e("div",{className:"AssetBrowser__details__usage__empty",children:"No docs use this asset."}):e("div",{className:"AssetBrowser__details__usage__list",children:h.map(c=>e("a",{className:"AssetBrowser__details__usage__doc",href:`/cms/content/${c.id}`,target:"_blank",rel:"noreferrer",children:[e("span",{children:c.id}),e(ot,{size:14})]},c.id))})]}),e("div",{className:"AssetBrowser__details__buttons",children:[e(g,{variant:"default",size:"xs",leftIcon:e(ge,{size:14}),onClick:()=>we(n),children:"Download"}),t.canManage&&e(C,{children:[e(g,{variant:"default",size:"xs",leftIcon:e(at,{size:14}),loading:_,onClick:()=>R(),children:"Replace file"}),e(g,{className:"AssetBrowser__details__buttons__delete",color:"red",variant:"filled",size:"xs",leftIcon:e(O,{size:14}),disabled:_,onClick:()=>v(!0),children:"Delete"})]})]}),m&&e("div",{className:"AssetBrowser__details__confirmReplace",children:[e("div",{children:["The new file has a different type (",e("b",{children:[".",D(f)]})," ","\u2192 ",e("b",{children:[".",D(m.name)]}),"). Replacing will change the asset's file extension and serving URL",Me(o.name,D(m.name))!==o.name&&e(C,{children:[", and the asset will be renamed to"," ",e("b",{children:Me(o.name,D(m.name))})]}),". Docs that use this asset will be updated."]}),e("div",{className:"AssetBrowser__details__confirmReplace__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>B(null),disabled:_,children:"Cancel"}),e(g,{color:"dark",size:"xs",loading:_,onClick:()=>E(m),children:"Replace"})]})]}),x&&e("div",{className:"AssetBrowser__details__confirmDelete",children:[e("div",{children:["Delete ",e("b",{children:o.name})," from the asset library?",h&&h.length>0&&e(C,{children:[" ","This asset is used in ",h.length," doc(s); those docs keep their copy of the file but will no longer receive updates."]})]}),e("div",{className:"AssetBrowser__details__confirmDelete__buttons",children:[e(g,{variant:"default",size:"xs",onClick:()=>v(!1),disabled:_,children:"Cancel"}),e(g,{color:"red",size:"xs",loading:_,onClick:()=>q(),children:"Delete"})]})]})]})})}function Te(t){let[o,a]=i(t.folder??t.initialFolder??""),l=t.folder??o,[r,_]=i([]),[d,x]=i(!0),[v,m]=i(""),[B,h]=i(!1),[F,n]=i(!1),[f,N]=i(null),[S,V]=i(!1),[W,z]=i(null),[X,R]=i(null),[E,$]=i(null),[q,c]=i(null),[w,p]=i(null),[y,K]=i(new Map),{roles:pt}=dt(),ht=window.firebase.user.email||"",J=ct(pt,ht),Q=v.trim().length>0;function P(s){a(s),m(""),t.onFolderChange&&t.onFolderChange(s)}async function I(s){x(!0),N(null),K(new Map),await M(async()=>{let u=await ke(s);_(u)}),x(!1)}T(()=>{I(l)},[l]),T(()=>{if(!Q||f!==null)return;let s=!1;return(async()=>{let u=[];await M(async()=>{u=await qe(l)}),s||N(u)})(),()=>{s=!0}},[Q,f,l]);let be=t.mode==="manage"?t.initialAssetId:"";T(()=>{be&&M(async()=>{let s=await Je(be);s&&s.type==="file"&&(P(s.parent),p(s))})},[be]);let Y=Se(()=>{let s=v.trim().toLowerCase(),u=s?f||[]:r;return t.mode==="pick"&&(u=u.filter(A=>A.type==="folder"||Ve(A.file?.filename||A.name,t.accept))),s&&(u=u.filter(A=>A.name.toLowerCase().includes(s))),u},[r,f,v,t.mode,t.accept]);async function Ue(s){if(s.length===0||F)return;let u="asset-browser-upload";n(!0),b({id:u,message:`Uploading ${s.length} file(s)...`,loading:!0,autoClose:!1,disallowClose:!0});let A=[],xe=[];for(let le=0;le<s.length;le++){let ne=s[le];je({id:u,message:`Uploading ${ne.name} (${le+1} of ${s.length})...`,loading:!0,autoClose:!1,disallowClose:!0});try{let Be=await re(ne),At=await Ye({parent:l,file:Be});A.push(At)}catch(Be){console.error(`failed to upload ${ne.name}:`,Be),xe.push(ne.name)}}Ge(u),n(!1),xe.length>0?b({title:"Upload failed",message:`Failed to upload: ${xe.join(", ")}`,color:"red",autoClose:!1}):b({message:`Uploaded ${A.length} file(s).`,color:"green"}),await I(l),t.mode==="pick"&&A.length===1&&s.length===1&&t.onPickFile&&t.onPickFile(A[0])}function vt(){let s=document.createElement("input");s.type="file",s.multiple=!0,t.mode==="pick"&&t.accept&&t.accept.length>0&&(s.accept=t.accept.join(",")),s.onchange=()=>{Ue(Array.from(s.files||[]))},s.click(),s.remove()}function wt(s){t.onPickFile&&t.onPickFile(s)}let Z=J,ae=t.mode==="manage"&&J,ee=Array.from(y.values()),Re=ee.filter(s=>s.type==="file"&&!s.file?.altDisabled&&(G(s.file?.filename||s.name)||H(s.file?.filename||s.name))),Ae=Y.length>0&&Y.every(s=>y.has(s.id));function $e(s){K(u=>{let A=new Map(u);return A.has(s.id)?A.delete(s.id):A.set(s.id,s),A})}function bt(){K(Ae?new Map:new Map(Y.map(s=>[s.id,s])))}return e("div",{className:fe("AssetBrowser",t.className,`AssetBrowser--${t.mode}`),children:[e("div",{className:"AssetBrowser__toolbar",children:[e(Te.Breadcrumbs,{folder:l,onNavigate:P}),e("div",{className:"AssetBrowser__toolbar__actions",children:[e(j,{className:"AssetBrowser__toolbar__filter",placeholder:"Search by name",size:"xs",icon:e(it,{size:14}),value:v,onChange:s=>m(s.currentTarget.value)}),Z&&t.mode==="manage"&&e(g,{variant:"default",size:"xs",leftIcon:e(lt,{size:16}),onClick:()=>V(!0),children:"New folder"}),Z&&e(g,{color:"dark",size:"xs",leftIcon:e(rt,{size:16}),loading:F,onClick:()=>vt(),children:"Upload"})]})]}),ae&&ee.length>0&&e("div",{className:"AssetBrowser__selectionBar",children:[e("div",{className:"AssetBrowser__selectionBar__count",children:[ee.length," selected"]}),e("div",{className:"AssetBrowser__selectionBar__actions",children:[e(g,{variant:"default",size:"xs",leftIcon:e(he,{size:14}),onClick:()=>R(ee),children:"Move"}),Re.length>0&&e(g,{variant:"default",size:"xs",onClick:()=>c(Re),children:"Disable alt text"}),e(g,{color:"red",size:"xs",leftIcon:e(O,{size:14}),onClick:()=>$(ee),children:"Delete"}),e(g,{variant:"subtle",color:"gray",size:"xs",onClick:()=>K(new Map),children:"Clear"})]})]}),e("div",{className:fe("AssetBrowser__listing",B&&"dragging"),onDragOver:s=>{Z&&(s.preventDefault(),h(!0))},onDragLeave:s=>{s.preventDefault(),h(!1)},onDrop:s=>{s.preventDefault(),h(!1),Z&&Ue(Array.from(s.dataTransfer?.files||[]))},children:d||Q&&f===null?e("div",{className:"AssetBrowser__loading",children:e(te,{color:"gray",size:"lg"})}):Y.length===0?e("div",{className:"AssetBrowser__empty","data-testid":"asset-browser-empty",children:v?e("div",{children:['No assets match "',v,'" in this folder or its subfolders.']}):e(C,{children:[e("div",{children:"This folder is empty."}),Z&&e("div",{className:"AssetBrowser__empty__hint",children:'Drop files here or click "Upload" to add assets.'})]})}):e(ie,{className:"AssetBrowser__table",verticalSpacing:"xs",fontSize:"xs",highlightOnHover:!0,children:[e("thead",{children:e("tr",{children:[ae&&e("th",{className:"AssetBrowser__table__checkboxCol",children:e(L,{size:"xs","aria-label":"Select all",checked:Ae,indeterminate:!Ae&&y.size>0,onChange:()=>bt()})}),e("th",{children:"name"}),e("th",{className:"AssetBrowser__table__modifiedCol",children:"modified"}),e("th",{className:"AssetBrowser__table__actionsCol"})]})}),e("tbody",{children:Y.map(s=>s.type==="folder"?e("tr",{className:"AssetBrowser__row AssetBrowser__row--folder",onClick:()=>P(oe(s.parent,s.name)),children:[ae&&e("td",{className:"AssetBrowser__checkboxCell",onClick:u=>u.stopPropagation(),children:e(L,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>$e(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e("div",{className:"AssetBrowser__thumb",children:e(De,{size:24,stroke:"1.5"})}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:s.name}),e(ut,{asset:s,folder:l,searching:Q,onNavigate:P})]})]})}),e("td",{children:e(gt,{asset:s})}),e("td",{onClick:u=>u.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode==="manage"&&J&&e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(Ne,{size:16})}),children:[e(k.Item,{icon:e(ze,{size:14}),onClick:()=>z(s),children:"Rename"}),e(k.Item,{icon:e(he,{size:14}),onClick:()=>R([s]),children:"Move"}),e(k.Item,{color:"red",icon:e(O,{size:14}),onClick:()=>$([s]),children:"Delete"})]})})})]},s.id):e("tr",{className:"AssetBrowser__row AssetBrowser__row--file",onClick:()=>{t.mode==="pick"?wt(s):p(s)},children:[ae&&e("td",{className:"AssetBrowser__checkboxCell",onClick:u=>u.stopPropagation(),children:e(L,{size:"xs","aria-label":`Select ${s.name}`,checked:y.has(s.id),onChange:()=>$e(s)})}),e("td",{children:e("div",{className:"AssetBrowser__nameCell",children:[e(mt,{file:s.file,size:36}),e("div",{className:"AssetBrowser__nameCell__text",children:[e("div",{className:"AssetBrowser__nameCell__name",children:[s.name,!!(s.file?.width&&s.file?.height)&&e("span",{className:"AssetBrowser__nameCell__dimens",children:[" ","(",s.file.width,"x",s.file.height,")"]})]}),e(ut,{asset:s,folder:l,searching:Q,onNavigate:P})]})]})}),e("td",{children:e(gt,{asset:s})}),e("td",{onClick:u=>u.stopPropagation(),children:e("div",{className:"AssetBrowser__actionsCell",children:t.mode!=="pick"&&e(xt,{asset:s,canManage:J,onDetails:()=>p(s),onRename:()=>z(s),onMove:()=>R([s]),onDelete:()=>$([s])})})})]},s.id))})]})}),e(Bt,{opened:S,parent:l,onClose:()=>V(!1),onCreated:s=>{V(!1),P(oe(l,s))}}),W&&e(yt,{asset:W,onClose:()=>z(null),onRenamed:()=>{z(null),I(l)}}),X&&X.length>0&&e(Ct,{assets:X,onClose:()=>R(null),onMoved:()=>{R(null),I(l)}}),E&&E.length>0&&e(Mt,{assets:E,onClose:()=>$(null),onDeleted:()=>{$(null),I(l)}}),q&&q.length>0&&e(Ft,{assets:q,onClose:()=>c(null),onDone:()=>{c(null),I(l)}}),w&&e(ft,{asset:w,canManage:J,onClose:()=>p(null),onChanged:()=>I(l),onDeleted:()=>{p(null),I(l)}})]})}Te.Breadcrumbs=t=>{let o=Xe(t.folder),a=[{label:"Assets",path:""}];return o.forEach((l,r)=>{a.push({label:l,path:o.slice(0,r+1).join("/")})}),e("div",{className:"AssetBrowser__breadcrumbs",children:a.map((l,r)=>e("div",{className:"AssetBrowser__breadcrumbs__crumb",children:[r>0&&e(Fe,{className:"AssetBrowser__breadcrumbs__divider",size:14}),e("button",{className:fe("AssetBrowser__breadcrumbs__link",r===a.length-1&&"active"),disabled:r===a.length-1,onClick:()=>t.onNavigate(l.path),children:l.label})]},l.path))})};function xt(t){let o=t.asset;return e(k,{shadow:"sm",position:"bottom",placement:"end",control:e(se,{size:"sm",children:e(Ne,{size:16})}),children:[e(k.Item,{icon:e(nt,{size:14}),onClick:t.onDetails,children:"Details"}),e(k.Item,{icon:e(ue,{size:14}),onClick:()=>ve(o.file),children:"Copy URL"}),e(k.Item,{icon:e(ge,{size:14}),onClick:()=>we(o.file),children:"Download"}),t.canManage&&e(C,{children:[e(k.Item,{icon:e(ze,{size:14}),onClick:t.onRename,children:"Rename"}),e(k.Item,{icon:e(he,{size:14}),onClick:t.onMove,children:"Move"}),e(k.Item,{color:"red",icon:e(O,{size:14}),onClick:t.onDelete,children:"Delete"})]})]})}function ut(t){let o=t.asset;return!t.searching||o.parent===t.folder?null:e("button",{className:"AssetBrowser__nameCell__path",title:"Go to folder",onClick:a=>{a.stopPropagation(),t.onNavigate(o.parent)},children:["in ",Ke(o.parent,t.folder)]})}function gt(t){let o=t.asset.modifiedAt||t.asset.createdAt,a=t.asset.modifiedBy||t.asset.createdBy||"",l=o&&typeof o.toMillis=="function"?o.toMillis():0;return e("div",{className:"AssetBrowser__modifiedCell",children:[a&&e(_t,{email:a,size:20}),e("span",{children:l?He(l):"\u2014"})]})}function Bt(t){let[o,a]=i(""),[l,r]=i(!1);async function _(){r(!0),await M(async()=>{let d=await Qe(t.parent,o);a(""),t.onCreated(d.name)}),r(!1)}return e(U,{opened:t.opened,onClose:t.onClose,title:"New folder",size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),_()},children:[e(j,{"data-autofocus":!0,placeholder:"Folder name",value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Create"})]})})}function yt(t){let[o,a]=i(t.asset.name),[l,r]=i(!1);async function _(){r(!0),await M(async()=>{await Ze(t.asset,o),t.onRenamed()}),r(!1)}return e(U,{opened:!0,onClose:t.onClose,title:`Rename ${t.asset.type}`,size:"sm",centered:!0,children:e("form",{className:"AssetBrowser__modalForm",onSubmit:d=>{d.preventDefault(),_()},children:[e(j,{"data-autofocus":!0,value:o,onChange:d=>a(d.currentTarget.value)}),e(g,{type:"submit",color:"dark",loading:l,disabled:!o,children:"Rename"})]})})}function Ct(t){let o=t.assets,[a,l]=i(o[0]?.parent||""),[r,_]=i([]),[d,x]=i(!0),[v,m]=i(!1);T(()=>{x(!0),M(async()=>{let n=await ke(a);_(n.filter(f=>f.type==="folder"))}).then(()=>x(!1))},[a]);let B=o.filter(n=>n.type==="folder").map(n=>oe(n.parent,n.name));function h(n){return B.some(f=>n===f||n.startsWith(`${f}/`))}async function F(){m(!0);let n=[],f=0;for(let N of o)try{await et(N,a),f+=1}catch(S){console.error(`failed to move ${N.name}:`,S),n.push(N.name)}m(!1),n.length>0&&b({title:"Move failed",message:`Failed to move: ${n.join(", ")}`,color:"red",autoClose:!1}),f>0&&b({message:o.length===1?`Moved "${o[0].name}" to ${a||"Assets"}.`:`Moved ${f} item(s) to ${a||"Assets"}.`,color:"green"}),t.onMoved()}return e(U,{opened:!0,onClose:t.onClose,title:o.length===1?`Move "${o[0].name}"`:`Move ${o.length} items`,size:"md",centered:!0,children:e("div",{className:"AssetBrowser__moveModal",children:[e(Te.Breadcrumbs,{folder:a,onNavigate:l}),e("div",{className:"AssetBrowser__moveModal__folders",children:d?e(te,{color:"gray",size:"sm"}):r.length===0?e("div",{className:"AssetBrowser__moveModal__empty",children:"No subfolders."}):r.map(n=>{let f=oe(n.parent,n.name);return e("button",{className:"AssetBrowser__moveModal__folder",disabled:h(f),onClick:()=>l(f),children:[e(De,{size:16,stroke:"1.5"}),e("span",{children:n.name}),e(Fe,{size:14})]},n.id)})}),e(g,{color:"dark",fullWidth:!0,loading:v,disabled:o.every(n=>n.parent===a),onClick:()=>F(),children:"Move here"})]})})}var kt=20;function Mt(t){let o=t.assets,[a,l]=i(!1),[r,_]=i(null),d=o.filter(m=>m.type==="file"),x=o.some(m=>m.type==="folder");T(()=>{d.length===0||d.length>kt||Promise.all(d.map(m=>_e(m.id))).then(m=>{let B=new Set(m.flat().map(h=>h.id));_(B.size)}).catch(()=>_(null))},[o.map(m=>m.id).join(",")]);async function v(){l(!0);let m=[],B=0;for(let h of o)try{await de(h),B+=1}catch(F){console.error(`failed to delete ${h.name}:`,F),m.push(h.name)}l(!1),m.length>0&&b({title:"Delete failed",message:`Failed to delete: ${m.join(", ")}. Note that folders must be empty before they can be deleted.`,color:"red",autoClose:!1}),B>0&&b({message:o.length===1?`Deleted "${o[0].name}".`:`Deleted ${B} item(s).`,color:"green"}),t.onDeleted()}return e(U,{opened:!0,onClose:t.onClose,title:o.length===1?`Delete ${o[0].type}?`:`Delete ${o.length} items?`,size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Are you sure you want to delete"," ",o.length===1?e("b",{children:o[0].name}):e("b",{children:[o.length," items"]})," ","from the asset manager?",d.length>0&&e(C,{children:[" ","The underlying files are not deleted from GCS, and docs that currently use the assets keep their copy of the files."]}),x&&e(C,{children:" Folders must be empty before they can be deleted."})]}),r!==null&&r>0&&e("div",{className:"AssetBrowser__deleteModal__warning",children:[o.length===1?"This asset is":"These assets are"," ","currently used in ",r," doc(s). Those docs will no longer receive updates when the asset changes."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"red",loading:a,onClick:()=>v(),children:"Delete"})]})]})})}function Ft(t){let o=t.assets,[a,l]=i(!1);async function r(){l(!0);let _=[],d=0;for(let x of o)try{let v=x.file,m=await ce(x,!0);await me(m,{previousFile:v}),d+=1}catch(v){console.error(`failed to disable alt text for ${x.name}:`,v),_.push(x.name)}l(!1),_.length>0&&b({title:"Failed to disable alt text",message:`Failed to update: ${_.join(", ")}`,color:"red",autoClose:!1}),d>0&&b({message:`Disabled alt text for ${d} file(s).`,color:"green"}),t.onDone()}return e(U,{opened:!0,onClose:t.onClose,title:"Disable alt text?",size:"sm",centered:!0,children:e("div",{className:"AssetBrowser__deleteModal",children:[e("div",{className:"AssetBrowser__deleteModal__text",children:["Disable alt text for ",e("b",{children:[o.length," file(s)"]}),"? The alt text input is hidden in docs that use these assets and their embedded alt text is cleared. Alt text can be re-enabled per asset from its details."]}),e("div",{className:"AssetBrowser__deleteModal__buttons",children:[e(g,{variant:"default",onClick:t.onClose,disabled:a,children:"Cancel"}),e(g,{color:"dark",loading:a,onClick:()=>r(),children:"Disable alt text"})]})]})})}export{Te as a};
@@ -0,0 +1 @@
1
+ import{a as H}from"./chunk-N3JSLTMV.js";import{a as j}from"./chunk-RAXWL656.js";import{f as U}from"./chunk-R6B3W5AJ.js";import{b as B,d as L,e as O,j as A}from"./chunk-AZCGXQTL.js";import{a as q}from"./chunk-76ZGLKLT.js";import{a as T}from"./chunk-JDW4UORS.js";import{a as W}from"./chunk-W5DOO6ID.js";import{a as $}from"./chunk-NSOTG64N.js";import{b as M}from"./chunk-J5E457OI.js";import{a as v}from"./chunk-QHJOTXYB.js";import{d as k}from"./chunk-YLSRRNSE.js";import{$ as D,Fa as I,Ga as e,Qa as V,Rc as F,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-LROR6N3B.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=j(),Q=H(),{roles:X}=$(),Z=window.firebase.user.email||"",n=W(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{f as t}from"./chunk-YLSRRNSE.js";import{Fa as l,Ga as i}from"./chunk-LROR6N3B.js";import{d as n}from"./chunk-KUCVLANF.js";function c(o){return o.condition?i(l,{label:o.label,children:i("div",{className:t(o.className,"ConditionalTooltip"),style:o.style,children:i("div",{className:"ConditionalTooltip__content",children:o.children})})}):i(n,{children:o.children})}export{c as a};
@@ -1,5 +1,5 @@
1
- import{B as ke,C as Ee,D as Ue,E as Ie,G as xe,H as Q,c as me,e as J,f as be,g as we,h as Re,p as Te,x as S,y as ye}from"./chunk-DTMZLUNY.js";var De="firebasestorage.googleapis.com",Le="storageBucket",st=120*1e3,rt=600*1e3,ot=1e3;var g=class t extends Te{constructor(e,n,s=0){super(ee(e),`Firebase Storage: ${n} (${ee(e)})`),this.status_=s,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,t.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return ee(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
2
- ${this.customData.serverResponse}`:this.message=this._baseMessage}},p;(function(t){t.UNKNOWN="unknown",t.OBJECT_NOT_FOUND="object-not-found",t.BUCKET_NOT_FOUND="bucket-not-found",t.PROJECT_NOT_FOUND="project-not-found",t.QUOTA_EXCEEDED="quota-exceeded",t.UNAUTHENTICATED="unauthenticated",t.UNAUTHORIZED="unauthorized",t.UNAUTHORIZED_APP="unauthorized-app",t.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",t.INVALID_CHECKSUM="invalid-checksum",t.CANCELED="canceled",t.INVALID_EVENT_NAME="invalid-event-name",t.INVALID_URL="invalid-url",t.INVALID_DEFAULT_BUCKET="invalid-default-bucket",t.NO_DEFAULT_BUCKET="no-default-bucket",t.CANNOT_SLICE_BLOB="cannot-slice-blob",t.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",t.NO_DOWNLOAD_URL="no-download-url",t.INVALID_ARGUMENT="invalid-argument",t.INVALID_ARGUMENT_COUNT="invalid-argument-count",t.APP_DELETED="app-deleted",t.INVALID_ROOT_OPERATION="invalid-root-operation",t.INVALID_FORMAT="invalid-format",t.INTERNAL_ERROR="internal-error",t.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(p||(p={}));function ee(t){return"storage/"+t}function le(){let t="An unknown error occurred, please check the error payload for server response.";return new g(p.UNKNOWN,t)}function it(t){return new g(p.OBJECT_NOT_FOUND,"Object '"+t+"' does not exist.")}function at(t){return new g(p.QUOTA_EXCEEDED,"Quota for bucket '"+t+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function ut(){let t="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new g(p.UNAUTHENTICATED,t)}function lt(){return new g(p.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function ct(t){return new g(p.UNAUTHORIZED,"User does not have permission to access '"+t+"'.")}function Fe(){return new g(p.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function Be(){return new g(p.CANCELED,"User canceled the upload/download.")}function ht(t){return new g(p.INVALID_URL,"Invalid URL '"+t+"'.")}function dt(t){return new g(p.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}function ft(){return new g(p.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Le+"' property when initializing the app?")}function Me(){return new g(p.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function pt(){return new g(p.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function _t(t){return new g(p.UNSUPPORTED_ENVIRONMENT,`${t} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function ne(t){return new g(p.INVALID_ARGUMENT,t)}function qe(){return new g(p.APP_DELETED,"The Firebase app was deleted.")}function gt(t){return new g(p.INVALID_ROOT_OPERATION,"The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function $(t,e){return new g(p.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function q(t){throw new g(p.INTERNAL_ERROR,"Internal error: "+t)}var k=class t{constructor(e,n){this.bucket=e,this.path_=n}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){let e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,n){let s;try{s=t.makeFromUrl(e,n)}catch{return new t(e,"")}if(s.path==="")return s;throw dt(e)}static makeFromUrl(e,n){let s=null,r="([A-Za-z0-9.\\-_]+)";function o(b){b.path.charAt(b.path.length-1)==="/"&&(b.path_=b.path_.slice(0,-1))}let i="(/(.*))?$",u=new RegExp("^gs://"+r+i,"i"),a={bucket:1,path:3};function l(b){b.path_=decodeURIComponent(b.path)}let c="v[A-Za-z0-9_]+",d=n.replace(/[.]/g,"\\."),f="(/([^?#]*).*)?$",_=new RegExp(`^https?://${d}/${c}/b/${r}/o${f}`,"i"),h={bucket:1,path:3},T=n===De?"(?:storage.googleapis.com|storage.cloud.google.com)":n,m="([^?#]*)",U=new RegExp(`^https?://${T}/${r}/${m}`,"i"),R=[{regex:u,indices:a,postModify:o},{regex:_,indices:h,postModify:l},{regex:U,indices:{bucket:1,path:2},postModify:l}];for(let b=0;b<R.length;b++){let C=R[b],v=C.regex.exec(e);if(v){let Y=v[C.indices.bucket],M=v[C.indices.path];M||(M=""),s=new t(Y,M),C.postModify(s);break}}if(s==null)throw ht(e);return s}},se=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function mt(t,e,n){let s=1,r=null,o=null,i=!1,u=0;function a(){return u===2}let l=!1;function c(...m){l||(l=!0,e.apply(null,m))}function d(m){r=setTimeout(()=>{r=null,t(_,a())},m)}function f(){o&&clearTimeout(o)}function _(m,...U){if(l){f();return}if(m){f(),c.call(null,m,...U);return}if(a()||i){f(),c.call(null,m,...U);return}s<64&&(s*=2);let R;u===1?(u=2,R=0):R=(s+Math.random())*1e3,d(R)}let h=!1;function T(m){h||(h=!0,f(),!l&&(r!==null?(m||(u=2),clearTimeout(r),d(0)):m||(u=1)))}return d(0),o=setTimeout(()=>{i=!0,T(!0)},n),T}function bt(t){t(!1)}function wt(t){return t!==void 0}function Rt(t){return typeof t=="function"}function Tt(t){return typeof t=="object"&&!Array.isArray(t)}function ce(t){return typeof t=="string"||t instanceof String}function Ae(t){return he()&&t instanceof Blob}function he(){return typeof Blob<"u"}function Oe(t,e,n,s){if(s<e)throw ne(`Invalid value for '${t}'. Expected ${e} or greater.`);if(s>n)throw ne(`Invalid value for '${t}'. Expected ${n} or less.`)}function z(t,e,n){let s=e;return n==null&&(s=`https://${e}`),`${n}://${s}/v0${t}`}function yt(t){let e=encodeURIComponent,n="?";for(let s in t)if(t.hasOwnProperty(s)){let r=e(s)+"="+e(t[s]);n=n+r+"&"}return n=n.slice(0,-1),n}var P;(function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"})(P||(P={}));function $e(t,e){let n=t>=500&&t<600,r=[408,429].indexOf(t)!==-1,o=e.indexOf(t)!==-1;return n||r||o}var re=class{constructor(e,n,s,r,o,i,u,a,l,c,d,f=!0,_=!1){this.url_=e,this.method_=n,this.headers_=s,this.body_=r,this.successCodes_=o,this.additionalRetryCodes_=i,this.callback_=u,this.errorCallback_=a,this.timeout_=l,this.progressCallback_=c,this.connectionFactory_=d,this.retry=f,this.isUsingEmulator=_,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((h,T)=>{this.resolve_=h,this.reject_=T,this.start_()})}start_(){let e=(s,r)=>{if(r){s(!1,new D(!1,null,!0));return}let o=this.connectionFactory_();this.pendingConnection_=o;let i=u=>{let a=u.loaded,l=u.lengthComputable?u.total:-1;this.progressCallback_!==null&&this.progressCallback_(a,l)};this.progressCallback_!==null&&o.addUploadProgressListener(i),o.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&o.removeUploadProgressListener(i),this.pendingConnection_=null;let u=o.getErrorCode()===P.NO_ERROR,a=o.getStatus();if(!u||$e(a,this.additionalRetryCodes_)&&this.retry){let c=o.getErrorCode()===P.ABORT;s(!1,new D(!1,null,c));return}let l=this.successCodes_.indexOf(a)!==-1;s(!0,new D(l,o))})},n=(s,r)=>{let o=this.resolve_,i=this.reject_,u=r.connection;if(r.wasSuccessCode)try{let a=this.callback_(u,u.getResponse());wt(a)?o(a):o()}catch(a){i(a)}else if(u!==null){let a=le();a.serverResponse=u.getErrorText(),this.errorCallback_?i(this.errorCallback_(u,a)):i(a)}else if(r.canceled){let a=this.appDelete_?qe():Be();i(a)}else{let a=Fe();i(a)}};this.canceled_?n(!1,new D(!1,null,!0)):this.backoffId_=mt(e,n,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&bt(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},D=class{constructor(e,n,s){this.wasSuccessCode=e,this.connection=n,this.canceled=!!s}};function kt(t,e){e!==null&&e.length>0&&(t.Authorization="Firebase "+e)}function Et(t,e){t["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function Ut(t,e){e&&(t["X-Firebase-GMPID"]=e)}function It(t,e){e!==null&&(t["X-Firebase-AppCheck"]=e)}function xt(t,e,n,s,r,o,i=!0,u=!1){let a=yt(t.urlParams),l=t.url+a,c=Object.assign({},t.headers);return Ut(c,e),kt(c,n),Et(c,o),It(c,s),new re(l,t.method,c,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,r,i,u)}function At(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function Ot(...t){let e=At();if(e!==void 0){let n=new e;for(let s=0;s<t.length;s++)n.append(t[s]);return n.getBlob()}else{if(he())return new Blob(t);throw new g(p.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function St(t,e,n){return t.webkitSlice?t.webkitSlice(e,n):t.mozSlice?t.mozSlice(e,n):t.slice?t.slice(e,n):null}function Pt(t){if(typeof atob>"u")throw _t("base-64");return atob(t)}var E={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"},H=class{constructor(e,n){this.data=e,this.contentType=n||null}};function Ct(t,e){switch(t){case E.RAW:return new H(He(e));case E.BASE64:case E.BASE64URL:return new H(je(t,e));case E.DATA_URL:return new H(Nt(e),Dt(e))}throw le()}function He(t){let e=[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);if(s<=127)e.push(s);else if(s<=2047)e.push(192|s>>6,128|s&63);else if((s&64512)===55296)if(!(n<t.length-1&&(t.charCodeAt(n+1)&64512)===56320))e.push(239,191,189);else{let o=s,i=t.charCodeAt(++n);s=65536|(o&1023)<<10|i&1023,e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63)}else(s&64512)===56320?e.push(239,191,189):e.push(224|s>>12,128|s>>6&63,128|s&63)}return new Uint8Array(e)}function vt(t){let e;try{e=decodeURIComponent(t)}catch{throw $(E.DATA_URL,"Malformed data URL.")}return He(e)}function je(t,e){switch(t){case E.BASE64:{let r=e.indexOf("-")!==-1,o=e.indexOf("_")!==-1;if(r||o)throw $(t,"Invalid character '"+(r?"-":"_")+"' found: is it base64url encoded?");break}case E.BASE64URL:{let r=e.indexOf("+")!==-1,o=e.indexOf("/")!==-1;if(r||o)throw $(t,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let n;try{n=Pt(e)}catch(r){throw r.message.includes("polyfill")?r:$(t,"Invalid character found")}let s=new Uint8Array(n.length);for(let r=0;r<n.length;r++)s[r]=n.charCodeAt(r);return s}var V=class{constructor(e){this.base64=!1,this.contentType=null;let n=e.match(/^data:([^,]+)?,/);if(n===null)throw $(E.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");let s=n[1]||null;s!=null&&(this.base64=Lt(s,";base64"),this.contentType=this.base64?s.substring(0,s.length-7):s),this.rest=e.substring(e.indexOf(",")+1)}};function Nt(t){let e=new V(t);return e.base64?je(E.BASE64,e.rest):vt(e.rest)}function Dt(t){return new V(t).contentType}function Lt(t,e){return t.length>=e.length?t.substring(t.length-e.length)===e:!1}var X=class t{constructor(e,n){let s=0,r="";Ae(e)?(this.data_=e,s=e.size,r=e.type):e instanceof ArrayBuffer?(n?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),s=this.data_.length):e instanceof Uint8Array&&(n?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),s=e.length),this.size_=s,this.type_=r}size(){return this.size_}type(){return this.type_}slice(e,n){if(Ae(this.data_)){let s=this.data_,r=St(s,e,n);return r===null?null:new t(r)}else{let s=new Uint8Array(this.data_.buffer,e,n-e);return new t(s,!0)}}static getBlob(...e){if(he()){let n=e.map(s=>s instanceof t?s.data_:s);return new t(Ot.apply(null,n))}else{let n=e.map(i=>ce(i)?Ct(E.RAW,i).data:i.data_),s=0;n.forEach(i=>{s+=i.byteLength});let r=new Uint8Array(s),o=0;return n.forEach(i=>{for(let u=0;u<i.length;u++)r[o++]=i[u]}),new t(r,!0)}}uploadData(){return this.data_}};function Ft(t){let e;try{e=JSON.parse(t)}catch{return null}return Tt(e)?e:null}function Bt(t){if(t.length===0)return null;let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}function Mt(t,e){let n=e.split("/").filter(s=>s.length>0).join("/");return t.length===0?n:t+"/"+n}function ze(t){let e=t.lastIndexOf("/",t.length-2);return e===-1?t:t.slice(e+1)}function qt(t,e){return e}var w=class{constructor(e,n,s,r){this.server=e,this.local=n||e,this.writable=!!s,this.xform=r||qt}},W=null;function $t(t){return!ce(t)||t.length<2?t:ze(t)}function de(){if(W)return W;let t=[];t.push(new w("bucket")),t.push(new w("generation")),t.push(new w("metageneration")),t.push(new w("name","fullPath",!0));function e(o,i){return $t(i)}let n=new w("name");n.xform=e,t.push(n);function s(o,i){return i!==void 0?Number(i):i}let r=new w("size");return r.xform=s,t.push(r),t.push(new w("timeCreated")),t.push(new w("updated")),t.push(new w("md5Hash",null,!0)),t.push(new w("cacheControl",null,!0)),t.push(new w("contentDisposition",null,!0)),t.push(new w("contentEncoding",null,!0)),t.push(new w("contentLanguage",null,!0)),t.push(new w("contentType",null,!0)),t.push(new w("metadata","customMetadata",!0)),W=t,W}function Ht(t,e){function n(){let s=t.bucket,r=t.fullPath,o=new k(s,r);return e._makeStorageReference(o)}Object.defineProperty(t,"ref",{get:n})}function jt(t,e,n){let s={};s.type="file";let r=n.length;for(let o=0;o<r;o++){let i=n[o];s[i.local]=i.xform(s,e[i.server])}return Ht(s,t),s}function zt(t,e,n){let s=Ft(e);return s===null?null:jt(t,s,n)}function fe(t,e){let n={},s=e.length;for(let r=0;r<s;r++){let o=e[r];o.writable&&(n[o.server]=t[o.local])}return JSON.stringify(n)}var x=class{constructor(e,n,s,r){this.url=e,this.method=n,this.handler=s,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}};function O(t){if(!t)throw le()}function K(t,e){function n(s,r){let o=zt(t,r,e);return O(o!==null),o}return n}function G(t){function e(n,s){let r;return n.getStatus()===401?n.getErrorText().includes("Firebase App Check token is invalid")?r=lt():r=ut():n.getStatus()===402?r=at(t.bucket):n.getStatus()===403?r=ct(t.path):r=s,r.status=n.getStatus(),r.serverResponse=s.serverResponse,r}return e}function pe(t){let e=G(t);function n(s,r){let o=e(s,r);return s.getStatus()===404&&(o=it(t.path)),o.serverResponse=r.serverResponse,o}return n}function Ge(t,e,n){let s=e.fullServerUrl(),r=z(s,t.host,t._protocol),o="GET",i=t.maxOperationRetryTime,u=new x(r,o,K(t,n),i);return u.errorHandler=pe(e),u}function Gt(t,e,n,s){let r=e.fullServerUrl(),o=z(r,t.host,t._protocol),i="PATCH",u=fe(n,s),a={"Content-Type":"application/json; charset=utf-8"},l=t.maxOperationRetryTime,c=new x(o,i,K(t,s),l);return c.headers=a,c.body=u,c.errorHandler=pe(e),c}function Wt(t,e){let n=e.fullServerUrl(),s=z(n,t.host,t._protocol),r="DELETE",o=t.maxOperationRetryTime;function i(a,l){}let u=new x(s,r,i,o);return u.successCodes=[200,204],u.errorHandler=pe(e),u}function Vt(t,e){return t&&t.contentType||e&&e.type()||"application/octet-stream"}function We(t,e,n){let s=Object.assign({},n);return s.fullPath=t.path,s.size=e.size(),s.contentType||(s.contentType=Vt(null,e)),s}function Xt(t,e,n,s,r){let o=e.bucketOnlyServerUrl(),i={"X-Goog-Upload-Protocol":"multipart"};function u(){let R="";for(let b=0;b<2;b++)R=R+Math.random().toString().slice(2);return R}let a=u();i["Content-Type"]="multipart/related; boundary="+a;let l=We(e,s,r),c=fe(l,n),d="--"+a+`\r
1
+ import{B as Ue,C as Ie,D as xe,E as Ae,G as Oe,H as ee,c as we,e as Q,f as Te,g as Re,h as ye,p as ke,x as S,y as Ee}from"./chunk-DTMZLUNY.js";var Fe="firebasestorage.googleapis.com",Be="storageBucket",ot=120*1e3,it=600*1e3,at=1e3;var g=class t extends ke{constructor(e,n,s=0){super(te(e),`Firebase Storage: ${n} (${te(e)})`),this.status_=s,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,t.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return te(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
2
+ ${this.customData.serverResponse}`:this.message=this._baseMessage}},p;(function(t){t.UNKNOWN="unknown",t.OBJECT_NOT_FOUND="object-not-found",t.BUCKET_NOT_FOUND="bucket-not-found",t.PROJECT_NOT_FOUND="project-not-found",t.QUOTA_EXCEEDED="quota-exceeded",t.UNAUTHENTICATED="unauthenticated",t.UNAUTHORIZED="unauthorized",t.UNAUTHORIZED_APP="unauthorized-app",t.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",t.INVALID_CHECKSUM="invalid-checksum",t.CANCELED="canceled",t.INVALID_EVENT_NAME="invalid-event-name",t.INVALID_URL="invalid-url",t.INVALID_DEFAULT_BUCKET="invalid-default-bucket",t.NO_DEFAULT_BUCKET="no-default-bucket",t.CANNOT_SLICE_BLOB="cannot-slice-blob",t.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",t.NO_DOWNLOAD_URL="no-download-url",t.INVALID_ARGUMENT="invalid-argument",t.INVALID_ARGUMENT_COUNT="invalid-argument-count",t.APP_DELETED="app-deleted",t.INVALID_ROOT_OPERATION="invalid-root-operation",t.INVALID_FORMAT="invalid-format",t.INTERNAL_ERROR="internal-error",t.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(p||(p={}));function te(t){return"storage/"+t}function ce(){let t="An unknown error occurred, please check the error payload for server response.";return new g(p.UNKNOWN,t)}function ut(t){return new g(p.OBJECT_NOT_FOUND,"Object '"+t+"' does not exist.")}function lt(t){return new g(p.QUOTA_EXCEEDED,"Quota for bucket '"+t+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function ct(){let t="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new g(p.UNAUTHENTICATED,t)}function ht(){return new g(p.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function dt(t){return new g(p.UNAUTHORIZED,"User does not have permission to access '"+t+"'.")}function Me(){return new g(p.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function qe(){return new g(p.CANCELED,"User canceled the upload/download.")}function ft(t){return new g(p.INVALID_URL,"Invalid URL '"+t+"'.")}function pt(t){return new g(p.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}function _t(){return new g(p.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Be+"' property when initializing the app?")}function $e(){return new g(p.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function gt(){return new g(p.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function mt(t){return new g(p.UNSUPPORTED_ENVIRONMENT,`${t} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function se(t){return new g(p.INVALID_ARGUMENT,t)}function He(){return new g(p.APP_DELETED,"The Firebase app was deleted.")}function bt(t){return new g(p.INVALID_ROOT_OPERATION,"The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function $(t,e){return new g(p.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function q(t){throw new g(p.INTERNAL_ERROR,"Internal error: "+t)}var k=class t{constructor(e,n){this.bucket=e,this.path_=n}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){let e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,n){let s;try{s=t.makeFromUrl(e,n)}catch{return new t(e,"")}if(s.path==="")return s;throw pt(e)}static makeFromUrl(e,n){let s=null,r="([A-Za-z0-9.\\-_]+)";function o(b){b.path.charAt(b.path.length-1)==="/"&&(b.path_=b.path_.slice(0,-1))}let i="(/(.*))?$",u=new RegExp("^gs://"+r+i,"i"),a={bucket:1,path:3};function l(b){b.path_=decodeURIComponent(b.path)}let c="v[A-Za-z0-9_]+",d=n.replace(/[.]/g,"\\."),f="(/([^?#]*).*)?$",_=new RegExp(`^https?://${d}/${c}/b/${r}/o${f}`,"i"),h={bucket:1,path:3},R=n===Fe?"(?:storage.googleapis.com|storage.cloud.google.com)":n,m="([^?#]*)",U=new RegExp(`^https?://${R}/${r}/${m}`,"i"),T=[{regex:u,indices:a,postModify:o},{regex:_,indices:h,postModify:l},{regex:U,indices:{bucket:1,path:2},postModify:l}];for(let b=0;b<T.length;b++){let C=T[b],v=C.regex.exec(e);if(v){let Z=v[C.indices.bucket],M=v[C.indices.path];M||(M=""),s=new t(Z,M),C.postModify(s);break}}if(s==null)throw ft(e);return s}},re=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function wt(t,e,n){let s=1,r=null,o=null,i=!1,u=0;function a(){return u===2}let l=!1;function c(...m){l||(l=!0,e.apply(null,m))}function d(m){r=setTimeout(()=>{r=null,t(_,a())},m)}function f(){o&&clearTimeout(o)}function _(m,...U){if(l){f();return}if(m){f(),c.call(null,m,...U);return}if(a()||i){f(),c.call(null,m,...U);return}s<64&&(s*=2);let T;u===1?(u=2,T=0):T=(s+Math.random())*1e3,d(T)}let h=!1;function R(m){h||(h=!0,f(),!l&&(r!==null?(m||(u=2),clearTimeout(r),d(0)):m||(u=1)))}return d(0),o=setTimeout(()=>{i=!0,R(!0)},n),R}function Tt(t){t(!1)}function Rt(t){return t!==void 0}function yt(t){return typeof t=="function"}function kt(t){return typeof t=="object"&&!Array.isArray(t)}function he(t){return typeof t=="string"||t instanceof String}function Se(t){return de()&&t instanceof Blob}function de(){return typeof Blob<"u"}function Pe(t,e,n,s){if(s<e)throw se(`Invalid value for '${t}'. Expected ${e} or greater.`);if(s>n)throw se(`Invalid value for '${t}'. Expected ${n} or less.`)}function G(t,e,n){let s=e;return n==null&&(s=`https://${e}`),`${n}://${s}/v0${t}`}function Et(t){let e=encodeURIComponent,n="?";for(let s in t)if(t.hasOwnProperty(s)){let r=e(s)+"="+e(t[s]);n=n+r+"&"}return n=n.slice(0,-1),n}var P;(function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"})(P||(P={}));function je(t,e){let n=t>=500&&t<600,r=[408,429].indexOf(t)!==-1,o=e.indexOf(t)!==-1;return n||r||o}var oe=class{constructor(e,n,s,r,o,i,u,a,l,c,d,f=!0,_=!1){this.url_=e,this.method_=n,this.headers_=s,this.body_=r,this.successCodes_=o,this.additionalRetryCodes_=i,this.callback_=u,this.errorCallback_=a,this.timeout_=l,this.progressCallback_=c,this.connectionFactory_=d,this.retry=f,this.isUsingEmulator=_,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((h,R)=>{this.resolve_=h,this.reject_=R,this.start_()})}start_(){let e=(s,r)=>{if(r){s(!1,new D(!1,null,!0));return}let o=this.connectionFactory_();this.pendingConnection_=o;let i=u=>{let a=u.loaded,l=u.lengthComputable?u.total:-1;this.progressCallback_!==null&&this.progressCallback_(a,l)};this.progressCallback_!==null&&o.addUploadProgressListener(i),o.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&o.removeUploadProgressListener(i),this.pendingConnection_=null;let u=o.getErrorCode()===P.NO_ERROR,a=o.getStatus();if(!u||je(a,this.additionalRetryCodes_)&&this.retry){let c=o.getErrorCode()===P.ABORT;s(!1,new D(!1,null,c));return}let l=this.successCodes_.indexOf(a)!==-1;s(!0,new D(l,o))})},n=(s,r)=>{let o=this.resolve_,i=this.reject_,u=r.connection;if(r.wasSuccessCode)try{let a=this.callback_(u,u.getResponse());Rt(a)?o(a):o()}catch(a){i(a)}else if(u!==null){let a=ce();a.serverResponse=u.getErrorText(),this.errorCallback_?i(this.errorCallback_(u,a)):i(a)}else if(r.canceled){let a=this.appDelete_?He():qe();i(a)}else{let a=Me();i(a)}};this.canceled_?n(!1,new D(!1,null,!0)):this.backoffId_=wt(e,n,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&Tt(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},D=class{constructor(e,n,s){this.wasSuccessCode=e,this.connection=n,this.canceled=!!s}};function Ut(t,e){e!==null&&e.length>0&&(t.Authorization="Firebase "+e)}function It(t,e){t["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function xt(t,e){e&&(t["X-Firebase-GMPID"]=e)}function At(t,e){e!==null&&(t["X-Firebase-AppCheck"]=e)}function Ot(t,e,n,s,r,o,i=!0,u=!1){let a=Et(t.urlParams),l=t.url+a,c=Object.assign({},t.headers);return xt(c,e),Ut(c,n),It(c,o),At(c,s),new oe(l,t.method,c,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,r,i,u)}function St(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function Pt(...t){let e=St();if(e!==void 0){let n=new e;for(let s=0;s<t.length;s++)n.append(t[s]);return n.getBlob()}else{if(de())return new Blob(t);throw new g(p.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function Ct(t,e,n){return t.webkitSlice?t.webkitSlice(e,n):t.mozSlice?t.mozSlice(e,n):t.slice?t.slice(e,n):null}function vt(t){if(typeof atob>"u")throw mt("base-64");return atob(t)}var E={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"},H=class{constructor(e,n){this.data=e,this.contentType=n||null}};function Nt(t,e){switch(t){case E.RAW:return new H(Ge(e));case E.BASE64:case E.BASE64URL:return new H(ze(t,e));case E.DATA_URL:return new H(Lt(e),Ft(e))}throw ce()}function Ge(t){let e=[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);if(s<=127)e.push(s);else if(s<=2047)e.push(192|s>>6,128|s&63);else if((s&64512)===55296)if(!(n<t.length-1&&(t.charCodeAt(n+1)&64512)===56320))e.push(239,191,189);else{let o=s,i=t.charCodeAt(++n);s=65536|(o&1023)<<10|i&1023,e.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63)}else(s&64512)===56320?e.push(239,191,189):e.push(224|s>>12,128|s>>6&63,128|s&63)}return new Uint8Array(e)}function Dt(t){let e;try{e=decodeURIComponent(t)}catch{throw $(E.DATA_URL,"Malformed data URL.")}return Ge(e)}function ze(t,e){switch(t){case E.BASE64:{let r=e.indexOf("-")!==-1,o=e.indexOf("_")!==-1;if(r||o)throw $(t,"Invalid character '"+(r?"-":"_")+"' found: is it base64url encoded?");break}case E.BASE64URL:{let r=e.indexOf("+")!==-1,o=e.indexOf("/")!==-1;if(r||o)throw $(t,"Invalid character '"+(r?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let n;try{n=vt(e)}catch(r){throw r.message.includes("polyfill")?r:$(t,"Invalid character found")}let s=new Uint8Array(n.length);for(let r=0;r<n.length;r++)s[r]=n.charCodeAt(r);return s}var X=class{constructor(e){this.base64=!1,this.contentType=null;let n=e.match(/^data:([^,]+)?,/);if(n===null)throw $(E.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");let s=n[1]||null;s!=null&&(this.base64=Bt(s,";base64"),this.contentType=this.base64?s.substring(0,s.length-7):s),this.rest=e.substring(e.indexOf(",")+1)}};function Lt(t){let e=new X(t);return e.base64?ze(E.BASE64,e.rest):Dt(e.rest)}function Ft(t){return new X(t).contentType}function Bt(t,e){return t.length>=e.length?t.substring(t.length-e.length)===e:!1}var V=class t{constructor(e,n){let s=0,r="";Se(e)?(this.data_=e,s=e.size,r=e.type):e instanceof ArrayBuffer?(n?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),s=this.data_.length):e instanceof Uint8Array&&(n?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),s=e.length),this.size_=s,this.type_=r}size(){return this.size_}type(){return this.type_}slice(e,n){if(Se(this.data_)){let s=this.data_,r=Ct(s,e,n);return r===null?null:new t(r)}else{let s=new Uint8Array(this.data_.buffer,e,n-e);return new t(s,!0)}}static getBlob(...e){if(de()){let n=e.map(s=>s instanceof t?s.data_:s);return new t(Pt.apply(null,n))}else{let n=e.map(i=>he(i)?Nt(E.RAW,i).data:i.data_),s=0;n.forEach(i=>{s+=i.byteLength});let r=new Uint8Array(s),o=0;return n.forEach(i=>{for(let u=0;u<i.length;u++)r[o++]=i[u]}),new t(r,!0)}}uploadData(){return this.data_}};function Mt(t){let e;try{e=JSON.parse(t)}catch{return null}return kt(e)?e:null}function qt(t){if(t.length===0)return null;let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}function $t(t,e){let n=e.split("/").filter(s=>s.length>0).join("/");return t.length===0?n:t+"/"+n}function We(t){let e=t.lastIndexOf("/",t.length-2);return e===-1?t:t.slice(e+1)}function Ht(t,e){return e}var w=class{constructor(e,n,s,r){this.server=e,this.local=n||e,this.writable=!!s,this.xform=r||Ht}},W=null;function jt(t){return!he(t)||t.length<2?t:We(t)}function fe(){if(W)return W;let t=[];t.push(new w("bucket")),t.push(new w("generation")),t.push(new w("metageneration")),t.push(new w("name","fullPath",!0));function e(o,i){return jt(i)}let n=new w("name");n.xform=e,t.push(n);function s(o,i){return i!==void 0?Number(i):i}let r=new w("size");return r.xform=s,t.push(r),t.push(new w("timeCreated")),t.push(new w("updated")),t.push(new w("md5Hash",null,!0)),t.push(new w("cacheControl",null,!0)),t.push(new w("contentDisposition",null,!0)),t.push(new w("contentEncoding",null,!0)),t.push(new w("contentLanguage",null,!0)),t.push(new w("contentType",null,!0)),t.push(new w("metadata","customMetadata",!0)),W=t,W}function Gt(t,e){function n(){let s=t.bucket,r=t.fullPath,o=new k(s,r);return e._makeStorageReference(o)}Object.defineProperty(t,"ref",{get:n})}function zt(t,e,n){let s={};s.type="file";let r=n.length;for(let o=0;o<r;o++){let i=n[o];s[i.local]=i.xform(s,e[i.server])}return Gt(s,t),s}function Wt(t,e,n){let s=Mt(e);return s===null?null:zt(t,s,n)}function pe(t,e){let n={},s=e.length;for(let r=0;r<s;r++){let o=e[r];o.writable&&(n[o.server]=t[o.local])}return JSON.stringify(n)}var x=class{constructor(e,n,s,r){this.url=e,this.method=n,this.handler=s,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}};function O(t){if(!t)throw ce()}function K(t,e){function n(s,r){let o=Wt(t,r,e);return O(o!==null),o}return n}function z(t){function e(n,s){let r;return n.getStatus()===401?n.getErrorText().includes("Firebase App Check token is invalid")?r=ht():r=ct():n.getStatus()===402?r=lt(t.bucket):n.getStatus()===403?r=dt(t.path):r=s,r.status=n.getStatus(),r.serverResponse=s.serverResponse,r}return e}function _e(t){let e=z(t);function n(s,r){let o=e(s,r);return s.getStatus()===404&&(o=ut(t.path)),o.serverResponse=r.serverResponse,o}return n}function Xe(t,e,n){let s=e.fullServerUrl(),r=G(s,t.host,t._protocol),o="GET",i=t.maxOperationRetryTime,u=new x(r,o,K(t,n),i);return u.errorHandler=_e(e),u}function Xt(t,e,n,s){let r=e.fullServerUrl(),o=G(r,t.host,t._protocol),i="PATCH",u=pe(n,s),a={"Content-Type":"application/json; charset=utf-8"},l=t.maxOperationRetryTime,c=new x(o,i,K(t,s),l);return c.headers=a,c.body=u,c.errorHandler=_e(e),c}function Vt(t,e){let n=e.fullServerUrl(),s=G(n,t.host,t._protocol),r="DELETE",o=t.maxOperationRetryTime;function i(a,l){}let u=new x(s,r,i,o);return u.successCodes=[200,204],u.errorHandler=_e(e),u}function Kt(t,e){return t&&t.contentType||e&&e.type()||"application/octet-stream"}function Ve(t,e,n){let s=Object.assign({},n);return s.fullPath=t.path,s.size=e.size(),s.contentType||(s.contentType=Kt(null,e)),s}function Yt(t,e,n,s,r){let o=e.bucketOnlyServerUrl(),i={"X-Goog-Upload-Protocol":"multipart"};function u(){let T="";for(let b=0;b<2;b++)T=T+Math.random().toString().slice(2);return T}let a=u();i["Content-Type"]="multipart/related; boundary="+a;let l=Ve(e,s,r),c=pe(l,n),d="--"+a+`\r
3
3
  Content-Type: application/json; charset=utf-8\r
4
4
  \r
5
5
  `+c+`\r
@@ -7,4 +7,4 @@ Content-Type: application/json; charset=utf-8\r
7
7
  Content-Type: `+l.contentType+`\r
8
8
  \r
9
9
  `,f=`\r
10
- --`+a+"--",_=X.getBlob(d,s,f);if(_===null)throw Me();let h={name:l.fullPath},T=z(o,t.host,t._protocol),m="POST",U=t.maxUploadRetryTime,I=new x(T,m,K(t,n),U);return I.urlParams=h,I.headers=i,I.body=_.uploadData(),I.errorHandler=G(e),I}var L=class{constructor(e,n,s,r){this.current=e,this.total=n,this.finalized=!!s,this.metadata=r||null}};function _e(t,e){let n=null;try{n=t.getResponseHeader("X-Goog-Upload-Status")}catch{O(!1)}return O(!!n&&(e||["active"]).indexOf(n)!==-1),n}function Kt(t,e,n,s,r){let o=e.bucketOnlyServerUrl(),i=We(e,s,r),u={name:i.fullPath},a=z(o,t.host,t._protocol),l="POST",c={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${s.size()}`,"X-Goog-Upload-Header-Content-Type":i.contentType,"Content-Type":"application/json; charset=utf-8"},d=fe(i,n),f=t.maxUploadRetryTime;function _(T){_e(T);let m;try{m=T.getResponseHeader("X-Goog-Upload-URL")}catch{O(!1)}return O(ce(m)),m}let h=new x(a,l,_,f);return h.urlParams=u,h.headers=c,h.body=d,h.errorHandler=G(e),h}function Yt(t,e,n,s){let r={"X-Goog-Upload-Command":"query"};function o(l){let c=_e(l,["active","final"]),d=null;try{d=l.getResponseHeader("X-Goog-Upload-Size-Received")}catch{O(!1)}d||O(!1);let f=Number(d);return O(!isNaN(f)),new L(f,s.size(),c==="final")}let i="POST",u=t.maxUploadRetryTime,a=new x(n,i,o,u);return a.headers=r,a.errorHandler=G(e),a}var Se=256*1024;function Zt(t,e,n,s,r,o,i,u){let a=new L(0,0);if(i?(a.current=i.current,a.total=i.total):(a.current=0,a.total=s.size()),s.size()!==a.total)throw pt();let l=a.total-a.current,c=l;r>0&&(c=Math.min(c,r));let d=a.current,f=d+c,_="";c===0?_="finalize":l===c?_="upload, finalize":_="upload";let h={"X-Goog-Upload-Command":_,"X-Goog-Upload-Offset":`${a.current}`},T=s.slice(d,f);if(T===null)throw Me();function m(b,C){let v=_e(b,["active","final"]),Y=a.current+c,M=s.size(),Z;return v==="final"?Z=K(e,o)(b,C):Z=null,new L(Y,M,v==="final",Z)}let U="POST",I=e.maxUploadRetryTime,R=new x(n,U,m,I);return R.headers=h,R.body=T.uploadData(),R.progressCallback=u||null,R.errorHandler=G(t),R}var y={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function te(t){switch(t){case"running":case"pausing":case"canceling":return y.RUNNING;case"paused":return y.PAUSED;case"success":return y.SUCCESS;case"canceled":return y.CANCELED;case"error":return y.ERROR;default:return y.ERROR}}var oe=class{constructor(e,n,s){if(Rt(e)||n!=null||s!=null)this.next=e,this.error=n??void 0,this.complete=s??void 0;else{let o=e;this.next=o.next,this.error=o.error,this.complete=o.complete}}};function N(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}var Pe=null,ie=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=P.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=P.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=P.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,n,s,r,o){if(this.sent_)throw q("cannot .send() more than once");if(J(e)&&s&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(n,e,!0),o!==void 0)for(let i in o)o.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,o[i].toString());return r!==void 0?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw q("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw q("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw q("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw q("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}},ae=class extends ie{initXhr(){this.xhr_.responseType="text"}};function A(){return Pe?Pe():new ae}var ue=class{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,n,s=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=n,this._metadata=s,this._mappings=de(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=r=>{if(this._request=void 0,this._chunkMultiplier=1,r._codeEquals(p.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{let o=this.isExponentialBackoffExpired();if($e(r.status,[]))if(o)r=Fe();else{this.sleepTime=Math.max(this.sleepTime*2,ot),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=r,this._transition("error")}},this._metadataErrorHandler=r=>{this._request=void 0,r._codeEquals(p.CANCELED)?this.completeTransitions_():(this._error=r,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((r,o)=>{this._resolve=r,this._reject=o,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){let e=this._transferred;return n=>this._updateProgress(e+n)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state==="running"&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([n,s])=>{switch(this._state){case"running":e(n,s);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused");break}})}_createResumable(){this._resolveToken((e,n)=>{let s=Kt(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(s,A,e,n);this._request=r,r.getPromise().then(o=>{this._request=void 0,this._uploadUrl=o,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){let e=this._uploadUrl;this._resolveToken((n,s)=>{let r=Yt(this._ref.storage,this._ref._location,e,this._blob),o=this._ref.storage._makeRequest(r,A,n,s);this._request=o,o.getPromise().then(i=>{i=i,this._request=void 0,this._updateProgress(i.current),this._needToFetchStatus=!1,i.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){let e=Se*this._chunkMultiplier,n=new L(this._transferred,this._blob.size()),s=this._uploadUrl;this._resolveToken((r,o)=>{let i;try{i=Zt(this._ref._location,this._ref.storage,s,this._blob,e,this._mappings,n,this._makeProgressCallback())}catch(a){this._error=a,this._transition("error");return}let u=this._ref.storage._makeRequest(i,A,r,o,!1);this._request=u,u.getPromise().then(a=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(a.current),a.finalized?(this._metadata=a.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){Se*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,n)=>{let s=Ge(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(s,A,e,n);this._request=r,r.getPromise().then(o=>{this._request=void 0,this._metadata=o,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,n)=>{let s=Xt(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(s,A,e,n);this._request=r,r.getPromise().then(o=>{this._request=void 0,this._metadata=o,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){let n=this._transferred;this._transferred=e,this._transferred!==n&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,this._request!==void 0?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":let n=this._state==="paused";this._state=e,n&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=Be(),this._state=e,this._notifyObservers();break;case"error":this._state=e,this._notifyObservers();break;case"success":this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start();break}}get snapshot(){let e=te(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,n,s,r){let o=new oe(n||void 0,s||void 0,r||void 0);return this._addObserver(o),()=>{this._removeObserver(o)}}then(e,n){return this._promise.then(e,n)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){let n=this._observers.indexOf(e);n!==-1&&this._observers.splice(n,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(n=>{this._notifyObserver(n)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(te(this._state)){case y.SUCCESS:N(this._resolve.bind(null,this.snapshot))();break;case y.CANCELED:case y.ERROR:let n=this._reject;N(n.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(te(this._state)){case y.RUNNING:case y.PAUSED:e.next&&N(e.next.bind(e,this.snapshot))();break;case y.SUCCESS:e.complete&&N(e.complete.bind(e))();break;case y.CANCELED:case y.ERROR:e.error&&N(e.error.bind(e,this._error))();break;default:e.error&&N(e.error.bind(e,this._error))()}}resume(){let e=this._state==="paused"||this._state==="pausing";return e&&this._transition("running"),e}pause(){let e=this._state==="running";return e&&this._transition("pausing"),e}cancel(){let e=this._state==="running"||this._state==="pausing";return e&&this._transition("canceling"),e}};var F=class t{constructor(e,n){this._service=e,n instanceof k?this._location=n:this._location=k.makeFromUrl(n,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,n){return new t(e,n)}get root(){let e=new k(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return ze(this._location.path)}get storage(){return this._service}get parent(){let e=Bt(this._location.path);if(e===null)return null;let n=new k(this._location.bucket,e);return new t(this._service,n)}_throwIfRoot(e){if(this._location.path==="")throw gt(e)}};function Jt(t,e,n){return t._throwIfRoot("uploadBytesResumable"),new ue(t,new X(e),n)}function Qt(t){t._throwIfRoot("getMetadata");let e=Ge(t.storage,t._location,de());return t.storage.makeRequestWithTokens(e,A)}function en(t,e){t._throwIfRoot("updateMetadata");let n=Gt(t.storage,t._location,e,de());return t.storage.makeRequestWithTokens(n,A)}function tn(t){t._throwIfRoot("deleteObject");let e=Wt(t.storage,t._location);return t.storage.makeRequestWithTokens(e,A)}function nn(t,e){let n=Mt(t._location.path,e),s=new k(t._location.bucket,n);return new F(t.storage,s)}function sn(t){return/^[A-Za-z]+:\/\//.test(t)}function rn(t,e){return new F(t,e)}function Ve(t,e){if(t instanceof j){let n=t;if(n._bucket==null)throw ft();let s=new F(n,n._bucket);return e!=null?Ve(s,e):s}else return e!==void 0?nn(t,e):t}function on(t,e){if(e&&sn(e)){if(t instanceof j)return rn(t,e);throw ne("To use ref(service, url), the first argument must be a Storage instance.")}else return Ve(t,e)}function Ce(t,e){let n=e?.[Le];return n==null?null:k.makeFromBucketSpec(n,t)}function an(t,e,n,s={}){t.host=`${e}:${n}`;let r=J(e);r&&(be(`https://${t.host}/b`),Re("Storage",!0)),t._isUsingEmulator=!0,t._protocol=r?"https":"http";let{mockUserToken:o}=s;o&&(t._overrideAuthToken=typeof o=="string"?o:we(o,t.app.options.projectId))}var j=class{constructor(e,n,s,r,o,i=!1){this.app=e,this._authProvider=n,this._appCheckProvider=s,this._url=r,this._firebaseVersion=o,this._isUsingEmulator=i,this._bucket=null,this._host=De,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=st,this._maxUploadRetryTime=rt,this._requests=new Set,r!=null?this._bucket=k.makeFromBucketSpec(r,this._host):this._bucket=Ce(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=k.makeFromBucketSpec(this._url,e):this._bucket=Ce(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){Oe("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){Oe("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;let e=this._authProvider.getImmediate({optional:!0});if(e){let n=await e.getToken();if(n!==null)return n.accessToken}return null}async _getAppCheckToken(){if(Ue(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new F(this,e)}_makeRequest(e,n,s,r,o=!0){if(this._deleted)return new se(qe());{let i=xt(e,this._appId,s,r,n,this._firebaseVersion,o,this._isUsingEmulator);return this._requests.add(i),i.getPromise().then(()=>this._requests.delete(i),()=>this._requests.delete(i)),i}}async makeRequestWithTokens(e,n){let[s,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,n,s,r).getPromise()}},ve="@firebase/storage",Ne="0.14.0";var Xe="storage";function Ke(t,e,n){return t=S(t),Jt(t,e,n)}function Ye(t){return t=S(t),Qt(t)}function Ze(t,e){return t=S(t),en(t,e)}function Je(t){return t=S(t),tn(t)}function B(t,e){return t=S(t),on(t,e)}function Un(t=xe(),e){t=S(t);let s=Ee(t,Xe).getImmediate({identifier:e}),r=me("storage");return r&&un(s,...r),s}function un(t,e,n,s={}){an(t,e,n,s)}function ln(t,{instanceIdentifier:e}){let n=t.getProvider("app").getImmediate(),s=t.getProvider("auth-internal"),r=t.getProvider("app-check-internal");return new j(n,s,r,e,Ie)}function cn(){ke(new ye(Xe,ln,"PUBLIC").setMultipleInstances(!0)),Q(ve,Ne,""),Q(ve,Ne,"esm2020")}cn();var Qe=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],et=[...Qe,"svg"],tt=["mp4","webm"],hn="https://lh3.googleusercontent.com/";async function Sn(t,e){let n=window.__ROOT_CTX.rootConfig.projectId,s=await wn(t),r=ge(t.name),o=dn(t,s,r,e),i=`${n}/uploads/${o}`,u=B(window.firebase.storage,i);if(e?.checkExists&&await fn(i))throw new Error(`File already exists: ${i}`);let a=Ke(u,t),l=-1,c=Date.now();return await new Promise((d,f)=>{let _=setInterval(()=>{Date.now()-c>1e4&&(clearInterval(_),f(new Error("Upload stalled: no progress for 10 seconds")))},1e3);a.on("state_changed",h=>{h.bytesTransferred>0&&clearInterval(_),console.log(`uploading ${t.name}: ${h.bytesTransferred} / ${h.totalBytes} bytes`),h.bytesTransferred!==l&&(l=h.bytesTransferred,c=Date.now())},h=>{clearInterval(_),f(h)},()=>{console.log(`uploaded ${i}`),clearInterval(_),d(a.snapshot)})}),pn(u,t,r,e)}async function Pn(t){let e=window.firebase.storage,n;t.startsWith("/")?n=B(e,`gs://${t.substring(1)}`):t.startsWith("http")?n=B(e,t):n=B(e,t),await Je(n),console.log(`deleted ${t}`)}function dn(t,e,n,s){return s?.namingMode==="clean"?t.name:s?.namingMode==="hash-path"||s?.preserveFilename?`${e}/${t.name}`:`${e}.${n}`}async function fn(t){let e=B(window.firebase.storage,t);try{return await Ye(e),!0}catch(n){if(n.code==="storage/object-not-found")return!1;throw n}}async function pn(t,e,n,s){let r={};r.filename=e.name,r.uploadedBy=window.firebase.user.email||"unknown",r.uploadedAt=String(Math.floor(new Date().getTime()));let o=`/${t.bucket}/${t.fullPath}`,i=`https://storage.googleapis.com${o}`;if(et.includes(n)){let a=await mn(e);if(r.width=a.width,r.height=a.height,!s?.disableGci&&Qe.includes(n)){let l=await gn(o);l&&(r.gcsPath=o,i=l)}r.canvasBgColor=await Tn(e)?"dark":"light"}else if(tt.includes(n)){let a=await bn(i);r.width=a.width,r.height=a.height,console.log("video dimensions:",a)}let u=s?.cacheControl||"public, max-age=31536000";return await Ze(t,{cacheControl:u,customMetadata:Rn(r)}),console.log("updated meta data: ",r),{...r,src:i}}function ge(t){return _n(t.split(".").at(-1)||"")}function _n(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function gn(t){let e=window.__ROOT_CTX.rootConfig.gci;if(!e)return"";let n=new URLSearchParams({gcs:t}),s=`${e}/_/serving_url?${n.toString()}`,r=await window.fetch(s);if(r.status!==200){let i=await r.text();throw console.error(`failed to get gci url: ${s}`),console.error(i),new Error("failed to get gci url")}return(await r.json()).servingUrl}async function mn(t){return new Promise((e,n)=>{let s=new FileReader;s.onload=()=>{let r=new Image;r.onload=()=>{e({width:r.width,height:r.height})},r.onerror=n,r.src=String(s.result)},s.onerror=n,s.readAsDataURL(t)})}async function bn(t){return new Promise((e,n)=>{let s=document.createElement("video");s.addEventListener("loadedmetadata",()=>{let r={width:s.videoWidth,height:s.videoHeight};e(r),document.body.removeChild(s)},!1),s.addEventListener("error",()=>{n(new Error("Failed to load video metadata")),document.body.removeChild(s)},!1),s.className="sr-only",s.src=t,s.preload="metadata",document.body.appendChild(s)})}async function wn(t){let e=await t.arrayBuffer(),n=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}function Rn(t){let e={};return Object.entries(t).forEach(([n,s])=>{t[n]=String(s).trim()}),e}function Cn(t){if(!t)return!1;if(nt(t)||t.startsWith("data:image/")||t.startsWith("blob:"))return!0;let e=ge(t);return et.includes(e)}function nt(t){return t?t.startsWith(hn):!1}function vn(t){if(!t)return!1;let e=ge(t);return tt.includes(e)}function Nn(t){return nt(t)?t.split("=")[0]+"=s0-d":t}function Tn(t){return new Promise((e,n)=>{let s=new Image,r=new FileReader;r.onload=()=>{s.src=r.result},s.onload=()=>{let o=document.createElement("canvas"),i=o.getContext("2d");o.width=s.width,o.height=s.height,i.drawImage(s,0,0,o.width,o.height);let{data:u}=i.getImageData(0,0,o.width,o.height),a=0,l=0,c=0,d=0,f=Math.floor(u.length/4e4)*4;f<4&&(f=4);for(let h=0;h<u.length;h+=f)u[h+3]<128||(a+=u[h],l+=u[h+1],c+=u[h+2],d++);if(d===0){e(!1);return}let _=.299*(a/d)+.587*(l/d)+.114*(c/d);e(_>128)},s.onerror=n,r.onerror=n,r.readAsDataURL(t)})}export{Un as a,Qe as b,et as c,tt as d,hn as e,Sn as f,Pn as g,fn as h,ge as i,Cn as j,nt as k,vn as l,Nn as m,Tn as n};
10
+ --`+a+"--",_=V.getBlob(d,s,f);if(_===null)throw $e();let h={name:l.fullPath},R=G(o,t.host,t._protocol),m="POST",U=t.maxUploadRetryTime,I=new x(R,m,K(t,n),U);return I.urlParams=h,I.headers=i,I.body=_.uploadData(),I.errorHandler=z(e),I}var L=class{constructor(e,n,s,r){this.current=e,this.total=n,this.finalized=!!s,this.metadata=r||null}};function ge(t,e){let n=null;try{n=t.getResponseHeader("X-Goog-Upload-Status")}catch{O(!1)}return O(!!n&&(e||["active"]).indexOf(n)!==-1),n}function Zt(t,e,n,s,r){let o=e.bucketOnlyServerUrl(),i=Ve(e,s,r),u={name:i.fullPath},a=G(o,t.host,t._protocol),l="POST",c={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${s.size()}`,"X-Goog-Upload-Header-Content-Type":i.contentType,"Content-Type":"application/json; charset=utf-8"},d=pe(i,n),f=t.maxUploadRetryTime;function _(R){ge(R);let m;try{m=R.getResponseHeader("X-Goog-Upload-URL")}catch{O(!1)}return O(he(m)),m}let h=new x(a,l,_,f);return h.urlParams=u,h.headers=c,h.body=d,h.errorHandler=z(e),h}function Jt(t,e,n,s){let r={"X-Goog-Upload-Command":"query"};function o(l){let c=ge(l,["active","final"]),d=null;try{d=l.getResponseHeader("X-Goog-Upload-Size-Received")}catch{O(!1)}d||O(!1);let f=Number(d);return O(!isNaN(f)),new L(f,s.size(),c==="final")}let i="POST",u=t.maxUploadRetryTime,a=new x(n,i,o,u);return a.headers=r,a.errorHandler=z(e),a}var Ce=256*1024;function Qt(t,e,n,s,r,o,i,u){let a=new L(0,0);if(i?(a.current=i.current,a.total=i.total):(a.current=0,a.total=s.size()),s.size()!==a.total)throw gt();let l=a.total-a.current,c=l;r>0&&(c=Math.min(c,r));let d=a.current,f=d+c,_="";c===0?_="finalize":l===c?_="upload, finalize":_="upload";let h={"X-Goog-Upload-Command":_,"X-Goog-Upload-Offset":`${a.current}`},R=s.slice(d,f);if(R===null)throw $e();function m(b,C){let v=ge(b,["active","final"]),Z=a.current+c,M=s.size(),J;return v==="final"?J=K(e,o)(b,C):J=null,new L(Z,M,v==="final",J)}let U="POST",I=e.maxUploadRetryTime,T=new x(n,U,m,I);return T.headers=h,T.body=R.uploadData(),T.progressCallback=u||null,T.errorHandler=z(t),T}var y={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function ne(t){switch(t){case"running":case"pausing":case"canceling":return y.RUNNING;case"paused":return y.PAUSED;case"success":return y.SUCCESS;case"canceled":return y.CANCELED;case"error":return y.ERROR;default:return y.ERROR}}var ie=class{constructor(e,n,s){if(yt(e)||n!=null||s!=null)this.next=e,this.error=n??void 0,this.complete=s??void 0;else{let o=e;this.next=o.next,this.error=o.error,this.complete=o.complete}}};function N(t){return(...e)=>{Promise.resolve().then(()=>t(...e))}}var ve=null,ae=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=P.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=P.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=P.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,n,s,r,o){if(this.sent_)throw q("cannot .send() more than once");if(Q(e)&&s&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(n,e,!0),o!==void 0)for(let i in o)o.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,o[i].toString());return r!==void 0?this.xhr_.send(r):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw q("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw q("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw q("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw q("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}},ue=class extends ae{initXhr(){this.xhr_.responseType="text"}};function A(){return ve?ve():new ue}var le=class{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,n,s=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=n,this._metadata=s,this._mappings=fe(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=r=>{if(this._request=void 0,this._chunkMultiplier=1,r._codeEquals(p.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{let o=this.isExponentialBackoffExpired();if(je(r.status,[]))if(o)r=Me();else{this.sleepTime=Math.max(this.sleepTime*2,at),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=r,this._transition("error")}},this._metadataErrorHandler=r=>{this._request=void 0,r._codeEquals(p.CANCELED)?this.completeTransitions_():(this._error=r,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((r,o)=>{this._resolve=r,this._reject=o,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){let e=this._transferred;return n=>this._updateProgress(e+n)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state==="running"&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([n,s])=>{switch(this._state){case"running":e(n,s);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused");break}})}_createResumable(){this._resolveToken((e,n)=>{let s=Zt(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(s,A,e,n);this._request=r,r.getPromise().then(o=>{this._request=void 0,this._uploadUrl=o,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){let e=this._uploadUrl;this._resolveToken((n,s)=>{let r=Jt(this._ref.storage,this._ref._location,e,this._blob),o=this._ref.storage._makeRequest(r,A,n,s);this._request=o,o.getPromise().then(i=>{i=i,this._request=void 0,this._updateProgress(i.current),this._needToFetchStatus=!1,i.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){let e=Ce*this._chunkMultiplier,n=new L(this._transferred,this._blob.size()),s=this._uploadUrl;this._resolveToken((r,o)=>{let i;try{i=Qt(this._ref._location,this._ref.storage,s,this._blob,e,this._mappings,n,this._makeProgressCallback())}catch(a){this._error=a,this._transition("error");return}let u=this._ref.storage._makeRequest(i,A,r,o,!1);this._request=u,u.getPromise().then(a=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(a.current),a.finalized?(this._metadata=a.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){Ce*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,n)=>{let s=Xe(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(s,A,e,n);this._request=r,r.getPromise().then(o=>{this._request=void 0,this._metadata=o,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,n)=>{let s=Yt(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(s,A,e,n);this._request=r,r.getPromise().then(o=>{this._request=void 0,this._metadata=o,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){let n=this._transferred;this._transferred=e,this._transferred!==n&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,this._request!==void 0?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":let n=this._state==="paused";this._state=e,n&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=qe(),this._state=e,this._notifyObservers();break;case"error":this._state=e,this._notifyObservers();break;case"success":this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start();break}}get snapshot(){let e=ne(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,n,s,r){let o=new ie(n||void 0,s||void 0,r||void 0);return this._addObserver(o),()=>{this._removeObserver(o)}}then(e,n){return this._promise.then(e,n)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){let n=this._observers.indexOf(e);n!==-1&&this._observers.splice(n,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(n=>{this._notifyObserver(n)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(ne(this._state)){case y.SUCCESS:N(this._resolve.bind(null,this.snapshot))();break;case y.CANCELED:case y.ERROR:let n=this._reject;N(n.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(ne(this._state)){case y.RUNNING:case y.PAUSED:e.next&&N(e.next.bind(e,this.snapshot))();break;case y.SUCCESS:e.complete&&N(e.complete.bind(e))();break;case y.CANCELED:case y.ERROR:e.error&&N(e.error.bind(e,this._error))();break;default:e.error&&N(e.error.bind(e,this._error))()}}resume(){let e=this._state==="paused"||this._state==="pausing";return e&&this._transition("running"),e}pause(){let e=this._state==="running";return e&&this._transition("pausing"),e}cancel(){let e=this._state==="running"||this._state==="pausing";return e&&this._transition("canceling"),e}};var F=class t{constructor(e,n){this._service=e,n instanceof k?this._location=n:this._location=k.makeFromUrl(n,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,n){return new t(e,n)}get root(){let e=new k(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return We(this._location.path)}get storage(){return this._service}get parent(){let e=qt(this._location.path);if(e===null)return null;let n=new k(this._location.bucket,e);return new t(this._service,n)}_throwIfRoot(e){if(this._location.path==="")throw bt(e)}};function en(t,e,n){return t._throwIfRoot("uploadBytesResumable"),new le(t,new V(e),n)}function tn(t){t._throwIfRoot("getMetadata");let e=Xe(t.storage,t._location,fe());return t.storage.makeRequestWithTokens(e,A)}function nn(t,e){t._throwIfRoot("updateMetadata");let n=Xt(t.storage,t._location,e,fe());return t.storage.makeRequestWithTokens(n,A)}function sn(t){t._throwIfRoot("deleteObject");let e=Vt(t.storage,t._location);return t.storage.makeRequestWithTokens(e,A)}function rn(t,e){let n=$t(t._location.path,e),s=new k(t._location.bucket,n);return new F(t.storage,s)}function on(t){return/^[A-Za-z]+:\/\//.test(t)}function an(t,e){return new F(t,e)}function Ke(t,e){if(t instanceof j){let n=t;if(n._bucket==null)throw _t();let s=new F(n,n._bucket);return e!=null?Ke(s,e):s}else return e!==void 0?rn(t,e):t}function un(t,e){if(e&&on(e)){if(t instanceof j)return an(t,e);throw se("To use ref(service, url), the first argument must be a Storage instance.")}else return Ke(t,e)}function Ne(t,e){let n=e?.[Be];return n==null?null:k.makeFromBucketSpec(n,t)}function ln(t,e,n,s={}){t.host=`${e}:${n}`;let r=Q(e);r&&(Te(`https://${t.host}/b`),ye("Storage",!0)),t._isUsingEmulator=!0,t._protocol=r?"https":"http";let{mockUserToken:o}=s;o&&(t._overrideAuthToken=typeof o=="string"?o:Re(o,t.app.options.projectId))}var j=class{constructor(e,n,s,r,o,i=!1){this.app=e,this._authProvider=n,this._appCheckProvider=s,this._url=r,this._firebaseVersion=o,this._isUsingEmulator=i,this._bucket=null,this._host=Fe,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=ot,this._maxUploadRetryTime=it,this._requests=new Set,r!=null?this._bucket=k.makeFromBucketSpec(r,this._host):this._bucket=Ne(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=k.makeFromBucketSpec(this._url,e):this._bucket=Ne(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){Pe("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){Pe("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;let e=this._authProvider.getImmediate({optional:!0});if(e){let n=await e.getToken();if(n!==null)return n.accessToken}return null}async _getAppCheckToken(){if(xe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new F(this,e)}_makeRequest(e,n,s,r,o=!0){if(this._deleted)return new re(He());{let i=Ot(e,this._appId,s,r,n,this._firebaseVersion,o,this._isUsingEmulator);return this._requests.add(i),i.getPromise().then(()=>this._requests.delete(i),()=>this._requests.delete(i)),i}}async makeRequestWithTokens(e,n){let[s,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,n,s,r).getPromise()}},De="@firebase/storage",Le="0.14.0";var Ye="storage";function Ze(t,e,n){return t=S(t),en(t,e,n)}function Je(t){return t=S(t),tn(t)}function Qe(t,e){return t=S(t),nn(t,e)}function et(t){return t=S(t),sn(t)}function B(t,e){return t=S(t),un(t,e)}function xn(t=Oe(),e){t=S(t);let s=Ie(t,Ye).getImmediate({identifier:e}),r=we("storage");return r&&cn(s,...r),s}function cn(t,e,n,s={}){ln(t,e,n,s)}function hn(t,{instanceIdentifier:e}){let n=t.getProvider("app").getImmediate(),s=t.getProvider("auth-internal"),r=t.getProvider("app-check-internal");return new j(n,s,r,e,Ae)}function dn(){Ue(new Ee(Ye,hn,"PUBLIC").setMultipleInstances(!0)),ee(De,Le,""),ee(De,Le,"esm2020")}dn();var tt=["bmp","gif","ico","jpeg","jpg","png","tiff","webp"],nt=[...tt,"svg"],fn=["avif"],st=[...nt,...fn],be=["mp4","webm"],pn="https://lh3.googleusercontent.com/";async function Cn(t,e){let n=window.__ROOT_CTX.rootConfig.projectId,s=await Rn(t),r=Y(t.name),o=_n(t,s,r,e),i=`${n}/uploads/${o}`,u=B(window.firebase.storage,i);if(e?.checkExists&&await gn(i))throw new Error(`File already exists: ${i}`);let a=Ze(u,t),l=-1,c=Date.now();return await new Promise((d,f)=>{let _=setInterval(()=>{Date.now()-c>1e4&&(clearInterval(_),f(new Error("Upload stalled: no progress for 10 seconds")))},1e3);a.on("state_changed",h=>{h.bytesTransferred>0&&clearInterval(_),console.log(`uploading ${t.name}: ${h.bytesTransferred} / ${h.totalBytes} bytes`),h.bytesTransferred!==l&&(l=h.bytesTransferred,c=Date.now())},h=>{clearInterval(_),f(h)},()=>{console.log(`uploaded ${i}`),clearInterval(_),d(a.snapshot)})}),mn(u,t,r,e)}async function vn(t){let e=window.firebase.storage,n;t.startsWith("/")?n=B(e,`gs://${t.substring(1)}`):t.startsWith("http")?n=B(e,t):n=B(e,t),await et(n),console.log(`deleted ${t}`)}function _n(t,e,n,s){return s?.namingMode==="clean"?t.name:s?.namingMode==="hash-path"||s?.preserveFilename?`${e}/${t.name}`:`${e}.${n}`}async function gn(t){let e=B(window.firebase.storage,t);try{return await Je(e),!0}catch(n){if(n.code==="storage/object-not-found")return!1;throw n}}async function mn(t,e,n,s){let r={};r.filename=e.name,r.uploadedBy=window.firebase.user.email||"unknown",r.uploadedAt=String(Math.floor(new Date().getTime()));let o=`/${t.bucket}/${t.fullPath}`,i=`https://storage.googleapis.com${o}`;if(st.includes(n)){let a=await wn(e);if(r.width=a.width,r.height=a.height,!s?.disableGci&&tt.includes(n)){let l=await bn(o);l&&(r.gcsPath=o,i=l)}r.canvasBgColor=await kn(e)?"dark":"light"}else if(be.includes(n)){let a=await Tn(i);r.width=a.width,r.height=a.height,console.log("video dimensions:",a)}let u=s?.cacheControl||"public, max-age=31536000";return await Qe(t,{cacheControl:u,customMetadata:yn(r)}),console.log("updated meta data: ",r),{...r,src:i}}function Y(t){return me(t.split(".").at(-1)||"")}function me(t){let e=String(t).toLowerCase();return e==="jpeg"&&(e="jpg"),e}async function bn(t){let e=window.__ROOT_CTX.rootConfig.gci;if(!e)return"";let n=new URLSearchParams({gcs:t}),s=`${e}/_/serving_url?${n.toString()}`,r=await window.fetch(s);if(r.status!==200){let i=await r.text();throw console.error(`failed to get gci url: ${s}`),console.error(i),new Error("failed to get gci url")}return(await r.json()).servingUrl}async function wn(t){return new Promise((e,n)=>{let s=new FileReader;s.onload=()=>{let r=new Image;r.onload=()=>{e({width:r.width,height:r.height})},r.onerror=n,r.src=String(s.result)},s.onerror=n,s.readAsDataURL(t)})}async function Tn(t){return new Promise((e,n)=>{let s=document.createElement("video");s.addEventListener("loadedmetadata",()=>{let r={width:s.videoWidth,height:s.videoHeight};e(r),document.body.removeChild(s)},!1),s.addEventListener("error",()=>{n(new Error("Failed to load video metadata")),document.body.removeChild(s)},!1),s.className="sr-only",s.src=t,s.preload="metadata",document.body.appendChild(s)})}async function Rn(t){let e=await t.arrayBuffer(),n=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}function yn(t){let e={};return Object.entries(t).forEach(([n,s])=>{t[n]=String(s).trim()}),e}function Nn(t){if(!t)return!1;if(rt(t)||t.startsWith("data:image/")||t.startsWith("blob:"))return!0;let e=Y(t);return st.includes(e)}function rt(t){return t?t.startsWith(pn):!1}function Dn(t){if(!t)return!1;let e=Y(t);return be.includes(e)}function Ln(t,e){if(!e||e.length===0)return!0;let n=Y(t);return e.some(s=>{let r=String(s).toLowerCase().trim();if(r==="*"||r==="*/*"||r===`*/${n}`)return!0;if(r.endsWith("/*")){let o=r.split("/")[0];return o==="image"?nt.includes(n):o==="video"?be.includes(n):!1}return r.includes("/")?me(r.split("/")[1].split("+")[0])===n:me(r.replace(/^\./,""))===n})}function Fn(t){return rt(t)?t.split("=")[0]+"=s0-d":t}function kn(t){return new Promise((e,n)=>{let s=new Image,r=new FileReader;r.onload=()=>{s.src=r.result},s.onload=()=>{let o=document.createElement("canvas"),i=o.getContext("2d");o.width=s.width,o.height=s.height,i.drawImage(s,0,0,o.width,o.height);let{data:u}=i.getImageData(0,0,o.width,o.height),a=0,l=0,c=0,d=0,f=Math.floor(u.length/4e4)*4;f<4&&(f=4);for(let h=0;h<u.length;h+=f)u[h+3]<128||(a+=u[h],l+=u[h+1],c+=u[h+2],d++);if(d===0){e(!1);return}let _=.299*(a/d)+.587*(l/d)+.114*(c/d);e(_>128)},s.onerror=n,r.onerror=n,r.readAsDataURL(t)})}export{xn as a,tt as b,nt as c,fn as d,st as e,be as f,pn as g,Cn as h,vn as i,gn as j,Y as k,Nn as l,rt as m,Dn as n,Ln as o,Fn as p,kn as q};
@@ -0,0 +1 @@
1
+ import{k as z}from"./chunk-D3UIZHRK.js";import{c as T}from"./chunk-JDW4UORS.js";import{C as _}from"./chunk-TFB3VGWP.js";import{f as l}from"./chunk-KRNQ6L35.js";import{a as f,b as w,c as s,g as b,i as k,n as v,o as j,q as u,t as R,u as c,v as y,x as I}from"./chunk-VD6G5NV4.js";var O=["agile","airy","alert","amber","amused","ancient","aqua","arctic","astral","autumn","avid","azure","balmy","beige","big","bitter","black","blazing","blissful","blooming","blue","bold","bouncy","brainy","brave","breezy","bright","brisk","broad","bronze","brown","bubbly","busy","calm","candid","careful","caring","charming","cheerful","cherry","chilly","chipper","classic","clean","clear","clever","cloudy","coastal","cobalt","cold","cool","copper","coral","cosmic","cosy","cozy","crafty","creamy","crimson","crisp","cuddly","curious","dandy","dapper","daring","dark","dawn","dazzling","dear","deep","deft","delicate","dewy","dizzy","dotted","dreamy","driven","dry","dusky","dusty","eager","early","earnest","earthy","eastern","easy","ebony","elated","electric","elegant","emerald","empty","epic","even","every","faint","fair","falling","famous","fancy","fast","feisty","festive","fierce","fiery","fine","firm","flat","floral","flowing","fluffy","foggy","fond","forest","fragrant","fresh","friendly","frisky","frosty","funky","funny","fuzzy","gallant","gentle","giant","gilded","glad","gleaming","glossy","glowing","gold","golden","good","graceful","grand","grassy","gray","green","groovy","gusty","handy","happy","hardy","hazy","hearty","heavy","helpful","heroic","hidden","high","holy","honest","honeyed","hopeful","humble","humming","hushed","icy","ideal","idle","indigo","inky","iron","ivory","jade","jaunty","jazzy","jolly","jovial","joyful","jubilant","juicy","jumpy","keen","kind","kindly","lacy","late","lazy","leafy","lemon","light","limber","lime","linen","little","lively","lone","long","loud","lovely","loyal","lucid","lucky","luminous","lunar","lush","magenta","magic","majestic","mango","marble","maritime","maroon","massive","mauve","mellow","merry","mighty","mild","milky","mindful","minty","misty","mocha","modest","morning","mossy","muddy","mysterious","mythic","narrow","navy","neat","neon","new","nimble","noble","noisy","noon","northern","nosy","nutty","oaken","oceanic","odd","old","olive","onyx","opal","open","orange","orderly","pale","pastel","patient","peaceful","peach","peachy","pearly","pebbly","peppy","perky","pink","placid","plain","playful","pleasant","plucky","plum","plush","polar","polite","prime","pristine","proud","pure","purple","quaint","quick","quiet","quirky","radiant","rapid","rare","raven","ready","red","regal","restless","rich","rolling","rosy","rough","round","royal","ruby","rugged","rumbling","russet","rustic","sable","safe","sage","salty","sandy","sapphire","savvy","scarlet","scenic","secret","sepia","serene","shaggy","sharp","shimmering","shiny","short","shrewd","shy","silent","silky","silly","silver","simple","sleek","sleepy","slim","slow","small","smart","smoky","smooth","snappy","snowy","soaring","soft","solar","solid","southern","sparkly","speedy","spicy","spiffy","spotted","spry","square","starry","steady","steel","stellar","sticky","still","stony","stormy","striped","strong","sturdy","subtle","sunlit","sunny","super","supreme","swank","sweet","swift","tame","tan","tangy","tart","teal","tender","thin","thirsty","thriving","tidal","tidy","tiny","tireless","toasty","topaz","tough","tranquil","trim","tropical","true","twinkly","umber","upbeat","urban","useful","valiant","vast","velvet","verdant","vernal","vibrant","vintage","violet","vivid","wandering","warm","watchful","wavy","wee","western","whimsical","whispering","white","wholesome","wild","winding","windy","winter","wintry","wise","witty","wondrous","woody","wool","yellow","young","youthful","zany","zealous","zen","zesty","zippy"],A=["acorn","almond","alpaca","anchor","antler","apple","apricot","arrow","aspen","aurora","autumn","avocado","badger","bagel","bamboo","banana","basil","bay","bayou","beach","bear","bee","beetle","bell","berry","birch","bird","biscuit","bison","blossom","bluff","boat","bobcat","bonfire","book","boot","bottle","boulder","branch","brass","breeze","bridge","brook","broom","brunch","bubble","bucket","bud","buffalo","bug","bunny","burrow","butter","button","cabin","cactus","cake","camel","canary","candle","canyon","cape","caravan","cardinal","carrot","cascade","cashew","castle","cat","cave","cedar","chair","cherry","chestnut","chickpea","chime","cinnamon","citadel","cliff","cloud","clove","clover","cocoa","comet","compass","condor","cookie","coral","cottage","cotton","cove","coyote","crane","crayon","creek","cricket","crocus","crow","crumpet","crystal","cup","cupcake","currant","cypress","daffodil","dahlia","daisy","dawn","deer","delta","desert","dew","diamond","dingo","dock","dogwood","dolphin","donut","dove","dragon","drift","drizzle","drum","duck","dumpling","dune","eagle","echo","eclipse","eel","egg","elder","elephant","elk","ember","ermine","estuary","evergreen","falcon","fawn","feather","fennel","fern","ferret","field","fig","finch","fir","firefly","fish","fjord","flame","flamingo","flask","flax","fleece","flicker","flower","flute","fog","forest","fossil","fountain","fox","frog","frost","galaxy","garden","gazelle","gecko","gem","geyser","ginger","glacier","glade","glen","globe","glow","goat","goose","gorge","gourd","granite","grape","grass","grotto","grove","gull","hammock","harbor","hare","harp","harvest","hat","hawk","haystack","hazel","hearth","heather","hedge","heron","hibiscus","hickory","hill","hollow","honey","horizon","horse","hummingbird","ibis","iceberg","icicle","inlet","iris","island","ivy","jackal","jacket","jade","jaguar","jam","jar","jasmine","jay","jelly","jetty","juniper","kayak","kelp","kestrel","kettle","key","kingfisher","kite","kitten","kiwi","knoll","koala","ladybug","lagoon","lake","lamp","lantern","lark","lava","lavender","leaf","ledge","lemon","lemur","leopard","lichen","lighthouse","lilac","lily","lime","lion","llama","lobster","log","loon","lotus","lynx","lyric","magnet","manatee","mango","mangrove","maple","marble","marigold","marlin","marsh","meadow","melody","melon","mermaid","mesa","meteor","minnow","mint","mirage","mist","mitten","mole","monkey","moon","moose","morel","mosaic","moss","moth","mountain","mouse","muffin","mushroom","mussel","narwhal","nautilus","nectar","needle","nest","nettle","newt","nightingale","nimbus","noodle","north","note","nutmeg","oak","oasis","oats","ocean","ocelot","octopus","olive","onion","opal","orange","orca","orchid","oriole","osprey","otter","owl","oyster","paddle","palm","panda","pansy","panther","papaya","paper","parrot","parsley","partridge","pasture","path","peach","peacock","pear","pebble","pecan","pelican","penguin","peony","pepper","petal","petunia","pheasant","phoenix","pie","pigeon","pine","pineapple","pistachio","planet","plateau","plover","plum","pond","pony","poppy","porpoise","pouch","prairie","pretzel","primrose","puffin","pumpkin","quail","quartz","queen","quill","quince","quokka","rabbit","raccoon","radish","rain","rainbow","rapids","raspberry","raven","redwood","reef","reel","reindeer","rhino","ribbon","ridge","river","road","robin","rock","rooster","rose","rosemary","rowan","rye","saffron","sage","salmon","sand","sapphire","satellite","savanna","scallop","scarf","sea","seagull","seal","seed","sequoia","sesame","shark","shell","shore","shrimp","silk","silo","sky","skylark","sleet","snail","snake","snow","sock","sorbet","spark","sparrow","spider","spire","spoon","spring","sprout","spruce","squirrel","star","starfish","starling","stone","stork","storm","stream","summer","sun","sundial","sunflower","swan","swift","sycamore","tadpole","tamarind","tangerine","tea","teal","tern","terrace","thicket","thistle","thrush","thunder","tide","tiger","timber","toad","toffee","tooth","topaz","tortoise","totem","toucan","tower","tractor","trail","tree","trout","truffle","tugboat","tulip","tundra","turnip","turtle","twig","twilight","umbrella","unicorn","urchin","valley","vanilla","vine","violet","vista","volcano","voyage","vulture","wagon","walnut","walrus","wasp","water","waterfall","wave","whale","wharf","wheat","whisker","wildcat","wildflower","willow","wind","window","winter","wisteria","wolf","wombat","wood","wren","yak","yam","yarrow","yew","yucca","zebra","zephyr","zinnia","zucchini"];var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",S="YYYYMMDD";function D(e,r){let a=r?.now??new Date,o=r?.random??Math.random,t=e.replace(/\{([^{}]+?)\}/g,(n,d)=>{let[p,g]=q(d);switch(p){case"date":return E(a,g||S);case"adjective":return C(O,o);case"noun":return C(A,o);case"random":return M(Y(g,6),o);default:return n}});return T(t.toLowerCase())}function q(e){let r=e.indexOf(":");return r===-1?[e.trim(),void 0]:[e.slice(0,r).trim(),e.slice(r+1)]}function Y(e,r){if(!e)return r;let a=parseInt(e,10);return Number.isFinite(a)&&a>0?a:r}function C(e,r){return e[Math.floor(r()*e.length)]}function M(e,r){let a=[];for(let o=0;o<e;o++)a.push(x.charAt(Math.floor(r()*x.length)));return a.join("")}function E(e,r){let a={YYYY:String(e.getFullYear()),YY:String(e.getFullYear()).slice(-2),MM:m(e.getMonth()+1),DD:m(e.getDate()),HH:m(e.getHours()),mm:m(e.getMinutes()),ss:m(e.getSeconds())};return r.replace(/YYYY|YY|MM|DD|HH|mm|ss/g,o=>a[o]??o)}function m(e){return e<10?`0${e}`:String(e)}var i="Releases";async function V(e,r){if(!e)throw new Error("missing data source id");let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await R(o,async n=>{if((await n.get(t)).exists())throw new Error(`release exists: ${e}`);await n.set(t,{...r,id:e,createdAt:y(),createdBy:window.firebase.user.email})}),l("release.create",{metadata:{releaseId:e}})}async function G(){let e=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,a=w(r,"Projects",e,i),o=b(a,k("createdAt","desc")),t=await j(o),n=[];return t.forEach(d=>{n.push(d.data())}),n}async function h(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e),t=await v(o);return t.exists()?t.data():null}async function K(e,r){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,r),l("release.save",{metadata:{releaseId:e}})}async function Q(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:y(),archivedBy:window.firebase.user.email}),l("release.archive",{metadata:{releaseId:e}})}async function W(e){let r=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=s(a,"Projects",r,i,e);await u(o,{archivedAt:c(),archivedBy:c()}),l("release.unarchive",{metadata:{releaseId:e}})}async function Z(e){let r=await h(e);if(!r)throw new Error(`release not found: ${e}`);if(r.archivedAt)throw new Error(`release is archived: ${e}`);let a=r.docIds||[],o=r.dataSourceIds||[];if(a.length===0&&o.length===0)throw new Error(`no docs or data sources to publish for release: ${e}`);let t=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,d=s(n,"Projects",t,i,e),p=I(n);p.update(d,{publishedAt:y(),publishedBy:window.firebase.user.email,scheduledAt:c(),scheduledBy:c()}),o.length>0&&await z(o,{batch:p,commitBatch:!1}),await _(a,{batch:p,releaseId:e,publishMessage:r.description}),console.log(`published release: ${e}`);let g={releaseId:e,docIds:a,dataSourceIds:o};r.description&&(g.publishMessage=r.description),l("release.publish",{metadata:g})}async function ee(e,r){let a=await h(e);if(!a)throw new Error(`release not found: ${e}`);if(a.archivedAt)throw new Error(`release is archived: ${e}`);typeof r=="number"&&(r=f.fromMillis(r));let o=window.__ROOT_CTX.rootConfig.projectId,t=window.firebase.db,n=s(t,"Projects",o,i,e);await u(n,{scheduledAt:r,scheduledBy:window.firebase.user.email}),l("release.publish",{metadata:{releaseId:e,scheduledAt:r.toMillis()}})}function re(){return D("{date}-{adjective}-{noun}")}async function ae(e){if(!await h(e))throw new Error(`release not found: ${e}`);let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,t=s(o,"Projects",a,i,e);await u(t,{scheduledAt:c(),scheduledBy:c()}),l("release.unschedule",{metadata:{releaseId:e}})}export{D as a,V as b,G as c,h as d,K as e,Q as f,W as g,Z as h,ee as i,re as j,ae as k};
@@ -1 +1 @@
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};
1
+ import{a as C}from"./chunk-FJLNXXE3.js";import{f as p}from"./chunk-YLSRRNSE.js";import{Fb as u,Ga as o,U as _,g,j as b}from"./chunk-LROR6N3B.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 +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-4CUWZQXT.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};
1
+ import{c as x,n as y}from"./chunk-VD6G5NV4.js";import{a as d,c as g,j as R}from"./chunk-LROR6N3B.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};