"use strict";exports.id=721,exports.ids=[721],exports.modules={95280:(e,r,n)=>{n.d(r,{Bj:()=>v,Bm:()=>U,L_:()=>C,RT:()=>f,VZ:()=>m,fC:()=>b,h4:()=>s,j$:()=>E,mm:()=>g,nJ:()=>h,nb:()=>u,sN:()=>R});var t=n(84770),o=n(55315),a=n.n(o),l=n(43753);function d(e){return{id:e.id,name:e.name,path:e.path,enabled:1===e.enabled,cloneUrl:e.clone_url||void 0,normalizedCloneUrl:e.normalized_clone_url||void 0,cloneSource:e.clone_source,isEnvManaged:1===e.is_env_managed,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function i(e){return{id:e.id,cloneUrl:e.clone_url,normalizedCloneUrl:e.normalized_clone_url,targetPath:e.target_path,repositoryId:e.repository_id||void 0,status:e.status,pid:e.pid||void 0,progress:e.progress,errorCategory:e.error_category||void 0,errorCode:e.error_code||void 0,errorMessage:e.error_message||void 0,startedAt:e.started_at?new Date(e.started_at):void 0,completedAt:e.completed_at?new Date(e.completed_at):void 0,createdAt:new Date(e.created_at)}}function s(e,r){let n=(0,t.randomUUID)(),o=Date.now();return e.prepare(`
    INSERT INTO repositories (
      id, name, path, enabled, clone_url, normalized_clone_url,
      clone_source, is_env_managed, created_at, updated_at
    )
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  `).run(n,r.name,r.path,!1!==r.enabled?1:0,r.cloneUrl||null,r.normalizedCloneUrl||null,r.cloneSource,r.isEnvManaged?1:0,o,o),{id:n,name:r.name,path:r.path,enabled:!1!==r.enabled,cloneUrl:r.cloneUrl,normalizedCloneUrl:r.normalizedCloneUrl,cloneSource:r.cloneSource,isEnvManaged:r.isEnvManaged||!1,createdAt:new Date(o),updatedAt:new Date(o)}}function u(e,r){let n=e.prepare(`
    SELECT * FROM repositories
    WHERE normalized_clone_url = ?
  `).get(r);return n?d(n):null}function p(e,r){let n=e.prepare(`
    SELECT * FROM repositories
    WHERE path = ?
  `).get(r);return n?d(n):null}function c(e,r,n){let t=Date.now(),o=["updated_at = ?"],a=[t];void 0!==n.name&&(o.push("name = ?"),a.push(n.name)),void 0!==n.enabled&&(o.push("enabled = ?"),a.push(n.enabled?1:0)),void 0!==n.cloneUrl&&(o.push("clone_url = ?"),a.push(n.cloneUrl||null)),void 0!==n.normalizedCloneUrl&&(o.push("normalized_clone_url = ?"),a.push(n.normalizedCloneUrl||null)),a.push(r),e.prepare(`
    UPDATE repositories
    SET ${o.join(", ")}
    WHERE id = ?
  `).run(...a)}function E(e){return e.prepare(`
    SELECT * FROM repositories
    ORDER BY name ASC
  `).all().map(d)}function _(e){return a().resolve(e)}function m(e){if(!e||"string"!=typeof e)return{valid:!1,error:"repositoryPath is required"};if(e.includes("\0"))return{valid:!1,error:"Invalid repository path"};let r=_(e);return(0,l.F)(r)?{valid:!1,error:"Invalid repository path"}:{valid:!0,resolvedPath:r}}function h(e,r){!function(e,r){for(let n of r){let r=_(n);p(e,r)||s(e,{name:a().basename(r),path:r,cloneSource:"local",isEnvManaged:!0,enabled:!0})}}(e,r);let n=function(e,r){let n=e.prepare("SELECT path FROM repositories WHERE enabled = 0").all().map(e=>e.path);return r.filter(e=>!n.includes(_(e)))}(e,r),t=r.filter(e=>!n.includes(e));return{filteredPaths:n,excludedPaths:t,excludedCount:t.length}}function g(e,r){let n=_(r),t=p(e,n);if(t)c(e,t.id,{enabled:!1});else{if(e.prepare("SELECT COUNT(*) as count FROM repositories WHERE enabled = 0").get().count>=1e3)throw Error("Disabled repository limit exceeded");s(e,{name:a().basename(n),path:n,cloneSource:"local",isEnvManaged:!1,enabled:!1})}}function v(e){return e.prepare("SELECT * FROM repositories WHERE enabled = 0 ORDER BY name ASC").all().map(d)}function f(e,r){let n=p(e,_(r));return n?(c(e,n.id,{enabled:!0}),{...n,enabled:!0}):null}function U(e,r){let n=(0,t.randomUUID)(),o=Date.now();return e.prepare(`
    INSERT INTO clone_jobs (
      id, clone_url, normalized_clone_url, target_path,
      status, progress, created_at
    )
    VALUES (?, ?, ?, ?, 'pending', 0, ?)
  `).run(n,r.cloneUrl,r.normalizedCloneUrl,r.targetPath,o),{id:n,cloneUrl:r.cloneUrl,normalizedCloneUrl:r.normalizedCloneUrl,targetPath:r.targetPath,status:"pending",progress:0,createdAt:new Date(o)}}function C(e,r){let n=e.prepare(`
    SELECT * FROM clone_jobs
    WHERE id = ?
  `).get(r);return n?i(n):null}function R(e,r,n){let t=[],o=[];void 0!==n.status&&(t.push("status = ?"),o.push(n.status)),void 0!==n.pid&&(t.push("pid = ?"),o.push(n.pid)),void 0!==n.progress&&(t.push("progress = ?"),o.push(n.progress)),void 0!==n.repositoryId&&(t.push("repository_id = ?"),o.push(n.repositoryId)),void 0!==n.errorCategory&&(t.push("error_category = ?"),o.push(n.errorCategory)),void 0!==n.errorCode&&(t.push("error_code = ?"),o.push(n.errorCode)),void 0!==n.errorMessage&&(t.push("error_message = ?"),o.push(n.errorMessage)),void 0!==n.startedAt&&(t.push("started_at = ?"),o.push(n.startedAt.getTime())),void 0!==n.completedAt&&(t.push("completed_at = ?"),o.push(n.completedAt.getTime())),0!==t.length&&(o.push(r),e.prepare(`
    UPDATE clone_jobs
    SET ${t.join(", ")}
    WHERE id = ?
  `).run(...o))}function b(e,r){let n=e.prepare(`
    SELECT * FROM clone_jobs
    WHERE normalized_clone_url = ?
      AND status IN ('pending', 'running')
    ORDER BY created_at DESC
    LIMIT 1
  `).get(r);return n?i(n):null}},30721:(e,r,n)=>{n.d(r,{Mf:()=>t.Mf,Aq:()=>t.Aq,dD:()=>t.dD,tn:()=>t.tn,HE:()=>t.HE,_e:()=>t._e,ls:()=>t.ls,GZ:()=>t.GZ,DF:()=>t.DF,j8:()=>t.j8,pM:()=>t.pM,Q7:()=>t.Q7,vX:()=>t.vX,ZI:()=>t.ZI,Db:()=>t.Db,S$:()=>t.S$,_U:()=>t._U,ER:()=>t.ER,zl:()=>t.zl,gU:()=>t.gU,Pv:()=>t.Pv,Xv:()=>t.Xv,GP:()=>t.GP,Ek:()=>t.Ek,VW:()=>t.VW,R3:()=>t.R3,OK:()=>t.OK,Of:()=>t.Of,Nr:()=>t.Nr,GA:()=>t.GA,ey:()=>t.ey,IH:()=>t.IH,Nf:()=>t.Nf,Yg:()=>t.Yg,dl:()=>t.dl,xr:()=>t.xr,y:()=>t.y,ly:()=>t.ly});var t=n(89168);n(67702),n(48215),n(78679),n(95280),n(92048),n(55315),n(19801),(0,n(43895).h)("db-migration-path")}};