@blinkk/root-cms 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/app.js +5 -5
  2. package/dist/{chunk-2BSW7SIH.js → chunk-N4K6ICFR.js} +4 -4
  3. package/dist/{chunk-BGTUWIV6.js → chunk-PNLLZXVY.js} +4 -4
  4. package/dist/{chunk-3HARN4U6.js → chunk-RLZFZT42.js} +176 -83
  5. package/dist/{chunk-C245C557.js → chunk-RXWDB3K4.js} +3 -3
  6. package/dist/{chunk-XLX37FRL.js → chunk-TEKMLYXS.js} +3 -4
  7. package/dist/cli/cli.d.ts +12 -0
  8. package/dist/cli/docs.d.ts +49 -0
  9. package/dist/cli/export.d.ts +11 -0
  10. package/dist/cli/generate-types.d.ts +6 -0
  11. package/dist/cli/import.d.ts +13 -0
  12. package/dist/cli/init-firebase.d.ts +7 -0
  13. package/dist/cli/utils.d.ts +27 -0
  14. package/dist/cli.js +10 -10
  15. package/dist/client.js +1 -1
  16. package/dist/core/ai-tools.d.ts +156 -0
  17. package/dist/core/ai.d.ts +330 -0
  18. package/dist/core/api.d.ts +21 -0
  19. package/dist/core/app.d.ts +16 -0
  20. package/dist/core/checks-translations.d.ts +13 -0
  21. package/dist/core/checks.d.ts +48 -0
  22. package/dist/core/client.d.ts +715 -0
  23. package/dist/core/core.d.ts +5 -0
  24. package/dist/core/cron.d.ts +19 -0
  25. package/dist/core/csv.d.ts +5 -0
  26. package/dist/core/functions.d.ts +9 -0
  27. package/dist/core/plugin.d.ts +357 -0
  28. package/dist/{project.d.ts → core/project.d.ts} +8 -12
  29. package/dist/core/richtext.d.ts +101 -0
  30. package/dist/{core.d.ts → core/route.d.ts} +13 -66
  31. package/dist/core/runtime.d.ts +46 -0
  32. package/dist/{schema-Db_xODoi.d.ts → core/schema.d.ts} +47 -100
  33. package/dist/core/search-extract.d.ts +70 -0
  34. package/dist/core/search-index.d.ts +182 -0
  35. package/dist/core/search-query.d.ts +68 -0
  36. package/dist/core/security.d.ts +6 -0
  37. package/dist/core/server-version.d.ts +5 -0
  38. package/dist/core/services-notifications.d.ts +57 -0
  39. package/dist/core/services.d.ts +44 -0
  40. package/dist/core/sse.d.ts +10 -0
  41. package/dist/core/translations-manager.d.ts +187 -0
  42. package/dist/core/translations.d.ts +83 -0
  43. package/dist/core/url-safety.d.ts +19 -0
  44. package/dist/core/validation.d.ts +30 -0
  45. package/dist/core/values.d.ts +9 -0
  46. package/dist/core/versions.d.ts +48 -0
  47. package/dist/core.js +1 -1
  48. package/dist/edit-M4PN4SGX.js +7 -0
  49. package/dist/functions.js +4 -4
  50. package/dist/{generate-types-SPV7I3A5.js → generate-types-JWIG4QVI.js} +1 -1
  51. package/dist/plugin.js +128 -133
  52. package/dist/shared/marshal.d.ts +68 -0
  53. package/dist/shared/objects.d.ts +9 -0
  54. package/dist/shared/richtext.d.ts +74 -0
  55. package/dist/shared/safe-json.d.ts +11 -0
  56. package/dist/shared/sanitize.d.ts +12 -0
  57. package/dist/shared/slug.d.ts +19 -0
  58. package/dist/shared/sse.d.ts +16 -0
  59. package/dist/shared/strings.d.ts +23 -0
  60. package/dist/ui/AIPage-YI3RFK5F.js +1 -0
  61. package/dist/ui/AssetsPage-4JNAOFYF.js +1 -0
  62. package/dist/ui/CollectionPage-JWHH5G55.js +1 -0
  63. package/dist/ui/ComparePage-YZE3EMU4.js +1 -0
  64. package/dist/ui/DataPage-VRCQSZZG.js +1 -0
  65. package/dist/ui/DataSourcePage-WMSPBZ3W.js +1 -0
  66. package/dist/ui/DocTranslationsPage-RY2LOZBX.js +1 -0
  67. package/dist/ui/DocumentPage-EEGTJMIW.js +1 -0
  68. package/dist/ui/EditDataSourcePage-LLCX6K4J.js +1 -0
  69. package/dist/ui/EditReleasePage-WQYXXMZQ.js +1 -0
  70. package/dist/ui/ImageEditorDialog-4H665KK2.js +81 -0
  71. package/dist/ui/ImageEditorDialog-4H665KK2.js.LEGAL.txt +17 -0
  72. package/dist/ui/LogsPage-IP2DKEYR.js +1 -0
  73. package/dist/ui/NewDataSourcePage-RDYJC4DH.js +1 -0
  74. package/dist/ui/NewReleasePage-DGMFU2JN.js +1 -0
  75. package/dist/ui/NotFoundPage-WDZ2K7EF.js +1 -0
  76. package/dist/ui/ProjectPage-HYJOQUWR.js +1 -0
  77. package/dist/ui/ReleasePage-2KSF23TK.js +1 -0
  78. package/dist/ui/ReleasesPage-NZIBBXU4.js +1 -0
  79. package/dist/ui/SettingsPage-36XFWV62.js +1 -0
  80. package/dist/ui/SidebarToolsPage-5C6YBWJ7.js +1 -0
  81. package/dist/ui/TaskPage-SPIFPGPP.js +1 -0
  82. package/dist/ui/TasksPage-ZOXRPBQV.js +1 -0
  83. package/dist/ui/TranslationsArbPage-UHANA7JD.js +2 -0
  84. package/dist/ui/TranslationsEditPage-PQY6W5YG.js +1 -0
  85. package/dist/ui/TranslationsPage-V2PQFCN5.js +162 -0
  86. package/dist/ui/ai-tools-5E5ELLZX.js +1 -0
  87. package/dist/ui/chunk-3IYZCUPI.js +1 -0
  88. package/dist/ui/chunk-4KE2SZKH.js +1 -0
  89. package/dist/ui/chunk-4W73RW5I.js +1 -0
  90. package/dist/ui/chunk-54DVDYU6.js +1 -0
  91. package/dist/ui/chunk-5MV6XVGA.js +1 -0
  92. package/dist/ui/chunk-62UWGWON.js +1 -0
  93. package/dist/ui/chunk-767BAQ53.js +1 -0
  94. package/dist/ui/chunk-AFWBSIPL.js +1 -0
  95. package/dist/ui/chunk-AL3TN2KI.js +1 -0
  96. package/dist/ui/chunk-BZIRGB4W.js +1 -0
  97. package/dist/ui/chunk-C5NH23G4.js +3 -0
  98. package/dist/ui/chunk-CGCKJFL4.js +1 -0
  99. package/dist/ui/chunk-DEGMKEHP.js +1 -0
  100. package/dist/ui/chunk-DTMZLUNY.js +15 -0
  101. package/dist/ui/chunk-DTMZLUNY.js.LEGAL.txt +237 -0
  102. package/dist/ui/chunk-DUJYIOLE.js +5 -0
  103. package/dist/ui/chunk-E2RCCK2T.js +1 -0
  104. package/dist/ui/chunk-EGEB6N4J.js +22 -0
  105. package/dist/ui/chunk-EGEB6N4J.js.LEGAL.txt +1059 -0
  106. package/dist/ui/chunk-FBJURT7Z.js +1 -0
  107. package/dist/ui/chunk-GXSAEPU3.js +1 -0
  108. package/dist/ui/chunk-HHMG665Z.js +1 -0
  109. package/dist/ui/chunk-HKINZLMW.js +84 -0
  110. package/dist/ui/chunk-HLMBCVRX.js +1 -0
  111. package/dist/ui/chunk-HRGYNHZ3.js +1 -0
  112. package/dist/ui/chunk-I6ICVKEC.js +1 -0
  113. package/dist/ui/chunk-JDW4UORS.js +1 -0
  114. package/dist/ui/chunk-JHBAMPGB.js +1 -0
  115. package/dist/ui/chunk-JT5L6GPZ.js +141 -0
  116. package/dist/ui/chunk-JT5L6GPZ.js.LEGAL.txt +106 -0
  117. package/dist/ui/chunk-JYFLU7DM.js +19 -0
  118. package/dist/ui/chunk-JZFTZ4X4.js +87 -0
  119. package/dist/ui/chunk-JZFTZ4X4.js.LEGAL.txt +9 -0
  120. package/dist/ui/chunk-KFAZBEPV.js +1 -0
  121. package/dist/ui/chunk-KKEWCXVV.js +1 -0
  122. package/dist/ui/chunk-KUCVLANF.js +1 -0
  123. package/dist/ui/chunk-KYDOSLTO.js +1 -0
  124. package/dist/ui/chunk-L4RHGQUG.js +1 -0
  125. package/dist/ui/chunk-MDUBCXU2.js +1 -0
  126. package/dist/ui/chunk-NXQVLOTK.js +1 -0
  127. package/dist/ui/chunk-NZHF733K.js +7 -0
  128. package/dist/ui/chunk-NZHF733K.js.LEGAL.txt +146 -0
  129. package/dist/ui/chunk-ONTGW2VA.js +1 -0
  130. package/dist/ui/chunk-ORXEMIQC.js +1 -0
  131. package/dist/ui/chunk-P3NETZZP.js +1 -0
  132. package/dist/ui/chunk-PHBMVORG.js +1 -0
  133. package/dist/ui/chunk-PJA7YP4A.js +1 -0
  134. package/dist/ui/chunk-PVAE643M.js +1 -0
  135. package/dist/ui/chunk-PWKJDYE2.js +1 -0
  136. package/dist/ui/chunk-RSVO46S3.js +1 -0
  137. package/dist/ui/chunk-SKEP5WYH.js +10 -0
  138. package/dist/ui/chunk-SKEP5WYH.js.LEGAL.txt +176 -0
  139. package/dist/ui/chunk-SQRKKWRG.js +3 -0
  140. package/dist/ui/chunk-TJBVMFNQ.js +1 -0
  141. package/dist/ui/chunk-V7S4IAGB.js +1 -0
  142. package/dist/ui/chunk-VMT7JFAM.js +1 -0
  143. package/dist/ui/chunk-W3BJ2EZX.js +1 -0
  144. package/dist/ui/chunk-W3HIZQ4Z.js +1 -0
  145. package/dist/ui/chunk-X2WHBGTP.js +1 -0
  146. package/dist/ui/chunk-XOQ3KDSR.js +3 -0
  147. package/dist/ui/chunk-YDO2EDVY.js +1 -0
  148. package/dist/ui/chunk-YFA6U2CV.js +1 -0
  149. package/dist/ui/gcs-L33FIRZU.js +1 -0
  150. package/dist/ui/prerender-Q4YSDCPB.js +1 -0
  151. package/dist/ui/signin.js +1 -1
  152. package/dist/ui/ui.css +1 -1
  153. package/dist/ui/ui.js +1 -630
  154. package/dist/ui/ui.js.LEGAL.txt +19 -732
  155. package/package.json +20 -20
  156. package/dist/client-1puwLgNx.d.ts +0 -1552
  157. package/dist/client.d.ts +0 -5
  158. package/dist/edit-MT4B37QK.js +0 -7
  159. package/dist/functions.d.ts +0 -13
  160. package/dist/plugin.d.ts +0 -5
  161. package/dist/richtext.d.ts +0 -104
