@blinkk/root-cms 3.0.2 → 3.0.3

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-3HARN4U6.js → chunk-7Z5IRD2G.js} +176 -83
  3. package/dist/{chunk-2BSW7SIH.js → chunk-N4K6ICFR.js} +4 -4
  4. package/dist/{chunk-BGTUWIV6.js → chunk-PNLLZXVY.js} +4 -4
  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 +124 -129
  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-2LUC2PWC.js +1 -0
  61. package/dist/ui/AssetsPage-PODV4QAB.js +1 -0
  62. package/dist/ui/CollectionPage-4DMKW5YB.js +1 -0
  63. package/dist/ui/ComparePage-JMJE5A5Y.js +1 -0
  64. package/dist/ui/DataPage-MVLZT2BU.js +1 -0
  65. package/dist/ui/DataSourcePage-4RPBXRI2.js +1 -0
  66. package/dist/ui/DocTranslationsPage-XJSPKGVX.js +1 -0
  67. package/dist/ui/DocumentPage-R2PVNG24.js +1 -0
  68. package/dist/ui/EditDataSourcePage-3SHAARNL.js +1 -0
  69. package/dist/ui/EditReleasePage-G5VW2OGW.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-K6KYEG2P.js +1 -0
  73. package/dist/ui/NewDataSourcePage-O2VQEOJG.js +1 -0
  74. package/dist/ui/NewReleasePage-RSVS32RZ.js +1 -0
  75. package/dist/ui/NotFoundPage-ZYD5ILG6.js +1 -0
  76. package/dist/ui/ProjectPage-X3YQBWL4.js +1 -0
  77. package/dist/ui/ReleasePage-FJHHXNNB.js +1 -0
  78. package/dist/ui/ReleasesPage-VGWIBNEZ.js +1 -0
  79. package/dist/ui/SettingsPage-C4RXOQ6T.js +1 -0
  80. package/dist/ui/SidebarToolsPage-ZBOKPEMP.js +1 -0
  81. package/dist/ui/TaskPage-BQ4OX5WN.js +1 -0
  82. package/dist/ui/TasksPage-3IGQYVYS.js +1 -0
  83. package/dist/ui/TranslationsArbPage-GGHCWPQL.js +2 -0
  84. package/dist/ui/TranslationsEditPage-E2BCMKYV.js +1 -0
  85. package/dist/ui/TranslationsPage-MC4O4ZNI.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-6IFGKSIE.js +1 -0
  94. package/dist/ui/chunk-767BAQ53.js +1 -0
  95. package/dist/ui/chunk-AFWBSIPL.js +1 -0
  96. package/dist/ui/chunk-AL3TN2KI.js +1 -0
  97. package/dist/ui/chunk-B6BLDN24.js +141 -0
  98. package/dist/ui/chunk-B6BLDN24.js.LEGAL.txt +106 -0
  99. package/dist/ui/chunk-BZIRGB4W.js +1 -0
  100. package/dist/ui/chunk-C5NH23G4.js +3 -0
  101. package/dist/ui/chunk-CGCKJFL4.js +1 -0
  102. package/dist/ui/chunk-DEGMKEHP.js +1 -0
  103. package/dist/ui/chunk-DTMZLUNY.js +15 -0
  104. package/dist/ui/chunk-DTMZLUNY.js.LEGAL.txt +237 -0
  105. package/dist/ui/chunk-DUJYIOLE.js +5 -0
  106. package/dist/ui/chunk-E2RCCK2T.js +1 -0
  107. package/dist/ui/chunk-EGEB6N4J.js +22 -0
  108. package/dist/ui/chunk-EGEB6N4J.js.LEGAL.txt +1059 -0
  109. package/dist/ui/chunk-GXSAEPU3.js +1 -0
  110. package/dist/ui/chunk-HHMG665Z.js +1 -0
  111. package/dist/ui/chunk-HKINZLMW.js +84 -0
  112. package/dist/ui/chunk-HLMBCVRX.js +1 -0
  113. package/dist/ui/chunk-HRGYNHZ3.js +1 -0
  114. package/dist/ui/chunk-I6ICVKEC.js +1 -0
  115. package/dist/ui/chunk-IU36W2TB.js +1 -0
  116. package/dist/ui/chunk-JDW4UORS.js +1 -0
  117. package/dist/ui/chunk-JHBAMPGB.js +1 -0
  118. package/dist/ui/chunk-JYFLU7DM.js +19 -0
  119. package/dist/ui/chunk-JZFTZ4X4.js +87 -0
  120. package/dist/ui/chunk-JZFTZ4X4.js.LEGAL.txt +9 -0
  121. package/dist/ui/chunk-KFAZBEPV.js +1 -0
  122. package/dist/ui/chunk-KKEWCXVV.js +1 -0
  123. package/dist/ui/chunk-KUCVLANF.js +1 -0
  124. package/dist/ui/chunk-KYDOSLTO.js +1 -0
  125. package/dist/ui/chunk-L4RHGQUG.js +1 -0
  126. package/dist/ui/chunk-MDUBCXU2.js +1 -0
  127. package/dist/ui/chunk-NXQVLOTK.js +1 -0
  128. package/dist/ui/chunk-NZHF733K.js +7 -0
  129. package/dist/ui/chunk-NZHF733K.js.LEGAL.txt +146 -0
  130. package/dist/ui/chunk-ONTGW2VA.js +1 -0
  131. package/dist/ui/chunk-ORXEMIQC.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-UEON4JAT.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{a as mt}from"./chunk-CGCKJFL4.js";import{f as pt,g as gt,h as ft,i as Ie,j as M,k as Ee,l as Q,m as ht}from"./chunk-SKEP5WYH.js";import{c as tt}from"./chunk-AFWBSIPL.js";import{a as Qe}from"./chunk-62UWGWON.js";import{a as F,c as xe}from"./chunk-I6ICVKEC.js";import{a as ce,f as et}from"./chunk-ORXEMIQC.js";import{a as ue,d as Se}from"./chunk-5MV6XVGA.js";import{c as Xe,q as Ze,r as Ye,t as de,u as ye}from"./chunk-EGEB6N4J.js";import{f as B}from"./chunk-AL3TN2KI.js";import{$ as Fe,A as Ve,Aa as le,Ab as Ce,Ca as se,Ea as Je,Ec as Y,Fc as dt,Ga as re,Ha as i,Ob as st,Pc as ct,R as Be,V as He,W as X,Wc as ut,Y as G,a as g,c as U,e as ve,ea as E,fa as qe,g as J,ga as z,ha as $e,i as oe,j as _e,jc as rt,lc as De,m as be,ma as je,mb as it,mc as Te,o as Me,oa as Z,ob as at,p as Le,qa as We,ra as k,sa as we,ub as ot,va as ne,w as Re,wb as nt,xb as lt,za as Ke}from"./chunk-NZHF733K.js";import{d as O,j as ae,k as ze}from"./chunk-KUCVLANF.js";ze();_e();function vt(e,l){let t;return(...a)=>{window.clearTimeout(t),t=window.setTimeout(()=>{e(...a)},l)}}function _t(e){e||(e=6);let l=[],t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=t.length;for(let o=0;o<e;o++)l.push(t.charAt(Math.floor(Math.random()*a)));return l.join("")}var H=class{constructor(){this.events=new Map}on(l,t){let a=_t(6),o=this.events.get(l);return o||(o=new Map,this.events.set(l,o)),o.set(a,t),()=>{this.off(l,a)}}off(l,t){let a=this.events.get(l);a&&(a.delete(t),a.size===0&&this.events.delete(l))}dispatch(l,...t){let a=this.events.get(l);a&&a.forEach(o=>o(...t))}dispose(){this.events.clear()}};var pe=class{constructor(){this.subscribers=new Set;this.subtreeSubscribers=new Set;this.children=new Map}},ge=class extends H{constructor(t){super();this.root=new pe;this.data=t||{}}get(t){return this.getValueFromPath(t,this.data)}set(t,a){if(t===""){ue(a)&&this.setData(a);return}this.update({[t]:a})}update(t){let a=new Map,o=(s,d,c)=>{a.set(s,c),ue(d)&&ue(c)&&(Object.entries(c).forEach(([u,m])=>{let _=d[u];Se(_,m)||o(`${s}.${u}`,_,m)}),Object.keys(d).forEach(u=>{u in c||o(`${s}.${u}`,d[u],void 0)}))};Object.entries(t).forEach(([s,d])=>{let c=this.data,u=s.split("."),m=u.pop();for(let C of u)c[C]||(c[C]={}),c=c[C];let _=c[m];c[m]=d,this.dispatch("VALUE_CHANGE",s,d),o(s,_,d)});let n=new Map;a.forEach((s,d)=>{this.collectSubtreeNotifications(d,n)}),a.forEach((s,d)=>{let c=this.getTrieNode(d);c&&c.subscribers.size>0&&c.subscribers.forEach(u=>u(s))}),n.forEach((s,d)=>{let c=this.get(d);s.subtreeSubscribers.forEach(u=>u(c))}),this.dispatch("CHANGE",this.data)}setData(t){let a=this.data;this.notifyOnUpdate(this.root,"",a,t),this.data=t,this.dispatch("CHANGE",this.data)}subscribe(t,a){let o=this.getTrieNode(t,!0);return o.subscribers.add(a),window.setTimeout(()=>{let n=this.get(t);n!==void 0&&a(n)}),()=>{o.subscribers.delete(a)}}subscribeSubtree(t,a){let o=this.getTrieNode(t,!0);return o.subtreeSubscribers.add(a),window.setTimeout(()=>{let n=this.get(t);n!==void 0&&a(n)}),()=>{o.subtreeSubscribers.delete(a)}}getDataSnapshot(){return this.data}dispose(){super.dispose(),this.data={},this.root.subscribers.clear(),this.root.subtreeSubscribers.clear(),this.root.children.clear()}notifyOnUpdate(t,a,o,n){let s=this.getValueFromPath(a,o),d=this.getValueFromPath(a,n);Se(s,d)||(t.subscribers.forEach(c=>c(d)),t.subtreeSubscribers.forEach(c=>c(d))),t.children.forEach((c,u)=>{let m=a?`${a}.${u}`:u;this.notifyOnUpdate(c,m,o,n)})}collectSubtreeNotifications(t,a){let o=this.root;if(o.subtreeSubscribers.size>0&&a.set("",o),!t)return;let n="";for(let s of t.split(".")){if(o=o.children.get(s),!o)return;n=n?`${n}.${s}`:s,o.subtreeSubscribers.size>0&&a.set(n,o)}}getValueFromPath(t,a){if(!t)return a;let o=t.split("."),n=a;for(let s of o){if(n===null||typeof n!="object"||!(s in n))return;n=n[s]}return n}getTrieNode(t,a=!1){if(!t)return this.root;let o=t.split("."),n=this.root;for(let s of o){if(!n.children.has(s))if(a)n.children.set(s,new pe);else return;n=n.children.get(s)}return n}};var bt=3*ce.second,Et=5*ce.minute;var kt=30*ce.second,ke=class extends H{constructor(t){super();this.pendingUpdates=new Map;this.saveState="NO_CHANGES";this.autolock=!1;this.autolockReason="autolock";this.autolockApplied=!1;this.readOnly=!1;this.autoSave=!0;this.flushOnStop=!0;this.started=!1;this.queueChanges=vt(()=>this.flush(),bt);this.projectId=window.__ROOT_CTX.rootConfig.projectId;let[a,o]=t.split("/");this.docId=t,this.collectionId=a,this.slug=o,this.db=window.firebase.db,this.docRef=Xe(this.db,"Projects",this.projectId,"Collections",a,"Drafts",o),this.store=new ge({id:this.docId,collection:this.collectionId,slug:this.slug,sys:{}}),this.store.on("CHANGE",s=>{this.dispatch("CHANGE",s)}),this.store.on("VALUE_CHANGE",(s,d)=>{this.dispatch("VALUE_CHANGE",s,d)});let n=window.__ROOT_CTX.collections[a];n&&(this.autolock=!!n.autolock,n.autolockReason&&(this.autolockReason=n.autolockReason))}async start(){this.started||(this.started=!0,this.dbUnsubscribe=Ye(this.docRef,t=>{if(t.metadata.hasPendingWrites)return;let a=t.data()||{};this.pendingUpdates.size>0&&Ft(a,Object.fromEntries(this.pendingUpdates)),this.store.setData(a)}))}stop(){this.started&&(this.dbUnsubscribe&&this.dbUnsubscribe(),this.flushOnStop&&this.flush(),this.started=!1)}onChange(t){return this.on("CHANGE",t)}onSaveStateChange(t){return this.on("SAVE_STATE_CHANGE",t)}onFlush(t){return this.on("FLUSH",t)}subscribe(t,a){return this.store.subscribe(t,a)}subscribeSubtree(t,a){return this.store.subscribeSubtree(t,a)}getData(){return this.store.getDataSnapshot()}getValue(t){return this.store.get(t)}async updateKey(t,a){this.readOnly||(a===void 0?this.pendingUpdates.set(t,de()):this.pendingUpdates.set(t,a),this.store.set(t,a),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}async updateKeys(t){if(!this.readOnly){for(let a in t){let o=t[a];o==null?this.pendingUpdates.set(a,de()):this.pendingUpdates.set(a,o)}this.store.update(t),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges()}}async removeKey(t){this.readOnly||(this.pendingUpdates.set(t,de()),this.store.set(t,void 0),this.setSaveState("UPDATE_PENDING"),this.autoSave&&this.queueChanges())}setSaveState(t){let a=this.saveState;t==="SAVED"&&a!=="SAVING"||(this.saveState=t,t==="SAVED"&&window.setTimeout(()=>{this.saveState==="SAVED"&&this.setSaveState("NO_CHANGES")},bt),this.dispatch("SAVE_STATE_CHANGE",t))}removePublishingLock(){this.autolockApplied=!0,this.removeKey("sys.publishingLocked"),this.flush()}async flush(t){if(this.readOnly||this.pendingUpdates.size===0)return;let a=Object.fromEntries(this.pendingUpdates);a["sys.modifiedAt"]=ye(),a["sys.modifiedBy"]=window.firebase.user.email,this.autolock&&!this.autolockApplied&&!this.store.get("sys.publishingLocked")&&(this.autolockApplied=!0,a["sys.publishingLocked"]={lockedAt:ye(),lockedBy:window.firebase.user.email,reason:this.autolockReason}),this.pendingUpdates.clear();try{this.setSaveState("SAVING"),await Ze(this.docRef,a),this.setSaveState("SAVED"),t?.quiet||this.dispatch("FLUSH"),et("doc.save",{metadata:{docId:this.docId},throttle:Et,throttleId:this.docId})}catch(o){console.error("failed to update doc:",o),this.setSaveState("ERROR");let n=Qe(o);F({title:`Failed to save ${this.slug}`,message:n||`Something went wrong while saving ${this.slug}`,color:"red",autoClose:!1});for(let s in a)s.startsWith("sys.")||this.pendingUpdates.has(s)||(this.pendingUpdates.set(s,a[s]),this.queueChanges(),console.log("re-queued updates"),console.log(this.pendingUpdates))}}getLocales(){let t=this.store.get("sys.locales");return t||["en"]}setLocales(t){this.updateKey("sys.locales",t)}async dispose(){super.dispose(),this.stop()}};function Ft(e,l){for(let t in l){let a=l[t];if(t.includes(".")){let[o,n]=At(t);e[o]??={},Ft(e[o],{[n]:a})}else typeof a>"u"?delete e[t]:e[t]=a}}function At(e){let l=e.indexOf("."),t=e.substring(0,l),a=e.substring(l+1);return[t,a]}var Ae=ae(null);function ci(e){let[l,t]=g(!0),a=J(()=>new ke(e.docId),[e.docId]);a.readOnly=e.readOnly??!1,a.autoSave=e.autoSave??!0,a.flushOnStop=e.flushOnStop??!0,U(()=>(t(!0),a.onChange(n=>{t(!1),tt(n.id,n)}),a.start(),()=>a.dispose()),[a]),U(()=>{let n,s=()=>{document.hidden||document.visibilityState!=="visible"?n=window.setTimeout(()=>{a.stop()},kt):(n&&(clearTimeout(n),n=void 0),a.started||a.start())};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),n&&clearTimeout(n)}},[a]);let o=J(()=>({loading:l,controller:a}),[l,a]);return i(Ae.Provider,{value:o,children:e.children})}function ui(e){return i(Ae.Provider,{value:e.value,children:e.children})}function fe(){let e=oe(Ae);if(!e)throw new Error("useDraftDoc() should be used within a <DraftDocProvider>");return e}function pi(e){let{controller:l}=fe();U(()=>l.onSaveStateChange(e),[l])}function gi(e){let{controller:l}=fe();U(()=>l.onChange(e),[l])}function fi(e,l){let{controller:t}=fe();U(()=>t.subscribe(e,l),[t])}function wt(e,l){let{controller:t}=fe(),[a,o]=g(t.getValue(e)??l);return U(()=>t.subscribe(e,s=>{o(s)}),[t]),[a,s=>{o(s),s==null?t.removeKey(e):t.updateKey(e,s)}]}ze();Re();Re();_e();var Pt=["drive.google.com","docs.google.com"];function he(e){try{let l=new URL(e);if(!Pt.includes(l.hostname))return null;if(l.searchParams.has("id"))return l.searchParams.get("id");let t=l.pathname.split("/"),a=t.findIndex(o=>o==="d");if(a!==-1&&a<t.length-1)return t[a+1]}catch{return null}return null}async function xt(e,l){let t="https://www.googleapis.com/auth/drive.readonly";(!e.isLoggedIn()||!e.hasScope(t))&&await e.login({scopes:[t]});let a=window.gapi;if(!a||!a.client||!a.client.drive)throw new Error("Google Drive API not loaded");let o=a.auth.getToken()?.access_token;if(!o)throw new Error("No Google Drive access token found");let[n,s]=await Promise.all([a.client.drive.files.get({fileId:l,fields:"name,mimeType,size",supportsAllDrives:!0}),fetch(`https://www.googleapis.com/drive/v3/files/${l}?alt=media&supportsAllDrives=true`,{headers:{Authorization:`Bearer ${o}`}})]),d=n.result;if(!s.ok)throw new Error(`Failed to download file from Drive: ${s.statusText}`);let c=await s.blob();return new File([c],d.name,{type:d.mimeType})}_e();var Nt=["1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9"],Ot=["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"];function yt(e){let[l,t]=g("simple"),[a,o]=g(!1),[n,s]=g(!1),[d,c]=g(null),[u,m]=g(""),[_,C]=g(e.initialWidth||1600),[p,w]=g(e.initialHeight||900),[y,q]=g("16:9"),$=!!(window.__ROOT_CTX?.experiments||{}).ai;async function L(){if(!u){F({title:"Prompt required",message:"Please enter a prompt to generate an image.",color:"red"});return}o(!0);try{let v=await(await fetch("/cms/api/ai.generate_image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u,aspectRatio:y})})).json();if(v.success&&v.image)c(v.image);else throw new Error(v.error||"Failed to generate image")}catch(f){console.error(f),F({title:"Generation failed",message:f.message||"Unknown error",color:"red"})}finally{o(!1)}}function te(f){f.preventDefault();let v=new FormData(f.target),b=parseInt(v.get("width"),10),D=parseInt(v.get("height"),10),W=v.get("backgroundColor"),A=v.get("label")||`${b}x${D}`,N=[];if(N.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${b}" height="${D}" viewBox="0 0 ${b} ${D}"><rect width="${b}" height="${D}" fill="${W}" />`),A){let ie=b*.5/(A.length*.6);N.push(`<text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" font-family="sans-serif" font-size="${ie}" fill="#fff">${A}</text>`)}N.push("</svg>");let R=N.join(""),K=new TextEncoder().encode(R),me={src:`data:image/svg+xml;base64,${btoa(String.fromCharCode(...K))}`,filename:"placeholder.svg",width:b,height:D,alt:""};e.onSubmit(me)}async function j(){if(d){s(!0);try{let v=await(await fetch(d)).blob(),b=new File([v],"generated-image.png",{type:"image/png"}),{uploadFileToGCS:D}=await import("./gcs-L33FIRZU.js"),W=await D(b),[A,N]=y.split(":").map(Number),R=1600,V=Math.round(R*N/A),K={...W,width:R,height:V,alt:u};e.onSubmit(K)}catch(f){console.error(f),F({title:"Save failed",message:f.message||"Failed to upload image",color:"red"})}finally{s(!1)}}}return i(se,{gap:"md",children:[$&&i(Ke,{value:l,onChange:f=>t(f),data:[{label:"Simple",value:"simple"},{label:i(z,{gap:5,children:[i(Y,{size:16}),i("span",{children:"Generate with AI"})]}),value:"ai"}],fullWidth:!0}),l==="simple"?i("form",{onSubmit:te,children:[i(se,{gap:"xs",children:[i(ne,{label:"Width",name:"width",type:"number",value:_,onChange:f=>C(parseInt(f.currentTarget.value,10)),"data-autofocus":!0}),i(ne,{label:"Height",name:"height",type:"number",value:p,onChange:f=>w(parseInt(f.currentTarget.value,10))}),i(ne,{name:"label",label:"Label",defaultValue:""}),i($e,{name:"backgroundColor",label:"Background color",format:"hex",defaultValue:"#868e96",swatches:Ot})]}),i(z,{justify:"flex-end",mt:"md",children:i(E,{variant:"filled",type:"submit",children:"Create"})})]}):i(se,{gap:"xs",children:[i(le,{label:"Aspect Ratio",data:Nt,value:y,onChange:f=>q(f)}),i(Z,{label:"Prompt",placeholder:"Describe the image you want to generate...",minRows:3,value:u,onChange:f=>m(f.currentTarget.value),"data-autofocus":!0,required:!0}),d&&i(je,{src:d,alt:"Generated preview",height:200,fit:"contain"}),i(z,{justify:"flex-end",mt:"md",children:[i(E,{variant:"light",onClick:L,loading:a,disabled:n||!u,leftIcon:i(Y,{size:16}),children:a?"Generating...":"Preview"}),i(E,{variant:"filled",onClick:j,loading:n,disabled:!d||a,children:n?"Saving...":"Save"})]})]})]})}var Ut=["image/gif","image/jpeg","image/png","image/svg+xml","image/webp"],St=ae(null),Gt=Le(()=>import("./ImageEditorDialog-4H665KK2.js").then(e=>({default:e.ImageEditorDialog})));function ee(){let e=oe(St);if(!e)throw new Error("useFileField() should be called within a <FileFieldContext.Provider>");return e}function zt(e){let{field:l,value:t,setValue:a,loadingState:o,setLoadingState:n}=e,s=Ve(),d=ve(null),[c,u]=g(!1),[m,_]=g(!1),[C,p]=g(!1),w=mt(),y=e.allowEditing!==!1,[q,Pe]=g("hash"),[$,L]=g(null),[te,j]=g(!1),[f,v]=g(null),b=e.accept??l.exts??(e.variant==="image"?Ut:[]),D=t?.alt||"",W=l.alt!==!1;async function A(r,S,h){try{n("loading");let P=h?.namingMode||(l.preserveFilename?"clean":"hash"),I=l.cacheControl||(P==="clean"?"no-cache":void 0),x=await pt(r,{namingMode:P,checkExists:h?.checkExists??!1,cacheControl:I});!x.alt&&Ct(x.filename)&&D&&(x.alt=D),S&&(x.originalSrc=S),a(x),n("complete"),L(null),v(null)}catch(P){console.error("upload failed"),console.error(P),n("error"),F({title:"Upload failed",message:"Failed to upload: "+String(P),color:"red",autoClose:!1})}}async function N(){n("loading");try{let r=t?.gcsPath||t?.src;r&&await gt(r),a(null),n(null),F({message:"File deleted from GCS",color:"green"})}catch(r){console.error(r),n("error"),F({title:"Delete failed",message:String(r),color:"red"})}finally{_(!1)}}function R(){if(!y&&t?.src){_(!0);return}a(null)}async function V(r,S){if(!r)return;if(L(null),v(null),j(!1),typeof r=="string"&&!S?.as){let I=he(r);if(I){try{if(!w.enabled){console.warn("Google API integration is not enabled for this project. Specify the `gapi` config in your root.config.ts to enable pasting from Google Drive URLs.");return}n("loading"),F({message:"Downloading from Google Drive...",loading:!0,autoClose:!1,id:"gdrive-download"});let x=await xt(w,I);xe("gdrive-download"),V(x)}catch(x){console.error(x),n("error"),xe("gdrive-download"),F({title:"Google Drive import failed",message:x.message||"Failed to download",color:"red"})}return}}S?.as==="svg"&&typeof r=="string"&&(r=new File([new Blob([r],{type:"image/svg+xml"})],"untitled.svg",{type:"image/svg+xml"}));let h=r,P=Ie(h.name);if(b.length>0&&!b.some(I=>I.endsWith(P)||I===`*/${P}`||I==="*/*"||I===h.type)){F({title:"Invalid file type",message:`File type ${P} is not allowed.`,color:"red",autoClose:!0});return}if(q==="clean"&&e.showNamingOptions){n("loading");let x=`${window.__ROOT_CTX.rootConfig.projectId}/uploads/${h.name}`;try{if(await ft(x)){L(h),v(`https://storage.googleapis.com/${window.firebase.storage.app.options.storageBucket}/${x}`),n(null);return}}catch(Ge){console.warn("Failed to check file existence",Ge)}}A(h,void 0,{namingMode:q})}function K(){d.current?.focus()}function Ne(){if(t?.src)if(Ee(t.src)){let r=document.createElement("a");r.href=ht(t.src),t.filename&&(r.download=t.filename),document.body.appendChild(r),r.click(),document.body.removeChild(r)}else window.open(t.src,"_blank")}function me(){let r=document.createElement("input");r.type="file",b.length>0&&(r.accept=b.join(",")),r.onchange=S=>{let h=S.target;h.files&&h.files.length>0&&V(h.files[0])},r.click(),r.remove()}function Oe(){u(!0)}function Ue(){p(!0)}function ie(r){t?.src&&a({...t,alt:r||""})}async function It(){let r=t;if(r?.src){n("loading");try{let S=await window.fetch("/cms/api/ai.generate_alt_text",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({imageUrl:r.src})}),h=await S.json();if(!S.ok||!h.success)throw new Error(h.error||"Failed to generate alt text");h.altText&&ie(h.altText)}catch(S){F({title:"Sorry, something went wrong.",message:S.message||"Unknown error",color:"red",autoClose:!0})}finally{n("complete")}}}return i(St.Provider,{value:{field:l,variant:e.variant,value:t,setValue:a,loadingState:o,removeFile:R,acceptedFileTypes:b,handleFile:V,focusDropZone:K,requestGenerateAltText:It,requestFileUpload:me,requestFileDownload:Ne,requestPlaceholderModalOpen:Oe,requestImageEditorOpen:Ue,showAltText:W,altText:D,setAltText:ie,allowEditing:y},children:[i(we,{size:"sm",opened:c,onClose:()=>u(!1),title:"Placeholder image",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:i(yt,{onSubmit:r=>{a(r),u(!1)}})}),i(we,{size:"sm",opened:m,onClose:()=>_(!1),title:"Delete file?",centered:!0,overlayColor:s.colorScheme==="dark"?s.colors.dark[9]:s.colors.gray[2],children:[i(G,{size:"sm",mb:"lg",children:"Are you sure you want to delete this file from GCS? This action cannot be undone."}),i(z,{grow:!0,spacing:"xs",children:[i(E,{variant:"default",onClick:()=>_(!1),disabled:o==="loading",children:"Cancel"}),i(E,{color:"red",onClick:N,loading:o==="loading",children:"Delete"})]})]}),C&&t?.src&&i(Me,{fallback:null,children:i(Gt,{opened:C,onClose:()=>p(!1),src:t.src,originalSrc:t.originalSrc,filename:t.filename,initialWidth:parseInt(t.width),initialHeight:parseInt(t.height),onSave:r=>{A(r,t.originalSrc||t.src),p(!1)}},t.src)}),$?i("div",{className:"FileField__overwriteWarning",children:[i("div",{className:"FileField__overwriteWarning__header",children:i(G,{size:"sm",color:"red",weight:700,children:"File already exists"})}),i(G,{size:"sm",children:["A file named ",i("strong",{children:$.name})," already exists."]}),f&&i(G,{size:"sm",className:"FileField__overwriteWarning__link",children:i("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:["View existing file ",i(lt,{size:12})]})}),i("div",{className:"FileField__overwriteWarning__checkbox",children:i(qe,{label:"Confirm overwrite",checked:te,onChange:r=>j(r.currentTarget.checked)})}),i(z,{grow:!0,spacing:"xs",className:"FileField__overwriteWarning__actions",children:[i(E,{variant:"default",onClick:()=>{L(null),v(null),j(!1)},disabled:o==="loading",children:"Cancel"}),i(E,{disabled:!te,onClick:()=>A($,void 0,{namingMode:"clean"}),color:"red",loading:o==="loading",children:"Overwrite"})]})]}):i(O,{children:[i("div",{className:B("FileField",e.showNamingOptions&&"FileField--withOptions"),children:[i(T.Dropzone,{ref:d}),t?.src?i(T.Preview,{}):i(T.InvisibleDropzone,{children:i(T.Empty,{})})]}),e.showNamingOptions&&!t&&i("div",{className:"FileField__settings",style:{marginTop:8},children:i(le,{label:"File name options",size:"xs",itemComponent:Mt,data:[{value:"hash",label:"Hash the file name",description:"The filename will be hashed so the file's original name won't be exposed."},{value:"hash-path",label:"Use a hashed path with the original file name",description:"Use the original file name, but put it inside a hashed directory."},{value:"clean",label:"Use the original file name only",description:"The file will be uploaded to the bucket as-is, without a hashed directory."}],value:q,onChange:r=>Pe(r||"hash"),disabled:o==="loading"||!!t})})]})]})}function T(e){let l=e.field,[t,a]=wt(e.deepKey),[o,n]=g(null);return i(zt,{field:l,value:t,setValue:a,loadingState:o,setLoadingState:n,variant:e.variant,allowEditing:e.allowEditing})}T.Preview=()=>{let e=ee(),[l,t]=g(!1),[a,o]=g(!1),n=window.__ROOT_CTX.experiments||{},s=!!e.value?.width&&!!e.value?.height&&Number(e.value.width)>0&&Number(e.value.height)>0,d=e.value?.filename||"",c=Q(d),u=M(d)||c&&s,[m,_]=g(!u),C=ve(e.value?.src);if(e.value?.src!==C.current){C.current=e.value?.src;let p=e.value?.filename||"",w=M(p)||Q(p)&&s;!w&&!m?_(!0):w&&m&&_(!1)}return e.value?.src?i("div",{className:"FileField__Preview",children:[i("div",{className:"FileField__Preview__InfoButton",children:[u&&i(re,{label:"Toggle file info",position:"top",withArrow:!0,children:i(X,{onClick:()=>_(p=>!p),size:"sm",variant:"outline",className:"FileField__Preview__InfoButton__Icon","aria-label":"Toggle file info",children:i(st,{size:16})})}),i(k,{shadow:"sm",control:i(X,{variant:"outline",size:"sm",radius:"sm",c:"black",className:"FileField__Preview__InfoButton__Icon",children:i(ot,{size:16})}),children:[e.allowEditing&&i(O,{children:[i(k.Label,{size:"sm",children:"REPLACE"}),i(k.Item,{icon:e.variant==="image"?i(Te,{size:16}):i(Ce,{size:16}),onClick:()=>e.requestFileUpload(),children:["Upload ",e.variant==="image"?"image":"file"]}),Dt(e.acceptedFileTypes)&&i(k.Item,{disabled:!e.value?.src,icon:i(De,{size:16}),onClick:()=>{e.requestPlaceholderModalOpen()},children:"Placeholder image"}),M(e.value?.src)&&!e.value?.src?.endsWith(".svg")&&i(k.Item,{disabled:!e.value?.src,icon:i(at,{size:16}),closeMenuOnClick:!0,onClick:()=>{e.requestImageEditorOpen()},children:"Edit image"}),i(Fe,{})]}),i(k.Item,{disabled:e.value?.src?.startsWith("data:"),onClick:()=>{e?.requestFileDownload()},icon:i(nt,{size:16}),children:"Download file"}),i(k.Item,{closeOnItemClick:!1,icon:i(it,{size:16}),onClick:()=>{o(!1);let p=e.value?.src||"";Ee(p)&&(p=p.split("=")[0]+"=s0"),navigator.clipboard.writeText(p).then(()=>o(!0)).finally(()=>setTimeout(()=>{o(!1)},2e3))},children:a?"Copied!":"Copy URL"}),e.allowEditing&&M(e.value?.src||"")&&e.value?.canvasBgColor&&i(k.Item,{icon:e.value?.canvasBgColor==="dark"?i(ut,{size:16}):i(dt,{size:16,style:{opacity:.25}}),closeOnItemClick:!1,onClick:()=>{let p=e.value?.canvasBgColor==="dark"?"light":"dark";e.value&&e.setValue({...e.value,canvasBgColor:p})},children:"Use dark canvas"}),i(Fe,{}),i(k.Item,{color:"red",onClick:()=>{e?.removeFile()},icon:i(ct,{size:16}),children:"Remove file"})]})]}),i("div",{className:B("FileField__Canvas",m&&"FileField__Canvas--infoOpened",l&&"dragging"),style:Lt(e.value),onDragOver:p=>{p.preventDefault(),t(!0)},onDragLeave:p=>{p.preventDefault(),t(!1)},onDrop:p=>{p.preventDefault(),t(!1);let w=p.dataTransfer?.files[0];w&&e&&e.handleFile(w)},onPaste:p=>{p.preventDefault();let w=p.clipboardData?.files[0];if(w){e.handleFile(w);return}let y=p.clipboardData?.getData("text/plain");if(y){if(he(y)){e.handleFile(y);return}if(Tt(y)){e.handleFile(y,{as:"svg"});return}}},children:[i(We,{visible:e.loadingState==="loading"}),m?i("div",{className:"FileField__Canvas__Info",children:[i(rt,{size:16,className:"FileField__Canvas__Info__Icon"}),i(Je,{className:"FileField__Canvas__Info__Table",verticalSpacing:"xs",fontSize:"xs",children:i("tbody",{children:[e.value?.filename&&i("tr",{children:[i("td",{children:i("b",{children:"Name"})}),i("td",{children:e.value.filename})]}),e.value?.uploadedAt&&i("tr",{children:[i("td",{children:i("b",{children:"Uploaded"})}),i("td",{children:[new Date(parseInt(e.value.uploadedAt,10)).toLocaleString(),e.value.uploadedBy&&i(O,{children:[" by ",e.value.uploadedBy]})]})]}),!!(e.value?.width&&e.value?.height)&&i("tr",{children:[i("td",{children:i("b",{children:"Dimensions"})}),i("td",{children:[e.value.width,"x",e.value.height]})]}),i("tr",{children:[i("td",{children:i("b",{children:"URL"})}),i("td",{children:i(Z,{readOnly:!0,value:e.value?.src,size:"xs",radius:0,autosize:!0,maxRows:10})})]})]})})]}):i(O,{children:[!!(e.value?.width&&e.value?.height)&&i(Be,{radius:"sm",className:"FileField__Preview__Info",children:[e.value.width,"x",e.value.height]}),M(e.value?.src)&&i("img",{onClick:()=>{e?.focusDropZone()},onDblClick:()=>{e.allowEditing&&e?.requestFileUpload()},src:e.value.src,alt:e.value.alt||"Uploaded file preview",className:"FileField__Preview__Image"}),Q(e.value?.src)&&i(O,{children:i("video",{className:"FileField__Preview__Image",controls:!0,muted:!0,preload:"metadata",children:i("source",{src:e.value.src,type:`video/${Ie(e.value.src)}`})})})]}),e.allowEditing&&i("div",{className:"FileField__reupload",children:i(T.UploadButton,{className:"FileField__reupload__button",compact:!0})})]}),e.allowEditing&&e.showAltText&&(e.altText||Ct(e.value?.filename)||e.variant==="image")&&i("div",{className:"DocEditor__ImageField__imagePreview__Image__Alt",children:[i(Z,{radius:0,className:"DocEditor__ImageField__imagePreview__Image__Alt__Textarea",value:e.altText,placeholder:"Alt text",size:"xs",autosize:!0,disabled:e.loadingState==="loading",onChange:p=>{e?.setAltText(p.currentTarget.value)}}),n.ai&&!e.altText&&e.value?.src?.startsWith("http")&&i(re,{label:"Generate alt text with AI",position:"top",withArrow:!0,children:i(X,{className:"DocEditor__ImageField__imagePreview__Image__Alt__AiButton",onClick:()=>{e.requestGenerateAltText()},disabled:e.loadingState==="loading",children:i(Y,{size:20,stroke:"1.75"})})})]})]}):null};T.UploadButton=e=>{let l=ee(),t=l.loadingState==="loading",a=e.compact?14:16;return i(E,{color:"black",variant:"default",disabled:t,size:e.compact?"compact-xs":"compact-md",className:B("FileField__FileUploadButton",e.compact&&"FileField__FileUploadButton--compact"),onClick:()=>{l.requestFileUpload()},leftIcon:i(O,{children:t&&!e.compact?i(He,{size:a}):l?.variant==="image"?i(Te,{size:a}):i(Ce,{size:a})}),children:t&&!e.compact?"Uploading...":l.value?.src?"Upload":"Paste, drop, or click to upload"})};T.InvisibleDropzone=e=>{let[l,t]=g(!1),a=ee();return i("div",{className:B("FileField__InvisibleDropzone",l&&"dragging"),onDragOver:o=>{o.preventDefault(),o.stopPropagation(),t(!0)},onDragLeave:o=>{o.preventDefault(),o.stopPropagation(),t(!1)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),t(!1);let n=o.dataTransfer?.files[0];n&&a.handleFile(n)},children:e.children})};T.Empty=()=>{let e=ee(),l=J(()=>{if(e.acceptedFileTypes.length===0)return"";let t=e.acceptedFileTypes.filter(a=>a!=="*/*"&&a!=="*");return t.length===0?"":t.map(a=>a.split("/").pop().split("+")[0].replaceAll(".","")).sort().join(", ")},[e.acceptedFileTypes]);return i("div",{className:"FileField__Empty",children:[i("div",{className:"FileField__Empty__Label",children:[i(T.UploadButton,{}),Dt(e.acceptedFileTypes)&&i("div",{children:i(re,{label:"Create placeholder image",children:i(X,{className:"FileField__Empty__Label__PlaceholderButton",onClick:()=>{e.requestPlaceholderModalOpen()},title:"Create placeholder image",children:i(De,{size:16})})})})]}),l&&i("div",{children:i("div",{className:"FileField__Empty__AcceptTypes",children:["Allowed file types: ",l]})})]})};T.Dropzone=be((e,l)=>{let[t,a]=g(!1),o=ee();return i("button",{ref:l,className:B("FileField__Dropzone",t&&"dragging"),onDblClick:()=>{o?.requestFileUpload()},onCopy:n=>{o.value?.src&&(n.preventDefault(),n.clipboardData?.setData("text/plain",o.value.src),n.clipboardData?.setData("application/json",JSON.stringify(o.value)))},onKeyDown:n=>{((n.metaKey||n.ctrlKey)&&n.key==="Backspace"||n.key==="Delete")&&(n.preventDefault(),o.value?.src&&o.removeFile())},onDragOver:n=>{n.preventDefault(),a(!0)},onDragLeave:n=>{n.preventDefault(),a(!1)},onDrop:n=>{n.preventDefault(),a(!1);let s=n.dataTransfer?.files[0];s&&o&&o.handleFile(s)},onPaste:n=>{if(n.preventDefault(),!o)return;let s=n.clipboardData?.getData("application/json");if(s)try{let u=JSON.parse(s);if(u&&u.src&&u.filename&&o){console.log("Parsed JSON file:",u),o.setValue(u);return}}catch(u){console.error("error parsing json",u)}let d=n.clipboardData?.files[0];if(d){o.handleFile(d);return}let c=n.clipboardData?.getData("text/plain");if(c){if(he(c)){o.handleFile(c);return}if(Tt(c)){o.handleFile(c,{as:"svg"});return}}},title:"Drop or paste to upload a file"})});var Mt=be(e=>{let{label:l,description:t,...a}=e;return i("div",{className:"FileField__NamingModeItem",...a,children:[i(G,{size:"sm",weight:500,children:l}),i(G,{size:"xs",color:"dimmed",children:t})]})});function Ct(e){return e?M(e)||Q(e):!1}function Dt(e){return e.some(l=>l.startsWith("image/"))||e.length===0}function Lt(e){let l={};if(e.width&&e.height){l["--canvas-aspect-ratio"]=`${e.width} / ${e.height}`,l["--canvas-asset-width"]=`${e.width}px`;let t=Math.min(e.height,280);t<80&&(t=80),l["--canvas-max-height"]=`${t}px`}return e.canvasBgColor==="dark"&&(l["--canvas-bg-color"]="#000"),l}function Tt(e){return/^(?:\uFEFF)?\s*(?:<!--[\s\S]*?-->\s*)*(?:<\?xml[\s\S]*?\?>\s*)?(?:<!DOCTYPE\s+svg[\s\S]*?>\s*)?<svg\b[^>]*?(?:\/>|>[\s\S]*?<\/svg>)\s*$/.test(e)}export{vt as a,_t as b,H as c,ci as d,ui as e,fe as f,pi as g,gi as h,fi as i,wt as j,zt as k,T as l};
@@ -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};