1import{r as p}from"./CX2mDMS3.js";import{m as a,l as c}from"./8EojVNpW.js";import"./CgMmVaGw.js";import"./BIKizZCS.js";import"./CDcxIzUs.js";import"./BhBJgTWr.js";import"./Bd6WCHVk.js";import"./Opx4FJVY.js";import"./C5veC5FN.js";import"./B5qAdmPZ.js";import"./D6lJUQn7.js";const u=100,d=5;function I(s,r={}){return p({collection:s.pages,replicationIdentifier:"garden-http-replication",live:!0,autoStart:!1,retryTime:1e4,pull:{async handler(n,o){console.info("[replication] pulling...",{checkpoint:n,batchSize:o});const t=await a("replication:pull",()=>$fetch("/.garden/api/pages/replication/pull",{method:"POST",body:{checkpoint:n,batchSize:o}}));console.info(`[replication] pulled ${t.documents.length} docs`,t.checkpoint),r.onPullBatch?.(t.documents.length,typeof t.remaining=="number"?t.remaining:null);const e=[];for(const i of t.documents)if(i?.softDeleted){const l=i.id??i.content?.content_id??i.content?.slug;l&&e.push(l)}return c({ev:"remote_pull",severity:e.length>0?"warn":"info",docCount:t.documents.length,softDeletedCount:e.length,softDeletedIds:e.slice(0,50),checkpoint:t.checkpoint??null}),{documents:t.documents,checkpoint:t.checkpoint??void 0}},batchSize:u},push:{async handler(n){console.info(`[replication] pushing ${n.length} docs...`,n.map(e=>({slug:e.newDocumentState.content?.slug,softDeleted:e.newDocumentState.softDeleted})));const o=[];for(const e of n)if(e.newDocumentState.softDeleted){const i=e.newDocumentState.id??e.newDocumentState.content?.content_id??e.newDocumentState.content?.slug;i&&o.push(i)}c({ev:"remote_push",severity:o.length>0?"warn":"info",docCount:n.length,softDeletedCount:o.length,softDeletedIds:o.slice(0,50)});const t=await $fetch("/.garden/api/pages/replication/push",{method:"POST",body:{docs:n}});return console.info(`[replication] push done, ${t.length} conflicts`),t.map(e=>({...e,_deleted:!1}))},batchSize:d}})}export{I as setupReplication};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.