@@ -0,0 +1 @@
1
+ import{a as s,g as F}from"./chunk-HKINZLMW.js";import{c as $}from"./chunk-JDW4UORS.js";import"./chunk-PVAE643M.js";function k(e,t){if(e==null)return[];if(typeof e!="object"||Array.isArray(e))return[{path:"",message:"Expected object for fields data",expected:"object",received:E(e)}];let i=[];for(let r of t.fields){if(!r.id||!(r.id in e))continue;let o=e[r.id];i.push(...g(o,r,r.id))}return i}function g(e,t,i){if(e===void 0)return[];switch(t.type){case"string":case"select":return typeof e!="string"?[c(i,"string",e)]:[];case"number":return typeof e!="number"?[c(i,"number",e)]:isNaN(e)?[c(i,"number",e)]:[];case"boolean":return typeof e!="boolean"?[c(i,"boolean",e)]:[];case"date":case"datetime":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[],o=e.seconds,n=e.nanoseconds;return o===void 0?r.push({path:`${i}.seconds`,message:"Required",expected:"number",received:"undefined"}):typeof o!="number"&&r.push(c(`${i}.seconds`,"number",o)),n===void 0?r.push({path:`${i}.nanoseconds`,message:"Required",expected:"number",received:"undefined"}):typeof n!="number"&&r.push(c(`${i}.nanoseconds`,"number",n)),r}case"multiselect":return Array.isArray(e)?e.flatMap((r,o)=>typeof r!="string"?[c(`${i}.${o}`,"string",r)]:[]):[c(i,"array",e)];case"image":case"file":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[];return e.src===void 0?r.push({path:`${i}.src`,message:"Required",expected:"string",received:"undefined"}):typeof e.src!="string"&&r.push(c(`${i}.src`,"string",e.src)),e.alt!==void 0&&typeof e.alt!="string"&&r.push(c(`${i}.alt`,"string",e.alt)),r}case"object":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=t,o=[];for(let n of r.fields)!n.id||!(n.id in e)||o.push(...g(e[n.id],n,`${i}.${n.id}`));return o}case"array":{if(!Array.isArray(e))return[c(i,"array",e)];let o=t.of;return e.flatMap((n,a)=>g(n,o,`${i}.${a}`))}case"oneof":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=t,o=e._type,n=new Map,a=[];for(let l of r.types){if(typeof l=="string"){a.push(l);continue}n.set(l.name,l),a.push(l.name)}if(!a.includes(o)){let l=a.map(u=>`'${u}'`).join(" | ");return[{path:`${i}._type`,message:`Invalid discriminator value. Expected ${l}`,expected:"valid discriminator value",received:o}]}let d=n.get(o);if(!d)return[];let f=[];for(let l of d.fields)!l.id||!(l.id in e)||f.push(...g(e[l.id],l,`${i}.${l.id}`));return f}case"richtext":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[];return e.blocks===void 0?r.push({path:`${i}.blocks`,message:"Required",expected:"array",received:"undefined"}):Array.isArray(e.blocks)?e.blocks.forEach((o,n)=>{if(typeof o!="object"||o===null){r.push(c(`${i}.blocks.${n}`,"object",o));return}o.type===void 0?r.push({path:`${i}.blocks.${n}.type`,message:"Required",expected:"string",received:"undefined"}):typeof o.type!="string"&&r.push(c(`${i}.blocks.${n}.type`,"string",o.type))}):r.push(c(`${i}.blocks`,"array",e.blocks)),r}case"reference":{if(typeof e!="object"||Array.isArray(e))return[c(i,"object",e)];let r=[],o=["id","collection","slug"];for(let n of o)e[n]===void 0?r.push({path:`${i}.${n}`,message:"Required",expected:"string",received:"undefined"}):typeof e[n]!="string"&&r.push(c(`${i}.${n}`,"string",e[n]));return r}case"references":return Array.isArray(e)?e.flatMap((r,o)=>{if(typeof r!="object"||r===null||Array.isArray(r))return[c(`${i}.${o}`,"object",r)];let n=[],a=["id","collection","slug"];for(let d of a)r[d]===void 0?n.push({path:`${i}.${o}.${d}`,message:"Required",expected:"string",received:"undefined"}):typeof r[d]!="string"&&n.push(c(`${i}.${o}.${d}`,"string",r[d]));return n}):[c(i,"array",e)];default:return console.warn(`Unknown field type: ${t.type}`),[]}}function E(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="number"&&Number.isNaN(e)?"nan":typeof e}function c(e,t,i){let r=E(i);return{path:e,message:`Expected ${t}, received ${r}`,expected:t,received:r}}var Y=["collections_list","docs_list","doc_get","doc_getVersion","doc_set","doc_create","doc_updateField","doc_edit","doc_duplicate","doc_listVersions","doc_translateField","schema_get"],T=["collections_list","docs_list","doc_get","doc_getVersion","doc_listVersions","schema_get"];function Z(e){let t=M(e),i={};for(let r of T)t[r]&&(i[r]=t[r]);return i}function M(e){return{collections_list:{description:"List all CMS collections defined in the project. Returns each collection id along with optional name/description metadata.",inputSchema:s.object({}),execute:async()=>{let t=await e.loadAllCollections();return{collections:Object.entries(t).map(([i,r])=>({id:i,name:r.name,description:r.description}))}}},docs_list:{description:"List documents inside a CMS collection. Returns up to `limit` docs (default 25, max 100). Use this to explore content before reading individual docs.",inputSchema:s.object({collectionId:s.string().describe('Collection id, e.g. "Pages" or "BlogPosts".'),mode:s.enum(["draft","published"]).default("draft").describe("Whether to read draft or published versions."),limit:s.number().int().min(1).max(100).default(25)}),execute:async({collectionId:t,mode:i="draft",limit:r=25})=>{let o=v(r,1,100,25);return{docs:(await e.cmsClient.listDocs(t,{mode:i,limit:o})).docs.map(a=>({id:a.id,slug:a.slug,sys:A(a.sys)}))}}},doc_get:{description:"Read a single CMS document. Returns the doc fields plus system metadata. Use this when you need the full content of a doc.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),mode:s.enum(["draft","published"]).default("draft")}),execute:async({docId:t,mode:i="draft"})=>{let{collection:r,slug:o}=S(t),n=await e.cmsClient.getRawDoc(r,o,{mode:i});return n?{found:!0,doc:{id:n.id,collection:n.collection,slug:n.slug,sys:A(n.sys),fields:N(n.fields)}}:{found:!1}}},doc_getVersion:{description:'Read a specific version of a CMS document. Use versionId "draft" or "published" for the current draft/published state, or a numeric timestamp for a historical version (from `doc_listVersions`).',inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),versionId:s.string().describe('Version identifier: "draft", "published", or a numeric timestamp.')}),execute:async({docId:t,versionId:i})=>{let{collection:r,slug:o}=S(t),n;i==="draft"?n=`Projects/${e.cmsClient.projectId}/Collections/${r}/Drafts/${o}`:i==="published"?n=`Projects/${e.cmsClient.projectId}/Collections/${r}/Published/${o}`:n=`Projects/${e.cmsClient.projectId}/Collections/${r}/Drafts/${o}/Versions/${i}`;let a=await e.cmsClient.db.doc(n).get();if(!a.exists)return{found:!1};let d=a.data();return{found:!0,doc:{id:d.id,collection:d.collection,slug:d.slug,sys:A(d.sys),fields:N(d.fields)}}}},doc_set:{description:"Replace the entire draft fields payload of a CMS document. Pass the full JSON object that should become the new draft contents \u2014 any fields omitted will be removed. The payload is validated against the collection schema and the call is rejected on validation errors. Prefer `doc_updateField` for targeted edits. Only writes the draft version; users must publish separately. Format: pass plain JSON. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals the payload into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape with `blocks` as a plain JSON array of `{type, data}` objects.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),fields:s.record(s.string(),s.any()).describe("New fields object. Replaces the existing draft fields entirely.")})},doc_create:{description:"Create a new draft CMS document with the given slug. Fails if the doc already exists. Pass optional initial fields (validated against the collection schema). Format: pass plain JSON for `fields`. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals the payload into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape with `blocks` as a plain JSON array of `{type, data}` objects.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "BlogPosts/my-new-post").'),fields:s.record(s.string(),s.any()).optional().describe("Optional initial fields for the new doc.")})},doc_updateField:{description:'Update a single field on a draft CMS document by JSON path. Paths are relative to the doc fields object; do not prefix them with "fields.". Use dotted paths (e.g. "hero.title") and zero-based array indices. For example, update the first module title with path "content.modules.0.title". To insert or remove array items, prefer `doc_edit` (it supports insert/remove operations); alternatively set the whole array path here (e.g. "content.modules") to the updated array. The value is validated against the field schema and the call is rejected if the shape is wrong (e.g. passing a string to a richtext field). Only updates the draft version; users must publish separately. Format: pass `value` as plain JSON. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals the value into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape and `blocks` MUST be a plain JSON array of `{type, data}` objects (never wrapped in `_array`).',inputSchema:s.object({docId:s.string(),path:s.string().describe('Dotted JSON path within the fields object, e.g. "content.modules.0.title".'),value:s.any().describe("JSON value to set at the path.")})},doc_edit:{description:'Apply multiple edits to a draft CMS document in a single call. Use this when a change spans more than one field or needs to add or remove array items (e.g. append a new module AND update a title). Pass an ordered `operations` list; each operation has an `op`:\n- "set": set the value at `path` (e.g. "hero.title" or "content.modules.0.title"). Provide `value`.\n- "insert_item": insert `value` into the array at `path` (e.g. "content.modules"). Optionally pass a zero-based `index` to insert before; omit `index` to append.\n- "remove_item": remove the array item at zero-based `index` from the array at `path`.\nOperations apply in order against the current draft. Array indices in each operation refer to the array state AFTER earlier operations have been applied. The whole result is validated against the collection schema and the call is rejected as a group on any error \u2014 nothing is written unless every operation succeeds. Paths are relative to the doc fields object; do not prefix them with "fields.". Use dotted paths and zero-based array indices. Only writes the draft version; users must publish separately. Format: pass `value` as plain JSON. Arrays must be plain JSON arrays \u2014 do NOT use the `_array` object notation. The tool marshals values into Firestore storage shape on its own. Rich text fields use the `{version, time, blocks}` shape with `blocks` as a plain JSON array of `{type, data}` objects.',inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),operations:s.array(s.object({op:s.enum(["set","insert_item","remove_item"]).describe('Operation: "set" a field value, "insert_item" into an array, or "remove_item" from an array.'),path:s.string().describe('Dotted path within the fields object. For "set" it targets the field to write (e.g. "hero.title"); for "insert_item"/"remove_item" it targets the array (e.g. "content.modules").'),value:s.any().optional().describe('JSON value. Required for "set" (the new field value) and "insert_item" (the new array item). Ignored for "remove_item".'),index:s.number().int().min(0).optional().describe('Zero-based array index. For "insert_item" it is the position to insert before (omit to append); for "remove_item" it is the item to delete (required).')})).min(1).describe("Ordered list of edit operations to apply to the draft.")})},doc_duplicate:{description:"Duplicate an existing CMS document to a new slug. Copies all draft fields to the target doc id. Fails if the target already exists.",inputSchema:s.object({fromDocId:s.string().describe('Source doc id to copy from (e.g. "Pages/home").'),toDocId:s.string().describe('Target doc id for the copy (e.g. "Pages/home-copy").')})},doc_listVersions:{description:"List version history for a CMS document. Returns versions ordered by most recent first. Use the versionId from the results with `doc_getVersion` to read a specific version.",inputSchema:s.object({docId:s.string().describe('Full doc id in the form "Collection/slug" (e.g. "Pages/home").'),limit:s.number().int().min(1).max(50).default(10)}),execute:async({docId:t,limit:i=10})=>{let{collection:r,slug:o}=S(t),n=v(i,1,50,10),a=`Projects/${e.cmsClient.projectId}/Collections/${r}/Drafts/${o}/Versions`;return{versions:(await e.cmsClient.db.collection(a).orderBy("sys.modifiedAt","desc").limit(n).get()).docs.map(f=>{let l=f.data();return{versionId:f.id,sys:A(l.sys),tags:l.tags||[],publishMessage:l.publishMessage}})}}},doc_translateField:{description:"Translate a text value into one or more target locales using AI. Returns the translated strings keyed by locale. Use this to help with localization workflows.",inputSchema:s.object({sourceText:s.string().min(1).describe("The source text to translate."),targetLocales:s.array(s.string()).min(1).describe('Array of locale codes to translate into (e.g. ["es", "fr", "de"]).'),description:s.string().optional().describe("Optional context about the text to improve translation quality.")})},schema_get:{description:"Get the field schema for a CMS collection. Returns the full field definitions including types, labels, and validation rules. Use this to understand what fields a collection supports before creating or editing docs.",inputSchema:s.object({collectionId:s.string().describe('Collection id, e.g. "Pages" or "BlogPosts".')}),execute:async({collectionId:t})=>{let i=await e.loadCollection(t);return i?{found:!0,collectionId:t,fields:_(i.fields||[])}:{found:!1,collectionId:t}}}}}function S(e){let t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`invalid docId: "${e}" (expected "Collection/slug")`);return{collection:e.slice(0,t),slug:$(e.slice(t+1))}}function v(e,t,i,r){let o=Number.isFinite(e)?Math.trunc(e):r;return Math.min(Math.max(o,t),i)}function A(e){return F(e??{})}function N(e){return F(e??{})}function _(e){return e.map(t=>{let i={id:t.id,type:t.type};return t.label&&(i.label=t.label),t.description&&(i.description=t.description),t.required&&(i.required=!0),t.translate&&(i.translate=!0),t.options&&(i.options=t.options),t.type==="object"&&t.fields&&(i.fields=_(t.fields)),t.type==="array"&&t.of&&(i.of=_([t.of])[0]),t.type==="oneof"&&t.types&&(i.types=t.types.map(r=>typeof r=="string"?r:{id:r.id,fields:_(r.fields||[])})),i})}function H(e,t,i){let r=V(e,t);if(r.error)return[r.error];let o=r.field;return o?g(i,o,t):[]}function V(e,t){let i=R(t);if(i)return{field:null,error:i};let r=t.trim().split(".");if(r.length===0)return{field:null};let o=e.fields||[],n=null;for(let a=0;a<r.length;a++){let d=r[a],f=r.slice(0,a+1).join("."),l=/^\d+$/.test(d),u=/^(0|[1-9]\d*)$/.test(d);if(l&&!u)return{field:null,error:h(f,"Array indices must be zero-based numeric path segments without leading zeros.","array index",d)};if(u){if(!n||n.type!=="array")return{field:null,error:h(f,"Array index path segments can only be used after an array field.","array field",n?.type||"root")};let x=n.of;n=x,o=x.type==="object"?x.fields:[];continue}if(n?.type==="array")return{field:null,error:h(f,"Array fields must be followed by a zero-based numeric index before nested fields.","array index",d)};let m=o.find(p=>p.id===d);if(!m&&n?.type==="oneof"){let p=n,x=Array.isArray(p.types)?p.types:[];for(let C of x){if(typeof C=="string")continue;let O=(C.fields||[]).find(P=>P.id===d);if(O){m=O;break}}}if(!m)return{field:null};n=m,m.type==="object"?o=m.fields:m.type==="array"?o=[]:o=[]}return{field:n}}function R(e){let t=e.trim();if(!t)return h(e,"Path is required and must be relative to the doc fields object.","non-empty field path",e);let i=t.split(".");return i.some(r=>r.length===0)?h(e,"Path must use dotted field segments without empty segments.","dotted field path",e):i[0]==="fields"?h(e,'Path must be relative to the fields object; remove the leading "fields." prefix.',"field path without fields prefix",e):i.some(r=>/[[\]]/.test(r))?h(e,'Use dotted zero-based array indices, e.g. "content.modules.0.title".',"dotted array index path",e):null}function h(e,t,i,r){return{path:e,message:t,expected:i,received:r}}var w=/^(0|[1-9]\d*)$/;function K(e,t){let i=JSON.parse(JSON.stringify(e??{}));for(let r=0;r<t.length;r++){let o=D(i,t[r],r);if(o)return{ok:!1,error:o}}return{ok:!0,fields:i}}function D(e,t,i){if(t.op!=="set"&&t.op!=="insert_item"&&t.op!=="remove_item")return y(i,t,typeof t.path=="string"?t.path:String(t.path),`Unknown operation "${t.op}".`,"set | insert_item | remove_item",t.op);if(typeof t.path!="string")return y(i,t,String(t.path),"Operation `path` must be a string.","string",b(t.path));let r=R(t.path);if(r)return{opIndex:i,op:t.op,...r};let o=t.path.trim().split("."),n=o[o.length-1],a=t.path.trim(),d=w.test(n),f=q(e,o,t.op!=="remove_item");if(!f.ok)return{opIndex:i,op:t.op,...f.error};let l=f.container;if(t.op==="set"){if(t.value===void 0)return y(i,t,a,'A "set" operation requires a `value`.',"value","undefined");if(Array.isArray(l)){if(!d)return y(i,t,a,"Use a zero-based array index to set an array item.","array index",n);let m=Number(n);return m>l.length?y(i,t,a,"Array index is out of range; set an existing index or append at the array length.",`0..${l.length}`,m):(l[m]=t.value,null)}return l&&typeof l=="object"?d?y(i,t,a,"Array index used on a non-array field.","object key",n):(l[n]=t.value,null):y(i,t,a,"Cannot set a value here; the parent is not an object or array.","object or array",b(l))}let u=J(l,n,d);if(t.op==="insert_item"){if(t.value===void 0)return y(i,t,a,'An "insert_item" operation requires a `value`.',"value","undefined");if(u==null){u=[];let p=U(l,n,d,u,i,t);if(p)return p}if(!Array.isArray(u))return y(i,t,a,'The target of an "insert_item" must be an array field.',"array",b(u));let m=t.index===void 0?u.length:t.index;return m<0||m>u.length?y(i,t,a,"Insert index is out of range.",`0..${u.length}`,m):(u.splice(m,0,t.value),null)}return Array.isArray(u)?t.index===void 0?y(i,t,a,'A "remove_item" operation requires an `index`.',"index","undefined"):t.index<0||t.index>=u.length?y(i,t,a,"Remove index is out of range.",`0..${Math.max(u.length-1,0)}`,t.index):(u.splice(t.index,1),null):y(i,t,a,'The target of a "remove_item" must be an array field.',"array",b(u))}function q(e,t,i){let r=e;for(let o=0;o<t.length-1;o++){let n=t[o],a=t.slice(0,o+1).join("."),d=w.test(n);if(Array.isArray(r)){if(!d)return j(a,"Expected a zero-based array index after an array field.","array index",n);let f=Number(n);if(f>=r.length)return j(a,"Array index is out of range for the current draft.",`0..${Math.max(r.length-1,0)}`,f);r=r[f];continue}if(r===null||typeof r!="object")return j(a,"Path walks through a value that is not an object or array.","object or array",b(r));if(d)return j(a,"Array index used on a non-array field.","object key",n);if(r[n]===void 0||r[n]===null){if(!i)return j(a,"Path segment does not exist in the current draft.","existing field",n);r[n]=w.test(t[o+1])?[]:{}}r=r[n]}return{ok:!0,container:r}}function J(e,t,i){if(Array.isArray(e))return i?e[Number(t)]:void 0;if(e&&typeof e=="object")return e[t]}function U(e,t,i,r,o,n){return Array.isArray(e)?i?(e[Number(t)]=r,null):y(o,n,n.path.trim(),"Use a zero-based array index for an array field.","array index",t):e&&typeof e=="object"?i?y(o,n,n.path.trim(),"Array index used on a non-array field.","object key",t):(e[t]=r,null):y(o,n,n.path.trim(),"Cannot write here; the parent is not an object or array.","object or array",b(e))}function j(e,t,i,r){return{ok:!1,error:{path:e,message:t,expected:i,received:r}}}function y(e,t,i,r,o,n){return{opIndex:e,op:t.op,path:i,message:r,expected:o,received:n}}function b(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}export{Y as CMS_TOOL_NAMES,T as READ_ONLY_CMS_TOOL_NAMES,K as applyDocEdits,M as createCmsTools,Z as createReadOnlyCmsTools,k as validateFields,H as validateValueAtPath};
@@ -0,0 +1 @@
1
+ import{b as F}from"./chunk-RSVO46S3.js";import{b as S,q as T}from"./chunk-AFWBSIPL.js";import{b as $}from"./chunk-62UWGWON.js";import{b as p,d as b}from"./chunk-ORXEMIQC.js";import{b as P}from"./chunk-5MV6XVGA.js";import{f as w}from"./chunk-AL3TN2KI.js";import{Ga as g,Ha as t,V as N,a as f,c as h,ca as l,e as k,i as R,j as B,ma as I}from"./chunk-NZHF733K.js";import{d as y,j as x,k as M}from"./chunk-KUCVLANF.js";M();B();var L=x(null);function W(e){let[i,n]=f([]),[o,a]=f(!1),r=k("idle");function u(){r.current==="idle"&&(r.current="fetching",a(!0),F().then(s=>{let c=s.filter(m=>!m.publishedAt&&!m.archivedAt);n(c)}).catch(s=>{console.error("Failed to fetch pending releases:",s)}).finally(()=>{r.current="done",a(!1)}))}function d(s){return i.filter(c=>c.docIds?.includes(s))}return t(L.Provider,{value:{releases:i,getReleasesForDoc:d,loading:o,fetchReleases:u},children:e.children})}function A(){let e=R(L);if(!e)throw new Error("usePendingReleases must be used within a <PendingReleasesProvider>");let{fetchReleases:i,...n}=e;return h(()=>{i()},[]),n}function z(e){let i={transition:"pop"},n=e.doc,o=n.sys;return t("div",{className:"DocStatusBadges",children:[(!o.publishedAt||!o.modifiedAt||o.modifiedAt>o.publishedAt)&&t(g,{...i,label:`Modified ${_(o.modifiedAt)} by ${o.modifiedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:"Draft"})}),!!o.publishedAt&&t(g,{...i,label:`Published ${_(o.publishedAt)} by ${o.publishedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"teal",to:"lime",deg:105},children:"Published"})}),!!o.scheduledAt&&t(g,{...i,label:`Scheduled ${b(o.scheduledAt)} by ${o.scheduledBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"grape",to:"pink",deg:35},children:"Scheduled"})}),!e.hideReleases&&t(K,{docId:e.docId||n.id,tooltipProps:i}),T(n)&&t(g,{...i,label:O(n),children:t(l,{size:"xs",variant:"gradient",gradient:{from:"orange",to:"red"},className:e.onPublishingLockClick?"DocStatusBadges__badge--clickable":void 0,style:e.onPublishingLockClick?{cursor:"pointer"}:void 0,role:e.onPublishingLockClick?"button":void 0,tabIndex:e.onPublishingLockClick?0:void 0,onClick:e.onPublishingLockClick,onKeyDown:e.onPublishingLockClick?a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e.onPublishingLockClick())}:void 0,children:"Locked"})}),!!o.archivedAt&&t(g,{...i,label:`Archived ${_(o.archivedAt)} by ${o.archivedBy}`,children:t(l,{size:"xs",variant:"gradient",gradient:{from:"gray",to:"dark"},children:"Archived"})})]})}function O(e){let i=e.sys?.publishingLocked;return i?i.until?`Locked until ${b(i.until)} by ${i.lockedBy}: "${i.reason}"`:`Locked by ${i.lockedBy}: "${i.reason}"`:""}function K(e){let{getReleasesForDoc:i}=A(),n=i(e.docId);return n.length===0?null:t(y,{children:n.map(o=>t(g,{...e.tooltipProps,label:`In release: ${o.id}`,children:t(l,{component:"a",href:`/cms/releases/${o.id}`,size:"xs",variant:"gradient",gradient:{from:"violet",to:"grape"},style:{cursor:"pointer"},children:o.id})},o.id))})}function _(e){return e?p(e.toMillis()):p(new Date().getTime())}function E(e){let{file:i,width:n,height:o,withPlaceholder:a,className:r,alt:u}=e,d=typeof i=="string"?i:i?.src;return U(i)?t(X,{className:r,src:d,width:n,height:o}):t(I,{className:r,src:d,width:n,height:o,withPlaceholder:a,alt:u})}function U(e){if(!e)return!1;if(typeof e=="string")return/\.mp4($|\?)/i.test(e);if(typeof e.mimeType=="string")return e.mimeType.toLowerCase()==="video/mp4";let i=e.src;return typeof i!="string"?!1:/\.mp4($|\?)/i.test(i)}function X(e){return t("video",{className:e.className,src:e.src,width:e.width,height:e.height,muted:!0,playsInline:!0,preload:"metadata",style:{width:`${e.width}px`,height:`${e.height}px`,backgroundColor:"#f1f3f5",objectFit:"cover",display:"block"}})}B();function De(e){let i=e.docId,[n,o]=f(e.doc),[a,r]=f(!e.doc);async function u(){r(!0),await $(async()=>{let V=await S(i);o(V)}),r(!1)}if(h(()=>{u()},[i]),a)return t("div",{className:w(e.className,"DocPreviewCard","DocPreviewCard--loading",e.variant&&`DocPreviewCard--${e.variant}`),children:t(N,{color:"gray",size:"sm"})});if(!n)return;let[d]=i.split("/"),s=n.fields||{},c=window.__ROOT_CTX.collections[d];if(!c)return console.error(`could not find collection: ${d}`),t("div",{className:"DocPreviewCard",children:["Collection ",t("b",{children:d})," not found."]});let m=P(s,c.preview?.title||"meta.title"),C=P(s,c.preview?.image||"meta.image")||c.preview?.defaultImage,D="div",v={};return e.clickable&&(D="a",v.href=`/cms/content/${e.docId}`,v.target="_blank"),t(D,{className:w(e.className,"DocPreviewCard",e.variant&&`DocPreviewCard--${e.variant}`),...v,children:[t("div",{className:"DocPreviewCard__image",children:t(E,{file:C,width:80,height:60,withPlaceholder:!C?.src})}),t("div",{className:"DocPreviewCard__content",children:[t("div",{className:"DocPreviewCard__content__header",children:t("div",{className:"DocPreviewCard__content__header__docId",children:n.id})}),t("div",{className:"DocPreviewCard__content__title",children:m||"[UNTITLED]"}),e.statusBadges&&n&&t("div",{className:"DocPreviewCard__content__badges",children:t(z,{doc:n,hideReleases:e.hideReleases})})]})]})}export{W as a,A as b,z as c,O as d,E as e,De as f};
@@ -0,0 +1 @@
1
+ import{a as _,c as P}from"./chunk-W3HIZQ4Z.js";import{f as u}from"./chunk-ORXEMIQC.js";import{a as w,b as j,c as n,g as T,n as b,o as R,p as I,q as m,t as h,u as l,w as f}from"./chunk-EGEB6N4J.js";async function F(t,a){if(!t)throw new Error("missing data source id");let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t);await I(s,{...a,id:t,createdAt:l(),createdBy:window.firebase.user.email}),u("datasource.create",{metadata:{datasourceId:t}})}async function G(){let t=window.__ROOT_CTX.rootConfig.projectId,a=window.firebase.db,o=j(a,"Projects",t,"DataSources"),e=T(o),s=await R(e),r=[];return s.forEach(c=>{r.push(c.data())}),r}async function S(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t),s=await b(e);return s.exists()?s.data():null}async function O(t,a){let o=a?.mode||"draft",e=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,r=n(s,"Projects",e,"DataSources",t,"Data",o),c=await b(r);return c.exists()?c.data():null}async function U(t,a){let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t);await m(s,a),u("datasource.save",{metadata:{datasourceId:t}})}async function q(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t);await m(e,{archivedAt:l(),archivedBy:window.firebase.user.email}),u("datasource.archive",{metadata:{datasourceId:t}})}async function H(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t);await m(e,{archivedAt:h(),archivedBy:h()}),u("datasource.unarchive",{metadata:{datasourceId:t}})}async function W(t){let a=await S(t);if(!a)throw new Error(`data source not found: ${t}`);if(a.archivedAt)throw new Error(`data source is archived: ${t}`);if(a.type==="http"&&a.url&&!C(a.url)){let o=await fetch("/cms/api/data.sync",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:a.id})});if(o.status!==200){let e=await o.text();throw new Error(`sync failed: ${e}`)}}else{let{data:o,headers:e}=await x(a),s=window.__ROOT_CTX.rootConfig.projectId,r=window.firebase.db,c=n(r,"Projects",s,"DataSources",t),d=n(r,"Projects",s,"DataSources",t,"Data","draft"),p={...a,syncedAt:w.now(),syncedBy:window.firebase.user.email},i=f(r);i.set(d,{dataSource:p,data:o,...e?{headers:e}:{}}),i.update(c,{syncedAt:w.now(),syncedBy:window.firebase.user.email}),await i.commit()}console.log(`synced data source: ${t}`),u("datasource.sync",{metadata:{datasourceId:t}})}async function M(t){let a=await S(t);if(!a)throw new Error(`data source not found: ${t}`);if(a.archivedAt)throw new Error(`data source is archived: ${t}`);let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t),r=n(e,"Projects",o,"DataSources",t,"Data","draft"),c=n(e,"Projects",o,"DataSources",t,"Data","published"),d=await O(t,{mode:"draft"}),p={...a,publishedAt:w.now(),publishedBy:window.firebase.user.email},i=f(e);i.set(c,{dataSource:p,data:d?.data||null,...d?.headers?{headers:d.headers}:{}}),i.update(r,{dataSource:p}),i.update(s,{publishedAt:w.now(),publishedBy:window.firebase.user.email}),await i.commit(),console.log(`published data ${t}`),u("datasource.publish",{metadata:{datasourceId:t}})}async function k(t){if(!await S(t))throw new Error(`data source not found: ${t}`);let o=window.__ROOT_CTX.rootConfig.projectId,e=window.firebase.db,s=n(e,"Projects",o,"DataSources",t),r=n(e,"Projects",o,"DataSources",t,"Data","draft"),c=n(e,"Projects",o,"DataSources",t,"Data","published"),d=f(e);d.update(s,{publishedAt:h(),publishedBy:h()}),(await b(r)).exists()&&d.update(r,{"dataSource.publishedAt":h(),"dataSource.publishedBy":h()}),d.delete(c),await d.commit(),console.log(`unpublished data source: ${t}`),u("datasource.unpublish",{metadata:{datasourceId:t}})}async function J(t,a){if(t.length===0)return;let o=window.firebase.db,e=window.__ROOT_CTX.rootConfig.projectId,s=a?.batch||f(o);for(let r of t){let c=await S(r);if(!c)throw new Error(`data source not found: ${r}`);if(c.archivedAt)throw new Error(`data source is archived: ${r}`);let d=await O(r,{mode:"draft"}),p=n(o,"Projects",e,"DataSources",r),i=n(o,"Projects",e,"DataSources",r,"Data","draft"),y=n(o,"Projects",e,"DataSources",r,"Data","published"),D={...c,publishedAt:l(),publishedBy:window.firebase.user.email};s.set(y,{dataSource:D,data:d?.data||null,...d?.headers?{headers:d.headers}:{}}),s.update(i,{dataSource:D}),s.update(p,{publishedAt:l(),publishedBy:window.firebase.user.email}),u("datasource.publish",{metadata:{datasourceId:r}})}(!a?.batch||a?.commitBatch)&&await s.commit()}async function N(t){let a=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,e=n(o,"Projects",a,"DataSources",t),s=n(o,"Projects",a,"DataSources",t,"Data","draft"),r=n(o,"Projects",a,"DataSources",t,"Data","published"),c=f(o);c.delete(s),c.delete(r),c.delete(e),await c.commit(),console.log(`deleted data source ${t}`),u("datasource.delete",{metadata:{datasourceId:t}})}async function x(t){if(t.type==="http")return{data:await B(t)};if(t.type==="gsheet")return await v(t);throw new Error(`unsupported data source: ${t.type}`)}async function v(t){let a=P(t.url);if(!a?.spreadsheetId)throw new Error(`failed to parse google sheet url: ${t.url}`);let e=await new _(a.spreadsheetId).getSheet(a.gid??0);if(!e)throw new Error(`could not find sheet: ${t.url}`);let s=t.dataFormat||"map",[r,c]=await e.getValues();return s==="array"?{data:[r,c],headers:r}:{data:c.map(p=>{let i={};return p.forEach((y,D)=>{let g=r[D];g&&(i[g]=String(y||""))}),i}),headers:r}}async function B(t){if(!C(t.url))throw new Error(`unsupported url: ${t.url}`);let a=await fetch(t.url,{method:t.httpOptions?.method||"GET",headers:t.httpOptions?.headers||[],body:t.httpOptions?.body||void 0});if(a.status!==200){let e=await a.text();throw new Error(`req failed: ${e}`)}return String(a.headers.get("content-type")).includes("application/json")?await a.json():a.text()}function C(t){return t&&t.startsWith("/")}export{F as a,G as b,S as c,O as d,U as e,q as f,H as g,W as h,M as i,k as j,J as k,N as l};
@@ -0,0 +1 @@
1
+ import{a as b,c as w}from"./chunk-HRGYNHZ3.js";import{b as z,e as I,f as C}from"./chunk-XOQ3KDSR.js";import{a as p}from"./chunk-I6ICVKEC.js";import{a}from"./chunk-HLMBCVRX.js";import{Ha as n,V as v,a as c,c as y,ea as m,j as L,zc as N}from"./chunk-NZHF733K.js";import{d as M}from"./chunk-KUCVLANF.js";L();var S="PruneTranslationsModal";function W(){let u=b(),o=w();return{open:r=>{u.openContextModal(S,{...o,title:`Prune unused strings from ${r.docId}`,innerProps:r,size:600})}}}function $(u){let{innerProps:o,context:r,id:f}=u,[l,h]=c(!0),[e,k]=c([]),[E,x]=c(!1);y(()=>{let s=!1;async function d(){let t=o.docId,g=await z({tags:[t]}),H=new Set(await Promise.all(o.sourceStrings.map(i=>C(i)))),T=[];for(let[i,P]of Object.entries(g))if(!H.has(i)){let _=P.tags||[];_.includes(t)&&T.push({hash:i,source:P.source||i,tags:_.filter(B=>B!==t)})}s||(k(T),h(!1))}return d().catch(t=>{console.error(t),s||h(!1)}),()=>{s=!0}},[o.docId,o.sourceStrings]);async function U(){if(e.length!==0){x(!0);try{let s=e.map(({hash:t,tags:g})=>({hash:t,tags:g}));await I(s,{mode:"replace"});let d=e.map(t=>t.hash);p({title:"Pruned translations",message:`Removed "${o.docId}" tag from ${d.length} unused translation(s).`,color:"green",autoClose:5e3}),o.onPruned?.(d),r.closeModal(f)}catch(s){console.error(s),p({title:"Error pruning translations",message:String(s),color:"red",autoClose:!1})}finally{x(!1)}}}return n("div",{className:"PruneTranslationsModal",children:[n("div",{className:"PruneTranslationsModal__description",children:n(a,{size:"body",children:["Pruning removes the ",n("strong",{children:o.docId})," tag from translation strings that are no longer referenced by this document. The translations themselves are not deleted and will remain available to other documents that still reference them."]})}),l&&n("div",{className:"PruneTranslationsModal__loading",children:[n(v,{color:"gray",size:"sm"}),n(a,{size:"body",color:"gray",children:"Scanning for unused strings\u2026"})]}),!l&&e.length===0&&n("div",{className:"PruneTranslationsModal__empty",children:n(a,{size:"body",color:"gray",children:['All translations tagged with "',o.docId,'" are still in use. Nothing to prune.']})}),!l&&e.length>0&&n(M,{children:[n(a,{size:"body",weight:"semi-bold",children:[e.length," unused string",e.length!==1?"s":""," will be untagged:"]}),n("div",{className:"PruneTranslationsModal__list",children:e.map(s=>n("div",{className:"PruneTranslationsModal__list__item",children:n(a,{size:"body-sm",children:s.source})},s.hash))})]}),n("div",{className:"PruneTranslationsModal__actions",children:[n(m,{variant:"default",size:"xs",onClick:()=>r.closeModal(f),children:"Cancel"}),n(m,{variant:"filled",size:"xs",color:"red",leftIcon:n(N,{size:14}),loading:E,disabled:l||e.length===0,onClick:U,children:["Prune ",e.length>0?e.length:""," string",e.length!==1?"s":""]})]})]})}$.id=S;export{W as a,$ as b};
@@ -0,0 +1 @@
1
+ import{i as t,j as i}from"./chunk-NZHF733K.js";import{j as r,k as o}from"./chunk-KUCVLANF.js";o();i();var s=r(null);function n(){let e=t(s);if(!e)throw new Error("useFirebase() should be called within a <FirebaseProvider>");return e}export{s as a,n as b};
@@ -0,0 +1 @@
1
+ function u(n){return typeof n=="object"&&!Array.isArray(n)&&n!==null}function d(n,r){if(Array.isArray(r)){for(let t of r){let s=d(n,t);if(s!=null)return s}return}let i=r.split("."),e=n;for(let t of i){if(e==null)return;e=g(e,t)}return e}function g(n,r){if(!r)return n;let i=/([^\[\]]+)|\[(\d+)\]/g,e=n,t;for(;t=i.exec(r);){if(e==null)return;let s=t[1],c=t[2];if(s!==void 0){e=e[s];continue}if(c===void 0)return;let o=Number(c);if(Array.isArray(e)){e=e[o];continue}if(u(e)&&Array.isArray(e._array)){let y=e._array[o];if(y===void 0)return;e=e[y];continue}if(u(e)&&Object.prototype.hasOwnProperty.call(e,String(o))){e=e[String(o)];continue}return}return e}function A(n,r){return n.sort((i,e)=>{let t=i[r],s=e[r];return t<s?-1:t>s?1:0})}function l(n,r){if(n===r)return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;if(Array.isArray(n)&&Array.isArray(r)){if(n.length!==r.length)return!1;for(let t=0;t<n.length;t++)if(!l(n[t],r[t]))return!1;return!0}let i=Object.keys(n),e=Object.keys(r);if(i.length!==e.length)return!1;for(let t of i)if(!l(n[t],r[t]))return!1;return!0}function x(n){return n==null?n:typeof globalThis.structuredClone=="function"?globalThis.structuredClone(n):JSON.parse(JSON.stringify(n))}function f(n){if(Array.isArray(n))return n.map(r=>f(r));if(u(n)){let r={},i=Object.keys(n).sort((e,t)=>e.localeCompare(t));for(let e of i)r[e]=f(n[e]);return r}return n}function T(n,r=2){return JSON.stringify(f(n),null,r)}function a(n){return u(n)&&Array.isArray(n._array)}function p(n,r){let i={...n};for(let e in r){let t=r[e],s=i[e];u(t)&&u(s)&&!a(t)&&!a(s)?i[e]=p(s,t):t!==void 0&&(i[e]=t)}return i}export{u as a,d as b,A as c,l as d,x as e,T as f,p as g};
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-I6ICVKEC.js";function s(e){if(typeof e=="object"&&e!==null){let o=e;if(typeof o.code=="string"&&typeof o.message=="string")return`${o.code}: ${o.message}`;if(typeof o.body=="string")return o.body;if(typeof o.message=="string")return o.message}return String(e)}async function i(e){try{await e()}catch(o){console.error(o);let r=s(o);t({title:"Error",message:r,color:"red",autoClose:!1})}}export{s as a,i as b};
@@ -0,0 +1 @@
1
+ import{d as Q}from"./chunk-AL3TN2KI.js";import{a as z,c as d,e as i,h as c,j as h}from"./chunk-NZHF733K.js";h();function R(r,t,n={}){let{query:l,route:g}=Q(),{replace:m=!1,serialize:y=e=>String(e),deserialize:f=e=>e}=n,a=i(t),T=i(y),P=i(f);a.current=t,T.current=y,P.current=f;let o=c(()=>{let e=l[r];return e!==void 0?P.current(e):a.current},[l,r]),[S,p]=z(o);d(()=>{p(o())},[o]);let b=c(e=>{p(e);let s=new URL(window.location.href),u=T.current(e);u===String(a.current)||u===""?s.searchParams.delete(r):s.searchParams.set(r,u);let k=s.pathname+s.search;g(k,m)},[r,m,g]);return[S,b]}function O(r,t=""){return R(r,t)}function w(r,t=[]){return R(r,t,{serialize:n=>Array.isArray(n)?n.join(","):"",deserialize:n=>n?n.split(",").filter(Boolean):t})}export{O as a,w as b};
@@ -0,0 +1 @@
1
+ import{a as X,f as G,g as M}from"./chunk-XOQ3KDSR.js";import{f as u}from"./chunk-ORXEMIQC.js";import{a as C,b as k,c as d,f as L,g as A,h as j,i as I,j as V,l as $,n as D,o as B,p as E,q as x,s as _,t as w,u as h,v as F,w as T}from"./chunk-EGEB6N4J.js";function H(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function Q(e){return H(e)&&Array.isArray(e.blocks)&&e.blocks.length>0}var P=new Map;function K(e){return P.get(e)||null}async function fe(e){let t=K(e);if(t)return t;let s=g(e),o=(await D(s)).data();return W(e,o),o}function W(e,t){P.set(e,t)}function v(e){P.delete(e)}function U(e){for(let t of e)v(t)}async function Te(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Published",o),c=d(s,"Projects",t,"Collections",n,"Scheduled",o),a=T(s);a.delete(r),a.delete(i),a.delete(c),await a.commit(),console.log(`deleted doc: ${e}`),u("doc.delete",{metadata:{docId:e}})}async function Ce(e,t){await Y([e],t)}async function Y(e,t){if(e.length===0){console.log("no docs to publish");return}let s=window.firebase.db;if(e.length>100)throw new Error("publish docs exceeds limit of 100 docs. break up your request into multiple calls.");let n=await ie(e),o=t?.batch||T(s),r=["published"];t?.releaseId&&r.push(`release:${t.releaseId}`),e.forEach(i=>{let c=n[i];if(!c)throw new Error(`doc does not exist: ${i}`);Z(o,i,c,r,t?.publishMessage)}),await o.commit(),e.length===1?console.log(`published ${e[0]}`):console.log(`published ${e.length} docs: ${e.join(", ")}`);for(let i of e){let c={docId:i};t?.publishMessage&&(c.publishMessage=t.publishMessage),u("doc.publish",{metadata:c})}U(e)}function Z(e,t,s,n,o){if(te(s))throw new Error(`publishing is locked for doc: ${s.id}`);if(ee(s))throw new Error(`cannot publish archived doc: ${s.id}`);let r=window.__ROOT_CTX.rootConfig.projectId,i=window.firebase.db,[c,a]=t.split("/"),b=d(i,"Projects",r,"Collections",c,"Drafts",a),f=d(i,"Projects",r,"Collections",c,"Scheduled",a),p=d(i,"Projects",r,"Collections",c,"Published",a),m={...s},l=m.sys??{};l.modifiedAt=h(),l.modifiedBy=window.firebase.user.email,l.publishedAt=h(),l.publishedBy=window.firebase.user.email,l.firstPublishedAt??=h(),l.firstPublishedBy??=window.firebase.user.email,delete l.scheduledAt,delete l.scheduledBy,e.update(b,{sys:l}),e.set(p,{...m,sys:l}),e.delete(f);let y=d(i,"Projects",r,"Collections",c,"Drafts",a,"Versions",String(Date.now())),R={id:t,collection:c,slug:a,fields:m.fields||{},sys:l};n?.length&&(R.tags=n),o&&(R.publishMessage=o),e.set(y,R)}async function Ae(e,t,s){let n=window.__ROOT_CTX.rootConfig.projectId,o=window.firebase.db,[r,i]=e.split("/"),c=d(o,"Projects",n,"Collections",r,"Drafts",i),a=d(o,"Projects",n,"Collections",r,"Scheduled",i);await _(o,async f=>{let p=await f.get(c);if(!p.exists())throw new Error(`${c.id} does not exist`);let m={...p.data()},l=m.sys??{};l.modifiedAt=h(),l.modifiedBy=window.firebase.user.email,l.scheduledAt=C.fromMillis(t),l.scheduledBy=window.firebase.user.email,f.update(c,{sys:l});let y={...m,sys:l};s?.publishMessage&&(y.scheduledPublishMessage=s.publishMessage),f.set(a,y)}),console.log(`saved ${a.id}`);let b={docId:e,scheduledAt:t};s?.publishMessage&&(b.publishMessage=s.publishMessage),u("doc.schedule",{metadata:b})}async function ke(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Scheduled",o),c=d(s,"Projects",t,"Collections",n,"Published",o),a=T(s);a.update(r,{"sys.modifiedAt":h(),"sys.modifiedBy":window.firebase.user.email,"sys.publishedAt":w(),"sys.publishedBy":w(),"sys.firstPublishedAt":w(),"sys.firstPublishedBy":w()}),a.delete(i),a.delete(c),await a.commit(),console.log(`unpublished ${e}`),u("doc.unpublish",{metadata:{docId:e}}),v(e)}async function je(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Published",o);await _(s,async c=>{let a=await c.get(i);if(!a.exists())throw new Error(`${i.id} does not exist`);let b=a.data();c.set(r,b)}),console.log(`reverted draft ${e}`),u("doc.revert",{metadata:{docId:e}})}async function Be(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/"),r=d(s,"Projects",t,"Collections",n,"Drafts",o),i=d(s,"Projects",t,"Collections",n,"Scheduled",o),c=T(s);c.update(r,{"sys.modifiedAt":h(),"sys.modifiedBy":window.firebase.user.email,"sys.scheduledAt":w(),"sys.scheduledBy":w()}),c.delete(i),await c.commit(),console.log(`unscheduled ${e}`),u("doc.unschedule",{metadata:{docId:e}})}async function _e(e,t){let s={lockedAt:h(),lockedBy:window.firebase.user.email,reason:t.reason||`Locked by ${window.firebase.user.email}.`};t.until&&(s.until=C.fromMillis(t.until));let n=g(e);await x(n,{"sys.publishingLocked":s});let r={docId:e,reason:t.reason};t.until&&(r.until=t.until),u("doc.lock_publishing",{metadata:r})}async function Me(e){let t=g(e),s={"sys.publishingLocked":w()};await x(t,s),u("doc.unlock_publishing",{metadata:{docId:e}})}async function Pe(e){let t=g(e);await x(t,{"sys.archivedAt":h(),"sys.archivedBy":window.firebase.user.email}),u("doc.archive",{metadata:{docId:e}})}async function ve(e){let t=g(e);await x(t,{"sys.archivedAt":w(),"sys.archivedBy":w()}),u("doc.unarchive",{metadata:{docId:e}})}function ee(e){return!!e?.sys?.archivedAt}function Se(e){let t=C.now().toMillis();return(e?.sys?.scheduledAt?.toMillis()||0)>t}function te(e){if(e?.sys?.publishingLocked){if(e.sys.publishingLocked.until){let t=C.now().toMillis(),s=e.sys.publishingLocked.until.toMillis();return t<s}return!0}return!1}async function Oe(e,t,s){let n=g(e),o=await D(n);if(!o.exists())throw new Error(`doc ${e} does not exist`);let r=o.data(),i=r.fields??{},c=r.sys?.locales;await se(t,{fields:i,locales:c,overwrite:s?.overwrite})}async function se(e,t){let[s,n]=e.split("/"),o=g(e),r=await D(o);if(r.exists()&&!t?.overwrite)throw new Error(`${e} already exists`);let i={id:e,collection:s,slug:n,sys:{createdAt:h(),createdBy:window.firebase.user.email,modifiedAt:h(),modifiedBy:window.firebase.user.email,locales:t?.locales??["en"]},fields:t?.fields??{}};if(r.exists()&&t?.overwrite){let c=r.data();i.sys={...c.sys,locales:t?.locales??c.sys.locales,modifiedAt:h(),modifiedBy:window.firebase.user.email}}await E(o,i),u("doc.create",{metadata:{docId:e}})}async function Le(e,t,s){let o=(window.__ROOT_CTX.rootConfig.i18n||{}).locales||["en"];function r(l){for(let y of o)if(String(y).toLowerCase()===l.toLowerCase())return y;return null}let i={};for(let l of t){if(!l.source)continue;let y={source:M(l.source)};Object.entries(l).forEach(([S,J])=>{if(S==="source")return;let O=r(S);O&&(y[O]=M(J||""))});let R=await G(y.source);i[R]=y}let a=[e.split("/")[0],e];s?.tags&&a.push(...s.tags);let b=X(),f=window.firebase.db,p=T(f),m=0;for(let l in i){let y=i[l],R=d(b,l);p.set(R,{...y,tags:F(...a)},{merge:!0}),m+=1,m>=500&&(await p.commit(),p=T(f),console.log(`saved ${m} strings`),m=0)}return m>0&&(await p.commit(),console.log(`saved ${m} strings`)),u("doc.import_translations",{metadata:{docId:e,...s?.actionMetadata},links:s?.actionLinks}),i}function g(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return d(s,"Projects",t,"Collections",n,"Drafts",o)}function oe(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,[n,o]=e.split("/");return d(s,"Projects",t,"Collections",n,"Published",o)}function ne(e,t){let s=window.__ROOT_CTX.rootConfig.projectId,n=window.firebase.db,[o,r]=e.split("/");return d(n,"Projects",s,"Collections",o,"Drafts",r,"Versions",t)}async function ie(e){let t=window.__ROOT_CTX.rootConfig.projectId,s=window.firebase.db,n={};e.forEach(r=>{let[i,c]=r.split("/");i in n?n[i].push(c):n[i]=[c]});let o={};return await Promise.all(Object.entries(n).map(async([r,i])=>{let c=k(s,"Projects",t,"Collections",r,"Drafts"),a=A(c,j(L(),"in",i));(await B(a)).forEach(f=>{let p=`${r}/${f.id}`;o[p]=f.data()})})),o}async function Ie(e,t){let s=window.firebase.db,n=g(e),o=k(s,n.path,"Versions"),r=t?.limit??50,i=A(o,I("sys.modifiedAt","desc"),V(r));t?.tags&&(i=A(i,j("tags","array-contains-any",t.tags))),t?.cursor&&(i=A(i,$(t.cursor)));let c=await B(i),a=[],b=null;return c.forEach(f=>{let p={...f.data(),_versionId:f.id};a.push(p),b=f}),{versions:a,lastDoc:b,hasMore:c.size===r}}async function Ve(e,t){let s=g(e),n={"sys.modifiedAt":h(),"sys.modifiedBy":window.firebase.user.email,fields:t.fields||{}};await x(s,n),u("doc.restore_version",{metadata:{docId:e,versionModifiedAt:t.sys?.modifiedAt,versionModifiedBy:t.sys?.modifiedBy}})}async function $e(e,t){let s;t==="draft"?s=g(e):t==="published"?s=oe(e):s=ne(e,t);let n=await D(s);return n.exists()?n.data():null}async function Ee(e,t){if(!t?.spreadsheetId)throw new Error("no spreadsheet id");let s=g(e),n={"sys.l10nSheet":{spreadsheetId:t.spreadsheetId,gid:t.gid||0,linkedAt:h(),linkedBy:window.firebase.user.email}};await x(s,n),u("doc.link_sheet",{metadata:{docId:e,sheetId:t}})}async function Fe(e){let t=g(e),s={"sys.l10nSheet":w()};await x(t,s),u("doc.unlink_sheet",{metadata:{docId:e}})}async function Xe(e){let t=g(e),o=(await D(t)).data()?.sys?.l10nSheet||{};return o?.spreadsheetId?{spreadsheetId:o.spreadsheetId,gid:o.gid||0}:null}function q(e,t){let s={};for(let n in e){let o=e[n];if(N(o))if(o.toMillis)s[n]=o.toMillis();else if(Object.hasOwn(o,"_array")&&Array.isArray(o._array)){let r=o._array.map(i=>{let c={...q(o[i]||{},t),_arrayKey:i};return t?.removeArrayKey&&delete c._arrayKey,c});s[n]=r}else s[n]=q(o,t);else s[n]=o}return s}async function Ge(e,t){let s=await window.fetch("/cms/api/ai.diff",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({docId:e,beforeVersion:t?.beforeVersion||"published",afterVersion:t?.afterVersion||"draft"})}),n=await s.text(),o=null;try{o=JSON.parse(n)}catch{}if(!s.ok||o?.success===!1){let r=o&&(o.error||o.message)||n;throw new Error(r||"Failed to fetch AI summary")}return typeof o?.summary=="string"?o.summary:typeof o?.data?.summary=="string"?o.data.summary:!o&&n?n:""}function N(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null}function He(e){let[t,s]=e.split("/");return{id:e,collection:t,slug:s}}function z(e){if(re(e))return C.fromMillis(e.seconds*1e3);if(Q(e))return e.time=Date.now(),e;if(Array.isArray(e))return e.map(t=>z(t));if(N(e)){let t={};return Object.keys(e).forEach(s=>{t[s]=z(e[s])}),t}return e}function re(e){return e?.type==="firestore/timestamp/1.0"}export{Q as a,fe as b,W as c,Te as d,Ce as e,Y as f,Ae as g,ke as h,je as i,Be as j,_e as k,Me as l,Pe as m,ve as n,ee as o,Se as p,te as q,Oe as r,se as s,Le as t,ie as u,Ie as v,Ve as w,$e as x,Ee as y,Fe as z,Xe as A,q as B,Ge as C,He as D,z as E};
@@ -0,0 +1 @@
1
+ import{C as ye,D as k,E as Se,G as J,H as Ee,I as we,K as Oe,O as xe,P as Pe,Q as Ce,S as Ae,T as be,Y as U,_ as Re,a as P,b as ae,c as q,d as se,e as y,g as le,ga as De,i as $,ia as Ie,j as ve,ja as Le,ka as je,la as Te,v as c,va as ke,y as b}from"./chunk-NZHF733K.js";import{a as Q,b as x,f as _e,i as ne,j as H,k as ie}from"./chunk-KUCVLANF.js";ie();ve();var N,W;function Ot(e){return!W||(typeof W=="string"?e.startsWith(W):W.test(e))}function xt(e,t){let r="";if(N=void 0,t&&t.type==="click"){if(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||t.button!==0)return e;let o=t.composedPath().find(i=>i.nodeName=="A"&&i.href),n=o&&o.getAttribute("href");if(!o||o.origin!=location.origin||/^#/.test(n)||!/^(_?self)?$/i.test(o.target)||!Ot(n)||o.download)return e;N=!0,t.preventDefault(),r=o.href.replace(location.origin,"")}else t&&t.url?(N=!t.replace,r=t.url):r=location.pathname+location.search;return N===!0?history.pushState(null,"",r):N===!1&&history.replaceState(null,"",r),r}var Pt=(e,t,r={})=>{e=e.split("/").filter(Boolean),t=(t||"").split("/").filter(Boolean),r.params||(r.params={});for(let o=0,n,i;o<Math.max(e.length,t.length);o++){let[,s,u,l]=(t[o]||"").match(/^(:?)(.*?)([+*?]?)$/);if(n=e[o],!(!s&&u==n)){if(!s&&n&&l=="*"){r.rest="/"+e.slice(o).map(decodeURIComponent).join("/");break}if(!s||!n&&l!="?"&&l!="*")return;if(i=l=="+"||l=="*",i?n=e.slice(o).map(decodeURIComponent).join("/")||void 0:n&&(n=decodeURIComponent(n)),r.params[u]=n,u in r||(r[u]=n),i)break}}return r};function F(e){let[t,r]=ae(xt,e.url||location.pathname+location.search);e.scope&&(W=e.scope);let o=N===!0,n=le(()=>{let i=new URL(t,location.origin),s=i.pathname.replace(/\/+$/g,"")||"/";return{url:t,path:s,query:Object.fromEntries(i.searchParams),route:(u,l)=>r({url:u,replace:l}),wasPush:o}},[t]);return se(()=>(addEventListener("click",r),addEventListener("popstate",r),()=>{removeEventListener("click",r),removeEventListener("popstate",r)}),[]),x(F.ctx.Provider,{value:n},e.children)}var Ct=Promise.resolve();function Me(e){let[t,r]=ae(p=>p+1,0),{url:o,query:n,wasPush:i,path:s}=Be();if(!o)throw new Error("preact-iso's <Router> must be used within a <LocationProvider>, see: https://github.com/preactjs/preact-iso#locationprovider");let{rest:u=s,params:l={}}=$(Ne),f=y(!1),d=y(s),h=y(0),a=y(),m=y(),_=y(),g=y(!1),w=y();w.current=!1;let R,C,E;_e(e.children).some(p=>{if(Pt(u,p.props.path,E={...p.props,path:u,query:n,params:Object.assign({},l),rest:""}))return R=ne(p,E);p.props.default&&(C=ne(p,E))});let O=R||C,D=a.current&&a.current.__u&Y&&a.current.__u&Z,I=a.current&&a.current.__h,M=le(()=>{m.current=a.current,a.current=x(Ne.Provider,{value:E},O);let p=m.current&&m.current.props.children;return!p||!O||O.type!==p.type||O.props.component!==p.props.component?(this.__v&&this.__v.__k&&this.__v.__k.reverse(),h.current++,!0):!1},[o,JSON.stringify(E)]);D?(a.current.__u|=Y,a.current.__u|=Z):I&&(a.current.__h=!0);let L=m.current;return m.current=null,this.__c=(p,A)=>{w.current=!0,m.current=L,e.onLoadStart&&e.onLoadStart(o),f.current=!0;let re=h.current;p.then(()=>{re===h.current&&(m.current=null,a.current&&(A.__h&&(a.current.__h=A.__h),A.__u&Z&&(a.current.__u|=Z),A.__u&Y&&(a.current.__u|=Y)),Ct.then(r))})},se(()=>{let p=this.__v&&this.__v.__e;if(w.current){!g.current&&!_.current&&(_.current=p);return}!g.current&&_.current&&(_.current!==p&&_.current.remove(),_.current=null),g.current=!0,d.current!==s&&(i&&scrollTo(0,0),e.onRouteChange&&e.onRouteChange(o),d.current=s),e.onLoadEnd&&f.current&&e.onLoadEnd(o),f.current=!1},[s,i,t]),M?[x(ce,{r:a}),x(ce,{r:m})]:x(ce,{r:a})}var Y=32,Z=128,ce=({r:e})=>e.current;Me.Provider=F;F.ctx=H({});var Ne=H({}),At=e=>x(e.component,e),Be=()=>$(F.ctx);ie();ve();var ze=Q.__b;Q.__b=e=>{e.type&&e.type._forwarded&&e.ref&&(e.props.ref=e.ref,e.ref=null),ze&&ze(e)};function He(e){let t,r,o=()=>e().then(i=>r=i&&i.default||i),n=i=>{let[,s]=P(0),u=y(r);if(t||(t=o()),r!==void 0)return x(r,i);throw u.current||(u.current=t.then(()=>s(1))),t};return n.preload=()=>(t||(t=o()),t),n._forwarded=!0,n}var Qe=Q.__e;Q.__e=(e,t,r)=>{if(e&&e.then){let o=t;for(;o=o.__;)if(o.__c&&o.__c.__c)return t.__e==null&&(t.__c.__z=[r.__e],t.__e=r.__e,t.__k=r.__k),t.__k||(t.__k=[]),o.__c.__c(e,t)}Qe&&Qe(e,t,r)};ie();function Er(...e){return e.filter(t=>!!t).join(" ")||void 0}b();b();var bt=Object.defineProperty,Rt=Object.defineProperties,Dt=Object.getOwnPropertyDescriptors,Ue=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable,We=(e,t,r)=>t in e?bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jt=(e,t)=>{for(var r in t||(t={}))It.call(t,r)&&We(e,r,t[r]);if(Ue)for(var r of Ue(t))Lt.call(t,r)&&We(e,r,t[r]);return e},Tt=(e,t)=>Rt(e,Dt(t));function kt(e){return Tt(jt({},e),{id:e.id||Oe()})}function Nt(e){let t=[];return e.reduceRight((r,o)=>(t.includes(o.id)||(t.push(o.id),r.push(o)),r),[]).reverse()}function X(e){return Nt(e.map(t=>kt(t)))}function Fe(e,t){let[r,o]=P(X(typeof e=="function"?e(t):e));return q(()=>{typeof e=="function"&&o(X(e(t)))},[t]),[r,{registerActions:l=>o(f=>X([...f,...l])),updateActions:l=>o(X(typeof l=="function"?l(t):l)),removeActions:l=>o(f=>f.filter(d=>!l.includes(d.id))),triggerAction:l=>{var f;let d=r.find(h=>h.id===l);(f=d?.onTrigger)==null||f.call(d,d)}}]}function Mt(e,t){return e===null?[]:Array.isArray(e)?e.map(r=>[r,t]):[[e,t]]}function Ke(e,t){Pe(Mt(e,t))}b();b();var Bt=k((e,{radius:t})=>({action:{position:"relative",display:"block",width:"100%",padding:"10px 12px",borderRadius:e.fn.radius(t)},actionHovered:{backgroundColor:e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[1]},actionIcon:{color:e.colorScheme==="dark"?e.colors.dark[2]:e.colors.gray[6]},actionBody:{flex:1}})),Ge=Bt;var zt=Object.defineProperty,V=Object.getOwnPropertySymbols,$e=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,qe=(e,t,r)=>t in e?zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qt=(e,t)=>{for(var r in t||(t={}))$e.call(t,r)&&qe(e,r,t[r]);if(V)for(var r of V(t))Je.call(t,r)&&qe(e,r,t[r]);return e},Ht=(e,t)=>{var r={};for(var o in e)$e.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&V)for(var o of V(e))t.indexOf(o)<0&&Je.call(e,o)&&(r[o]=e[o]);return r};function ue(e){var t=e,{action:r,styles:o,classNames:n,hovered:i,onTrigger:s,highlightQuery:u,highlightColor:l,query:f,radius:d}=t,h=Ht(t,["action","styles","classNames","hovered","onTrigger","highlightQuery","highlightColor","query","radius"]);let{classes:a,cx:m}=Ge({radius:d},{styles:o,classNames:n,name:"Spotlight"});return c.createElement(Ae,Qt({className:m(a.action,{[a.actionHovered]:i}),tabIndex:-1,onMouseDown:_=>_.preventDefault(),onClick:s},h),c.createElement(De,{noWrap:!0},r.icon&&c.createElement(be,{className:a.actionIcon},r.icon),c.createElement("div",{className:a.actionBody},c.createElement(Te,{highlightColor:l,highlight:u?f:null},r.title),r.description&&c.createElement(U,{color:"dimmed",size:"xs"},r.description))))}ue.displayName="@mantine/spotlight/DefaultAction";b();var Ut=k(e=>({nothingFound:{},actions:{padding:e.spacing.xs/2,borderTop:`1px solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[2]}`},actionsGroup:{textTransform:"uppercase",fontSize:e.spacing.xs,fontWeight:700,padding:"10px 12px",paddingBottom:0,paddingTop:15}})),Ye=Ut;function pe({actions:e,styles:t,classNames:r,actionComponent:o,hovered:n,onActionHover:i,onActionTrigger:s,query:u,nothingFoundMessage:l,highlightQuery:f,highlightColor:d,radius:h}){let{classes:a}=Ye(null,{classNames:r,styles:t,name:"Spotlight"}),m=e.map(g=>g.type==="item"?c.createElement(o,{query:u,key:g.item.id,action:g.item,hovered:g.index===n,onMouseEnter:()=>i(g.index),classNames:r,styles:t,radius:h,onTrigger:()=>s(g.item),highlightQuery:f,highlightColor:d}):c.createElement(U,{className:a.actionsGroup,color:"dimmed",key:g.label},g.label)),_=m.length>0||!!l&&u.trim().length>0;return c.createElement(c.Fragment,null,_&&c.createElement("div",{className:a.actions},m.length>0?m:c.createElement(U,{color:"dimmed",className:a.nothingFound,align:"center",size:"lg",py:"md"},l)))}pe.displayName="@mantine/spotlight/ActionsList";function Wt(e){return Array.isArray(e)?e.map(t=>t.trim()).join(",").toLowerCase().trim():typeof e=="string"?e.toLowerCase().trim():""}function Ze(e,t){let r=e.trim().toLowerCase(),o=[[],[]];return t.forEach(n=>{var i,s;(i=n.title)!=null&&i.toLowerCase().includes(r)?o[0].push(n):((s=n.description)!=null&&s.toLowerCase().includes(r)||Wt(n.keywords).includes(r))&&o[1].push(n)}),o.flat()}var Ft=Object.defineProperty,Kt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable,Ve=(e,t,r)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t)=>{for(var r in t||(t={}))qt.call(t,r)&&Ve(e,r,t[r]);if(Xe)for(var r of Xe(t))$t.call(t,r)&&Ve(e,r,t[r]);return e},tt=(e,t)=>Kt(e,Gt(t)),Jt=k((e,{centered:t,maxWidth:r,topOffset:o,radius:n})=>({root:tt(et({},e.fn.cover()),{position:"fixed"}),spotlight:{position:"relative",zIndex:2,backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white,borderRadius:e.fn.radius(n),width:"100%",maxWidth:r,overflow:"hidden",marginLeft:"calc(var(--removed-scroll-width, 0px) * -1)"},overlay:tt(et({},e.fn.cover()),{position:"fixed"}),inner:{height:"100vh",display:"flex",flexDirection:"column",paddingTop:t?e.spacing.md:o,justifyContent:t?"center":"flex-start",alignItems:"center"},searchInput:{border:0,borderBottomRightRadius:0,borderBottomLeftRadius:0,backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white}})),rt=Jt;var Yt=Object.defineProperty,ee=Object.getOwnPropertySymbols,nt=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable,ot=(e,t,r)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Zt=(e,t)=>{for(var r in t||(t={}))nt.call(t,r)&&ot(e,r,t[r]);if(ee)for(var r of ee(t))it.call(t,r)&&ot(e,r,t[r]);return e},Xt=(e,t)=>{var r={};for(var o in e)nt.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&ee)for(var o of ee(e))t.indexOf(o)<0&&it.call(e,o)&&(r[o]=e[o]);return r};function fe(e){var t=e,{query:r,onQueryChange:o,actions:n,onClose:i,opened:s,withinPortal:u,transition:l="pop",transitionDuration:f,classNames:d,styles:h,overlayColor:a="#000",overlayOpacity:m=.25,overlayBlur:_=3,shadow:g="md",radius:w="sm",centered:R=!1,closeOnActionTrigger:C=!0,highlightQuery:E=!1,highlightColor:O,maxWidth:D=600,topOffset:I=120,className:M,searchPlaceholder:L,searchIcon:p,filter:A=Ze,nothingFoundMessage:re,limit:ft=10,actionComponent:dt=ue,actionsWrapperComponent:mt="div",zIndex:gt=ye("modal")}=t,ht=Xt(t,["query","onQueryChange","actions","onClose","opened","withinPortal","transition","transitionDuration","classNames","styles","overlayColor","overlayOpacity","overlayBlur","shadow","radius","centered","closeOnActionTrigger","highlightQuery","highlightColor","maxWidth","topOffset","className","searchPlaceholder","searchIcon","filter","nothingFoundMessage","limit","actionComponent","actionsWrapperComponent","zIndex"]);let[K,j]=P(-1),[_t,me]=P(!1),{classes:B,cx:vt}=rt({centered:R,maxWidth:D,topOffset:I,radius:w},{classNames:d,styles:h,name:"Spotlight"}),[,ge]=xe(),yt=we(s),oe=()=>j(-1),G=()=>{oe(),i()};Ee({transitionDuration:0,opened:s});let St=A(r,n).slice(0,ft),he=Se(St).items,T=he.map(v=>v.type==="item"?v.item:void 0).filter(v=>v);J(()=>{T.length-1<K&&j(T.length-1)},[T.length]);let Et=v=>{var z;if(!_t)switch(v.code){case"ArrowDown":{v.preventDefault(),j(S=>S<T.length-1?S+1:0);break}case"ArrowUp":{v.preventDefault(),j(S=>S>0?S-1:T.length-1);break}case"Enter":{v.preventDefault();let S=T[K];(z=S?.onTrigger)==null||z.call(S,S),C&&S?.onTrigger&&G();break}case"Escape":v.preventDefault(),G()}},wt=v=>{o(v.currentTarget.value),K===-1&&j(0)};return c.createElement(Ie,{withinPortal:u,zIndex:gt},c.createElement(Le,{onExited:()=>ge(!1),onEntered:()=>ge(!0),mounted:s,transitions:{spotlight:{duration:f,transition:l,timingFunction:"ease"},overlay:{duration:f/2,transition:"fade",timingFunction:"ease"}}},v=>c.createElement("div",Zt({className:vt(B.root,M)},ht),c.createElement("div",{className:B.inner,ref:yt},c.createElement(Re,{style:v.spotlight,className:B.spotlight,shadow:g,radius:w,onMouseLeave:oe},c.createElement(ke,{value:r,onChange:wt,onKeyDown:Et,onCompositionStart:()=>me(!0),onCompositionEnd:()=>me(!1),classNames:{input:B.searchInput},size:"lg",placeholder:L,icon:p,onMouseEnter:oe,autoComplete:"chrome-please-just-do-not-show-it-thanks"}),c.createElement(mt,null,c.createElement(pe,{highlightQuery:E,highlightColor:O,actions:he,actionComponent:dt,hovered:K,query:r,nothingFoundMessage:re,onActionHover:j,onActionTrigger:z=>{z.onTrigger(z),C&&G()},styles:h,classNames:d,radius:w}))),c.createElement("div",{style:v.overlay},c.createElement(je,{className:B.overlay,zIndex:1,onMouseDown:G,color:a,opacity:m,blur:_}))))))}fe.displayName="@mantine/spotlight/Spotlight";b();var de={open:"mantine:open-spotlight",close:"mantine:close-spotlight",toggle:"mantine:toggle-spotlight",triggerAction:"mantine:trigger-spotlight-action",registerActions:"mantine:register-spotlight-actions",removeActions:"mantine:remove-spotlight-actions"};function Vt(e,t){return new CustomEvent(e,{detail:t})}function er(){window.dispatchEvent(Vt(de.open))}function at(e){let t={registerActions:r=>e.registerActions(r.detail),removeActions:r=>e.removeActions(r.detail),triggerAction:r=>e.triggerAction(r.detail),open:e.openSpotlight,close:e.closeSpotlight,toggle:e.toggleSpotlight};q(()=>(Object.keys(t).forEach(r=>{window.addEventListener(de[r],t[r])}),()=>{Object.keys(t).forEach(r=>{window.removeEventListener(de[r],t[r])})}),[])}b();var st=H(null);var tr=Object.defineProperty,te=Object.getOwnPropertySymbols,ct=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,lt=(e,t,r)=>t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rr=(e,t)=>{for(var r in t||(t={}))ct.call(t,r)&&lt(e,r,t[r]);if(te)for(var r of te(t))ut.call(t,r)&&lt(e,r,t[r]);return e},or=(e,t)=>{var r={};for(var o in e)ct.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&te)for(var o of te(e))t.indexOf(o)<0&&ut.call(e,o)&&(r[o]=e[o]);return r};function pt(e){var t=e,{actions:r,children:o,shortcut:n="mod + K",onSpotlightClose:i,onSpotlightOpen:s,onQueryChange:u,cleanQueryOnClose:l=!0,transitionDuration:f=150}=t,d=or(t,["actions","children","shortcut","onSpotlightClose","onSpotlightOpen","onQueryChange","cleanQueryOnClose","transitionDuration"]);let h=y(-1),[a,m]=P(""),[_,{registerActions:g,updateActions:w,removeActions:R,triggerAction:C}]=Fe(r,a);J(()=>{w(r)},[r]);let E=p=>{m(p),u?.(p)},[O,{open:D,close:I,toggle:M}]=Ce(!1,{onClose:()=>{i?.(),l&&(h.current=window.setTimeout(()=>{E("")},f))},onOpen:()=>{s?.(),window.clearTimeout(h.current)}}),L={openSpotlight:D,closeSpotlight:I,toggleSpotlight:M,registerActions:g,removeActions:R,triggerAction:C,opened:O,actions:_,query:a};return Ke(n,D),at(L),c.createElement(st.Provider,{value:L},c.createElement(fe,rr({actions:_,onClose:I,opened:O,query:a,onQueryChange:E,transitionDuration:f},d)),o)}pt.displayName="@mantine/spotlight/SpotlightProvider";export{F as a,Me as b,At as c,Be as d,He as e,Er as f,er as g,pt as h};
@@ -0,0 +1 @@
1
+ import{b as R,f as O,g as U,i as A,j as H,k as j,m as N,o as M}from"./chunk-EGEB6N4J.js";import{a,c as E,e as x,h as D,j as B}from"./chunk-NZHF733K.js";B();var F=200,X=25,Y=2;function W(u,d={}){let[b,r]=a([]),[f,t]=a(!1),[e,g]=a(null),[y,n]=a(null),o=x(null),T=d.limit??X,L=d.minQueryLength??Y;return E(()=>{let h=u.trim();if(h.length<L){o.current?.abort(),o.current=null,r([]),t(!1),g(null);return}t(!0),g(null);let S=window.setTimeout(async()=>{o.current?.abort();let s=new AbortController;o.current=s;try{let l=await fetch("/cms/api/search.query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({q:h,limit:T}),signal:s.signal});if(!l.ok)throw new Error(`search.query returned ${l.status}`);let c=await l.json();if(!c?.success)throw new Error(c?.error||"search failed");if(s.signal.aborted)return;r(Array.isArray(c.hits)?c.hits:[]),n(c.meta||null),t(!1)}catch(l){if(s.signal.aborted)return;console.error("global search failed:",l),g(String(l?.message||l)),r([]),t(!1)}},F);return()=>{window.clearTimeout(S)}},[u,T,L]),{hits:b,loading:f,error:e,status:y}}function Z(){let[u,d]=a({status:{lastRun:null,docCount:0,fieldCount:0,shardCount:0},running:!1}),[b,r]=a(!0),f=D(async()=>{try{let t=await fetch("/cms/api/search.status",{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)return;let e=await t.json();if(!e?.success)return;d({status:e.status,running:!!e.running})}catch(t){console.error("search.status failed:",t)}finally{r(!1)}},[]);return E(()=>{f()},[f]),{...u,loading:b,refresh:f}}var v=200,J=5,K=2;function tt(u,d={}){let[b,r]=a([]),[f,t]=a(!1),e=x(null),g=d.limit??10,y=d.minQueryLength??K;return E(()=>{let n=u.trim(),o=n.indexOf("/");if((o>=0?n.slice(o+1):n).length<y){e.current&&(e.current.aborted=!0),e.current=null,r([]),t(!1);return}t(!0);let L=window.setTimeout(async()=>{e.current&&(e.current.aborted=!0);let h={aborted:!1};e.current=h;let S=null,s=n;o>=0&&(S=n.slice(0,o),s=n.slice(o+1));let l=window.__ROOT_CTX?.rootConfig?.projectId,c=window.firebase?.db;if(!l||!c){r([]),t(!1);return}let I=Object.keys(window.__ROOT_CTX.collections||{}),q=S?I.filter(p=>p.toLowerCase()===S.toLowerCase()):I,P=s,Q=`${s}\uF8FF`;try{let p=q.map(async i=>{let w=R(c,"Projects",l,"Collections",i,"Drafts"),C=U(w,A(O()),j(P),N(Q),H(J));try{let m=await M(C),_=[];return m.forEach(G=>{_.push({collection:i,slug:G.id,docId:`${i}/${G.id}`})}),_}catch(m){return console.error(`docSlugSearch failed for ${i}:`,m),[]}}),$=(await Promise.all(p)).flat();if(h.aborted)return;let k=$.sort((i,w)=>{let C=i.slug===s||i.docId===n?0:1,m=w.slug===s||w.docId===n?0:1;return C!==m?C-m:i.docId.localeCompare(w.docId)});r(k.slice(0,g)),t(!1)}catch(p){if(h.aborted)return;console.error("docSlugSearch failed:",p),r([]),t(!1)}},v);return()=>{window.clearTimeout(L)}},[u,g,y]),{hits:b,loading:f}}export{W as a,Z as b,tt as c};
@@ -0,0 +1,3 @@
1
+ import{a as Z}from"./chunk-CGCKJFL4.js";import{a as Q,c as X,e as Y}from"./chunk-4KE2SZKH.js";import{c as K}from"./chunk-W3HIZQ4Z.js";import{a as j}from"./chunk-JDW4UORS.js";import{b as J}from"./chunk-62UWGWON.js";import{a as x}from"./chunk-I6ICVKEC.js";import{d as W}from"./chunk-AL3TN2KI.js";import{Aa as S,Ha as e,a as s,c as q,e as B,ea as A,fa as P,j as re,oa as b,qa as $,va as F,wa as V}from"./chunk-NZHF733K.js";import{d as M}from"./chunk-KUCVLANF.js";re();var se="Enter the URL to make the HTTP request.",ne="Enter the URL of the Google Sheet, e.g. https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit#gid=SHEET_ID";function Ne(a){let{route:n}=W(),c=B(null),i=Z(),[h,d]=s(!1),[r,U]=s(i.enabled?"gsheet":"http"),[g,z]=s("map"),[v,ee]=s("GET"),[y,T]=s(!1),[w,N]=s(1),[E,H]=s("hours"),[R,C]=s(!1),[L,p]=s(""),[te,O]=s(!!a.dataSourceId),[_,G]=s(null),I="";r==="http"?I=se:r==="gsheet"&&(I=ne);async function ae(t){await J(async()=>{let o=await X(t);G(o),U(o?.type||"http"),z(o?.dataFormat||"map"),o?.cron?(T(o.cron.enabled||!1),N(o.cron.interval||1),H(o.cron.unit||"hours"),C(o.cron.autoPublish||!1)):(T(!1),N(1),H("hours"),C(!1))}),O(!1)}q(()=>{a.dataSourceId&&(O(!0),ae(a.dataSourceId))},[a.dataSourceId]);async function oe(){p("");let t=c.current;function o(l){let f=t.elements[l];return f?f.value.trim():""}let m=a.dataSourceId||o("id");if(!m){p("missing id");return}if(!j(m)){p("id is invalid (alphanumeric characters and dashes only)");return}let D=o("url");if(!D){p("missing url");return}let u={id:m,description:o("description"),type:r,url:D,previewUrl:o("previewUrl")};if(r==="http"){if(!ie(D)){p("invalid url");return}u.httpOptions={method:v};let l=o("httpHeaders");if(l&&(u.httpOptions.headers=ue(l)),v==="POST"){let f=o("httpBody");f&&(u.httpOptions.body=f)}}else if(r==="gsheet"){if(!K(D)?.spreadsheetId){p("failed to parse spreadsheet url");return}u.dataFormat=g||"map"}y?u.cron={enabled:!0,interval:w,unit:E,autoPublish:R}:u.cron={enabled:!1,interval:w,unit:E};try{G(u),d(!0),a.dataSourceId?(await Y(a.dataSourceId,u),x({title:"Saved data source",message:`Successfully updated ${m}`,autoClose:5e3}),d(!1)):(await Q(m,u),x({title:"Added data source",message:`Successfully added ${m}`,autoClose:5e3}),d(!1),n(`/cms/data/${m}`))}catch(l){console.error(l),x({title:"Failed to save data source",message:String(l),color:"red",autoClose:!1}),d(!1)}}let k=[{value:"http",label:"HTTP"}];return(i.enabled||r==="gsheet")&&k.push({value:"gsheet",label:"Google Sheet"}),e("form",{className:"DataSourceForm",ref:c,onSubmit:t=>{t.preventDefault(),oe()},children:[e($,{visible:te}),e("div",{className:"DataSourceForm__input",children:e(S,{name:"type",label:"Type",data:k,value:r,onChange:t=>U(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(F,{className:"DataSourceForm__input",name:"id",label:"ID",description:"Unique identifier for the data source. Use alphanumeric characters and dashes only, e.g. grogus-favorite-meals",size:"xs",radius:0,value:a.dataSourceId,disabled:!!a.dataSourceId}),e(b,{className:"DataSourceForm__input",name:"description",label:"Description",description:"Optional.",size:"xs",radius:0,value:_?.description}),e(F,{className:"DataSourceForm__input",name:"url",label:"URL",description:I,size:"xs",radius:0,value:_?.url}),r==="http"&&e(M,{children:[e("div",{className:"DataSourceForm__input",children:e(S,{name:"httpMethod",label:"HTTP Request Method",data:[{value:"GET",label:"GET"},{value:"POST",label:"POST"}],value:v,onChange:t=>ee(t),size:"xs",radius:0,dropdownComponent:"div"})}),e(b,{className:"DataSourceForm__input",name:"httpHeaders",label:"HTTP Request Headers",description:"Format as `HeaderName: Value`, each value on its own line.",size:"xs",radius:0,value:ce(_?.httpOptions?.headers||{})}),v==="POST"&&e(b,{className:"DataSourceForm__input",name:"httpRequestBody",label:"HTTP Request Body",size:"xs",radius:0,value:_?.httpOptions?.body})]}),r==="gsheet"&&e("div",{className:"DataSourceForm__input",children:[e(S,{name:"dataFormat",label:"Data Format",data:[{value:"map",label:"map"}],value:g,onChange:t=>z(t),size:"xs",radius:0,dropdownComponent:"div"}),g==="array"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of arrays, e.g.",e("code",{children:"[[header1, header2], [foo, bar]]"})]}),g==="map"&&e("div",{className:"DataSourceForm__input__example",children:["Data is stored as an array of maps, e.g.",e("code",{children:["[","{","header1: foo, header2: bar","}","]"]})]})]}),e("div",{className:"DataSourceForm__section",children:[e("div",{className:"DataSourceForm__section__label",children:"Sync Schedule"}),e(P,{className:"DataSourceForm__input",label:"Enable scheduled sync",checked:y,onChange:t=>T(t.currentTarget.checked),size:"xs"}),y&&e("div",{className:"DataSourceForm__cron",children:[e("div",{className:"DataSourceForm__cron__row",children:[e("span",{children:"Run every"}),e(V,{className:"DataSourceForm__cron__interval",value:w,onChange:t=>N(Number(t)||1),min:1,size:"xs",radius:0}),e(S,{className:"DataSourceForm__cron__unit",data:[{value:"minutes",label:"minutes"},{value:"hours",label:"hours"},{value:"days",label:"days"}],value:E,onChange:t=>H(t),size:"xs",radius:0,dropdownComponent:"div"})]}),e(P,{className:"DataSourceForm__input",label:"Auto-publish after sync",checked:R,onChange:t=>C(t.currentTarget.checked),size:"xs"})]})]}),e(F,{className:"DataSourceForm__input",name:"previewUrl",label:"Preview URL",description:"URL where users can preview the data source.",size:"xs",radius:0,value:_?.previewUrl}),e(A,{className:"DataSourceForm__submit",color:"blue",size:"xs",type:"submit",loading:h,children:a.buttonLabel||"Save"}),L&&e("div",{className:"DataSourceForm__error",children:["Error: ",L]})]})}function ie(a){let n,c=a.startsWith("/")?"http://localhost":void 0;try{n=new URL(a,c)}catch(i){return console.error(i),!1}return n.protocol==="http:"||n.protocol==="https:"}function ue(a){let n={};return a.split(`
2
+ `).forEach(i=>{let h=i.indexOf(":");if(h===-1)return;let d=i.slice(0,h).trim(),r=i.slice(h+1).trim();d&&r&&(n[d]=r)}),n}function ce(a){let n=[];for(let c in a){let i=a[c];n.push(`${c}: ${i}`)}return n.join(`
3
+ `)}export{Ne as a};
@@ -0,0 +1 @@
1
+ import{L as m,a,c as f,j as O}from"./chunk-NZHF733K.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};
@@ -0,0 +1 @@
1
+ import{h as M}from"./chunk-RSVO46S3.js";import{a as n,c as _}from"./chunk-HRGYNHZ3.js";import{b as h}from"./chunk-62UWGWON.js";import{a as u}from"./chunk-I6ICVKEC.js";import{e as f}from"./chunk-ORXEMIQC.js";import{a as m}from"./chunk-EGEB6N4J.js";import{Ha as e,a as i,e as c,ea as d,j as I}from"./chunk-NZHF733K.js";I();var S="ScheduleReleaseModal";function F(l){let t=n(),a=_();return{open:()=>{t.openContextModal(S,{...a,title:`Schedule release: ${l.releaseId}`,innerProps:l})}}}function T(l){let{innerProps:t,context:a,id:g}=l,[s,x]=i(""),[R,r]=i(!1),v=c(null),b=n();async function w(){r(!0),await h(async()=>{let o=Math.floor(new Date(s).getTime());if(Math.floor(new Date().getTime())>=o)throw new Error("bad datetime, please choose a date in the future");let y=m.fromMillis(o);await M(t.releaseId,o),u({title:"Scheduled!",message:`Release ${t.releaseId} will go live ${s}.`,autoClose:1e4}),b.closeAll(),t.onScheduled&&t.onScheduled(y)}),r(!1)}return e("div",{className:"ScheduleReleaseModal",children:e("div",{className:"ScheduleReleaseModal__content",children:e("form",{className:"ScheduleReleaseModal__form",onSubmit:o=>{o.preventDefault(),w()},children:[e("div",{className:"ScheduleReleaseModal__form__description",children:"Content in the release will go live at the datetime specified below."}),e("div",{className:"ScheduleReleaseModal__form__dateInput",children:[e("input",{ref:v,type:"datetime-local",value:s,min:f(),onChange:o=>{let p=o.target;x(p.value)}}),e("div",{className:"ScheduleReleaseModal__form__dateInput__help",children:["timezone: ",Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),e("div",{className:"ScheduleReleaseModal__form__buttons",children:[e(d,{variant:"outline",onClick:()=>a.closeModal(g),type:"button",size:"xs",color:"dark",children:"Cancel"}),e(d,{variant:"filled",size:"xs",color:"dark",loading:R,type:"submit",children:"Schedule"})]})]})})})}T.id=S;export{F as a,T as b};
@@ -0,0 +1,15 @@
1
+ var ie=()=>{};var ae=function(t){let e=[],n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=i&63|128):(i&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++r)&1023),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=i&63|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=i&63|128)}return e},Oe=function(t){let e=[],n=0,r=0;for(;n<t.length;){let i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){let s=t[n++];e[r++]=String.fromCharCode((i&31)<<6|s&63)}else if(i>239&&i<365){let s=t[n++],o=t[n++],l=t[n++],c=((i&7)<<18|(s&63)<<12|(o&63)<<6|l&63)-65536;e[r++]=String.fromCharCode(55296+(c>>10)),e[r++]=String.fromCharCode(56320+(c&1023))}else{let s=t[n++],o=t[n++];e[r++]=String.fromCharCode((i&15)<<12|(s&63)<<6|o&63)}}return e.join("")},ce={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();let n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i<t.length;i+=3){let s=t[i],o=i+1<t.length,l=o?t[i+1]:0,c=i+2<t.length,d=c?t[i+2]:0,S=s>>2,m=(s&3)<<4|l>>4,a=(l&15)<<2|d>>6,u=d&63;c||(u=64,o||(a=64)),r.push(n[S],n[m],n[a],n[u])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(ae(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):Oe(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();let n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i<t.length;){let s=n[t.charAt(i++)],l=i<t.length?n[t.charAt(i)]:0;++i;let d=i<t.length?n[t.charAt(i)]:64;++i;let m=i<t.length?n[t.charAt(i)]:64;if(++i,s==null||l==null||d==null||m==null)throw new k;let a=s<<2|l>>4;if(r.push(a),d!==64){let u=l<<4&240|d>>2;if(r.push(u),m!==64){let E=d<<6&192|m;r.push(E)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},k=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},xe=function(t){let e=ae(t);return ce.encodeByteArray(e,!0)},C=function(t){return xe(t).replace(/\./g,"")},fe=function(t){try{return ce.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function Be(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}var Te=()=>Be().__FIREBASE_DEFAULTS__,Me=()=>{if(typeof process>"u"||typeof process.env>"u")return;let t=process.env.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},Ne=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let e=t&&fe(t[1]);return e&&JSON.parse(e)},O=()=>{try{return ie()||Te()||Me()||Ne()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},Re=t=>O()?.emulatorHosts?.[t],Jt=t=>{let e=Re(t);if(!e)return;let n=e.lastIndexOf(":");if(n<=0||n+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);let r=parseInt(e.substring(n+1),10);return e[0]==="["?[e.substring(1,n-1),r]:[e.substring(0,n),r]},$=()=>O()?.config,Kt=t=>O()?.[`_${t}`];var I=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}wrapCallback(e){return(n,r)=>{n?this.reject(n):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,r))}}};function Le(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function Zt(t){return(await fetch(t,{credentials:"include"})).ok}function Yt(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let n={alg:"none",type:"JWT"},r=e||"demo-project",i=t.iat||0,s=t.sub||t.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let o={iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}},...t};return[C(JSON.stringify(n)),C(JSON.stringify(o)),""].join(".")}var w={};function ke(){let t={prod:[],emulator:[]};for(let e of Object.keys(w))w[e]?t.emulator.push(e):t.prod.push(e);return t}function Pe(t){let e=document.getElementById(t),n=!1;return e||(e=document.createElement("div"),e.setAttribute("id",t),n=!0),{created:n,element:e}}var se=!1;function qt(t,e){if(typeof window>"u"||typeof document>"u"||!Le(window.location.host)||w[t]===e||w[t]||se)return;w[t]=e;function n(a){return`__firebase__banner__${a}`}let r="__firebase__banner",s=ke().prod.length>0;function o(){let a=document.getElementById(r);a&&a.remove()}function l(a){a.style.display="flex",a.style.background="#7faaf0",a.style.position="fixed",a.style.bottom="5px",a.style.left="5px",a.style.padding=".5em",a.style.borderRadius="5px",a.style.alignItems="center"}function c(a,u){a.setAttribute("width","24"),a.setAttribute("id",u),a.setAttribute("height","24"),a.setAttribute("viewBox","0 0 24 24"),a.setAttribute("fill","none"),a.style.marginLeft="-6px"}function d(){let a=document.createElement("span");return a.style.cursor="pointer",a.style.marginLeft="16px",a.style.fontSize="24px",a.innerHTML=" &times;",a.onclick=()=>{se=!0,o()},a}function S(a,u){a.setAttribute("id",u),a.innerText="Learn more",a.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",a.setAttribute("target","__blank"),a.style.paddingLeft="5px",a.style.textDecoration="underline"}function m(){let a=Pe(r),u=n("text"),E=document.getElementById(u)||document.createElement("span"),te=n("learnmore"),ne=document.getElementById(te)||document.createElement("a"),re=n("preprendIcon"),A=document.getElementById(re)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(a.created){let R=a.element;l(R),S(ne,te);let Ie=d();c(A,re),R.append(A,E,ne,Ie),document.body.appendChild(R)}s?(E.innerText="Preview backend disconnected.",A.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
2
+ <path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
3
+ </g>
4
+ <defs>
5
+ <clipPath id="clip0_6013_33858">
6
+ <rect width="24" height="24" fill="white"/>
7
+ </clipPath>
8
+ </defs>`):(A.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
9
+ <path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
10
+ </g>
11
+ <defs>
12
+ <clipPath id="clip0_6083_34804">
13
+ <rect width="24" height="24" fill="white"/>
14
+ </clipPath>
15
+ </defs>`,E.innerText="Preview backend running in this workspace."),E.setAttribute("id",u)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",m):m()}function le(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Xt(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(le())}function $e(){let t=O()?.forceEnvironment;if(t==="node")return!0;if(t==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function Qt(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function en(){let t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function tn(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function nn(){let t=le();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function rn(){return!$e()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function de(){try{return typeof indexedDB=="object"}catch{return!1}}function ue(){return new Promise((t,e)=>{try{let n=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{e(i.error?.message||"")}}catch(n){e(n)}})}var He="FirebaseError",b=class t extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=He,Object.setPrototypeOf(this,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,v.prototype.create)}},v=class{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r}create(e,...n){let r=n[0]||{},i=`${this.service}/${e}`,s=this.errors[e],o=s?Fe(s,r):"Error",l=`${this.serviceName}: ${o} (${i}).`;return new b(i,l,r)}};function Fe(t,e){return t.replace(ze,(n,r)=>{let i=e[r];return i!=null?String(i):`<${r}?>`})}var ze=/\{\$([^}]+)}/g;function sn(t){for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function x(t,e){if(t===e)return!0;let n=Object.keys(t),r=Object.keys(e);for(let i of n){if(!r.includes(i))return!1;let s=t[i],o=e[i];if(oe(s)&&oe(o)){if(!x(s,o))return!1}else if(s!==o)return!1}for(let i of r)if(!n.includes(i))return!1;return!0}function oe(t){return t!==null&&typeof t=="object"}function on(t){let e=[];for(let[n,r]of Object.entries(t))Array.isArray(r)?r.forEach(i=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function an(t){let e={};return t.replace(/^\?/,"").split("&").forEach(r=>{if(r){let[i,s]=r.split("=");e[decodeURIComponent(i)]=decodeURIComponent(s)}}),e}function cn(t){let e=t.indexOf("?");if(!e)return"";let n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function fn(t,e){let n=new P(t,e);return n.subscribe.bind(n)}var P=class{constructor(e,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(n=>{n.next(e)})}error(e){this.forEachObserver(n=>{n.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,n,r){let i;if(e===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");Ue(e,["next","error","complete"])?i=e:i={next:e,error:n,complete:r},i.next===void 0&&(i.next=L),i.error===void 0&&(i.error=L),i.complete===void 0&&(i.complete=L);let s=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),s}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let n=0;n<this.observers.length;n++)this.sendOne(n,e)}sendOne(e,n){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{n(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}};function Ue(t,e){if(typeof t!="object"||t===null)return!1;for(let n of e)if(n in t&&typeof t[n]=="function")return!0;return!1}function L(){}var ln=14400*1e3;function dn(t){return t&&t._delegate?t._delegate:t}var _=class{constructor(e,n,r){this.name=e,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}};var y="[DEFAULT]";var H=class{constructor(e,n){this.name=e,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){let r=new I;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{let i=this.getOrInitializeService({instanceIdentifier:n});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){let n=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(je(e))try{this.getOrInitializeService({instanceIdentifier:y})}catch{}for(let[n,r]of this.instancesDeferred.entries()){let i=this.normalizeInstanceIdentifier(n);try{let s=this.getOrInitializeService({instanceIdentifier:i});r.resolve(s)}catch{}}}}clearInstance(e=y){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...e.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=y){return this.instances.has(e)}getOptions(e=y){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:n={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let i=this.getOrInitializeService({instanceIdentifier:r,options:n});for(let[s,o]of this.instancesDeferred.entries()){let l=this.normalizeInstanceIdentifier(s);r===l&&o.resolve(i)}return i}onInit(e,n){let r=this.normalizeInstanceIdentifier(n),i=this.onInitCallbacks.get(r)??new Set;i.add(e),this.onInitCallbacks.set(r,i);let s=this.instances.get(r);return s&&e(s,r),()=>{i.delete(e)}}invokeOnInitCallbacks(e,n){let r=this.onInitCallbacks.get(n);if(r)for(let i of r)try{i(e,n)}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Ve(e),options:n}),this.instances.set(e,r),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=y){return this.component?this.component.multipleInstances?e:y:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function Ve(t){return t===y?void 0:t}function je(t){return t.instantiationMode==="EAGER"}var B=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let n=this.getProvider(e.name);if(n.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);n.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let n=new H(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}};var We=[],f;(function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"})(f||(f={}));var Ge={debug:f.DEBUG,verbose:f.VERBOSE,info:f.INFO,warn:f.WARN,error:f.ERROR,silent:f.SILENT},Je=f.INFO,Ke={[f.DEBUG]:"log",[f.VERBOSE]:"log",[f.INFO]:"info",[f.WARN]:"warn",[f.ERROR]:"error"},Ze=(t,e,...n)=>{if(e<t.logLevel)return;let r=new Date().toISOString(),i=Ke[e];if(i)console[i](`[${r}] ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)},T=class{constructor(e){this.name=e,this._logLevel=Je,this._logHandler=Ze,this._userLogHandler=null,We.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in f))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Ge[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,f.DEBUG,...e),this._logHandler(this,f.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,f.VERBOSE,...e),this._logHandler(this,f.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,f.INFO,...e),this._logHandler(this,f.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,f.WARN,...e),this._logHandler(this,f.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,f.ERROR,...e),this._logHandler(this,f.ERROR,...e)}};var Ye=(t,e)=>e.some(n=>t instanceof n),he,pe;function qe(){return he||(he=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Xe(){return pe||(pe=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var me=new WeakMap,z=new WeakMap,ge=new WeakMap,F=new WeakMap,V=new WeakMap;function Qe(t){let e=new Promise((n,r)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{n(h(t.result)),i()},o=()=>{r(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(n=>{n instanceof IDBCursor&&me.set(n,t)}).catch(()=>{}),V.set(e,t),e}function et(t){if(z.has(t))return;let e=new Promise((n,r)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{n(),i()},o=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});z.set(t,e)}var U={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return z.get(t);if(e==="objectStoreNames")return t.objectStoreNames||ge.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return h(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function be(t){U=t(U)}function tt(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){let r=t.call(M(this),e,...n);return ge.set(r,e.sort?e.sort():[e]),h(r)}:Xe().includes(t)?function(...e){return t.apply(M(this),e),h(me.get(this))}:function(...e){return h(t.apply(M(this),e))}}function nt(t){return typeof t=="function"?tt(t):(t instanceof IDBTransaction&&et(t),Ye(t,qe())?new Proxy(t,U):t)}function h(t){if(t instanceof IDBRequest)return Qe(t);if(F.has(t))return F.get(t);let e=nt(t);return e!==t&&(F.set(t,e),V.set(e,t)),e}var M=t=>V.get(t);function _e(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),l=h(o);return r&&o.addEventListener("upgradeneeded",c=>{r(h(o.result),c.oldVersion,c.newVersion,h(o.transaction),c)}),n&&o.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),l.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}var rt=["get","getKey","getAll","getAllKeys","count"],it=["put","add","delete","clear"],j=new Map;function ye(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(j.get(e))return j.get(e);let n=e.replace(/FromIndex$/,""),r=e!==n,i=it.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||rt.includes(n)))return;let s=async function(o,...l){let c=this.transaction(o,i?"readwrite":"readonly"),d=c.store;return r&&(d=d.index(l.shift())),(await Promise.all([d[n](...l),i&&c.done]))[0]};return j.set(e,s),s}be(t=>({...t,get:(e,n,r)=>ye(e,n)||t.get(e,n,r),has:(e,n)=>!!ye(e,n)||t.has(e,n)}));var J=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(st(n)){let r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}};function st(t){return t.getComponent()?.type==="VERSION"}var K="@firebase/app",Ee="0.14.2";var p=new T("@firebase/app"),ot="@firebase/app-compat",at="@firebase/analytics-compat",ct="@firebase/analytics",ft="@firebase/app-check-compat",lt="@firebase/app-check",dt="@firebase/auth",ut="@firebase/auth-compat",ht="@firebase/database",pt="@firebase/data-connect",mt="@firebase/database-compat",gt="@firebase/functions",bt="@firebase/functions-compat",yt="@firebase/installations",_t="@firebase/installations-compat",Et="@firebase/messaging",wt="@firebase/messaging-compat",Ct="@firebase/performance",vt="@firebase/performance-compat",Dt="@firebase/remote-config",St="@firebase/remote-config-compat",At="@firebase/storage",It="@firebase/storage-compat",Ot="@firebase/firestore",xt="@firebase/ai",Bt="@firebase/firestore-compat",Tt="firebase",Mt="12.2.0";var Z="[DEFAULT]",Nt={[K]:"fire-core",[ot]:"fire-core-compat",[ct]:"fire-analytics",[at]:"fire-analytics-compat",[lt]:"fire-app-check",[ft]:"fire-app-check-compat",[dt]:"fire-auth",[ut]:"fire-auth-compat",[ht]:"fire-rtdb",[pt]:"fire-data-connect",[mt]:"fire-rtdb-compat",[gt]:"fire-fn",[bt]:"fire-fn-compat",[yt]:"fire-iid",[_t]:"fire-iid-compat",[Et]:"fire-fcm",[wt]:"fire-fcm-compat",[Ct]:"fire-perf",[vt]:"fire-perf-compat",[Dt]:"fire-rc",[St]:"fire-rc-compat",[At]:"fire-gcs",[It]:"fire-gcs-compat",[Ot]:"fire-fst",[Bt]:"fire-fst-compat",[xt]:"fire-vertex","fire-js":"fire-js",[Tt]:"fire-js-all"};var N=new Map,Rt=new Map,Y=new Map;function we(t,e){try{t.container.addComponent(e)}catch(n){p.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function q(t){let e=t.name;if(Y.has(e))return p.debug(`There were multiple attempts to register component ${e}.`),!1;Y.set(e,t);for(let n of N.values())we(n,t);for(let n of Rt.values())we(n,t);return!0}function On(t,e){let n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function xn(t){return t==null?!1:t.settings!==void 0}var Lt={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},g=new v("app","Firebase",Lt);var X=class{constructor(e,n,r){this._isDeleted=!1,this._options={...e},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new _("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw g.create("app-deleted",{appName:this._name})}};var Bn=Mt;function kt(t,e={}){let n=t;typeof e!="object"&&(e={name:e});let r={name:Z,automaticDataCollectionEnabled:!0,...e},i=r.name;if(typeof i!="string"||!i)throw g.create("bad-app-name",{appName:String(i)});if(n||(n=$()),!n)throw g.create("no-options");let s=N.get(i);if(s){if(x(n,s.options)&&x(r,s.config))return s;throw g.create("duplicate-app",{appName:i})}let o=new B(i);for(let c of Y.values())o.addComponent(c);let l=new X(n,r,o);return N.set(i,l),l}function Tn(t=Z){let e=N.get(t);if(!e&&t===Z&&$())return kt();if(!e)throw g.create("no-app",{appName:t});return e}function W(t,e,n){let r=Nt[t]??t;n&&(r+=`-${n}`);let i=r.match(/\s|\//),s=e.match(/\s|\//);if(i||s){let o=[`Unable to register library "${r}" with version "${e}":`];i&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&s&&o.push("and"),s&&o.push(`version name "${e}" contains illegal characters (whitespace or "/")`),p.warn(o.join(" "));return}q(new _(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}var Pt="firebase-heartbeat-database",$t=1,D="firebase-heartbeat-store",G=null;function Se(){return G||(G=_e(Pt,$t,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(D)}catch(n){console.warn(n)}}}}).catch(t=>{throw g.create("idb-open",{originalErrorMessage:t.message})})),G}async function Ht(t){try{let n=(await Se()).transaction(D),r=await n.objectStore(D).get(Ae(t));return await n.done,r}catch(e){if(e instanceof b)p.warn(e.message);else{let n=g.create("idb-get",{originalErrorMessage:e?.message});p.warn(n.message)}}}async function Ce(t,e){try{let r=(await Se()).transaction(D,"readwrite");await r.objectStore(D).put(e,Ae(t)),await r.done}catch(n){if(n instanceof b)p.warn(n.message);else{let r=g.create("idb-set",{originalErrorMessage:n?.message});p.warn(r.message)}}}function Ae(t){return`${t.name}!${t.options.appId}`}var Ft=1024,zt=30,Q=class{constructor(e){this.container=e,this._heartbeatsCache=null;let n=this.container.getProvider("app").getImmediate();this._storage=new ee(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{let n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=ve();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(i=>i.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats.length>zt){let i=Vt(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(i,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){p.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";let e=ve(),{heartbeatsToSend:n,unsentEntries:r}=Ut(this._heartbeatsCache.heartbeats),i=C(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return p.warn(e),""}}};function ve(){return new Date().toISOString().substring(0,10)}function Ut(t,e=Ft){let n=[],r=t.slice();for(let i of t){let s=n.find(o=>o.agent===i.agent);if(s){if(s.dates.push(i.date),De(n)>e){s.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),De(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}var ee=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return de()?ue().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let n=await Ht(this.app);return n?.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){let r=await this.read();return Ce(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){let r=await this.read();return Ce(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}};function De(t){return C(JSON.stringify({version:2,heartbeats:t})).length}function Vt(t){if(t.length===0)return-1;let e=0,n=t[0].date;for(let r=1;r<t.length;r++)t[r].date<n&&(n=t[r].date,e=r);return e}function jt(t){q(new _("platform-logger",e=>new J(e),"PRIVATE")),q(new _("heartbeat",e=>new Q(e),"PRIVATE")),W(K,Ee,t),W(K,Ee,"esm2020"),W("fire-js","")}jt("");export{fe as a,Re as b,Jt as c,Kt as d,Le as e,Zt as f,Yt as g,qt as h,le as i,Xt as j,Qt as k,en as l,tn as m,nn as n,rn as o,b as p,v as q,sn as r,x as s,on as t,an as u,cn as v,fn as w,dn as x,_ as y,f as z,T as A,q as B,On as C,xn as D,Bn as E,kt as F,Tn as G,W as H};
@@ -0,0 +1,237 @@
1
+ Bundled license information:
2
+
3
+ @firebase/util/dist/index.esm.js:
4
+ @firebase/util/dist/index.esm.js:
5
+ @firebase/util/dist/index.esm.js:
6
+ @firebase/util/dist/index.esm.js:
7
+ @firebase/util/dist/index.esm.js:
8
+ @firebase/util/dist/index.esm.js:
9
+ @firebase/util/dist/index.esm.js:
10
+ @firebase/util/dist/index.esm.js:
11
+ @firebase/util/dist/index.esm.js:
12
+ @firebase/logger/dist/esm/index.esm.js:
13
+ /**
14
+ * @license
15
+ * Copyright 2017 Google LLC
16
+ *
17
+ * Licensed under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software
24
+ * distributed under the License is distributed on an "AS IS" BASIS,
25
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ * See the License for the specific language governing permissions and
27
+ * limitations under the License.
28
+ */
29
+
30
+ @firebase/util/dist/index.esm.js:
31
+ /**
32
+ * @license
33
+ * Copyright 2022 Google LLC
34
+ *
35
+ * Licensed under the Apache License, Version 2.0 (the "License");
36
+ * you may not use this file except in compliance with the License.
37
+ * You may obtain a copy of the License at
38
+ *
39
+ * http://www.apache.org/licenses/LICENSE-2.0
40
+ *
41
+ * Unless required by applicable law or agreed to in writing, software
42
+ * distributed under the License is distributed on an "AS IS" BASIS,
43
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ * See the License for the specific language governing permissions and
45
+ * limitations under the License.
46
+ */
47
+ /**
48
+ * @license
49
+ * Copyright 2017 Google LLC
50
+ *
51
+ * Licensed under the Apache License, Version 2.0 (the "License");
52
+ * you may not use this file except in compliance with the License.
53
+ * You may obtain a copy of the License at
54
+ *
55
+ * http://www.apache.org/licenses/LICENSE-2.0
56
+ *
57
+ * Unless required by applicable law or agreed to in writing, software
58
+ * distributed under the License is distributed on an "AS IS" BASIS,
59
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60
+ * See the License for the specific language governing permissions and
61
+ * limitations under the License.
62
+ */
63
+ /**
64
+ * @license
65
+ * Copyright 2025 Google LLC
66
+ *
67
+ * Licensed under the Apache License, Version 2.0 (the "License");
68
+ * you may not use this file except in compliance with the License.
69
+ * You may obtain a copy of the License at
70
+ *
71
+ * http://www.apache.org/licenses/LICENSE-2.0
72
+ *
73
+ * Unless required by applicable law or agreed to in writing, software
74
+ * distributed under the License is distributed on an "AS IS" BASIS,
75
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76
+ * See the License for the specific language governing permissions and
77
+ * limitations under the License.
78
+ */
79
+ /**
80
+ * @license
81
+ * Copyright 2021 Google LLC
82
+ *
83
+ * Licensed under the Apache License, Version 2.0 (the "License");
84
+ * you may not use this file except in compliance with the License.
85
+ * You may obtain a copy of the License at
86
+ *
87
+ * http://www.apache.org/licenses/LICENSE-2.0
88
+ *
89
+ * Unless required by applicable law or agreed to in writing, software
90
+ * distributed under the License is distributed on an "AS IS" BASIS,
91
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92
+ * See the License for the specific language governing permissions and
93
+ * limitations under the License.
94
+ */
95
+
96
+ @firebase/util/dist/index.esm.js:
97
+ /**
98
+ * @license
99
+ * Copyright 2022 Google LLC
100
+ *
101
+ * Licensed under the Apache License, Version 2.0 (the "License");
102
+ * you may not use this file except in compliance with the License.
103
+ * You may obtain a copy of the License at
104
+ *
105
+ * http://www.apache.org/licenses/LICENSE-2.0
106
+ *
107
+ * Unless required by applicable law or agreed to in writing, software
108
+ * distributed under the License is distributed on an "AS IS" BASIS,
109
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
110
+ * See the License for the specific language governing permissions and
111
+ * limitations under the License.
112
+ */
113
+
114
+ @firebase/util/dist/index.esm.js:
115
+ @firebase/component/dist/esm/index.esm.js:
116
+ @firebase/app/dist/esm/index.esm.js:
117
+ @firebase/app/dist/esm/index.esm.js:
118
+ /**
119
+ * @license
120
+ * Copyright 2019 Google LLC
121
+ *
122
+ * Licensed under the Apache License, Version 2.0 (the "License");
123
+ * you may not use this file except in compliance with the License.
124
+ * You may obtain a copy of the License at
125
+ *
126
+ * http://www.apache.org/licenses/LICENSE-2.0
127
+ *
128
+ * Unless required by applicable law or agreed to in writing, software
129
+ * distributed under the License is distributed on an "AS IS" BASIS,
130
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131
+ * See the License for the specific language governing permissions and
132
+ * limitations under the License.
133
+ */
134
+
135
+ @firebase/util/dist/index.esm.js:
136
+ /**
137
+ * @license
138
+ * Copyright 2020 Google LLC
139
+ *
140
+ * Licensed under the Apache License, Version 2.0 (the "License");
141
+ * you may not use this file except in compliance with the License.
142
+ * You may obtain a copy of the License at
143
+ *
144
+ * http://www.apache.org/licenses/LICENSE-2.0
145
+ *
146
+ * Unless required by applicable law or agreed to in writing, software
147
+ * distributed under the License is distributed on an "AS IS" BASIS,
148
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
149
+ * See the License for the specific language governing permissions and
150
+ * limitations under the License.
151
+ */
152
+
153
+ @firebase/util/dist/index.esm.js:
154
+ /**
155
+ * @license
156
+ * Copyright 2021 Google LLC
157
+ *
158
+ * Licensed under the Apache License, Version 2.0 (the "License");
159
+ * you may not use this file except in compliance with the License.
160
+ * You may obtain a copy of the License at
161
+ *
162
+ * http://www.apache.org/licenses/LICENSE-2.0
163
+ *
164
+ * Unless required by applicable law or agreed to in writing, software
165
+ * distributed under the License is distributed on an "AS IS" BASIS,
166
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
167
+ * See the License for the specific language governing permissions and
168
+ * limitations under the License.
169
+ */
170
+
171
+ @firebase/app/dist/esm/index.esm.js:
172
+ /**
173
+ * @license
174
+ * Copyright 2019 Google LLC
175
+ *
176
+ * Licensed under the Apache License, Version 2.0 (the "License");
177
+ * you may not use this file except in compliance with the License.
178
+ * You may obtain a copy of the License at
179
+ *
180
+ * http://www.apache.org/licenses/LICENSE-2.0
181
+ *
182
+ * Unless required by applicable law or agreed to in writing, software
183
+ * distributed under the License is distributed on an "AS IS" BASIS,
184
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
185
+ * See the License for the specific language governing permissions and
186
+ * limitations under the License.
187
+ */
188
+ /**
189
+ * @license
190
+ * Copyright 2023 Google LLC
191
+ *
192
+ * Licensed under the Apache License, Version 2.0 (the "License");
193
+ * you may not use this file except in compliance with the License.
194
+ * You may obtain a copy of the License at
195
+ *
196
+ * http://www.apache.org/licenses/LICENSE-2.0
197
+ *
198
+ * Unless required by applicable law or agreed to in writing, software
199
+ * distributed under the License is distributed on an "AS IS" BASIS,
200
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ * See the License for the specific language governing permissions and
202
+ * limitations under the License.
203
+ */
204
+
205
+ @firebase/app/dist/esm/index.esm.js:
206
+ /**
207
+ * @license
208
+ * Copyright 2021 Google LLC
209
+ *
210
+ * Licensed under the Apache License, Version 2.0 (the "License");
211
+ * you may not use this file except in compliance with the License.
212
+ * You may obtain a copy of the License at
213
+ *
214
+ * http://www.apache.org/licenses/LICENSE-2.0
215
+ *
216
+ * Unless required by applicable law or agreed to in writing, software
217
+ * distributed under the License is distributed on an "AS IS" BASIS,
218
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
219
+ * See the License for the specific language governing permissions and
220
+ * limitations under the License.
221
+ */
222
+ /**
223
+ * @license
224
+ * Copyright 2019 Google LLC
225
+ *
226
+ * Licensed under the Apache License, Version 2.0 (the "License");
227
+ * you may not use this file except in compliance with the License.
228
+ * You may obtain a copy of the License at
229
+ *
230
+ * http://www.apache.org/licenses/LICENSE-2.0
231
+ *
232
+ * Unless required by applicable law or agreed to in writing, software
233
+ * distributed under the License is distributed on an "AS IS" BASIS,
234
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
235
+ * See the License for the specific language governing permissions and
236
+ * limitations under the License.
237
+ */
@@ -0,0 +1,5 @@
1
+ import{f as c}from"./chunk-ORXEMIQC.js";import{a as p,b,c as g,g as E,i as C,n as x,p as _,q as A,r as w,s as h,u,v as D}from"./chunk-EGEB6N4J.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};