@fabiofiorita/porcelain 0.63.4 → 0.64.0

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @fabiofiorita/porcelain (0.63.4)
1
+ # @fabiofiorita/porcelain (0.64.0)
2
2
 
3
3
  The Electron-free Porcelain daemon and browser client, packaged for plain Node. Run it on the
4
4
  machine that owns the repositories and terminals you want to review.
@@ -3944,6 +3944,7 @@ var lanStatusOutputSchema = import_zod32.z.object({
3944
3944
  enabled: import_zod32.z.boolean(),
3945
3945
  url: import_zod32.z.string().url().nullable(),
3946
3946
  numericUrl: import_zod32.z.string().url().nullable(),
3947
+ urls: import_zod32.z.array(import_zod32.z.string().url()).optional(),
3947
3948
  error: import_zod32.z.literal("in-use").nullable(),
3948
3949
  envForced: import_zod32.z.boolean(),
3949
3950
  port: import_zod32.z.number()
@@ -11661,7 +11662,11 @@ function isDeniedIface(name) {
11661
11662
  }
11662
11663
  function findLanAddresses(interfaces = (0, import_node_os4.networkInterfaces)()) {
11663
11664
  const matches = [];
11664
- for (const [name, addrs] of Object.entries(interfaces)) {
11665
+ const physical = (name) => /^(wi-?fi|ethernet|en\d|eth\d|enp|eno|ens|wlan|wlp|wls)/i.test(name);
11666
+ const entries = Object.entries(interfaces).sort(
11667
+ ([a], [b]) => Number(physical(b)) - Number(physical(a))
11668
+ );
11669
+ for (const [name, addrs] of entries) {
11665
11670
  if (isDeniedIface(name)) continue;
11666
11671
  for (const addr of addrs ?? []) {
11667
11672
  if (addr.internal || addr.family !== "IPv4") continue;
@@ -11886,6 +11891,9 @@ function lanNumericUrl() {
11886
11891
  const [first] = lan.addresses();
11887
11892
  return first !== void 0 ? `http://${first}:${ifaceListenerPort()}` : null;
11888
11893
  }
11894
+ function lanUrls() {
11895
+ return lan.addresses().map((address) => `http://${address}:${ifaceListenerPort()}`);
11896
+ }
11889
11897
 
11890
11898
  // ../daemon/src/features/remote/remote-network-router.ts
11891
11899
  function createRemoteNetworkRouter(operations) {
@@ -12056,6 +12064,7 @@ function createRemoteOperations(options) {
12056
12064
  enabled: flags.lanBind === true || envForced,
12057
12065
  url: options.listeners.lanUrl(),
12058
12066
  numericUrl: options.listeners.lanNumericUrl(),
12067
+ urls: options.listeners.lanUrls(),
12059
12068
  error: options.listeners.lanBindError(),
12060
12069
  envForced,
12061
12070
  port: options.listeners.ifaceListenerPort()
@@ -12073,6 +12082,7 @@ function createRemoteOperations(options) {
12073
12082
  enabled: input || envForced,
12074
12083
  url: options.listeners.lanUrl(),
12075
12084
  numericUrl: options.listeners.lanNumericUrl(),
12085
+ urls: options.listeners.lanUrls(),
12076
12086
  error: options.listeners.lanBindError(),
12077
12087
  envForced,
12078
12088
  port: options.listeners.ifaceListenerPort()
@@ -14725,7 +14735,7 @@ function daemonIdentity(host = process.env.PORCELAIN_DAEMON_HOST?.trim() || (0,
14725
14735
 
14726
14736
  // ../daemon/src/net/daemon-version.ts
14727
14737
  function daemonVersion() {
14728
- return "0.63.4";
14738
+ return "0.64.0";
14729
14739
  }
14730
14740
 
14731
14741
  // ../daemon/src/daemon-composition/daemon-operations.ts
@@ -14770,6 +14780,7 @@ function createDaemonOperations(options) {
14770
14780
  stopTailnetListener,
14771
14781
  lanUrl,
14772
14782
  lanNumericUrl,
14783
+ lanUrls,
14773
14784
  lanBindError,
14774
14785
  startLanListener,
14775
14786
  stopLanListener,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabiofiorita/porcelain",
3
- "version": "0.63.4",
3
+ "version": "0.64.0",
4
4
  "description": "Headless Porcelain daemon — plain Node backend for remote machines (npx @fabiofiorita/porcelain@latest serve)",
5
5
  "license": "MIT",
6
6
  "author": "Fabio Fiorita <fabiolfp@gmail.com>",
@@ -1,4 +1,4 @@
1
- import{bo as re}from"./index-CuWbxCsX.js";function oe(r,o){for(var i=0;i<o.length;i++){const e=o[i];if(typeof e!="string"&&!Array.isArray(e)){for(const t in e)if(t!=="default"&&!(t in r)){const n=Object.getOwnPropertyDescriptor(e,t);n&&Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var z={},Q,Bt;function ie(){return Bt||(Bt=1,Q=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Q}var $={},_={},At;function U(){if(At)return _;At=1;let r;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return _.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17},_.getSymbolTotalCodewords=function(e){return o[e]},_.getBCHDigit=function(i){let e=0;for(;i!==0;)e++,i>>>=1;return e},_.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');r=e},_.isKanjiModeEnabled=function(){return typeof r<"u"},_.toSJIS=function(e){return r(e)},_}var W={},Rt;function yt(){return Rt||(Rt=1,(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function o(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+i)}}r.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4},r.from=function(e,t){if(r.isValid(e))return e;try{return o(e)}catch{return t}}})(W)),W}var Z,Tt;function se(){if(Tt)return Z;Tt=1;function r(){this.buffer=[],this.length=0}return r.prototype={get:function(o){const i=Math.floor(o/8);return(this.buffer[i]>>>7-o%8&1)===1},put:function(o,i){for(let e=0;e<i;e++)this.putBit((o>>>i-e-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(o){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),o&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Z=r,Z}var X,It;function ue(){if(It)return X;It=1;function r(o){if(!o||o<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=o,this.data=new Uint8Array(o*o),this.reservedBit=new Uint8Array(o*o)}return r.prototype.set=function(o,i,e,t){const n=o*this.size+i;this.data[n]=e,t&&(this.reservedBit[n]=!0)},r.prototype.get=function(o,i){return this.data[o*this.size+i]},r.prototype.xor=function(o,i,e){this.data[o*this.size+i]^=e},r.prototype.isReserved=function(o,i){return this.reservedBit[o*this.size+i]},X=r,X}var x={},Nt;function ae(){return Nt||(Nt=1,(function(r){const o=U().getSymbolSize;r.getRowColCoords=function(e){if(e===1)return[];const t=Math.floor(e/7)+2,n=o(e),s=n===145?26:Math.ceil((n-13)/(2*t-2))*2,a=[n-7];for(let u=1;u<t-1;u++)a[u]=a[u-1]-s;return a.push(6),a.reverse()},r.getPositions=function(e){const t=[],n=r.getRowColCoords(e),s=n.length;for(let a=0;a<s;a++)for(let u=0;u<s;u++)a===0&&u===0||a===0&&u===s-1||a===s-1&&u===0||t.push([n[a],n[u]]);return t}})(x)),x}var tt={},Pt;function ce(){if(Pt)return tt;Pt=1;const r=U().getSymbolSize,o=7;return tt.getPositions=function(e){const t=r(e);return[[0,0],[t-o,0],[0,t-o]]},tt}var et={},Mt;function fe(){return Mt||(Mt=1,(function(r){r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const o={N1:3,N2:3,N3:40,N4:10};r.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},r.from=function(t){return r.isValid(t)?parseInt(t,10):void 0},r.getPenaltyN1=function(t){const n=t.size;let s=0,a=0,u=0,c=null,d=null;for(let p=0;p<n;p++){a=u=0,c=d=null;for(let h=0;h<n;h++){let f=t.get(p,h);f===c?a++:(a>=5&&(s+=o.N1+(a-5)),c=f,a=1),f=t.get(h,p),f===d?u++:(u>=5&&(s+=o.N1+(u-5)),d=f,u=1)}a>=5&&(s+=o.N1+(a-5)),u>=5&&(s+=o.N1+(u-5))}return s},r.getPenaltyN2=function(t){const n=t.size;let s=0;for(let a=0;a<n-1;a++)for(let u=0;u<n-1;u++){const c=t.get(a,u)+t.get(a,u+1)+t.get(a+1,u)+t.get(a+1,u+1);(c===4||c===0)&&s++}return s*o.N2},r.getPenaltyN3=function(t){const n=t.size;let s=0,a=0,u=0;for(let c=0;c<n;c++){a=u=0;for(let d=0;d<n;d++)a=a<<1&2047|t.get(c,d),d>=10&&(a===1488||a===93)&&s++,u=u<<1&2047|t.get(d,c),d>=10&&(u===1488||u===93)&&s++}return s*o.N3},r.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let u=0;u<s;u++)n+=t.data[u];return Math.abs(Math.ceil(n*100/s/5)-10)*o.N4};function i(e,t,n){switch(e){case r.Patterns.PATTERN000:return(t+n)%2===0;case r.Patterns.PATTERN001:return t%2===0;case r.Patterns.PATTERN010:return n%3===0;case r.Patterns.PATTERN011:return(t+n)%3===0;case r.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(n/3))%2===0;case r.Patterns.PATTERN101:return t*n%2+t*n%3===0;case r.Patterns.PATTERN110:return(t*n%2+t*n%3)%2===0;case r.Patterns.PATTERN111:return(t*n%3+(t+n)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}}r.applyMask=function(t,n){const s=n.size;for(let a=0;a<s;a++)for(let u=0;u<s;u++)n.isReserved(u,a)||n.xor(u,a,i(t,u,a))},r.getBestMask=function(t,n){const s=Object.keys(r.Patterns).length;let a=0,u=1/0;for(let c=0;c<s;c++){n(c),r.applyMask(c,t);const d=r.getPenaltyN1(t)+r.getPenaltyN2(t)+r.getPenaltyN3(t)+r.getPenaltyN4(t);r.applyMask(c,t),d<u&&(u=d,a=c)}return a}})(et)),et}var J={},bt;function $t(){if(bt)return J;bt=1;const r=yt(),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return J.getBlocksCount=function(t,n){switch(n){case r.L:return o[(t-1)*4+0];case r.M:return o[(t-1)*4+1];case r.Q:return o[(t-1)*4+2];case r.H:return o[(t-1)*4+3];default:return}},J.getTotalCodewordsCount=function(t,n){switch(n){case r.L:return i[(t-1)*4+0];case r.M:return i[(t-1)*4+1];case r.Q:return i[(t-1)*4+2];case r.H:return i[(t-1)*4+3];default:return}},J}var nt={},K={},St;function le(){if(St)return K;St=1;const r=new Uint8Array(512),o=new Uint8Array(256);return(function(){let e=1;for(let t=0;t<255;t++)r[t]=e,o[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)r[t]=r[t-255]})(),K.log=function(e){if(e<1)throw new Error("log("+e+")");return o[e]},K.exp=function(e){return r[e]},K.mul=function(e,t){return e===0||t===0?0:r[o[e]+o[t]]},K}var Lt;function de(){return Lt||(Lt=1,(function(r){const o=le();r.mul=function(e,t){const n=new Uint8Array(e.length+t.length-1);for(let s=0;s<e.length;s++)for(let a=0;a<t.length;a++)n[s+a]^=o.mul(e[s],t[a]);return n},r.mod=function(e,t){let n=new Uint8Array(e);for(;n.length-t.length>=0;){const s=n[0];for(let u=0;u<t.length;u++)n[u]^=o.mul(t[u],s);let a=0;for(;a<n.length&&n[a]===0;)a++;n=n.slice(a)}return n},r.generateECPolynomial=function(e){let t=new Uint8Array([1]);for(let n=0;n<e;n++)t=r.mul(t,new Uint8Array([1,o.exp(n)]));return t}})(nt)),nt}var rt,Dt;function ge(){if(Dt)return rt;Dt=1;const r=de();function o(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return o.prototype.initialize=function(e){this.degree=e,this.genPoly=r.generateECPolynomial(this.degree)},o.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=r.mod(t,this.genPoly),s=this.degree-n.length;if(s>0){const a=new Uint8Array(this.degree);return a.set(n,s),a}return n},rt=o,rt}var ot={},it={},st={},qt;function Wt(){return qt||(qt=1,st.isValid=function(o){return!isNaN(o)&&o>=1&&o<=40}),st}var L={},vt;function Zt(){if(vt)return L;vt=1;const r="[0-9]+",o="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const e="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
1
+ import{bo as re}from"./index-ybEI0zyv.js";function oe(r,o){for(var i=0;i<o.length;i++){const e=o[i];if(typeof e!="string"&&!Array.isArray(e)){for(const t in e)if(t!=="default"&&!(t in r)){const n=Object.getOwnPropertyDescriptor(e,t);n&&Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var z={},Q,Bt;function ie(){return Bt||(Bt=1,Q=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Q}var $={},_={},At;function U(){if(At)return _;At=1;let r;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return _.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17},_.getSymbolTotalCodewords=function(e){return o[e]},_.getBCHDigit=function(i){let e=0;for(;i!==0;)e++,i>>>=1;return e},_.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');r=e},_.isKanjiModeEnabled=function(){return typeof r<"u"},_.toSJIS=function(e){return r(e)},_}var W={},Rt;function yt(){return Rt||(Rt=1,(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function o(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+i)}}r.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4},r.from=function(e,t){if(r.isValid(e))return e;try{return o(e)}catch{return t}}})(W)),W}var Z,Tt;function se(){if(Tt)return Z;Tt=1;function r(){this.buffer=[],this.length=0}return r.prototype={get:function(o){const i=Math.floor(o/8);return(this.buffer[i]>>>7-o%8&1)===1},put:function(o,i){for(let e=0;e<i;e++)this.putBit((o>>>i-e-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(o){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),o&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Z=r,Z}var X,It;function ue(){if(It)return X;It=1;function r(o){if(!o||o<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=o,this.data=new Uint8Array(o*o),this.reservedBit=new Uint8Array(o*o)}return r.prototype.set=function(o,i,e,t){const n=o*this.size+i;this.data[n]=e,t&&(this.reservedBit[n]=!0)},r.prototype.get=function(o,i){return this.data[o*this.size+i]},r.prototype.xor=function(o,i,e){this.data[o*this.size+i]^=e},r.prototype.isReserved=function(o,i){return this.reservedBit[o*this.size+i]},X=r,X}var x={},Nt;function ae(){return Nt||(Nt=1,(function(r){const o=U().getSymbolSize;r.getRowColCoords=function(e){if(e===1)return[];const t=Math.floor(e/7)+2,n=o(e),s=n===145?26:Math.ceil((n-13)/(2*t-2))*2,a=[n-7];for(let u=1;u<t-1;u++)a[u]=a[u-1]-s;return a.push(6),a.reverse()},r.getPositions=function(e){const t=[],n=r.getRowColCoords(e),s=n.length;for(let a=0;a<s;a++)for(let u=0;u<s;u++)a===0&&u===0||a===0&&u===s-1||a===s-1&&u===0||t.push([n[a],n[u]]);return t}})(x)),x}var tt={},Pt;function ce(){if(Pt)return tt;Pt=1;const r=U().getSymbolSize,o=7;return tt.getPositions=function(e){const t=r(e);return[[0,0],[t-o,0],[0,t-o]]},tt}var et={},Mt;function fe(){return Mt||(Mt=1,(function(r){r.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const o={N1:3,N2:3,N3:40,N4:10};r.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},r.from=function(t){return r.isValid(t)?parseInt(t,10):void 0},r.getPenaltyN1=function(t){const n=t.size;let s=0,a=0,u=0,c=null,d=null;for(let p=0;p<n;p++){a=u=0,c=d=null;for(let h=0;h<n;h++){let f=t.get(p,h);f===c?a++:(a>=5&&(s+=o.N1+(a-5)),c=f,a=1),f=t.get(h,p),f===d?u++:(u>=5&&(s+=o.N1+(u-5)),d=f,u=1)}a>=5&&(s+=o.N1+(a-5)),u>=5&&(s+=o.N1+(u-5))}return s},r.getPenaltyN2=function(t){const n=t.size;let s=0;for(let a=0;a<n-1;a++)for(let u=0;u<n-1;u++){const c=t.get(a,u)+t.get(a,u+1)+t.get(a+1,u)+t.get(a+1,u+1);(c===4||c===0)&&s++}return s*o.N2},r.getPenaltyN3=function(t){const n=t.size;let s=0,a=0,u=0;for(let c=0;c<n;c++){a=u=0;for(let d=0;d<n;d++)a=a<<1&2047|t.get(c,d),d>=10&&(a===1488||a===93)&&s++,u=u<<1&2047|t.get(d,c),d>=10&&(u===1488||u===93)&&s++}return s*o.N3},r.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let u=0;u<s;u++)n+=t.data[u];return Math.abs(Math.ceil(n*100/s/5)-10)*o.N4};function i(e,t,n){switch(e){case r.Patterns.PATTERN000:return(t+n)%2===0;case r.Patterns.PATTERN001:return t%2===0;case r.Patterns.PATTERN010:return n%3===0;case r.Patterns.PATTERN011:return(t+n)%3===0;case r.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(n/3))%2===0;case r.Patterns.PATTERN101:return t*n%2+t*n%3===0;case r.Patterns.PATTERN110:return(t*n%2+t*n%3)%2===0;case r.Patterns.PATTERN111:return(t*n%3+(t+n)%2)%2===0;default:throw new Error("bad maskPattern:"+e)}}r.applyMask=function(t,n){const s=n.size;for(let a=0;a<s;a++)for(let u=0;u<s;u++)n.isReserved(u,a)||n.xor(u,a,i(t,u,a))},r.getBestMask=function(t,n){const s=Object.keys(r.Patterns).length;let a=0,u=1/0;for(let c=0;c<s;c++){n(c),r.applyMask(c,t);const d=r.getPenaltyN1(t)+r.getPenaltyN2(t)+r.getPenaltyN3(t)+r.getPenaltyN4(t);r.applyMask(c,t),d<u&&(u=d,a=c)}return a}})(et)),et}var J={},bt;function $t(){if(bt)return J;bt=1;const r=yt(),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return J.getBlocksCount=function(t,n){switch(n){case r.L:return o[(t-1)*4+0];case r.M:return o[(t-1)*4+1];case r.Q:return o[(t-1)*4+2];case r.H:return o[(t-1)*4+3];default:return}},J.getTotalCodewordsCount=function(t,n){switch(n){case r.L:return i[(t-1)*4+0];case r.M:return i[(t-1)*4+1];case r.Q:return i[(t-1)*4+2];case r.H:return i[(t-1)*4+3];default:return}},J}var nt={},K={},St;function le(){if(St)return K;St=1;const r=new Uint8Array(512),o=new Uint8Array(256);return(function(){let e=1;for(let t=0;t<255;t++)r[t]=e,o[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)r[t]=r[t-255]})(),K.log=function(e){if(e<1)throw new Error("log("+e+")");return o[e]},K.exp=function(e){return r[e]},K.mul=function(e,t){return e===0||t===0?0:r[o[e]+o[t]]},K}var Lt;function de(){return Lt||(Lt=1,(function(r){const o=le();r.mul=function(e,t){const n=new Uint8Array(e.length+t.length-1);for(let s=0;s<e.length;s++)for(let a=0;a<t.length;a++)n[s+a]^=o.mul(e[s],t[a]);return n},r.mod=function(e,t){let n=new Uint8Array(e);for(;n.length-t.length>=0;){const s=n[0];for(let u=0;u<t.length;u++)n[u]^=o.mul(t[u],s);let a=0;for(;a<n.length&&n[a]===0;)a++;n=n.slice(a)}return n},r.generateECPolynomial=function(e){let t=new Uint8Array([1]);for(let n=0;n<e;n++)t=r.mul(t,new Uint8Array([1,o.exp(n)]));return t}})(nt)),nt}var rt,Dt;function ge(){if(Dt)return rt;Dt=1;const r=de();function o(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return o.prototype.initialize=function(e){this.degree=e,this.genPoly=r.generateECPolynomial(this.degree)},o.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=r.mod(t,this.genPoly),s=this.degree-n.length;if(s>0){const a=new Uint8Array(this.degree);return a.set(n,s),a}return n},rt=o,rt}var ot={},it={},st={},qt;function Wt(){return qt||(qt=1,st.isValid=function(o){return!isNaN(o)&&o>=1&&o<=40}),st}var L={},vt;function Zt(){if(vt)return L;vt=1;const r="[0-9]+",o="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const e="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
2
2
  ]))+`;L.KANJI=new RegExp(i,"g"),L.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),L.BYTE=new RegExp(e,"g"),L.NUMERIC=new RegExp(r,"g"),L.ALPHANUMERIC=new RegExp(o,"g");const t=new RegExp("^"+i+"$"),n=new RegExp("^"+r+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return L.testKanji=function(u){return t.test(u)},L.testNumeric=function(u){return n.test(u)},L.testAlphanumeric=function(u){return s.test(u)},L}var _t;function F(){return _t||(_t=1,(function(r){const o=Wt(),i=Zt();r.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},r.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},r.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},r.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},r.MIXED={bit:-1},r.getCharCountIndicator=function(n,s){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!o.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?n.ccBits[0]:s<27?n.ccBits[1]:n.ccBits[2]},r.getBestModeForData=function(n){return i.testNumeric(n)?r.NUMERIC:i.testAlphanumeric(n)?r.ALPHANUMERIC:i.testKanji(n)?r.KANJI:r.BYTE},r.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},r.isValid=function(n){return n&&n.bit&&n.ccBits};function e(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return r.NUMERIC;case"alphanumeric":return r.ALPHANUMERIC;case"kanji":return r.KANJI;case"byte":return r.BYTE;default:throw new Error("Unknown mode: "+t)}}r.from=function(n,s){if(r.isValid(n))return n;try{return e(n)}catch{return s}}})(it)),it}var Ut;function he(){return Ut||(Ut=1,(function(r){const o=U(),i=$t(),e=yt(),t=F(),n=Wt(),s=7973,a=o.getBCHDigit(s);function u(h,f,N){for(let P=1;P<=40;P++)if(f<=r.getCapacity(P,N,h))return P}function c(h,f){return t.getCharCountIndicator(h,f)+4}function d(h,f){let N=0;return h.forEach(function(P){const b=c(P.mode,f);N+=b+P.getBitsLength()}),N}function p(h,f){for(let N=1;N<=40;N++)if(d(h,N)<=r.getCapacity(N,f,t.MIXED))return N}r.from=function(f,N){return n.isValid(f)?parseInt(f,10):N},r.getCapacity=function(f,N,P){if(!n.isValid(f))throw new Error("Invalid QR Code version");typeof P>"u"&&(P=t.BYTE);const b=o.getSymbolTotalCodewords(f),R=i.getTotalCodewordsCount(f,N),M=(b-R)*8;if(P===t.MIXED)return M;const T=M-c(P,f);switch(P){case t.NUMERIC:return Math.floor(T/10*3);case t.ALPHANUMERIC:return Math.floor(T/11*2);case t.KANJI:return Math.floor(T/13);case t.BYTE:default:return Math.floor(T/8)}},r.getBestVersionForData=function(f,N){let P;const b=e.from(N,e.M);if(Array.isArray(f)){if(f.length>1)return p(f,b);if(f.length===0)return 1;P=f[0]}else P=f;return u(P.mode,P.getLength(),b)},r.getEncodedBits=function(f){if(!n.isValid(f)||f<7)throw new Error("Invalid QR Code version");let N=f<<12;for(;o.getBCHDigit(N)-a>=0;)N^=s<<o.getBCHDigit(N)-a;return f<<12|N}})(ot)),ot}var ut={},Ft;function me(){if(Ft)return ut;Ft=1;const r=U(),o=1335,i=21522,e=r.getBCHDigit(o);return ut.getEncodedBits=function(n,s){const a=n.bit<<3|s;let u=a<<10;for(;r.getBCHDigit(u)-e>=0;)u^=o<<r.getBCHDigit(u)-e;return(a<<10|u)^i},ut}var at={},ct,kt;function we(){if(kt)return ct;kt=1;const r=F();function o(i){this.mode=r.NUMERIC,this.data=i.toString()}return o.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){let t,n,s;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),s=parseInt(n,10),e.put(s,10);const a=this.data.length-t;a>0&&(n=this.data.substr(t),s=parseInt(n,10),e.put(s,a*3+1))},ct=o,ct}var ft,zt;function ye(){if(zt)return ft;zt=1;const r=F(),o=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(e){this.mode=r.ALPHANUMERIC,this.data=e}return i.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let s=o.indexOf(this.data[n])*45;s+=o.indexOf(this.data[n+1]),t.put(s,11)}this.data.length%2&&t.put(o.indexOf(this.data[n]),6)},ft=i,ft}var lt,Vt;function Ce(){if(Vt)return lt;Vt=1;const r=F();function o(i){this.mode=r.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return o.getBitsLength=function(e){return e*8},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(i){for(let e=0,t=this.data.length;e<t;e++)i.put(this.data[e],8)},lt=o,lt}var dt,Kt;function Ee(){if(Kt)return dt;Kt=1;const r=F(),o=U();function i(e){this.mode=r.KANJI,this.data=e}return i.getBitsLength=function(t){return t*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=o.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},dt=i,dt}var gt={exports:{}},Ht;function pe(){return Ht||(Ht=1,(function(r){var o={single_source_shortest_paths:function(i,e,t){var n={},s={};s[e]=0;var a=o.PriorityQueue.make();a.push(e,0);for(var u,c,d,p,h,f,N,P,b;!a.empty();){u=a.pop(),c=u.value,p=u.cost,h=i[c]||{};for(d in h)h.hasOwnProperty(d)&&(f=h[d],N=p+f,P=s[d],b=typeof s[d]>"u",(b||P>N)&&(s[d]=N,a.push(d,N),n[d]=c))}if(typeof t<"u"&&typeof s[t]>"u"){var R=["Could not find a path from ",e," to ",t,"."].join("");throw new Error(R)}return n},extract_shortest_path_from_predecessor_list:function(i,e){for(var t=[],n=e;n;)t.push(n),i[n],n=i[n];return t.reverse(),t},find_path:function(i,e,t){var n=o.single_source_shortest_paths(i,e,t);return o.extract_shortest_path_from_predecessor_list(n,t)},PriorityQueue:{make:function(i){var e=o.PriorityQueue,t={},n;i=i||{};for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t.queue=[],t.sorter=i.sorter||e.default_sorter,t},default_sorter:function(i,e){return i.cost-e.cost},push:function(i,e){var t={value:i,cost:e};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};r.exports=o})(gt)),gt.exports}var Jt;function Be(){return Jt||(Jt=1,(function(r){const o=F(),i=we(),e=ye(),t=Ce(),n=Ee(),s=Zt(),a=U(),u=pe();function c(R){return unescape(encodeURIComponent(R)).length}function d(R,M,T){const B=[];let S;for(;(S=R.exec(T))!==null;)B.push({data:S[0],index:S.index,mode:M,length:S[0].length});return B}function p(R){const M=d(s.NUMERIC,o.NUMERIC,R),T=d(s.ALPHANUMERIC,o.ALPHANUMERIC,R);let B,S;return a.isKanjiModeEnabled()?(B=d(s.BYTE,o.BYTE,R),S=d(s.KANJI,o.KANJI,R)):(B=d(s.BYTE_KANJI,o.BYTE,R),S=[]),M.concat(T,B,S).sort(function(C,y){return C.index-y.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function h(R,M){switch(M){case o.NUMERIC:return i.getBitsLength(R);case o.ALPHANUMERIC:return e.getBitsLength(R);case o.KANJI:return n.getBitsLength(R);case o.BYTE:return t.getBitsLength(R)}}function f(R){return R.reduce(function(M,T){const B=M.length-1>=0?M[M.length-1]:null;return B&&B.mode===T.mode?(M[M.length-1].data+=T.data,M):(M.push(T),M)},[])}function N(R){const M=[];for(let T=0;T<R.length;T++){const B=R[T];switch(B.mode){case o.NUMERIC:M.push([B,{data:B.data,mode:o.ALPHANUMERIC,length:B.length},{data:B.data,mode:o.BYTE,length:B.length}]);break;case o.ALPHANUMERIC:M.push([B,{data:B.data,mode:o.BYTE,length:B.length}]);break;case o.KANJI:M.push([B,{data:B.data,mode:o.BYTE,length:c(B.data)}]);break;case o.BYTE:M.push([{data:B.data,mode:o.BYTE,length:c(B.data)}])}}return M}function P(R,M){const T={},B={start:{}};let S=["start"];for(let g=0;g<R.length;g++){const C=R[g],y=[];for(let l=0;l<C.length;l++){const A=C[l],m=""+g+l;y.push(m),T[m]={node:A,lastCount:0},B[m]={};for(let E=0;E<S.length;E++){const w=S[E];T[w]&&T[w].node.mode===A.mode?(B[w][m]=h(T[w].lastCount+A.length,A.mode)-h(T[w].lastCount,A.mode),T[w].lastCount+=A.length):(T[w]&&(T[w].lastCount=A.length),B[w][m]=h(A.length,A.mode)+4+o.getCharCountIndicator(A.mode,M))}}S=y}for(let g=0;g<S.length;g++)B[S[g]].end=0;return{map:B,table:T}}function b(R,M){let T;const B=o.getBestModeForData(R);if(T=o.from(M,B),T!==o.BYTE&&T.bit<B.bit)throw new Error('"'+R+'" cannot be encoded with mode '+o.toString(T)+`.
4
4
  Suggested mode is: `+o.toString(B));switch(T===o.KANJI&&!a.isKanjiModeEnabled()&&(T=o.BYTE),T){case o.NUMERIC:return new i(R);case o.ALPHANUMERIC:return new e(R);case o.KANJI:return new n(R);case o.BYTE:return new t(R)}}r.fromArray=function(M){return M.reduce(function(T,B){return typeof B=="string"?T.push(b(B,null)):B.data&&T.push(b(B.data,B.mode)),T},[])},r.fromString=function(M,T){const B=p(M,a.isKanjiModeEnabled()),S=N(B),g=P(S,T),C=u.find_path(g.map,"start","end"),y=[];for(let l=1;l<C.length-1;l++)y.push(g.table[C[l]].node);return r.fromArray(f(y))},r.rawSplit=function(M){return r.fromArray(p(M,a.isKanjiModeEnabled()))}})(at)),at}var Ot;function Ae(){if(Ot)return $;Ot=1;const r=U(),o=yt(),i=se(),e=ue(),t=ae(),n=ce(),s=fe(),a=$t(),u=ge(),c=he(),d=me(),p=F(),h=Be();function f(g,C){const y=g.size,l=n.getPositions(C);for(let A=0;A<l.length;A++){const m=l[A][0],E=l[A][1];for(let w=-1;w<=7;w++)if(!(m+w<=-1||y<=m+w))for(let I=-1;I<=7;I++)E+I<=-1||y<=E+I||(w>=0&&w<=6&&(I===0||I===6)||I>=0&&I<=6&&(w===0||w===6)||w>=2&&w<=4&&I>=2&&I<=4?g.set(m+w,E+I,!0,!0):g.set(m+w,E+I,!1,!0))}}function N(g){const C=g.size;for(let y=8;y<C-8;y++){const l=y%2===0;g.set(y,6,l,!0),g.set(6,y,l,!0)}}function P(g,C){const y=t.getPositions(C);for(let l=0;l<y.length;l++){const A=y[l][0],m=y[l][1];for(let E=-2;E<=2;E++)for(let w=-2;w<=2;w++)E===-2||E===2||w===-2||w===2||E===0&&w===0?g.set(A+E,m+w,!0,!0):g.set(A+E,m+w,!1,!0)}}function b(g,C){const y=g.size,l=c.getEncodedBits(C);let A,m,E;for(let w=0;w<18;w++)A=Math.floor(w/3),m=w%3+y-8-3,E=(l>>w&1)===1,g.set(A,m,E,!0),g.set(m,A,E,!0)}function R(g,C,y){const l=g.size,A=d.getEncodedBits(C,y);let m,E;for(m=0;m<15;m++)E=(A>>m&1)===1,m<6?g.set(m,8,E,!0):m<8?g.set(m+1,8,E,!0):g.set(l-15+m,8,E,!0),m<8?g.set(8,l-m-1,E,!0):m<9?g.set(8,15-m-1+1,E,!0):g.set(8,15-m-1,E,!0);g.set(l-8,8,1,!0)}function M(g,C){const y=g.size;let l=-1,A=y-1,m=7,E=0;for(let w=y-1;w>0;w-=2)for(w===6&&w--;;){for(let I=0;I<2;I++)if(!g.isReserved(A,w-I)){let v=!1;E<C.length&&(v=(C[E]>>>m&1)===1),g.set(A,w-I,v),m--,m===-1&&(E++,m=7)}if(A+=l,A<0||y<=A){A-=l,l=-l;break}}}function T(g,C,y){const l=new i;y.forEach(function(I){l.put(I.mode.bit,4),l.put(I.getLength(),p.getCharCountIndicator(I.mode,g)),I.write(l)});const A=r.getSymbolTotalCodewords(g),m=a.getTotalCodewordsCount(g,C),E=(A-m)*8;for(l.getLengthInBits()+4<=E&&l.put(0,4);l.getLengthInBits()%8!==0;)l.putBit(0);const w=(E-l.getLengthInBits())/8;for(let I=0;I<w;I++)l.put(I%2?17:236,8);return B(l,g,C)}function B(g,C,y){const l=r.getSymbolTotalCodewords(C),A=a.getTotalCodewordsCount(C,y),m=l-A,E=a.getBlocksCount(C,y),w=l%E,I=E-w,v=Math.floor(l/E),V=Math.floor(m/E),te=V+1,Ct=v-V,ee=new u(Ct);let O=0;const H=new Array(E),Et=new Array(E);let j=0;const ne=new Uint8Array(g.buffer);for(let k=0;k<E;k++){const G=k<I?V:te;H[k]=ne.slice(O,O+G),Et[k]=ee.encode(H[k]),O+=G,j=Math.max(j,G)}const Y=new Uint8Array(l);let pt=0,D,q;for(D=0;D<j;D++)for(q=0;q<E;q++)D<H[q].length&&(Y[pt++]=H[q][D]);for(D=0;D<Ct;D++)for(q=0;q<E;q++)Y[pt++]=Et[q][D];return Y}function S(g,C,y,l){let A;if(Array.isArray(g))A=h.fromArray(g);else if(typeof g=="string"){let v=C;if(!v){const V=h.rawSplit(g);v=c.getBestVersionForData(V,y)}A=h.fromString(g,v||40)}else throw new Error("Invalid data");const m=c.getBestVersionForData(A,y);if(!m)throw new Error("The amount of data is too big to be stored in a QR Code");if(!C)C=m;else if(C<m)throw new Error(`
@@ -1 +1 @@
1
- import{$ as I,r as o,aG as we,aH as Ve,aI as ne,aJ as F,aK as de,aL as pe,aM as ge,aN as me,j as e,aO as Ae,aP as De,aQ as ke,aR as Ie,aS as _e,aT as ve,aU as Oe,aV as Be,aW as Pe,aX as be,aY as je,aZ as Fe,a_ as He,a$ as Ue,b0 as We,b1 as qe,b2 as Ye,b3 as Je,n as ie,b4 as Ke,c as Re,al as V,B as G,y as te,z as se,A as ue,b5 as Xe,aA as Ge,b6 as Qe,b7 as Ze,b8 as et,b9 as tt,ba as st,bb as at,bc as nt,bd as it,be as rt,bf as lt,F as ot,T as X,bg as ct,bh as dt,bi as ut,bj as mt,bk as xt,bl as ft,bm as ht}from"./index-CuWbxCsX.js";import{M as Te,b as ye}from"./html-view-BPOrX4do.js";const pt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],gt=I("circle-alert",pt);const vt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],bt=I("circle-minus",vt);const jt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],yt=I("external-link",jt);const Nt=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Me=I("file-code-corner",Nt);const Ct=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],wt=I("gauge",Ct);const kt=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Rt=I("lightbulb",kt);const Tt=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],Mt=I("scale",Tt);const Et=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],zt=I("video",Et),Ee=o.createContext(void 0);function xe(){const t=o.useContext(Ee);if(t===void 0)throw new Error(we(64));return t}let $t=(function(t){return t.activationDirection="data-activation-direction",t.orientation="data-orientation",t})({});const fe={tabActivationDirection:t=>({[$t.activationDirection]:t})},St=o.forwardRef(function(a,s){const{className:n,defaultValue:r=0,onValueChange:i,orientation:c="horizontal",render:u,value:h,style:b,...p}=a,y=a.defaultValue!==void 0,T=o.useRef([]),[E,d]=o.useState(()=>new Map),[l,R]=Ve({controlled:h,default:r,name:"Tabs",state:"value"}),S=h!==void 0,[f,C]=o.useState(()=>new Map),w=o.useCallback(m=>{if(m===void 0)return null;for(const[v,N]of f.entries())if(N!=null&&m===(N.value??N.index))return v;return null},[f]),[A,L]=o.useState(()=>({previousValue:l,tabActivationDirection:"none"})),{previousValue:k,tabActivationDirection:M}=A;let g=M,z=!1;k!==l&&(g=Ne(k,l,c,f),z=k!=null&&l!=null&&w(l)==null);const x=z?k:l,$=k!==x||M!==g;ne(()=>{$&&L({previousValue:x,tabActivationDirection:g})},[x,$,g]);const Q=F((m,v)=>{const N=Ne(l,m,c,f);v.activationDirection=N,i?.(m,v),!v.isCanceled&&R(m)}),Y=F((m,v)=>{i?.(m,de(v,void 0,void 0,{activationDirection:"none"}))}),_=F((m,v)=>{d(N=>{if(N.get(m)===v)return N;const D=new Map(N);return D.set(m,v),D})}),W=F((m,v)=>{d(N=>{if(!N.has(m)||N.get(m)!==v)return N;const D=new Map(N);return D.delete(m),D})}),Z=o.useCallback(m=>E.get(m),[E]),ee=o.useCallback(m=>{for(const v of f.values())if(m===v?.value)return v?.id},[f]),re=o.useMemo(()=>({getTabElementBySelectedValue:w,getTabIdByPanelValue:ee,getTabPanelIdByValue:Z,onValueChange:Q,orientation:c,registerMountedTabPanel:_,setTabMap:C,unregisterMountedTabPanel:W,tabActivationDirection:g,value:l}),[w,ee,Z,Q,c,_,C,W,g,l]),J=o.useMemo(()=>{for(const m of f.values())if(m!=null&&m.value===l)return m},[f,l]),le=o.useMemo(()=>{for(const m of f.values())if(m!=null&&!m.disabled)return m.value},[f]),j=o.useRef(!y),O=o.useRef(y),oe=o.useRef(!1);ne(()=>{if(S)return;function m(B,K){R(B),L(ce=>ce.previousValue===B&&ce.tabActivationDirection==="none"?ce:{previousValue:B,tabActivationDirection:"none"}),Y(B,K),j.current=!1}if(f.size===0){if(!oe.current||l===null)return;m(null,ge);return}oe.current=!0;const v=J?.disabled,N=J==null&&l!==null;if(!v&&l===r&&(O.current=!1),O.current&&v&&l===r)return;const D=j.current;if(v||N){const B=le??null;if(l===B){j.current=!1;return}let K=ge;D?K=pe:v&&(K=De),m(B,K);return}D&&J!=null&&(Y(l,pe),j.current=!1)},[r,le,S,Y,J,R,f,l]);const Le=me("div",a,{state:{orientation:c,tabActivationDirection:g},ref:s,props:p,stateAttributesMapping:fe});return e.jsx(Ee.Provider,{value:re,children:e.jsx(Ae,{elementsRef:T,children:Le})})});function Ne(t,a,s,n){if(t==null||a==null)return"none";let r=null,i=null;for(const[h,b]of n.entries()){if(b==null)continue;const p=b.value??b.index;if(t===p&&(r=h),a===p&&(i=h),r!=null&&i!=null)break}if(r==null||i==null)return r!==i&&(typeof t=="number"||typeof t=="string")&&typeof t==typeof a?s==="horizontal"?a>t?"right":"left":a>t?"down":"up":"none";const c=r.getBoundingClientRect(),u=i.getBoundingClientRect();if(s==="horizontal"){if(u.left<c.left)return"left";if(u.left>c.left)return"right"}else{if(u.top<c.top)return"up";if(u.top>c.top)return"down"}return"none"}const ze=o.createContext(void 0);function Lt(){const t=o.useContext(ze);if(t===void 0)throw new Error(we(65));return t}const Vt=o.forwardRef(function(a,s){const{className:n,disabled:r=!1,render:i,value:c,id:u,nativeButton:h=!0,style:b,...p}=a,{value:y,getTabPanelIdByValue:T,orientation:E}=xe(),{activateOnFocus:d,highlightedTabIndex:l,onTabActivation:R,registerTabResizeObserverElement:S,setHighlightedTabIndex:f,tabsListElement:C}=Lt(),w=ke(u),A=o.useMemo(()=>({disabled:r,id:w,value:c}),[r,w,c]),{compositeProps:L,compositeRef:k,index:M}=Ie({metadata:A}),g=c===y,z=o.useRef(!1),x=o.useRef(null);o.useEffect(()=>{const j=x.current;if(j)return S(j)},[S]),ne(()=>{if(z.current){z.current=!1;return}if(!(g&&M>-1&&l!==M))return;const j=C;if(j!=null){const O=_e(ve(j));if(O&&Oe(j,O))return}r||f(M)},[g,M,l,f,r,C]);const{getButtonProps:$,buttonRef:Q}=Be({disabled:r,native:h,focusableWhenDisabled:!0}),Y=T(c),_=o.useRef(!1),W=o.useRef(!1);function Z(j){g||r||R(c,de(be,j.nativeEvent,void 0,{activationDirection:"none"}))}function ee(j){g||(M>-1&&!r&&f(M),!r&&d&&(!_.current||_.current&&W.current)&&R(c,de(be,j.nativeEvent,void 0,{activationDirection:"none"})))}function re(j){if(g||r)return;_.current=!0;function O(){_.current=!1,W.current=!1}(!j.button||j.button===0)&&(W.current=!0,ve(j.currentTarget).addEventListener("pointerup",O,{once:!0}))}return me("button",a,{state:{disabled:r,active:g,orientation:E},ref:[s,Q,k,x],props:[L,{role:"tab","aria-controls":Y,"aria-selected":g,id:w,onClick:Z,onFocus:ee,onPointerDown:re,[Pe]:g?"":void 0,onKeyDownCapture(){z.current=!0}},p,$]})});let At=(function(t){return t.index="data-index",t.activationDirection="data-activation-direction",t.orientation="data-orientation",t.hidden="data-hidden",t[t.startingStyle=je.startingStyle]="startingStyle",t[t.endingStyle=je.endingStyle]="endingStyle",t})({});const Dt={...fe,...qe},It=o.forwardRef(function(a,s){const{className:n,value:r,render:i,keepMounted:c=!1,style:u,...h}=a,{value:b,getTabIdByPanelValue:p,orientation:y,tabActivationDirection:T,registerMountedTabPanel:E,unregisterMountedTabPanel:d}=xe(),l=ke(),R=o.useMemo(()=>({id:l,value:r}),[l,r]),{ref:S,index:f}=Fe({metadata:R}),C=r===b,{mounted:w,transitionStatus:A,setMounted:L}=He(C),k=!w,M=p(r),g={hidden:k,orientation:y,tabActivationDirection:T,transitionStatus:A},z=o.useRef(null),x=me("div",a,{state:g,ref:[s,S,z],props:[{"aria-labelledby":M,hidden:k,id:l,role:"tabpanel",tabIndex:C?0:-1,inert:Ue(!C),[At.index]:f},h],stateAttributesMapping:Dt});return We({open:C,ref:z,onComplete(){C||L(!1)}}),ne(()=>{if(!(k&&!c)&&l!=null)return E(r,l),()=>{d(r,l)}},[k,c,r,l,E,d]),c||w?x:null}),_t=o.forwardRef(function(a,s){const{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:c,style:u,...h}=a,{onValueChange:b,orientation:p,value:y,setTabMap:T,tabActivationDirection:E}=xe(),[d,l]=o.useState(0),[R,S]=o.useState(null),f=o.useRef(new Set),C=o.useRef(new Set),w=o.useRef(null);o.useEffect(()=>{if(typeof ResizeObserver>"u")return;const x=new ResizeObserver(()=>{f.current.forEach($=>{$()})});return w.current=x,R&&x.observe(R),C.current.forEach($=>{x.observe($)}),()=>{x.disconnect(),w.current=null}},[R]);const A=F(x=>(f.current.add(x),()=>{f.current.delete(x)})),L=F(x=>(C.current.add(x),w.current?.observe(x),()=>{C.current.delete(x),w.current?.unobserve(x)})),k=F((x,$)=>{x!==y&&b(x,$)}),M={orientation:p,tabActivationDirection:E},g={"aria-orientation":p==="vertical"?"vertical":void 0,role:"tablist"},z=o.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:d,registerIndicatorUpdateListener:A,registerTabResizeObserverElement:L,onTabActivation:k,setHighlightedTabIndex:l,tabsListElement:R}),[n,d,A,L,k,l,R]);return e.jsx(ze.Provider,{value:z,children:e.jsx(Ye,{render:c,className:r,style:u,state:M,refs:[s,S],props:[g,h],stateAttributesMapping:fe,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:p,onHighlightedIndexChange:l,onMapChange:T,disabledIndices:Je})})});function $e({className:t,orientation:a="horizontal",...s}){return e.jsx(St,{"data-slot":"tabs","data-orientation":a,className:ie("group/tabs flex gap-2 data-horizontal:flex-col",t),...s})}const Ot=Ke("group/tabs-list inline-flex w-fit items-center justify-center rounded-2xl p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col group-data-vertical/tabs:p-1 data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Se({className:t,variant:a="default",...s}){return e.jsx(_t,{"data-slot":"tabs-list","data-variant":a,className:ie(Ot({variant:a}),t),...s})}function H({className:t,...a}){return e.jsx(Vt,{"data-slot":"tabs-trigger",className:ie("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-2xl border border-transparent! px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-3 group-data-vertical/tabs:py-0.5 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",t),...a})}function U({className:t,...a}){return e.jsx(It,{"data-slot":"tabs-content",className:ie("flex-1 text-sm outline-none",t),...a})}function P({title:t,children:a}){return e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-base font-semibold tracking-tight",children:t}),a]})}function q({items:t,empty:a}){return t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:a}):e.jsx("ul",{className:"space-y-2 text-sm leading-6",children:t.map(s=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:"mt-2 size-1.5 shrink-0 rounded-full bg-current"}),e.jsx("span",{children:s})]},s))})}function ae({references:t,onOpen:a}){return t.length===0?null:e.jsxs("fieldset",{className:"flex flex-wrap gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Repository references"}),t.map(s=>e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-auto min-h-8 max-w-full justify-start gap-2 py-1.5 font-mono text-xs",onClick:()=>a(s),children:[e.jsx(Me,{className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[s.label??s.path,s.line===void 0?"":`:${s.line}`]})]},`${s.path}:${s.line??""}`))]})}function Bt({option:t,onOpen:a}){return e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-8 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsx(V,{variant:"secondary",children:"Option"}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:t.name}),e.jsx("p",{className:"max-w-3xl text-base leading-7 text-muted-foreground",children:t.summary}),e.jsx(ae,{references:t.references,onOpen:a})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("h2",{className:"mb-3 flex items-center gap-2 font-medium",children:[e.jsx(Xe,{className:"size-4 text-emerald-600 dark:text-emerald-400"})," Pros"]}),e.jsx(q,{items:t.pros,empty:"No advantages recorded."})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("h2",{className:"mb-3 flex items-center gap-2 font-medium",children:[e.jsx(Ge,{className:"size-4 text-rose-600 dark:text-rose-400"})," Cons"]}),e.jsx(q,{items:t.cons,empty:"No disadvantages recorded."})]})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(P,{title:"Risks",children:t.risks.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No risks recorded."}):e.jsx("div",{className:"space-y-3",children:t.risks.map(s=>e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"font-medium",children:s.summary}),s.severity===void 0?null:e.jsx(V,{variant:"outline",className:"capitalize",children:s.severity})]}),s.mitigation===void 0?null:e.jsxs("p",{className:"mt-2 leading-6 text-muted-foreground",children:["Mitigation: ",s.mitigation]})]},s.summary))})}),e.jsx(P,{title:"Effort",children:e.jsx("p",{className:"rounded-lg border bg-muted/20 p-4 text-sm leading-6",children:t.effort??"No effort assessment recorded."})})]})]})}const Pt={poor:"border-rose-500/30 bg-rose-500/10",fair:"border-amber-500/30 bg-amber-500/10",good:"border-sky-500/30 bg-sky-500/10",strong:"border-emerald-500/30 bg-emerald-500/10"};function Ft({document:t}){return e.jsxs("div",{className:"mx-auto w-full max-w-7xl space-y-7 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsxs(V,{variant:"secondary",className:"gap-1.5",children:[e.jsx(Mt,{className:"size-3.5"})," Comparison"]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:"Compare the options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Assessments are explanatory signals, not code truth or review state."})]}),t.criteria.map(a=>e.jsxs("section",{className:"space-y-3 rounded-xl border bg-card p-4 sm:p-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:a.label}),a.description===void 0?null:e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a.description})]}),e.jsx("div",{"data-testid":`decision-comparison-${a.id}`,className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:t.options.map(s=>{const n=t.assessments.find(r=>r.optionId===s.id&&r.criterionId===a.id);return e.jsxs("article",{className:`min-w-0 rounded-lg border p-4 ${n===void 0?"bg-muted/20":Pt[n.rating]}`,children:[e.jsx("h3",{className:"truncate text-sm font-semibold",children:s.name}),n===void 0?e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Not assessed"}):e.jsxs(e.Fragment,{children:[e.jsx(V,{variant:"outline",className:"mt-2 capitalize",children:n.rating}),e.jsx("p",{className:"mt-3 text-sm leading-6",children:n.note})]})]},s.id)})})]},a.id))]})}function Ht({document:t,repoPath:a}){const s=Re(i=>i.openTab),n=i=>{a!==void 0&&s(te("file",`${a}/${i.path}`,{title:ue(i.path),...i.line===void 0?{}:{line:i.line}},se()))},r=t.decision===void 0?"Recommendation":"Decision";return e.jsxs($e,{defaultValue:"summary",className:"flex h-full min-h-0 flex-col gap-0",children:[e.jsx("div",{className:"shrink-0 overflow-x-auto border-b px-3 py-2 sm:px-5",children:e.jsxs(Se,{variant:"line","aria-label":"Decision Canvas views",className:"w-max min-w-full justify-start",children:[e.jsx(H,{value:"summary",children:"Summary"}),t.options.map(i=>e.jsx(H,{value:`option-${i.id}`,children:i.name},i.id)),e.jsx(H,{value:"compare",children:"Compare"}),e.jsx(H,{value:"recommendation",children:r})]})}),e.jsx(U,{value:"summary",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-8 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-4",children:[e.jsxs(V,{variant:"secondary",className:"gap-1.5",children:[e.jsx(Rt,{className:"size-3.5"})," Decision / RFC"]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:t.title}),e.jsx("p",{className:"max-w-3xl text-lg leading-8 text-muted-foreground",children:t.summary}),e.jsx(ae,{references:t.references,onOpen:n})]}),t.context===void 0?null:e.jsx(P,{title:"Context",children:e.jsx("p",{className:"max-w-3xl whitespace-pre-wrap text-sm leading-7",children:t.context})}),e.jsx(P,{title:"Options at a glance",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:t.options.map(i=>e.jsxs("div",{className:"rounded-xl border bg-card p-4",children:[e.jsx("h3",{className:"font-semibold",children:i.name}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.summary})]},i.id))})})]})}),t.options.map(i=>e.jsx(U,{value:`option-${i.id}`,className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Bt,{option:i,onOpen:n})},i.id)),e.jsx(U,{value:"compare",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Ft,{document:t})}),e.jsx(U,{value:"recommendation",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-8 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs(V,{variant:"secondary",className:"gap-1.5",children:[e.jsx(wt,{className:"size-3.5"})," ",r]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:t.recommendation.summary}),e.jsxs(V,{variant:"outline",className:"capitalize",children:[t.recommendation.confidence," confidence"]})]}),e.jsx(P,{title:"Rationale",children:e.jsx(q,{items:t.recommendation.rationale,empty:"No rationale recorded."})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(P,{title:"Assumptions",children:e.jsx(q,{items:t.recommendation.assumptions,empty:"No assumptions recorded."})}),e.jsx(P,{title:"What would change this",children:e.jsx(q,{items:t.recommendation.changeConditions,empty:"No change conditions recorded."})})]}),e.jsx(ae,{references:t.recommendation.references,onOpen:n}),t.decision===void 0?null:e.jsxs("section",{className:"space-y-4 rounded-xl border border-primary/30 bg-primary/5 p-5 sm:p-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[e.jsx(gt,{className:"size-5"})," Recorded final decision"]}),e.jsx("p",{className:"text-base leading-7",children:t.decision.summary}),e.jsx(q,{items:t.decision.rationale,empty:"No additional rationale recorded."}),e.jsx(ae,{references:t.decision.references,onOpen:n})]})]})})]})}function Ce(t,a){return t===null?null:`${t}/${a.split("/").map(encodeURIComponent).join("/")}`}function Ut({references:t,onOpen:a}){return t.length===0?null:e.jsxs("fieldset",{className:"flex flex-wrap gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Code references"}),t.map(s=>{const n=s.startLine===void 0?"":s.endLine===void 0||s.endLine===s.startLine?`:${s.startLine}`:`:${s.startLine}-${s.endLine}`;return e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-auto min-h-8 max-w-full justify-start gap-2 py-1.5 font-mono text-xs",onClick:()=>a(s),children:[e.jsx(Me,{className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[s.label??s.path,n]})]},`${s.path}:${s.startLine??""}:${s.endLine??""}`)})]})}function Wt({section:t,onOpen:a,onComment:s}){return e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-6 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:t.title}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Comment on this section"}),e.jsx(Ut,{references:t.references,onOpen:a})]}),t.prose===""?null:e.jsx(Te,{content:t.prose,compact:!0,className:"overflow-visible"}),t.svg===void 0?null:e.jsx("div",{className:"overflow-hidden rounded-xl border bg-card",style:{height:t.htmlHeight??448},children:e.jsx(ye,{html:t.svg,title:`${t.title} diagram`})}),t.html===void 0?null:e.jsx("div",{className:"overflow-hidden rounded-xl border bg-card",style:{height:t.htmlHeight??448},children:e.jsx(ye,{html:t.html,title:`${t.title} visual`})})]})}function qt({asset:t,baseUrl:a}){if(t.kind==="link")return e.jsxs("a",{className:"flex items-center gap-3 rounded-xl border bg-card p-4 text-sm hover:bg-muted/40",href:t.href,target:"_blank",rel:"noreferrer",children:[e.jsx(yt,{className:"size-4 shrink-0"}),e.jsx("span",{className:"font-medium",children:t.label})]});const s=Ce(a,t.path);return s===null?e.jsxs("div",{className:"rounded-xl border bg-card p-4 text-sm",children:[e.jsx("p",{className:"font-medium",children:t.label}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Attachment is unavailable."})]}):t.kind==="image"?e.jsxs("figure",{className:"overflow-hidden rounded-xl border bg-card",children:[e.jsx("img",{src:s,alt:t.label,className:"max-h-[36rem] w-full object-contain"}),e.jsx("figcaption",{className:"border-t px-4 py-3 text-sm font-medium",children:t.label})]}):t.kind==="video"?e.jsxs("figure",{className:"overflow-hidden rounded-xl border bg-card",children:[e.jsxs("video",{className:"max-h-[36rem] w-full bg-black",controls:!0,preload:"metadata",children:[e.jsx("source",{src:s,type:t.mime}),t.captions===void 0?null:e.jsx("track",{kind:"captions",src:Ce(a,t.captions)??void 0,srcLang:"en",label:"Captions",default:!0}),"Your browser cannot play this video."]}),e.jsxs("figcaption",{className:"flex items-center gap-2 border-t px-4 py-3 text-sm font-medium",children:[e.jsx(zt,{className:"size-4 shrink-0"}),t.label]})]}):e.jsxs("a",{className:"flex items-center gap-3 rounded-xl border bg-card p-4 text-sm hover:bg-muted/40",href:s,target:"_blank",rel:"noreferrer",children:[e.jsx(ot,{className:"size-4 shrink-0"}),e.jsx("span",{className:"font-medium",children:t.label})]})}const Yt={pass:rt,fail:it,skip:bt};function Jt({document:t,assetBaseUrl:a}){const s=t.evidence;return s===void 0?null:e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-7 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx(V,{variant:"secondary",children:"Evidence"}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:s.title})]}),s.checks.length===0?null:e.jsx("section",{className:"grid gap-3 md:grid-cols-2",children:s.checks.map(n=>{const r=Yt[n.status];return e.jsxs("div",{className:"rounded-xl border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"size-4 shrink-0"}),e.jsx("p",{className:"font-medium",children:n.label}),e.jsx(V,{variant:"outline",className:"ml-auto capitalize",children:n.status})]}),n.detail===void 0?null:e.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:n.detail})]},n.label)})}),s.assets.length===0?null:e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-base font-semibold",children:"Attachments"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:s.assets.map(n=>e.jsx(qt,{asset:n,baseUrl:a},n.kind==="link"?n.href:n.path))})]})]})}function Kt({canvasId:t}){const s=lt().filter(n=>n.anchor?.kind==="changeset"||n.anchor?.kind==="canvas"&&n.anchor.canvasId===t);return s.length===0?null:e.jsxs("section",{className:"mx-auto w-full max-w-5xl space-y-3 border-t p-5 sm:p-8",children:[e.jsx("h2",{className:"text-base font-semibold",children:"Review comments"}),s.map(n=>e.jsxs("article",{className:"rounded-lg border bg-card p-3 text-sm",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:n.anchor?.kind==="changeset"?"Whole changeset":n.anchor?.kind!=="canvas"||n.anchor.section===void 0?"Review Canvas":n.anchor.section}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap",children:n.body}),n.agentReply===void 0?null:e.jsxs("div",{className:"mt-3 border-l-2 border-border pl-3","data-testid":`canvas-comment-agent-${n.id}`,children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Agent"}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap text-muted-foreground",children:n.agentReply.body})]})]},n.id))]})}function Xt({document:t,repoPath:a,assetBaseUrl:s,canvasId:n,reviewTarget:r}){const i=Re(d=>d.openTab),{add:c}=Qe(),[u,h]=o.useState(null),[b,p]=o.useState(""),y=d=>{h(d),p("")},T=d=>{if(a===void 0)return;const l=d.startLine;if(r?.type==="working"||r?.type==="range"){i(te("diff",d.path,{title:ue(d.path),...r.type==="range"?{base:r.base}:{},...l===void 0?{}:{line:l}},se()));return}if(r?.type==="commit"){i(te("commit",r.hash,{title:r.hash.slice(0,12),reviewFilePath:d.path,...l===void 0?{}:{line:l}},se()));return}i(te("file",`${a}/${d.path}`,{title:ue(d.path),...l===void 0?{}:{line:l}},se()))};return e.jsxs(e.Fragment,{children:[e.jsxs($e,{defaultValue:"section-0",className:"flex h-full min-h-0 flex-col gap-0",children:[e.jsx("div",{className:"shrink-0 overflow-x-auto border-b px-3 py-2 sm:px-5",children:e.jsxs(Se,{variant:"line","aria-label":"Review Canvas sections",className:"w-max min-w-full justify-start",children:[t.sections.map((d,l)=>e.jsx(H,{value:`section-${l}`,children:d.title},d.title)),t.evidence===void 0?null:e.jsx(H,{value:"evidence",children:"Evidence"}),e.jsx(H,{value:"discussion",children:"Discussion"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>y("changeset"),children:"Comment on change"})]})}),t.sections.map((d,l)=>e.jsxs(U,{value:`section-${l}`,className:"min-h-0 flex-1 overflow-y-auto",children:[l!==0||t.summary===void 0?null:e.jsx("p",{className:"mx-auto max-w-5xl px-5 pt-5 text-base leading-7 text-muted-foreground sm:px-8",children:t.summary}),e.jsx(Wt,{section:d,onOpen:T,onComment:()=>y(d.title)})]},d.title)),e.jsx(U,{value:"evidence",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Jt,{document:t,assetBaseUrl:s})}),e.jsx(U,{value:"discussion",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Kt,{canvasId:n??t.title})})]}),e.jsx(Ze,{open:u!==null,onOpenChange:d=>!d&&h(null),children:e.jsxs(et,{children:[e.jsx(tt,{children:e.jsx(st,{children:"Review comment"})}),e.jsx(at,{value:b,onChange:d=>p(d.target.value),placeholder:"What should the reviewer know?"}),e.jsx(nt,{children:e.jsx(G,{type:"button",onClick:()=>{u===null||b.trim()===""||c({body:b.trim(),anchor:u==="changeset"?{kind:"changeset"}:{kind:"canvas",canvasId:n??t.title,section:u}}).then(()=>h(null))},children:"Add comment"})})]})})]})}function Gt({content:t,repoPath:a,assetBaseUrl:s=null,canvasId:n,reviewTarget:r}){let i;try{i=JSON.parse(t)}catch(u){return e.jsxs("div",{"data-testid":X.structuredCanvasInvalid,className:"p-6 text-sm text-destructive",children:["Invalid structured Canvas: ",u instanceof Error?u.message:"invalid JSON"]})}const c=ct.safeParse(i);return c.success?c.data.template==="review"?e.jsx("div",{"data-testid":X.structuredCanvas,className:"h-full min-h-0",children:e.jsx(Xt,{document:c.data,repoPath:a,assetBaseUrl:s,canvasId:n,reviewTarget:r})}):e.jsx("div",{"data-testid":X.structuredCanvas,className:"h-full min-h-0",children:e.jsx(Ht,{document:c.data,repoPath:a})}):e.jsxs("div",{"data-testid":X.structuredCanvasInvalid,className:"p-6 text-sm text-destructive",children:["Invalid structured Canvas: ",dt(c.error)]})}function Qt(t){if(typeof t!="object"||t===null)return null;const a=t;return a.source!=="porcelain-canvas"?null:typeof a.href=="string"&&/^https?:\/\//i.test(a.href)?a.href:null}function he({projectId:t,canvasId:a,worktreePath:s,environmentId:n,revision:r}){const{mint:i}=mt(),u=xt(n??null)?.session.baseUrl()??ft(),[h,b]=o.useState(null),[p,y]=o.useState(null);return o.useEffect(()=>{let T=!1;b(null),y(null);const E={projectId:t,canvasId:a,...s===void 0?{}:{worktreePath:s},...n===void 0?{}:{environmentId:n}};return ht((async()=>{try{const d=await i(E);T||b(`${u}/canvas/${d}`)}catch(d){T||y(d instanceof Error&&d.message.length>0?d.message:"Could not open this Canvas.")}})(),"fallback"),()=>{T=!0}},[t,a,s,n,u,i,r]),{src:h,error:p}}function Zt({projectId:t,canvasId:a,title:s,worktreePath:n,environmentId:r,revision:i}){const{src:c,error:u}=he({projectId:t,canvasId:a,worktreePath:n,environmentId:r,revision:i}),h=o.useRef(null);return o.useEffect(()=>{function b(p){if(p.source!==h.current?.contentWindow)return;const y=Qt(p.data);y!==null&&window.open(y,"_blank","noopener,noreferrer")}return window.addEventListener("message",b),()=>window.removeEventListener("message",b)},[]),u!==null?e.jsx("div",{className:"p-4 text-sm text-destructive",children:u}):c===null?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):e.jsx("iframe",{ref:h,"data-testid":X.canvasIframe,title:s,src:c,sandbox:"allow-scripts",className:"h-full w-full flex-1 border-0 bg-background"})}function es({projectId:t,canvasId:a,content:s,worktreePath:n,environmentId:r,revision:i,reviewTarget:c}){const{src:u}=he({projectId:t,canvasId:a,worktreePath:n,environmentId:r,revision:i});return e.jsx(Gt,{content:s,canvasId:a,repoPath:n,assetBaseUrl:u===null?null:`${u}/assets`,reviewTarget:c})}function is({projectId:t,canvasId:a,worktreePath:s,environmentId:n,reviewTarget:r}){const{canvas:i,isLoading:c,loadError:u}=ut(t,a,s??null,n??null);return u!==null?e.jsx("div",{className:"p-4 text-sm text-destructive",children:u}):c||i===void 0?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):i.record.kind==="markdown"?e.jsx(ts,{projectId:t,canvasId:a,content:i.content,worktreePath:s,environmentId:n,revision:`${i.record.updatedAt}\0${i.content}`}):i.record.kind==="structured"?e.jsx(es,{projectId:t,canvasId:a,content:i.content,worktreePath:s,environmentId:n,revision:`${i.record.updatedAt}\0${i.content}`,reviewTarget:r}):e.jsx(Zt,{projectId:t,canvasId:a,title:i.record.title,worktreePath:s,environmentId:n,revision:`${i.record.updatedAt}\0${i.content}`})}function ts({projectId:t,canvasId:a,content:s,worktreePath:n,environmentId:r,revision:i}){const{src:c}=he({projectId:t,canvasId:a,worktreePath:n,environmentId:r,revision:i});return e.jsx(Te,{content:s,assetBaseUrl:c===null?null:`${c}/assets`})}export{is as CanvasView};
1
+ import{$ as I,r as o,aG as we,aH as Ve,aI as ne,aJ as F,aK as de,aL as pe,aM as ge,aN as me,j as e,aO as Ae,aP as De,aQ as ke,aR as Ie,aS as _e,aT as ve,aU as Oe,aV as Be,aW as Pe,aX as be,aY as je,aZ as Fe,a_ as He,a$ as Ue,b0 as We,b1 as qe,b2 as Ye,b3 as Je,n as ie,b4 as Ke,c as Re,al as V,B as G,y as te,z as se,A as ue,b5 as Xe,aA as Ge,b6 as Qe,b7 as Ze,b8 as et,b9 as tt,ba as st,bb as at,bc as nt,bd as it,be as rt,bf as lt,F as ot,T as X,bg as ct,bh as dt,bi as ut,bj as mt,bk as xt,bl as ft,bm as ht}from"./index-ybEI0zyv.js";import{M as Te,b as ye}from"./html-view-CDqcReet.js";const pt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],gt=I("circle-alert",pt);const vt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],bt=I("circle-minus",vt);const jt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],yt=I("external-link",jt);const Nt=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Me=I("file-code-corner",Nt);const Ct=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],wt=I("gauge",Ct);const kt=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Rt=I("lightbulb",kt);const Tt=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]],Mt=I("scale",Tt);const Et=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],zt=I("video",Et),Ee=o.createContext(void 0);function xe(){const t=o.useContext(Ee);if(t===void 0)throw new Error(we(64));return t}let $t=(function(t){return t.activationDirection="data-activation-direction",t.orientation="data-orientation",t})({});const fe={tabActivationDirection:t=>({[$t.activationDirection]:t})},St=o.forwardRef(function(a,s){const{className:n,defaultValue:r=0,onValueChange:i,orientation:c="horizontal",render:u,value:h,style:b,...p}=a,y=a.defaultValue!==void 0,T=o.useRef([]),[E,d]=o.useState(()=>new Map),[l,R]=Ve({controlled:h,default:r,name:"Tabs",state:"value"}),S=h!==void 0,[f,C]=o.useState(()=>new Map),w=o.useCallback(m=>{if(m===void 0)return null;for(const[v,N]of f.entries())if(N!=null&&m===(N.value??N.index))return v;return null},[f]),[A,L]=o.useState(()=>({previousValue:l,tabActivationDirection:"none"})),{previousValue:k,tabActivationDirection:M}=A;let g=M,z=!1;k!==l&&(g=Ne(k,l,c,f),z=k!=null&&l!=null&&w(l)==null);const x=z?k:l,$=k!==x||M!==g;ne(()=>{$&&L({previousValue:x,tabActivationDirection:g})},[x,$,g]);const Q=F((m,v)=>{const N=Ne(l,m,c,f);v.activationDirection=N,i?.(m,v),!v.isCanceled&&R(m)}),Y=F((m,v)=>{i?.(m,de(v,void 0,void 0,{activationDirection:"none"}))}),_=F((m,v)=>{d(N=>{if(N.get(m)===v)return N;const D=new Map(N);return D.set(m,v),D})}),W=F((m,v)=>{d(N=>{if(!N.has(m)||N.get(m)!==v)return N;const D=new Map(N);return D.delete(m),D})}),Z=o.useCallback(m=>E.get(m),[E]),ee=o.useCallback(m=>{for(const v of f.values())if(m===v?.value)return v?.id},[f]),re=o.useMemo(()=>({getTabElementBySelectedValue:w,getTabIdByPanelValue:ee,getTabPanelIdByValue:Z,onValueChange:Q,orientation:c,registerMountedTabPanel:_,setTabMap:C,unregisterMountedTabPanel:W,tabActivationDirection:g,value:l}),[w,ee,Z,Q,c,_,C,W,g,l]),J=o.useMemo(()=>{for(const m of f.values())if(m!=null&&m.value===l)return m},[f,l]),le=o.useMemo(()=>{for(const m of f.values())if(m!=null&&!m.disabled)return m.value},[f]),j=o.useRef(!y),O=o.useRef(y),oe=o.useRef(!1);ne(()=>{if(S)return;function m(B,K){R(B),L(ce=>ce.previousValue===B&&ce.tabActivationDirection==="none"?ce:{previousValue:B,tabActivationDirection:"none"}),Y(B,K),j.current=!1}if(f.size===0){if(!oe.current||l===null)return;m(null,ge);return}oe.current=!0;const v=J?.disabled,N=J==null&&l!==null;if(!v&&l===r&&(O.current=!1),O.current&&v&&l===r)return;const D=j.current;if(v||N){const B=le??null;if(l===B){j.current=!1;return}let K=ge;D?K=pe:v&&(K=De),m(B,K);return}D&&J!=null&&(Y(l,pe),j.current=!1)},[r,le,S,Y,J,R,f,l]);const Le=me("div",a,{state:{orientation:c,tabActivationDirection:g},ref:s,props:p,stateAttributesMapping:fe});return e.jsx(Ee.Provider,{value:re,children:e.jsx(Ae,{elementsRef:T,children:Le})})});function Ne(t,a,s,n){if(t==null||a==null)return"none";let r=null,i=null;for(const[h,b]of n.entries()){if(b==null)continue;const p=b.value??b.index;if(t===p&&(r=h),a===p&&(i=h),r!=null&&i!=null)break}if(r==null||i==null)return r!==i&&(typeof t=="number"||typeof t=="string")&&typeof t==typeof a?s==="horizontal"?a>t?"right":"left":a>t?"down":"up":"none";const c=r.getBoundingClientRect(),u=i.getBoundingClientRect();if(s==="horizontal"){if(u.left<c.left)return"left";if(u.left>c.left)return"right"}else{if(u.top<c.top)return"up";if(u.top>c.top)return"down"}return"none"}const ze=o.createContext(void 0);function Lt(){const t=o.useContext(ze);if(t===void 0)throw new Error(we(65));return t}const Vt=o.forwardRef(function(a,s){const{className:n,disabled:r=!1,render:i,value:c,id:u,nativeButton:h=!0,style:b,...p}=a,{value:y,getTabPanelIdByValue:T,orientation:E}=xe(),{activateOnFocus:d,highlightedTabIndex:l,onTabActivation:R,registerTabResizeObserverElement:S,setHighlightedTabIndex:f,tabsListElement:C}=Lt(),w=ke(u),A=o.useMemo(()=>({disabled:r,id:w,value:c}),[r,w,c]),{compositeProps:L,compositeRef:k,index:M}=Ie({metadata:A}),g=c===y,z=o.useRef(!1),x=o.useRef(null);o.useEffect(()=>{const j=x.current;if(j)return S(j)},[S]),ne(()=>{if(z.current){z.current=!1;return}if(!(g&&M>-1&&l!==M))return;const j=C;if(j!=null){const O=_e(ve(j));if(O&&Oe(j,O))return}r||f(M)},[g,M,l,f,r,C]);const{getButtonProps:$,buttonRef:Q}=Be({disabled:r,native:h,focusableWhenDisabled:!0}),Y=T(c),_=o.useRef(!1),W=o.useRef(!1);function Z(j){g||r||R(c,de(be,j.nativeEvent,void 0,{activationDirection:"none"}))}function ee(j){g||(M>-1&&!r&&f(M),!r&&d&&(!_.current||_.current&&W.current)&&R(c,de(be,j.nativeEvent,void 0,{activationDirection:"none"})))}function re(j){if(g||r)return;_.current=!0;function O(){_.current=!1,W.current=!1}(!j.button||j.button===0)&&(W.current=!0,ve(j.currentTarget).addEventListener("pointerup",O,{once:!0}))}return me("button",a,{state:{disabled:r,active:g,orientation:E},ref:[s,Q,k,x],props:[L,{role:"tab","aria-controls":Y,"aria-selected":g,id:w,onClick:Z,onFocus:ee,onPointerDown:re,[Pe]:g?"":void 0,onKeyDownCapture(){z.current=!0}},p,$]})});let At=(function(t){return t.index="data-index",t.activationDirection="data-activation-direction",t.orientation="data-orientation",t.hidden="data-hidden",t[t.startingStyle=je.startingStyle]="startingStyle",t[t.endingStyle=je.endingStyle]="endingStyle",t})({});const Dt={...fe,...qe},It=o.forwardRef(function(a,s){const{className:n,value:r,render:i,keepMounted:c=!1,style:u,...h}=a,{value:b,getTabIdByPanelValue:p,orientation:y,tabActivationDirection:T,registerMountedTabPanel:E,unregisterMountedTabPanel:d}=xe(),l=ke(),R=o.useMemo(()=>({id:l,value:r}),[l,r]),{ref:S,index:f}=Fe({metadata:R}),C=r===b,{mounted:w,transitionStatus:A,setMounted:L}=He(C),k=!w,M=p(r),g={hidden:k,orientation:y,tabActivationDirection:T,transitionStatus:A},z=o.useRef(null),x=me("div",a,{state:g,ref:[s,S,z],props:[{"aria-labelledby":M,hidden:k,id:l,role:"tabpanel",tabIndex:C?0:-1,inert:Ue(!C),[At.index]:f},h],stateAttributesMapping:Dt});return We({open:C,ref:z,onComplete(){C||L(!1)}}),ne(()=>{if(!(k&&!c)&&l!=null)return E(r,l),()=>{d(r,l)}},[k,c,r,l,E,d]),c||w?x:null}),_t=o.forwardRef(function(a,s){const{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:c,style:u,...h}=a,{onValueChange:b,orientation:p,value:y,setTabMap:T,tabActivationDirection:E}=xe(),[d,l]=o.useState(0),[R,S]=o.useState(null),f=o.useRef(new Set),C=o.useRef(new Set),w=o.useRef(null);o.useEffect(()=>{if(typeof ResizeObserver>"u")return;const x=new ResizeObserver(()=>{f.current.forEach($=>{$()})});return w.current=x,R&&x.observe(R),C.current.forEach($=>{x.observe($)}),()=>{x.disconnect(),w.current=null}},[R]);const A=F(x=>(f.current.add(x),()=>{f.current.delete(x)})),L=F(x=>(C.current.add(x),w.current?.observe(x),()=>{C.current.delete(x),w.current?.unobserve(x)})),k=F((x,$)=>{x!==y&&b(x,$)}),M={orientation:p,tabActivationDirection:E},g={"aria-orientation":p==="vertical"?"vertical":void 0,role:"tablist"},z=o.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:d,registerIndicatorUpdateListener:A,registerTabResizeObserverElement:L,onTabActivation:k,setHighlightedTabIndex:l,tabsListElement:R}),[n,d,A,L,k,l,R]);return e.jsx(ze.Provider,{value:z,children:e.jsx(Ye,{render:c,className:r,style:u,state:M,refs:[s,S],props:[g,h],stateAttributesMapping:fe,highlightedIndex:d,enableHomeAndEndKeys:!0,loopFocus:i,orientation:p,onHighlightedIndexChange:l,onMapChange:T,disabledIndices:Je})})});function $e({className:t,orientation:a="horizontal",...s}){return e.jsx(St,{"data-slot":"tabs","data-orientation":a,className:ie("group/tabs flex gap-2 data-horizontal:flex-col",t),...s})}const Ot=Ke("group/tabs-list inline-flex w-fit items-center justify-center rounded-2xl p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col group-data-vertical/tabs:p-1 data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Se({className:t,variant:a="default",...s}){return e.jsx(_t,{"data-slot":"tabs-list","data-variant":a,className:ie(Ot({variant:a}),t),...s})}function H({className:t,...a}){return e.jsx(Vt,{"data-slot":"tabs-trigger",className:ie("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-2xl border border-transparent! px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-3 group-data-vertical/tabs:py-0.5 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",t),...a})}function U({className:t,...a}){return e.jsx(It,{"data-slot":"tabs-content",className:ie("flex-1 text-sm outline-none",t),...a})}function P({title:t,children:a}){return e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-base font-semibold tracking-tight",children:t}),a]})}function q({items:t,empty:a}){return t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:a}):e.jsx("ul",{className:"space-y-2 text-sm leading-6",children:t.map(s=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{"aria-hidden":"true",className:"mt-2 size-1.5 shrink-0 rounded-full bg-current"}),e.jsx("span",{children:s})]},s))})}function ae({references:t,onOpen:a}){return t.length===0?null:e.jsxs("fieldset",{className:"flex flex-wrap gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Repository references"}),t.map(s=>e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-auto min-h-8 max-w-full justify-start gap-2 py-1.5 font-mono text-xs",onClick:()=>a(s),children:[e.jsx(Me,{className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[s.label??s.path,s.line===void 0?"":`:${s.line}`]})]},`${s.path}:${s.line??""}`))]})}function Bt({option:t,onOpen:a}){return e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-8 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsx(V,{variant:"secondary",children:"Option"}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:t.name}),e.jsx("p",{className:"max-w-3xl text-base leading-7 text-muted-foreground",children:t.summary}),e.jsx(ae,{references:t.references,onOpen:a})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("h2",{className:"mb-3 flex items-center gap-2 font-medium",children:[e.jsx(Xe,{className:"size-4 text-emerald-600 dark:text-emerald-400"})," Pros"]}),e.jsx(q,{items:t.pros,empty:"No advantages recorded."})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("h2",{className:"mb-3 flex items-center gap-2 font-medium",children:[e.jsx(Ge,{className:"size-4 text-rose-600 dark:text-rose-400"})," Cons"]}),e.jsx(q,{items:t.cons,empty:"No disadvantages recorded."})]})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(P,{title:"Risks",children:t.risks.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No risks recorded."}):e.jsx("div",{className:"space-y-3",children:t.risks.map(s=>e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("p",{className:"font-medium",children:s.summary}),s.severity===void 0?null:e.jsx(V,{variant:"outline",className:"capitalize",children:s.severity})]}),s.mitigation===void 0?null:e.jsxs("p",{className:"mt-2 leading-6 text-muted-foreground",children:["Mitigation: ",s.mitigation]})]},s.summary))})}),e.jsx(P,{title:"Effort",children:e.jsx("p",{className:"rounded-lg border bg-muted/20 p-4 text-sm leading-6",children:t.effort??"No effort assessment recorded."})})]})]})}const Pt={poor:"border-rose-500/30 bg-rose-500/10",fair:"border-amber-500/30 bg-amber-500/10",good:"border-sky-500/30 bg-sky-500/10",strong:"border-emerald-500/30 bg-emerald-500/10"};function Ft({document:t}){return e.jsxs("div",{className:"mx-auto w-full max-w-7xl space-y-7 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsxs(V,{variant:"secondary",className:"gap-1.5",children:[e.jsx(Mt,{className:"size-3.5"})," Comparison"]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:"Compare the options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Assessments are explanatory signals, not code truth or review state."})]}),t.criteria.map(a=>e.jsxs("section",{className:"space-y-3 rounded-xl border bg-card p-4 sm:p-5",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold",children:a.label}),a.description===void 0?null:e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a.description})]}),e.jsx("div",{"data-testid":`decision-comparison-${a.id}`,className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3",children:t.options.map(s=>{const n=t.assessments.find(r=>r.optionId===s.id&&r.criterionId===a.id);return e.jsxs("article",{className:`min-w-0 rounded-lg border p-4 ${n===void 0?"bg-muted/20":Pt[n.rating]}`,children:[e.jsx("h3",{className:"truncate text-sm font-semibold",children:s.name}),n===void 0?e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Not assessed"}):e.jsxs(e.Fragment,{children:[e.jsx(V,{variant:"outline",className:"mt-2 capitalize",children:n.rating}),e.jsx("p",{className:"mt-3 text-sm leading-6",children:n.note})]})]},s.id)})})]},a.id))]})}function Ht({document:t,repoPath:a}){const s=Re(i=>i.openTab),n=i=>{a!==void 0&&s(te("file",`${a}/${i.path}`,{title:ue(i.path),...i.line===void 0?{}:{line:i.line}},se()))},r=t.decision===void 0?"Recommendation":"Decision";return e.jsxs($e,{defaultValue:"summary",className:"flex h-full min-h-0 flex-col gap-0",children:[e.jsx("div",{className:"shrink-0 overflow-x-auto border-b px-3 py-2 sm:px-5",children:e.jsxs(Se,{variant:"line","aria-label":"Decision Canvas views",className:"w-max min-w-full justify-start",children:[e.jsx(H,{value:"summary",children:"Summary"}),t.options.map(i=>e.jsx(H,{value:`option-${i.id}`,children:i.name},i.id)),e.jsx(H,{value:"compare",children:"Compare"}),e.jsx(H,{value:"recommendation",children:r})]})}),e.jsx(U,{value:"summary",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-8 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-4",children:[e.jsxs(V,{variant:"secondary",className:"gap-1.5",children:[e.jsx(Rt,{className:"size-3.5"})," Decision / RFC"]}),e.jsx("h1",{className:"text-3xl font-semibold tracking-tight sm:text-4xl",children:t.title}),e.jsx("p",{className:"max-w-3xl text-lg leading-8 text-muted-foreground",children:t.summary}),e.jsx(ae,{references:t.references,onOpen:n})]}),t.context===void 0?null:e.jsx(P,{title:"Context",children:e.jsx("p",{className:"max-w-3xl whitespace-pre-wrap text-sm leading-7",children:t.context})}),e.jsx(P,{title:"Options at a glance",children:e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:t.options.map(i=>e.jsxs("div",{className:"rounded-xl border bg-card p-4",children:[e.jsx("h3",{className:"font-semibold",children:i.name}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:i.summary})]},i.id))})})]})}),t.options.map(i=>e.jsx(U,{value:`option-${i.id}`,className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Bt,{option:i,onOpen:n})},i.id)),e.jsx(U,{value:"compare",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Ft,{document:t})}),e.jsx(U,{value:"recommendation",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-8 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs(V,{variant:"secondary",className:"gap-1.5",children:[e.jsx(wt,{className:"size-3.5"})," ",r]}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:t.recommendation.summary}),e.jsxs(V,{variant:"outline",className:"capitalize",children:[t.recommendation.confidence," confidence"]})]}),e.jsx(P,{title:"Rationale",children:e.jsx(q,{items:t.recommendation.rationale,empty:"No rationale recorded."})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(P,{title:"Assumptions",children:e.jsx(q,{items:t.recommendation.assumptions,empty:"No assumptions recorded."})}),e.jsx(P,{title:"What would change this",children:e.jsx(q,{items:t.recommendation.changeConditions,empty:"No change conditions recorded."})})]}),e.jsx(ae,{references:t.recommendation.references,onOpen:n}),t.decision===void 0?null:e.jsxs("section",{className:"space-y-4 rounded-xl border border-primary/30 bg-primary/5 p-5 sm:p-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-semibold",children:[e.jsx(gt,{className:"size-5"})," Recorded final decision"]}),e.jsx("p",{className:"text-base leading-7",children:t.decision.summary}),e.jsx(q,{items:t.decision.rationale,empty:"No additional rationale recorded."}),e.jsx(ae,{references:t.decision.references,onOpen:n})]})]})})]})}function Ce(t,a){return t===null?null:`${t}/${a.split("/").map(encodeURIComponent).join("/")}`}function Ut({references:t,onOpen:a}){return t.length===0?null:e.jsxs("fieldset",{className:"flex flex-wrap gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Code references"}),t.map(s=>{const n=s.startLine===void 0?"":s.endLine===void 0||s.endLine===s.startLine?`:${s.startLine}`:`:${s.startLine}-${s.endLine}`;return e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-auto min-h-8 max-w-full justify-start gap-2 py-1.5 font-mono text-xs",onClick:()=>a(s),children:[e.jsx(Me,{className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[s.label??s.path,n]})]},`${s.path}:${s.startLine??""}:${s.endLine??""}`)})]})}function Wt({section:t,onOpen:a,onComment:s}){return e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-6 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:t.title}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:s,children:"Comment on this section"}),e.jsx(Ut,{references:t.references,onOpen:a})]}),t.prose===""?null:e.jsx(Te,{content:t.prose,compact:!0,className:"overflow-visible"}),t.svg===void 0?null:e.jsx("div",{className:"overflow-hidden rounded-xl border bg-card",style:{height:t.htmlHeight??448},children:e.jsx(ye,{html:t.svg,title:`${t.title} diagram`})}),t.html===void 0?null:e.jsx("div",{className:"overflow-hidden rounded-xl border bg-card",style:{height:t.htmlHeight??448},children:e.jsx(ye,{html:t.html,title:`${t.title} visual`})})]})}function qt({asset:t,baseUrl:a}){if(t.kind==="link")return e.jsxs("a",{className:"flex items-center gap-3 rounded-xl border bg-card p-4 text-sm hover:bg-muted/40",href:t.href,target:"_blank",rel:"noreferrer",children:[e.jsx(yt,{className:"size-4 shrink-0"}),e.jsx("span",{className:"font-medium",children:t.label})]});const s=Ce(a,t.path);return s===null?e.jsxs("div",{className:"rounded-xl border bg-card p-4 text-sm",children:[e.jsx("p",{className:"font-medium",children:t.label}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Attachment is unavailable."})]}):t.kind==="image"?e.jsxs("figure",{className:"overflow-hidden rounded-xl border bg-card",children:[e.jsx("img",{src:s,alt:t.label,className:"max-h-[36rem] w-full object-contain"}),e.jsx("figcaption",{className:"border-t px-4 py-3 text-sm font-medium",children:t.label})]}):t.kind==="video"?e.jsxs("figure",{className:"overflow-hidden rounded-xl border bg-card",children:[e.jsxs("video",{className:"max-h-[36rem] w-full bg-black",controls:!0,preload:"metadata",children:[e.jsx("source",{src:s,type:t.mime}),t.captions===void 0?null:e.jsx("track",{kind:"captions",src:Ce(a,t.captions)??void 0,srcLang:"en",label:"Captions",default:!0}),"Your browser cannot play this video."]}),e.jsxs("figcaption",{className:"flex items-center gap-2 border-t px-4 py-3 text-sm font-medium",children:[e.jsx(zt,{className:"size-4 shrink-0"}),t.label]})]}):e.jsxs("a",{className:"flex items-center gap-3 rounded-xl border bg-card p-4 text-sm hover:bg-muted/40",href:s,target:"_blank",rel:"noreferrer",children:[e.jsx(ot,{className:"size-4 shrink-0"}),e.jsx("span",{className:"font-medium",children:t.label})]})}const Yt={pass:rt,fail:it,skip:bt};function Jt({document:t,assetBaseUrl:a}){const s=t.evidence;return s===void 0?null:e.jsxs("article",{className:"mx-auto w-full max-w-5xl space-y-7 p-5 sm:p-8",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx(V,{variant:"secondary",children:"Evidence"}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight sm:text-3xl",children:s.title})]}),s.checks.length===0?null:e.jsx("section",{className:"grid gap-3 md:grid-cols-2",children:s.checks.map(n=>{const r=Yt[n.status];return e.jsxs("div",{className:"rounded-xl border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"size-4 shrink-0"}),e.jsx("p",{className:"font-medium",children:n.label}),e.jsx(V,{variant:"outline",className:"ml-auto capitalize",children:n.status})]}),n.detail===void 0?null:e.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:n.detail})]},n.label)})}),s.assets.length===0?null:e.jsxs("section",{className:"space-y-3",children:[e.jsx("h2",{className:"text-base font-semibold",children:"Attachments"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:s.assets.map(n=>e.jsx(qt,{asset:n,baseUrl:a},n.kind==="link"?n.href:n.path))})]})]})}function Kt({canvasId:t}){const s=lt().filter(n=>n.anchor?.kind==="changeset"||n.anchor?.kind==="canvas"&&n.anchor.canvasId===t);return s.length===0?null:e.jsxs("section",{className:"mx-auto w-full max-w-5xl space-y-3 border-t p-5 sm:p-8",children:[e.jsx("h2",{className:"text-base font-semibold",children:"Review comments"}),s.map(n=>e.jsxs("article",{className:"rounded-lg border bg-card p-3 text-sm",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:n.anchor?.kind==="changeset"?"Whole changeset":n.anchor?.kind!=="canvas"||n.anchor.section===void 0?"Review Canvas":n.anchor.section}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap",children:n.body}),n.agentReply===void 0?null:e.jsxs("div",{className:"mt-3 border-l-2 border-border pl-3","data-testid":`canvas-comment-agent-${n.id}`,children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Agent"}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap text-muted-foreground",children:n.agentReply.body})]})]},n.id))]})}function Xt({document:t,repoPath:a,assetBaseUrl:s,canvasId:n,reviewTarget:r}){const i=Re(d=>d.openTab),{add:c}=Qe(),[u,h]=o.useState(null),[b,p]=o.useState(""),y=d=>{h(d),p("")},T=d=>{if(a===void 0)return;const l=d.startLine;if(r?.type==="working"||r?.type==="range"){i(te("diff",d.path,{title:ue(d.path),...r.type==="range"?{base:r.base}:{},...l===void 0?{}:{line:l}},se()));return}if(r?.type==="commit"){i(te("commit",r.hash,{title:r.hash.slice(0,12),reviewFilePath:d.path,...l===void 0?{}:{line:l}},se()));return}i(te("file",`${a}/${d.path}`,{title:ue(d.path),...l===void 0?{}:{line:l}},se()))};return e.jsxs(e.Fragment,{children:[e.jsxs($e,{defaultValue:"section-0",className:"flex h-full min-h-0 flex-col gap-0",children:[e.jsx("div",{className:"shrink-0 overflow-x-auto border-b px-3 py-2 sm:px-5",children:e.jsxs(Se,{variant:"line","aria-label":"Review Canvas sections",className:"w-max min-w-full justify-start",children:[t.sections.map((d,l)=>e.jsx(H,{value:`section-${l}`,children:d.title},d.title)),t.evidence===void 0?null:e.jsx(H,{value:"evidence",children:"Evidence"}),e.jsx(H,{value:"discussion",children:"Discussion"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>y("changeset"),children:"Comment on change"})]})}),t.sections.map((d,l)=>e.jsxs(U,{value:`section-${l}`,className:"min-h-0 flex-1 overflow-y-auto",children:[l!==0||t.summary===void 0?null:e.jsx("p",{className:"mx-auto max-w-5xl px-5 pt-5 text-base leading-7 text-muted-foreground sm:px-8",children:t.summary}),e.jsx(Wt,{section:d,onOpen:T,onComment:()=>y(d.title)})]},d.title)),e.jsx(U,{value:"evidence",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Jt,{document:t,assetBaseUrl:s})}),e.jsx(U,{value:"discussion",className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(Kt,{canvasId:n??t.title})})]}),e.jsx(Ze,{open:u!==null,onOpenChange:d=>!d&&h(null),children:e.jsxs(et,{children:[e.jsx(tt,{children:e.jsx(st,{children:"Review comment"})}),e.jsx(at,{value:b,onChange:d=>p(d.target.value),placeholder:"What should the reviewer know?"}),e.jsx(nt,{children:e.jsx(G,{type:"button",onClick:()=>{u===null||b.trim()===""||c({body:b.trim(),anchor:u==="changeset"?{kind:"changeset"}:{kind:"canvas",canvasId:n??t.title,section:u}}).then(()=>h(null))},children:"Add comment"})})]})})]})}function Gt({content:t,repoPath:a,assetBaseUrl:s=null,canvasId:n,reviewTarget:r}){let i;try{i=JSON.parse(t)}catch(u){return e.jsxs("div",{"data-testid":X.structuredCanvasInvalid,className:"p-6 text-sm text-destructive",children:["Invalid structured Canvas: ",u instanceof Error?u.message:"invalid JSON"]})}const c=ct.safeParse(i);return c.success?c.data.template==="review"?e.jsx("div",{"data-testid":X.structuredCanvas,className:"h-full min-h-0",children:e.jsx(Xt,{document:c.data,repoPath:a,assetBaseUrl:s,canvasId:n,reviewTarget:r})}):e.jsx("div",{"data-testid":X.structuredCanvas,className:"h-full min-h-0",children:e.jsx(Ht,{document:c.data,repoPath:a})}):e.jsxs("div",{"data-testid":X.structuredCanvasInvalid,className:"p-6 text-sm text-destructive",children:["Invalid structured Canvas: ",dt(c.error)]})}function Qt(t){if(typeof t!="object"||t===null)return null;const a=t;return a.source!=="porcelain-canvas"?null:typeof a.href=="string"&&/^https?:\/\//i.test(a.href)?a.href:null}function he({projectId:t,canvasId:a,worktreePath:s,environmentId:n,revision:r}){const{mint:i}=mt(),u=xt(n??null)?.session.baseUrl()??ft(),[h,b]=o.useState(null),[p,y]=o.useState(null);return o.useEffect(()=>{let T=!1;b(null),y(null);const E={projectId:t,canvasId:a,...s===void 0?{}:{worktreePath:s},...n===void 0?{}:{environmentId:n}};return ht((async()=>{try{const d=await i(E);T||b(`${u}/canvas/${d}`)}catch(d){T||y(d instanceof Error&&d.message.length>0?d.message:"Could not open this Canvas.")}})(),"fallback"),()=>{T=!0}},[t,a,s,n,u,i,r]),{src:h,error:p}}function Zt({projectId:t,canvasId:a,title:s,worktreePath:n,environmentId:r,revision:i}){const{src:c,error:u}=he({projectId:t,canvasId:a,worktreePath:n,environmentId:r,revision:i}),h=o.useRef(null);return o.useEffect(()=>{function b(p){if(p.source!==h.current?.contentWindow)return;const y=Qt(p.data);y!==null&&window.open(y,"_blank","noopener,noreferrer")}return window.addEventListener("message",b),()=>window.removeEventListener("message",b)},[]),u!==null?e.jsx("div",{className:"p-4 text-sm text-destructive",children:u}):c===null?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):e.jsx("iframe",{ref:h,"data-testid":X.canvasIframe,title:s,src:c,sandbox:"allow-scripts",className:"h-full w-full flex-1 border-0 bg-background"})}function es({projectId:t,canvasId:a,content:s,worktreePath:n,environmentId:r,revision:i,reviewTarget:c}){const{src:u}=he({projectId:t,canvasId:a,worktreePath:n,environmentId:r,revision:i});return e.jsx(Gt,{content:s,canvasId:a,repoPath:n,assetBaseUrl:u===null?null:`${u}/assets`,reviewTarget:c})}function is({projectId:t,canvasId:a,worktreePath:s,environmentId:n,reviewTarget:r}){const{canvas:i,isLoading:c,loadError:u}=ut(t,a,s??null,n??null);return u!==null?e.jsx("div",{className:"p-4 text-sm text-destructive",children:u}):c||i===void 0?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):i.record.kind==="markdown"?e.jsx(ts,{projectId:t,canvasId:a,content:i.content,worktreePath:s,environmentId:n,revision:`${i.record.updatedAt}\0${i.content}`}):i.record.kind==="structured"?e.jsx(es,{projectId:t,canvasId:a,content:i.content,worktreePath:s,environmentId:n,revision:`${i.record.updatedAt}\0${i.content}`,reviewTarget:r}):e.jsx(Zt,{projectId:t,canvasId:a,title:i.record.title,worktreePath:s,environmentId:n,revision:`${i.record.updatedAt}\0${i.content}`})}function ts({projectId:t,canvasId:a,content:s,worktreePath:n,environmentId:r,revision:i}){const{src:c}=he({projectId:t,canvasId:a,worktreePath:n,environmentId:r,revision:i});return e.jsx(Te,{content:s,assetBaseUrl:c===null?null:`${c}/assets`})}export{is as CanvasView};
@@ -1 +1 @@
1
- import{U as J,V as Q,W as ee,r as h,X as G,h as se,j as e,Y as te,T as E,n as q,v as ne,x as ae,c as oe,u as re,N as le,e as ie,f as ce,g as de,i as he,D as pe,B as m,Z as xe,_ as ue,k as N,l as w,S as K,m as _,o as y,M as U,F as me,p as ge,C as fe,q as je,s as ve,t as D,w as be,y as Ce,z as ke,A as Ne,E as we,G as ye,H as Se,I as Te}from"./index-CuWbxCsX.js";import{L as qe}from"./index-CuWbxCsX.js";import{a as Fe}from"./line-selection-CDQurM1g.js";import{H as Re}from"./hunks-view-CXQMQon9.js";import{U as Le,F as Ee}from"./unfold-vertical-CIpACs4g.js";import"./virtual-rows-CsZNdhfp.js";function X(s,o,t,l){const r=new Set(s[o]??[]);return l?r.add(t):r.delete(t),{...s,[o]:[...r]}}const V=J(s=>({collapsedByScope:{},toggle:(o,t)=>s(l=>{const r=!(l.collapsedByScope[o]??[]).includes(t);return{collapsedByScope:X(l.collapsedByScope,o,t,r)}}),collapse:(o,t)=>s(l=>({collapsedByScope:X(l.collapsedByScope,o,t,!0)})),clear:()=>s({collapsedByScope:{}})}));function Me(s,o){if(!s||s.path!==o||s.startLine===void 0)return;const t=new Set,l=s.endLine??s.startLine;for(let r=s.startLine;r<=l;r++)t.add(r);return t}function ze({file:s,collapseScope:o,reviewable:t,commentAnchor:l,onComment:r,onSelectFile:g,reviewScope:d}){const p=V(n=>(n.collapsedByScope[o]??[]).includes(s.path)),M=V(n=>n.toggle),f=V(n=>n.collapse),[x,c]=h.useState(null),j=G(n=>n.project),z=oe(n=>n.openTab),S=re(n=>n.setSidebarTab),T=le(n=>n.reveal),F=d?.type==="commit"?void 0:d,a=ie(F),{mark:R,unmark:v}=ce(F),W=de(s.path,d),i=a.has(s.path),u=s.status!=="deleted",B=h.useMemo(()=>Me(l,s.path),[l,s.path]),[L,A]=h.useState([]),O=h.useMemo(()=>he(s.hunks??[],{context:pe,revealed:L}),[s.hunks,L]),$=O.gaps.some(n=>n.expandable),P=$||L.length>0,Y=(n,b)=>{const C=b==="up"?we(n):b==="down"?ye(n):Se(n);A(k=>Te(k,C))},Z=()=>{if(!j||!u)return;const n=`${j.path}/${s.path}`;z(Ce("file",n,{title:Ne(s.path),preview:!0},ke())),S("files"),T(n)},H=()=>{if(i){v(s.path);return}R(s.path),f(o,s.path)};return e.jsxs("div",{"data-testid":E.changesetCard(s.path),"data-review-file-path":s.path,className:q(be,"flex flex-col"),onPointerEnter:()=>g(s.path),children:[e.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b px-3",children:[e.jsx(m,{variant:"ghost",size:"icon-2xs",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:()=>M(o,s.path),"aria-expanded":!p,"aria-label":p?"Expand diff":"Collapse diff","data-testid":E.diffCollapse(s.path),children:p?e.jsx(xe,{}):e.jsx(ue,{})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs font-medium",children:s.path}),s.additions?e.jsxs("span",{className:"font-mono text-2xs text-success",children:["+",s.additions]}):null,s.deletions?e.jsxs("span",{className:"font-mono text-2xs text-destructive",children:["−",s.deletions]}):null,t&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:H,className:q("shrink-0",i?"text-success":"text-muted-foreground hover:text-foreground"),"aria-label":i?"Unmark reviewed":"Mark reviewed","data-testid":E.diffReviewed(s.path),children:i?e.jsx(K,{className:"size-3.5"}):e.jsx(_,{className:"size-3.5"})})}),e.jsx(y,{children:i?"Unmark reviewed":"Mark reviewed"})]}),e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:()=>r({path:s.path,scope:d}),className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Comment on file",children:e.jsx(U,{className:"size-3.5"})})}),e.jsx(y,{children:"Comment on file"})]}),u&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:Z,className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Open file",children:e.jsx(me,{className:"size-3.5"})})}),e.jsx(y,{children:"Open file"})]}),$&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:()=>A(ge()),className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Expand all context",children:e.jsx(Le,{className:"size-3.5"})})}),e.jsx(y,{children:"Expand all context"})]}),L.length>0&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:()=>A([]),className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Collapse context",children:e.jsx(Ee,{className:"size-3.5"})})}),e.jsx(y,{children:"Collapse context"})]})]}),!p&&s.hunks&&s.hunks.length>0&&e.jsxs(fe,{onOpenChange:n=>{n||c(null)},children:[e.jsx(je,{className:"block select-text",onContextMenu:n=>{const b=Fe(s.path);if(b){c(b);return}const C=n.target.closest("[data-line]"),k=C?Number.parseInt(C.getAttribute("data-line")??"",10):Number.NaN,I=C?.getAttribute("data-side");c(Number.isFinite(k)?{startLine:k,endLine:k,text:"",...I==="old"||I==="new"?{side:I}:{}}:null)},children:e.jsx(Re,{hunks:P?O.hunks:s.hunks??[],gaps:P?O.gaps:void 0,onExpand:P?Y:void 0,filePath:s.path,diffMode:"unified",layout:"content",commentIndex:W,pendingLines:B})}),e.jsxs(ve,{className:"w-52",children:[x?e.jsxs(D,{onClick:()=>r({path:s.path,startLine:x.startLine,endLine:x.endLine,anchorText:x.text.slice(0,2e3),scope:d,side:x.side}),children:[e.jsx(U,{})," Add comment"]}):e.jsxs(D,{onClick:()=>r({path:s.path,scope:d}),children:[e.jsx(U,{})," Comment on file"]}),t&&e.jsxs(D,{onClick:H,children:[i?e.jsx(_,{}):e.jsx(K,{}),i?"Unmark reviewed":"Mark reviewed"]})]})]})]})}function Ue({path:s,paneIndex:o=0}){const t=Q(s),{reading:l,error:r}=ee(t),[g,d]=h.useState(null),p=h.useRef(null),M=G(a=>a.project?.path??""),f=se(a=>a.setPath),x=`${M}\0${s}`,c=l?.groups.flatMap(a=>a.files)??[],j=c.map(a=>a.path).join("\0"),[z,S]=h.useState(null),T=z??c[0]?.path??null;if(h.useEffect(()=>(f(o,T),()=>f(o,null)),[o,f,T]),h.useEffect(()=>{const a=p.current;if(a===null||j===""||typeof IntersectionObserver>"u")return;const R=new IntersectionObserver(v=>{const i=v.filter(u=>u.isIntersecting).sort((u,B)=>u.boundingClientRect.top-B.boundingClientRect.top)[0]?.target.getAttribute("data-review-file-path");i!=null&&S(i)},{root:a,threshold:.5});for(const v of a.querySelectorAll("[data-review-file-path]"))R.observe(v);return()=>R.disconnect()},[j]),r)return e.jsx("p",{className:"p-4 text-sm text-destructive",children:r.message});if(l===void 0)return e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"});if(c.length===0)return e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:t.type==="commit"?"Empty commit":"No changes to review"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t.type==="commit"?"This commit doesn’t touch any files.":"Nothing to walk through in this range yet."})]})});const F=t.type==="working"?"Working tree":t.type==="branch"?"Branch range":`Commit ${t.hash.slice(0,7)}`;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 px-4 py-2 text-2xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"All changes"}),e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsx("span",{children:F}),e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsxs("span",{className:"tabular-nums",children:[c.length," file",c.length===1?"":"s"]}),e.jsx(te,{className:"ml-auto",scope:t.type==="working"?{type:"working"}:t.type==="branch"?{type:"range",...t.base===void 0?{}:{base:t.base}}:{type:"commit",hash:t.hash}})]}),e.jsx("div",{ref:p,"data-testid":E.codeWell,className:q(ne,"overflow-auto"),children:e.jsx("div",{className:"flex flex-col gap-3",children:c.map(a=>e.jsx(ze,{file:a,collapseScope:x,reviewable:t.type!=="commit",reviewScope:t.type==="commit"?{type:"commit",hash:t.hash}:t.type==="working"?{type:"working"}:t.base===void 0?void 0:{type:"branch",base:t.base},commentAnchor:g,onComment:d,onSelectFile:S},a.path))})}),e.jsx(ae,{anchor:g,open:g!==null,onOpenChange:a=>{a||d(null)}})]})}export{Ue as ChangesetView,qe as changesetTabKey,Q as parseChangesetTabKey};
1
+ import{U as J,V as Q,W as ee,r as h,X as G,h as se,j as e,Y as te,T as E,n as q,v as ne,x as ae,c as oe,u as re,N as le,e as ie,f as ce,g as de,i as he,D as pe,B as m,Z as xe,_ as ue,k as N,l as w,S as K,m as _,o as y,M as U,F as me,p as ge,C as fe,q as je,s as ve,t as D,w as be,y as Ce,z as ke,A as Ne,E as we,G as ye,H as Se,I as Te}from"./index-ybEI0zyv.js";import{L as qe}from"./index-ybEI0zyv.js";import{a as Fe}from"./line-selection-CDQurM1g.js";import{H as Re}from"./hunks-view-eSL-9s0V.js";import{U as Le,F as Ee}from"./unfold-vertical-CdeIOsfR.js";import"./virtual-rows-C-Fk3Zmu.js";function X(s,o,t,l){const r=new Set(s[o]??[]);return l?r.add(t):r.delete(t),{...s,[o]:[...r]}}const V=J(s=>({collapsedByScope:{},toggle:(o,t)=>s(l=>{const r=!(l.collapsedByScope[o]??[]).includes(t);return{collapsedByScope:X(l.collapsedByScope,o,t,r)}}),collapse:(o,t)=>s(l=>({collapsedByScope:X(l.collapsedByScope,o,t,!0)})),clear:()=>s({collapsedByScope:{}})}));function Me(s,o){if(!s||s.path!==o||s.startLine===void 0)return;const t=new Set,l=s.endLine??s.startLine;for(let r=s.startLine;r<=l;r++)t.add(r);return t}function ze({file:s,collapseScope:o,reviewable:t,commentAnchor:l,onComment:r,onSelectFile:g,reviewScope:d}){const p=V(n=>(n.collapsedByScope[o]??[]).includes(s.path)),M=V(n=>n.toggle),f=V(n=>n.collapse),[x,c]=h.useState(null),j=G(n=>n.project),z=oe(n=>n.openTab),S=re(n=>n.setSidebarTab),T=le(n=>n.reveal),F=d?.type==="commit"?void 0:d,a=ie(F),{mark:R,unmark:v}=ce(F),W=de(s.path,d),i=a.has(s.path),u=s.status!=="deleted",B=h.useMemo(()=>Me(l,s.path),[l,s.path]),[L,A]=h.useState([]),O=h.useMemo(()=>he(s.hunks??[],{context:pe,revealed:L}),[s.hunks,L]),$=O.gaps.some(n=>n.expandable),P=$||L.length>0,Y=(n,b)=>{const C=b==="up"?we(n):b==="down"?ye(n):Se(n);A(k=>Te(k,C))},Z=()=>{if(!j||!u)return;const n=`${j.path}/${s.path}`;z(Ce("file",n,{title:Ne(s.path),preview:!0},ke())),S("files"),T(n)},H=()=>{if(i){v(s.path);return}R(s.path),f(o,s.path)};return e.jsxs("div",{"data-testid":E.changesetCard(s.path),"data-review-file-path":s.path,className:q(be,"flex flex-col"),onPointerEnter:()=>g(s.path),children:[e.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-2 border-b px-3",children:[e.jsx(m,{variant:"ghost",size:"icon-2xs",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:()=>M(o,s.path),"aria-expanded":!p,"aria-label":p?"Expand diff":"Collapse diff","data-testid":E.diffCollapse(s.path),children:p?e.jsx(xe,{}):e.jsx(ue,{})}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs font-medium",children:s.path}),s.additions?e.jsxs("span",{className:"font-mono text-2xs text-success",children:["+",s.additions]}):null,s.deletions?e.jsxs("span",{className:"font-mono text-2xs text-destructive",children:["−",s.deletions]}):null,t&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:H,className:q("shrink-0",i?"text-success":"text-muted-foreground hover:text-foreground"),"aria-label":i?"Unmark reviewed":"Mark reviewed","data-testid":E.diffReviewed(s.path),children:i?e.jsx(K,{className:"size-3.5"}):e.jsx(_,{className:"size-3.5"})})}),e.jsx(y,{children:i?"Unmark reviewed":"Mark reviewed"})]}),e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:()=>r({path:s.path,scope:d}),className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Comment on file",children:e.jsx(U,{className:"size-3.5"})})}),e.jsx(y,{children:"Comment on file"})]}),u&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:Z,className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Open file",children:e.jsx(me,{className:"size-3.5"})})}),e.jsx(y,{children:"Open file"})]}),$&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:()=>A(ge()),className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Expand all context",children:e.jsx(Le,{className:"size-3.5"})})}),e.jsx(y,{children:"Expand all context"})]}),L.length>0&&e.jsxs(N,{children:[e.jsx(w,{render:e.jsx(m,{variant:"ghost",size:"icon-2xs",onClick:()=>A([]),className:"shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Collapse context",children:e.jsx(Ee,{className:"size-3.5"})})}),e.jsx(y,{children:"Collapse context"})]})]}),!p&&s.hunks&&s.hunks.length>0&&e.jsxs(fe,{onOpenChange:n=>{n||c(null)},children:[e.jsx(je,{className:"block select-text",onContextMenu:n=>{const b=Fe(s.path);if(b){c(b);return}const C=n.target.closest("[data-line]"),k=C?Number.parseInt(C.getAttribute("data-line")??"",10):Number.NaN,I=C?.getAttribute("data-side");c(Number.isFinite(k)?{startLine:k,endLine:k,text:"",...I==="old"||I==="new"?{side:I}:{}}:null)},children:e.jsx(Re,{hunks:P?O.hunks:s.hunks??[],gaps:P?O.gaps:void 0,onExpand:P?Y:void 0,filePath:s.path,diffMode:"unified",layout:"content",commentIndex:W,pendingLines:B})}),e.jsxs(ve,{className:"w-52",children:[x?e.jsxs(D,{onClick:()=>r({path:s.path,startLine:x.startLine,endLine:x.endLine,anchorText:x.text.slice(0,2e3),scope:d,side:x.side}),children:[e.jsx(U,{})," Add comment"]}):e.jsxs(D,{onClick:()=>r({path:s.path,scope:d}),children:[e.jsx(U,{})," Comment on file"]}),t&&e.jsxs(D,{onClick:H,children:[i?e.jsx(_,{}):e.jsx(K,{}),i?"Unmark reviewed":"Mark reviewed"]})]})]})]})}function Ue({path:s,paneIndex:o=0}){const t=Q(s),{reading:l,error:r}=ee(t),[g,d]=h.useState(null),p=h.useRef(null),M=G(a=>a.project?.path??""),f=se(a=>a.setPath),x=`${M}\0${s}`,c=l?.groups.flatMap(a=>a.files)??[],j=c.map(a=>a.path).join("\0"),[z,S]=h.useState(null),T=z??c[0]?.path??null;if(h.useEffect(()=>(f(o,T),()=>f(o,null)),[o,f,T]),h.useEffect(()=>{const a=p.current;if(a===null||j===""||typeof IntersectionObserver>"u")return;const R=new IntersectionObserver(v=>{const i=v.filter(u=>u.isIntersecting).sort((u,B)=>u.boundingClientRect.top-B.boundingClientRect.top)[0]?.target.getAttribute("data-review-file-path");i!=null&&S(i)},{root:a,threshold:.5});for(const v of a.querySelectorAll("[data-review-file-path]"))R.observe(v);return()=>R.disconnect()},[j]),r)return e.jsx("p",{className:"p-4 text-sm text-destructive",children:r.message});if(l===void 0)return e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"});if(c.length===0)return e.jsx("div",{className:"flex h-full items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:t.type==="commit"?"Empty commit":"No changes to review"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t.type==="commit"?"This commit doesn’t touch any files.":"Nothing to walk through in this range yet."})]})});const F=t.type==="working"?"Working tree":t.type==="branch"?"Branch range":`Commit ${t.hash.slice(0,7)}`;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 px-4 py-2 text-2xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"All changes"}),e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsx("span",{children:F}),e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsxs("span",{className:"tabular-nums",children:[c.length," file",c.length===1?"":"s"]}),e.jsx(te,{className:"ml-auto",scope:t.type==="working"?{type:"working"}:t.type==="branch"?{type:"range",...t.base===void 0?{}:{base:t.base}}:{type:"commit",hash:t.hash}})]}),e.jsx("div",{ref:p,"data-testid":E.codeWell,className:q(ne,"overflow-auto"),children:e.jsx("div",{className:"flex flex-col gap-3",children:c.map(a=>e.jsx(ze,{file:a,collapseScope:x,reviewable:t.type!=="commit",reviewScope:t.type==="commit"?{type:"commit",hash:t.hash}:t.type==="working"?{type:"working"}:t.base===void 0?void 0:{type:"branch",base:t.base},commentAnchor:g,onComment:d,onSelectFile:S},a.path))})}),e.jsx(ae,{anchor:g,open:g!==null,onOpenChange:a=>{a||d(null)}})]})}export{Ue as ChangesetView,qe as changesetTabKey,Q as parseChangesetTabKey};
@@ -1,2 +1,2 @@
1
- import{r as j,J as E,K as L,b as V,c as y,h as $,j as e,T as h,k as C,l as v,B as N,R as z,o as w,n as f,w as T,F as S,v as H,L as q,y as g,z as b,u as F,N as B,A as M,C as O,q as R,s as K,t as k,M as W,x as J,O as G}from"./index-CuWbxCsX.js";import{D as I}from"./diff-mode-toggle-DTeqhuLC.js";import{H as Q}from"./hunks-view-CXQMQon9.js";import"./virtual-rows-CsZNdhfp.js";function U({file:n,repoPath:a,selected:l,onSelect:i}){const c=y(s=>s.openTab),o=F(s=>s.setSidebarTab),p=B(s=>s.reveal),d=M(n.path),[m,x]=j.useState(null),r=()=>{const s=`${a}/${n.path}`;c(g("file",s,{title:d},b())),o("files"),p(s)};return e.jsxs(O,{children:[e.jsx(R,{render:e.jsx("button",{type:"button",onClick:()=>i(n.path),className:f("block w-full truncate px-3 py-1 text-left font-mono text-xs",l?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50")}),children:d}),e.jsxs(K,{children:[e.jsxs(k,{onClick:()=>x({path:n.path}),children:[e.jsx(W,{}),"Comment on file"]}),n.status!=="deleted"&&e.jsxs(k,{onClick:r,children:[e.jsx(S,{}),"Open file"]})]}),e.jsx(J,{anchor:m,open:m!==null,onOpenChange:s=>{s||x(null)}})]})}function X({hash:n,filePath:a}){const l=F(o=>o.diffMode),{hunks:i,error:c}=G(n,a);return c?e.jsx("p",{className:"p-4 text-sm text-destructive",children:c.message}):i===void 0?e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(O,{children:e.jsx(R,{className:"block min-h-0 flex-1 select-text",children:e.jsx(Q,{hunks:i,filePath:a,diffMode:l})})})})}function se({hash:n,filePath:a,paneIndex:l=0}){const[i,c]=j.useState(null),{groups:o}=E(n),p=L(n),d=V(),m=y(t=>t.openTab),x=$(t=>t.setPath),r=o?.flatMap(t=>t.files)??[],s=i??(r.some(t=>t.path===a)?a:void 0)??r[0]?.path??null,A=r.find(t=>t.path===s)?.status;if(j.useEffect(()=>(x(l,s),()=>x(l,null)),[l,s,x]),d===null||o===void 0)return e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"});const P=()=>{if(!s)return;const t=`${d}/${s}`;m(g("file",t,{title:M(s),preview:!0},b()))},D=()=>{const t=q({type:"commit",hash:n}),u=(p??n.slice(0,12)).split(`
1
+ import{r as j,J as E,K as L,b as V,c as y,h as $,j as e,T as h,k as C,l as v,B as N,R as z,o as w,n as f,w as T,F as S,v as H,L as q,y as g,z as b,u as F,N as B,A as M,C as O,q as R,s as K,t as k,M as W,x as J,O as G}from"./index-ybEI0zyv.js";import{D as I}from"./diff-mode-toggle-DEsEWLZg.js";import{H as Q}from"./hunks-view-eSL-9s0V.js";import"./virtual-rows-C-Fk3Zmu.js";function U({file:n,repoPath:a,selected:l,onSelect:i}){const c=y(s=>s.openTab),o=F(s=>s.setSidebarTab),p=B(s=>s.reveal),d=M(n.path),[m,x]=j.useState(null),r=()=>{const s=`${a}/${n.path}`;c(g("file",s,{title:d},b())),o("files"),p(s)};return e.jsxs(O,{children:[e.jsx(R,{render:e.jsx("button",{type:"button",onClick:()=>i(n.path),className:f("block w-full truncate px-3 py-1 text-left font-mono text-xs",l?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent/50")}),children:d}),e.jsxs(K,{children:[e.jsxs(k,{onClick:()=>x({path:n.path}),children:[e.jsx(W,{}),"Comment on file"]}),n.status!=="deleted"&&e.jsxs(k,{onClick:r,children:[e.jsx(S,{}),"Open file"]})]}),e.jsx(J,{anchor:m,open:m!==null,onOpenChange:s=>{s||x(null)}})]})}function X({hash:n,filePath:a}){const l=F(o=>o.diffMode),{hunks:i,error:c}=G(n,a);return c?e.jsx("p",{className:"p-4 text-sm text-destructive",children:c.message}):i===void 0?e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"}):e.jsx("div",{className:"flex h-full flex-col",children:e.jsx(O,{children:e.jsx(R,{className:"block min-h-0 flex-1 select-text",children:e.jsx(Q,{hunks:i,filePath:a,diffMode:l})})})})}function se({hash:n,filePath:a,paneIndex:l=0}){const[i,c]=j.useState(null),{groups:o}=E(n),p=L(n),d=V(),m=y(t=>t.openTab),x=$(t=>t.setPath),r=o?.flatMap(t=>t.files)??[],s=i??(r.some(t=>t.path===a)?a:void 0)??r[0]?.path??null,A=r.find(t=>t.path===s)?.status;if(j.useEffect(()=>(x(l,s),()=>x(l,null)),[l,s,x]),d===null||o===void 0)return e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"});const P=()=>{if(!s)return;const t=`${d}/${s}`;m(g("file",t,{title:M(s),preview:!0},b()))},D=()=>{const t=q({type:"commit",hash:n}),u=(p??n.slice(0,12)).split(`
2
2
  `)[0]?.trim()||n.slice(0,12);m(g("changeset",t,{title:u},b()))};return e.jsxs("div",{"data-testid":h.codeWell,className:f(H,"flex gap-3"),children:[e.jsxs("div",{"data-testid":h.commitListCard,className:f(T,"flex w-64 shrink-0 flex-col overflow-y-auto"),children:[e.jsxs("div",{className:"border-b px-3 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words text-sm-minus text-foreground",children:p??"…"}),r.length>0&&e.jsxs(C,{children:[e.jsx(v,{render:e.jsx(N,{variant:"ghost",size:"icon-xs",className:"shrink-0 text-muted-foreground",onClick:D,"aria-label":"All changes",children:e.jsx(z,{})})}),e.jsx(w,{children:"All changes"})]})]}),e.jsx("p",{className:"mt-1 font-mono text-xs-minus text-muted-foreground",children:n.slice(0,12)})]}),o.map(t=>e.jsxs("div",{children:[e.jsx("p",{className:"flex h-6 items-center px-3 text-2xs font-bold uppercase tracking-[0.08em] text-muted-foreground",children:t.layer}),t.files.map(u=>e.jsx(U,{file:u,repoPath:d,selected:u.path===s,onSelect:c},u.path))]},t.layer)),r.length===0&&e.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No files changed"})]}),e.jsx("div",{className:"min-w-0 min-h-0 flex-1",children:e.jsxs("div",{"data-testid":h.codeCard,className:f(T,"flex h-full min-h-0 flex-col"),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-3 py-1",children:[e.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s&&A!=="deleted"&&e.jsxs(C,{children:[e.jsx(v,{render:e.jsx(N,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:P,"aria-label":"Open file",children:e.jsx(S,{})})}),e.jsx(w,{children:"Open file"})]}),e.jsx(I,{})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:s?e.jsx(X,{hash:n,filePath:s}):e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Empty commit"})})]})})]})}export{se as CommitView};
@@ -1 +1 @@
1
- import{u as o,a as t,j as i,P as r,Q as n}from"./index-CuWbxCsX.js";function a(){const f=o(e=>e.diffMode),l=o(e=>e.setDiffMode);return t()?null:i.jsxs(r,{value:[f],onValueChange:e=>{const s=e[0];(s==="unified"||s==="split")&&l(s)},children:[i.jsx(n,{value:"unified",size:"sm",children:"Unified"}),i.jsx(n,{value:"split",size:"sm",children:"Split"})]})}export{a as D};
1
+ import{u as o,a as t,j as i,P as r,Q as n}from"./index-ybEI0zyv.js";function a(){const f=o(e=>e.diffMode),l=o(e=>e.setDiffMode);return t()?null:i.jsxs(r,{value:[f],onValueChange:e=>{const s=e[0];(s==="unified"||s==="split")&&l(s)},children:[i.jsx(n,{value:"unified",size:"sm",children:"Unified"}),i.jsx(n,{value:"split",size:"sm",children:"Split"})]})}export{a as D};
@@ -1 +1 @@
1
- import{u as Q,a as Y,b as Z,c as P,d as ee,e as se,f as te,r,g as ne,h as oe,i as ae,j as e,v as re,T as E,k as c,l as x,B as u,S as ie,m as le,n as I,o as m,M as D,F as de,p as ce,C as xe,q as ue,s as me,t as U,w as pe,x as fe,D as he,y as je,z as ge,A as ve,E as Ce,G as we,H as be,I as Ne}from"./index-CuWbxCsX.js";import{l as ke}from"./line-selection-CDQurM1g.js";import{D as Te}from"./diff-mode-toggle-DTeqhuLC.js";import{H as Me}from"./hunks-view-CXQMQon9.js";import{U as Se,F as Fe}from"./unfold-vertical-CIpACs4g.js";import"./virtual-rows-CsZNdhfp.js";function Ue({filePath:t,base:p,paneIndex:v=0}){const z=Q(s=>s.diffMode),O=Y()?"unified":z,R=Z(),V=P(s=>s.openTab),{hunks:C,status:w,image:f,binary:b,error:A}=ee(t,p),N=p===void 0?{type:"working"}:{type:"branch",base:p},H=se(N),{mark:q,unmark:$}=te(N),h=N,i=H.has(t),[l,k]=r.useState(null),[n,j]=r.useState(null),B=ne(t,h),T=oe(s=>s.setPath);r.useEffect(()=>(T(v,t),()=>T(v,null)),[t,v,T]);const[M,g]=r.useState([]),S=`${t}\0${p??""}`,[W,_]=r.useState(S);W!==S&&(_(S),g([]));const F=r.useMemo(()=>ae(C??[],{context:he,revealed:M}),[C,M]),G=(s,a)=>{const o=a==="up"?Ce(s):a==="down"?we(s):be(s);g(d=>Ne(d,o))},K=F.gaps.some(s=>s.expandable),X=r.useMemo(()=>{if(!n||n.path!==t||n.startLine===void 0)return;const s=new Set,a=n.endLine??n.startLine;for(let o=n.startLine;o<=a;o++)s.add(o);return s},[n,t]),J=()=>{if(R===null)return;const s=`${R}/${t}`;V(je("file",s,{title:ve(t),preview:!0},ge()))};if(A)return e.jsx("p",{className:"p-4 text-sm text-destructive",children:A.message});if(C===void 0&&f===void 0&&!b)return e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"});const L=f!==void 0||b;return e.jsxs("div",{"data-testid":E.codeWell,className:re,children:[e.jsxs("div",{"data-testid":E.codeCard,className:I(pe,"flex h-full min-h-0 flex-col"),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-3 py-1",children:[e.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:I(i?"text-success":"text-muted-foreground hover:text-foreground"),onClick:()=>{i?$(t):q(t)},"aria-label":i?"Unmark reviewed":"Mark reviewed","data-testid":E.diffReviewed(t),children:i?e.jsx(ie,{}):e.jsx(le,{})})}),e.jsx(m,{children:i?"Unmark reviewed":"Mark reviewed"})]}),e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-foreground",onClick:()=>j({path:t,scope:h}),"aria-label":"Comment on file",children:e.jsx(D,{})})}),e.jsx(m,{children:"Comment on file"})]}),w!=="deleted"&&e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:J,"aria-label":"Open file",children:e.jsx(de,{})})}),e.jsx(m,{children:"Open file"})]}),!L&&K&&e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-foreground",onClick:()=>g(ce()),"aria-label":"Expand all context",children:e.jsx(Se,{})})}),e.jsx(m,{children:"Expand all context"})]}),!L&&M.length>0&&e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-foreground",onClick:()=>g([]),"aria-label":"Collapse context",children:e.jsx(Fe,{})})}),e.jsx(m,{children:"Collapse context"})]}),!L&&e.jsx(Te,{})]})]}),f!==void 0?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 overflow-auto p-8",children:[e.jsx("img",{src:f.dataUrl,alt:t,className:"max-h-full max-w-full object-contain"}),e.jsxs("p",{className:"text-2xs text-muted-foreground",children:[w==="untracked"||w==="added"?"New image":"Image changed"," · binary diff"]})]}):b?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Binary file"}):e.jsxs(xe,{onOpenChange:s=>{s||k(null)},children:[e.jsx(ue,{className:"block min-h-0 flex-1 select-text",onContextMenu:s=>{const a=ke();if(a){k(a);return}const o=s.target.closest("[data-line]"),d=o?Number.parseInt(o.getAttribute("data-line")??"",10):Number.NaN,y=o?.getAttribute("data-side");k(Number.isFinite(d)?{startLine:d,endLine:d,text:"",...y==="old"||y==="new"?{side:y}:{}}:null)},children:e.jsx(Me,{hunks:F.hunks,gaps:F.gaps,onExpand:G,filePath:t,diffMode:O,commentIndex:B,pendingLines:X})}),e.jsx(me,{className:"w-52",children:l?e.jsxs(U,{onClick:()=>j({path:t,startLine:l.startLine,endLine:l.endLine,anchorText:l.text.slice(0,2e3),scope:h,side:l.side}),children:[e.jsx(D,{})," Add comment"]}):e.jsxs(U,{onClick:()=>j({path:t,scope:h}),children:[e.jsx(D,{})," Comment on file"]})})]})]}),e.jsx(fe,{anchor:n,open:n!==null,onOpenChange:s=>{s||j(null)}})]})}export{Ue as DiffView};
1
+ import{u as Q,a as Y,b as Z,c as P,d as ee,e as se,f as te,r,g as ne,h as oe,i as ae,j as e,v as re,T as E,k as c,l as x,B as u,S as ie,m as le,n as I,o as m,M as D,F as de,p as ce,C as xe,q as ue,s as me,t as U,w as pe,x as fe,D as he,y as je,z as ge,A as ve,E as Ce,G as we,H as be,I as Ne}from"./index-ybEI0zyv.js";import{l as ke}from"./line-selection-CDQurM1g.js";import{D as Te}from"./diff-mode-toggle-DEsEWLZg.js";import{H as Me}from"./hunks-view-eSL-9s0V.js";import{U as Se,F as Fe}from"./unfold-vertical-CdeIOsfR.js";import"./virtual-rows-C-Fk3Zmu.js";function Ue({filePath:t,base:p,paneIndex:v=0}){const z=Q(s=>s.diffMode),O=Y()?"unified":z,R=Z(),V=P(s=>s.openTab),{hunks:C,status:w,image:f,binary:b,error:A}=ee(t,p),N=p===void 0?{type:"working"}:{type:"branch",base:p},H=se(N),{mark:q,unmark:$}=te(N),h=N,i=H.has(t),[l,k]=r.useState(null),[n,j]=r.useState(null),B=ne(t,h),T=oe(s=>s.setPath);r.useEffect(()=>(T(v,t),()=>T(v,null)),[t,v,T]);const[M,g]=r.useState([]),S=`${t}\0${p??""}`,[W,_]=r.useState(S);W!==S&&(_(S),g([]));const F=r.useMemo(()=>ae(C??[],{context:he,revealed:M}),[C,M]),G=(s,a)=>{const o=a==="up"?Ce(s):a==="down"?we(s):be(s);g(d=>Ne(d,o))},K=F.gaps.some(s=>s.expandable),X=r.useMemo(()=>{if(!n||n.path!==t||n.startLine===void 0)return;const s=new Set,a=n.endLine??n.startLine;for(let o=n.startLine;o<=a;o++)s.add(o);return s},[n,t]),J=()=>{if(R===null)return;const s=`${R}/${t}`;V(je("file",s,{title:ve(t),preview:!0},ge()))};if(A)return e.jsx("p",{className:"p-4 text-sm text-destructive",children:A.message});if(C===void 0&&f===void 0&&!b)return e.jsx("p",{className:"p-4 text-sm text-muted-foreground",children:"Loading…"});const L=f!==void 0||b;return e.jsxs("div",{"data-testid":E.codeWell,className:re,children:[e.jsxs("div",{"data-testid":E.codeCard,className:I(pe,"flex h-full min-h-0 flex-col"),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b px-3 py-1",children:[e.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:t}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:I(i?"text-success":"text-muted-foreground hover:text-foreground"),onClick:()=>{i?$(t):q(t)},"aria-label":i?"Unmark reviewed":"Mark reviewed","data-testid":E.diffReviewed(t),children:i?e.jsx(ie,{}):e.jsx(le,{})})}),e.jsx(m,{children:i?"Unmark reviewed":"Mark reviewed"})]}),e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-foreground",onClick:()=>j({path:t,scope:h}),"aria-label":"Comment on file",children:e.jsx(D,{})})}),e.jsx(m,{children:"Comment on file"})]}),w!=="deleted"&&e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground",onClick:J,"aria-label":"Open file",children:e.jsx(de,{})})}),e.jsx(m,{children:"Open file"})]}),!L&&K&&e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-foreground",onClick:()=>g(ce()),"aria-label":"Expand all context",children:e.jsx(Se,{})})}),e.jsx(m,{children:"Expand all context"})]}),!L&&M.length>0&&e.jsxs(c,{children:[e.jsx(x,{render:e.jsx(u,{variant:"ghost",size:"icon-xs",className:"text-muted-foreground hover:text-foreground",onClick:()=>g([]),"aria-label":"Collapse context",children:e.jsx(Fe,{})})}),e.jsx(m,{children:"Collapse context"})]}),!L&&e.jsx(Te,{})]})]}),f!==void 0?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-3 overflow-auto p-8",children:[e.jsx("img",{src:f.dataUrl,alt:t,className:"max-h-full max-w-full object-contain"}),e.jsxs("p",{className:"text-2xs text-muted-foreground",children:[w==="untracked"||w==="added"?"New image":"Image changed"," · binary diff"]})]}):b?e.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Binary file"}):e.jsxs(xe,{onOpenChange:s=>{s||k(null)},children:[e.jsx(ue,{className:"block min-h-0 flex-1 select-text",onContextMenu:s=>{const a=ke();if(a){k(a);return}const o=s.target.closest("[data-line]"),d=o?Number.parseInt(o.getAttribute("data-line")??"",10):Number.NaN,y=o?.getAttribute("data-side");k(Number.isFinite(d)?{startLine:d,endLine:d,text:"",...y==="old"||y==="new"?{side:y}:{}}:null)},children:e.jsx(Me,{hunks:F.hunks,gaps:F.gaps,onExpand:G,filePath:t,diffMode:O,commentIndex:B,pendingLines:X})}),e.jsx(me,{className:"w-52",children:l?e.jsxs(U,{onClick:()=>j({path:t,startLine:l.startLine,endLine:l.endLine,anchorText:l.text.slice(0,2e3),scope:h,side:l.side}),children:[e.jsx(D,{})," Add comment"]}):e.jsxs(U,{onClick:()=>j({path:t,scope:h}),children:[e.jsx(D,{})," Comment on file"]})})]})]}),e.jsx(fe,{anchor:n,open:n!==null,onOpenChange:s=>{s||j(null)}})]})}export{Ue as DiffView};
@@ -1,4 +1,4 @@
1
- import{$ as Pe,r,a1 as ue,ad as xe,ae as me,af as Ae,ag as ze,ah as Ie,ai as fe,b as te,aj as ne,j as e,C as he,q as je,a6 as pe,n as F,ak as He,T as J,al as Q,am as D,s as ge,t as v,an as B,ao as U,ap as Z,aq as ve,ar as De,as as re,M as E,at as ee,au as Ce,av as we,aw as ke,x as oe,a8 as be,c as se,ax as Oe,ay as q,az as Ke,B as O,ab as Ve,_ as _e,aA as Be,a7 as Ue,u as R,g as qe,aB as Ge,aC as We,v as $e,k as Xe,l as Qe,o as Ye,w as Je,P as ye,Q as G,aD as Ze,aE as es}from"./index-CuWbxCsX.js";import{i as ss,a as ts,M as ns,H as rs}from"./html-view-BPOrX4do.js";import{b as os,l as as,c as is}from"./line-selection-CDQurM1g.js";import{R as ls,V as cs}from"./virtual-rows-CsZNdhfp.js";const ds=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],us=Pe("scissors",ds);function Se(t,o){return!o||o.length===0?!1:o.some(n=>t>=n.start&&t<=n.end)}const xs=5e3,ms=800,Y="pointer-events-none absolute bottom-2 right-3 rounded-md border-transparent bg-muted/80 text-2xs",fs=r.memo(be),hs=8;function js({path:t,initialContent:o,highlightLine:n,highlightRanges:i,commentsByLine:a}){const[c,p]=r.useState(o),[m,x]=r.useState(o),[u,C]=r.useState(""),[d,w]=r.useState(!1),[f,k]=r.useState(null),[h,N]=r.useState(null),b=r.useRef(null),L=r.useRef(null),S=r.useRef(null),T=ue(t),M=r.useDeferredValue(c),P=xe(M,T),{findReferences:K,copyPath:V,copyRelativePath:_,reveal:W}=me(t),{save:A,isSaving:z,error:I}=Ae(t),g=ze();r.useEffect(()=>{if(!(c===m&&!z))return Ie(b,g,t)},[c,m,z,g,t]);const y=fe(),Ne=te()??void 0,ae=ne(Ne,t),Le=r.useMemo(()=>{if(!f||f.startLine===void 0)return null;const s=new Set,l=f.endLine??f.startLine;for(let j=f.startLine;j<=l;j++)s.add(j);return s},[f]),Me=r.useMemo(()=>{if(!d||u===""||!h)return null;const s=new Set;for(let l=h.startLine;l<=h.endLine;l++)s.add(l);return s},[d,u,h]),$=r.useEffectEvent(()=>{if(S.current&&clearTimeout(S.current),c===m)return;const s=c;A(s,()=>x(s))}),ie=s=>{p(s);const l=se.getState().panes.flatMap(j=>j.tabs).find(j=>j.kind==="file"&&j.path===t);se.getState().pinTab(l?.id??Oe("file",t)),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>$(),ms)};r.useEffect(()=>()=>{S.current&&clearTimeout(S.current),$()},[]);const le=r.useRef(o);r.useEffect(()=>{o!==le.current&&c===m&&(le.current=o,p(o),x(o))},[o,c,m]),r.useEffect(()=>{const s=L.current;!s||n===void 0||(s.scrollTop=Math.max(0,(n-1)*20-s.clientHeight/2+10))},[n]);const ce=s=>{const l=b.current;if(!l)return;const{selectionStart:j,selectionEnd:X,value:H}=l;ie(H.slice(0,j)+s+H.slice(X)),requestAnimationFrame(()=>{l.focus(),l.selectionStart=l.selectionEnd=j+s.length})},Te=()=>{const s=b.current;return s?s.value.slice(s.selectionStart,s.selectionEnd):""},Ee=()=>{navigator.clipboard?.readText&&U(async()=>{ce(await navigator.clipboard.readText())},s=>{q("Paste",s)})},Fe=c!==m;return e.jsxs(e.Fragment,{children:[e.jsxs(he,{onOpenChange:s=>{if(w(s),s){C(Te());const l=b.current;N(l?os(l.value,l.selectionStart,l.selectionEnd):null)}},children:[e.jsxs(je,{className:"relative block h-full select-text overflow-hidden",children:[e.jsx("div",{ref:L,className:"h-full overflow-auto",children:e.jsxs("div",{className:"relative min-h-full w-max min-w-full",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 z-0 px-4 py-2 font-mono text-xs leading-5",children:e.jsx("div",{className:"w-max min-w-full",children:c.split(`
1
+ import{$ as Pe,r,a1 as ue,ad as xe,ae as me,af as Ae,ag as ze,ah as Ie,ai as fe,b as te,aj as ne,j as e,C as he,q as je,a6 as pe,n as F,ak as He,T as J,al as Q,am as D,s as ge,t as v,an as B,ao as U,ap as Z,aq as ve,ar as De,as as re,M as E,at as ee,au as Ce,av as we,aw as ke,x as oe,a8 as be,c as se,ax as Oe,ay as q,az as Ke,B as O,ab as Ve,_ as _e,aA as Be,a7 as Ue,u as R,g as qe,aB as Ge,aC as We,v as $e,k as Xe,l as Qe,o as Ye,w as Je,P as ye,Q as G,aD as Ze,aE as es}from"./index-ybEI0zyv.js";import{i as ss,a as ts,M as ns,H as rs}from"./html-view-CDqcReet.js";import{b as os,l as as,c as is}from"./line-selection-CDQurM1g.js";import{R as ls,V as cs}from"./virtual-rows-C-Fk3Zmu.js";const ds=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],us=Pe("scissors",ds);function Se(t,o){return!o||o.length===0?!1:o.some(n=>t>=n.start&&t<=n.end)}const xs=5e3,ms=800,Y="pointer-events-none absolute bottom-2 right-3 rounded-md border-transparent bg-muted/80 text-2xs",fs=r.memo(be),hs=8;function js({path:t,initialContent:o,highlightLine:n,highlightRanges:i,commentsByLine:a}){const[c,p]=r.useState(o),[m,x]=r.useState(o),[u,C]=r.useState(""),[d,w]=r.useState(!1),[f,k]=r.useState(null),[h,N]=r.useState(null),b=r.useRef(null),L=r.useRef(null),S=r.useRef(null),T=ue(t),M=r.useDeferredValue(c),P=xe(M,T),{findReferences:K,copyPath:V,copyRelativePath:_,reveal:W}=me(t),{save:A,isSaving:z,error:I}=Ae(t),g=ze();r.useEffect(()=>{if(!(c===m&&!z))return Ie(b,g,t)},[c,m,z,g,t]);const y=fe(),Ne=te()??void 0,ae=ne(Ne,t),Le=r.useMemo(()=>{if(!f||f.startLine===void 0)return null;const s=new Set,l=f.endLine??f.startLine;for(let j=f.startLine;j<=l;j++)s.add(j);return s},[f]),Me=r.useMemo(()=>{if(!d||u===""||!h)return null;const s=new Set;for(let l=h.startLine;l<=h.endLine;l++)s.add(l);return s},[d,u,h]),$=r.useEffectEvent(()=>{if(S.current&&clearTimeout(S.current),c===m)return;const s=c;A(s,()=>x(s))}),ie=s=>{p(s);const l=se.getState().panes.flatMap(j=>j.tabs).find(j=>j.kind==="file"&&j.path===t);se.getState().pinTab(l?.id??Oe("file",t)),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>$(),ms)};r.useEffect(()=>()=>{S.current&&clearTimeout(S.current),$()},[]);const le=r.useRef(o);r.useEffect(()=>{o!==le.current&&c===m&&(le.current=o,p(o),x(o))},[o,c,m]),r.useEffect(()=>{const s=L.current;!s||n===void 0||(s.scrollTop=Math.max(0,(n-1)*20-s.clientHeight/2+10))},[n]);const ce=s=>{const l=b.current;if(!l)return;const{selectionStart:j,selectionEnd:X,value:H}=l;ie(H.slice(0,j)+s+H.slice(X)),requestAnimationFrame(()=>{l.focus(),l.selectionStart=l.selectionEnd=j+s.length})},Te=()=>{const s=b.current;return s?s.value.slice(s.selectionStart,s.selectionEnd):""},Ee=()=>{navigator.clipboard?.readText&&U(async()=>{ce(await navigator.clipboard.readText())},s=>{q("Paste",s)})},Fe=c!==m;return e.jsxs(e.Fragment,{children:[e.jsxs(he,{onOpenChange:s=>{if(w(s),s){C(Te());const l=b.current;N(l?os(l.value,l.selectionStart,l.selectionEnd):null)}},children:[e.jsxs(je,{className:"relative block h-full select-text overflow-hidden",children:[e.jsx("div",{ref:L,className:"h-full overflow-auto",children:e.jsxs("div",{className:"relative min-h-full w-max min-w-full",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 z-0 px-4 py-2 font-mono text-xs leading-5",children:e.jsx("div",{className:"w-max min-w-full",children:c.split(`
2
2
  `).map((s,l)=>{const j=l+1,X=(Le?.has(j)??!1)||(Me?.has(j)??!1),H=pe(a?.get(j),X)??(j===n?"bg-primary/15":void 0),Re=!H&&Se(j,i);return e.jsxs("div",{className:F("flex",H,Re&&"border-l-2 border-l-diff-add bg-diff-add/10"),children:[e.jsx("span",{className:"w-10 shrink-0 select-none pr-3 text-right text-muted-foreground/50",children:j}),e.jsx(fs,{tokens:P?.[l]??null,text:s})]},l)})})}),a&&a.size>0&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-20 font-mono text-xs leading-5",children:[...a.entries()].map(([s,l])=>e.jsx("div",{className:"pointer-events-auto absolute left-1 flex h-5 items-center",style:{top:hs+(s-1)*ls},children:e.jsx(He,{comments:l})},s))}),e.jsx("textarea",{ref:b,value:c,onChange:s=>ie(s.target.value),onKeyDown:s=>{s.key==="s"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),$())},spellCheck:!1,wrap:"off","aria-label":`Edit ${t}`,"data-testid":J.fileEditor,className:"relative z-10 block min-h-full min-w-full resize-none whitespace-pre bg-transparent py-2 pl-14 pr-4 font-mono text-xs leading-5 text-transparent caret-foreground outline-none field-sizing-content"})]})}),I?e.jsx(Q,{variant:"outline",className:F(Y,"text-destructive"),children:I.message}):z?e.jsx(Q,{variant:"outline",className:F(Y,"text-muted-foreground"),children:"Saving…"}):Fe?e.jsxs(Q,{variant:"outline",className:F(Y,"text-muted-foreground"),children:["Unsaved ",e.jsx(D,{className:"[@media(hover:none)]:hidden",tokens:["mod","S"]})]}):null]}),e.jsxs(ge,{className:"w-60",children:[e.jsxs(v,{disabled:u==="",onClick:()=>{U(async()=>{await Z(u),ce("")},s=>{q("Cut",s)})},children:[e.jsx(us,{})," Cut",e.jsx(B,{children:e.jsx(D,{tokens:["mod","X"]})})]}),e.jsxs(v,{disabled:u==="",onClick:()=>{U(()=>Z(u),s=>{q("Copy",s)})},children:[e.jsx(ve,{})," Copy",e.jsx(B,{children:e.jsx(D,{tokens:["mod","C"]})})]}),e.jsxs(v,{onClick:()=>Ee(),children:[e.jsx(De,{})," Paste",e.jsx(B,{children:e.jsx(D,{tokens:["mod","V"]})})]}),e.jsxs(v,{disabled:u.trim()==="",onClick:()=>K(u),children:[e.jsx(re,{})," Find references"]}),e.jsxs(v,{disabled:u==="",onClick:()=>{h&&k({path:ae,startLine:h.startLine,endLine:h.endLine,anchorText:u.slice(0,2e3)})},children:[e.jsx(E,{})," Add comment"]}),e.jsx(ee,{}),e.jsxs(v,{onClick:()=>k({path:ae}),children:[e.jsx(E,{})," Comment on file"]}),e.jsxs(v,{onClick:()=>{V()},children:[e.jsx(Ce,{})," Copy path"]}),e.jsxs(v,{onClick:()=>{_()},children:[e.jsx(we,{})," Copy relative path"]}),y&&e.jsxs(v,{onClick:()=>{W()},children:[e.jsx(ke,{})," Reveal in Finder"]})]})]}),e.jsx(oe,{anchor:f,open:f!==null,onOpenChange:s=>{s||k(null)}})]})}function ps({content:t,onClose:o,onMatchLine:n}){const[i,a]=r.useState(""),[c,p]=r.useState(0),m=r.useRef(null),x=r.useMemo(()=>{const d=i.toLowerCase();if(d==="")return[];const w=[];return t.split(`
3
3
  `).forEach((f,k)=>{f.toLowerCase().includes(d)&&w.push(k+1)}),w},[t,i]),u=x.length===0?0:(c%x.length+x.length)%x.length,C=x.length===0?void 0:x[u];return r.useEffect(()=>{n(C)},[C,n]),r.useEffect(()=>{m.current?.focus()},[]),e.jsxs("div",{className:"absolute right-3 top-3 z-30 flex items-center gap-1 rounded-lg border bg-popover px-2 py-1 shadow-lg",children:[e.jsx(re,{className:"size-3.5 shrink-0 text-muted-foreground"}),e.jsx(Ke,{ref:m,value:i,onChange:d=>{a(d.target.value),p(0)},onKeyDown:d=>{d.key==="Escape"&&o(),d.key==="Enter"&&p(w=>w+(d.shiftKey?-1:1))},placeholder:"Find in file…","aria-label":"Find in file",className:"h-6 max-w-64 border-none bg-transparent text-xs shadow-none focus-visible:ring-0"}),e.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground tabular-nums",children:i===""?"":x.length===0?"No results":`${u+1}/${x.length}`}),e.jsx(O,{variant:"ghost",size:"icon-xs",disabled:x.length===0,onClick:()=>p(d=>d-1),"aria-label":"Previous match",children:e.jsx(Ve,{})}),e.jsx(O,{variant:"ghost",size:"icon-xs",disabled:x.length===0,onClick:()=>p(d=>d+1),"aria-label":"Next match",children:e.jsx(_e,{})}),e.jsx(O,{variant:"ghost",size:"icon-xs",onClick:o,"aria-label":"Close find bar",children:e.jsx(Be,{})})]})}function de({path:t,children:o}){const[n,i]=r.useState(""),[a,c]=r.useState(null),[p,m]=r.useState(null),x=te()??void 0,{copyPath:u,copyRelativePath:C,reveal:d,findReferences:w}=me(t),f=fe(),k=ne(x,t);return e.jsxs(e.Fragment,{children:[e.jsxs(he,{onOpenChange:h=>{if(!h){c(null);return}i(window.getSelection()?.toString()??"")},children:[e.jsx(je,{className:"block h-full select-text",onContextMenu:h=>{const N=as();if(N){c(N);return}const b=h.target.closest("[data-line]"),L=b?Number.parseInt(b.getAttribute("data-line")??"",10):Number.NaN;c(Number.isFinite(L)?{startLine:L,endLine:L,text:""}:null)},children:o}),e.jsx(ge,{className:"w-56",children:n!==""?e.jsxs(e.Fragment,{children:[e.jsxs(v,{onClick:()=>{U(()=>Z(n),h=>{q("Copy",h)})},children:[e.jsx(ve,{})," Copy",e.jsx(B,{children:e.jsx(D,{tokens:["mod","C"]})})]}),e.jsxs(v,{disabled:n.trim()==="",onClick:()=>w(n),children:[e.jsx(re,{})," Find references"]}),a&&e.jsxs(v,{onClick:()=>m({path:k,startLine:a.startLine,endLine:a.endLine,anchorText:a.text.slice(0,2e3)}),children:[e.jsx(E,{})," Add comment"]})]}):e.jsxs(e.Fragment,{children:[a?e.jsxs(v,{onClick:()=>m({path:k,startLine:a.startLine,endLine:a.endLine}),children:[e.jsx(E,{})," Add comment"]}):e.jsxs(v,{onClick:()=>m({path:k}),children:[e.jsx(E,{})," Comment on file"]}),e.jsx(ee,{}),e.jsxs(v,{onClick:()=>{u()},children:[e.jsx(Ce,{})," Copy path"]}),e.jsxs(v,{onClick:()=>{C()},children:[e.jsx(we,{})," Copy relative path"]}),f&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{}),e.jsxs(v,{onClick:()=>{d()},children:[e.jsx(ke,{})," Reveal in Finder"]})]})]})})]}),e.jsx(oe,{anchor:p,open:p!==null,onOpenChange:h=>{h||m(null)}})]})}function gs({path:t,content:o,highlightLine:n,highlightRanges:i,commentsByLine:a}){const c=ue(t),p=o.split(`
4
4
  `),m=xe(o,c);return e.jsx(cs,{rows:p,className:"px-4 py-2 leading-5",scrollToLine:n,renderRow:(x,u)=>{const C=u+1,d=a?.get(C),w=pe(d),f=!w&&Se(C,i);return e.jsxs("div",{"data-line":C,className:F("relative flex",!w&&C===n&&"bg-primary/15",w,f&&"border-l-2 border-l-diff-add bg-diff-add/10"),children:[e.jsx(Ue,{comments:d}),e.jsx("span",{className:"w-10 shrink-0 select-none pr-3 text-right text-muted-foreground/50",children:C}),e.jsx(be,{tokens:m?.[u]??null,text:x})]})}})}function vs(){const t=R(n=>n.markdownMode),o=R(n=>n.setMarkdownMode);return e.jsxs(ye,{value:[t],onValueChange:n=>{const i=n[0];(i==="reader"||i==="source")&&o(i)},children:[e.jsx(G,{value:"reader",size:"sm",children:"Reader"}),e.jsx(G,{value:"source",size:"sm",children:"Source"})]})}function Cs(){const t=R(n=>n.htmlMode)??"preview",o=R(n=>n.setHtmlMode);return e.jsxs(ye,{value:[t],onValueChange:n=>{const i=n[0];(i==="preview"||i==="source")&&o(i)},children:[e.jsx(G,{value:"preview",size:"sm",children:"Preview"}),e.jsx(G,{value:"source",size:"sm",children:"Source"})]})}function ws({path:t,content:o,line:n,highlightRanges:i,paneIndex:a}){const c=te()??void 0,p=R(g=>g.markdownMode),m=R(g=>g.htmlMode)??"preview",[x,u]=r.useState(!1),[C,d]=r.useState(void 0),[w,f]=r.useState(null),[k,h]=r.useState(null),N=ne(c,t),b=qe(N),L=ss(t),S=ts(t),T=L&&p==="reader",M=S&&m==="preview",{html:P,error:K}=Ge(t,M),V=We(t,M&&P!==null),_=o.split(`