@sourcegraph/code-host-integration 0.0.80 → 0.0.81

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/code-host-integration",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -127,7 +127,7 @@
127
127
  alwaysNil
128
128
  }
129
129
  }
130
- `,variables:{...e,source:la.CODEHOSTINTEGRATION,argument:e.argument&&JSON.stringify(e.argument),publicArgument:e.publicArgument&&JSON.stringify(e.publicArgument)},mightContainPrivateInfo:!1}).subscribe({error:e=>{}})})({name:e,userCookieID:await this.getAnonUserID(),url:this.sourcegraphURL,argument:{platform:this.platform,version:this.version,...t},publicArgument:{platform:this.platform,version:this.version,...n}},this.requestGraphQL)}async log(e,t,n){await this.logEvent(e,t,n)}async logViewEvent(e,t){await this.logEvent(`View${e}`,t)}async logPageView(e,t,n){await this.logEvent(`${e}Viewed`,t,n)}}const hp={allowErrorReporting:!1,sendTelemetry:!0,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},mp=({get:e,set:t})=>({set:t,enable:e=>t(e,!0),disable:e=>t(e,!1),async isEnabled(t){const n=await e(t);return"boolean"==typeof n?n:hp[t]},async toggle(n){const r=await e(n);return await t(n,!r),!r}});const gp=mp({get:async function(e){const{featureFlags:t={}}=await vf.sync.get();return t[e]},set:async function(e,t){const{featureFlags:n}=await vf.sync.get("featureFlags");await vf.sync.set({featureFlags:{...n,[e]:t}})}}),bp=mp({get:async e=>{const t=localStorage.getItem(e);return null===t?void 0:"true"===t},set:async(e,t)=>{localStorage.setItem(e,String(t))}}),vp=cf?bp:gp,yp={sendTelemetry:!1,allowErrorReporting:!1,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},wp=e=>({...yp,...e}),Ep=()=>(lf?yf("sync","featureFlags"):q(void 0)).pipe($(wp));function _p(e){return Ep().pipe($((t=>t[e])),We())}const xp=e=>hf(e).pipe($((t=>!(pf()&&e)||!bf(t)))),Sp=e=>Ce([xp(e),_p("sendTelemetry")]).pipe($((([e,t])=>!!e||t)));function Cp(){const{host:e,pathname:t}=location,[n,r]=t.slice(1).split("/");if(!n||!r)throw new Uf(`Could not parse repoName from Bitbucket Cloud url: ${location.href}`);return`${e}/${n}/${r}`}const Op={getCodeElementFromTarget:e=>e.closest(".view-line > span"),getLineNumberFromCodeElement:e=>{if(!document.querySelector(".line-number"))throw new Error("No line number elements found on the currently viewed page");const t=e.closest(".react-monaco-editor-container");if(!t)throw new Error("No editor found");const n=e.closest(".view-line"),r=[...t.querySelectorAll(".view-line")].findIndex((e=>e===n)),o=t.querySelectorAll(".line-number")[r];if(o){let e=parseInt(o.dataset.lineNum??"",10);if(!isNaN(e))return e;if(e=parseInt(o.textContent?.trim()??"",10),!isNaN(e))return e}throw new Error("Could not find line number")},getLineElementFromLineNumber:Np,getCodeElementFromLineNumber:(e,t)=>{const n=Np(e,t);if(!n)return null;const r=n.querySelector(":scope > span");return r||console.error(`Could not find code element inside .view-line container for line #${t}`),r}};function Np(e,t){let n=e.querySelector(`[data-line-num="${t}"]`);if(!n)for(const r of e.querySelectorAll(".line-number")){if(parseInt(r.textContent??"",10)===t){n=r;break}}if(!n)return console.error(`Could not find line number element for line #${t}`),null;const r=[...e.querySelectorAll(".line-number")].findIndex((e=>e===n)),o=e.querySelectorAll(".view-line")[r];return o||console.error(`Could not find line element for line #${t}`),o}function kp(e,t,n){const r=e.querySelector(`[aria-label="${"base"===n?"From":"To"} line ${t}"]`)?.closest(".line-wrapper")?.querySelector(".code-component");if(!r)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return r}const Tp={getCodeElementFromTarget:e=>e.closest(".code-diff"),getLineNumberFromCodeElement:e=>{const t=e.closest(".line-wrapper")?.querySelectorAll(".line-number-permalink");if(!t||0===t.length)throw new Error("Could not find line number permalink(s) for code element");const n=t[t.length-1],r=parseInt(n.textContent??"",10);if(!isNaN(r))return r;throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:kp,getCodeElementFromLineNumber:(e,t,n)=>kp(e,t,n)?.querySelector(".code-diff"),getDiffCodePart:e=>{const t=e.closest(".code-component")?.querySelector(".line-type");if(t?.textContent?.includes("+"))return"head";if(t?.textContent?.includes("+"))return"base";if(!e.closest(".side-by-side"))return"head";const n=e.closest(".line-wrapper");if(n?.id)return n?.id.includes("oldline")?"base":"head";return 0===[...n?.parentElement?.childNodes||[]].findIndex((e=>e===n))?"base":"head"},isFirstCharacterDiffIndicator:()=>!1};function Ap(e,t,n){const r=e.querySelector(`[data-${"base"===n?"f":"t"}num="${t}"]`)?.closest(".udiff-line");if(!r)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return r}const Ip={getCodeElementFromTarget:e=>e.closest(".source"),getLineNumberFromCodeElement:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element");const n=t.querySelector(".line-numbers");if(!n)throw new Error("Could not find line numbers element");const r=n?.dataset.tnum;if(r){const e=parseInt(r,10);if(!isNaN(e))return e}const o=n?.dataset.fnum;if(o){const e=parseInt(o,10);if(!isNaN(e))return e}throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:Ap,getCodeElementFromLineNumber:(e,t,n)=>Ap(e,t,n)?.querySelector(".source"),getDiffCodePart:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element for code element");return t.classList.contains("deletion")?"base":"head"},isFirstCharacterDiffIndicator:()=>!0},Rp=e=>e.replace("//","/"),Pp=["modified","renamed","removed","added"];function Dp(){const e=Cp(),t=location.pathname.match(/src\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]);return{blob:{rawRepoName:e,revision:n,filePath:decodeURIComponent(t[2]),commitID:function(){const e=['a[type="button"]',"a"];for(const t of e){const e=document.querySelectorAll(t);for(const t of e){const e=t.href.match(/full-commit\/([\da-f]{40})\//);if(e)return e[1]}}return null}()??n}}}function Lp(e){const t=Cp(),n=function(e){const t=[...e.querySelectorAll('[data-qa="bk-file__header"] span')];for(const e of t)for(const t of Pp)if(e.textContent?.toLowerCase().includes(t))return t;return"modified"}(e),{base:r,head:o}=function(e,t){const n=e.querySelector('[data-qa="bk-filepath"]')?.cloneNode(!0),r=n?.textContent;if(!(n instanceof HTMLElement&&r))throw new Error("Could not find breadcrumbs component for code view");if("added"===t)return{head:r};if("removed"===t)return{base:r};if("modified"===t)return{base:r,head:r};const o="<>SEPARATOR<>",i=n.querySelectorAll('[aria-label="arrow"]');for(const e of i)e.textContent=o;const[s,a,l]=n.textContent.split(/[{}]/),[c,u]=a.split(o);return{base:Rp(s+c+l),head:Rp(s+u+l)}}(e,n),{baseRevision:i,headRevision:s}=function(){const e=document.querySelector('[data-qa="pr-branches-and-state-styles"]');if(!e)throw new Error("Could not find branches element");const t=[...e.querySelectorAll('[aria-hidden="true"]')];if(2!==t.length)throw new Error("Expected source and destination branch elements");const n=t[0].textContent??"";return{baseRevision:t[1].textContent??"",headRevision:n}}();return"added"===n?{head:{rawRepoName:t,filePath:o,commitID:s,revision:s}}:"removed"===n?{base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}:{head:{rawRepoName:t,filePath:o,commitID:s,revision:s},base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}}function Mp(e){const t=Cp(),n=function(e){const t=e.querySelector(".diff-entry-lozenge");for(const e of Pp)if(t?.textContent?.toLowerCase().includes(e))return e;return"modified"}(e),{head:r,base:o}=function(e,t){const n=e.querySelector(".filename")?.cloneNode(!0);if(!n)throw new Error("Could not find breadcrumbs component for code view");for(const e of n.childNodes)e instanceof HTMLSpanElement&&(e.textContent=null);const r=n.textContent.trim();if("added"===t)return{head:r};if("removed"===t)return{base:r};if("modified"===t)return{base:r,head:r};const[o,i,s]=r.split(/[{}]/).map((e=>e.trim())),[a,l]=i.split("\u2192").map((e=>e.trim()));return{base:Rp(o+a+s),head:Rp(o+l+s)}}(e,n),{baseCommitID:i,headCommitID:s}=function(){const e=document.querySelector('[title="Parent commit"]')?.href.match(/\/commits\/(.*)/);if(!e)throw new Error("Could not determine base commit ID");const t=e[1],n=window.location.href.match(/\/commits\/(.*)/);if(!n)throw new Error("Could not determine head commit ID");return{baseCommitID:t,headCommitID:n[1]}}();return"added"===n?{head:{rawRepoName:t,filePath:r,commitID:s}}:"removed"===n?{base:{rawRepoName:t,filePath:o,commitID:i}}:{head:{rawRepoName:t,filePath:r,commitID:s},base:{rawRepoName:t,filePath:o,commitID:i}}}const jp="codeHost-module__icon_3KtzB",Fp="codeHost-module__commit-container_8Jft-";function Up(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector('[data-testid="file-actions"');if(!n)throw new Error("Unable to find mount location");const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}function Bp(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector(".diff-actions");if(!n)throw new Error("Unable to find mount location");n.classList.add(Fp);const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}const qp={type:"bitbucket-cloud",name:"Bitbucket Cloud",codeViewResolvers:[{selector:e=>{const t=e.querySelector('[data-qa="bk-file__header"]'),n=e.querySelector('[data-qa="bk-file__content"]');if(!t||!n)return null;let r=t;for(;!r.contains(n);){if(!r.parentElement)return null;r=r.parentElement}return[r]},resolveView:e=>function({pathname:e}){return/\/pull-requests\/\d+/.test(e)}(window.location)?{element:e,getToolbarMount:Up,dom:Tp,resolveFileInfo:Lp}:{element:e,getToolbarMount:Up,dom:Op,resolveFileInfo:Dp}},{selector:".bb-udiff",resolveView:e=>({element:e,getToolbarMount:Bp,dom:Ip,resolveFileInfo:Mp})}],getContext:async function(){const e=Cp();return Promise.resolve({rawRepoName:e,revision:"",privateRepository:!1})},getViewContextOnSourcegraphMount:function(e){const t="open-on-sourcegraph",n=fe(e,'[data-qa="page-header-wrapper"] > div > div');if(!n)return null;let r=n.querySelector("#open-on-sourcegraph");if(r)return r;r=document.createElement("span"),r.id=t;const o=n.childNodes[1]?.childNodes[1].firstChild;return o instanceof HTMLElement?o.append(r):n.append(r),r},check:function(){return"bitbucket.org"===location.hostname},viewOnSourcegraphButtonClassProps:{className:"codeHost-module__open-on-sourcegraph_10lR9",iconClassName:jp},codeViewToolbarClassProps:{className:"codeHost-module__code-view-toolbar_N0wZ1",listItemClass:"codeHost-module__list-item_370zl",actionItemClass:"codeHost-module__code-view-toolbar-action-item_2p6Pr",actionItemPressedClass:"codeHost-module__pressed_1ksxF",actionItemIconClass:jp},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_2e1lQ",closeButtonClassName:"codeHost-module__close_2lJ85",badgeClassName:"codeHost-module__badge_16Tsk",actionItemClassName:"codeHost-module__hover-overlay-action-item_39z-G",iconClassName:jp,contentClassName:"codeHost-module__content_eSBN7"},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},codeViewsRequireTokenization:!0,observeLineSelection:Ae(window,"hashchange").pipe(ae(void 0),$((()=>(e=>{if(e.startsWith("#")&&(e=e.slice(1)),!/^lines-\d+(:\d+)?$/.test(e))return{};const t={},[n,r]=e.slice("lines-".length).split(":");return t.line=parseInt(n,10),r&&(t.endLine=parseInt(r,10)),t})(window.location.hash))))},$p=(e,t)=>n=>s()(e[n],t),zp=/\/projects\/([^/]+)\/repos\/([^/]+)\//;const Vp=(e,t)=>{const n=e.querySelector(`[data-line-number="${t}"]`);if(!n)throw new Error(`Line ${t} not found in code view`);const r=n.closest(".line");if(!r)throw new Error("Could not find line elem for line element");return r},Hp={getCodeElementFromTarget:e=>{const t=e.closest(".CodeMirror-line");return t?t.querySelector('span[role="presentation"]'):null},getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-locator");if(!n)throw new Error("Could not find the line number in a line container");const r=parseInt(n.dataset.lineNumber||"",10);if(isNaN(r))throw new TypeError("data-line-number not set on line number element");return r},getLineElementFromLineNumber:Vp,getCodeElementFromLineNumber:(e,t)=>Vp(e,t).querySelector('.CodeMirror-line span[role="presentation"]')},Gp=(e,t,n)=>{for(const r of e.querySelectorAll(".line-number-"+("head"===n?"to":"from"))){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e)&&e===t){const e=r.closest(".line");if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},Wp={getCodeElementFromTarget:Hp.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-number-to");if(n){const e=parseInt((n.textContent||"").trim(),10);if(!isNaN(e))return e}const r=t.querySelector(".line-number-from");if(r){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getLineElementFromLineNumber:Gp,getCodeElementFromLineNumber:(e,t,n)=>Gp(e,t,n).querySelector('.CodeMirror-line span[role="presentation"]'),getDiffCodePart:e=>{if(!document.querySelector(".side-by-side-diff"))return e.closest(".line").classList.contains("removed")?"base":"head";return e.closest(".diff-editor").previousElementSibling?.classList.contains("segment-connector-column")?"head":"base"},isFirstCharacterDiffIndicator:()=>!1},Qp=(e,t,n)=>{for(const r of e.querySelectorAll(".diff-line-number")){const e=r.textContent?.trim().split(" ")[0];if(!e)continue;const o=parseInt(e,10);if(!isNaN(o)&&o===t){const e=r.closest("tr")?.querySelector(`.diff-line[data-diff-line="${"head"===n?"TO":"FROM"}"]`);if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},Kp={getCodeElementFromTarget:e=>e.closest(".diff-line"),getLineNumberFromCodeElement:e=>{const t=e.closest("tr")?.querySelector(".diff-gutter .diff-line-number");if(t){const e=parseInt((t.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getDiffCodePart:e=>{const t=e.closest("tr")?.querySelectorAll(".diff-line");if(!t||0===t.length)throw new Error("Could not find diff lines for code element");if(1===t.length)return e.classList.contains("added-line")?"head":"base";const[n,r]=t;return e===n?"base":e===r?"head":e.classList.contains("removed-line")?"base":"head"},getLineElementFromLineNumber:Qp,getCodeElementFromLineNumber:Qp};var Zp=o(11570),Yp=o.n(Zp);const Jp=(e,t,n)=>`${window.AJS?window.AJS.contextPath():window.location.origin}/rest/api/1.0/projects/${encodeURIComponent(e)}/repos/${t}${n}`,Xp=e=>sr(e,{selector:e=>ur(e).json()}),ed=gs((({project:e,repoSlug:t,prID:n})=>Xp(Jp(e,t,`/pull-requests/${n}`)).pipe($((({fromRef:e,toRef:t})=>({baseCommitID:t.latestCommit,headCommitID:e.latestCommit}))))),(({prID:e})=>e.toString())),td=gs((({project:e,repoSlug:t,commitID:n})=>Xp(Jp(e,t,`/commits/${n}`)).pipe($((({parents:e})=>Yp()(e))),qe(Qn),$((({id:e})=>e)))),(({project:e,repoSlug:t,commitID:n})=>`${e}:${t}:${n}`)),nd=["a.raw-view-link","a.source-view-link","a.mode-source"],rd=({repoSlug:e,project:t})=>[window.location.hostname,t,e].join("/"),od=e=>{const t=[];for(const n of nd)try{const t=e.querySelector(n);if(!t)throw new Error(`Could not find selector ${n} in code view`);const r=new URL(t.href),o=r.pathname,i=o.match(/\/projects\/(.*?)\/repos\/(.*?)\/(?:browse|raw)\/(.*)$/);if(!i)throw new Error(`Path of link matching selector ${n} did not match path regex: ${o}`);const[,s,a,l]=i,c=r.searchParams.get("at");if(!c)throw new Error(`href of link matching selector ${n} did not have 'at' search param: ${r.href}`);const u=c.match(/refs\/heads\/(.*?)$/),f=u?u[1]:c;return{rawRepoName:rd({repoSlug:a,project:s}),filePath:decodeURIComponent(l),revision:f,project:s,repoSlug:a}}catch(e){t.push(e);continue}throw cn(t)},id=(e="a.commitid")=>{const t=document.querySelector(e);if(!t)throw new Error("No element found matching a.commitid");const n=t.dataset.commitid;if(!n)throw new Error("Element matching a.commitid has no data-commitid");return n},sd=e=>{const{rawRepoName:t,filePath:n,revision:r,project:o,repoSlug:i}=od(e);return{rawRepoName:t,filePath:n,revision:r,commitID:(()=>{const e=document.querySelector("span[data-revision-ref]");if(!e)throw new Error("Could not find span[data-revision-ref] element");try{const{latestCommit:t}=JSON.parse(e.dataset.revisionRef);return t}catch{throw new Error("Could not parse JSON from revision selector")}})(),project:o,repoSlug:i}},ad=({codeViewElement:e})=>e.querySelector(".change-type-lozenge"),ld=({changeTypeElement:e})=>{if(!e)return"MODIFY";const t=[...e.classList].find((e=>/^change-type-[A-Z]+/.test(e)));if(!t)throw new Error("Could not detect change type from change type element");return t.replace(/^change-type-/,"")},cd=({filePath:e,changeType:t,changeTypeElement:n})=>{if("ADD"!==t){if("MODIFY"===t||"DELETE"===t)return e;if("MOVE"===t||"RENAME"===t||"COPY"===t){if(!n)throw new Error(`Change type is ${t} but no change type indicator found`);const r=n.getAttribute("original-title");if(!r)throw new Error("Moved change type badge did not have original-title attribute");const o=document.createElement("span");o.innerHTML=r;const i=o.textContent;if("MOVE"===t||"COPY"===t){const e=i.split("\u2192")[0].trim();if(!e)throw new Error(`Unexpected move change type badge content "${i}"`);return e}if("RENAME"===t){const t=/Renamed from '(.+)'/,n=i.match(t);if(!n)throw new Error(`Rename change type badge content did not match ${t.toString()}: "${i}"`);return Il.join(Il.dirname(e),n[1])}}throw new Error(`Unexpected change type "${t}"`)}},ud=e=>{const t=e.querySelector(".breadcrumbs")??e.querySelector(".file-breadcrumbs");if(!t)throw new Error("Could not find diff code view breadcrumbs element through selector .breadcrumbs");const n=t.textContent;if(!n)throw new Error("Unexpected empty file path in breadcrumbs");const r=location.pathname.match(/\/projects\/(.*?)\/repos\/(.*?)\//);if(!r)throw new Error("Location did not match regexp");const[,o,i]=r,s=rd({project:o,repoSlug:i}),a=ad({codeViewElement:e}),l=ld({changeTypeElement:a});return{changeType:l,rawRepoName:s,filePath:n,baseFilePath:cd({changeTypeElement:a,changeType:l,filePath:n})||n,project:o,repoSlug:i}};const fd=e=>{const t=ud(e),{rawRepoName:n,filePath:r,baseFilePath:o}=t,i=function(){const e=window.location.pathname.match(/pull-requests\/(\d*?)\/(diff|overview|commits)/);if(!e)throw new Error(`Could not parse PR ID from pathname: ${window.location.pathname}`);return parseInt(e[1],10)}();return ed({...t,prID:i}).pipe($((({headCommitID:e,baseCommitID:t})=>({head:{rawRepoName:n,filePath:r,commitID:e},base:{rawRepoName:n,filePath:o,commitID:t}}))))},pd="codeHost-module__command-palette-button_1LPsz",dd="codeHost-module__command-palette-popover_wqnFp",hd="codeHost-module__no-results_3Di26",md="codeHost-module__open-on-sourcegraph_i9J2G",gd="codeHost-module__sg-toolbar-mount_2Fbz5",bd="codeHost-module__code-view-toolbar_IVqgq",vd="codeHost-module__action-nav-item_223JV",yd="codeHost-module__action-nav-item-new-diff_23eTl",wd="codeHost-module__action-item-new-diff_3Tuv4",Ed="codeHost-module__hover-action-item_9CC-W",_d="codeHost-module__command-list-popover-button_3eptU",xd=(e,t=".file-toolbar .secondary")=>{const n=e.querySelector(".sg-toolbar-mount");if(n)return n;const r=e.querySelector(t);if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("btn-group"),o.classList.add("sg-toolbar-mount"),o.classList.add(gd),r.prepend(o),o},Sd=e=>({direction:t,codeView:n,position:r})=>{const o=e.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");let i=0;for(const e of o.querySelectorAll("[cm-text]")){const t=e.getAttribute("cm-text")||"",n=e.textContent||"";i+=t.length-n.length}const s=t===jn.ActualToCodeView?-1:1;return q({line:r.line,character:r.character+s*i})},Cd={getToolbarMount:xd,dom:Hp,resolveFileInfo:e=>({blob:sd(e)}),getPositionAdjuster:()=>Sd(Hp)},Od={getToolbarMount:xd,dom:Wp,getPositionAdjuster:()=>Sd(Wp),overrideTokenize:!0},Nd={...Od,resolveFileInfo:e=>{const{changeType:t,rawRepoName:n,filePath:r,commitID:o,baseFilePath:i,revision:s,...a}=(e=>{const{rawRepoName:t,project:n,repoSlug:r,filePath:o}=od(e),i=id(),s=ad({codeViewElement:e}),a=ld({changeTypeElement:s});return{changeType:a,rawRepoName:t,filePath:o,baseFilePath:cd({changeTypeElement:s,changeType:a,filePath:o})||o,commitID:i,project:n,repoSlug:r}})(e);return"ADD"===t?q({head:{rawRepoName:n,filePath:r,commitID:o}}):td({commitID:o,...a}).pipe($((e=>"DELETE"===t?{base:{rawRepoName:n,filePath:i,commitID:e}}:{base:{rawRepoName:n,filePath:i,commitID:e},head:{rawRepoName:n,filePath:r,commitID:o}})))}},kd={...Od,resolveFileInfo:fd},Td={...Od,resolveFileInfo:e=>{const{rawRepoName:t,filePath:n,baseFilePath:r}=ud(e),{baseCommitID:o,headCommitID:i}=function(){const e=document.querySelector("#branch-compare .source-selector a.commitid[data-commitid]"),t=document.querySelector("#branch-compare .target-selector a.commitid[data-commitid]");if(!e||!t)throw new Error("Could not resolve Bitbucket compare diff spec");return{headCommitID:e.getAttribute("data-commitid"),baseCommitID:t.getAttribute("data-commitid")}}();return{base:{rawRepoName:t,filePath:r,commitID:i},head:{rawRepoName:t,filePath:n,commitID:o}}}},Ad={...Od,resolveFileInfo:e=>(e=>{const t=id(".commit-badge-oneline .commitid"),n=id(".commit-parents .commitid"),{rawRepoName:r,filePath:o,baseFilePath:i}=ud(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}})(e)},Id={selector:".change-view",resolveView:e=>({element:e,...Rd})},Rd={resolveFileInfo:fd,getToolbarMount:e=>xd(e,".change-header .diff-actions"),toolbarButtonProps:{listItemClass:yd,actionItemClass:wd},dom:Kp};const Pd="aui-icon",Dd={[gc]:"aui-message aui-message-info",[bc]:"aui-message aui-message-success",[mc]:"aui-message aui-message-info",[hc]:"aui-message aui-message-warning",[dc]:"aui-message aui-message-error"},Ld={type:"bitbucket-server",name:"Bitbucket Server",check:()=>!!document.querySelector(".bitbucket-header-logo")||!!document.querySelector(".aui-header-logo.aui-header-logo-bitbucket"),codeViewResolvers:[{selector:".file-content",resolveView:e=>{const t=e.querySelector(".content-view");if(!t)return null;if(document.querySelector("#branch-compare"))return{element:e,...Td};if((({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/commits\/\w+$/.test(e))(window.location))return{element:e,...Ad};if(e.querySelector(".mode-toggle")){return t.classList.contains("diff-view")?{element:e,...Nd}:{element:e,...Cd}}return(({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/pull-requests\/\d+/.test(e))(window.location)?{element:e,...kd}:(console.error("Unknown code view",e),null)}},Id],getCommandPaletteMount:e=>{const t=fe(e,".aui-header-primary .aui-nav");if(!t)return null;const n=["command-palette-button",pd];return t.querySelector(n.map((e=>`.${e}`)).join(""))||(()=>{const e=document.createElement("li");return e.className=n.join(" "),t.append(e),e})()},notificationClassNames:Dd,commandPaletteClassProps:{buttonClassName:s()(_d,"aui-alignment-target aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),buttonElement:"a",buttonOpenClassName:"aui-dropdown2-active active aui-alignment-enabled",showCaret:!1,popoverClassName:s()(dd,"aui-dropdown2 aui-style-default aui-layer aui-dropdown2-in-header aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-enabled aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),popoverInnerClassName:"aui-dropdown2-section",formClassName:"aui",inputClassName:"text",resultsContainerClassName:"results",listClassName:"results-list",listItemClassName:"result",selectedListItemClassName:"focused",noResultsClassName:hd,iconClassName:Pd},codeViewToolbarClassProps:{className:s()(bd,"aui-buttons"),actionItemClass:"aui-button",actionItemIconClass:"aui-icon",listItemClass:vd},hoverOverlayClassProps:{className:"aui-dialog",actionItemClassName:s()("aui-button",Ed),getAlertClassName:$p(Dd),iconClassName:Pd},getViewContextOnSourcegraphMount:function(e){const t=fe(e,".branch-selector-toolbar .aui-buttons");if(!t)return null;const n=t.querySelector("#open-on-sourcegraph");if(n)return n;const r=document.createElement("span");return r.id="open-on-sourcegraph",r.className=md,t.append(r),r},getContext:async function(){const e=function(e){const{hostname:t,pathname:n}=e,r=n.match(zp);if(!r)throw new Error(`location pathname does not match path regex: ${n}`);const[,o,i]=r;return{rawRepoName:`${t}/${o}/${i}`}}(window.location);let t={};try{t=function(){const e=document.querySelector("#repository-layout-revision-selector .name[data-revision-ref]");if(!e)throw new Error("branchNameElement not found");const t=e.getAttribute("data-revision-ref");let n=null;if(t)try{n=JSON.parse(t)}catch{throw new Error(`Could not parse revisionRefStr: ${t}`)}if(n?.latestCommit)return{revision:n.latestCommit};throw new Error(`revisionRefInfo is empty or has no latestCommit (revisionRefStr: ${String(t)})`)}()}catch{}return Promise.resolve({...e,...t,privateRepository:"bitbucket.org"!==window.location.hostname})},viewOnSourcegraphButtonClassProps:{className:"aui-button",iconClassName:Pd},codeViewsRequireTokenization:!1,observeLineSelection:Ae(window,"hashchange").pipe(ae(void 0),$((()=>(e=>{if(e.startsWith("#")&&(e=e.slice(1)),!/^\d+(-\d+)?$/.test(e))return{};const t={},[n,r]=e.split("-");return t.line=parseInt(n,10),r&&(t.endLine=parseInt(r,10)),t})(window.location.hash))))};var Md=o(65291),jd=o.n(Md),Fd=o(92674),Ud=o.n(Fd),Bd=o(26416),qd=o.n(Bd);function $d(e){return new M((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?Y(n):Te()).subscribe(t)}))}function zd(e){return t=>$d((()=>{const n=new Map;return t.pipe(wt(Me),ie(),tt((({removedNodes:e})=>{for(const t of e){if(!(t instanceof HTMLElement))continue;const e=n.get(t);if(e)e.subscriptions.unsubscribe(),n.delete(t);else for(const[e,r]of n.entries())t.contains(e)&&(r.subscriptions.unsubscribe(),n.delete(e))}})),te((t=>Y(t.addedNodes).pipe(qe(Wn(HTMLElement)),te((t=>Y(e).pipe(te((({selector:e,resolveView:n})=>[...Vd(t,e)].map((e=>{const t=n(e);return t&&{...t,subscriptions:new g}})))),qe(Qn),qe((e=>!n.has(e.element))),tt((e=>{n.set(e.element,e)})))))))))}))}function Vd(e,t){if("string"==typeof t)return ue(e,t);return t(e)||[]}const Hd=/patchset (\d+)/i;function Gd(e,t){return`refs/changes/${e.slice(-2).padStart(2,"0")}/${e}/${t}`}function Wd(e){return rh(document.body,e)?.textContent??void 0}function Qd(e){const t=Hd.exec(e);if(t?.[1])return t[1]}function Kd(){const e=new URL(window.location.href).pathname.split("/"),t=e.indexOf("c"),n=e.indexOf("+"),r=e.slice(t+1,n).join("/"),o=e[n+1],i=e[n+2],s=e.slice(n+3).join("/"),a=window.location.hostname+"/"+r,{basePatchsetId:l,headPatchsetId:c}=function(){const e=Wd("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #basePatchDropdown >> #triggerText")??Wd("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #basePatchDropdown >> #triggerText"),t=Wd("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #patchNumDropdown >> #triggerText")??Wd("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #patchNumDropdown >> #triggerText");return{basePatchsetId:e&&Qd(e),headPatchsetId:t&&Qd(t)}}();return{repoName:a,changeId:o,patchsetId:c||i,filePath:s,basePatchsetId:l}}const Zd={selector(e){if(e.matches("#diffTable"))return[e];const t=rh(document,"#app >> #app-element >> gr-change-view >> #fileList")?.shadowRoot?.querySelectorAll(".file-row.expanded"),n=[...t||[]].map((e=>{const t=e.parentElement;if(t)return rh(t,"gr-diff-host >> gr-diff >> #diffTable")}));return qd()(n)},resolveView(e){const t=oh(e,".stickyArea");if(!t)return null;const n=t.querySelector(".file-row")?.getAttribute("data-path");if(!n)return null;const r=Kd();if(!r.patchsetId)return console.error("Sourcegraph: Cannot get Gerrit patchset ID"),null;const o=Gd(r.changeId,r.patchsetId);let i;return i=r.basePatchsetId?Gd(r.changeId,r.basePatchsetId):function(){const e=rh(document.body,"#app >> #app-element >> gr-change-view >> #metadata >> gr-commit-info");if(!e)return null;return e?.shadowRoot?.querySelector(".container")?.textContent?.trim()}()||o+"^",sh(e),{element:e,dom:Jd,resolveFileInfo(){const e={base:{filePath:n||"",rawRepoName:r.repoName,commitID:i},head:{filePath:n||"",rawRepoName:r.repoName,commitID:o}};return console.log("resolveFileListCodeView: fileInfo",e),e}}}},Yd=(e,t,n)=>{const r="head"===n?"right":"left",o=e.querySelector(`td.lineNum.${r}[data-value="${t}"]`);if(!o)return null;const i=function(e,t){const n=[...e.parentElement?.childNodes||[]],r=n.slice(n.indexOf(e)+1);for(const e of r)if(e instanceof HTMLElement&&e.matches(t))return e;return null}(o,"td.content")?.querySelector(".contentText");return i},Jd={getLineElementFromLineNumber:Yd,getCodeElementFromLineNumber:Yd,getCodeElementFromTarget:e=>{const t=e.closest("td.content"),n=t?.closest("tr")?.querySelector("[data-line-number]");if(n){if("FILE"===n.getAttribute("data-line-number"))return null}return t},getLineNumberFromCodeElement:e=>{const t=nh(e);if(!t)throw console.error(e),new TypeError("Could not find line number (no side)");const n=e.closest("td")?.parentElement?.querySelector(`.lineNum.${t}`),r=n?.getAttribute("data-value");if(!r)throw new TypeError(`Could not find line number (${t})`);return parseInt(r,10)},getDiffCodePart:e=>{const t=nh(e);return"left"===t?"base":"right"===t?"head":(console.error("Cannot tell: base or head"),"base")}},Xd=[{selector(e){const t=rh(document.body,"#app >> #app-element >> gr-diff-view >> #diffHost >> #diff >> #diffTable");return t?[t]:[]},resolveView(e){const t=Kd();if(!t.patchsetId)return console.error("Sourcegraph: cannot find patchset ID"),null;const n=Gd(t.changeId,t.patchsetId);let r=n+"^";return t.basePatchsetId&&(r=Gd(t.changeId,t.basePatchsetId)),sh(e),{element:e,dom:Jd,getToolbarMount(e){const t=function(e){const t=oh(e,"gr-diff-view")?.shadowRoot?.querySelector("gr-fixed-panel .subHeader");return t}(e)?.querySelector(".patchRangeLeft");if(!t)throw new Error("Could not find subheader");const n=t.querySelector(".sourcegraph-toolbar-mount");if(n)return n;const r=document.createElement("div");return r.classList.add("sourcegraph-toolbar-mount"),t.append(r),t.append(ih(ah)),r},resolveFileInfo(){const e={base:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:r},head:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:n}};return console.log("resolveFilePageCodeView: fileInfo",e),e}}}},Zd],eh={type:"gerrit",name:"Gerrit",codeViewResolvers:Xd,contentViewResolvers:[],nativeTooltipResolvers:[],codeViewsRequireTokenization:!0,observeMutations:(e,t,n)=>{let r=[];return Tf(1500).pipe($((()=>{const{filePath:e=""}=Kd(),t=[...Xd.map((e=>e.selector)),th].map((e=>[...Vd(document.body,e)])).flat(),n=t.filter((t=>!Ud()(r,{element:t,filePath:e}))),o=r.filter((n=>!(n.filePath===e&&t.find((e=>e===n.element)))));for(const t of n)r.push({element:t,filePath:e});return r=r.filter((e=>!Ud()(o,e))),{addedNodes:n,removedNodes:o.map((e=>e.element))}})),qe((({addedNodes:e,removedNodes:t})=>!!e.length||!!t.length)),$((e=>[e])),hs(),jt())},getContext:async()=>{const{repoName:e,changeId:t,patchsetId:n}=Kd();return Promise.resolve({privateRepository:!0,rawRepoName:e,revision:n&&Gd(t,n)})},check:function(){return!!document.querySelector("gr-app#app")},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_1jwSd"},codeViewToolbarClassProps:{className:"code-view-toolbar--gerrit",actionItemIconClass:"icon--gerrit"},viewOnSourcegraphButtonClassProps:{className:"open-on-sourcegraph--gerrit",iconClassName:"open-on-sourcegraph-icon--gerrit"},getViewContextOnSourcegraphMount:e=>{const t=jd()(th(e));if(!t)return null;const n=t.querySelector(".open-in-sourcegraph-mount");if(n)return n;const r=document.createElement("gr-button");return r.setAttribute("link","link"),r.classList.add("open-in-sourcegraph-mount"),t.prepend(r),t.append(ih(ah)),r}},th=()=>{const e=rh(document.body,"#app >> #app-element >> gr-change-view >> #actions >> #secondaryActions");return e?[e]:null};function nh(e){if("unified"===function(e){return e.closest("tr")?.matches(".unified")?"unified":"side-by-side"}(e)){const t=e.closest("tr")?.querySelector("td.right")?.getAttribute("data-value");return t?"right":"left"}return e.closest("td")?.previousElementSibling?.matches(".right")?"right":"left"}function rh(e,t){"string"==typeof t&&(t=t.split(">>"));let n=e;const r=t.slice(0,-1),o=t[t.length-1];for(const e of r){if(!n)return null;n=n.querySelector(e)?.shadowRoot||null}return n?.querySelector(o)}function oh(e,t){for(;;){const n=e.closest(t);if(n)return n;if(e=e.getRootNode()?.host,!e||e===document.getRootNode())return null}}function ih(e){const t=document.createElement("style");return t.textContent=e,t}function sh(e){if(!e.querySelector("style.sourcegraph-injected-style")){const t=ih(lh);t.classList.add("sourcegraph-injected-style"),e.append(t)}}const ah="\n.icon--gerrit {\n height: 1.3rem;\n width: 1.3rem;\n padding: 5px 4px;\n}\n.open-on-sourcegraph-icon--gerrit {\n height: 1rem;\n width: 1rem;\n}\n.open-on-sourcegraph--gerrit {\n text-decoration: none;\n}\n",lh="\n.sourcegraph-document-highlight {\n background-color: var(--secondary);\n}\n.selection-highlight {\n background-color: var(--mark-bg);\n}\n";var ch=o(36021),uh=o.n(ch);const fh=(e,t)=>({selector:e,resolveView:e=>({...t,element:e})}),ph=(e,t,n)=>((e,t)=>{const{repoName:n,commitID:r}=e;return zf({repoName:n,revision:r,requestGraphQL:t}).pipe(Vf())})(e,n).pipe(Ve((()=>Hf({repoName:e.repoName,filePath:e.filePath,commitID:e.commitID,requestGraphQL:n}))),$((t=>t?{...e,content:t.join("\n")}:{...e})),at((n=>Y(t(n)).pipe(Ve((t=>{if(t)return q(e);throw n}))))));function dh(){return Yn(Xa(window.location.hash))}function hh(){return Ae(window,"hashchange").pipe($(dh),We(((e,t)=>de()(e,t))))}function mh(e){const t=e.title.split(" \u2192 ");return t.length>1?{headFilePath:t[1],baseFilePath:t[0]}:{headFilePath:t[0],baseFilePath:t[0]}}function gh(e){const{pageType:t}=Eh();if(!wh(t))return null;let n="",r="";if("pull"===t){const t=document.querySelector("details-menu[src*='sha1='][src*='sha2=']")?.getAttribute("src"),o=e.classList.contains("js-comment-container");if(t){const e=new URLSearchParams(t),n=e.get("sha1"),r=e.get("sha2");if(n&&r)return{baseCommitID:n,headCommitID:r}}else if(o){const t=function(e){const t=e.querySelector(`summary a[href^="${location.pathname}"`);if(!t)return null;const n=t.href.match(bh);if(!n)return null;const r=n[3],o=vh(document.documentElement.innerHTML,!0);return r&&o?{...o,headCommitID:r}:null}(e);if(t)return t}else{const e=document.querySelector('input[name="comparison_start_oid"]');e&&(n=e.value);const t=document.querySelector('input[name="comparison_end_oid"]');t&&(r=t.value)}}else if("commit"===t){const e=document.querySelectorAll(".sha-block:not(.patch-diff-links)");if(e&&2===e.length){const t=e[0].querySelector("a");t&&(n=t.href.split("/").slice(-1)[0]);const o=e[1].querySelector("span.sha");o&&(r=o.innerHTML)}}else if("compare"===t){const e=function(){const[e,t]=document.querySelectorAll(".commitish-suggester .select-menu-button span");if(e&&t&&e.textContent&&t.textContent)return{baseCommitID:e.textContent,headCommitID:t.textContent};return}();if(e)return e}return""===n||""===r?vh(document.documentElement.innerHTML,"pull"===t):{baseCommitID:n,headCommitID:r}}const bh=/\/files\/((\w+)\.\.)?(\w+)#diff-\w+$/;function vh(e,t){if(!t)return null;const n="\x3c!-- base sha1: &quot;",r=e.indexOf(n);if(-1===r)return null;const o="\x3c!-- head sha1: &quot;",i=e.indexOf(o,r);if(-1===i)return null;return{baseCommitID:e.slice(r+n.length,40),headCommitID:e.slice(i+o.length,40)}}function yh(){const e=document.querySelector("a.js-permalink-shortcut");if(!e)throw new Error("Unable to determine the file path because no a.js-permalink-shortcut element was found.");const t=new URL(e.href),[,,,n,,...r]=t.pathname.split("/");if("tree"!==n&&0===r.length)throw new Error(`Unable to determine the file path because the a.js-permalink-shortcut element's href's path was ${t.pathname} (it is expected to be of the form /<user>/<repo>/blob/<commitID>/<path/to/file>).`);return decodeURIComponent(r.join("/"))}function wh(e){switch(e){case"commit":case"pull":case"compare":return!0;default:return!1}}function Eh(e=window.location){const{host:t,pathname:n}=e,[r,o,i,...s]=n.slice(1).split("/");if(!r||!o)throw new Uf(`Could not parse repoName from GitHub url: ${e.href}`);const a=`${r}/${o}`,l=`${t}/${a}`;switch(i){case"blob":case"tree":return{pageType:i,rawRepoName:l,revisionAndFilePath:decodeURIComponent(s.join("/")),repoName:a};case"pull":case"commit":case"compare":return{pageType:i,rawRepoName:l,repoName:a};default:return{pageType:"other",rawRepoName:l,repoName:a}}}const _h=e=>{let t=e.closest("td").previousElementSibling;for(;t;){if(t.dataset.lineNumber)return parseInt(t.dataset.lineNumber,10);t=t.previousElementSibling}throw new Error("Could not find a line number in any cell")},xh=e=>{const t=e.closest("td.blob-code");return!t||t.parentElement?.classList.contains("js-expandable-line")?null:t},Sh=(e,t,n)=>{const r=Ih(e),o=((e,t)=>"base"===e?0:t?2:1)(n,r)+1,i=e.querySelector(`td:nth-child(${o})[data-line-number="${t}"]`);if(!i)return null;if(!r&&"base"===n&&!i.classList.contains("blob-num-addition")&&!i.classList.contains("blob-num-deletion"))return null;let s;if(r)s=i.nextElementSibling;else{s=i.parentElement.lastElementChild}return s},Ch=e=>e.classList.contains("blob-code-inner")?e:e.querySelector(".blob-code-inner"),Oh={getCodeElementFromTarget:e=>{const t=xh(e);return t&&Ch(t)},getLineElementFromLineNumber:Sh,getCodeElementFromLineNumber:(e,t,n)=>{const r=Sh(e,t,n);return r&&Ch(r)},getLineNumberFromCodeElement:_h,getDiffCodePart:e=>{const t=e.closest("td");return t.classList.contains("blob-code-addition")?"head":t.classList.contains("blob-code-deletion")||Ih(e)&&t.nextElementSibling?"base":"head"},isFirstCharacterDiffIndicator:e=>{const t=e.closest(".blob-code-inner"),n=t&&["deletion","context","addition"].some((e=>t.classList.contains("blob-code-marker-"+e))),r=e.closest("tr")?.querySelector("td[data-code-marker]"),o=t?.hasAttribute("data-code-marker"),i=r||o,s=e.closest(".refined-github-diff-signs");return!n&&!i&&!s}},Nh=(e,t)=>{const n=e.querySelector(`td[data-line-number="${t}"]`);return n&&n.nextElementSibling},kh={getCodeElementFromTarget:xh,getCodeElementFromLineNumber:Nh,getLineElementFromLineNumber:Nh,getLineNumberFromCodeElement:_h},Th=(e,t)=>{const n=((e,t)=>{const n=e.querySelectorAll("td.blob-num");let r=null;for(const e of n)if(e.querySelector("a").href.endsWith(`#L${t}`)){r=e;break}return r})(e,t);return n&&n.nextElementSibling},Ah={getCodeElementFromTarget:xh,getCodeElementFromLineNumber:Th,getLineElementFromLineNumber:Th,getLineNumberFromCodeElement:e=>{const t=e.closest("td").previousElementSibling;return parseInt(t.firstElementChild.textContent,10)}};function Ih(e){const{pageType:t}=Eh();if(!wh(t))return!1;const n=e.classList.contains("file")?e:e.closest(".file");if(!n)throw new Error("Could not resolve code view element");if(n.classList.contains("js-comment-container"))return!1;const r=n.querySelector("table");if(!r)throw new Error("Could not find code view table");return r.classList.contains("js-file-diff-split")||r.classList.contains("file-diff-split")}const Rh=()=>{const e=Eh();if("blob"!==e.pageType&&"tree"!==e.pageType)throw new Error(`Current URL does not match a blob or tree url: ${window.location.href}`);const{revisionAndFilePath:t,rawRepoName:n}=e,r=yh(),o=r&&!r.startsWith("/")?`/${r}`:r,i=o?t.slice(0,-o.length):t;if(!t.endsWith(o))throw new Error(`The file path ${o} should always be a suffix of revAndFilePath ${t}, but isn't in this case.`);return{blob:{rawRepoName:n,filePath:r,revision:i,commitID:le({selector:".js-permalink-shortcut",hrefRegex:/^\/.*?\/.*?\/(?:blob|tree)\/([\da-f]{40})/})}}},Ph=/\/([\da-f]{40})$/i,Dh=e=>{const t=e.querySelector("a.commit-tease-sha");if(!t)throw new Error("Could not find commit link in snippet code view");const n=t.href.match(Ph);if(!n?.[1])throw new Error(`Could not parse commitID from snippet commit link href: ${t.href}`);const r=n[1],o=e.querySelectorAll("a:not(.commit-tease-sha)"),i=new URL(o[0].href),s=Eh(i);if("blob"!==s.pageType)throw new Error(`Snippet URL does not match a blob url: ${i.href}`);const{revisionAndFilePath:a,rawRepoName:l}=s;if(!a.startsWith(r))throw new Error(`Could not parse filePath: revAndFilePath ${a} does not start with commitID ${r}`);return{blob:{rawRepoName:l,filePath:a.slice(r.length+1),commitID:r,revision:r}}},Lh=["tooltipped","tooltipped-n"];const Mh="codeHost-module__command-palette-popover_xVrp2",jh="codeHost-module__command-palette-action-item_16BFG",Fh="codeHost-module__action-item_7QWb2",Uh="codeHost-module__icon_3PdA7",Bh="codeHost-module__code-view-toolbar_gOzAp",qh="codeHost-module__code-view-toolbar-item_2fTzz",$h="codeHost-module__hover-overlay-badge_3wpZt";function zh(e){const t="github-file-actions-toolbar-mount",n=e.querySelector("."+t);if(n)return n;const r=document.createElement("div");r.className=t;const o=e.querySelector(".file-actions");if(!o)throw new Error("Could not find GitHub file actions with selector .file-actions");o.classList.add("sg-github-file-actions");const i=e.querySelector(".show-file-notes");return i?i.after(r):o.prepend(r),r}const Vh={dom:Oh,getToolbarMount:zh,resolveFileInfo:e=>{const{rawRepoName:t}=Eh(),{headFilePath:n,baseFilePath:r}=function(e){const t=e.querySelector(".file-info");if(t){if("A"===t.tagName)return mh(t);const e=t.querySelector(".diffstat + a");if(e)return mh(e)}const n=e.querySelector(".file-header a");if(n)return mh(n);throw new Error("Could not determine diff file name")}(e);if(!n)throw new Error("cannot determine file path");const o=gh(e);if(!o)throw new Error("cannot determine delta info");const{headCommitID:i,baseCommitID:s}=o;return{head:{rawRepoName:t,filePath:n,commitID:i,revision:i},base:{rawRepoName:t,filePath:r||n,commitID:s,revision:s}}},getScrollBoundaries:e=>{const t=e.querySelector(".file-header");if(!t)throw new Error("Could not find .file-header element in GitHub PR code view");return[t]}},Hh={...Vh,getToolbarMount:void 0},Gh={dom:kh,getToolbarMount:zh,resolveFileInfo:Rh,getSelections:dh,observeSelections:hh},Wh=e=>({direction:t,codeView:n,position:r})=>Hf({...r,requestGraphQL:e}).pipe($((e=>{const o=kh.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");const i=e[r.line-1],s=o.textContent||"",a=i.length-uh()(i).length,l=s.length-uh()(s).length,c=t===jn.ActualToCodeView?-1:1,u=Math.abs(a-l)*c;return{line:r.line,character:r.character+u}}))),Qh=fh(".code-list-item",{dom:Ah,getPositionAdjuster:Wh,resolveFileInfo:Dh}),Kh={dom:kh,resolveFileInfo:Dh,getPositionAdjuster:Wh},Zh=e=>{const t="sourcegraph-github-file-code-view-toolbar-mount",n=e.querySelector(`.${t}`);if(n)return n;const r=document.createElement("div");r.style.display="inline-flex",r.style.verticalAlign="middle",r.style.alignItems="center",r.className=t;const o=e.querySelector("#raw-url")?.closest(".BtnGroup");if(!o?.parentNode)throw new Error("File actions not found");return o.parentNode.insertBefore(r,o),r},Yh={selector:".js-file-line-container",resolveView:e=>{const t=e.closest(".blob-wrapper-embedded");if(t){return{element:t.parentElement,...Kh}}const{pageType:n}=Eh();if("blob"!==n)return null;const r=e.closest("#repo-content-turbo-frame");if(!r)throw new Error("Could not find repository content element");return{element:r,...Gh,getToolbarMount:Zh}}},Jh={selector:e=>{const t=new Set;for(const n of ue(e,".file"))0===n.querySelectorAll(".js-diff-load-container").length&&t.add(n);for(const n of ue(e,".js-blob-wrapper")){const e=n.closest(".file");e instanceof HTMLElement&&t.add(e)}return[...t]},resolveView:e=>{if(e.querySelector("article.markdown-body"))return null;if(e.closest(".js-suggested-changes-blob"))return null;const{pageType:t}=Eh();return"blob"===t&&1===document.querySelectorAll(".file").length&&0===document.querySelectorAll(".diff-view").length?{element:e,...Gh}:e.closest(".discussion-item-body")||e.classList.contains("js-comment-container")?{element:e,...Hh}:{element:e,...Vh}}};function Xh(){const e=document.head.querySelector('meta[property="og:site_name"]');return!!e&&("GitHub Enterprise"===e.content||"GitHub"===e.content)&&document.body.classList.contains("enterprise")}const em="open-on-sourcegraph",tm=s()(Uh,"v-align-text-bottom"),nm={[gc]:"flash",[bc]:"flash flash-success",[mc]:"flash",[hc]:"flash flash-warn",[dc]:"flash flash-error"},rm={searchViewResolver:{selector:'.js-site-search-form input[type="text"][aria-controls="jump-to-results"]',resolveView:e=>({element:e})},resultViewResolver:{selector:"#jump-to-suggestion-search-global",resolveView:e=>({element:e})},onChange:({value:e,searchURL:t,resultElement:n})=>{const r="#jump-to-sourcegraph-search-global";(n=>{const r=n.querySelector(".jump-to-suggestion-name");r.textContent=e,r.setAttribute("aria-label",e);const o=n.querySelector("a"),i=new URL(t);i.searchParams.append("q",e),o.setAttribute("href",i.href),o.setAttribute("target","_blank"),n.setAttribute("style","display: "+(e?"initial":"none !important"))})(document.querySelector(r)??(()=>{const e=n.cloneNode(!0);e.id=r.replace("#",""),e.classList.remove("navigation-focus"),e.setAttribute("aria-selected","false");const t=document.createElement("img");t.src="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNTIgNTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTMwLjggNTEuOGMtMi44LjUtNS41LTEuMy02LTQuMUwxNy4yIDYuMmMtLjUtMi44IDEuMy01LjUgNC4xLTZzNS41IDEuMyA2IDQuMWw3LjYgNDEuNWMuNSAyLjgtMS40IDUuNS00LjEgNnoiIGZpbGw9IiNGRjU1NDMiLz48cGF0aCBkPSJNMTAuOSA0NC43QzkuMSA0NSA3LjMgNDQuNCA2IDQzYy0xLjgtMi4yLTEuNi01LjQuNi03LjJMMzguNyA4LjVjMi4yLTEuOCA1LjQtMS42IDcuMi42IDEuOCAyLjIgMS42IDUuNC0uNiA3LjJsLTMyIDI3LjNjLS43LjYtMS42IDEtMi40IDEuMXoiIGZpbGw9IiNBMTEyRkYiLz48cGF0aCBkPSJNNDYuOCAzOC4xYy0uOS4yLTEuOC4xLTIuNi0uMkw0LjQgMjMuOGMtMi43LTEtNC4xLTMuOS0zLjEtNi42IDEtMi43IDMuOS00LjEgNi42LTMuMWwzOS43IDE0LjFjMi43IDEgNC4xIDMuOSAzLjEgNi42LS42IDEuOC0yLjIgMy0zLjkgMy4zeiIgZmlsbD0iIzAwQ0JFQyIvPjwvc3ZnPgo=",t.setAttribute("style","width: 16px; height: 20px; float: left; margin-right: 2px;"),t.setAttribute("alt","Sourcegraph Logo Image");const o=e.querySelector(".js-jump-to-badge-search-text-global");return o.textContent="Sourcegraph",o.parentNode?.insertBefore(t,o),n.parentNode?.insertBefore(e,n.nextElementSibling),e})())}},om=async(e,t=ff.fetchCache,n="#repository-container-header h2 span.Label")=>{if("github.com"!==window.location.hostname)return Promise.resolve(!0);try{const{status:n}=await t({url:`https://github.com/${e}`,credentials:"omit",cacheMaxAge:36e5});return 200!==n}catch(e){return console.warn("Failed to fetch if the repository is private.",e),"public"!==document.querySelector(n)?.textContent?.toLowerCase().trim()}},im=()=>"/search"===window.location.pathname,sm=()=>"/search/advanced"===window.location.pathname,am=()=>!im()&&window.location.pathname.endsWith("/search"),lm=()=>Boolean(new URLSearchParams(window.location.search).get("q"))&&!sm(),cm=()=>{const e=new URLSearchParams(window.location.search).get("type");return e?e.toLowerCase():""},um=e=>{const t=e.filter(Boolean).map((e=>e.trim())),n=(()=>{switch(cm()){case"repositories":return"repo";case"commits":return"commit";case"code":return"";default:return im()||sm()?"repo":""}})(),r=new URLSearchParams(window.location.search).get("l");if(n&&t.push(`type:${n}`),r&&t.push(`lang:${encodeURIComponent(r)}`),am()){const[e,n]=window.location.pathname.split("/").filter(Boolean);t.push(`repo:${e}/${n}$`)}for(const e of["org","user"]){const n=t.findIndex((t=>t.startsWith(`${e}:`)));if(n>=0){const r=t[n].replace(`${e}:`,"");r&&(t[n]=`repo:${r}/*`)}}return t.join("+")},fm=(e,t="")=>{let n=document.querySelector(`#${e}`);return n||(n=document.createElement("div"),n.setAttribute("id",e),n.classList.add(...t.split(/\s/gi)),n)};const pm={type:"github",name:Xh()?"GitHub Enterprise":"GitHub",searchEnhancement:rm,enhanceSearchPage:function(e){if(!(im()||sm()||am()||lm()))return;const t=({container:t,className:n="",getSearchQuery:r,utmCampaign:o})=>{const i=nf(new URL("/search",e),{utm_source:mf(),utm_campaign:o});(0,me.s)(t).render((0,u.jsx)(If,{label:"Search on Sourcegraph",title:"Search on Sourcegraph to get hover tooltips, go to definition and more",ariaLabel:"Search on Sourcegraph to get hover tooltips, go to definition and more",className:s()("btn","m-auto",n),iconClassName:s()("mr-1","v-align-middle",Uh),href:i.href,dataTestId:"search-on-sourcegraph",onClick:e=>{const t=um(r());e.target.href=`${i.href}${t?`&q=${t}`:""}`}}))};if(lm()){const e=cm();if(["repositories","commits","code"].includes(e)||""===e&&(im()||am())){const e=document.querySelector(".application-main form.js-site-search-form"),n=e?.querySelector("input.form-control[name='q']"),r=e?.parentElement?.parentElement?.querySelector("button[type='submit']");if(n&&r){const e=fm("pageSearchFormSourcegraphButton","ml-2 d-none d-md-block");r.after(e),t({container:e,utmCampaign:"github-search-results-page",getSearchQuery:()=>n.value.split(" ")})}const o=document.querySelector("header form.js-site-search-form input.form-control[name='q']"),i=document.querySelector(".codesearch-results"),s=i?.querySelector(".blankslate"),a=i?.querySelector("div > div > h3");if(o&&(s||a)){const e=fm("headerSearchInputSourcegraphButton","ml-auto d-none d-lg-block");s?(e.classList.add("mt-2"),s.append(e)):a&&(e.classList.add("mr-2"),a.after(e)),t({container:e,className:s?"":"btn-sm",utmCampaign:"github-search-results-page",getSearchQuery:()=>o.value.split(" ")})}}return}const n=document.querySelector("#search_form"),r=n?.querySelector(".search-form-fluid"),o=n?.querySelector("input");if(r&&o){const e=fm("searchInputSourcegraphButton","ml-0 ml-md-2 mt-2 mt-md-0");r?.append(e),t({container:e,utmCampaign:`github-${sm()?"advanced":"simple"}-search-page`,getSearchQuery:()=>o.value.split(" ")})}},codeViewResolvers:[Jh,Yh,Qh],contentViewResolvers:[{selector:".markdown-body",resolveView:e=>({element:e})}],nativeTooltipResolvers:[{selector:".js-tagsearch-popover",resolveView:e=>({element:e})}],routeChange:e=>e.pipe($((()=>{const{pathname:e}=window.location,t=e.slice(1).split("/")[2];return"blob"===t||"tree"===t?e.endsWith(yh())?e:void 0:lm()?document.querySelector(".codesearch-results h3")?.textContent?.trim():e})),qe(Boolean),We()),getContext:async()=>{const{repoName:e,rawRepoName:t,pageType:n}=Eh();return{rawRepoName:t,revision:"blob"===n||"tree"===n?Rh().blob.revision:void 0,privateRepository:await om(e)}},isLightTheme:$d((()=>{const e=document.documentElement.dataset.colorMode;return"auto"===e?((e=window)=>{const t=e.matchMedia("(prefers-color-scheme: dark)");return{observable:se(q(!t.matches),Ae(t,"change").pipe($((e=>!e.matches)))),initialValue:!t.matches}})().observable:q("dark"!==e)})),getViewContextOnSourcegraphMount:e=>{const t=fe(e,".pagehead-actions");if(!t||0===t.children.length)return null;let n=t.querySelector("#open-on-sourcegraph");return n||(n=document.createElement("li"),n.id=em,t.prepend(n),n)},viewOnSourcegraphButtonClassProps:{className:"btn btn-sm tooltipped tooltipped-s",iconClassName:tm},check:()=>((e=window.location.href)=>/^https?:\/\/(www\.)?github\.com/.test(e))()||Xh(),getCommandPaletteMount:e=>{const t="command-palette-button",n=e.querySelector(`.Header .${t}`)||e.querySelector(`.Header-old .${t}`);if(n)return n;const r=fe(e,".HeaderMenu > :last-child");if(r){const e=document.createElement("div");return e.classList.add(t),r.prepend(e),e}let o=fe(e,".Header-item:nth-last-child(2)");if(o){0!==o.previousElementSibling.children.length&&(o=o.previousElementSibling);const e=document.createElement("div");return e.classList.add("Header-item","mr-0","mr-lg-3",t),o.before(e),e}return null},notificationClassNames:nm,commandPaletteClassProps:{buttonClassName:"Header-link d-flex flex-items-baseline",popoverClassName:s()("Box",Mh),formClassName:"p-1",inputClassName:"form-control input-sm header-search-input jump-to-field-active",listClassName:"p-0 m-0 js-navigation-container jump-to-suggestions-results-container",selectedListItemClassName:"navigation-focus",listItemClassName:"d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-scoped-search",actionItemClassName:s()(jh,"no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path p-2"),noResultsClassName:"d-flex flex-auto flex-items-center jump-to-suggestions-path p-2",iconClassName:tm},codeViewToolbarClassProps:{className:Bh,listItemClass:s()(qh,"BtnGroup"),actionItemClass:s()("btn btn-sm tooltipped tooltipped-s BtnGroup-item",Fh),actionItemPressedClass:"selected",actionItemIconClass:s()(Uh,"v-align-text-bottom")},hoverOverlayClassProps:{className:"Box",actionItemClassName:"btn btn-sm btn-secondary",actionItemPressedClassName:"active",closeButtonClassName:"btn-octicon p-0 hover-overlay__close-button--github",badgeClassName:s()("label",$h),getAlertClassName:$p(nm,"flash-full"),iconClassName:tm},setElementTooltip:function(e,t){"string"==typeof t?(e.classList.add(...Lh),e.setAttribute("aria-label",t)):(e.classList.remove(...Lh),e.removeAttribute("aria-label"))},linkPreviewContentClass:"text-small text-gray p-1 mx-1 border rounded-1 bg-gray text-gray-dark",urlToFile:(e,t,n)=>{if(t.viewState)return il(e,t);if(!t.rawRepoName.startsWith(window.location.hostname))return il(e,t);const r=t.revision||"HEAD",{rawRepoName:o}=Eh();if(o===t.rawRepoName&&void 0!==n.part){const e=document.querySelectorAll(".file");for(const r of e){const e=r.querySelector(".file-header[data-path][data-anchor]");if(!e)continue;if(e.dataset.path===t.filePath){const r=e.dataset.anchor,o=new URL(window.location.href);if(o.hash=r,t.position&&(o.hash+=`${"base"===n.part?"L":"R"}${t.position.line}`),!document.querySelector(o.hash))break;return o.href}}}const i=t.position?`#L${t.position.line}${t.position.character?`:${t.position.character}`:""}`:"";return`https://${t.rawRepoName}/blob/${r}/${t.filePath}${i}`},observeLineSelection:Ae(window,"hashchange").pipe(ae(void 0),$((()=>(e=>{const t=e.match(/(L\d+)/g);if(!t||t.length>2)return{};const n={},[r,o]=t.map((e=>e.slice(1)));return n.line=parseInt(r,10),o&&(n.endLine=parseInt(o,10)),n})(window.location.hash)))),codeViewsRequireTokenization:!0};var dm=o(6314);function hm(){var e=(0,dm.R)(),t=e.crypto||e.msCrypto;if(t&&t.randomUUID)return t.randomUUID().replace(/-/g,"");var n=t&&t.getRandomValues?()=>t.getRandomValues(new Uint8Array(1))[0]:()=>16*Math.random();return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(e=>(e^(15&n())>>e/4).toString(16)))}var mm=o(91698),gm=(0,dm.R)(),bm=["debug","info","warn","error","log","assert","trace"];function vm(e){var t=(0,dm.R)();if(!("console"in t))return e();var n=t.console,r={};bm.forEach((e=>{var o=n[e]&&n[e].__sentry_original__;e in t.console&&o&&(r[e]=n[e],n[e]=o)}));try{return e()}finally{Object.keys(r).forEach((e=>{n[e]=r[e]}))}}function ym(){let e=!1;var t={enable:()=>{e=!0},disable:()=>{e=!1}};return"undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?bm.forEach((n=>{t[n]=(...t)=>{e&&vm((()=>{gm.console[n](`Sentry Logger [${n}]:`,...t)}))}})):bm.forEach((e=>{t[e]=()=>{}})),t}let wm;wm="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?(0,dm.Y)("logger",ym):ym();var Em,_m=o(38241),xm=Object.prototype.toString;function Sm(e,t){return xm.call(e)===`[object ${t}]`}function Cm(e){return Sm(e,"Object")}function Om(e){return Boolean(e&&e.then&&"function"==typeof e.then)}!function(e){e[e.PENDING=0]="PENDING";e[e.RESOLVED=1]="RESOLVED";e[e.REJECTED=2]="REJECTED"}(Em||(Em={}));class Nm{__init(){this._state=Em.PENDING}__init2(){this._handlers=[]}constructor(e){Nm.prototype.__init.call(this),Nm.prototype.__init2.call(this),Nm.prototype.__init3.call(this),Nm.prototype.__init4.call(this),Nm.prototype.__init5.call(this),Nm.prototype.__init6.call(this);try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}then(e,t){return new Nm(((n,r)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){r(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){r(e)}else r(e)}]),this._executeHandlers()}))}catch(e){return this.then((e=>e),e)}finally(e){return new Nm(((t,n)=>{let r,o;return this.then((t=>{o=!1,r=t,e&&e()}),(t=>{o=!0,r=t,e&&e()})).then((()=>{o?n(r):t(r)}))}))}__init3(){this._resolve=e=>{this._setResult(Em.RESOLVED,e)}}__init4(){this._reject=e=>{this._setResult(Em.REJECTED,e)}}__init5(){this._setResult=(e,t)=>{this._state===Em.PENDING&&(Om(t)?t.then(this._resolve,this._reject):(this._state=e,this._value=t,this._executeHandlers()))}}__init6(){this._executeHandlers=()=>{if(this._state!==Em.PENDING){var e=this._handlers.slice();this._handlers=[],e.forEach((e=>{e[0]||(this._state===Em.RESOLVED&&e[1](this._value),this._state===Em.REJECTED&&e[2](this._value),e[0]=!0)}))}}}}function km(e){return Tm(e,new Map)}function Tm(e,t){if(Cm(e)){if(void 0!==(o=t.get(e)))return o;var n={};for(var r of(t.set(e,n),Object.keys(e)))void 0!==e[r]&&(n[r]=Tm(e[r],t));return n}if(Array.isArray(e)){var o;if(void 0!==(o=t.get(e)))return o;n=[];return t.set(e,n),e.forEach((e=>{n.push(Tm(e,t))})),n}return e}function Am(e){var t=(0,mm.ph)(),n={sid:hm(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return km({sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}})}(n)};return e&&Im(n,e),n}function Im(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||(0,mm.ph)(),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:hm()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{var n=e.timestamp-e.started;e.duration=n>=0?n:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}class Rm{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={}}static clone(e){var t=new Rm;return e&&(t._breadcrumbs=[...e._breadcrumbs],t._tags={...e._tags},t._extra={...e._extra},t._contexts={...e._contexts},t._user=e._user,t._level=e._level,t._span=e._span,t._session=e._session,t._transactionName=e._transactionName,t._fingerprint=e._fingerprint,t._eventProcessors=[...e._eventProcessors],t._requestSession=e._requestSession,t._attachments=[...e._attachments]),t}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{},this._session&&Im(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this._tags={...this._tags,[e]:t},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts={...this._contexts,[e]:t},this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){var e=this.getSpan();return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;if("function"==typeof e){var t=e(this);return t instanceof Rm?t:this}return e instanceof Rm?(this._tags={...this._tags,...e._tags},this._extra={...this._extra,...e._extra},this._contexts={...this._contexts,...e._contexts},e._user&&Object.keys(e._user).length&&(this._user=e._user),e._level&&(this._level=e._level),e._fingerprint&&(this._fingerprint=e._fingerprint),e._requestSession&&(this._requestSession=e._requestSession)):Cm(e)&&(e=e,this._tags={...this._tags,...e.tags},this._extra={...this._extra,...e.extra},this._contexts={...this._contexts,...e.contexts},e.user&&(this._user=e.user),e.level&&(this._level=e.level),e.fingerprint&&(this._fingerprint=e.fingerprint),e.requestSession&&(this._requestSession=e.requestSession)),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this}addBreadcrumb(e,t){var n="number"==typeof t?Math.min(t,100):100;if(n<=0)return this;var r={timestamp:(0,mm.yW)(),...e};return this._breadcrumbs=[...this._breadcrumbs,r].slice(-n),this._notifyScopeListeners(),this}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this._attachments}clearAttachments(){return this._attachments=[],this}applyToEvent(e,t={}){if(this._extra&&Object.keys(this._extra).length&&(e.extra={...this._extra,...e.extra}),this._tags&&Object.keys(this._tags).length&&(e.tags={...this._tags,...e.tags}),this._user&&Object.keys(this._user).length&&(e.user={...this._user,...e.user}),this._contexts&&Object.keys(this._contexts).length&&(e.contexts={...this._contexts,...e.contexts}),this._level&&(e.level=this._level),this._transactionName&&(e.transaction=this._transactionName),this._span){e.contexts={trace:this._span.getTraceContext(),...e.contexts};var n=this._span.transaction&&this._span.transaction.name;n&&(e.tags={transaction:n,...e.tags})}return this._applyFingerprint(e),e.breadcrumbs=[...e.breadcrumbs||[],...this._breadcrumbs],e.breadcrumbs=e.breadcrumbs.length>0?e.breadcrumbs:void 0,e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...this._sdkProcessingMetadata},this._notifyEventProcessors([...Pm(),...this._eventProcessors],e,t)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}_notifyEventProcessors(e,t,n,r=0){return new Nm(((o,i)=>{var s=e[r];if(null===t||"function"!=typeof s)o(t);else{var a=s({...t},n);("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.id&&null===a&&wm.log(`Event processor "${s.id}" dropped event`),Om(a)?a.then((t=>this._notifyEventProcessors(e,t,n,r+1).then(o))).then(null,i):this._notifyEventProcessors(e,a,n,r+1).then(o).then(null,i)}}))}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((e=>{e(this)})),this._notifyingListeners=!1)}_applyFingerprint(e){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],this._fingerprint&&(e.fingerprint=e.fingerprint.concat(this._fingerprint)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint}}function Pm(){return(0,dm.Y)("globalEventProcessors",(()=>[]))}var Dm=100;class Lm{__init(){this._stack=[{}]}constructor(e,t=new Rm,n=4){this._version=n,Lm.prototype.__init.call(this),this.getStackTop().scope=t,e&&this.bindClient(e)}isOlderThan(e){return this._version<e}bindClient(e){this.getStackTop().client=e,e&&e.setupIntegrations&&e.setupIntegrations()}pushScope(){var e=Rm.clone(this.getScope());return this.getStack().push({client:this.getClient(),scope:e}),e}popScope(){return!(this.getStack().length<=1)&&!!this.getStack().pop()}withScope(e){var t=this.pushScope();try{e(t)}finally{this.popScope()}}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,t){var n=this._lastEventId=t&&t.event_id?t.event_id:hm(),r=new Error("Sentry syntheticException");return this._withClient(((o,i)=>{o.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},i)})),n}captureMessage(e,t,n){var r=this._lastEventId=n&&n.event_id?n.event_id:hm(),o=new Error(e);return this._withClient(((i,s)=>{i.captureMessage(e,t,{originalException:e,syntheticException:o,...n,event_id:r},s)})),r}captureEvent(e,t){var n=t&&t.event_id?t.event_id:hm();return"transaction"!==e.type&&(this._lastEventId=n),this._withClient(((r,o)=>{r.captureEvent(e,{...t,event_id:n},o)})),n}lastEventId(){return this._lastEventId}addBreadcrumb(e,t){const{scope:n,client:r}=this.getStackTop();if(!n||!r)return;const{beforeBreadcrumb:o=null,maxBreadcrumbs:i=Dm}=r.getOptions&&r.getOptions()||{};if(!(i<=0)){var s={timestamp:(0,mm.yW)(),...e},a=o?vm((()=>o(s,t))):s;null!==a&&n.addBreadcrumb(a,i)}}setUser(e){var t=this.getScope();t&&t.setUser(e)}setTags(e){var t=this.getScope();t&&t.setTags(e)}setExtras(e){var t=this.getScope();t&&t.setExtras(e)}setTag(e,t){var n=this.getScope();n&&n.setTag(e,t)}setExtra(e,t){var n=this.getScope();n&&n.setExtra(e,t)}setContext(e,t){var n=this.getScope();n&&n.setContext(e,t)}configureScope(e){const{scope:t,client:n}=this.getStackTop();t&&n&&e(t)}run(e){var t=jm(this);try{e(this)}finally{jm(t)}}getIntegration(e){var t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(t){return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&wm.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,t){return this._callExtensionMethod("startTransaction",e,t)}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){var e=this.getStackTop(),t=e&&e.scope,n=t&&t.getSession();n&&function(e,t){let n={};t?n={status:t}:"ok"===e.status&&(n={status:"exited"}),Im(e,n)}(n),this._sendSessionUpdate(),t&&t.setSession()}startSession(e){const{scope:t,client:n}=this.getStackTop(),{release:r,environment:o}=n&&n.getOptions()||{};var i=(0,dm.R)();const{userAgent:s}=i.navigator||{};var a=Am({release:r,environment:o,...t&&{user:t.getUser()},...s&&{userAgent:s},...e});if(t){var l=t.getSession&&t.getSession();l&&"ok"===l.status&&Im(l,{status:"exited"}),this.endSession(),t.setSession(a)}return a}shouldSendDefaultPii(){var e=this.getClient(),t=e&&e.getOptions();return Boolean(t&&t.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:t}=this.getStackTop();if(e){var n=e.getSession();n&&t&&t.captureSession&&t.captureSession(n)}}_withClient(e){const{scope:t,client:n}=this.getStackTop();n&&e(n,t)}_callExtensionMethod(e,...t){var n=Mm().__SENTRY__;if(n&&n.extensions&&"function"==typeof n.extensions[e])return n.extensions[e].apply(this,t);("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&wm.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function Mm(){var e=(0,dm.R)();return e.__SENTRY__=e.__SENTRY__||{extensions:{},hub:void 0},e}function jm(e){var t=Mm(),n=Bm(t);return qm(t,e),n}function Fm(){var e=Mm();return Um(e)&&!Bm(e).isOlderThan(4)||qm(e,new Lm),(0,_m.KV)()?function(e){try{var t=Mm().__SENTRY__,n=t&&t.extensions&&t.extensions.domain&&t.extensions.domain.active;if(!n)return Bm(e);if(!Um(n)||Bm(n).isOlderThan(4)){var r=Bm(e).getStackTop();qm(n,new Lm(r.client,Rm.clone(r.scope)))}return Bm(n)}catch(t){return Bm(e)}}(e):Bm(e)}function Um(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function Bm(e){return(0,dm.Y)("hub",(()=>new Lm),e)}function qm(e,t){return!!e&&((e.__SENTRY__=e.__SENTRY__||{}).hub=t,!0)}const $m=(e,t,n)=>e.querySelector(`#LC${t}`),zm={getCodeElementFromTarget:e=>e.closest("span.line"),getLineNumberFromCodeElement:e=>{const t=e.id.replace(/^LC/,"");return parseInt(t,10)},getCodeElementFromLineNumber:$m,getLineElementFromLineNumber:$m},Vm=e=>{const t=e.closest("[data-interop-type]");return t?"old"===t.dataset.interopType?"base":"head":(e=>{let t="old";const n=e.closest(".diff-td,td");return n.classList.contains("parallel")&&(t="left-side"),n.classList.contains(t)?"base":"head"})(e)},Hm=(e,t,n)=>{const r="base"===n?"old":"new",o=e.querySelector(`[data-interop-${r}-line="${t}"]`);return o?o.querySelector("span.line"):((e,t,n)=>{const r=e.querySelector(`.${"base"===n?"old_line":"new_line"} [data-linenumber="${t}"]`);if(!r)return null;const o=r.closest(".diff-tr,tr");if(!o)return null;let i="span.line";return o.classList.contains("parallel")&&(i=`.${"base"===n?"left-side":"right-side"} ${i}`),o.querySelector(i)})(e,t,n)},Gm={getCodeElementFromTarget:zm.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest("[data-interop-line]");return t?parseInt(t.dataset.interopLine||"",10):(e=>{const t=Vm(e);let n=e.closest(".diff-td,td");for(;n&&(!n.matches(".diff-line-num."+("base"===t?"old_line":"new_line"))||!n.querySelector("a"))&&n.previousElementSibling;)n=n.previousElementSibling;if(n){const e=n.querySelector("a");return parseInt(e.dataset.linenumber||"",10)}throw new Error("Unable to determine line number for diff code element")})(e)},getCodeElementFromLineNumber:Hm,getLineElementFromLineNumber:(e,t,n)=>{const r=Hm(e,t,n);return r&&r.parentElement},getDiffCodePart:Vm},Wm="codeHost-module__command-list-popover_hwImg",Qm="codeHost-module__command-palette-button_2FnHe",Km="codeHost-module__hover-overlay_3Cize",Zm=(e,t,n)=>`${window.location.origin}/api/v4/projects/${encodeURIComponent(e)}%2f${t}${n}`,Ym=e=>sr(e,{selector:e=>ur(e).json()}),Jm=gs((e=>Ym(`${window.location.origin}/api/v4/projects/${e}`).pipe($((({web_url:e})=>{const{hostname:t,pathname:n}=new URL(e);return`${t}${n}`})))),Xl()),Xm=gs((({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>r?Ym(Zm(e,t,`/merge_requests/${n}/versions/${r}`)).pipe($((({base_commit_sha:e})=>e))):q(void 0)),(({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>`${e}:${t}:${n}:${String(r)}`)),eg=gs((({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>Pf(Ym(Zm(e,t,`/merge_requests/${n}`)),Xm({owner:e,projectName:t,mergeRequestID:n,diffID:o})).pipe(Ve((([{diff_refs:e,source_project_id:t},n])=>Jm(t).pipe($((t=>({baseCommitID:n||e.base_sha,commitID:e.head_sha,rawRepoName:r,baseRawRepoName:t})))))))),(({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>`${e}:${t}:${n}:${r}:${String(o)}`)),tg=gs((({owner:e,projectName:t,commitID:n})=>Ym(Zm(e,t,`/repository/commits/${n}`)).pipe($((({parent_ids:e})=>Yp()(e))))),(({owner:e,projectName:t,commitID:n})=>`${e}:${t}:${n}`));var ng=o(68642),rg=o.n(ng),og=o(90006),ig=o.n(og);let sg;!function(e){e[e.File=0]="File",e[e.Commit=1]="Commit",e[e.MergeRequest=2]="MergeRequest",e[e.Other=3]="Other"}(sg||(sg={}));function ag(){const e=document.querySelector(".context-header a");if(!e)throw new Error("Unable to determine project name");const t=new URL(e.href).pathname.slice(1),n=t.split("/"),r=rg()(n,n.length-1).join("/"),o=ig()(n),i=((e,t,n)=>{const r=n.match(new RegExp(`^/${e}/${t}(/-)?/(commit|merge_requests|blob)/`));if(!r)return sg.Other;switch(r[2]){case"commit":return sg.Commit;case"merge_requests":return sg.MergeRequest;case"blob":return sg.File;default:return sg.Other}})(r,o,window.location.pathname);return{owner:r,projectName:o,rawRepoName:[lf?window.location.hostname:new URL(gon.gitlab_url).hostname,r,o].join("/"),repoName:t,pageKind:i}}const lg=()=>{let e=window.location.pathname.match(/merge_requests\/(.*?)\/diffs/);if(!e&&document.querySelector(".diffs-tab.active")&&(e=window.location.pathname.match(/merge_requests\/(.*?)((\/)|$)/)),!e)throw new Error("Unable to determine merge request ID");return e[1]},cg=e=>{const t=e.dataset.originalTitle||e.dataset.title||e.title;if(!t)throw new Error("Unable to get file paths from code view: no file title");return t.endsWith(" deleted")?t.slice(0,-8):t};function ug(e){const t=e.querySelectorAll(".file-title-name");if(0===t.length)throw new Error("Unable to get file paths from code view: no .file-title.name");const n=t.length>1,r=cg(t.item(n?1:0));return{headFilePath:r,baseFilePath:n?cg(t.item(0)):r}}function fg(){const{rawRepoName:e,owner:t,projectName:n}=ag();return{rawRepoName:e,owner:t,projectName:n,commitID:ig()(window.location.pathname.split("/"))}}const pg=(e,t)=>{const n=e.querySelector(".sg-toolbar-mount-gitlab");if(n)return n;const r=e.querySelector(".file-actions");if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("sg-toolbar-mount","sg-toolbar-mount-gitlab"),t===sg.Commit&&o.classList.add("gl-mr-3"),r.prepend(o),o},dg={dom:zm,getToolbarMount:e=>pg(e,sg.File),resolveFileInfo:()=>{const{rawRepoName:e,filePath:t,revision:n}=function(){const{rawRepoName:e}=ag(),t=window.location.pathname.match(/\/blob\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]);return{rawRepoName:e,filePath:decodeURIComponent(t[2]),revision:n}}();if(!t)throw new Error(`Unable to determine the file path of the current file because the current URL (window.location ${window.location.href}) does not have a file path.`);return{blob:{rawRepoName:e,filePath:t,commitID:le({selector:".js-data-file-blob-permalink-url",hrefRegex:new RegExp("^/.*?/.*?/blob/([0-9a-f]{40})/")}),revision:n}}},getSelections:dh,observeSelections:hh},hg=e=>{const t=e.querySelector(".js-file-title");if(!t)throw new Error("Could not find .file-title element");return[t]},mg={dom:Gm,getToolbarMount:e=>pg(e,sg.MergeRequest),resolveFileInfo:e=>Y(eg({...ag(),mergeRequestID:lg(),diffID:new URLSearchParams(window.location.search).get("diff_id")??void 0})).pipe($((t=>{const{rawRepoName:n,baseRawRepoName:r,commitID:o,baseCommitID:i}=t,{headFilePath:s,baseFilePath:a}=ug(e);return{head:{rawRepoName:n,filePath:s,commitID:o},base:{rawRepoName:r,filePath:a,commitID:i}}}))),getScrollBoundaries:hg},gg={dom:Gm,getToolbarMount:e=>pg(e,sg.Commit),resolveFileInfo:e=>rr(fg).pipe(Ve((({owner:e,projectName:t,commitID:n,rawRepoName:r})=>tg({owner:e,projectName:t,commitID:n}).pipe($((e=>({commitID:n,baseCommitID:e,rawRepoName:r})))))),$((({commitID:t,baseCommitID:n,rawRepoName:r})=>{const{headFilePath:o,baseFilePath:i}=ug(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}}))),getScrollBoundaries:hg},bg={selector:".file-holder",resolveView:e=>{if(e.classList.contains("discussion-wrapper"))return null;const{pageKind:t}=ag();return t===sg.Other?null:t===sg.File?{element:e,...dg}:t===sg.MergeRequest?e.querySelector(".file-actions")?{element:e,...mg}:null:{element:e,...gg}}},vg={[gc]:"alert alert-secondary",[bc]:"alert alert-success",[mc]:"alert alert-info",[hc]:"alert alert-warning",[dc]:"alert alert-danger"},yg=(e,t=ff.fetchCache)=>"gitlab.com"===window.location.hostname&&e?t({url:`https://gitlab.com/api/v4/projects/${encodeURIComponent(e)}`,credentials:"omit",cacheMaxAge:36e5}).then((e=>{const t=e.headers["ratelimit-remaining"];if(Number(t)<=0){const e=new Error("Gitlab rate limit exceeded.");throw n=e,Fm().captureException(n,{captureContext:r}),e}var n,r;return e})).then((({status:e})=>200!==e)).catch((e=>(console.warn("Failed to fetch repository visibility info.",e),!0))):Promise.resolve(!0),wg={type:"gitlab",name:"GitLab",check:function(){return!!document.head.querySelector('meta[content="GitLab"]')},codeViewResolvers:[bg],getCommandPaletteMount:e=>{const t=fe(e,".navbar-collapse");if(!t)return null;const n="command-palette-button";return t.querySelector("."+n)||(()=>{const e=document.createElement("div");return e.classList.add(n,Qm),t.prepend(e),e})()},getContext:async()=>{const{repoName:e,...t}=ag();return{...t,privateRepository:await yg(e)}},urlToFile:(e,t,n)=>{if(t.viewState||!t.rawRepoName.startsWith(window.location.hostname))return il(e,t);if(ag().rawRepoName===t.rawRepoName&&void 0!==n.part){const e=Vd(document.body,bg.selector);for(const r of e){const{headFilePath:e,baseFilePath:o}=ug(r);if(e!==t.filePath&&o!==t.filePath)continue;if(!t.position){const e=new URL(window.location.href);return e.hash=r.id,e.href}const i=null!==n.part?{head:".new_line",base:".old_line"}[n.part]:"",s=r.querySelector(`${i} a[data-linenumber="${t.position.line}"]`);if(!s)break;return new URL(s.href).href}}const r=new URL(`https://${t.rawRepoName}/blob/${t.revision}/${t.filePath}`);if(t.position){const{line:e}=t.position;r.hash=`#L${e}`}return r.href},notificationClassNames:vg,commandPaletteClassProps:{popoverClassName:s()("dropdown-menu",Wm),formClassName:"dropdown-input",inputClassName:"dropdown-input-field",resultsContainerClassName:"dropdown-content",selectedActionItemClassName:"is-focused",noResultsClassName:"px-3",iconClassName:"s16 align-bottom"},codeViewToolbarClassProps:{className:"pl-0",actionItemClass:"btn btn-md gl-button btn-icon",actionItemPressedClass:"active",actionItemIconClass:"gl-button-icon gl-icon s16"},hoverOverlayClassProps:{className:s()("card",Km),actionItemClassName:"btn btn-secondary",actionItemPressedClassName:"active",closeButtonClassName:"btn btn-transparent p-0 btn-icon--gitlab",iconClassName:"square s16",getAlertClassName:$p(vg)},codeViewsRequireTokenization:!0,getHoverOverlayMountLocation:()=>{const{pageKind:e}=ag();return e===sg.MergeRequest?"div.tab-pane.diffs":null},observeLineSelection:Ae(document,"click").pipe(qe((e=>e.target.matches("a[data-line-number]"))),$((()=>(e=>{if(e.startsWith("#")&&(e=e.slice(1)),!/^L\d+(-\d+)?$/.test(e))return{};const t={},[n,r]=e.slice(1).split("-");return t.line=parseInt(n,10),r&&(t.endLine=parseInt(r,10)),t})(window.location.hash))))},Eg=e=>Boolean("TH"===e.tagName&&e.textContent||e.dataset.n),_g=e=>parseInt(("TH"===e.tagName?e.textContent:e.dataset.n)||"",10),xg=e=>{let t=e;for(;t;){if(Eg(t))return t;t=t.previousElementSibling}return null},Sg=(e,t,n)=>{let r=((e,t,n)=>{const r=e.querySelector("td[data-n]")?"td[data-n]":`th:nth-of-type(${"base"===n?1:2})`;for(const o of e.querySelectorAll(r))if(_g(o)===t){if("head"===n&&null===o.previousElementSibling)continue;return o}return null})(e,t,n);for(;r&&("TD"!==r.tagName||r.classList.contains("n")||Eg(r)||r.classList.contains("copy"));)r=r.nextElementSibling;return r},Cg={getCodeElementFromTarget:e=>{if("TH"===e.tagName||e.classList.contains("copy"))return null;const t=e.closest("td");return t?t.classList.contains("show-more")||t.classList.contains("show-context")?null:xg(t)?t:null:null},getCodeElementFromLineNumber:Sg,getLineElementFromLineNumber:Sg,getLineNumberFromCodeElement:e=>{const t=xg(e);if(!t)throw new Error("Could not find line number cell from code element");return _g(t)},getDiffCodePart:e=>{if(e.classList.contains("old"))return"base";if(e.classList.contains("new"))return"head";const t=xg(e);if(!t)throw new Error("Could not find line number cell from code element");return t.classList.contains("left")?"base":t.classList.contains("right")||t.previousElementSibling?"head":"base"},isFirstCharacterDiffIndicator:e=>!!e.firstElementChild?.classList.contains("aural-only")},Og=(e,t,n)=>{const r=e.querySelector(`tr:nth-of-type(${t})`);if(!r)throw new Error(`unable to find row ${t} from code view`);return r.querySelector("td")},Ng={getCodeElementFromTarget:e=>e.closest("td"),getCodeElementFromLineNumber:Og,getLineElementFromLineNumber:Og,getLineNumberFromCodeElement:e=>{let t=e;for(;null!==t&&"TH"!==t.tagName&&!t.classList.contains("phabricator-source-line");)t=t.previousElementSibling;if(!t)throw new Error("could not find line number cell from code element");const n=t.querySelector("a");if(!n)throw new Error("could not find line number anchor from code element");if(void 0!==n.dataset.n){const e=parseInt(n.dataset.n,10);if(isNaN(e))throw new TypeError(`Could not parse lineNumber from data-n attribute: ${n.dataset.n}`);return e}const r=parseInt(n.textContent||"",10);if(isNaN(r))throw new TypeError(`Could not parse lineNumber from lineAnchor.textContent: ${String(n.textContent)}`);return r},isFirstCharacterDiffIndicator:()=>!1};let kg;!function(e){e[e.Diffusion=1]="Diffusion",e[e.Differential=2]="Differential",e[e.Revision=3]="Revision",e[e.Change=4]="Change"}(kg||(kg={}));const Tg=/r([\dA-z]+)([\da-f]{40})/;function Ag(){const e=document.querySelectorAll(".phui-tag-core").item(0);if(!e)throw new Error("Could not find Phabricator page tag");return Tg.exec(e.children[0].getAttribute("href"))}function Ig(){const e=Ag();if(!e)throw new Error("Could not determine callsign from page tag");return e[1]}function Rg(){const e=Ag();if(!e)throw new Error("Could not determine commitID from page tag");return e[2]}const Pg=/Diff (\d+)/;const Dg=/^\/?(source|diffusion)\/([\w-]+)\/browse\/([\w-]+\/)?([^$;]+)(;[\da-f]{40})?(?:\$\d+)?/i,Lg=/^\/?(d\d+)(?:\?(?:(?:id=(\d+))|(vs=(?:\d+|on)&id=\d+)))?/i,Mg=/^\/?r([\dA-z]+)([\da-f]{40})/i,jg=/^\/?(source|diffusion)\/([\da-z]+)\/change\/([\w-]+)\/([^;]+)(;[\da-f]{40})?/i,Fg=/^\/?\/differential\/changeset.*/i,Ug=/^vs=((?:\d+|on))&id=(\d+)/i;function Bg(e,t,n){try{const r=e.href.replace(e.origin,""),o=Dg.exec(r);if(o){const e=o[4];if(!e)throw new Error(`Could not determine file path from diffusionMatch, stateUrl: ${r}`);return Wg(Ig(),t,n).pipe($((({rawRepoName:t})=>({mode:kg.Diffusion,rawRepoName:t,filePath:e,commitID:Rg()}))))}const i=Lg.exec(r);if(i){const e=i[1],r=i[3],o=parseInt(e.split("D")[1],10);let s,a=i[2]?parseInt(i[2],10):void 0;if(a||(a=function(){const e=document.querySelector("#differential-review-stage");if(!e)throw new Error("no element with id differential-review-stage found on page.");const t=e.parentElement;if(!t)throw new Error("parent container of diff container not found.");const n=t.children[0].querySelectorAll(".phui-header-header").item(0);if(!n||!n.textContent)throw new Error("Could not find diffTitle element, or it had no text content");const r=Pg.exec(n.textContent);if(!r)throw new Error(`diffTitle element does not match pattern. Content: '${n.textContent}'`);return parseInt(r[1],10)}()),r){const e=Ug.exec(r)?.[1];e&&"on"!==e&&(s=parseInt(e,10),console.log(`comparison diffID ${a} baseDiffID ${s}`))}return Kg(o,t,n).pipe($((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:o,diffID:a,baseDiffID:s,mode:kg.Differential}))))}const s=Mg.exec(r);if(s){const e=s[1],r=s[2],o=function(){const e=document.querySelectorAll(".phui-property-list-key");for(const t of e)if("Parents "===t.textContent){const e=t.nextSibling.children[0].children[0].href,n=new URL(e),r=Mg.exec(n.pathname);if(r)return r[2]}throw new Error("Could not determine base commit ID from revision page")}();return Wg(e,t,n).pipe($((({rawRepoName:e})=>({mode:kg.Revision,rawRepoName:e,baseCommitID:o,headCommitID:r}))))}const a=jg.exec(r);if(a){const e=a[8],r=Ig(),o=Rg();return Wg(r,t,n).pipe($((({rawRepoName:t})=>({mode:kg.Change,filePath:e,rawRepoName:t,commitID:o}))))}if(Fg.exec(r)){const e=document.querySelector(".phui-crumbs-view");if(!e)throw new Error("failed parsing changeset dom");const[,r,o]=e.querySelectorAll("a"),i=r.getAttribute("href").match(/D(\d+)/);if(!i)throw new Error("failed parsing differentialID");const s=parseInt(i[1],10),a=o.getAttribute("href").match(/\/differential\/diff\/(\d+)/);if(!a)throw new Error("failed parsing diffID");const l=parseInt(a[1],10);return Kg(s,t,n).pipe($((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:s,diffID:l,mode:kg.Differential}))))}throw new Error(`Could not determine Phabricator state from stateUrl ${r}`)}catch(e){return bt(e)}}function qg(e){let t=e;if(t=t.replace("\\",""),e.startsWith("git@"))t=e.slice("git@".length),t=t.replace(":","/");else if(e.startsWith("git://"))t=e.slice("git://".length);else if(e.startsWith("https://"))t=e.slice("https://".length);else if(e.includes("@")){t=e.split("@")[1],t=t.replace(":","/")}return t.replace(/.git$/,"")}function $g(e,t){const n=function(){const e=document.querySelector(".phabricator-search-menu form");if(!e)throw new Error("cannot create conduit request form");const t=new FormData;return t.set("__csrf__",e.querySelector("input[name=__csrf__]").value),t.set("__form__",e.querySelector("input[name=__form__]").value),t}();for(const[e,r]of Object.entries(t))n.set(`params[${e}]`,JSON.stringify(r));return sr(window.location.origin+e,{method:"POST",body:n,credentials:"include",headers:{Accept:"application/json"},selector:e=>ur(e).json()}).pipe($((e=>{if(null!==e.error_code)throw new Error(`error ${e.error_code}: ${e.error_info}`);return e.result})))}const zg=gs((({diffID:e,revisionID:t,queryConduit:n=$g})=>n("/api/differential.querydiffs",{ids:[e],revisionIDs:[t]}).pipe($((t=>t[String(e)])))),(({diffID:e,revisionID:t})=>`${e}-${t}`)),Vg=gs((({diffID:e,queryConduit:t=$g})=>t("/api/differential.getrawdiff",{diffID:e})),(({diffID:e})=>e.toString())),Hg=gs((({revisionID:e,queryConduit:t=$g})=>t("/api/differential.query",{ids:[e]}).pipe($((t=>{const n=t[0].repositoryPHID;if(!n)throw new Error(`no repositoryPHID for revision ${e}`);return n})))),(({revisionID:e})=>e.toString())),Gg=gs((({requestGraphQL:e,...t})=>e({request:fr`
130
+ `,variables:{...e,source:la.CODEHOSTINTEGRATION,argument:e.argument&&JSON.stringify(e.argument),publicArgument:e.publicArgument&&JSON.stringify(e.publicArgument)},mightContainPrivateInfo:!1}).subscribe({error:e=>{}})})({name:e,userCookieID:await this.getAnonUserID(),url:this.sourcegraphURL,argument:{platform:this.platform,version:this.version,...t},publicArgument:{platform:this.platform,version:this.version,...n}},this.requestGraphQL)}async log(e,t,n){await this.logEvent(e,t,n)}async logViewEvent(e,t){await this.logEvent(`View${e}`,t)}async logPageView(e,t,n){await this.logEvent(`${e}Viewed`,t,n)}}const hp={allowErrorReporting:!1,sendTelemetry:!0,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},mp=({get:e,set:t})=>({set:t,enable:e=>t(e,!0),disable:e=>t(e,!1),async isEnabled(t){const n=await e(t);return"boolean"==typeof n?n:hp[t]},async toggle(n){const r=await e(n);return await t(n,!r),!r}});const gp=mp({get:async function(e){const{featureFlags:t={}}=await vf.sync.get();return t[e]},set:async function(e,t){const{featureFlags:n}=await vf.sync.get("featureFlags");await vf.sync.set({featureFlags:{...n,[e]:t}})}}),bp=mp({get:async e=>{const t=localStorage.getItem(e);return null===t?void 0:"true"===t},set:async(e,t)=>{localStorage.setItem(e,String(t))}}),vp=cf?bp:gp,yp={sendTelemetry:!1,allowErrorReporting:!1,experimentalLinkPreviews:!1,experimentalTextFieldCompletion:!1,clickToGoToDefinition:!1},wp=e=>({...yp,...e}),Ep=()=>(lf?yf("sync","featureFlags"):q(void 0)).pipe($(wp));function _p(e){return Ep().pipe($((t=>t[e])),We())}const xp=e=>hf(e).pipe($((t=>!(pf()&&e)||!bf(t)))),Sp=e=>Ce([xp(e),_p("sendTelemetry")]).pipe($((([e,t])=>!!e||t)));function Cp(){const{host:e,pathname:t}=location,[n,r]=t.slice(1).split("/");if(!n||!r)throw new Uf(`Could not parse repoName from Bitbucket Cloud url: ${location.href}`);return`${e}/${n}/${r}`}const Op={getCodeElementFromTarget:e=>e.closest(".view-line > span"),getLineNumberFromCodeElement:e=>{if(!document.querySelector(".line-number"))throw new Error("No line number elements found on the currently viewed page");const t=e.closest(".react-monaco-editor-container");if(!t)throw new Error("No editor found");const n=e.closest(".view-line"),r=[...t.querySelectorAll(".view-line")].findIndex((e=>e===n)),o=t.querySelectorAll(".line-number")[r];if(o){let e=parseInt(o.dataset.lineNum??"",10);if(!isNaN(e))return e;if(e=parseInt(o.textContent?.trim()??"",10),!isNaN(e))return e}throw new Error("Could not find line number")},getLineElementFromLineNumber:Np,getCodeElementFromLineNumber:(e,t)=>{const n=Np(e,t);if(!n)return null;const r=n.querySelector(":scope > span");return r||console.error(`Could not find code element inside .view-line container for line #${t}`),r}};function Np(e,t){let n=e.querySelector(`[data-line-num="${t}"]`);if(!n)for(const r of e.querySelectorAll(".line-number")){if(parseInt(r.textContent??"",10)===t){n=r;break}}if(!n)return console.error(`Could not find line number element for line #${t}`),null;const r=[...e.querySelectorAll(".line-number")].findIndex((e=>e===n)),o=e.querySelectorAll(".view-line")[r];return o||console.error(`Could not find line element for line #${t}`),o}function kp(e,t,n){const r=e.querySelector(`[aria-label="${"base"===n?"From":"To"} line ${t}"]`)?.closest(".line-wrapper")?.querySelector(".code-component");if(!r)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return r}const Tp={getCodeElementFromTarget:e=>e.closest(".code-diff"),getLineNumberFromCodeElement:e=>{const t=e.closest(".line-wrapper")?.querySelectorAll(".line-number-permalink");if(!t||0===t.length)throw new Error("Could not find line number permalink(s) for code element");const n=t[t.length-1],r=parseInt(n.textContent??"",10);if(!isNaN(r))return r;throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:kp,getCodeElementFromLineNumber:(e,t,n)=>kp(e,t,n)?.querySelector(".code-diff"),getDiffCodePart:e=>{const t=e.closest(".code-component")?.querySelector(".line-type");if(t?.textContent?.includes("+"))return"head";if(t?.textContent?.includes("+"))return"base";if(!e.closest(".side-by-side"))return"head";const n=e.closest(".line-wrapper");if(n?.id)return n?.id.includes("oldline")?"base":"head";return 0===[...n?.parentElement?.childNodes||[]].findIndex((e=>e===n))?"base":"head"},isFirstCharacterDiffIndicator:()=>!1};function Ap(e,t,n){const r=e.querySelector(`[data-${"base"===n?"f":"t"}num="${t}"]`)?.closest(".udiff-line");if(!r)throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`);return r}const Ip={getCodeElementFromTarget:e=>e.closest(".source"),getLineNumberFromCodeElement:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element");const n=t.querySelector(".line-numbers");if(!n)throw new Error("Could not find line numbers element");const r=n?.dataset.tnum;if(r){const e=parseInt(r,10);if(!isNaN(e))return e}const o=n?.dataset.fnum;if(o){const e=parseInt(o,10);if(!isNaN(e))return e}throw new Error("Could not find line number for code element")},getLineElementFromLineNumber:Ap,getCodeElementFromLineNumber:(e,t,n)=>Ap(e,t,n)?.querySelector(".source"),getDiffCodePart:e=>{const t=e.closest(".udiff-line");if(!t)throw new Error("Could not find line element for code element");return t.classList.contains("deletion")?"base":"head"},isFirstCharacterDiffIndicator:()=>!0},Rp=e=>e.replace("//","/"),Pp=["modified","renamed","removed","added"];function Dp(){const e=Cp(),t=location.pathname.match(/src\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]);return{blob:{rawRepoName:e,revision:n,filePath:decodeURIComponent(t[2]),commitID:function(){const e=['a[type="button"]',"a"];for(const t of e){const e=document.querySelectorAll(t);for(const t of e){const e=t.href.match(/full-commit\/([\da-f]{40})\//);if(e)return e[1]}}return null}()??n}}}function Lp(e){const t=Cp(),n=function(e){const t=[...e.querySelectorAll('[data-qa="bk-file__header"] span')];for(const e of t)for(const t of Pp)if(e.textContent?.toLowerCase().includes(t))return t;return"modified"}(e),{base:r,head:o}=function(e,t){const n=e.querySelector('[data-qa="bk-filepath"]')?.cloneNode(!0),r=n?.textContent;if(!(n instanceof HTMLElement&&r))throw new Error("Could not find breadcrumbs component for code view");if("added"===t)return{head:r};if("removed"===t)return{base:r};if("modified"===t)return{base:r,head:r};const o="<>SEPARATOR<>",i=n.querySelectorAll('[aria-label="arrow"]');for(const e of i)e.textContent=o;const[s,a,l]=n.textContent.split(/[{}]/),[c,u]=a.split(o);return{base:Rp(s+c+l),head:Rp(s+u+l)}}(e,n),{baseRevision:i,headRevision:s}=function(){const e=document.querySelector('[data-qa="pr-branches-and-state-styles"]');if(!e)throw new Error("Could not find branches element");const t=[...e.querySelectorAll('[aria-hidden="true"]')];if(2!==t.length)throw new Error("Expected source and destination branch elements");const n=t[0].textContent??"";return{baseRevision:t[1].textContent??"",headRevision:n}}();return"added"===n?{head:{rawRepoName:t,filePath:o,commitID:s,revision:s}}:"removed"===n?{base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}:{head:{rawRepoName:t,filePath:o,commitID:s,revision:s},base:{rawRepoName:t,filePath:r,commitID:i,revision:i}}}function Mp(e){const t=Cp(),n=function(e){const t=e.querySelector(".diff-entry-lozenge");for(const e of Pp)if(t?.textContent?.toLowerCase().includes(e))return e;return"modified"}(e),{head:r,base:o}=function(e,t){const n=e.querySelector(".filename")?.cloneNode(!0);if(!n)throw new Error("Could not find breadcrumbs component for code view");for(const e of n.childNodes)e instanceof HTMLSpanElement&&(e.textContent=null);const r=n.textContent.trim();if("added"===t)return{head:r};if("removed"===t)return{base:r};if("modified"===t)return{base:r,head:r};const[o,i,s]=r.split(/[{}]/).map((e=>e.trim())),[a,l]=i.split("\u2192").map((e=>e.trim()));return{base:Rp(o+a+s),head:Rp(o+l+s)}}(e,n),{baseCommitID:i,headCommitID:s}=function(){const e=document.querySelector('[title="Parent commit"]')?.href.match(/\/commits\/(.*)/);if(!e)throw new Error("Could not determine base commit ID");const t=e[1],n=window.location.href.match(/\/commits\/(.*)/);if(!n)throw new Error("Could not determine head commit ID");return{baseCommitID:t,headCommitID:n[1]}}();return"added"===n?{head:{rawRepoName:t,filePath:r,commitID:s}}:"removed"===n?{base:{rawRepoName:t,filePath:o,commitID:i}}:{head:{rawRepoName:t,filePath:r,commitID:s},base:{rawRepoName:t,filePath:o,commitID:i}}}const jp="codeHost-module__icon_3KtzB",Fp="codeHost-module__commit-container_8Jft-";function Up(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector('[data-testid="file-actions"');if(!n)throw new Error("Unable to find mount location");const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}function Bp(e){const t=e.querySelector(".sg-toolbar-mount");if(t)return t;const n=e.querySelector(".diff-actions");if(!n)throw new Error("Unable to find mount location");n.classList.add(Fp);const r=document.createElement("div");return r.classList.add("sg-toolbar-mount"),n.prepend(r),r}const qp={type:"bitbucket-cloud",name:"Bitbucket Cloud",codeViewResolvers:[{selector:e=>{const t=e.querySelector('[data-qa="bk-file__header"]'),n=e.querySelector('[data-qa="bk-file__content"]');if(!t||!n)return null;let r=t;for(;!r.contains(n);){if(!r.parentElement)return null;r=r.parentElement}return[r]},resolveView:e=>function({pathname:e}){return/\/pull-requests\/\d+/.test(e)}(window.location)?{element:e,getToolbarMount:Up,dom:Tp,resolveFileInfo:Lp}:{element:e,getToolbarMount:Up,dom:Op,resolveFileInfo:Dp}},{selector:".bb-udiff",resolveView:e=>({element:e,getToolbarMount:Bp,dom:Ip,resolveFileInfo:Mp})}],getContext:async function(){const e=Cp();return Promise.resolve({rawRepoName:e,revision:"",privateRepository:!1})},getViewContextOnSourcegraphMount:function(e){const t="open-on-sourcegraph",n=fe(e,'[data-qa="page-header-wrapper"] > div > div');if(!n)return null;let r=n.querySelector("#open-on-sourcegraph");if(r)return r;r=document.createElement("span"),r.id=t;const o=n.childNodes[1]?.childNodes[1].firstChild;return o instanceof HTMLElement?o.append(r):n.append(r),r},check:function(){return"bitbucket.org"===location.hostname},viewOnSourcegraphButtonClassProps:{className:"codeHost-module__open-on-sourcegraph_10lR9",iconClassName:jp},codeViewToolbarClassProps:{className:"codeHost-module__code-view-toolbar_N0wZ1",listItemClass:"codeHost-module__list-item_370zl",actionItemClass:"codeHost-module__code-view-toolbar-action-item_2p6Pr",actionItemPressedClass:"codeHost-module__pressed_1ksxF",actionItemIconClass:jp},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_2e1lQ",closeButtonClassName:"codeHost-module__close_2lJ85",badgeClassName:"codeHost-module__badge_16Tsk",actionItemClassName:"codeHost-module__hover-overlay-action-item_39z-G",iconClassName:jp,contentClassName:"codeHost-module__content_eSBN7"},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},codeViewsRequireTokenization:!0,observeLineSelection:Ae(window,"hashchange").pipe(ae(void 0),$((()=>(e=>{if(e.startsWith("#")&&(e=e.slice(1)),!/^lines-\d+(:\d+)?$/.test(e))return{};const t={},[n,r]=e.slice("lines-".length).split(":");return t.line=parseInt(n,10),r&&(t.endLine=parseInt(r,10)),t})(window.location.hash))))},$p=(e,t)=>n=>s()(e[n],t),zp=/\/projects\/([^/]+)\/repos\/([^/]+)\//;const Vp=(e,t)=>{const n=e.querySelector(`[data-line-number="${t}"]`);if(!n)throw new Error(`Line ${t} not found in code view`);const r=n.closest(".line");if(!r)throw new Error("Could not find line elem for line element");return r},Hp={getCodeElementFromTarget:e=>{const t=e.closest(".CodeMirror-line");return t?t.querySelector('span[role="presentation"]'):null},getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-locator");if(!n)throw new Error("Could not find the line number in a line container");const r=parseInt(n.dataset.lineNumber||"",10);if(isNaN(r))throw new TypeError("data-line-number not set on line number element");return r},getLineElementFromLineNumber:Vp,getCodeElementFromLineNumber:(e,t)=>Vp(e,t).querySelector('.CodeMirror-line span[role="presentation"]')},Gp=(e,t,n)=>{for(const r of e.querySelectorAll(".line-number-"+("head"===n?"to":"from"))){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e)&&e===t){const e=r.closest(".line");if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},Wp={getCodeElementFromTarget:Hp.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest(".line");if(!t)throw new Error("Could not find line containing code element");const n=t.querySelector(".line-number-to");if(n){const e=parseInt((n.textContent||"").trim(),10);if(!isNaN(e))return e}const r=t.querySelector(".line-number-from");if(r){const e=parseInt((r.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getLineElementFromLineNumber:Gp,getCodeElementFromLineNumber:(e,t,n)=>Gp(e,t,n).querySelector('.CodeMirror-line span[role="presentation"]'),getDiffCodePart:e=>{if(!document.querySelector(".side-by-side-diff"))return e.closest(".line").classList.contains("removed")?"base":"head";return e.closest(".diff-editor").previousElementSibling?.classList.contains("segment-connector-column")?"head":"base"},isFirstCharacterDiffIndicator:()=>!1},Qp=(e,t,n)=>{for(const r of e.querySelectorAll(".diff-line-number")){const e=r.textContent?.trim().split(" ")[0];if(!e)continue;const o=parseInt(e,10);if(!isNaN(o)&&o===t){const e=r.closest("tr")?.querySelector(`.diff-line[data-diff-line="${"head"===n?"TO":"FROM"}"]`);if(!e)throw new Error("Could not find lineElem from lineNumElem");return e}}throw new Error(`Could not locate line number element for line ${t}, part: ${String(n)}`)},Kp={getCodeElementFromTarget:e=>e.closest(".diff-line"),getLineNumberFromCodeElement:e=>{const t=e.closest("tr")?.querySelector(".diff-gutter .diff-line-number");if(t){const e=parseInt((t.textContent||"").trim(),10);if(!isNaN(e))return e}throw new Error("Could not find line number element for code element")},getDiffCodePart:e=>{const t=e.closest("tr")?.querySelectorAll(".diff-line");if(!t||0===t.length)throw new Error("Could not find diff lines for code element");if(1===t.length)return e.classList.contains("added-line")?"head":"base";const[n,r]=t;return e===n?"base":e===r?"head":e.classList.contains("removed-line")?"base":"head"},getLineElementFromLineNumber:Qp,getCodeElementFromLineNumber:Qp};var Zp=o(11570),Yp=o.n(Zp);const Jp=(e,t,n)=>`${window.AJS?window.AJS.contextPath():window.location.origin}/rest/api/1.0/projects/${encodeURIComponent(e)}/repos/${t}${n}`,Xp=e=>sr(e,{selector:e=>ur(e).json()}),ed=gs((({project:e,repoSlug:t,prID:n})=>Xp(Jp(e,t,`/pull-requests/${n}`)).pipe($((({fromRef:e,toRef:t})=>({baseCommitID:t.latestCommit,headCommitID:e.latestCommit}))))),(({prID:e})=>e.toString())),td=gs((({project:e,repoSlug:t,commitID:n})=>Xp(Jp(e,t,`/commits/${n}`)).pipe($((({parents:e})=>Yp()(e))),qe(Qn),$((({id:e})=>e)))),(({project:e,repoSlug:t,commitID:n})=>`${e}:${t}:${n}`)),nd=["a.raw-view-link","a.source-view-link","a.mode-source"],rd=({repoSlug:e,project:t})=>[window.location.hostname,t,e].join("/"),od=e=>{const t=[];for(const n of nd)try{const t=e.querySelector(n);if(!t)throw new Error(`Could not find selector ${n} in code view`);const r=new URL(t.href),o=r.pathname,i=o.match(/\/projects\/(.*?)\/repos\/(.*?)\/(?:browse|raw)\/(.*)$/);if(!i)throw new Error(`Path of link matching selector ${n} did not match path regex: ${o}`);const[,s,a,l]=i,c=r.searchParams.get("at");if(!c)throw new Error(`href of link matching selector ${n} did not have 'at' search param: ${r.href}`);const u=c.match(/refs\/heads\/(.*?)$/),f=u?u[1]:c;return{rawRepoName:rd({repoSlug:a,project:s}),filePath:decodeURIComponent(l),revision:f,project:s,repoSlug:a}}catch(e){t.push(e);continue}throw cn(t)},id=(e="a.commitid")=>{const t=document.querySelector(e);if(!t)throw new Error("No element found matching a.commitid");const n=t.dataset.commitid;if(!n)throw new Error("Element matching a.commitid has no data-commitid");return n},sd=e=>{const{rawRepoName:t,filePath:n,revision:r,project:o,repoSlug:i}=od(e);return{rawRepoName:t,filePath:n,revision:r,commitID:(()=>{const e=document.querySelector("span[data-revision-ref]");if(!e)throw new Error("Could not find span[data-revision-ref] element");try{const{latestCommit:t}=JSON.parse(e.dataset.revisionRef);return t}catch{throw new Error("Could not parse JSON from revision selector")}})(),project:o,repoSlug:i}},ad=({codeViewElement:e})=>e.querySelector(".change-type-lozenge"),ld=({changeTypeElement:e})=>{if(!e)return"MODIFY";const t=[...e.classList].find((e=>/^change-type-[A-Z]+/.test(e)));if(!t)throw new Error("Could not detect change type from change type element");return t.replace(/^change-type-/,"")},cd=({filePath:e,changeType:t,changeTypeElement:n})=>{if("ADD"!==t){if("MODIFY"===t||"DELETE"===t)return e;if("MOVE"===t||"RENAME"===t||"COPY"===t){if(!n)throw new Error(`Change type is ${t} but no change type indicator found`);const r=n.getAttribute("original-title");if(!r)throw new Error("Moved change type badge did not have original-title attribute");const o=document.createElement("span");o.innerHTML=r;const i=o.textContent;if("MOVE"===t||"COPY"===t){const e=i.split("\u2192")[0].trim();if(!e)throw new Error(`Unexpected move change type badge content "${i}"`);return e}if("RENAME"===t){const t=/Renamed from '(.+)'/,n=i.match(t);if(!n)throw new Error(`Rename change type badge content did not match ${t.toString()}: "${i}"`);return Il.join(Il.dirname(e),n[1])}}throw new Error(`Unexpected change type "${t}"`)}},ud=e=>{const t=e.querySelector(".breadcrumbs")??e.querySelector(".file-breadcrumbs");if(!t)throw new Error("Could not find diff code view breadcrumbs element through selector .breadcrumbs");const n=t.textContent;if(!n)throw new Error("Unexpected empty file path in breadcrumbs");const r=location.pathname.match(/\/projects\/(.*?)\/repos\/(.*?)\//);if(!r)throw new Error("Location did not match regexp");const[,o,i]=r,s=rd({project:o,repoSlug:i}),a=ad({codeViewElement:e}),l=ld({changeTypeElement:a});return{changeType:l,rawRepoName:s,filePath:n,baseFilePath:cd({changeTypeElement:a,changeType:l,filePath:n})||n,project:o,repoSlug:i}};const fd=e=>{const t=ud(e),{rawRepoName:n,filePath:r,baseFilePath:o}=t,i=function(){const e=window.location.pathname.match(/pull-requests\/(\d*?)\/(diff|overview|commits)/);if(!e)throw new Error(`Could not parse PR ID from pathname: ${window.location.pathname}`);return parseInt(e[1],10)}();return ed({...t,prID:i}).pipe($((({headCommitID:e,baseCommitID:t})=>({head:{rawRepoName:n,filePath:r,commitID:e},base:{rawRepoName:n,filePath:o,commitID:t}}))))},pd="codeHost-module__command-palette-button_1LPsz",dd="codeHost-module__command-palette-popover_wqnFp",hd="codeHost-module__no-results_3Di26",md="codeHost-module__open-on-sourcegraph_i9J2G",gd="codeHost-module__sg-toolbar-mount_2Fbz5",bd="codeHost-module__code-view-toolbar_IVqgq",vd="codeHost-module__action-nav-item_223JV",yd="codeHost-module__action-nav-item-new-diff_23eTl",wd="codeHost-module__action-item-new-diff_3Tuv4",Ed="codeHost-module__hover-action-item_9CC-W",_d="codeHost-module__command-list-popover-button_3eptU",xd=(e,t=".file-toolbar .secondary")=>{const n=e.querySelector(".sg-toolbar-mount");if(n)return n;const r=e.querySelector(t);if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("btn-group"),o.classList.add("sg-toolbar-mount"),o.classList.add(gd),r.prepend(o),o},Sd=e=>({direction:t,codeView:n,position:r})=>{const o=e.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");let i=0;for(const e of o.querySelectorAll("[cm-text]")){const t=e.getAttribute("cm-text")||"",n=e.textContent||"";i+=t.length-n.length}const s=t===jn.ActualToCodeView?-1:1;return q({line:r.line,character:r.character+s*i})},Cd={getToolbarMount:xd,dom:Hp,resolveFileInfo:e=>({blob:sd(e)}),getPositionAdjuster:()=>Sd(Hp)},Od={getToolbarMount:xd,dom:Wp,getPositionAdjuster:()=>Sd(Wp),overrideTokenize:!0},Nd={...Od,resolveFileInfo:e=>{const{changeType:t,rawRepoName:n,filePath:r,commitID:o,baseFilePath:i,revision:s,...a}=(e=>{const{rawRepoName:t,project:n,repoSlug:r,filePath:o}=od(e),i=id(),s=ad({codeViewElement:e}),a=ld({changeTypeElement:s});return{changeType:a,rawRepoName:t,filePath:o,baseFilePath:cd({changeTypeElement:s,changeType:a,filePath:o})||o,commitID:i,project:n,repoSlug:r}})(e);return"ADD"===t?q({head:{rawRepoName:n,filePath:r,commitID:o}}):td({commitID:o,...a}).pipe($((e=>"DELETE"===t?{base:{rawRepoName:n,filePath:i,commitID:e}}:{base:{rawRepoName:n,filePath:i,commitID:e},head:{rawRepoName:n,filePath:r,commitID:o}})))}},kd={...Od,resolveFileInfo:fd},Td={...Od,resolveFileInfo:e=>{const{rawRepoName:t,filePath:n,baseFilePath:r}=ud(e),{baseCommitID:o,headCommitID:i}=function(){const e=document.querySelector("#branch-compare .source-selector a.commitid[data-commitid]"),t=document.querySelector("#branch-compare .target-selector a.commitid[data-commitid]");if(!e||!t)throw new Error("Could not resolve Bitbucket compare diff spec");return{headCommitID:e.getAttribute("data-commitid"),baseCommitID:t.getAttribute("data-commitid")}}();return{base:{rawRepoName:t,filePath:r,commitID:i},head:{rawRepoName:t,filePath:n,commitID:o}}}},Ad={...Od,resolveFileInfo:e=>(e=>{const t=id(".commit-badge-oneline .commitid"),n=id(".commit-parents .commitid"),{rawRepoName:r,filePath:o,baseFilePath:i}=ud(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}})(e)},Id={selector:".change-view",resolveView:e=>({element:e,...Rd})},Rd={resolveFileInfo:fd,getToolbarMount:e=>xd(e,".change-header .diff-actions"),toolbarButtonProps:{listItemClass:yd,actionItemClass:wd},dom:Kp};const Pd="aui-icon",Dd={[gc]:"aui-message aui-message-info",[bc]:"aui-message aui-message-success",[mc]:"aui-message aui-message-info",[hc]:"aui-message aui-message-warning",[dc]:"aui-message aui-message-error"},Ld={type:"bitbucket-server",name:"Bitbucket Server",check:()=>!!document.querySelector(".bitbucket-header-logo")||!!document.querySelector(".aui-header-logo.aui-header-logo-bitbucket"),codeViewResolvers:[{selector:".file-content",resolveView:e=>{const t=e.querySelector(".content-view");if(!t)return null;if(document.querySelector("#branch-compare"))return{element:e,...Td};if((({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/commits\/\w+$/.test(e))(window.location))return{element:e,...Ad};if(e.querySelector(".mode-toggle")){return t.classList.contains("diff-view")?{element:e,...Nd}:{element:e,...Cd}}return(({pathname:e})=>/\/projects\/[^/]+\/repos\/[^/]+\/pull-requests\/\d+/.test(e))(window.location)?{element:e,...kd}:(console.error("Unknown code view",e),null)}},Id],getCommandPaletteMount:e=>{const t=fe(e,".aui-header-primary .aui-nav");if(!t)return null;const n=["command-palette-button",pd];return t.querySelector(n.map((e=>`.${e}`)).join(""))||(()=>{const e=document.createElement("li");return e.className=n.join(" "),t.append(e),e})()},notificationClassNames:Dd,commandPaletteClassProps:{buttonClassName:s()(_d,"aui-alignment-target aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),buttonElement:"a",buttonOpenClassName:"aui-dropdown2-active active aui-alignment-enabled",showCaret:!1,popoverClassName:s()(dd,"aui-dropdown2 aui-style-default aui-layer aui-dropdown2-in-header aui-alignment-element aui-alignment-side-bottom aui-alignment-snap-left aui-alignment-enabled aui-alignment-abutted aui-alignment-abutted-left aui-alignment-element-attached-top aui-alignment-element-attached-left aui-alignment-target-attached-bottom aui-alignment-target-attached-left"),popoverInnerClassName:"aui-dropdown2-section",formClassName:"aui",inputClassName:"text",resultsContainerClassName:"results",listClassName:"results-list",listItemClassName:"result",selectedListItemClassName:"focused",noResultsClassName:hd,iconClassName:Pd},codeViewToolbarClassProps:{className:s()(bd,"aui-buttons"),actionItemClass:"aui-button",actionItemIconClass:"aui-icon",listItemClass:vd},hoverOverlayClassProps:{className:"aui-dialog",actionItemClassName:s()("aui-button",Ed),getAlertClassName:$p(Dd),iconClassName:Pd},getViewContextOnSourcegraphMount:function(e){const t=fe(e,".branch-selector-toolbar .aui-buttons");if(!t)return null;const n=t.querySelector("#open-on-sourcegraph");if(n)return n;const r=document.createElement("span");return r.id="open-on-sourcegraph",r.className=md,t.append(r),r},getContext:async function(){const e=function(e){const{hostname:t,pathname:n}=e,r=n.match(zp);if(!r)throw new Error(`location pathname does not match path regex: ${n}`);const[,o,i]=r;return{rawRepoName:`${t}/${o}/${i}`}}(window.location);let t={};try{t=function(){const e=document.querySelector("#repository-layout-revision-selector .name[data-revision-ref]");if(!e)throw new Error("branchNameElement not found");const t=e.getAttribute("data-revision-ref");let n=null;if(t)try{n=JSON.parse(t)}catch{throw new Error(`Could not parse revisionRefStr: ${t}`)}if(n?.latestCommit)return{revision:n.latestCommit};throw new Error(`revisionRefInfo is empty or has no latestCommit (revisionRefStr: ${String(t)})`)}()}catch{}return Promise.resolve({...e,...t,privateRepository:"bitbucket.org"!==window.location.hostname})},viewOnSourcegraphButtonClassProps:{className:"aui-button",iconClassName:Pd},codeViewsRequireTokenization:!1,observeLineSelection:Ae(window,"hashchange").pipe(ae(void 0),$((()=>(e=>{if(e.startsWith("#")&&(e=e.slice(1)),!/^\d+(-\d+)?$/.test(e))return{};const t={},[n,r]=e.split("-");return t.line=parseInt(n,10),r&&(t.endLine=parseInt(r,10)),t})(window.location.hash))))};var Md=o(65291),jd=o.n(Md),Fd=o(92674),Ud=o.n(Fd),Bd=o(26416),qd=o.n(Bd);function $d(e){return new M((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?Y(n):Te()).subscribe(t)}))}function zd(e){return t=>$d((()=>{const n=new Map;return t.pipe(wt(Me),ie(),tt((({removedNodes:e})=>{for(const t of e){if(!(t instanceof HTMLElement))continue;const e=n.get(t);if(e)e.subscriptions.unsubscribe(),n.delete(t);else for(const[e,r]of n.entries())t.contains(e)&&(r.subscriptions.unsubscribe(),n.delete(e))}})),te((t=>Y(t.addedNodes).pipe(qe(Wn(HTMLElement)),te((t=>Y(e).pipe(te((({selector:e,resolveView:n})=>[...Vd(t,e)].map((e=>{const t=n(e);return t&&{...t,subscriptions:new g}})))),qe(Qn),qe((e=>!n.has(e.element))),tt((e=>{n.set(e.element,e)})))))))))}))}function Vd(e,t){if("string"==typeof t)return ue(e,t);return t(e)||[]}const Hd=/patchset (\d+)/i;function Gd(e,t){return`refs/changes/${e.slice(-2).padStart(2,"0")}/${e}/${t}`}function Wd(e){return rh(document.body,e)?.textContent??void 0}function Qd(e){const t=Hd.exec(e);if(t?.[1])return t[1]}function Kd(){const e=new URL(window.location.href).pathname.split("/"),t=e.indexOf("c"),n=e.indexOf("+"),r=e.slice(t+1,n).join("/"),o=e[n+1],i=e[n+2],s=e.slice(n+3).join("/"),a=window.location.hostname+"/"+r,{basePatchsetId:l,headPatchsetId:c}=function(){const e=Wd("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #basePatchDropdown >> #triggerText")??Wd("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #basePatchDropdown >> #triggerText"),t=Wd("#app >> #app-element >> gr-change-view >> #fileListHeader >> #rangeSelect >> #patchNumDropdown >> #triggerText")??Wd("#app >> #app-element >> gr-diff-view >> #rangeSelect >> #patchNumDropdown >> #triggerText");return{basePatchsetId:e&&Qd(e),headPatchsetId:t&&Qd(t)}}();return{repoName:a,changeId:o,patchsetId:c||i,filePath:s,basePatchsetId:l}}const Zd={selector(e){if(e.matches("#diffTable"))return[e];const t=rh(document,"#app >> #app-element >> gr-change-view >> #fileList")?.shadowRoot?.querySelectorAll(".file-row.expanded"),n=[...t||[]].map((e=>{const t=e.parentElement;if(t)return rh(t,"gr-diff-host >> gr-diff >> #diffTable")}));return qd()(n)},resolveView(e){const t=oh(e,".stickyArea");if(!t)return null;const n=t.querySelector(".file-row")?.getAttribute("data-path");if(!n)return null;const r=Kd();if(!r.patchsetId)return console.error("Sourcegraph: Cannot get Gerrit patchset ID"),null;const o=Gd(r.changeId,r.patchsetId);let i;return i=r.basePatchsetId?Gd(r.changeId,r.basePatchsetId):function(){const e=rh(document.body,"#app >> #app-element >> gr-change-view >> #metadata >> gr-commit-info");if(!e)return null;return e?.shadowRoot?.querySelector(".container")?.textContent?.trim()}()||o+"^",sh(e),{element:e,dom:Jd,resolveFileInfo(){const e={base:{filePath:n||"",rawRepoName:r.repoName,commitID:i},head:{filePath:n||"",rawRepoName:r.repoName,commitID:o}};return console.log("resolveFileListCodeView: fileInfo",e),e}}}},Yd=(e,t,n)=>{const r="head"===n?"right":"left",o=e.querySelector(`td.lineNum.${r}[data-value="${t}"]`);if(!o)return null;const i=function(e,t){const n=[...e.parentElement?.childNodes||[]],r=n.slice(n.indexOf(e)+1);for(const e of r)if(e instanceof HTMLElement&&e.matches(t))return e;return null}(o,"td.content")?.querySelector(".contentText");return i},Jd={getLineElementFromLineNumber:Yd,getCodeElementFromLineNumber:Yd,getCodeElementFromTarget:e=>{const t=e.closest("td.content"),n=t?.closest("tr")?.querySelector("[data-line-number]");if(n){if("FILE"===n.getAttribute("data-line-number"))return null}return t},getLineNumberFromCodeElement:e=>{const t=nh(e);if(!t)throw console.error(e),new TypeError("Could not find line number (no side)");const n=e.closest("td")?.parentElement?.querySelector(`.lineNum.${t}`),r=n?.getAttribute("data-value");if(!r)throw new TypeError(`Could not find line number (${t})`);return parseInt(r,10)},getDiffCodePart:e=>{const t=nh(e);return"left"===t?"base":"right"===t?"head":(console.error("Cannot tell: base or head"),"base")}},Xd=[{selector(e){const t=rh(document.body,"#app >> #app-element >> gr-diff-view >> #diffHost >> #diff >> #diffTable");return t?[t]:[]},resolveView(e){const t=Kd();if(!t.patchsetId)return console.error("Sourcegraph: cannot find patchset ID"),null;const n=Gd(t.changeId,t.patchsetId);let r=n+"^";return t.basePatchsetId&&(r=Gd(t.changeId,t.basePatchsetId)),sh(e),{element:e,dom:Jd,getToolbarMount(e){const t=function(e){const t=oh(e,"gr-diff-view")?.shadowRoot?.querySelector("gr-fixed-panel .subHeader");return t}(e)?.querySelector(".patchRangeLeft");if(!t)throw new Error("Could not find subheader");const n=t.querySelector(".sourcegraph-toolbar-mount");if(n)return n;const r=document.createElement("div");return r.classList.add("sourcegraph-toolbar-mount"),t.append(r),t.append(ih(ah)),r},resolveFileInfo(){const e={base:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:r},head:{filePath:t.filePath||"",rawRepoName:t.repoName,commitID:n}};return console.log("resolveFilePageCodeView: fileInfo",e),e}}}},Zd],eh={type:"gerrit",name:"Gerrit",codeViewResolvers:Xd,contentViewResolvers:[],nativeTooltipResolvers:[],codeViewsRequireTokenization:!0,observeMutations:(e,t,n)=>{let r=[];return Tf(1500).pipe($((()=>{const{filePath:e=""}=Kd(),t=[...Xd.map((e=>e.selector)),th].map((e=>[...Vd(document.body,e)])).flat(),n=t.filter((t=>!Ud()(r,{element:t,filePath:e}))),o=r.filter((n=>!(n.filePath===e&&t.find((e=>e===n.element)))));for(const t of n)r.push({element:t,filePath:e});return r=r.filter((e=>!Ud()(o,e))),{addedNodes:n,removedNodes:o.map((e=>e.element))}})),qe((({addedNodes:e,removedNodes:t})=>!!e.length||!!t.length)),$((e=>[e])),hs(),jt())},getContext:async()=>{const{repoName:e,changeId:t,patchsetId:n}=Kd();return Promise.resolve({privateRepository:!0,rawRepoName:e,revision:n&&Gd(t,n)})},check:function(){return!!document.querySelector("gr-app#app")},notificationClassNames:{1:"",2:"",3:"",4:"",5:""},hoverOverlayClassProps:{className:"codeHost-module__hover-overlay_1jwSd"},codeViewToolbarClassProps:{className:"code-view-toolbar--gerrit",actionItemIconClass:"icon--gerrit"},viewOnSourcegraphButtonClassProps:{className:"open-on-sourcegraph--gerrit",iconClassName:"open-on-sourcegraph-icon--gerrit"},getViewContextOnSourcegraphMount:e=>{const t=jd()(th(e));if(!t)return null;const n=t.querySelector(".open-in-sourcegraph-mount");if(n)return n;const r=document.createElement("gr-button");return r.setAttribute("link","link"),r.classList.add("open-in-sourcegraph-mount"),t.prepend(r),t.append(ih(ah)),r}},th=()=>{const e=rh(document.body,"#app >> #app-element >> gr-change-view >> #actions >> #secondaryActions");return e?[e]:null};function nh(e){if("unified"===function(e){return e.closest("tr")?.matches(".unified")?"unified":"side-by-side"}(e)){const t=e.closest("tr")?.querySelector("td.right")?.getAttribute("data-value");return t?"right":"left"}return e.closest("td")?.previousElementSibling?.matches(".right")?"right":"left"}function rh(e,t){"string"==typeof t&&(t=t.split(">>"));let n=e;const r=t.slice(0,-1),o=t[t.length-1];for(const e of r){if(!n)return null;n=n.querySelector(e)?.shadowRoot||null}return n?.querySelector(o)}function oh(e,t){for(;;){const n=e.closest(t);if(n)return n;if(e=e.getRootNode()?.host,!e||e===document.getRootNode())return null}}function ih(e){const t=document.createElement("style");return t.textContent=e,t}function sh(e){if(!e.querySelector("style.sourcegraph-injected-style")){const t=ih(lh);t.classList.add("sourcegraph-injected-style"),e.append(t)}}const ah="\n.icon--gerrit {\n height: 1.3rem;\n width: 1.3rem;\n padding: 5px 4px;\n}\n.open-on-sourcegraph-icon--gerrit {\n height: 1rem;\n width: 1rem;\n}\n.open-on-sourcegraph--gerrit {\n text-decoration: none;\n}\n",lh="\n.sourcegraph-document-highlight {\n background-color: var(--secondary);\n}\n.selection-highlight {\n background-color: var(--mark-bg);\n}\n";var ch=o(36021),uh=o.n(ch);const fh=(e,t)=>({selector:e,resolveView:e=>({...t,element:e})}),ph=(e,t,n)=>((e,t)=>{const{repoName:n,commitID:r}=e;return zf({repoName:n,revision:r,requestGraphQL:t}).pipe(Vf())})(e,n).pipe(Ve((()=>Hf({repoName:e.repoName,filePath:e.filePath,commitID:e.commitID,requestGraphQL:n}))),$((t=>t?{...e,content:t.join("\n")}:{...e})),at((n=>Y(t(n)).pipe(Ve((t=>{if(t)return q(e);throw n}))))));function dh(){return Yn(Xa(window.location.hash))}function hh(){return Ae(window,"hashchange").pipe($(dh),We(((e,t)=>de()(e,t))))}function mh(e){const t=e.title.split(" \u2192 ");return t.length>1?{headFilePath:t[1],baseFilePath:t[0]}:{headFilePath:t[0],baseFilePath:t[0]}}function gh(e){const{pageType:t}=Eh();if(!wh(t))return null;let n="",r="";if("pull"===t){const t=document.querySelector("details-menu[src*='sha1='][src*='sha2=']")?.getAttribute("src"),o=e.classList.contains("js-comment-container");if(t){const e=new URLSearchParams(t),n=e.get("sha1"),r=e.get("sha2");if(n&&r)return{baseCommitID:n,headCommitID:r}}else if(o){const t=function(e){const t=e.querySelector(`summary a[href^="${location.pathname}"`);if(!t)return null;const n=t.href.match(bh);if(!n)return null;const r=n[3],o=vh(document.documentElement.innerHTML,!0);return r&&o?{...o,headCommitID:r}:null}(e);if(t)return t}else{const e=document.querySelector('input[name="comparison_start_oid"]');e&&(n=e.value);const t=document.querySelector('input[name="comparison_end_oid"]');t&&(r=t.value)}}else if("commit"===t){const e=document.querySelectorAll(".sha-block:not(.patch-diff-links)");if(e&&2===e.length){const t=e[0].querySelector("a");t&&(n=t.href.split("/").slice(-1)[0]);const o=e[1].querySelector("span.sha");o&&(r=o.innerHTML)}}else if("compare"===t){const e=function(){const[e,t]=document.querySelectorAll(".commitish-suggester .select-menu-button span");if(e&&t&&e.textContent&&t.textContent)return{baseCommitID:e.textContent,headCommitID:t.textContent};return}();if(e)return e}return""===n||""===r?vh(document.documentElement.innerHTML,"pull"===t):{baseCommitID:n,headCommitID:r}}const bh=/\/files\/((\w+)\.\.)?(\w+)#diff-\w+$/;function vh(e,t){if(!t)return null;const n="\x3c!-- base sha1: &quot;",r=e.indexOf(n);if(-1===r)return null;const o="\x3c!-- head sha1: &quot;",i=e.indexOf(o,r);if(-1===i)return null;return{baseCommitID:e.slice(r+n.length,40),headCommitID:e.slice(i+o.length,40)}}function yh(){const e=document.querySelector("a.js-permalink-shortcut");if(!e)throw new Error("Unable to determine the file path because no a.js-permalink-shortcut element was found.");const t=new URL(e.href),[,,,n,,...r]=t.pathname.split("/");if("tree"!==n&&0===r.length)throw new Error(`Unable to determine the file path because the a.js-permalink-shortcut element's href's path was ${t.pathname} (it is expected to be of the form /<user>/<repo>/blob/<commitID>/<path/to/file>).`);return decodeURIComponent(r.join("/"))}function wh(e){switch(e){case"commit":case"pull":case"compare":return!0;default:return!1}}function Eh(e=window.location){const{host:t,pathname:n}=e,[r,o,i,...s]=n.slice(1).split("/");if(!r||!o)throw new Uf(`Could not parse repoName from GitHub url: ${e.href}`);const a=`${r}/${o}`,l=`${t}/${a}`;switch(i){case"blob":case"tree":return{pageType:i,rawRepoName:l,revisionAndFilePath:decodeURIComponent(s.join("/")),repoName:a};case"pull":case"commit":case"compare":return{pageType:i,rawRepoName:l,repoName:a};default:return{pageType:"other",rawRepoName:l,repoName:a}}}const _h=e=>{let t=e.closest("td").previousElementSibling;for(;t;){if(t.dataset.lineNumber)return parseInt(t.dataset.lineNumber,10);t=t.previousElementSibling}throw new Error("Could not find a line number in any cell")},xh=e=>{const t=e.closest("td.blob-code");return!t||t.parentElement?.classList.contains("js-expandable-line")?null:t},Sh=(e,t,n)=>{const r=Ih(e),o=((e,t)=>"base"===e?0:t?2:1)(n,r)+1,i=e.querySelector(`td:nth-child(${o})[data-line-number="${t}"]`);if(!i)return null;if(!r&&"base"===n&&!i.classList.contains("blob-num-addition")&&!i.classList.contains("blob-num-deletion"))return null;let s;if(r)s=i.nextElementSibling;else{s=i.parentElement.lastElementChild}return s},Ch=e=>e.classList.contains("blob-code-inner")?e:e.querySelector(".blob-code-inner"),Oh={getCodeElementFromTarget:e=>{const t=xh(e);return t&&Ch(t)},getLineElementFromLineNumber:Sh,getCodeElementFromLineNumber:(e,t,n)=>{const r=Sh(e,t,n);return r&&Ch(r)},getLineNumberFromCodeElement:_h,getDiffCodePart:e=>{const t=e.closest("td");return t.classList.contains("blob-code-addition")?"head":t.classList.contains("blob-code-deletion")||Ih(e)&&t.nextElementSibling?"base":"head"},isFirstCharacterDiffIndicator:e=>{const t=e.closest(".blob-code-inner"),n=t&&["deletion","context","addition"].some((e=>t.classList.contains("blob-code-marker-"+e))),r=e.closest("tr")?.querySelector("td[data-code-marker]"),o=t?.hasAttribute("data-code-marker"),i=r||o,s=e.closest(".refined-github-diff-signs");return!n&&!i&&!s}},Nh=(e,t)=>{const n=e.querySelector(`td[data-line-number="${t}"]`);return n&&n.nextElementSibling},kh={getCodeElementFromTarget:xh,getCodeElementFromLineNumber:Nh,getLineElementFromLineNumber:Nh,getLineNumberFromCodeElement:_h},Th=(e,t)=>{const n=((e,t)=>{const n=e.querySelectorAll("td.blob-num");let r=null;for(const e of n)if(e.querySelector("a").href.endsWith(`#L${t}`)){r=e;break}return r})(e,t);return n&&n.nextElementSibling},Ah={getCodeElementFromTarget:xh,getCodeElementFromLineNumber:Th,getLineElementFromLineNumber:Th,getLineNumberFromCodeElement:e=>{const t=e.closest("td").previousElementSibling;return parseInt(t.firstElementChild.textContent,10)}};function Ih(e){const{pageType:t}=Eh();if(!wh(t))return!1;const n=e.classList.contains("file")?e:e.closest(".file");if(!n)throw new Error("Could not resolve code view element");if(n.classList.contains("js-comment-container"))return!1;const r=n.querySelector("table");if(!r)throw new Error("Could not find code view table");return r.classList.contains("js-file-diff-split")||r.classList.contains("file-diff-split")}const Rh=()=>{const e=Eh();if("blob"!==e.pageType&&"tree"!==e.pageType)throw new Error(`Current URL does not match a blob or tree url: ${window.location.href}`);const{revisionAndFilePath:t,rawRepoName:n}=e,r=yh(),o=r&&!r.startsWith("/")?`/${r}`:r,i=o?t.slice(0,-o.length):t;if(!t.endsWith(o))throw new Error(`The file path ${o} should always be a suffix of revAndFilePath ${t}, but isn't in this case.`);return{blob:{rawRepoName:n,filePath:r,revision:i,commitID:le({selector:".js-permalink-shortcut",hrefRegex:/^\/.*?\/.*?\/(?:blob|tree)\/([\da-f]{40})/})}}},Ph=/\/([\da-f]{40})$/i,Dh=e=>{const t=e.querySelector("a.commit-tease-sha");if(!t)throw new Error("Could not find commit link in snippet code view");const n=t.href.match(Ph);if(!n?.[1])throw new Error(`Could not parse commitID from snippet commit link href: ${t.href}`);const r=n[1],o=e.querySelectorAll("a:not(.commit-tease-sha)"),i=new URL(o[0].href),s=Eh(i);if("blob"!==s.pageType)throw new Error(`Snippet URL does not match a blob url: ${i.href}`);const{revisionAndFilePath:a,rawRepoName:l}=s;if(!a.startsWith(r))throw new Error(`Could not parse filePath: revAndFilePath ${a} does not start with commitID ${r}`);return{blob:{rawRepoName:l,filePath:a.slice(r.length+1),commitID:r,revision:r}}},Lh=["tooltipped","tooltipped-n"];const Mh="codeHost-module__command-palette-popover_xVrp2",jh="codeHost-module__command-palette-action-item_16BFG",Fh="codeHost-module__action-item_7QWb2",Uh="codeHost-module__icon_3PdA7",Bh="codeHost-module__code-view-toolbar_gOzAp",qh="codeHost-module__code-view-toolbar-item_2fTzz",$h="codeHost-module__hover-overlay-badge_3wpZt";function zh(e){const t="github-file-actions-toolbar-mount",n=e.querySelector("."+t);if(n)return n;const r=document.createElement("div");r.className=t;const o=e.querySelector(".file-actions");if(!o)throw new Error("Could not find GitHub file actions with selector .file-actions");o.classList.add("sg-github-file-actions");const i=e.querySelector(".show-file-notes");return i?i.after(r):o.prepend(r),r}const Vh={dom:Oh,getToolbarMount:zh,resolveFileInfo:e=>{const{rawRepoName:t}=Eh(),{headFilePath:n,baseFilePath:r}=function(e){const t=e.querySelector(".file-info");if(t){if("A"===t.tagName)return mh(t);const e=t.querySelector(".diffstat + a");if(e)return mh(e)}const n=e.querySelector(".file-header a");if(n)return mh(n);throw new Error("Could not determine diff file name")}(e);if(!n)throw new Error("cannot determine file path");const o=gh(e);if(!o)throw new Error("cannot determine delta info");const{headCommitID:i,baseCommitID:s}=o;return{head:{rawRepoName:t,filePath:n,commitID:i,revision:i},base:{rawRepoName:t,filePath:r||n,commitID:s,revision:s}}},getScrollBoundaries:e=>{const t=e.querySelector(".file-header");if(!t)throw new Error("Could not find .file-header element in GitHub PR code view");return[t]}},Hh={...Vh,getToolbarMount:void 0},Gh={dom:kh,getToolbarMount:zh,resolveFileInfo:Rh,getSelections:dh,observeSelections:hh},Wh=e=>({direction:t,codeView:n,position:r})=>Hf({...r,requestGraphQL:e}).pipe($((e=>{const o=kh.getCodeElementFromLineNumber(n,r.line,r.part);if(!o)throw new Error("(adjustPosition) could not find code element for line provided");const i=e[r.line-1],s=o.textContent||"",a=i.length-uh()(i).length,l=s.length-uh()(s).length,c=t===jn.ActualToCodeView?-1:1,u=Math.abs(a-l)*c;return{line:r.line,character:r.character+u}}))),Qh=fh(".code-list-item",{dom:Ah,getPositionAdjuster:Wh,resolveFileInfo:Dh}),Kh={dom:kh,resolveFileInfo:Dh,getPositionAdjuster:Wh},Zh=e=>{const t="sourcegraph-github-file-code-view-toolbar-mount",n=e.querySelector(`.${t}`);if(n)return n;const r=document.createElement("div");r.style.display="inline-flex",r.style.verticalAlign="middle",r.style.alignItems="center",r.className=t;const o=e.querySelector("#raw-url")?.closest(".BtnGroup");if(!o?.parentNode)throw new Error("File actions not found");return o.parentNode.insertBefore(r,o),r},Yh={selector:".js-file-line-container",resolveView:e=>{const t=e.closest(".blob-wrapper-embedded");if(t){return{element:t.parentElement,...Kh}}const{pageType:n}=Eh();if("blob"!==n)return null;const r=e.closest(".repository-content")||e.closest("#repo-content-turbo-frame");if(!r)throw new Error("Could not find repository content element");return{element:r,...Gh,getToolbarMount:Zh}}},Jh={selector:e=>{const t=new Set;for(const n of ue(e,".file"))0===n.querySelectorAll(".js-diff-load-container").length&&t.add(n);for(const n of ue(e,".js-blob-wrapper")){const e=n.closest(".file");e instanceof HTMLElement&&t.add(e)}return[...t]},resolveView:e=>{if(e.querySelector("article.markdown-body"))return null;if(e.closest(".js-suggested-changes-blob"))return null;const{pageType:t}=Eh();return"blob"===t&&1===document.querySelectorAll(".file").length&&0===document.querySelectorAll(".diff-view").length?{element:e,...Gh}:e.closest(".discussion-item-body")||e.classList.contains("js-comment-container")?{element:e,...Hh}:{element:e,...Vh}}};function Xh(){const e=document.head.querySelector('meta[property="og:site_name"]');return!!e&&("GitHub Enterprise"===e.content||"GitHub"===e.content)&&document.body.classList.contains("enterprise")}const em="open-on-sourcegraph",tm=s()(Uh,"v-align-text-bottom"),nm={[gc]:"flash",[bc]:"flash flash-success",[mc]:"flash",[hc]:"flash flash-warn",[dc]:"flash flash-error"},rm={searchViewResolver:{selector:'.js-site-search-form input[type="text"][aria-controls="jump-to-results"]',resolveView:e=>({element:e})},resultViewResolver:{selector:"#jump-to-suggestion-search-global",resolveView:e=>({element:e})},onChange:({value:e,searchURL:t,resultElement:n})=>{const r="#jump-to-sourcegraph-search-global";(n=>{const r=n.querySelector(".jump-to-suggestion-name");r.textContent=e,r.setAttribute("aria-label",e);const o=n.querySelector("a"),i=new URL(t);i.searchParams.append("q",e),o.setAttribute("href",i.href),o.setAttribute("target","_blank"),n.setAttribute("style","display: "+(e?"initial":"none !important"))})(document.querySelector(r)??(()=>{const e=n.cloneNode(!0);e.id=r.replace("#",""),e.classList.remove("navigation-focus"),e.setAttribute("aria-selected","false");const t=document.createElement("img");t.src="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNTIgNTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTMwLjggNTEuOGMtMi44LjUtNS41LTEuMy02LTQuMUwxNy4yIDYuMmMtLjUtMi44IDEuMy01LjUgNC4xLTZzNS41IDEuMyA2IDQuMWw3LjYgNDEuNWMuNSAyLjgtMS40IDUuNS00LjEgNnoiIGZpbGw9IiNGRjU1NDMiLz48cGF0aCBkPSJNMTAuOSA0NC43QzkuMSA0NSA3LjMgNDQuNCA2IDQzYy0xLjgtMi4yLTEuNi01LjQuNi03LjJMMzguNyA4LjVjMi4yLTEuOCA1LjQtMS42IDcuMi42IDEuOCAyLjIgMS42IDUuNC0uNiA3LjJsLTMyIDI3LjNjLS43LjYtMS42IDEtMi40IDEuMXoiIGZpbGw9IiNBMTEyRkYiLz48cGF0aCBkPSJNNDYuOCAzOC4xYy0uOS4yLTEuOC4xLTIuNi0uMkw0LjQgMjMuOGMtMi43LTEtNC4xLTMuOS0zLjEtNi42IDEtMi43IDMuOS00LjEgNi42LTMuMWwzOS43IDE0LjFjMi43IDEgNC4xIDMuOSAzLjEgNi42LS42IDEuOC0yLjIgMy0zLjkgMy4zeiIgZmlsbD0iIzAwQ0JFQyIvPjwvc3ZnPgo=",t.setAttribute("style","width: 16px; height: 20px; float: left; margin-right: 2px;"),t.setAttribute("alt","Sourcegraph Logo Image");const o=e.querySelector(".js-jump-to-badge-search-text-global");return o.textContent="Sourcegraph",o.parentNode?.insertBefore(t,o),n.parentNode?.insertBefore(e,n.nextElementSibling),e})())}},om=async(e,t=ff.fetchCache,n="#repository-container-header h2 span.Label")=>{if("github.com"!==window.location.hostname)return Promise.resolve(!0);try{const{status:n}=await t({url:`https://github.com/${e}`,credentials:"omit",cacheMaxAge:36e5});return 200!==n}catch(e){return console.warn("Failed to fetch if the repository is private.",e),"public"!==document.querySelector(n)?.textContent?.toLowerCase().trim()}},im=()=>"/search"===window.location.pathname,sm=()=>"/search/advanced"===window.location.pathname,am=()=>!im()&&window.location.pathname.endsWith("/search"),lm=()=>Boolean(new URLSearchParams(window.location.search).get("q"))&&!sm(),cm=()=>{const e=new URLSearchParams(window.location.search).get("type");return e?e.toLowerCase():""},um=e=>{const t=e.filter(Boolean).map((e=>e.trim())),n=(()=>{switch(cm()){case"repositories":return"repo";case"commits":return"commit";case"code":return"";default:return im()||sm()?"repo":""}})(),r=new URLSearchParams(window.location.search).get("l");if(n&&t.push(`type:${n}`),r&&t.push(`lang:${encodeURIComponent(r)}`),am()){const[e,n]=window.location.pathname.split("/").filter(Boolean);t.push(`repo:${e}/${n}$`)}for(const e of["org","user"]){const n=t.findIndex((t=>t.startsWith(`${e}:`)));if(n>=0){const r=t[n].replace(`${e}:`,"");r&&(t[n]=`repo:${r}/*`)}}return t.join("+")},fm=(e,t="")=>{let n=document.querySelector(`#${e}`);return n||(n=document.createElement("div"),n.setAttribute("id",e),n.classList.add(...t.split(/\s/gi)),n)};const pm={type:"github",name:Xh()?"GitHub Enterprise":"GitHub",searchEnhancement:rm,enhanceSearchPage:function(e){if(!(im()||sm()||am()||lm()))return;const t=({container:t,className:n="",getSearchQuery:r,utmCampaign:o})=>{const i=nf(new URL("/search",e),{utm_source:mf(),utm_campaign:o});(0,me.s)(t).render((0,u.jsx)(If,{label:"Search on Sourcegraph",title:"Search on Sourcegraph to get hover tooltips, go to definition and more",ariaLabel:"Search on Sourcegraph to get hover tooltips, go to definition and more",className:s()("btn","m-auto",n),iconClassName:s()("mr-1","v-align-middle",Uh),href:i.href,dataTestId:"search-on-sourcegraph",onClick:e=>{const t=um(r());e.target.href=`${i.href}${t?`&q=${t}`:""}`}}))};if(lm()){const e=cm();if(["repositories","commits","code"].includes(e)||""===e&&(im()||am())){const e=document.querySelector(".application-main form.js-site-search-form"),n=e?.querySelector("input.form-control[name='q']"),r=e?.parentElement?.parentElement?.querySelector("button[type='submit']");if(n&&r){const e=fm("pageSearchFormSourcegraphButton","ml-2 d-none d-md-block");r.after(e),t({container:e,utmCampaign:"github-search-results-page",getSearchQuery:()=>n.value.split(" ")})}const o=document.querySelector("header form.js-site-search-form input.form-control[name='q']"),i=document.querySelector(".codesearch-results"),s=i?.querySelector(".blankslate"),a=i?.querySelector("div > div > h3");if(o&&(s||a)){const e=fm("headerSearchInputSourcegraphButton","ml-auto d-none d-lg-block");s?(e.classList.add("mt-2"),s.append(e)):a&&(e.classList.add("mr-2"),a.after(e)),t({container:e,className:s?"":"btn-sm",utmCampaign:"github-search-results-page",getSearchQuery:()=>o.value.split(" ")})}}return}const n=document.querySelector("#search_form"),r=n?.querySelector(".search-form-fluid"),o=n?.querySelector("input");if(r&&o){const e=fm("searchInputSourcegraphButton","ml-0 ml-md-2 mt-2 mt-md-0");r?.append(e),t({container:e,utmCampaign:`github-${sm()?"advanced":"simple"}-search-page`,getSearchQuery:()=>o.value.split(" ")})}},codeViewResolvers:[Jh,Yh,Qh],contentViewResolvers:[{selector:".markdown-body",resolveView:e=>({element:e})}],nativeTooltipResolvers:[{selector:".js-tagsearch-popover",resolveView:e=>({element:e})}],routeChange:e=>e.pipe($((()=>{const{pathname:e}=window.location,t=e.slice(1).split("/")[2];return"blob"===t||"tree"===t?e.endsWith(yh())?e:void 0:lm()?document.querySelector(".codesearch-results h3")?.textContent?.trim():e})),qe(Boolean),We()),getContext:async()=>{const{repoName:e,rawRepoName:t,pageType:n}=Eh();return{rawRepoName:t,revision:"blob"===n||"tree"===n?Rh().blob.revision:void 0,privateRepository:await om(e)}},isLightTheme:$d((()=>{const e=document.documentElement.dataset.colorMode;return"auto"===e?((e=window)=>{const t=e.matchMedia("(prefers-color-scheme: dark)");return{observable:se(q(!t.matches),Ae(t,"change").pipe($((e=>!e.matches)))),initialValue:!t.matches}})().observable:q("dark"!==e)})),getViewContextOnSourcegraphMount:e=>{const t=fe(e,".pagehead-actions");if(!t||0===t.children.length)return null;let n=t.querySelector("#open-on-sourcegraph");return n||(n=document.createElement("li"),n.id=em,t.prepend(n),n)},viewOnSourcegraphButtonClassProps:{className:"btn btn-sm tooltipped tooltipped-s",iconClassName:tm},check:()=>((e=window.location.href)=>/^https?:\/\/(www\.)?github\.com/.test(e))()||Xh(),getCommandPaletteMount:e=>{const t="command-palette-button",n=e.querySelector(`.Header .${t}`)||e.querySelector(`.Header-old .${t}`);if(n)return n;const r=fe(e,".HeaderMenu > :last-child");if(r){const e=document.createElement("div");return e.classList.add(t),r.prepend(e),e}let o=fe(e,".Header-item:nth-last-child(2)");if(o){0!==o.previousElementSibling.children.length&&(o=o.previousElementSibling);const e=document.createElement("div");return e.classList.add("Header-item","mr-0","mr-lg-3",t),o.before(e),e}return null},notificationClassNames:nm,commandPaletteClassProps:{buttonClassName:"Header-link d-flex flex-items-baseline",popoverClassName:s()("Box",Mh),formClassName:"p-1",inputClassName:"form-control input-sm header-search-input jump-to-field-active",listClassName:"p-0 m-0 js-navigation-container jump-to-suggestions-results-container",selectedListItemClassName:"navigation-focus",listItemClassName:"d-flex flex-justify-start flex-items-center p-0 f5 navigation-item js-navigation-item js-jump-to-scoped-search",actionItemClassName:s()(jh,"no-underline d-flex flex-auto flex-items-center jump-to-suggestions-path p-2"),noResultsClassName:"d-flex flex-auto flex-items-center jump-to-suggestions-path p-2",iconClassName:tm},codeViewToolbarClassProps:{className:Bh,listItemClass:s()(qh,"BtnGroup"),actionItemClass:s()("btn btn-sm tooltipped tooltipped-s BtnGroup-item",Fh),actionItemPressedClass:"selected",actionItemIconClass:s()(Uh,"v-align-text-bottom")},hoverOverlayClassProps:{className:"Box",actionItemClassName:"btn btn-sm btn-secondary",actionItemPressedClassName:"active",closeButtonClassName:"btn-octicon p-0 hover-overlay__close-button--github",badgeClassName:s()("label",$h),getAlertClassName:$p(nm,"flash-full"),iconClassName:tm},setElementTooltip:function(e,t){"string"==typeof t?(e.classList.add(...Lh),e.setAttribute("aria-label",t)):(e.classList.remove(...Lh),e.removeAttribute("aria-label"))},linkPreviewContentClass:"text-small text-gray p-1 mx-1 border rounded-1 bg-gray text-gray-dark",urlToFile:(e,t,n)=>{if(t.viewState)return il(e,t);if(!t.rawRepoName.startsWith(window.location.hostname))return il(e,t);const r=t.revision||"HEAD",{rawRepoName:o}=Eh();if(o===t.rawRepoName&&void 0!==n.part){const e=document.querySelectorAll(".file");for(const r of e){const e=r.querySelector(".file-header[data-path][data-anchor]");if(!e)continue;if(e.dataset.path===t.filePath){const r=e.dataset.anchor,o=new URL(window.location.href);if(o.hash=r,t.position&&(o.hash+=`${"base"===n.part?"L":"R"}${t.position.line}`),!document.querySelector(o.hash))break;return o.href}}}const i=t.position?`#L${t.position.line}${t.position.character?`:${t.position.character}`:""}`:"";return`https://${t.rawRepoName}/blob/${r}/${t.filePath}${i}`},observeLineSelection:Ae(window,"hashchange").pipe(ae(void 0),$((()=>(e=>{const t=e.match(/(L\d+)/g);if(!t||t.length>2)return{};const n={},[r,o]=t.map((e=>e.slice(1)));return n.line=parseInt(r,10),o&&(n.endLine=parseInt(o,10)),n})(window.location.hash)))),codeViewsRequireTokenization:!0};var dm=o(6314);function hm(){var e=(0,dm.R)(),t=e.crypto||e.msCrypto;if(t&&t.randomUUID)return t.randomUUID().replace(/-/g,"");var n=t&&t.getRandomValues?()=>t.getRandomValues(new Uint8Array(1))[0]:()=>16*Math.random();return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(e=>(e^(15&n())>>e/4).toString(16)))}var mm=o(91698),gm=(0,dm.R)(),bm=["debug","info","warn","error","log","assert","trace"];function vm(e){var t=(0,dm.R)();if(!("console"in t))return e();var n=t.console,r={};bm.forEach((e=>{var o=n[e]&&n[e].__sentry_original__;e in t.console&&o&&(r[e]=n[e],n[e]=o)}));try{return e()}finally{Object.keys(r).forEach((e=>{n[e]=r[e]}))}}function ym(){let e=!1;var t={enable:()=>{e=!0},disable:()=>{e=!1}};return"undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?bm.forEach((n=>{t[n]=(...t)=>{e&&vm((()=>{gm.console[n](`Sentry Logger [${n}]:`,...t)}))}})):bm.forEach((e=>{t[e]=()=>{}})),t}let wm;wm="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__?(0,dm.Y)("logger",ym):ym();var Em,_m=o(38241),xm=Object.prototype.toString;function Sm(e,t){return xm.call(e)===`[object ${t}]`}function Cm(e){return Sm(e,"Object")}function Om(e){return Boolean(e&&e.then&&"function"==typeof e.then)}!function(e){e[e.PENDING=0]="PENDING";e[e.RESOLVED=1]="RESOLVED";e[e.REJECTED=2]="REJECTED"}(Em||(Em={}));class Nm{__init(){this._state=Em.PENDING}__init2(){this._handlers=[]}constructor(e){Nm.prototype.__init.call(this),Nm.prototype.__init2.call(this),Nm.prototype.__init3.call(this),Nm.prototype.__init4.call(this),Nm.prototype.__init5.call(this),Nm.prototype.__init6.call(this);try{e(this._resolve,this._reject)}catch(e){this._reject(e)}}then(e,t){return new Nm(((n,r)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){r(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){r(e)}else r(e)}]),this._executeHandlers()}))}catch(e){return this.then((e=>e),e)}finally(e){return new Nm(((t,n)=>{let r,o;return this.then((t=>{o=!1,r=t,e&&e()}),(t=>{o=!0,r=t,e&&e()})).then((()=>{o?n(r):t(r)}))}))}__init3(){this._resolve=e=>{this._setResult(Em.RESOLVED,e)}}__init4(){this._reject=e=>{this._setResult(Em.REJECTED,e)}}__init5(){this._setResult=(e,t)=>{this._state===Em.PENDING&&(Om(t)?t.then(this._resolve,this._reject):(this._state=e,this._value=t,this._executeHandlers()))}}__init6(){this._executeHandlers=()=>{if(this._state!==Em.PENDING){var e=this._handlers.slice();this._handlers=[],e.forEach((e=>{e[0]||(this._state===Em.RESOLVED&&e[1](this._value),this._state===Em.REJECTED&&e[2](this._value),e[0]=!0)}))}}}}function km(e){return Tm(e,new Map)}function Tm(e,t){if(Cm(e)){if(void 0!==(o=t.get(e)))return o;var n={};for(var r of(t.set(e,n),Object.keys(e)))void 0!==e[r]&&(n[r]=Tm(e[r],t));return n}if(Array.isArray(e)){var o;if(void 0!==(o=t.get(e)))return o;n=[];return t.set(e,n),e.forEach((e=>{n.push(Tm(e,t))})),n}return e}function Am(e){var t=(0,mm.ph)(),n={sid:hm(),init:!0,timestamp:t,started:t,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(e){return km({sid:`${e.sid}`,init:e.init,started:new Date(1e3*e.started).toISOString(),timestamp:new Date(1e3*e.timestamp).toISOString(),status:e.status,errors:e.errors,did:"number"==typeof e.did||"string"==typeof e.did?`${e.did}`:void 0,duration:e.duration,attrs:{release:e.release,environment:e.environment,ip_address:e.ipAddress,user_agent:e.userAgent}})}(n)};return e&&Im(n,e),n}function Im(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||(0,mm.ph)(),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:hm()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),"number"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if("number"==typeof t.duration)e.duration=t.duration;else{var n=e.timestamp-e.started;e.duration=n>=0?n:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),"number"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}class Rm{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={}}static clone(e){var t=new Rm;return e&&(t._breadcrumbs=[...e._breadcrumbs],t._tags={...e._tags},t._extra={...e._extra},t._contexts={...e._contexts},t._user=e._user,t._level=e._level,t._span=e._span,t._session=e._session,t._transactionName=e._transactionName,t._fingerprint=e._fingerprint,t._eventProcessors=[...e._eventProcessors],t._requestSession=e._requestSession,t._attachments=[...e._attachments]),t}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{},this._session&&Im(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this._tags={...this._tags,[e]:t},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts={...this._contexts,[e]:t},this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){var e=this.getSpan();return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;if("function"==typeof e){var t=e(this);return t instanceof Rm?t:this}return e instanceof Rm?(this._tags={...this._tags,...e._tags},this._extra={...this._extra,...e._extra},this._contexts={...this._contexts,...e._contexts},e._user&&Object.keys(e._user).length&&(this._user=e._user),e._level&&(this._level=e._level),e._fingerprint&&(this._fingerprint=e._fingerprint),e._requestSession&&(this._requestSession=e._requestSession)):Cm(e)&&(e=e,this._tags={...this._tags,...e.tags},this._extra={...this._extra,...e.extra},this._contexts={...this._contexts,...e.contexts},e.user&&(this._user=e.user),e.level&&(this._level=e.level),e.fingerprint&&(this._fingerprint=e.fingerprint),e.requestSession&&(this._requestSession=e.requestSession)),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this}addBreadcrumb(e,t){var n="number"==typeof t?Math.min(t,100):100;if(n<=0)return this;var r={timestamp:(0,mm.yW)(),...e};return this._breadcrumbs=[...this._breadcrumbs,r].slice(-n),this._notifyScopeListeners(),this}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this._attachments}clearAttachments(){return this._attachments=[],this}applyToEvent(e,t={}){if(this._extra&&Object.keys(this._extra).length&&(e.extra={...this._extra,...e.extra}),this._tags&&Object.keys(this._tags).length&&(e.tags={...this._tags,...e.tags}),this._user&&Object.keys(this._user).length&&(e.user={...this._user,...e.user}),this._contexts&&Object.keys(this._contexts).length&&(e.contexts={...this._contexts,...e.contexts}),this._level&&(e.level=this._level),this._transactionName&&(e.transaction=this._transactionName),this._span){e.contexts={trace:this._span.getTraceContext(),...e.contexts};var n=this._span.transaction&&this._span.transaction.name;n&&(e.tags={transaction:n,...e.tags})}return this._applyFingerprint(e),e.breadcrumbs=[...e.breadcrumbs||[],...this._breadcrumbs],e.breadcrumbs=e.breadcrumbs.length>0?e.breadcrumbs:void 0,e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...this._sdkProcessingMetadata},this._notifyEventProcessors([...Pm(),...this._eventProcessors],e,t)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}_notifyEventProcessors(e,t,n,r=0){return new Nm(((o,i)=>{var s=e[r];if(null===t||"function"!=typeof s)o(t);else{var a=s({...t},n);("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&s.id&&null===a&&wm.log(`Event processor "${s.id}" dropped event`),Om(a)?a.then((t=>this._notifyEventProcessors(e,t,n,r+1).then(o))).then(null,i):this._notifyEventProcessors(e,a,n,r+1).then(o).then(null,i)}}))}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach((e=>{e(this)})),this._notifyingListeners=!1)}_applyFingerprint(e){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],this._fingerprint&&(e.fingerprint=e.fingerprint.concat(this._fingerprint)),e.fingerprint&&!e.fingerprint.length&&delete e.fingerprint}}function Pm(){return(0,dm.Y)("globalEventProcessors",(()=>[]))}var Dm=100;class Lm{__init(){this._stack=[{}]}constructor(e,t=new Rm,n=4){this._version=n,Lm.prototype.__init.call(this),this.getStackTop().scope=t,e&&this.bindClient(e)}isOlderThan(e){return this._version<e}bindClient(e){this.getStackTop().client=e,e&&e.setupIntegrations&&e.setupIntegrations()}pushScope(){var e=Rm.clone(this.getScope());return this.getStack().push({client:this.getClient(),scope:e}),e}popScope(){return!(this.getStack().length<=1)&&!!this.getStack().pop()}withScope(e){var t=this.pushScope();try{e(t)}finally{this.popScope()}}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,t){var n=this._lastEventId=t&&t.event_id?t.event_id:hm(),r=new Error("Sentry syntheticException");return this._withClient(((o,i)=>{o.captureException(e,{originalException:e,syntheticException:r,...t,event_id:n},i)})),n}captureMessage(e,t,n){var r=this._lastEventId=n&&n.event_id?n.event_id:hm(),o=new Error(e);return this._withClient(((i,s)=>{i.captureMessage(e,t,{originalException:e,syntheticException:o,...n,event_id:r},s)})),r}captureEvent(e,t){var n=t&&t.event_id?t.event_id:hm();return"transaction"!==e.type&&(this._lastEventId=n),this._withClient(((r,o)=>{r.captureEvent(e,{...t,event_id:n},o)})),n}lastEventId(){return this._lastEventId}addBreadcrumb(e,t){const{scope:n,client:r}=this.getStackTop();if(!n||!r)return;const{beforeBreadcrumb:o=null,maxBreadcrumbs:i=Dm}=r.getOptions&&r.getOptions()||{};if(!(i<=0)){var s={timestamp:(0,mm.yW)(),...e},a=o?vm((()=>o(s,t))):s;null!==a&&n.addBreadcrumb(a,i)}}setUser(e){var t=this.getScope();t&&t.setUser(e)}setTags(e){var t=this.getScope();t&&t.setTags(e)}setExtras(e){var t=this.getScope();t&&t.setExtras(e)}setTag(e,t){var n=this.getScope();n&&n.setTag(e,t)}setExtra(e,t){var n=this.getScope();n&&n.setExtra(e,t)}setContext(e,t){var n=this.getScope();n&&n.setContext(e,t)}configureScope(e){const{scope:t,client:n}=this.getStackTop();t&&n&&e(t)}run(e){var t=jm(this);try{e(this)}finally{jm(t)}}getIntegration(e){var t=this.getClient();if(!t)return null;try{return t.getIntegration(e)}catch(t){return("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&wm.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,t){return this._callExtensionMethod("startTransaction",e,t)}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){var e=this.getStackTop(),t=e&&e.scope,n=t&&t.getSession();n&&function(e,t){let n={};t?n={status:t}:"ok"===e.status&&(n={status:"exited"}),Im(e,n)}(n),this._sendSessionUpdate(),t&&t.setSession()}startSession(e){const{scope:t,client:n}=this.getStackTop(),{release:r,environment:o}=n&&n.getOptions()||{};var i=(0,dm.R)();const{userAgent:s}=i.navigator||{};var a=Am({release:r,environment:o,...t&&{user:t.getUser()},...s&&{userAgent:s},...e});if(t){var l=t.getSession&&t.getSession();l&&"ok"===l.status&&Im(l,{status:"exited"}),this.endSession(),t.setSession(a)}return a}shouldSendDefaultPii(){var e=this.getClient(),t=e&&e.getOptions();return Boolean(t&&t.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:t}=this.getStackTop();if(e){var n=e.getSession();n&&t&&t.captureSession&&t.captureSession(n)}}_withClient(e){const{scope:t,client:n}=this.getStackTop();n&&e(n,t)}_callExtensionMethod(e,...t){var n=Mm().__SENTRY__;if(n&&n.extensions&&"function"==typeof n.extensions[e])return n.extensions[e].apply(this,t);("undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__)&&wm.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function Mm(){var e=(0,dm.R)();return e.__SENTRY__=e.__SENTRY__||{extensions:{},hub:void 0},e}function jm(e){var t=Mm(),n=Bm(t);return qm(t,e),n}function Fm(){var e=Mm();return Um(e)&&!Bm(e).isOlderThan(4)||qm(e,new Lm),(0,_m.KV)()?function(e){try{var t=Mm().__SENTRY__,n=t&&t.extensions&&t.extensions.domain&&t.extensions.domain.active;if(!n)return Bm(e);if(!Um(n)||Bm(n).isOlderThan(4)){var r=Bm(e).getStackTop();qm(n,new Lm(r.client,Rm.clone(r.scope)))}return Bm(n)}catch(t){return Bm(e)}}(e):Bm(e)}function Um(e){return!!(e&&e.__SENTRY__&&e.__SENTRY__.hub)}function Bm(e){return(0,dm.Y)("hub",(()=>new Lm),e)}function qm(e,t){return!!e&&((e.__SENTRY__=e.__SENTRY__||{}).hub=t,!0)}const $m=(e,t,n)=>e.querySelector(`#LC${t}`),zm={getCodeElementFromTarget:e=>e.closest("span.line"),getLineNumberFromCodeElement:e=>{const t=e.id.replace(/^LC/,"");return parseInt(t,10)},getCodeElementFromLineNumber:$m,getLineElementFromLineNumber:$m},Vm=e=>{const t=e.closest("[data-interop-type]");return t?"old"===t.dataset.interopType?"base":"head":(e=>{let t="old";const n=e.closest(".diff-td,td");return n.classList.contains("parallel")&&(t="left-side"),n.classList.contains(t)?"base":"head"})(e)},Hm=(e,t,n)=>{const r="base"===n?"old":"new",o=e.querySelector(`[data-interop-${r}-line="${t}"]`);return o?o.querySelector("span.line"):((e,t,n)=>{const r=e.querySelector(`.${"base"===n?"old_line":"new_line"} [data-linenumber="${t}"]`);if(!r)return null;const o=r.closest(".diff-tr,tr");if(!o)return null;let i="span.line";return o.classList.contains("parallel")&&(i=`.${"base"===n?"left-side":"right-side"} ${i}`),o.querySelector(i)})(e,t,n)},Gm={getCodeElementFromTarget:zm.getCodeElementFromTarget,getLineNumberFromCodeElement:e=>{const t=e.closest("[data-interop-line]");return t?parseInt(t.dataset.interopLine||"",10):(e=>{const t=Vm(e);let n=e.closest(".diff-td,td");for(;n&&(!n.matches(".diff-line-num."+("base"===t?"old_line":"new_line"))||!n.querySelector("a"))&&n.previousElementSibling;)n=n.previousElementSibling;if(n){const e=n.querySelector("a");return parseInt(e.dataset.linenumber||"",10)}throw new Error("Unable to determine line number for diff code element")})(e)},getCodeElementFromLineNumber:Hm,getLineElementFromLineNumber:(e,t,n)=>{const r=Hm(e,t,n);return r&&r.parentElement},getDiffCodePart:Vm},Wm="codeHost-module__command-list-popover_hwImg",Qm="codeHost-module__command-palette-button_2FnHe",Km="codeHost-module__hover-overlay_3Cize",Zm=(e,t,n)=>`${window.location.origin}/api/v4/projects/${encodeURIComponent(e)}%2f${t}${n}`,Ym=e=>sr(e,{selector:e=>ur(e).json()}),Jm=gs((e=>Ym(`${window.location.origin}/api/v4/projects/${e}`).pipe($((({web_url:e})=>{const{hostname:t,pathname:n}=new URL(e);return`${t}${n}`})))),Xl()),Xm=gs((({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>r?Ym(Zm(e,t,`/merge_requests/${n}/versions/${r}`)).pipe($((({base_commit_sha:e})=>e))):q(void 0)),(({owner:e,projectName:t,mergeRequestID:n,diffID:r})=>`${e}:${t}:${n}:${String(r)}`)),eg=gs((({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>Pf(Ym(Zm(e,t,`/merge_requests/${n}`)),Xm({owner:e,projectName:t,mergeRequestID:n,diffID:o})).pipe(Ve((([{diff_refs:e,source_project_id:t},n])=>Jm(t).pipe($((t=>({baseCommitID:n||e.base_sha,commitID:e.head_sha,rawRepoName:r,baseRawRepoName:t})))))))),(({owner:e,projectName:t,mergeRequestID:n,rawRepoName:r,diffID:o})=>`${e}:${t}:${n}:${r}:${String(o)}`)),tg=gs((({owner:e,projectName:t,commitID:n})=>Ym(Zm(e,t,`/repository/commits/${n}`)).pipe($((({parent_ids:e})=>Yp()(e))))),(({owner:e,projectName:t,commitID:n})=>`${e}:${t}:${n}`));var ng=o(68642),rg=o.n(ng),og=o(90006),ig=o.n(og);let sg;!function(e){e[e.File=0]="File",e[e.Commit=1]="Commit",e[e.MergeRequest=2]="MergeRequest",e[e.Other=3]="Other"}(sg||(sg={}));function ag(){const e=document.querySelector(".context-header a");if(!e)throw new Error("Unable to determine project name");const t=new URL(e.href).pathname.slice(1),n=t.split("/"),r=rg()(n,n.length-1).join("/"),o=ig()(n),i=((e,t,n)=>{const r=n.match(new RegExp(`^/${e}/${t}(/-)?/(commit|merge_requests|blob)/`));if(!r)return sg.Other;switch(r[2]){case"commit":return sg.Commit;case"merge_requests":return sg.MergeRequest;case"blob":return sg.File;default:return sg.Other}})(r,o,window.location.pathname);return{owner:r,projectName:o,rawRepoName:[lf?window.location.hostname:new URL(gon.gitlab_url).hostname,r,o].join("/"),repoName:t,pageKind:i}}const lg=()=>{let e=window.location.pathname.match(/merge_requests\/(.*?)\/diffs/);if(!e&&document.querySelector(".diffs-tab.active")&&(e=window.location.pathname.match(/merge_requests\/(.*?)((\/)|$)/)),!e)throw new Error("Unable to determine merge request ID");return e[1]},cg=e=>{const t=e.dataset.originalTitle||e.dataset.title||e.title;if(!t)throw new Error("Unable to get file paths from code view: no file title");return t.endsWith(" deleted")?t.slice(0,-8):t};function ug(e){const t=e.querySelectorAll(".file-title-name");if(0===t.length)throw new Error("Unable to get file paths from code view: no .file-title.name");const n=t.length>1,r=cg(t.item(n?1:0));return{headFilePath:r,baseFilePath:n?cg(t.item(0)):r}}function fg(){const{rawRepoName:e,owner:t,projectName:n}=ag();return{rawRepoName:e,owner:t,projectName:n,commitID:ig()(window.location.pathname.split("/"))}}const pg=(e,t)=>{const n=e.querySelector(".sg-toolbar-mount-gitlab");if(n)return n;const r=e.querySelector(".file-actions");if(!r)throw new Error("Unable to find mount location");const o=document.createElement("div");return o.classList.add("sg-toolbar-mount","sg-toolbar-mount-gitlab"),t===sg.Commit&&o.classList.add("gl-mr-3"),r.prepend(o),o},dg={dom:zm,getToolbarMount:e=>pg(e,sg.File),resolveFileInfo:()=>{const{rawRepoName:e,filePath:t,revision:n}=function(){const{rawRepoName:e}=ag(),t=window.location.pathname.match(/\/blob\/(.*?)\/(.*)/);if(!t)throw new Error("Unable to determine revision or file path");const n=decodeURIComponent(t[1]);return{rawRepoName:e,filePath:decodeURIComponent(t[2]),revision:n}}();if(!t)throw new Error(`Unable to determine the file path of the current file because the current URL (window.location ${window.location.href}) does not have a file path.`);return{blob:{rawRepoName:e,filePath:t,commitID:le({selector:".js-data-file-blob-permalink-url",hrefRegex:new RegExp("^/.*?/.*?/blob/([0-9a-f]{40})/")}),revision:n}}},getSelections:dh,observeSelections:hh},hg=e=>{const t=e.querySelector(".js-file-title");if(!t)throw new Error("Could not find .file-title element");return[t]},mg={dom:Gm,getToolbarMount:e=>pg(e,sg.MergeRequest),resolveFileInfo:e=>Y(eg({...ag(),mergeRequestID:lg(),diffID:new URLSearchParams(window.location.search).get("diff_id")??void 0})).pipe($((t=>{const{rawRepoName:n,baseRawRepoName:r,commitID:o,baseCommitID:i}=t,{headFilePath:s,baseFilePath:a}=ug(e);return{head:{rawRepoName:n,filePath:s,commitID:o},base:{rawRepoName:r,filePath:a,commitID:i}}}))),getScrollBoundaries:hg},gg={dom:Gm,getToolbarMount:e=>pg(e,sg.Commit),resolveFileInfo:e=>rr(fg).pipe(Ve((({owner:e,projectName:t,commitID:n,rawRepoName:r})=>tg({owner:e,projectName:t,commitID:n}).pipe($((e=>({commitID:n,baseCommitID:e,rawRepoName:r})))))),$((({commitID:t,baseCommitID:n,rawRepoName:r})=>{const{headFilePath:o,baseFilePath:i}=ug(e);return{head:{rawRepoName:r,filePath:o,commitID:t},base:{rawRepoName:r,filePath:i,commitID:n}}}))),getScrollBoundaries:hg},bg={selector:".file-holder",resolveView:e=>{if(e.classList.contains("discussion-wrapper"))return null;const{pageKind:t}=ag();return t===sg.Other?null:t===sg.File?{element:e,...dg}:t===sg.MergeRequest?e.querySelector(".file-actions")?{element:e,...mg}:null:{element:e,...gg}}},vg={[gc]:"alert alert-secondary",[bc]:"alert alert-success",[mc]:"alert alert-info",[hc]:"alert alert-warning",[dc]:"alert alert-danger"},yg=(e,t=ff.fetchCache)=>"gitlab.com"===window.location.hostname&&e?t({url:`https://gitlab.com/api/v4/projects/${encodeURIComponent(e)}`,credentials:"omit",cacheMaxAge:36e5}).then((e=>{const t=e.headers["ratelimit-remaining"];if(Number(t)<=0){const e=new Error("Gitlab rate limit exceeded.");throw n=e,Fm().captureException(n,{captureContext:r}),e}var n,r;return e})).then((({status:e})=>200!==e)).catch((e=>(console.warn("Failed to fetch repository visibility info.",e),!0))):Promise.resolve(!0),wg={type:"gitlab",name:"GitLab",check:function(){return!!document.head.querySelector('meta[content="GitLab"]')},codeViewResolvers:[bg],getCommandPaletteMount:e=>{const t=fe(e,".navbar-collapse");if(!t)return null;const n="command-palette-button";return t.querySelector("."+n)||(()=>{const e=document.createElement("div");return e.classList.add(n,Qm),t.prepend(e),e})()},getContext:async()=>{const{repoName:e,...t}=ag();return{...t,privateRepository:await yg(e)}},urlToFile:(e,t,n)=>{if(t.viewState||!t.rawRepoName.startsWith(window.location.hostname))return il(e,t);if(ag().rawRepoName===t.rawRepoName&&void 0!==n.part){const e=Vd(document.body,bg.selector);for(const r of e){const{headFilePath:e,baseFilePath:o}=ug(r);if(e!==t.filePath&&o!==t.filePath)continue;if(!t.position){const e=new URL(window.location.href);return e.hash=r.id,e.href}const i=null!==n.part?{head:".new_line",base:".old_line"}[n.part]:"",s=r.querySelector(`${i} a[data-linenumber="${t.position.line}"]`);if(!s)break;return new URL(s.href).href}}const r=new URL(`https://${t.rawRepoName}/blob/${t.revision}/${t.filePath}`);if(t.position){const{line:e}=t.position;r.hash=`#L${e}`}return r.href},notificationClassNames:vg,commandPaletteClassProps:{popoverClassName:s()("dropdown-menu",Wm),formClassName:"dropdown-input",inputClassName:"dropdown-input-field",resultsContainerClassName:"dropdown-content",selectedActionItemClassName:"is-focused",noResultsClassName:"px-3",iconClassName:"s16 align-bottom"},codeViewToolbarClassProps:{className:"pl-0",actionItemClass:"btn btn-md gl-button btn-icon",actionItemPressedClass:"active",actionItemIconClass:"gl-button-icon gl-icon s16"},hoverOverlayClassProps:{className:s()("card",Km),actionItemClassName:"btn btn-secondary",actionItemPressedClassName:"active",closeButtonClassName:"btn btn-transparent p-0 btn-icon--gitlab",iconClassName:"square s16",getAlertClassName:$p(vg)},codeViewsRequireTokenization:!0,getHoverOverlayMountLocation:()=>{const{pageKind:e}=ag();return e===sg.MergeRequest?"div.tab-pane.diffs":null},observeLineSelection:Ae(document,"click").pipe(qe((e=>e.target.matches("a[data-line-number]"))),$((()=>(e=>{if(e.startsWith("#")&&(e=e.slice(1)),!/^L\d+(-\d+)?$/.test(e))return{};const t={},[n,r]=e.slice(1).split("-");return t.line=parseInt(n,10),r&&(t.endLine=parseInt(r,10)),t})(window.location.hash))))},Eg=e=>Boolean("TH"===e.tagName&&e.textContent||e.dataset.n),_g=e=>parseInt(("TH"===e.tagName?e.textContent:e.dataset.n)||"",10),xg=e=>{let t=e;for(;t;){if(Eg(t))return t;t=t.previousElementSibling}return null},Sg=(e,t,n)=>{let r=((e,t,n)=>{const r=e.querySelector("td[data-n]")?"td[data-n]":`th:nth-of-type(${"base"===n?1:2})`;for(const o of e.querySelectorAll(r))if(_g(o)===t){if("head"===n&&null===o.previousElementSibling)continue;return o}return null})(e,t,n);for(;r&&("TD"!==r.tagName||r.classList.contains("n")||Eg(r)||r.classList.contains("copy"));)r=r.nextElementSibling;return r},Cg={getCodeElementFromTarget:e=>{if("TH"===e.tagName||e.classList.contains("copy"))return null;const t=e.closest("td");return t?t.classList.contains("show-more")||t.classList.contains("show-context")?null:xg(t)?t:null:null},getCodeElementFromLineNumber:Sg,getLineElementFromLineNumber:Sg,getLineNumberFromCodeElement:e=>{const t=xg(e);if(!t)throw new Error("Could not find line number cell from code element");return _g(t)},getDiffCodePart:e=>{if(e.classList.contains("old"))return"base";if(e.classList.contains("new"))return"head";const t=xg(e);if(!t)throw new Error("Could not find line number cell from code element");return t.classList.contains("left")?"base":t.classList.contains("right")||t.previousElementSibling?"head":"base"},isFirstCharacterDiffIndicator:e=>!!e.firstElementChild?.classList.contains("aural-only")},Og=(e,t,n)=>{const r=e.querySelector(`tr:nth-of-type(${t})`);if(!r)throw new Error(`unable to find row ${t} from code view`);return r.querySelector("td")},Ng={getCodeElementFromTarget:e=>e.closest("td"),getCodeElementFromLineNumber:Og,getLineElementFromLineNumber:Og,getLineNumberFromCodeElement:e=>{let t=e;for(;null!==t&&"TH"!==t.tagName&&!t.classList.contains("phabricator-source-line");)t=t.previousElementSibling;if(!t)throw new Error("could not find line number cell from code element");const n=t.querySelector("a");if(!n)throw new Error("could not find line number anchor from code element");if(void 0!==n.dataset.n){const e=parseInt(n.dataset.n,10);if(isNaN(e))throw new TypeError(`Could not parse lineNumber from data-n attribute: ${n.dataset.n}`);return e}const r=parseInt(n.textContent||"",10);if(isNaN(r))throw new TypeError(`Could not parse lineNumber from lineAnchor.textContent: ${String(n.textContent)}`);return r},isFirstCharacterDiffIndicator:()=>!1};let kg;!function(e){e[e.Diffusion=1]="Diffusion",e[e.Differential=2]="Differential",e[e.Revision=3]="Revision",e[e.Change=4]="Change"}(kg||(kg={}));const Tg=/r([\dA-z]+)([\da-f]{40})/;function Ag(){const e=document.querySelectorAll(".phui-tag-core").item(0);if(!e)throw new Error("Could not find Phabricator page tag");return Tg.exec(e.children[0].getAttribute("href"))}function Ig(){const e=Ag();if(!e)throw new Error("Could not determine callsign from page tag");return e[1]}function Rg(){const e=Ag();if(!e)throw new Error("Could not determine commitID from page tag");return e[2]}const Pg=/Diff (\d+)/;const Dg=/^\/?(source|diffusion)\/([\w-]+)\/browse\/([\w-]+\/)?([^$;]+)(;[\da-f]{40})?(?:\$\d+)?/i,Lg=/^\/?(d\d+)(?:\?(?:(?:id=(\d+))|(vs=(?:\d+|on)&id=\d+)))?/i,Mg=/^\/?r([\dA-z]+)([\da-f]{40})/i,jg=/^\/?(source|diffusion)\/([\da-z]+)\/change\/([\w-]+)\/([^;]+)(;[\da-f]{40})?/i,Fg=/^\/?\/differential\/changeset.*/i,Ug=/^vs=((?:\d+|on))&id=(\d+)/i;function Bg(e,t,n){try{const r=e.href.replace(e.origin,""),o=Dg.exec(r);if(o){const e=o[4];if(!e)throw new Error(`Could not determine file path from diffusionMatch, stateUrl: ${r}`);return Wg(Ig(),t,n).pipe($((({rawRepoName:t})=>({mode:kg.Diffusion,rawRepoName:t,filePath:e,commitID:Rg()}))))}const i=Lg.exec(r);if(i){const e=i[1],r=i[3],o=parseInt(e.split("D")[1],10);let s,a=i[2]?parseInt(i[2],10):void 0;if(a||(a=function(){const e=document.querySelector("#differential-review-stage");if(!e)throw new Error("no element with id differential-review-stage found on page.");const t=e.parentElement;if(!t)throw new Error("parent container of diff container not found.");const n=t.children[0].querySelectorAll(".phui-header-header").item(0);if(!n||!n.textContent)throw new Error("Could not find diffTitle element, or it had no text content");const r=Pg.exec(n.textContent);if(!r)throw new Error(`diffTitle element does not match pattern. Content: '${n.textContent}'`);return parseInt(r[1],10)}()),r){const e=Ug.exec(r)?.[1];e&&"on"!==e&&(s=parseInt(e,10),console.log(`comparison diffID ${a} baseDiffID ${s}`))}return Kg(o,t,n).pipe($((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:o,diffID:a,baseDiffID:s,mode:kg.Differential}))))}const s=Mg.exec(r);if(s){const e=s[1],r=s[2],o=function(){const e=document.querySelectorAll(".phui-property-list-key");for(const t of e)if("Parents "===t.textContent){const e=t.nextSibling.children[0].children[0].href,n=new URL(e),r=Mg.exec(n.pathname);if(r)return r[2]}throw new Error("Could not determine base commit ID from revision page")}();return Wg(e,t,n).pipe($((({rawRepoName:e})=>({mode:kg.Revision,rawRepoName:e,baseCommitID:o,headCommitID:r}))))}const a=jg.exec(r);if(a){const e=a[8],r=Ig(),o=Rg();return Wg(r,t,n).pipe($((({rawRepoName:t})=>({mode:kg.Change,filePath:e,rawRepoName:t,commitID:o}))))}if(Fg.exec(r)){const e=document.querySelector(".phui-crumbs-view");if(!e)throw new Error("failed parsing changeset dom");const[,r,o]=e.querySelectorAll("a"),i=r.getAttribute("href").match(/D(\d+)/);if(!i)throw new Error("failed parsing differentialID");const s=parseInt(i[1],10),a=o.getAttribute("href").match(/\/differential\/diff\/(\d+)/);if(!a)throw new Error("failed parsing diffID");const l=parseInt(a[1],10);return Kg(s,t,n).pipe($((({rawRepoName:e})=>({baseRawRepoName:e,headRawRepoName:e,revisionID:s,diffID:l,mode:kg.Differential}))))}throw new Error(`Could not determine Phabricator state from stateUrl ${r}`)}catch(e){return bt(e)}}function qg(e){let t=e;if(t=t.replace("\\",""),e.startsWith("git@"))t=e.slice("git@".length),t=t.replace(":","/");else if(e.startsWith("git://"))t=e.slice("git://".length);else if(e.startsWith("https://"))t=e.slice("https://".length);else if(e.includes("@")){t=e.split("@")[1],t=t.replace(":","/")}return t.replace(/.git$/,"")}function $g(e,t){const n=function(){const e=document.querySelector(".phabricator-search-menu form");if(!e)throw new Error("cannot create conduit request form");const t=new FormData;return t.set("__csrf__",e.querySelector("input[name=__csrf__]").value),t.set("__form__",e.querySelector("input[name=__form__]").value),t}();for(const[e,r]of Object.entries(t))n.set(`params[${e}]`,JSON.stringify(r));return sr(window.location.origin+e,{method:"POST",body:n,credentials:"include",headers:{Accept:"application/json"},selector:e=>ur(e).json()}).pipe($((e=>{if(null!==e.error_code)throw new Error(`error ${e.error_code}: ${e.error_info}`);return e.result})))}const zg=gs((({diffID:e,revisionID:t,queryConduit:n=$g})=>n("/api/differential.querydiffs",{ids:[e],revisionIDs:[t]}).pipe($((t=>t[String(e)])))),(({diffID:e,revisionID:t})=>`${e}-${t}`)),Vg=gs((({diffID:e,queryConduit:t=$g})=>t("/api/differential.getrawdiff",{diffID:e})),(({diffID:e})=>e.toString())),Hg=gs((({revisionID:e,queryConduit:t=$g})=>t("/api/differential.query",{ids:[e]}).pipe($((t=>{const n=t[0].repositoryPHID;if(!n)throw new Error(`no repositoryPHID for revision ${e}`);return n})))),(({revisionID:e})=>e.toString())),Gg=gs((({requestGraphQL:e,...t})=>e({request:fr`
131
131
  mutation addPhabricatorRepo($callsign: String!, $repoName: String!, $phabricatorURL: String!) {
132
132
  addPhabricatorRepo(callsign: $callsign, uri: $repoName, url: $phabricatorURL) {
133
133
  alwaysNil