{
  "schema": 1,
  "id": "ext.git",
  "name": "Git",
  "version": "1.1.3",
  "category": "tool",
  "description": "Source control with Git: stage and commit changes, diffs, history, branches, tags, stashes, push/pull and the branch in the status bar. Ships with program code.",
  "author": "Lumen",
  "icon": "Gt",
  "color": "#f05033",
  "license": "MIT",
  "minAppVersion": "0.5.0",
  "keywords": [
    "git",
    "scm",
    "source control",
    "version control",
    "commit",
    "branch"
  ],
  "readme": "# Git\n\nSource control with Git, right inside Lumen.\n\n## Contents\n\n- **Source Control** (sidebar): commit message with *Commit*, *Commit & Push*\n  and *Amend*; merge conflicts, staged, changed and untracked files with diff,\n  stage, unstage and discard, one by one or for the whole group. Running\n  merges, rebases and cherry-picks can be continued or aborted.\n- **Branches**: local and remote branches with upstream and ↑/↓, tags, stashes\n  and remotes: check out, merge, rebase, rename, delete, apply.\n- **Git History** (bottom panel): the latest commits with branches and tags;\n  a click shows the diff, the context menu offers create branch/tag, checkout,\n  cherry-pick, revert and reset.\n- **Status bar**: the current branch (with `*` when there are changes) and ↓/↑\n  for syncing.\n- **Commands** in the command palette (`Git: …`), including history and blame\n  of the active file, clone and initialize repository.\n\nThe view refreshes on save, when the window gains focus and every few seconds\nwhile you work with it. Optionally it fetches automatically at an interval\n(*Settings → Extensions → Git*).\n\n## Requirement\n\nGit must be installed. The extension ships program code, which must be\nconfirmed on install; it only calls the installed `git`, without a shell and\nwithout interactive prompts.\n",
  "settings": [
    {
      "key": "gitPath",
      "label": "Path to git",
      "type": "path",
      "pathKind": "file",
      "default": "",
      "placeholder": "git from PATH",
      "hint": "Leave empty to use git from PATH.",
      "section": "General"
    },
    {
      "key": "showUntracked",
      "label": "Show untracked files",
      "type": "toggle",
      "default": "true",
      "section": "General"
    },
    {
      "key": "historyLimit",
      "label": "Commits in history",
      "type": "number",
      "default": "200",
      "min": 20,
      "max": 2000,
      "step": 20,
      "section": "General"
    },
    {
      "key": "confirmDiscard",
      "label": "Ask before discarding",
      "type": "toggle",
      "default": "true",
      "section": "Commits"
    },
    {
      "key": "signOff",
      "label": "Sign off commits (--signoff)",
      "type": "toggle",
      "default": "false",
      "hint": "Appends a Signed-off-by line to every commit message.",
      "section": "Commits"
    },
    {
      "key": "pullMode",
      "label": "Pull behavior",
      "type": "select",
      "default": "merge",
      "section": "Sync",
      "choices": [
        {
          "value": "merge",
          "label": "Merge"
        },
        {
          "value": "rebase",
          "label": "Rebase"
        },
        {
          "value": "ff-only",
          "label": "Fast-forward only"
        }
      ]
    },
    {
      "key": "followTags",
      "label": "Push tags too (--follow-tags)",
      "type": "toggle",
      "default": "false",
      "section": "Sync"
    },
    {
      "key": "autoFetchMinutes",
      "label": "Fetch automatically (minutes)",
      "type": "number",
      "default": "0",
      "min": 0,
      "max": 240,
      "step": 1,
      "hint": "0 turns automatic fetch off.",
      "section": "Sync"
    }
  ],
  "pages": [],
  "agents": [],
  "views": [
    {
      "id": "changes",
      "title": "Source Control",
      "icon": "git-branch",
      "location": "left",
      "order": 15
    },
    {
      "id": "branches",
      "title": "Branches",
      "icon": "git-fork",
      "location": "left",
      "order": 16
    },
    {
      "id": "history",
      "title": "Git History",
      "icon": "history",
      "location": "bottom",
      "order": 70
    }
  ],
  "commands": [
    {
      "id": "git.refresh",
      "title": "Git: Refresh",
      "category": "Git",
      "icon": "refresh-cw"
    },
    {
      "id": "git.open-changes",
      "title": "Git: Show Source Control",
      "category": "Git",
      "icon": "git-branch",
      "keybinding": "Ctrl+Shift+G"
    },
    {
      "id": "git.open-history",
      "title": "Git: Show History",
      "category": "Git",
      "icon": "history"
    },
    {
      "id": "git.open-branches",
      "title": "Git: Show Branches",
      "category": "Git",
      "icon": "git-branch"
    },
    {
      "id": "git.commit",
      "title": "Git: Commit",
      "category": "Git",
      "icon": "git-commit"
    },
    {
      "id": "git.commit-amend",
      "title": "Git: Amend Last Commit",
      "category": "Git",
      "icon": "pencil"
    },
    {
      "id": "git.stage-all",
      "title": "Git: Stage All Changes",
      "category": "Git",
      "icon": "plus"
    },
    {
      "id": "git.unstage-all",
      "title": "Git: Unstage All Changes",
      "category": "Git",
      "icon": "minus"
    },
    {
      "id": "git.discard-all",
      "title": "Git: Discard All Changes",
      "category": "Git",
      "icon": "undo"
    },
    {
      "id": "git.push",
      "title": "Git: Push",
      "category": "Git",
      "icon": "push"
    },
    {
      "id": "git.force-push",
      "title": "Git: Force-Push (with lease)",
      "category": "Git",
      "icon": "push"
    },
    {
      "id": "git.pull",
      "title": "Git: Pull",
      "category": "Git",
      "icon": "pull"
    },
    {
      "id": "git.fetch",
      "title": "Git: Fetch",
      "category": "Git",
      "icon": "cloud-download"
    },
    {
      "id": "git.sync",
      "title": "Git: Sync (Pull & Push)",
      "category": "Git",
      "icon": "arrow-up-down"
    },
    {
      "id": "git.checkout",
      "title": "Git: Checkout Branch…",
      "category": "Git",
      "icon": "git-branch"
    },
    {
      "id": "git.create-branch",
      "title": "Git: Create Branch…",
      "category": "Git",
      "icon": "git-branch-plus"
    },
    {
      "id": "git.merge",
      "title": "Git: Merge Branch…",
      "category": "Git",
      "icon": "git-merge"
    },
    {
      "id": "git.rebase",
      "title": "Git: Rebase onto Branch…",
      "category": "Git",
      "icon": "git-compare"
    },
    {
      "id": "git.create-tag",
      "title": "Git: Create Tag…",
      "category": "Git",
      "icon": "tag"
    },
    {
      "id": "git.stash",
      "title": "Git: Create Stash…",
      "category": "Git",
      "icon": "archive"
    },
    {
      "id": "git.stash-pop",
      "title": "Git: Pop Latest Stash",
      "category": "Git",
      "icon": "archive"
    },
    {
      "id": "git.init",
      "title": "Git: Initialize Repository",
      "category": "Git",
      "icon": "plus"
    },
    {
      "id": "git.clone",
      "title": "Git: Clone Repository…",
      "category": "Git",
      "icon": "download"
    },
    {
      "id": "git.file-history",
      "title": "Git: History of Active File",
      "category": "Git",
      "icon": "history"
    },
    {
      "id": "git.blame",
      "title": "Git: Blame of Active File",
      "category": "Git",
      "icon": "user"
    },
    {
      "id": "git.open-terminal",
      "title": "Git: Open Terminal in Repository",
      "category": "Git",
      "icon": "terminal"
    }
  ],
  "code": {
    "main": "import { createRequire as __lumenRequire } from 'node:module'; const require = __lumenRequire(import.meta.url);\nvar O={en:{view:{changes:\"Source Control\",history:\"History\",branches:\"Branches\"},toolbar:{refresh:\"Refresh\",fetch:\"Fetch\",pull:\"Pull\",push:\"Push\",sync:\"Sync\",checkout:\"Switch Branch\\u2026\",stash:\"Stash\\u2026\"},busy:{loading:\"Reading the repository \\u2026\",commit:\"Committing \\u2026\",push:\"Pushing \\u2026\",pull:\"Pulling \\u2026\",fetch:\"Fetching \\u2026\",checkout:\"Switching branch \\u2026\",merge:\"Merging \\u2026\",rebase:\"Rebasing \\u2026\",clone:\"Cloning repository \\u2026\"},error:{noFolder:\"No folder is open.\",noRepo:\"This folder is not a Git repository.\",noGit:\"git was not found ({path}). Install Git or set its path in the settings.\",timeout:\"{command} took too long and was stopped.\",failed:\"{command} failed (code {code}).\"},empty:{noFolder:\"No folder open\",noFolderHint:\"Open a folder to see its changes.\",noRepo:\"Not a Git repository\",noRepoHint:\"Create a repository here, or clone one.\",clean:\"No changes\",cleanHint:\"Everything on {branch} is committed.\",noCommits:\"No commits yet\",noCommitsHint:\"The first commit will appear here.\"},repo:{init:\"Initialize Repository\",initialized:\"Git repository created.\"},clone:{title:\"Clone Repository\\u2026\",url:\"URL\",parent:\"Parent folder\",parentHint:\"Absolute path of the folder the clone goes into.\",name:\"Folder name\",namePlaceholder:\"from the URL\",submit:\"Clone\",absolute:\"The parent folder must be an absolute path.\",done:\"Cloned into {folder}.\"},commit:{title:\"Commit\",message:\"Commit message\",submit:\"Commit\",andPush:\"Commit & Push\",amend:\"Amend\",placeholder:\"Message (Ctrl+Enter to commit on {branch})\",amendTitle:\"Amend the last commit?\",amendBody:\"The last commit is replaced by a new one. If it was pushed already, you will have to force-push.\",nothing:\"Nothing to commit.\",stageAllTitle:\"Nothing staged\",stageAllBody:\"Nothing is staged. Stage and commit all {count} changes?\",stageAllConfirm:\"Commit All\",done:\"Committed.\",amended:\"Commit amended.\"},diff:{staged:\"staged\",worktree:\"working tree\"},discard:{title:\"Discard changes?\",body:\"{count} file(s) will be reset to the last commit or deleted. This cannot be undone.\",confirm:\"Discard\"},file:{open:\"Open File\",diff:\"Show Changes\",stage:\"Stage\",unstage:\"Unstage\",discard:\"Discard Changes\",delete:\"Delete File\",markResolved:\"Mark as Resolved\",history:\"File History\",conflictCount:\"{count} conflict(s)\",stillConflictedTitle:\"Conflict markers left\",stillConflictedBody:\"{files} still contains conflict markers (<<<<<<<). Stage it as resolved anyway?\",none:\"No file of the repository is active.\",noHistory:\"No history for this file.\",historySuffix:\"history\",blameSuffix:\"blame\"},group:{conflicts:\"Merge Changes\",staged:\"Staged\",changes:\"Changes\",untracked:\"Untracked\",stageAll:\"Stage All\",unstageAll:\"Unstage All\",discardAll:\"Discard All\",markAllResolved:\"Mark All as Resolved\",local:\"Local\",remote:\"Remote\",tags:\"Tags\",stashes:\"Stashes\",remotes:\"Remotes\"},kind:{modified:\"modified\",added:\"added\",deleted:\"deleted\",renamed:\"renamed\",untracked:\"untracked\",conflict:\"conflict\",bothDeleted:\"conflict: deleted by both\",addedByUs:\"conflict: added by us\",deletedByThem:\"conflict: deleted by them\",addedByThem:\"conflict: added by them\",deletedByUs:\"conflict: deleted by us\",bothAdded:\"conflict: added by both\",bothModified:\"conflict: modified by both\"},operation:{merge:\"A merge is in progress. Resolve the conflicts, stage them and continue.\",rebase:\"A rebase is in progress. Resolve the conflicts, stage them and continue.\",cherryPick:\"A cherry-pick is in progress.\",revert:\"A revert is in progress.\",continue:\"Continue\",abort:\"Abort\",abortTitle:\"Abort the operation?\",abortBody:\"The state before the operation is restored.\",unresolved:\"{count} conflicts are still unresolved.\"},push:{detached:\"No branch is checked out (detached HEAD) \\u2014 nothing to push.\",noRemote:\"No remote is set up.\",pickRemote:\"Choose a remote\",publishTitle:\"Publish branch?\",publishBody:\"{branch} has no upstream yet. Push it to {remote} and track it?\",publish:\"Publish\",forceTitle:\"Force push?\",forceBody:\"The history of {branch} on the server will be overwritten (--force-with-lease).\",force:\"Force Push\",done:\"Pushed {branch}.\"},pull:{noUpstream:\"The branch has no upstream.\",done:\"Pull finished.\"},fetch:{done:\"Fetch finished.\"},branch:{none:\"no branch\",current:\"current\",checkout:\"Checkout\",checkoutTitle:\"Switch branch\",checkoutPlaceholder:\"Search branches \\u2026\",createItem:\"+ New branch\\u2026\",remoteDetail:\"remote branch\",createTitle:\"New Branch\",name:\"Name\",from:\"Start point\",checkoutAfter:\"Check it out\",create:\"Create\",invalidName:\"\\u201C{name}\\u201D is not a valid branch name.\",noOther:\"There is no other branch.\",mergeTitle:\"Merge into {branch}\",mergeInto:\"Merge into Current Branch\",merged:\"Merged {branch}.\",rebaseTitle:\"Rebase {branch} onto\",rebaseOnto:\"Rebase Current Branch onto This\",rebased:\"Rebased onto {branch}.\",createFrom:\"Create Branch from Here\\u2026\",rename:\"Rename\\u2026\",renameTitle:\"Rename {branch}\",newName:\"New name\",delete:\"Delete\",deleteTitle:\"Delete branch?\",deleteBody:\"Delete branch {branch}?\",forceDeleteTitle:\"Not merged\",forceDeleteBody:\"{branch} is not fully merged. Delete it anyway? Its commits will be lost.\",forceDelete:\"Delete Anyway\",gone:\"upstream gone\",noUpstream:\"no upstream\"},tag:{createTitle:\"New Tag\",name:\"Name\",message:\"Message\",messageHint:\"With a message an annotated tag is created.\",create:\"Create\",delete:\"Delete Tag\",deleteTitle:\"Delete tag?\",deleteBody:\"Delete tag {tag} locally?\",push:\"Push Tag\"},stash:{title:\"Stash\",message:\"Message\",messagePlaceholder:\"optional\",includeUntracked:\"Include untracked files\",submit:\"Stash\",done:\"Changes stashed.\",show:\"Show\",apply:\"Apply\",pop:\"Pop\",drop:\"Drop\",dropTitle:\"Drop stash?\",dropBody:\"Drop {stash} for good?\"},history:{show:\"Show Commit\",branchHere:\"Create Branch Here\\u2026\",tagHere:\"Create Tag Here\\u2026\",checkout:\"Checkout (Detached)\",cherryPick:\"Cherry-Pick\",revert:\"Revert\",resetSoft:\"Reset (Soft) to Here\",resetMixed:\"Reset (Mixed) to Here\",resetHard:\"Reset (Hard) to Here\",reset:\"Reset\",resetTitle:\"Reset --{mode}?\",resetBody:\"{branch} will point at {hash}; the changes stay in the working tree.\",resetHardBody:\"{branch} will point at {hash}. All uncommitted changes will be lost!\",checkoutTitle:\"Check out commit?\",checkoutBody:\"{hash} will be checked out without a branch (detached HEAD).\",more:\"Load More\"},ref:{head:\"HEAD\",branch:\"branch\",remote:\"remote\",tag:\"tag\"},status:{branchTooltip:\"Branch {branch} \\u2014 click to switch\",detached:\"Detached HEAD at {branch}\",publishTooltip:\"Publish branch\",syncTooltip:\"{upstream}: {ahead} ahead, {behind} behind \\u2014 click to sync\"}}};function L(n,t){return t.split(\".\").reduce((e,r)=>e&&typeof e==\"object\"?e[r]:void 0,n)}function ge(n){let t=String(n.locale?.()??\"en\").slice(0,2);return O[t]?t:\"en\"}function E(n){return(t,e={})=>{let r=L(O[ge(n)],t)??L(O.en,t)??t;return String(r).replace(/\\{(\\w+)\\}/g,(a,i)=>i in e?String(e[i]):a)}}var be=[[\"year\",365*24*3600],[\"month\",720*3600],[\"week\",168*3600],[\"day\",24*3600],[\"hour\",3600],[\"minute\",60]];function v(n,t){if(!t)return\"\";let e=Math.round((t-Date.now())/1e3),r=new Intl.RelativeTimeFormat(n.locale?.()??\"en\",{numeric:\"auto\"}),a=be.find(([,i])=>Math.abs(e)>=i);return a?r.format(Math.round(e/a[1]),a[0]):r.format(0,\"minute\")}import ye from\"node:os\";import we from\"node:path\";var T=class extends Error{constructor(t,e){super(t),this.name=\"GitError\",this.result=e}};function x(n,t){let e=()=>{let i=(n.settings.get(\"gitPath\")??\"\").trim();return i.startsWith(\"~/\")?we.join(ye.homedir(),i.slice(2)):i||\"git\"};function r(i){let c={GIT_TERMINAL_PROMPT:\"0\",GCM_INTERACTIVE:\"never\"};return process.platform!==\"win32\"&&(c.GIT_EDITOR=\"true\"),i&&(c.GIT_OPTIONAL_LOCKS=\"0\"),c}async function a(i,c={}){let d=c.cwd??n.workspace.root();if(!d)throw new T(t(\"error.noFolder\"));let o;try{o=await n.exec(e(),i,{cwd:d,input:c.input,timeoutMs:c.timeoutMs??6e4,env:r(c.readOnly)})}catch(s){throw s?.code===\"ENOENT\"?new T(t(\"error.noGit\",{path:e()})):s}if(o.timedOut)throw new T(t(\"error.timeout\",{command:`git ${i[0]}`}),o);if(o.code===0||c.allowFail)return o;let h=(o.stderr||o.stdout).trim();if(process.platform===\"darwin\"&&/xcode-select|xcodebuild -license|Xcode license/.test(h))throw new T(`${h}\nInstall git with \"xcode-select --install\" or \"brew install git\", or set the path to git in the settings.`,o);let l=h||t(\"error.failed\",{command:`git ${i[0]}`,code:String(o.code)});throw new T(l,o)}return{run:a,binary:e}}import F from\"node:fs\";import R from\"node:path\";var _={M:\"modified\",T:\"modified\",A:\"added\",D:\"deleted\",R:\"renamed\",C:\"added\",U:\"conflict\"},ke={DD:\"bothDeleted\",AU:\"addedByUs\",UD:\"deletedByThem\",UA:\"addedByThem\",DU:\"deletedByUs\",AA:\"bothAdded\",UU:\"bothModified\"};function C(){return{branch:{oid:null,head:null,detached:!1,initial:!1,upstream:null,ahead:0,behind:0},stashes:0,staged:[],unstaged:[],untracked:[],conflicts:[]}}function Te(n,t){let e=t.indexOf(\" \"),r=t.slice(0,e),a=t.slice(e+1),i=n.branch;if(r===\"branch.oid\"){i.initial=a===\"(initial)\",i.oid=i.initial?null:a;return}if(r===\"branch.head\"){i.detached=a===\"(detached)\",i.head=i.detached?null:a;return}if(r===\"branch.upstream\"){i.upstream=a;return}if(r===\"branch.ab\"){let c=/^\\+(\\d+) -(\\d+)$/.exec(a);if(!c)return;i.ahead=Number(c[1]),i.behind=Number(c[2]);return}r===\"stash\"&&(n.stashes=Number(a)||0)}function I(n,t,e,r){let[a,i]=t;a!==\".\"&&n.staged.push({path:e,orig:r,status:a,kind:_[a]??\"modified\"}),i!==\".\"&&n.unstaged.push({path:e,orig:r,status:i,kind:_[i]??\"modified\"})}function j(n){let t=C(),e=String(n??\"\").split(\"\\0\");for(let r=0;r<e.length;r++){let a=e[r];if(!a)continue;if(a.startsWith(\"# \")){Te(t,a.slice(2));continue}let i=a[0];if(i===\"?\"){t.untracked.push({path:a.slice(2),status:\"?\",kind:\"untracked\"});continue}let c=a.split(\" \");if(i===\"1\"){I(t,c[1],c.slice(8).join(\" \"));continue}if(i===\"2\"){let d=e[r+1]??\"\";r++,I(t,c[1],c.slice(9).join(\" \"),d);continue}i===\"u\"&&t.conflicts.push({path:c.slice(10).join(\" \"),status:\"U\",kind:\"conflict\",conflict:ke[c[1]]??\"bothModified\"})}return t}var U=\"%H%x1f%h%x1f%an%x1f%ae%x1f%at%x1f%D%x1f%P%x1f%s%x1e\";function Ae(n){return n.trim()?n.split(\", \").map(t=>{let e=t.trim();return e.startsWith(\"HEAD -> \")?{name:e.slice(8),kind:\"head\"}:e===\"HEAD\"?{name:\"HEAD\",kind:\"head\"}:e.startsWith(\"tag: \")?{name:e.slice(5),kind:\"tag\"}:e.includes(\"/\")?{name:e,kind:\"remote\"}:{name:e,kind:\"branch\"}}):[]}function G(n){return String(n??\"\").split(\"\u001e\").map(t=>t.replace(/^\\n/,\"\")).filter(Boolean).map(t=>{let[e,r,a,i,c,d,o,...h]=t.split(\"\u001f\");return{hash:e,short:r,author:a,email:i,time:Number(c)*1e3,refs:Ae(d??\"\"),parents:(o??\"\").split(\" \").filter(Boolean),subject:h.join(\"\u001f\")}})}var V=\"%(refname)%1f%(refname:short)%1f%(objectname:short)%1f%(upstream:short)%1f%(upstream:track,nobracket)%1f%(HEAD)%1f%(committerdate:unix)%1f%(contents:subject)\";function ve(n){let t=/ahead (\\d+)/.exec(n),e=/behind (\\d+)/.exec(n);return{ahead:t?Number(t[1]):0,behind:e?Number(e[1]):0,gone:n.includes(\"gone\")}}function W(n){let t={local:[],remote:[],tags:[]};for(let e of String(n??\"\").split(`\n`)){if(!e.trim())continue;let[r,a,i,c,d,o,h,...l]=e.split(\"\u001f\"),s={ref:r,name:a,oid:i,time:Number(h)*1e3,subject:l.join(\"\u001f\")};if(r.startsWith(\"refs/heads/\")){t.local.push({...s,upstream:c||null,current:o===\"*\",...ve(d??\"\")});continue}if(r.startsWith(\"refs/remotes/\")){if(r.endsWith(\"/HEAD\"))continue;let u=a.indexOf(\"/\");t.remote.push({...s,remote:a.slice(0,u),branch:a.slice(u+1)});continue}r.startsWith(\"refs/tags/\")&&t.tags.push(s)}return t}var q=\"%gd%x1f%ct%x1f%s\";function z(n){return String(n??\"\").split(`\n`).filter(t=>t.trim()).map(t=>{let[e,r,...a]=t.split(\"\u001f\");return{ref:e,time:Number(r)*1e3,message:a.join(\"\u001f\")}})}function K(n){let t=new Map;for(let e of String(n??\"\").split(`\n`)){let r=/^(\\S+)\\s+(\\S+)\\s+\\((fetch|push)\\)$/.exec(e.trim());if(!r)continue;let[,a,i,c]=r,d=t.get(a)??{name:a,fetch:\"\",push:\"\"};d[c]=i,t.set(a,d)}return[...t.values()]}function X(n){let t=0;for(let e of String(n??\"\").split(`\n`))/^<{7}(?:[ \\r]|$)/.test(e)&&t++;return t}function A(n){let t=n.lastIndexOf(\"/\");return t===-1?{name:n,dir:\"\"}:{name:n.slice(t+1),dir:n.slice(0,t)}}var Re=4*1024*1024,Se=[{marker:\"rebase-merge\",kind:\"rebase\"},{marker:\"rebase-apply\",kind:\"rebase\"},{marker:\"MERGE_HEAD\",kind:\"merge\"},{marker:\"CHERRY_PICK_HEAD\",kind:\"cherryPick\"},{marker:\"REVERT_HEAD\",kind:\"revert\"}];function De(){return{folder:null,top:null,gitDir:null,isRepo:!1,loaded:!1,error:null,busy:null,operation:null,status:C(),refs:{local:[],remote:[],tags:[]},stashes:[],remotes:[],log:[],logLimit:0}}var Y=n=>{let t=Number(n.settings.get(\"historyLimit\"));return Number.isFinite(t)&&t>0?Math.min(t,2e3):200};async function Ce({ctx:n,git:t,state:e}){let r=n.workspace.root();if(e.folder=r,!r)return Object.assign(e,{isRepo:!1,top:null,gitDir:null}),!1;let a=await t.run([\"rev-parse\",\"--show-toplevel\",\"--absolute-git-dir\"],{cwd:r,allowFail:!0,readOnly:!0});if(a.code!==0)return Object.assign(e,{isRepo:!1,top:null,gitDir:null,status:C()}),!1;let[i,c]=a.stdout.trim().split(`\n`);return Object.assign(e,{isRepo:!0,top:i.trim(),gitDir:c?.trim()??null}),!0}function Be(n){return n.gitDir?Se.find(({marker:e})=>F.existsSync(R.join(n.gitDir,e)))?.kind??null:null}function $e(n,t){try{let e=R.join(n.top,t);return F.statSync(e).size>Re?null:X(F.readFileSync(e,\"utf8\"))}catch{return null}}async function Me({ctx:n,git:t,state:e}){let r=[\"status\",\"--porcelain=v2\",\"--branch\",\"--show-stash\",\"-z\"];n.settings.get(\"showUntracked\")===\"false\"&&r.push(\"--untracked-files=no\"),n.settings.get(\"showUntracked\")!==\"false\"&&r.push(\"--untracked-files=all\");let a=await t.run(r,{cwd:e.top,readOnly:!0});e.status=j(a.stdout);for(let i of e.status.conflicts)i.blocks=$e(e,i.path);e.operation=Be(e)}async function He({ctx:n,git:t,state:e}){e.logLimit=Math.max(e.logLimit,Y(n));let[r,a,i,c]=await Promise.all([t.run([\"for-each-ref\",\"--sort=-committerdate\",`--format=${V}`,\"refs/heads\",\"refs/remotes\",\"refs/tags\"],{cwd:e.top,readOnly:!0}),t.run([\"stash\",\"list\",`--format=${q}`],{cwd:e.top,readOnly:!0,allowFail:!0}),t.run([\"remote\",\"-v\"],{cwd:e.top,readOnly:!0,allowFail:!0}),t.run([\"log\",`--max-count=${e.logLimit}`,\"--date-order\",`--pretty=format:${U}`],{cwd:e.top,readOnly:!0,allowFail:!0})]);e.refs=W(r.stdout),e.stashes=z(a.stdout),e.remotes=K(i.stdout),e.log=c.code===0?G(c.stdout):[]}function J(n,t){let e=De(),r={ctx:n,git:t,state:e},a=new Set,i=null,c=null,d=()=>{for(let s of a)s(e)};async function o(s){try{if(!await Ce(r)){e.error=null;return}let f=`${e.status.branch.head}:${e.status.branch.oid}`;await Me(r);let p=f!==`${e.status.branch.head}:${e.status.branch.oid}`;(s||p||!e.loaded)&&await He(r),e.error=null}catch(u){e.error=u.message}finally{e.loaded=!0,d()}}function h(s){return i?(c=c===\"full\"||s?\"full\":\"status\",i):(i=o(s).finally(()=>{if(i=null,!c)return;let u=c;c=null,h(u===\"full\")}),i)}function l(s){if(!e.top)return null;let u=R.relative(e.top,s);return!u||u.startsWith(\"..\")||R.isAbsolute(u)?null:u.split(R.sep).join(\"/\")}return{state:e,onChange(s){return a.add(s),()=>a.delete(s)},refresh:()=>h(!0),refreshStatus:()=>h(!1),run:(s,u={})=>t.run(s,{cwd:e.top??e.folder??void 0,...u}),async busy(s,u){e.busy=s,d();try{return await u()}finally{e.busy=null,d()}},loadMoreHistory(){return e.logLimit+=Y(n),h(!0)},relative:l,absolute:s=>R.join(e.top??\"\",s)}}function Q({ctx:n,repo:t,t:e,notify:r}){async function a(d,o,h){let l=d?t.relative(d):null;if(!l){r(e(\"file.none\"),\"warning\");return}let s=await t.run([...o,\"--\",l],{readOnly:!0,timeoutMs:12e4}).catch(u=>({error:u}));if(s.error){r(s.error.message,\"error\");return}if(!s.stdout.trim()){r(e(\"file.noHistory\"),\"info\");return}n.ui.openDocument(`${A(l).name} (${h})`,s.stdout,o[0]===\"blame\"?void 0:\"diff\")}return{fileHistory:d=>a(d,[\"log\",\"--follow\",\"--patch\",\"--max-count=100\",\"--format=fuller\"],e(\"file.historySuffix\")),blame:d=>a(d,[\"blame\",\"--date=short\"],e(\"file.blameSuffix\"))}}function Z({ctx:n,repo:t,t:e,notify:r,branchName:a,attempt:i,requireRepo:c,validBranchName:d}){async function o(f){let p=[...t.state.refs.local.filter(m=>!m.current).map(m=>({value:m.name,label:m.name,detail:m.subject})),...t.state.refs.remote.map(m=>({value:m.name,label:m.name,detail:e(\"branch.remoteDetail\")}))];return p.length?n.ui.pick(f,p):(r(e(\"branch.noOther\"),\"info\"),null)}async function h(f){if(!c())return;let p=f??await o(e(\"branch.mergeTitle\",{branch:a()??\"HEAD\"}));if(!p)return;let m=await i(()=>t.busy(e(\"busy.merge\"),()=>t.run([\"merge\",\"--no-edit\",p],{timeoutMs:3e5})).then(()=>!0));m&&r(e(\"branch.merged\",{branch:p}),\"success\"),!m&&t.state.status.conflicts.length&&n.ui.showView(\"changes\")}async function l(f){if(!c())return;let p=f??await o(e(\"branch.rebaseTitle\",{branch:a()??\"HEAD\"}));if(!p)return;let m=await i(()=>t.busy(e(\"busy.rebase\"),()=>t.run([\"rebase\",p],{timeoutMs:3e5})).then(()=>!0));m&&r(e(\"branch.rebased\",{branch:p}),\"success\"),!m&&t.state.operation&&n.ui.showView(\"changes\")}async function s(f){let m=(await n.ui.input(e(\"branch.renameTitle\",{branch:f}),[{id:\"name\",label:e(\"branch.newName\"),value:f,required:!0,mono:!0}],{submitLabel:e(\"branch.rename\")}))?.name?.trim();if(!(!m||m===f)){if(!await d(m)){r(e(\"branch.invalidName\",{name:m}),\"error\");return}await i(()=>t.run([\"branch\",\"-m\",f,m]))}}async function u(f){if(!await n.ui.confirm(e(\"branch.deleteTitle\"),e(\"branch.deleteBody\",{branch:f}),{confirmLabel:e(\"branch.delete\"),danger:!0}))return;if((await t.run([\"branch\",\"-d\",f],{allowFail:!0}).catch(g=>({code:1,stderr:g.message}))).code===0){await t.refresh();return}await n.ui.confirm(e(\"branch.forceDeleteTitle\"),e(\"branch.forceDeleteBody\",{branch:f}),{confirmLabel:e(\"branch.forceDelete\"),danger:!0})&&await i(()=>t.run([\"branch\",\"-D\",f]))}return{merge:h,rebase:l,renameBranch:s,deleteBranch:u}}function ee({ctx:n,repo:t,t:e,notify:r,attempt:a,requireRepo:i}){async function c(l){return(await t.run([\"check-ref-format\",\"--branch\",l],{allowFail:!0,readOnly:!0})).code===0}async function d(l){if(!i())return;let s=await n.ui.input(e(\"branch.createTitle\"),[{id:\"name\",label:e(\"branch.name\"),required:!0,mono:!0,placeholder:\"feature/\\u2026\"},{id:\"from\",label:e(\"branch.from\"),value:l??\"\",placeholder:\"HEAD\",mono:!0},{id:\"checkout\",label:e(\"branch.checkoutAfter\"),type:\"toggle\",value:\"true\"}],{submitLabel:e(\"branch.create\")}),u=s?.name?.trim();if(!u)return;if(!await c(u)){r(e(\"branch.invalidName\",{name:u}),\"error\");return}let f=s.from?.trim(),p=s.checkout===\"false\"?[\"branch\",u]:[\"switch\",\"-c\",u];f&&p.push(f),await a(()=>t.run(p))}async function o(l,s=!1){if(!s)return a(()=>t.busy(e(\"busy.checkout\"),()=>t.run([\"switch\",l])));let u=l.slice(l.indexOf(\"/\")+1);return t.state.refs.local.some(p=>p.name===u)?a(()=>t.busy(e(\"busy.checkout\"),()=>t.run([\"switch\",u]))):a(()=>t.busy(e(\"busy.checkout\"),()=>t.run([\"switch\",\"--track\",l])))}async function h(){if(!i())return;let{local:l,remote:s}=t.state.refs,u=new Set(l.map(m=>m.name)),f=[{value:\"\\0new\",label:e(\"branch.createItem\"),detail:\"\"},...l.filter(m=>!m.current).map(m=>({value:`l:${m.name}`,label:m.name,detail:m.subject})),...s.filter(m=>!u.has(m.branch)).map(m=>({value:`r:${m.name}`,label:m.name,detail:e(\"branch.remoteDetail\")}))],p=await n.ui.pick(e(\"branch.checkoutTitle\"),f,{placeholder:e(\"branch.checkoutPlaceholder\")});if(p){if(p===\"\\0new\"){await d();return}await o(p.slice(2),p.startsWith(\"r:\"))}}return{validBranchName:c,createBranch:d,checkoutRef:o,checkout:h}}function te({ctx:n,repo:t,t:e,flag:r,notify:a,status:i,attempt:c,requireRepo:d,push:o}){async function h(l,{amend:s=!1,push:u=!1}={}){if(!d())return!1;let f=String(l??\"\").trim();if(!f&&!s&&(f=(await n.ui.input(e(\"commit.title\"),[{id:\"message\",label:e(\"commit.message\"),type:\"textarea\",required:!0}],{submitLabel:e(\"commit.submit\")}))?.message?.trim()??\"\",!f)||s&&!await n.ui.confirm(e(\"commit.amendTitle\"),e(\"commit.amendBody\"),{confirmLabel:e(\"commit.amend\")}))return!1;let p=i(),m=p.unstaged.length+p.untracked.length;if(!p.staged.length&&!s){if(!m)return a(e(\"commit.nothing\"),\"info\"),!1;if(!await n.ui.confirm(e(\"commit.stageAllTitle\"),e(\"commit.stageAllBody\",{count:String(m)}),{confirmLabel:e(\"commit.stageAllConfirm\")})||!await c(()=>t.run([\"add\",\"-A\"]).then(()=>!0),{full:!1}))return!1}let b=[\"commit\"];return s&&b.push(\"--amend\"),s&&!f&&b.push(\"--no-edit\"),f&&b.push(\"-F\",\"-\"),r(\"signOff\",!1)&&b.push(\"--signoff\"),await c(()=>t.busy(e(\"busy.commit\"),()=>t.run(b,{input:f?`${f}\n`:void 0,timeoutMs:18e4})).then(()=>!0))?(a(e(s?\"commit.amended\":\"commit.done\"),\"success\"),u&&await o(),!0):!1}return{commit:h}}function ne({ctx:n,repo:t,t:e,flag:r,notify:a,status:i,attempt:c}){let d=g=>n.ui.openFile(t.absolute(g));async function o(g,y){if([...i().untracked,...i().conflicts].find(H=>H.path===g)&&!y){d(g);return}let S=y?[\"diff\",\"--cached\",\"--\",g]:[\"diff\",\"--\",g],k=await t.run(S,{readOnly:!0}).catch(H=>({stdout:\"\",error:H}));if(k.error){a(k.error.message,\"error\");return}if(!k.stdout.trim()){d(g);return}let pe=e(y?\"diff.staged\":\"diff.worktree\");n.ui.openDocument(`${A(g).name} (${pe}).diff`,k.stdout,\"diff\")}let h=g=>c(()=>t.run([\"add\",\"-A\",\"--\",...g]),{full:!1});function l(g){return i().branch.initial?c(()=>t.run([\"rm\",\"--cached\",\"-r\",\"-q\",\"--\",...g]),{full:!1}):c(()=>t.run([\"restore\",\"--staged\",\"--\",...g]),{full:!1})}async function s(g){return r(\"confirmDiscard\",!0)?n.ui.confirm(e(\"discard.title\"),e(\"discard.body\",{count:String(g)}),{confirmLabel:e(\"discard.confirm\"),danger:!0}):!0}async function u(g){if(!g.length||!await s(g.length))return;let y=new Set(i().untracked.map(k=>k.path)),w=g.filter(k=>!y.has(k)),S=g.filter(k=>y.has(k));await c(async()=>{w.length&&await t.run([\"restore\",\"--worktree\",\"--\",...w]),S.length&&await t.run([\"clean\",\"-f\",\"-q\",\"--\",...S])},{full:!1})}let f=()=>c(()=>t.run([\"add\",\"-A\"]),{full:!1}),p=()=>l(i().staged.map(g=>g.path)),m=()=>u([...i().unstaged.map(g=>g.path),...i().untracked.map(g=>g.path)]);async function b(g){let y=i().conflicts.filter(w=>g.includes(w.path)&&w.blocks>0);if(y.length){let w=y.map(k=>A(k.path).name).join(\", \");if(!await n.ui.confirm(e(\"file.stillConflictedTitle\"),e(\"file.stillConflictedBody\",{files:w}),{confirmLabel:e(\"file.markResolved\"),danger:!0}))return}return h(g)}return{openFile:d,openDiff:o,stage:h,unstage:l,discard:u,stageAll:f,unstageAll:p,discardAll:m,markResolved:b}}function re({ctx:n,repo:t,t:e,notify:r,branchName:a,attempt:i}){async function c(s){let u=await t.run([\"show\",\"--stat\",\"--patch\",\"--format=fuller\",s],{readOnly:!0,timeoutMs:6e4}).catch(f=>({error:f}));if(u.error){r(u.error.message,\"error\");return}n.ui.openDocument(`${s.slice(0,8)}.diff`,u.stdout,\"diff\")}async function d(s){await n.ui.confirm(e(\"history.checkoutTitle\"),e(\"history.checkoutBody\",{hash:s.slice(0,8)}),{confirmLabel:e(\"history.checkout\")})&&await i(()=>t.run([\"switch\",\"--detach\",s]))}let o=s=>i(()=>t.run([\"cherry-pick\",s])),h=s=>i(()=>t.run([\"revert\",\"--no-edit\",s]));async function l(s,u){let f=u===\"hard\";await n.ui.confirm(e(\"history.resetTitle\",{mode:u}),e(f?\"history.resetHardBody\":\"history.resetBody\",{hash:s.slice(0,8),branch:a()??\"HEAD\"}),{confirmLabel:e(\"history.reset\"),danger:f})&&await i(()=>t.run([\"reset\",`--${u}`,s]))}return{showCommit:c,checkoutCommit:d,cherryPick:o,revert:h,reset:l}}var P={merge:[\"--no-rebase\"],rebase:[\"--rebase\"],\"ff-only\":[\"--ff-only\"]},N={merge:{continue:[\"commit\",\"--no-edit\"],abort:[\"merge\",\"--abort\"]},rebase:{continue:[\"rebase\",\"--continue\"],abort:[\"rebase\",\"--abort\"]},cherryPick:{continue:[\"cherry-pick\",\"--continue\"],abort:[\"cherry-pick\",\"--abort\"]},revert:{continue:[\"revert\",\"--continue\"],abort:[\"revert\",\"--abort\"]}};function oe({ctx:n,repo:t,t:e,notify:r,status:a,attempt:i}){async function c(){let o=N[t.state.operation];if(o){if(a().conflicts.length){r(e(\"operation.unresolved\",{count:String(a().conflicts.length)}),\"warning\");return}await i(()=>t.run(o.continue,{timeoutMs:3e5}))}}async function d(){let o=N[t.state.operation];o&&await n.ui.confirm(e(\"operation.abortTitle\"),e(\"operation.abortBody\"),{confirmLabel:e(\"operation.abort\"),danger:!0})&&await i(()=>t.run(o.abort))}return{continueOperation:c,abortOperation:d}}function ae({ctx:n,repo:t,t:e,setting:r,flag:a,notify:i,status:c,attempt:d,requireRepo:o}){async function h(){let p=t.state.remotes;if(!p.length)return i(e(\"push.noRemote\"),\"warning\"),null;let m=p.find(b=>b.name===\"origin\");return m?m.name:p.length===1?p[0].name:n.ui.pick(e(\"push.pickRemote\"),p.map(b=>({value:b.name,label:b.name,detail:b.push||b.fetch})))}async function l({force:p=!1}={}){if(!o())return;let{branch:m}=c();if(m.detached||!m.head){i(e(\"push.detached\"),\"warning\");return}let b=[\"push\"];if(p&&b.push(\"--force-with-lease\"),a(\"followTags\",!1)&&b.push(\"--follow-tags\"),!m.upstream){let y=await h();if(!y||!await n.ui.confirm(e(\"push.publishTitle\"),e(\"push.publishBody\",{branch:m.head,remote:y}),{confirmLabel:e(\"push.publish\")}))return;b.push(\"-u\",y,m.head)}if(p&&!await n.ui.confirm(e(\"push.forceTitle\"),e(\"push.forceBody\",{branch:m.head}),{confirmLabel:e(\"push.force\"),danger:!0}))return;await d(()=>t.busy(e(\"busy.push\"),()=>t.run(b,{timeoutMs:3e5})).then(()=>!0))&&i(e(\"push.done\",{branch:m.head}),\"success\")}async function s(){if(!o())return!1;if(!c().branch.upstream)return i(e(\"pull.noUpstream\"),\"warning\"),!1;let p=P[r(\"pullMode\")]?r(\"pullMode\"):\"merge\",m=await d(()=>t.busy(e(\"busy.pull\"),()=>t.run([\"pull\",...P[p]],{timeoutMs:3e5})).then(()=>!0));return m&&i(e(\"pull.done\"),\"success\"),!!m}async function u({quiet:p=!1}={}){if(!t.state.isRepo)return;if(p){await t.run([\"fetch\",\"--all\",\"--prune\",\"--quiet\"],{timeoutMs:12e4,allowFail:!0}).catch(()=>{}),await t.refresh();return}await d(()=>t.busy(e(\"busy.fetch\"),()=>t.run([\"fetch\",\"--all\",\"--prune\"],{timeoutMs:3e5})).then(()=>!0))&&i(e(\"fetch.done\"),\"success\")}async function f(){if(!o())return;if(!c().branch.upstream){await l();return}await s()&&c().branch.ahead>0&&await l()}return{pickRemote:h,push:l,pull:s,fetch:u,sync:f}}import B from\"node:path\";function ie({ctx:n,repo:t,t:e,notify:r,attempt:a}){async function i(){let d=n.workspace.root();if(!d){r(e(\"error.noFolder\"),\"warning\");return}await a(()=>t.run([\"init\"],{cwd:d}).then(()=>!0))&&r(e(\"repo.initialized\"),\"success\")}async function c(){let d=n.workspace.root()?B.dirname(n.workspace.root()):\"\",o=await n.ui.input(e(\"clone.title\"),[{id:\"url\",label:e(\"clone.url\"),required:!0,mono:!0,placeholder:\"https://github.com/owner/repo.git\"},{id:\"parent\",label:e(\"clone.parent\"),required:!0,mono:!0,value:d,hint:e(\"clone.parentHint\")},{id:\"name\",label:e(\"clone.name\"),mono:!0,placeholder:e(\"clone.namePlaceholder\")}],{submitLabel:e(\"clone.submit\")}),h=o?.url?.trim(),l=o?.parent?.trim();if(!h||!l)return;if(!B.isAbsolute(l)){r(e(\"clone.absolute\"),\"error\");return}let s=[\"clone\",\"--progress\",h];o.name?.trim()&&s.push(o.name.trim());try{await t.busy(e(\"busy.clone\"),()=>t.run(s,{cwd:l,timeoutMs:18e5})),r(e(\"clone.done\",{folder:B.join(l,o.name?.trim()||B.basename(h).replace(/\\.git$/,\"\"))}),\"success\")}catch(u){r(u.message,\"error\")}}return{init:i,clone:c}}function se({ctx:n,repo:t,t:e,notify:r,attempt:a,requireRepo:i}){async function c(){if(!i())return;let s=await n.ui.input(e(\"stash.title\"),[{id:\"message\",label:e(\"stash.message\"),placeholder:e(\"stash.messagePlaceholder\")},{id:\"untracked\",label:e(\"stash.includeUntracked\"),type:\"toggle\",value:\"true\"}],{submitLabel:e(\"stash.submit\")});if(!s)return;let u=[\"stash\",\"push\"];s.untracked!==\"false\"&&u.push(\"--include-untracked\"),s.message?.trim()&&u.push(\"-m\",s.message.trim()),await a(()=>t.run(u).then(()=>!0))&&r(e(\"stash.done\"),\"success\")}let d=(s=\"stash@{0}\")=>a(()=>t.run([\"stash\",\"pop\",s])),o=s=>a(()=>t.run([\"stash\",\"apply\",s]));async function h(s){await n.ui.confirm(e(\"stash.dropTitle\"),e(\"stash.dropBody\",{stash:s}),{confirmLabel:e(\"stash.drop\"),danger:!0})&&await a(()=>t.run([\"stash\",\"drop\",s]))}async function l(s){let u=await t.run([\"stash\",\"show\",\"--include-untracked\",\"--stat\",\"--patch\",s],{readOnly:!0}).catch(f=>({error:f}));if(u.error){r(u.error.message,\"error\");return}n.ui.openDocument(`${s}.diff`,u.stdout,\"diff\")}return{stash:c,stashPop:d,stashApply:o,stashDrop:h,stashShow:l}}function ce({ctx:n,repo:t,t:e,attempt:r,requireRepo:a,pickRemote:i}){async function c(h){if(!a())return;let l=await n.ui.input(e(\"tag.createTitle\"),[{id:\"name\",label:e(\"tag.name\"),required:!0,mono:!0,placeholder:\"v1.0.0\"},{id:\"message\",label:e(\"tag.message\"),type:\"textarea\",hint:e(\"tag.messageHint\")}],{submitLabel:e(\"tag.create\")}),s=l?.name?.trim();if(!s)return;let u=l.message?.trim(),f=u?[\"tag\",\"-a\",s,\"-m\",u]:[\"tag\",s];h&&f.push(h),await r(()=>t.run(f))}async function d(h){await n.ui.confirm(e(\"tag.deleteTitle\"),e(\"tag.deleteBody\",{tag:h}),{confirmLabel:e(\"tag.delete\"),danger:!0})&&await r(()=>t.run([\"tag\",\"-d\",h]))}async function o(h){let l=await i();l&&await r(()=>t.busy(e(\"busy.push\"),()=>t.run([\"push\",l,`refs/tags/${h}`],{timeoutMs:3e5})))}return{createTag:c,deleteTag:d,pushTag:o}}function le({ctx:n,repo:t,t:e}){let r=g=>n.settings.get(g),a=(g,y)=>{let w=r(g);return w===void 0||w===\"\"?y:w===\"true\"},i=(g,y=\"info\")=>n.ui.notify(g,y),c=()=>t.state.status,d=()=>c().branch.head;async function o(g,{full:y=!0}={}){try{return await g()}catch(w){i(w.message,\"error\");return}finally{await(y?t.refresh():t.refreshStatus())}}let l={ctx:n,repo:t,t:e,setting:r,flag:a,notify:i,status:c,branchName:d,attempt:o,requireRepo:()=>t.state.isRepo?!0:(i(e(\"error.noRepo\"),\"warning\"),!1)},s=ae(l),u=te({...l,push:s.push}),f=ne(l),p=ee(l),m={...s};delete m.pickRemote;let b={...p};return delete b.validBranchName,{...f,...u,...m,...b,...Z({...l,validBranchName:p.validBranchName}),...ce({...l,pickRemote:s.pickRemote}),...se(l),...re(l),...oe(l),...ie(l),...Q(l)}}var Oe={M:\"M\",T:\"T\",A:\"A\",D:\"D\",R:\"R\",C:\"C\",U:\"!\",\"?\":\"U\"};function Fe(n,t,e){let r={action:\"open\",title:e(\"file.open\"),icon:\"file\",payload:t.path};return{staged:[r,{action:\"unstage\",title:e(\"file.unstage\"),icon:\"minus\",payload:t.path}],changes:[r,{action:\"discard\",title:e(\"file.discard\"),icon:\"undo\",payload:t.path},{action:\"stage\",title:e(\"file.stage\"),icon:\"plus\",payload:t.path}],untracked:[r,{action:\"discard\",title:e(\"file.delete\"),icon:\"trash-2\",payload:t.path},{action:\"stage\",title:e(\"file.stage\"),icon:\"plus\",payload:t.path}],conflicts:[r,{action:\"resolve\",title:e(\"file.markResolved\"),icon:\"check\",payload:t.path}]}[n]}function Pe(n,t,e){let r=n===\"staged\";return[{action:\"open\",title:e(\"file.open\"),payload:t.path},{action:\"diff\",title:e(\"file.diff\"),payload:{path:t.path,staged:r}},...n===\"changes\"||n===\"untracked\"?[{action:\"stage\",title:e(\"file.stage\"),payload:t.path}]:[],...r?[{action:\"unstage\",title:e(\"file.unstage\"),payload:t.path}]:[],...n===\"changes\"?[{action:\"discard\",title:e(\"file.discard\"),payload:t.path,danger:!0}]:[],...n===\"untracked\"?[{action:\"discard\",title:e(\"file.delete\"),payload:t.path,danger:!0}]:[],{action:\"history\",title:e(\"file.history\"),payload:t.path}]}function Ne(n,t,e){let{name:r,dir:a}=A(n.path),i=t===\"staged\",c=n.orig?`${n.orig} \\u2192 `:\"\",d=t===\"conflicts\"&&n.blocks?e(\"file.conflictCount\",{count:String(n.blocks)}):\"\";return{type:\"item\",id:`${t}:${n.path}`,label:r,description:[d,a].filter(Boolean).join(\" \\xB7 \"),tooltip:`${c}${n.path}\n${e(`kind.${n.conflict??n.kind}`)}`,fileIcon:r,tone:n.kind,badge:Oe[n.status]??n.status,badgeTone:n.kind,strike:n.kind===\"deleted\",onClick:t===\"conflicts\"?{action:\"open\",title:e(\"file.open\"),payload:n.path}:{action:\"diff\",title:e(\"file.diff\"),payload:{path:n.path,staged:i}},actions:Fe(t,n,e),menu:Pe(t,n,e)}}function $(n,t,e,r,a){return e.length?[{type:\"section\",id:n,title:t,badge:e.length,actions:r,children:e.map(i=>Ne(i,n,a))}]:[]}function Le(n,t){return n?[{type:\"text\",text:t(`operation.${n}`),tone:\"warning\"},{type:\"buttons\",buttons:[{action:\"continue\",title:t(\"operation.continue\"),icon:\"check\",variant:\"primary\"},{action:\"abort\",title:t(\"operation.abort\"),icon:\"x\",variant:\"danger\"}]},{type:\"divider\"}]:[]}function Ee(n,t){return n.workspace.root()?{title:t(\"view.changes\"),nodes:[{type:\"empty\",title:t(\"empty.noRepo\"),hint:t(\"empty.noRepoHint\"),icon:\"git-branch\",action:{action:\"init\",title:t(\"repo.init\"),icon:\"plus\",variant:\"primary\"}},{type:\"buttons\",buttons:[{action:\"clone\",title:t(\"clone.title\"),icon:\"download\",variant:\"secondary\"}]}]}:{nodes:[{type:\"empty\",title:t(\"empty.noFolder\"),hint:t(\"empty.noFolderHint\"),icon:\"folder\"}]}}function xe({id:n,draft:t,branch:e,state:r,status:a,t:i}){let c=!!r.busy;return[{type:\"input\",id:n,placeholder:i(\"commit.placeholder\",{branch:e}),value:t,multiline:!0,rows:3,submit:{action:\"commit\",title:i(\"commit.submit\")}},{type:\"buttons\",buttons:[{action:\"commit\",title:i(\"commit.submit\"),icon:\"check\",variant:\"primary\",disabled:c},{action:\"commitPush\",title:i(\"commit.andPush\"),icon:\"cloud-upload\",variant:\"secondary\",disabled:c},{action:\"amend\",title:i(\"commit.amend\"),icon:\"pencil\",variant:\"secondary\",disabled:c||a.branch.initial}]}]}function _e(n,t){return[...$(\"conflicts\",t(\"group.conflicts\"),n.conflicts,[{action:\"resolveAll\",title:t(\"group.markAllResolved\"),icon:\"check-check\"}],t),...$(\"staged\",t(\"group.staged\"),n.staged,[{action:\"unstageAll\",title:t(\"group.unstageAll\"),icon:\"minus\"}],t),...$(\"changes\",t(\"group.changes\"),n.unstaged,[{action:\"discardAll\",title:t(\"group.discardAll\"),icon:\"undo\",danger:!0},{action:\"stageAll\",title:t(\"group.stageAll\"),icon:\"plus\"}],t),...$(\"untracked\",t(\"group.untracked\"),n.untracked,[{action:\"stageUntracked\",title:t(\"group.stageAll\"),icon:\"plus\"}],t)]}function Ie(n){return[{action:\"refresh\",title:n(\"toolbar.refresh\"),icon:\"refresh-cw\"},{action:\"fetch\",title:n(\"toolbar.fetch\"),icon:\"cloud-download\"},{action:\"pull\",title:n(\"toolbar.pull\"),icon:\"pull\"},{action:\"push\",title:n(\"toolbar.push\"),icon:\"push\"},{action:\"sync\",title:n(\"toolbar.sync\"),icon:\"arrow-up-down\"},{action:\"branch\",title:n(\"toolbar.checkout\"),icon:\"git-branch\"},{action:\"stash\",title:n(\"toolbar.stash\"),icon:\"archive\"}]}var M=n=>n.map(t=>t.path);function je(n,t){return{refresh:()=>n.refresh(),fetch:()=>t.fetch(),pull:()=>t.pull(),push:()=>t.push(),sync:()=>t.sync(),branch:()=>t.checkout(),stash:()=>t.stash(),init:()=>t.init(),clone:()=>t.clone(),open:e=>t.openFile(String(e)),diff:e=>t.openDiff(e.path,e.staged),history:e=>t.fileHistory(n.absolute(String(e))),stage:e=>t.stage([String(e)]),unstage:e=>t.unstage([String(e)]),discard:e=>t.discard([String(e)]),resolve:e=>t.markResolved([String(e)]),resolveAll:()=>t.markResolved(M(n.state.status.conflicts)),stageAll:()=>t.stage(M(n.state.status.unstaged)),stageUntracked:()=>t.stage(M(n.state.status.untracked)),unstageAll:()=>t.unstageAll(),discardAll:()=>t.discard(M(n.state.status.unstaged)),continue:()=>t.continueOperation(),abort:()=>t.abortOperation()}}var Ue={commit:{},commitPush:{push:!0},amend:{amend:!0}};function ue({ctx:n,repo:t,actions:e,t:r}){let a=\"\",i=0,c=()=>`message-${i}`;function d(){let{state:l}=t;if(!l.loaded)return{title:r(\"view.changes\"),nodes:[{type:\"progress\",label:r(\"busy.loading\")}]};if(!l.isRepo)return Ee(n,r);let{status:s}=l,u=s.staged.length+s.unstaged.length+s.untracked.length+s.conflicts.length,f=s.branch.head??s.branch.oid?.slice(0,8)??r(\"branch.none\"),p=[...l.busy?[{type:\"progress\",label:l.busy}]:[],...l.error?[{type:\"text\",text:l.error,tone:\"danger\",small:!0}]:[],...Le(l.operation,r),...xe({id:c(),draft:a,branch:f,state:l,status:s,t:r}),..._e(s,r),...u?[]:[{type:\"empty\",title:r(\"empty.clean\"),hint:r(\"empty.cleanHint\",{branch:f}),icon:\"circle-check\"}]];return{title:r(\"view.changes\"),badge:u||void 0,toolbar:Ie(r),nodes:p}}let o=je(t,e);async function h(l){a=String(l.inputs?.[c()]??a);let s=Ue[l.action];if(s){if(!await e.commit(a,s))return;a=\"\",i++,n.views.refresh(\"changes\");return}let u=o[l.action];u&&await u(l.payload)}return{render:d,onAction:h,currentDraft:()=>a}}var Ge={head:\"accent\",branch:\"success\",remote:\"muted\",tag:\"warning\"};function Ve(n){if(n.length)return n.length===1?n[0].name:`${n[0].name} +${n.length-1}`}function de({ctx:n,repo:t,actions:e,t:r}){function a(o){let h=o.parents.length>1,l=o.refs.filter(f=>f.name!==\"HEAD\"),s=l[0],u=v(n,o.time);return{type:\"item\",id:o.hash,label:o.subject||o.short,description:`${o.short} \\xB7 ${o.author} \\xB7 ${u}`,tooltip:[o.subject,`${o.hash}`,`${o.author} <${o.email}>`,new Date(o.time).toLocaleString(n.locale()),...l.map(f=>`${r(`ref.${f.kind}`)}: ${f.name}`)].join(`\n`),icon:h?\"git-merge\":\"git-commit\",iconTone:s?.kind===\"head\"?\"accent\":\"muted\",badge:Ve(l),badgeTone:s?Ge[s.kind]:void 0,onClick:{action:\"show\",title:r(\"history.show\"),payload:o.hash},actions:[{action:\"show\",title:r(\"history.show\"),icon:\"file-diff\",payload:o.hash}],menu:[{action:\"show\",title:r(\"history.show\"),payload:o.hash},{action:\"branch\",title:r(\"history.branchHere\"),payload:o.hash},{action:\"tag\",title:r(\"history.tagHere\"),payload:o.hash},{action:\"checkout\",title:r(\"history.checkout\"),payload:o.hash},{action:\"cherryPick\",title:r(\"history.cherryPick\"),payload:o.hash},{action:\"revert\",title:r(\"history.revert\"),payload:o.hash},{action:\"resetSoft\",title:r(\"history.resetSoft\"),payload:o.hash},{action:\"resetMixed\",title:r(\"history.resetMixed\"),payload:o.hash},{action:\"resetHard\",title:r(\"history.resetHard\"),payload:o.hash,danger:!0}]}}function i(){let{state:o}=t;if(!o.loaded)return{title:r(\"view.history\"),nodes:[{type:\"progress\",label:r(\"busy.loading\")}]};if(!o.isRepo)return{title:r(\"view.history\"),nodes:[{type:\"empty\",title:r(\"empty.noRepo\"),icon:\"history\"}]};if(!o.log.length)return{title:r(\"view.history\"),nodes:[{type:\"empty\",title:r(\"empty.noCommits\"),hint:r(\"empty.noCommitsHint\"),icon:\"git-commit\"}]};let h=o.log.length>=o.logLimit;return{title:r(\"view.history\"),toolbar:[{action:\"refresh\",title:r(\"toolbar.refresh\"),icon:\"refresh-cw\"}],nodes:[...o.log.map(a),...h?[{type:\"buttons\",buttons:[{action:\"more\",title:r(\"history.more\"),icon:\"chevron-down\",variant:\"secondary\"}]}]:[]]}}let c={refresh:()=>t.refresh(),more:()=>t.loadMoreHistory(),show:o=>e.showCommit(o),branch:o=>e.createBranch(o),tag:o=>e.createTag(o),checkout:o=>e.checkoutCommit(o),cherryPick:o=>e.cherryPick(o),revert:o=>e.revert(o),resetSoft:o=>e.reset(o,\"soft\"),resetMixed:o=>e.reset(o,\"mixed\"),resetHard:o=>e.reset(o,\"hard\")};async function d(o){let h=c[o.action];h&&await h(String(o.payload??\"\"))}return{render:i,onAction:d}}function We(n,t){if(n.gone)return t(\"branch.gone\");if(!n.upstream)return t(\"branch.noUpstream\");let e=[n.upstream];return n.ahead&&e.push(`\\u2191${n.ahead}`),n.behind&&e.push(`\\u2193${n.behind}`),e.join(\" \")}function qe(n,{ctx:t,t:e}){let r=[...n.current?[]:[{action:\"checkout\",title:e(\"branch.checkout\"),payload:n.name}],...n.current?[]:[{action:\"merge\",title:e(\"branch.mergeInto\"),payload:n.name}],...n.current?[]:[{action:\"rebase\",title:e(\"branch.rebaseOnto\"),payload:n.name}],{action:\"branchFrom\",title:e(\"branch.createFrom\"),payload:n.name},{action:\"rename\",title:e(\"branch.rename\"),payload:n.name},...n.current?[]:[{action:\"delete\",title:e(\"branch.delete\"),payload:n.name,danger:!0}]];return{type:\"item\",id:`local:${n.name}`,label:n.name,description:We(n,e),tooltip:`${n.name}\n${n.oid} ${n.subject}\n${v(t,n.time)}`,icon:n.current?\"check\":\"git-branch\",iconTone:n.current?\"accent\":\"muted\",tone:n.current?\"accent\":\"default\",badge:n.current?e(\"branch.current\"):void 0,badgeTone:\"accent\",onClick:n.current?void 0:{action:\"checkout\",title:e(\"branch.checkout\"),payload:n.name},actions:n.current?[]:[{action:\"checkout\",title:e(\"branch.checkout\"),icon:\"log-in\",payload:n.name}],menu:r}}function ze(n,{ctx:t,t:e}){return{type:\"item\",id:`remote:${n.name}`,label:n.name,description:`${n.oid} \\xB7 ${v(t,n.time)}`,tooltip:`${n.name}\n${n.subject}`,icon:\"cloud\",iconTone:\"muted\",onClick:{action:\"checkoutRemote\",title:e(\"branch.checkout\"),payload:n.name},actions:[{action:\"checkoutRemote\",title:e(\"branch.checkout\"),icon:\"log-in\",payload:n.name}],menu:[{action:\"checkoutRemote\",title:e(\"branch.checkout\"),payload:n.name},{action:\"merge\",title:e(\"branch.mergeInto\"),payload:n.name},{action:\"rebase\",title:e(\"branch.rebaseOnto\"),payload:n.name},{action:\"branchFrom\",title:e(\"branch.createFrom\"),payload:n.name}]}}function Ke(n,{t}){return{type:\"item\",id:`tag:${n.name}`,label:n.name,description:n.subject,icon:\"tag\",iconTone:\"warning\",onClick:{action:\"showCommit\",title:t(\"history.show\"),payload:n.name},menu:[{action:\"showCommit\",title:t(\"history.show\"),payload:n.name},{action:\"checkoutTag\",title:t(\"branch.checkout\"),payload:n.name},{action:\"branchFrom\",title:t(\"branch.createFrom\"),payload:n.name},{action:\"pushTag\",title:t(\"tag.push\"),payload:n.name},{action:\"deleteTag\",title:t(\"tag.delete\"),payload:n.name,danger:!0}]}}function Xe(n,{ctx:t,t:e}){return{type:\"item\",id:`stash:${n.ref}`,label:n.message,description:`${n.ref} \\xB7 ${v(t,n.time)}`,icon:\"archive\",iconTone:\"muted\",onClick:{action:\"stashShow\",title:e(\"stash.show\"),payload:n.ref},actions:[{action:\"stashApply\",title:e(\"stash.apply\"),icon:\"check\",payload:n.ref},{action:\"stashPop\",title:e(\"stash.pop\"),icon:\"arrow-up\",payload:n.ref}],menu:[{action:\"stashShow\",title:e(\"stash.show\"),payload:n.ref},{action:\"stashApply\",title:e(\"stash.apply\"),payload:n.ref},{action:\"stashPop\",title:e(\"stash.pop\"),payload:n.ref},{action:\"stashDrop\",title:e(\"stash.drop\"),payload:n.ref,danger:!0}]}}function Ye(n,{t}){return{type:\"item\",id:`remote-entry:${n.name}`,label:n.name,description:n.fetch,tooltip:`fetch: ${n.fetch}\npush: ${n.push}`,icon:\"globe\",iconTone:\"muted\",actions:[{action:\"fetch\",title:t(\"toolbar.fetch\"),icon:\"cloud-download\"}]}}function D(n,t,e,r=[],a=!1){return e.length?[{type:\"section\",id:n,title:t,badge:e.length,collapsed:a,actions:r,children:e}]:[]}function Je(n){return[{action:\"create\",title:n(\"branch.createTitle\"),icon:\"git-branch-plus\"},{action:\"createTag\",title:n(\"tag.createTitle\"),icon:\"tag\"},{action:\"stash\",title:n(\"toolbar.stash\"),icon:\"archive\"},{action:\"fetch\",title:n(\"toolbar.fetch\"),icon:\"cloud-download\"},{action:\"refresh\",title:n(\"toolbar.refresh\"),icon:\"refresh-cw\"}]}function Qe(n,t){let{t:e}=t,{refs:r,stashes:a,remotes:i}=n;return[...D(\"local\",e(\"group.local\"),r.local.map(c=>qe(c,t)),[{action:\"create\",title:e(\"branch.createTitle\"),icon:\"plus\"}]),...D(\"remote\",e(\"group.remote\"),r.remote.map(c=>ze(c,t)),[],r.remote.length>30),...D(\"tags\",e(\"group.tags\"),r.tags.map(c=>Ke(c,t)),[{action:\"createTag\",title:e(\"tag.createTitle\"),icon:\"plus\"}],!0),...D(\"stashes\",e(\"group.stashes\"),a.map(c=>Xe(c,t)),[{action:\"stash\",title:e(\"toolbar.stash\"),icon:\"plus\"}]),...D(\"remotes\",e(\"group.remotes\"),i.map(c=>Ye(c,t)),[],!0)]}function Ze(n,t){return{refresh:()=>n.refresh(),fetch:()=>t.fetch(),create:()=>t.createBranch(),createTag:()=>t.createTag(),stash:()=>t.stash(),checkout:e=>t.checkoutRef(e),checkoutRemote:e=>t.checkoutRef(e,!0),checkoutTag:e=>t.checkoutCommit(e),merge:e=>t.merge(e),rebase:e=>t.rebase(e),branchFrom:e=>t.createBranch(e),rename:e=>t.renameBranch(e),delete:e=>t.deleteBranch(e),showCommit:e=>t.showCommit(e),pushTag:e=>t.pushTag(e),deleteTag:e=>t.deleteTag(e),stashShow:e=>t.stashShow(e),stashApply:e=>t.stashApply(e),stashPop:e=>t.stashPop(e),stashDrop:e=>t.stashDrop(e)}}function he({ctx:n,repo:t,actions:e,t:r}){let a={ctx:n,t:r};function i(){let{state:o}=t;return o.loaded?o.isRepo?{title:r(\"view.branches\"),toolbar:Je(r),nodes:[...o.busy?[{type:\"progress\",label:o.busy}]:[],...Qe(o,a)]}:{title:r(\"view.branches\"),nodes:[{type:\"empty\",title:r(\"empty.noRepo\"),icon:\"git-branch\"}]}:{title:r(\"view.branches\"),nodes:[{type:\"progress\",label:r(\"busy.loading\")}]}}let c=Ze(t,e);async function d(o){let h=c[o.action];h&&await h(String(o.payload??\"\"))}return{render:i,onAction:d}}var me=[\"changes\",\"history\",\"branches\"],et=1e4,tt=12e4;function nt({ctx:n,repo:t,t:e}){let{state:r}=t;if(!r.isRepo){n.statusBar.set(\"branch\",null),n.statusBar.set(\"sync\",null);return}let{branch:a,staged:i,unstaged:c,untracked:d,conflicts:o}=r.status,h=i.length+c.length+d.length+o.length>0,l=a.head??a.oid?.slice(0,8)??e(\"branch.none\");if(n.statusBar.set(\"branch\",{text:`${l}${h?\"*\":\"\"}`,icon:\"git-branch\",tooltip:e(a.detached?\"status.detached\":\"status.branchTooltip\",{branch:l}),command:\"git.checkout\",tone:o.length?\"danger\":\"default\",priority:100}),!a.head){n.statusBar.set(\"sync\",null);return}if(!a.upstream){n.statusBar.set(\"sync\",{text:\"\",icon:\"cloud-upload\",tooltip:e(\"status.publishTooltip\"),command:\"git.push\",priority:99});return}n.statusBar.set(\"sync\",{text:`${a.behind}\\u2193 ${a.ahead}\\u2191`,icon:\"refresh-cw\",tooltip:e(\"status.syncTooltip\",{upstream:a.upstream,ahead:String(a.ahead),behind:String(a.behind)}),command:\"git.sync\",priority:99})}function rt({ctx:n,repo:t,views:e,touch:r}){for(let a of me)n.views.register(a,{render:()=>e[a].render(),onAction:i=>(r(),e[a].onAction(i)),onShow:()=>{r(),t.refreshStatus()}})}function ot({ctx:n,repo:t,actions:e,views:r,touch:a,session:i}){let c={\"git.refresh\":()=>t.refresh(),\"git.open-changes\":()=>n.ui.showView(\"changes\"),\"git.open-history\":()=>n.ui.showView(\"history\"),\"git.open-branches\":()=>n.ui.showView(\"branches\"),\"git.commit\":()=>e.commit(r.changes.currentDraft()),\"git.commit-amend\":()=>e.commit(r.changes.currentDraft(),{amend:!0}),\"git.stage-all\":()=>e.stageAll(),\"git.unstage-all\":()=>e.unstageAll(),\"git.discard-all\":()=>e.discardAll(),\"git.push\":()=>e.push(),\"git.force-push\":()=>e.push({force:!0}),\"git.pull\":()=>e.pull(),\"git.fetch\":()=>e.fetch(),\"git.sync\":()=>e.sync(),\"git.checkout\":()=>e.checkout(),\"git.create-branch\":()=>e.createBranch(),\"git.merge\":()=>e.merge(),\"git.rebase\":()=>e.rebase(),\"git.create-tag\":()=>e.createTag(),\"git.stash\":()=>e.stash(),\"git.stash-pop\":()=>e.stashPop(),\"git.init\":()=>e.init(),\"git.clone\":()=>e.clone(),\"git.file-history\":()=>e.fileHistory(i.activeFile),\"git.blame\":()=>e.blame(i.activeFile),\"git.open-terminal\":()=>n.ui.runInTerminal(\"git status\",{cwd:t.state.top??void 0,title:\"git\"})};for(let[d,o]of Object.entries(c))n.commands.register(d,()=>(a(),o()))}function at({ctx:n,repo:t,touch:e,session:r,refreshViews:a}){let i=()=>{r.saveTimer&&clearTimeout(r.saveTimer),r.saveTimer=setTimeout(()=>{t.refreshStatus()},400)};n.events.on(\"fileSaved\",i),n.events.on(\"activeFile\",c=>{r.activeFile=c.path}),n.events.on(\"windowFocus\",()=>{e(),t.refreshStatus()}),n.events.on(\"viewVisible\",c=>{c.extensionId===n.id&&(e(),t.refreshStatus())}),n.events.on(\"locale\",a),n.workspace.onDidChange(()=>{t.refresh()})}function fe({ctx:n,actions:t,session:e}){e.fetchTimer&&clearInterval(e.fetchTimer),e.fetchTimer=null;let r=Number(n.settings.get(\"autoFetchMinutes\"));!Number.isFinite(r)||r<=0||(e.fetchTimer=setInterval(()=>{t.fetch({quiet:!0})},Math.max(1,r)*6e4))}function rn(n){let t=E(n),e=x(n,t),r=J(n,e),a=le({ctx:n,repo:r,t}),i={ctx:n,repo:r,actions:a,t},c={changes:ue(i),history:de(i),branches:he(i)},d=Date.now(),o={activeFile:null,saveTimer:null,fetchTimer:null},h=()=>{d=Date.now()},l=()=>{for(let u of me)n.views.refresh(u);nt(i)};rt({ctx:n,repo:r,views:c,touch:h}),r.onChange(l),ot({ctx:n,repo:r,actions:a,views:c,touch:h,session:o}),at({ctx:n,repo:r,touch:h,session:o,refreshViews:l});let s=setInterval(()=>{Date.now()-d>tt||r.refreshStatus()},et);return n.settings.onDidChange(()=>{fe({ctx:n,actions:a,session:o}),r.refresh()}),fe({ctx:n,actions:a,session:o}),r.refresh(),()=>{clearInterval(s),o.fetchTimer&&clearInterval(o.fetchTimer),o.saveTimer&&clearTimeout(o.saveTimer)}}export{rn as activate};\n"
  },
  "addon": {
    "schema": 1,
    "languages": [],
    "themes": [],
    "commands": [],
    "events": [],
    "templates": [],
    "projectKinds": [],
    "snippets": [],
    "id": "ext.git",
    "name": "Git",
    "version": "1.1.3",
    "description": "Source control with Git: stage and commit changes, diffs, history, branches, tags, stashes, push/pull and the branch in the status bar. Ships with program code.",
    "author": "Lumen",
    "icon": "Gt",
    "color": "#f05033",
    "category": "tool"
  }
}
