@hienlh/ppm 0.8.8 → 0.8.9

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.
@@ -0,0 +1 @@
1
+ import"./react-CYzKIDNi.js";import"./api-client-TUmacMRS.js";import{x as e}from"./index-BjNob0pC.js";export{e as useKeybindingsStore};
@@ -1,4 +1,4 @@
1
- import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{t as r}from"./tab-store-0CKk8cSr.js";import{t as i}from"./utils-DC-bdPS3.js";import{i as a,t as o}from"./api-client-TUmacMRS.js";import{_ as s,m as c}from"./index-BGTzm7B1.js";function l(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var u=l();function d(e){u=e}var f={exec:()=>null};function p(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(h.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var m=(()=>{try{return!0}catch{return!1}})(),h={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},ee=/^(?:[ \t]*(?:\n|$))+/,te=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ne=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,g=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,re=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,v=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ie=p(v).replace(/bull/g,_).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ae=p(v).replace(/bull/g,_).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),y=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,oe=/^[^\n]+/,b=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,se=p(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,b).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ce=p(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_).getRegex(),x=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,S=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,le=p(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,S).replace(`tag`,x).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),C=p(y).replace(`hr`,g).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,x).getRegex(),w={blockquote:p(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,C).getRegex(),code:te,def:se,fences:ne,heading:re,hr:g,html:le,lheading:ie,list:ce,newline:ee,paragraph:C,table:f,text:oe},T=p(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,g).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,x).getRegex(),ue={...w,lheading:ae,table:T,paragraph:p(y).replace(`hr`,g).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,T).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,x).getRegex()},de={...w,html:p(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,S).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:f,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:p(y).replace(`hr`,g).replace(`heading`,` *#{1,6} *[^
1
+ import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{t as r}from"./tab-store-0CKk8cSr.js";import{t as i}from"./utils-DC-bdPS3.js";import{i as a,t as o}from"./api-client-TUmacMRS.js";import{_ as s,m as c}from"./index-BjNob0pC.js";function l(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var u=l();function d(e){u=e}var f={exec:()=>null};function p(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(h.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var m=(()=>{try{return!0}catch{return!1}})(),h={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},ee=/^(?:[ \t]*(?:\n|$))+/,te=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ne=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,g=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,re=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,v=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ie=p(v).replace(/bull/g,_).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ae=p(v).replace(/bull/g,_).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),y=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,oe=/^[^\n]+/,b=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,se=p(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,b).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ce=p(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_).getRegex(),x=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,S=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,le=p(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,S).replace(`tag`,x).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),C=p(y).replace(`hr`,g).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,x).getRegex(),w={blockquote:p(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,C).getRegex(),code:te,def:se,fences:ne,heading:re,hr:g,html:le,lheading:ie,list:ce,newline:ee,paragraph:C,table:f,text:oe},T=p(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,g).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,x).getRegex(),ue={...w,lheading:ae,table:T,paragraph:p(y).replace(`hr`,g).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,T).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,x).getRegex()},de={...w,html:p(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,S).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:f,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:p(y).replace(`hr`,g).replace(`heading`,` *#{1,6} *[^
2
2
  ]`).replace(`lheading`,ie).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},fe=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,pe=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,E=/^( {2,}|\\)\n(?!\s*$)/,me=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,D=/[\p{P}\p{S}]/u,O=/[\s\p{P}\p{S}]/u,k=/[^\s\p{P}\p{S}]/u,he=p(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,O).getRegex(),A=/(?!~)[\p{P}\p{S}]/u,ge=/(?!~)[\s\p{P}\p{S}]/u,_e=/(?:[^\s\p{P}\p{S}]|~)/u,j=/(?![*_])[\p{P}\p{S}]/u,ve=/(?![*_])[\s\p{P}\p{S}]/u,ye=/(?:[^\s\p{P}\p{S}]|[*_])/u,be=p(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,m?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),M=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,xe=p(M,`u`).replace(/punct/g,D).getRegex(),Se=p(M,`u`).replace(/punct/g,A).getRegex(),N=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Ce=p(N,`gu`).replace(/notPunctSpace/g,k).replace(/punctSpace/g,O).replace(/punct/g,D).getRegex(),we=p(N,`gu`).replace(/notPunctSpace/g,_e).replace(/punctSpace/g,ge).replace(/punct/g,A).getRegex(),Te=p(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,k).replace(/punctSpace/g,O).replace(/punct/g,D).getRegex(),Ee=p(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,j).getRegex(),De=p(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ye).replace(/punctSpace/g,ve).replace(/punct/g,j).getRegex(),Oe=p(/\\(punct)/,`gu`).replace(/punct/g,D).getRegex(),ke=p(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ae=p(S).replace(`(?:-->|$)`,`-->`).getRegex(),je=p(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Ae).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),P=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Me=p(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,P).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),F=p(/^!?\[(label)\]\[(ref)\]/).replace(`label`,P).replace(`ref`,b).getRegex(),I=p(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,b).getRegex(),Ne=p(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,F).replace(`nolink`,I).getRegex(),L=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,R={_backpedal:f,anyPunctuation:Oe,autolink:ke,blockSkip:be,br:E,code:pe,del:f,delLDelim:f,delRDelim:f,emStrongLDelim:xe,emStrongRDelimAst:Ce,emStrongRDelimUnd:Te,escape:fe,link:Me,nolink:I,punctuation:he,reflink:F,reflinkSearch:Ne,tag:je,text:me,url:f},Pe={...R,link:p(/^!?\[(label)\]\((.*?)\)/).replace(`label`,P).getRegex(),reflink:p(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,P).getRegex()},z={...R,emStrongRDelimAst:we,emStrongLDelim:Se,delLDelim:Ee,delRDelim:De,url:p(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,L).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:p(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,L).getRegex()},Fe={...z,br:p(E).replace(`{2,}`,`*`).getRegex(),text:p(z.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},B={normal:w,gfm:ue,pedantic:de},V={normal:R,gfm:z,breaks:Fe,pedantic:Pe},Ie={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},H=e=>Ie[e];function U(e,t){if(t){if(h.escapeTest.test(e))return e.replace(h.escapeReplace,H)}else if(h.escapeTestNoEncode.test(e))return e.replace(h.escapeReplaceNoEncode,H);return e}function Le(e){try{e=encodeURI(e).replace(h.percentDecode,`%`)}catch{return null}return e}function Re(e,t){let n=e.replace(h.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(h.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(h.slashPipe,`|`);return n}function W(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function ze(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Be(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Ve(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function He(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
3
3
  `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
4
4
  `)}var G=class{options;rules;lexer;constructor(e){this.options=e||u}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:W(e,`
@@ -1 +1 @@
1
- import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{a as r,c as i,i as a,o,r as s,s as c,t as l}from"./dist-D9RHR8A4.js";import{t as u}from"./table-C0oSLUYn.js";import{t as d}from"./api-client-TUmacMRS.js";import{A as f,E as p,H as m,L as h,U as g,V as _}from"./index-BGTzm7B1.js";var v=e(t(),1),y=`/api/postgres`;function b(e){let[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(!1),a=e?`/api/db/connections/${e}`:null,[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(null),[u,f]=(0,v.useState)(`public`),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)([]),[_,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(async e=>{b(!0),S(null);try{let t=await d.post(`${y}/test`,{connectionString:e});if(!t.ok){S(t.error??`Connection failed`);return}n(e),i(!0);let r=await d.post(`${y}/tables`,{connectionString:e});s(r),r.length>0&&(l(r[0].name),f(r[0].schema))}catch(e){S(e.message)}finally{b(!1)}},[]),M=(0,v.useCallback)(async()=>{if(a){b(!0);try{s(await d.get(`${a}/tables?cached=1`))}catch(e){S(e.message)}finally{b(!1)}return}if(t){b(!0);try{s(await d.post(`${y}/tables`,{connectionString:t}))}catch(e){S(e.message)}finally{b(!1)}}},[a,t,c]);(0,v.useEffect)(()=>{a&&(i(!0),M())},[a]);let N=(0,v.useCallback)(async(e,n,r)=>{let i=e??c,o=n??u;if(i){b(!0);try{if(a){let[e,t]=await Promise.all([d.get(`${a}/data?table=${encodeURIComponent(i)}&schema=${o}&page=${r??C}&limit=100`),d.get(`${a}/schema?table=${encodeURIComponent(i)}&schema=${o}`)]);m(e),g(t)}else{if(!t)return;let[e,n]=await Promise.all([d.post(`${y}/data`,{connectionString:t,table:i,schema:o,page:r??C,limit:100}),d.post(`${y}/schema`,{connectionString:t,table:i,schema:o})]);m(e),g(n)}}catch(e){S(e.message)}finally{b(!1)}}},[a,t,c,u,C]);return{connectionString:t,connected:r,connect:j,tables:o,selectedTable:c,selectTable:(0,v.useCallback)((e,t=`public`)=>{l(e),f(t),w(1),E(null),N(e,t,1)},[N]),tableData:p,schema:h,loading:_,error:x,page:C,setPage:(0,v.useCallback)(e=>{w(e),N(void 0,void 0,e)},[N]),queryResult:T,queryError:D,queryLoading:k,executeQuery:(0,v.useCallback)(async e=>{if(!(!a&&!t)){A(!0),O(null);try{let n=a?await d.post(`${a}/query`,{sql:e}):await d.post(`${y}/query`,{connectionString:t,sql:e});E(n),n.changeType===`modify`&&N()}catch(e){O(e.message)}finally{A(!1)}}},[a,t,N]),updateCell:(0,v.useCallback)(async(e,n,r,i)=>{if(c)try{if(a)await d.put(`${a}/cell`,{table:c,schema:u,pkColumn:e,pkValue:n,column:r,value:i});else{if(!t)return;await d.post(`${y}/cell`,{connectionString:t,table:c,schema:u,pkColumn:e,pkValue:n,column:r,value:i})}N()}catch(e){S(e.message)}},[a,t,c,u,N]),refreshTables:M,refreshData:N}}var x=n();function S({metadata:e}){let t=e?.connectionString??``,n=e?.connectionId,r=b(n);return r.connected?(0,x.jsx)(w,{pg:r,initialTable:e?.tableName,hideTableList:!!n,connectionName:e?.connectionName}):(0,x.jsx)(C,{initialValue:t,onConnect:r.connect,loading:r.loading,error:r.error})}function C({initialValue:e,onConnect:t,loading:n,error:r}){let[i,a]=(0,v.useState)(e);return(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,x.jsxs)(`div`,{className:`flex flex-col gap-3 w-full max-w-lg px-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,x.jsx)(h,{className:`size-4`}),` Connect to PostgreSQL`]}),(0,x.jsx)(`input`,{className:`w-full px-3 py-2 rounded border border-border bg-background text-sm font-mono outline-none focus:border-primary`,placeholder:`postgresql://user:pass@host:5432/db`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i.trim()&&t(i.trim())}}),r&&(0,x.jsxs)(`p`,{className:`text-xs text-destructive flex items-center gap-1`,children:[(0,x.jsx)(_,{className:`size-3`}),r]}),(0,x.jsx)(`button`,{type:`button`,disabled:n||!i.trim(),onClick:()=>t(i.trim()),className:`px-4 py-2 rounded bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:n?(0,x.jsx)(f,{className:`size-4 animate-spin mx-auto`}):`Connect`})]})})}function w({pg:e,initialTable:t,hideTableList:n,connectionName:r}){let[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{if(!(!t||o.current)){if(n&&e.connected)o.current=!0,e.selectTable(t);else if(e.tables.length>0){let n=e.tables.find(e=>e.name===t);n&&(o.current=!0,e.selectTable(n.name,n.schema))}}},[t,e.connected,e.tables]),(0,x.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden`,children:[!n&&(0,x.jsxs)(`div`,{className:`w-48 shrink-0 flex flex-col bg-background overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Tables`}),(0,x.jsx)(`button`,{type:`button`,onClick:e.refreshTables,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Refresh`,children:(0,x.jsx)(p,{className:`size-3`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.tables.map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>e.selectTable(t.name,t.schema),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors ${e.selectedTable===t.name?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[(0,x.jsx)(u,{className:`size-3 shrink-0`}),(0,x.jsxs)(`span`,{className:`truncate flex-1`,children:[t.schema===`public`?``:`${t.schema}.`,t.name]}),(0,x.jsx)(`span`,{className:`text-[10px] opacity-60`,children:t.rowCount})]},`${t.schema}.${t.name}`)),e.tables.length===0&&(0,x.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No tables found`})]})]}),(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden ${n?``:`border-l border-border`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,x.jsx)(h,{className:`size-3.5 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:r??`PostgreSQL`}),e.selectedTable&&(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,e.selectedTable]}),(0,x.jsx)(`div`,{className:`ml-auto`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`px-2 py-1 rounded text-xs transition-colors ${i?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:`SQL`})})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-hidden ${i?`max-h-[60%]`:``}`,children:(0,x.jsx)(T,{tableData:e.tableData,schema:e.schema,loading:e.loading,page:e.page,onPageChange:e.setPage,onCellUpdate:e.updateCell})}),i&&(0,x.jsx)(`div`,{className:`border-t border-border h-[40%] shrink-0`,children:(0,x.jsx)(E,{onExecute:e.executeQuery,result:e.queryResult,error:e.queryError,loading:e.queryLoading})})]})]})}function T({tableData:e,schema:t,loading:n,page:i,onPageChange:a,onCellUpdate:s}){let[l,u]=(0,v.useState)(null),[d,p]=(0,v.useState)(``),h=(0,v.useMemo)(()=>t.find(e=>e.pk)?.name??null,[t]),_=(0,v.useCallback)((e,t,n)=>{u({rowIdx:e,col:t}),p(n==null?``:String(n))},[]),y=(0,v.useCallback)(()=>{if(!l||!e||!h)return;let t=e.rows[l.rowIdx];if(!t)return;let n=t[l.col];String(n??``)!==d&&s(h,t[h],l.col,d===``?null:d),u(null)},[l,d,e,h,s]),b=(0,v.useCallback)(()=>u(null),[]),S=(0,v.useMemo)(()=>(e?.columns??[]).map(e=>({id:e,accessorFn:t=>t[e],header:()=>(0,x.jsx)(`span`,{className:t.find(t=>t.name===e)?.pk?`font-bold`:``,children:e}),cell:({row:t,getValue:n})=>{let r=l?.rowIdx===t.index&&l?.col===e,i=n();return r?(0,x.jsx)(`input`,{autoFocus:!0,className:`w-full bg-transparent border border-primary/50 rounded px-1 py-0 text-xs outline-none`,value:d,onChange:e=>p(e.target.value),onBlur:y,onKeyDown:e=>{e.key===`Enter`&&y(),e.key===`Escape`&&b()}}):(0,x.jsx)(`span`,{className:`cursor-pointer truncate block ${i==null?`text-muted-foreground/40 italic`:``}`,onDoubleClick:()=>h&&_(t.index,e,i),title:i==null?`NULL`:String(i),children:i==null?`NULL`:String(i)})}})),[e?.columns,t,l,d,y,b,_,h]),C=o({data:e?.rows??[],columns:S,getCoreRowModel:c()});if(!e)return(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:n?(0,x.jsx)(f,{className:`size-4 animate-spin`}):`Select a table`});let w=Math.ceil(e.total/e.limit)||1;return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,x.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:C.getHeaderGroups().map(e=>(0,x.jsx)(`tr`,{children:e.headers.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:r(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,x.jsxs)(`tbody`,{children:[C.getRowModel().rows.map(e=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:e.getVisibleCells().map(e=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px]`,children:r(e.column.columnDef.cell,e.getContext())},e.id))},e.id)),e.rows.length===0&&(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:e.columns.length,className:`px-2 py-8 text-center text-muted-foreground`,children:`No data`})})]})]})}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-t border-border bg-background shrink-0 text-xs text-muted-foreground`,children:[(0,x.jsxs)(`span`,{children:[e.total.toLocaleString(),` rows`]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,disabled:i<=1,onClick:()=>a(i-1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(g,{className:`size-3.5`})}),(0,x.jsxs)(`span`,{children:[i,` / `,w]}),(0,x.jsx)(`button`,{type:`button`,disabled:i>=w,onClick:()=>a(i+1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(m,{className:`size-3.5`})})]})]})]})}function E({onExecute:e,result:t,error:n,loading:r}){let[o,c]=(0,v.useState)(`SELECT * FROM `),u=(0,v.useCallback)(()=>{let t=o.trim();t&&e(t)},[o,e]);return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-1 border-b border-border bg-background`,onKeyDown:(0,v.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),u())},[u]),children:[(0,x.jsx)(`div`,{className:`flex-1 max-h-[120px] overflow-auto`,children:(0,x.jsx)(a,{value:o,onChange:c,extensions:[s({dialect:l})],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1},className:`text-xs [&_.cm-editor]:!outline-none [&_.cm-scroller]:!overflow-auto`})}),(0,x.jsx)(`button`,{type:`button`,onClick:u,disabled:r,title:`Execute (Cmd+Enter)`,className:`shrink-0 m-1 p-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:r?(0,x.jsx)(f,{className:`size-3.5 animate-spin`}):(0,x.jsx)(i,{className:`size-3.5`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-auto text-xs`,children:[n&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5`,children:n}),t?.changeType===`modify`&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-green-500`,children:[`Query executed. `,t.rowsAffected,` row(s) affected.`]}),t?.changeType===`select`&&t.rows.length>0&&(0,x.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,x.jsx)(`tr`,{children:t.columns.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:e},e))})}),(0,x.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:t.columns.map(t=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px] truncate`,title:e[t]==null?`NULL`:String(e[t]),children:e[t]==null?(0,x.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`NULL`}):String(e[t])},t))},n))})]}),t?.changeType===`select`&&t.rows.length===0&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-muted-foreground`,children:`No results`})]})]})}export{S as PostgresViewer};
1
+ import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{a as r,c as i,i as a,o,r as s,s as c,t as l}from"./dist-D9RHR8A4.js";import{t as u}from"./table-C0oSLUYn.js";import{t as d}from"./api-client-TUmacMRS.js";import{A as f,E as p,H as m,L as h,U as g,V as _}from"./index-BjNob0pC.js";var v=e(t(),1),y=`/api/postgres`;function b(e){let[t,n]=(0,v.useState)(``),[r,i]=(0,v.useState)(!1),a=e?`/api/db/connections/${e}`:null,[o,s]=(0,v.useState)([]),[c,l]=(0,v.useState)(null),[u,f]=(0,v.useState)(`public`),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)([]),[_,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(async e=>{b(!0),S(null);try{let t=await d.post(`${y}/test`,{connectionString:e});if(!t.ok){S(t.error??`Connection failed`);return}n(e),i(!0);let r=await d.post(`${y}/tables`,{connectionString:e});s(r),r.length>0&&(l(r[0].name),f(r[0].schema))}catch(e){S(e.message)}finally{b(!1)}},[]),M=(0,v.useCallback)(async()=>{if(a){b(!0);try{s(await d.get(`${a}/tables?cached=1`))}catch(e){S(e.message)}finally{b(!1)}return}if(t){b(!0);try{s(await d.post(`${y}/tables`,{connectionString:t}))}catch(e){S(e.message)}finally{b(!1)}}},[a,t,c]);(0,v.useEffect)(()=>{a&&(i(!0),M())},[a]);let N=(0,v.useCallback)(async(e,n,r)=>{let i=e??c,o=n??u;if(i){b(!0);try{if(a){let[e,t]=await Promise.all([d.get(`${a}/data?table=${encodeURIComponent(i)}&schema=${o}&page=${r??C}&limit=100`),d.get(`${a}/schema?table=${encodeURIComponent(i)}&schema=${o}`)]);m(e),g(t)}else{if(!t)return;let[e,n]=await Promise.all([d.post(`${y}/data`,{connectionString:t,table:i,schema:o,page:r??C,limit:100}),d.post(`${y}/schema`,{connectionString:t,table:i,schema:o})]);m(e),g(n)}}catch(e){S(e.message)}finally{b(!1)}}},[a,t,c,u,C]);return{connectionString:t,connected:r,connect:j,tables:o,selectedTable:c,selectTable:(0,v.useCallback)((e,t=`public`)=>{l(e),f(t),w(1),E(null),N(e,t,1)},[N]),tableData:p,schema:h,loading:_,error:x,page:C,setPage:(0,v.useCallback)(e=>{w(e),N(void 0,void 0,e)},[N]),queryResult:T,queryError:D,queryLoading:k,executeQuery:(0,v.useCallback)(async e=>{if(!(!a&&!t)){A(!0),O(null);try{let n=a?await d.post(`${a}/query`,{sql:e}):await d.post(`${y}/query`,{connectionString:t,sql:e});E(n),n.changeType===`modify`&&N()}catch(e){O(e.message)}finally{A(!1)}}},[a,t,N]),updateCell:(0,v.useCallback)(async(e,n,r,i)=>{if(c)try{if(a)await d.put(`${a}/cell`,{table:c,schema:u,pkColumn:e,pkValue:n,column:r,value:i});else{if(!t)return;await d.post(`${y}/cell`,{connectionString:t,table:c,schema:u,pkColumn:e,pkValue:n,column:r,value:i})}N()}catch(e){S(e.message)}},[a,t,c,u,N]),refreshTables:M,refreshData:N}}var x=n();function S({metadata:e}){let t=e?.connectionString??``,n=e?.connectionId,r=b(n);return r.connected?(0,x.jsx)(w,{pg:r,initialTable:e?.tableName,hideTableList:!!n,connectionName:e?.connectionName}):(0,x.jsx)(C,{initialValue:t,onConnect:r.connect,loading:r.loading,error:r.error})}function C({initialValue:e,onConnect:t,loading:n,error:r}){let[i,a]=(0,v.useState)(e);return(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,x.jsxs)(`div`,{className:`flex flex-col gap-3 w-full max-w-lg px-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,x.jsx)(h,{className:`size-4`}),` Connect to PostgreSQL`]}),(0,x.jsx)(`input`,{className:`w-full px-3 py-2 rounded border border-border bg-background text-sm font-mono outline-none focus:border-primary`,placeholder:`postgresql://user:pass@host:5432/db`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i.trim()&&t(i.trim())}}),r&&(0,x.jsxs)(`p`,{className:`text-xs text-destructive flex items-center gap-1`,children:[(0,x.jsx)(_,{className:`size-3`}),r]}),(0,x.jsx)(`button`,{type:`button`,disabled:n||!i.trim(),onClick:()=>t(i.trim()),className:`px-4 py-2 rounded bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:n?(0,x.jsx)(f,{className:`size-4 animate-spin mx-auto`}):`Connect`})]})})}function w({pg:e,initialTable:t,hideTableList:n,connectionName:r}){let[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1);return(0,v.useEffect)(()=>{if(!(!t||o.current)){if(n&&e.connected)o.current=!0,e.selectTable(t);else if(e.tables.length>0){let n=e.tables.find(e=>e.name===t);n&&(o.current=!0,e.selectTable(n.name,n.schema))}}},[t,e.connected,e.tables]),(0,x.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden`,children:[!n&&(0,x.jsxs)(`div`,{className:`w-48 shrink-0 flex flex-col bg-background overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Tables`}),(0,x.jsx)(`button`,{type:`button`,onClick:e.refreshTables,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Refresh`,children:(0,x.jsx)(p,{className:`size-3`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.tables.map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>e.selectTable(t.name,t.schema),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors ${e.selectedTable===t.name?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[(0,x.jsx)(u,{className:`size-3 shrink-0`}),(0,x.jsxs)(`span`,{className:`truncate flex-1`,children:[t.schema===`public`?``:`${t.schema}.`,t.name]}),(0,x.jsx)(`span`,{className:`text-[10px] opacity-60`,children:t.rowCount})]},`${t.schema}.${t.name}`)),e.tables.length===0&&(0,x.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No tables found`})]})]}),(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden ${n?``:`border-l border-border`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,x.jsx)(h,{className:`size-3.5 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:r??`PostgreSQL`}),e.selectedTable&&(0,x.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,e.selectedTable]}),(0,x.jsx)(`div`,{className:`ml-auto`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`px-2 py-1 rounded text-xs transition-colors ${i?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:`SQL`})})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-hidden ${i?`max-h-[60%]`:``}`,children:(0,x.jsx)(T,{tableData:e.tableData,schema:e.schema,loading:e.loading,page:e.page,onPageChange:e.setPage,onCellUpdate:e.updateCell})}),i&&(0,x.jsx)(`div`,{className:`border-t border-border h-[40%] shrink-0`,children:(0,x.jsx)(E,{onExecute:e.executeQuery,result:e.queryResult,error:e.queryError,loading:e.queryLoading})})]})]})}function T({tableData:e,schema:t,loading:n,page:i,onPageChange:a,onCellUpdate:s}){let[l,u]=(0,v.useState)(null),[d,p]=(0,v.useState)(``),h=(0,v.useMemo)(()=>t.find(e=>e.pk)?.name??null,[t]),_=(0,v.useCallback)((e,t,n)=>{u({rowIdx:e,col:t}),p(n==null?``:String(n))},[]),y=(0,v.useCallback)(()=>{if(!l||!e||!h)return;let t=e.rows[l.rowIdx];if(!t)return;let n=t[l.col];String(n??``)!==d&&s(h,t[h],l.col,d===``?null:d),u(null)},[l,d,e,h,s]),b=(0,v.useCallback)(()=>u(null),[]),S=(0,v.useMemo)(()=>(e?.columns??[]).map(e=>({id:e,accessorFn:t=>t[e],header:()=>(0,x.jsx)(`span`,{className:t.find(t=>t.name===e)?.pk?`font-bold`:``,children:e}),cell:({row:t,getValue:n})=>{let r=l?.rowIdx===t.index&&l?.col===e,i=n();return r?(0,x.jsx)(`input`,{autoFocus:!0,className:`w-full bg-transparent border border-primary/50 rounded px-1 py-0 text-xs outline-none`,value:d,onChange:e=>p(e.target.value),onBlur:y,onKeyDown:e=>{e.key===`Enter`&&y(),e.key===`Escape`&&b()}}):(0,x.jsx)(`span`,{className:`cursor-pointer truncate block ${i==null?`text-muted-foreground/40 italic`:``}`,onDoubleClick:()=>h&&_(t.index,e,i),title:i==null?`NULL`:String(i),children:i==null?`NULL`:String(i)})}})),[e?.columns,t,l,d,y,b,_,h]),C=o({data:e?.rows??[],columns:S,getCoreRowModel:c()});if(!e)return(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:n?(0,x.jsx)(f,{className:`size-4 animate-spin`}):`Select a table`});let w=Math.ceil(e.total/e.limit)||1;return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,x.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:C.getHeaderGroups().map(e=>(0,x.jsx)(`tr`,{children:e.headers.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:r(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,x.jsxs)(`tbody`,{children:[C.getRowModel().rows.map(e=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:e.getVisibleCells().map(e=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px]`,children:r(e.column.columnDef.cell,e.getContext())},e.id))},e.id)),e.rows.length===0&&(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:e.columns.length,className:`px-2 py-8 text-center text-muted-foreground`,children:`No data`})})]})]})}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-t border-border bg-background shrink-0 text-xs text-muted-foreground`,children:[(0,x.jsxs)(`span`,{children:[e.total.toLocaleString(),` rows`]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,disabled:i<=1,onClick:()=>a(i-1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(g,{className:`size-3.5`})}),(0,x.jsxs)(`span`,{children:[i,` / `,w]}),(0,x.jsx)(`button`,{type:`button`,disabled:i>=w,onClick:()=>a(i+1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(m,{className:`size-3.5`})})]})]})]})}function E({onExecute:e,result:t,error:n,loading:r}){let[o,c]=(0,v.useState)(`SELECT * FROM `),u=(0,v.useCallback)(()=>{let t=o.trim();t&&e(t)},[o,e]);return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-1 border-b border-border bg-background`,onKeyDown:(0,v.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),u())},[u]),children:[(0,x.jsx)(`div`,{className:`flex-1 max-h-[120px] overflow-auto`,children:(0,x.jsx)(a,{value:o,onChange:c,extensions:[s({dialect:l})],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1},className:`text-xs [&_.cm-editor]:!outline-none [&_.cm-scroller]:!overflow-auto`})}),(0,x.jsx)(`button`,{type:`button`,onClick:u,disabled:r,title:`Execute (Cmd+Enter)`,className:`shrink-0 m-1 p-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:r?(0,x.jsx)(f,{className:`size-3.5 animate-spin`}):(0,x.jsx)(i,{className:`size-3.5`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-auto text-xs`,children:[n&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5`,children:n}),t?.changeType===`modify`&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-green-500`,children:[`Query executed. `,t.rowsAffected,` row(s) affected.`]}),t?.changeType===`select`&&t.rows.length>0&&(0,x.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,x.jsx)(`tr`,{children:t.columns.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:e},e))})}),(0,x.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:t.columns.map(t=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px] truncate`,title:e[t]==null?`NULL`:String(e[t]),children:e[t]==null?(0,x.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`NULL`}):String(e[t])},t))},n))})]}),t?.changeType===`select`&&t.rows.length===0&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-muted-foreground`,children:`No results`})]})]})}export{S as PostgresViewer};
@@ -1 +1 @@
1
- import"./react-CYzKIDNi.js";import"./input-CE3bFwLk.js";import"./jsx-runtime-wQxeESYQ.js";import"./switch-BEmt1alu.js";import"./settings-store-2NQzaOVJ.js";import"./api-client-TUmacMRS.js";import{n as e}from"./index-BGTzm7B1.js";export{e as SettingsTab};
1
+ import"./react-CYzKIDNi.js";import"./input-CE3bFwLk.js";import"./jsx-runtime-wQxeESYQ.js";import"./switch-D0FJQVBN.js";import"./settings-store-2NQzaOVJ.js";import"./api-client-TUmacMRS.js";import{n as e}from"./index-BjNob0pC.js";export{e as SettingsTab};
@@ -1 +1 @@
1
- import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{a as r,c as i,i as a,n as o,o as s,r as c,s as l}from"./dist-D9RHR8A4.js";import{t as u}from"./table-C0oSLUYn.js";import{i as d,t as f}from"./api-client-TUmacMRS.js";import{A as p,E as m,H as h,L as g,U as _,V as v}from"./index-BGTzm7B1.js";var y=e(t(),1);function b(e,t,n){let[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)([]),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(1),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(!1),E=n?`/api/db/connections/${n}`:null,D=E??`${d(e)}/sqlite`,O=E?``:`path=${encodeURIComponent(t)}`,k=(0,y.useCallback)(async()=>{m(!0),g(null);try{let e=E?`?cached=1`:O?`?${O}`:``,t=await f.get(`${D}/tables${e}`);i(t),!E&&t.length>0&&!a&&o(t[0].name)}catch(e){g(e.message)}finally{m(!1)}},[D,O,E]);(0,y.useEffect)(()=>{k()},[k]);let A=(0,y.useCallback)(async()=>{if(a){m(!0);try{let e=O?`${O}&`:``,[t,n]=await Promise.all([f.get(`${D}/data?${e}table=${encodeURIComponent(a)}&page=${_}&limit=100`),f.get(`${D}/schema?${e}table=${encodeURIComponent(a)}`)]);c(t),u(n)}catch(e){g(e.message)}finally{m(!1)}}},[D,O,a,_]);return(0,y.useEffect)(()=>{A()},[A]),{tables:r,selectedTable:a,selectTable:(0,y.useCallback)(e=>{o(e),v(1),x(null)},[]),tableData:s,schema:l,loading:p,error:h,page:_,setPage:v,queryResult:b,queryError:S,queryLoading:w,executeQuery:(0,y.useCallback)(async e=>{T(!0),C(null);try{let n=E?{sql:e}:{path:t,sql:e},r=await f.post(`${D}/query`,n);x(r),r.changeType===`modify`&&A()}catch(e){C(e.message)}finally{T(!1)}},[D,E,t,A]),updateCell:(0,y.useCallback)(async(e,n,r)=>{if(a)try{E?await f.put(`${D}/cell`,{table:a,pkColumn:`rowid`,pkValue:e,column:n,value:r}):await f.put(`${D}/cell`,{path:t,table:a,rowid:e,column:n,value:r}),A()}catch(e){g(e.message)}},[D,E,t,a,A]),refreshTables:k,refreshData:A}}var x=n();function S({tables:e,selectedTable:t,onSelect:n,onRefresh:r}){return(0,x.jsxs)(`div`,{className:`w-48 shrink-0 flex flex-col bg-background overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Tables`}),(0,x.jsx)(`button`,{type:`button`,onClick:r,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Refresh tables`,children:(0,x.jsx)(m,{className:`size-3`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.map(e=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>n(e.name),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors ${t===e.name?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[(0,x.jsx)(u,{className:`size-3 shrink-0`}),(0,x.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),(0,x.jsx)(`span`,{className:`text-[10px] opacity-60`,children:e.rowCount})]},e.name)),e.length===0&&(0,x.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No tables found`})]})]})}function C({tableData:e,schema:t,loading:n,page:r,onPageChange:i,onCellUpdate:a}){if(!e)return(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:n?(0,x.jsx)(p,{className:`size-4 animate-spin`}):`Select a table`});let o=Math.ceil(e.total/e.limit)||1;return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,x.jsx)(w,{columns:e.columns,rows:e.rows,schema:t,onCellUpdate:a})}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-t border-border bg-background shrink-0 text-xs text-muted-foreground`,children:[(0,x.jsxs)(`span`,{children:[e.total.toLocaleString(),` rows`]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,disabled:r<=1,onClick:()=>i(r-1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(_,{className:`size-3.5`})}),(0,x.jsxs)(`span`,{children:[r,` / `,o]}),(0,x.jsx)(`button`,{type:`button`,disabled:r>=o,onClick:()=>i(r+1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(h,{className:`size-3.5`})})]})]})]})}function w({columns:e,rows:t,schema:n,onCellUpdate:i}){let[a,o]=(0,y.useState)(null),[c,u]=(0,y.useState)(``),d=(0,y.useMemo)(()=>new Set(n.filter(e=>e.pk).map(e=>e.name)),[n]),f=(0,y.useCallback)((e,t,n)=>{t!==`rowid`&&(o({rowIdx:e,col:t}),u(n==null?``:String(n)))},[]),p=(0,y.useCallback)(()=>{if(!a)return;let e=t[a.rowIdx];if(!e)return;let n=e.rowid,r=e[a.col];String(r??``)!==c&&i(n,a.col,c===``?null:c),o(null)},[a,c,t,i]),m=(0,y.useCallback)(()=>o(null),[]),h=s({data:t,columns:(0,y.useMemo)(()=>e.map(e=>({id:e,accessorFn:t=>t[e],header:()=>(0,x.jsx)(`span`,{className:`${d.has(e)?`font-bold`:``} ${e===`rowid`?`text-muted-foreground/50`:``}`,children:e}),cell:({row:t,getValue:n})=>{let r=t.index,i=a?.rowIdx===r&&a?.col===e,o=n();return i?(0,x.jsx)(`input`,{autoFocus:!0,className:`w-full bg-transparent border border-primary/50 rounded px-1 py-0 text-xs outline-none`,value:c,onChange:e=>u(e.target.value),onBlur:p,onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&m()}}):(0,x.jsx)(`span`,{className:`cursor-pointer truncate block ${o==null?`text-muted-foreground/40 italic`:``} ${e===`rowid`?`text-muted-foreground/50`:``}`,onDoubleClick:()=>f(r,e,o),title:o==null?`NULL`:String(o),children:o==null?`NULL`:String(o)})}})),[e,d,a,c,p,m,f]),getCoreRowModel:l()});return(0,x.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:h.getHeaderGroups().map(e=>(0,x.jsx)(`tr`,{children:e.headers.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:r(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,x.jsxs)(`tbody`,{children:[h.getRowModel().rows.map(e=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:e.getVisibleCells().map(e=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px]`,children:r(e.column.columnDef.cell,e.getContext())},e.id))},e.id)),t.length===0&&(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:e.length,className:`px-2 py-8 text-center text-muted-foreground`,children:`No data`})})]})]})}function T({onExecute:e,result:t,error:n,loading:r}){let[s,l]=(0,y.useState)(`SELECT * FROM `),u=(0,y.useCallback)(()=>{let t=s.trim();t&&e(t)},[s,e]);return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-1 border-b border-border bg-background`,onKeyDown:(0,y.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),u())},[u]),children:[(0,x.jsx)(`div`,{className:`flex-1 max-h-[120px] overflow-auto`,children:(0,x.jsx)(a,{value:s,onChange:l,extensions:[c({dialect:o})],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1},className:`text-xs [&_.cm-editor]:!outline-none [&_.cm-scroller]:!overflow-auto`})}),(0,x.jsx)(`button`,{type:`button`,onClick:u,disabled:r,className:`shrink-0 m-1 p-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,title:`Execute (Cmd+Enter)`,children:r?(0,x.jsx)(p,{className:`size-3.5 animate-spin`}):(0,x.jsx)(i,{className:`size-3.5`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-auto text-xs`,children:[n&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5`,children:n}),t&&t.changeType===`modify`&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-green-500`,children:[`Query executed. `,t.rowsAffected,` row(s) affected.`]}),t&&t.changeType===`select`&&t.rows.length>0&&(0,x.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,x.jsx)(`tr`,{children:t.columns.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:e},e))})}),(0,x.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:t.columns.map(t=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px] truncate`,title:e[t]==null?`NULL`:String(e[t]),children:e[t]==null?(0,x.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`NULL`}):String(e[t])},t))},n))})]}),t&&t.changeType===`select`&&t.rows.length===0&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-muted-foreground`,children:`No results`})]})]})}function E({metadata:e}){let t=e?.filePath,n=e?.projectName,r=e?.connectionId,i=e?.tableName,[a,o]=(0,y.useState)(!1);return r?(0,x.jsx)(D,{projectName:``,dbPath:``,connectionId:r,connectionName:e?.connectionName,initialTable:i,queryPanelOpen:a,onToggleQueryPanel:()=>o(e=>!e),hideTableList:!0}):!t||!n?(0,x.jsxs)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:[(0,x.jsx)(g,{className:`size-5 mr-2`}),` No database file selected.`]}):(0,x.jsx)(D,{projectName:n,dbPath:t,queryPanelOpen:a,onToggleQueryPanel:()=>o(e=>!e)})}function D({projectName:e,dbPath:t,connectionId:n,connectionName:r,initialTable:i,queryPanelOpen:a,onToggleQueryPanel:o,hideTableList:s}){let c=b(e,t,n),l=(0,y.useRef)(!1);return(0,y.useEffect)(()=>{i&&!l.current&&c.tables.length>0&&(l.current=!0,c.selectTable(i))},[i,c.tables]),c.error&&c.tables.length===0?(0,x.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,x.jsx)(v,{className:`size-10 text-destructive`}),(0,x.jsx)(`p`,{className:`text-sm`,children:c.error})]}):c.loading&&c.tables.length===0?(0,x.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,x.jsx)(p,{className:`size-5 animate-spin`}),(0,x.jsx)(`span`,{className:`text-sm`,children:`Loading database...`})]}):(0,x.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden`,children:[!s&&(0,x.jsx)(S,{tables:c.tables,selectedTable:c.selectedTable,onSelect:c.selectTable,onRefresh:c.refreshTables}),(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden ${s?``:`border-l border-border`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,x.jsx)(g,{className:`size-3.5 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:r??t}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c.selectedTable&&`/ ${c.selectedTable}`}),(0,x.jsx)(`div`,{className:`ml-auto`,children:(0,x.jsx)(`button`,{type:`button`,onClick:o,className:`px-2 py-1 rounded text-xs transition-colors ${a?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:`SQL`})})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-hidden ${a?`max-h-[60%]`:``}`,children:(0,x.jsx)(C,{tableData:c.tableData,schema:c.schema,loading:c.loading,page:c.page,onPageChange:c.setPage,onCellUpdate:c.updateCell})}),a&&(0,x.jsx)(`div`,{className:`border-t border-border h-[40%] shrink-0`,children:(0,x.jsx)(T,{onExecute:c.executeQuery,result:c.queryResult,error:c.queryError,loading:c.queryLoading})})]})]})}export{E as SqliteViewer};
1
+ import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{a as r,c as i,i as a,n as o,o as s,r as c,s as l}from"./dist-D9RHR8A4.js";import{t as u}from"./table-C0oSLUYn.js";import{i as d,t as f}from"./api-client-TUmacMRS.js";import{A as p,E as m,H as h,L as g,U as _,V as v}from"./index-BjNob0pC.js";var y=e(t(),1);function b(e,t,n){let[r,i]=(0,y.useState)([]),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)([]),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(1),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(!1),E=n?`/api/db/connections/${n}`:null,D=E??`${d(e)}/sqlite`,O=E?``:`path=${encodeURIComponent(t)}`,k=(0,y.useCallback)(async()=>{m(!0),g(null);try{let e=E?`?cached=1`:O?`?${O}`:``,t=await f.get(`${D}/tables${e}`);i(t),!E&&t.length>0&&!a&&o(t[0].name)}catch(e){g(e.message)}finally{m(!1)}},[D,O,E]);(0,y.useEffect)(()=>{k()},[k]);let A=(0,y.useCallback)(async()=>{if(a){m(!0);try{let e=O?`${O}&`:``,[t,n]=await Promise.all([f.get(`${D}/data?${e}table=${encodeURIComponent(a)}&page=${_}&limit=100`),f.get(`${D}/schema?${e}table=${encodeURIComponent(a)}`)]);c(t),u(n)}catch(e){g(e.message)}finally{m(!1)}}},[D,O,a,_]);return(0,y.useEffect)(()=>{A()},[A]),{tables:r,selectedTable:a,selectTable:(0,y.useCallback)(e=>{o(e),v(1),x(null)},[]),tableData:s,schema:l,loading:p,error:h,page:_,setPage:v,queryResult:b,queryError:S,queryLoading:w,executeQuery:(0,y.useCallback)(async e=>{T(!0),C(null);try{let n=E?{sql:e}:{path:t,sql:e},r=await f.post(`${D}/query`,n);x(r),r.changeType===`modify`&&A()}catch(e){C(e.message)}finally{T(!1)}},[D,E,t,A]),updateCell:(0,y.useCallback)(async(e,n,r)=>{if(a)try{E?await f.put(`${D}/cell`,{table:a,pkColumn:`rowid`,pkValue:e,column:n,value:r}):await f.put(`${D}/cell`,{path:t,table:a,rowid:e,column:n,value:r}),A()}catch(e){g(e.message)}},[D,E,t,a,A]),refreshTables:k,refreshData:A}}var x=n();function S({tables:e,selectedTable:t,onSelect:n,onRefresh:r}){return(0,x.jsxs)(`div`,{className:`w-48 shrink-0 flex flex-col bg-background overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Tables`}),(0,x.jsx)(`button`,{type:`button`,onClick:r,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Refresh tables`,children:(0,x.jsx)(m,{className:`size-3`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.map(e=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>n(e.name),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors ${t===e.name?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[(0,x.jsx)(u,{className:`size-3 shrink-0`}),(0,x.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),(0,x.jsx)(`span`,{className:`text-[10px] opacity-60`,children:e.rowCount})]},e.name)),e.length===0&&(0,x.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No tables found`})]})]})}function C({tableData:e,schema:t,loading:n,page:r,onPageChange:i,onCellUpdate:a}){if(!e)return(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:n?(0,x.jsx)(p,{className:`size-4 animate-spin`}):`Select a table`});let o=Math.ceil(e.total/e.limit)||1;return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,x.jsx)(w,{columns:e.columns,rows:e.rows,schema:t,onCellUpdate:a})}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-t border-border bg-background shrink-0 text-xs text-muted-foreground`,children:[(0,x.jsxs)(`span`,{children:[e.total.toLocaleString(),` rows`]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,disabled:r<=1,onClick:()=>i(r-1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(_,{className:`size-3.5`})}),(0,x.jsxs)(`span`,{children:[r,` / `,o]}),(0,x.jsx)(`button`,{type:`button`,disabled:r>=o,onClick:()=>i(r+1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,x.jsx)(h,{className:`size-3.5`})})]})]})]})}function w({columns:e,rows:t,schema:n,onCellUpdate:i}){let[a,o]=(0,y.useState)(null),[c,u]=(0,y.useState)(``),d=(0,y.useMemo)(()=>new Set(n.filter(e=>e.pk).map(e=>e.name)),[n]),f=(0,y.useCallback)((e,t,n)=>{t!==`rowid`&&(o({rowIdx:e,col:t}),u(n==null?``:String(n)))},[]),p=(0,y.useCallback)(()=>{if(!a)return;let e=t[a.rowIdx];if(!e)return;let n=e.rowid,r=e[a.col];String(r??``)!==c&&i(n,a.col,c===``?null:c),o(null)},[a,c,t,i]),m=(0,y.useCallback)(()=>o(null),[]),h=s({data:t,columns:(0,y.useMemo)(()=>e.map(e=>({id:e,accessorFn:t=>t[e],header:()=>(0,x.jsx)(`span`,{className:`${d.has(e)?`font-bold`:``} ${e===`rowid`?`text-muted-foreground/50`:``}`,children:e}),cell:({row:t,getValue:n})=>{let r=t.index,i=a?.rowIdx===r&&a?.col===e,o=n();return i?(0,x.jsx)(`input`,{autoFocus:!0,className:`w-full bg-transparent border border-primary/50 rounded px-1 py-0 text-xs outline-none`,value:c,onChange:e=>u(e.target.value),onBlur:p,onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&m()}}):(0,x.jsx)(`span`,{className:`cursor-pointer truncate block ${o==null?`text-muted-foreground/40 italic`:``} ${e===`rowid`?`text-muted-foreground/50`:``}`,onDoubleClick:()=>f(r,e,o),title:o==null?`NULL`:String(o),children:o==null?`NULL`:String(o)})}})),[e,d,a,c,p,m,f]),getCoreRowModel:l()});return(0,x.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:h.getHeaderGroups().map(e=>(0,x.jsx)(`tr`,{children:e.headers.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:r(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,x.jsxs)(`tbody`,{children:[h.getRowModel().rows.map(e=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:e.getVisibleCells().map(e=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px]`,children:r(e.column.columnDef.cell,e.getContext())},e.id))},e.id)),t.length===0&&(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:e.length,className:`px-2 py-8 text-center text-muted-foreground`,children:`No data`})})]})]})}function T({onExecute:e,result:t,error:n,loading:r}){let[s,l]=(0,y.useState)(`SELECT * FROM `),u=(0,y.useCallback)(()=>{let t=s.trim();t&&e(t)},[s,e]);return(0,x.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-1 border-b border-border bg-background`,onKeyDown:(0,y.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),u())},[u]),children:[(0,x.jsx)(`div`,{className:`flex-1 max-h-[120px] overflow-auto`,children:(0,x.jsx)(a,{value:s,onChange:l,extensions:[c({dialect:o})],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1},className:`text-xs [&_.cm-editor]:!outline-none [&_.cm-scroller]:!overflow-auto`})}),(0,x.jsx)(`button`,{type:`button`,onClick:u,disabled:r,className:`shrink-0 m-1 p-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,title:`Execute (Cmd+Enter)`,children:r?(0,x.jsx)(p,{className:`size-3.5 animate-spin`}):(0,x.jsx)(i,{className:`size-3.5`})})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-auto text-xs`,children:[n&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5`,children:n}),t&&t.changeType===`modify`&&(0,x.jsxs)(`div`,{className:`px-3 py-2 text-green-500`,children:[`Query executed. `,t.rowsAffected,` row(s) affected.`]}),t&&t.changeType===`select`&&t.rows.length>0&&(0,x.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,x.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,x.jsx)(`tr`,{children:t.columns.map(e=>(0,x.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:e},e))})}),(0,x.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,x.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:t.columns.map(t=>(0,x.jsx)(`td`,{className:`px-2 py-1 max-w-[300px] truncate`,title:e[t]==null?`NULL`:String(e[t]),children:e[t]==null?(0,x.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`NULL`}):String(e[t])},t))},n))})]}),t&&t.changeType===`select`&&t.rows.length===0&&(0,x.jsx)(`div`,{className:`px-3 py-2 text-muted-foreground`,children:`No results`})]})]})}function E({metadata:e}){let t=e?.filePath,n=e?.projectName,r=e?.connectionId,i=e?.tableName,[a,o]=(0,y.useState)(!1);return r?(0,x.jsx)(D,{projectName:``,dbPath:``,connectionId:r,connectionName:e?.connectionName,initialTable:i,queryPanelOpen:a,onToggleQueryPanel:()=>o(e=>!e),hideTableList:!0}):!t||!n?(0,x.jsxs)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:[(0,x.jsx)(g,{className:`size-5 mr-2`}),` No database file selected.`]}):(0,x.jsx)(D,{projectName:n,dbPath:t,queryPanelOpen:a,onToggleQueryPanel:()=>o(e=>!e)})}function D({projectName:e,dbPath:t,connectionId:n,connectionName:r,initialTable:i,queryPanelOpen:a,onToggleQueryPanel:o,hideTableList:s}){let c=b(e,t,n),l=(0,y.useRef)(!1);return(0,y.useEffect)(()=>{i&&!l.current&&c.tables.length>0&&(l.current=!0,c.selectTable(i))},[i,c.tables]),c.error&&c.tables.length===0?(0,x.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,x.jsx)(v,{className:`size-10 text-destructive`}),(0,x.jsx)(`p`,{className:`text-sm`,children:c.error})]}):c.loading&&c.tables.length===0?(0,x.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,x.jsx)(p,{className:`size-5 animate-spin`}),(0,x.jsx)(`span`,{className:`text-sm`,children:`Loading database...`})]}):(0,x.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden`,children:[!s&&(0,x.jsx)(S,{tables:c.tables,selectedTable:c.selectedTable,onSelect:c.selectTable,onRefresh:c.refreshTables}),(0,x.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden ${s?``:`border-l border-border`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,x.jsx)(g,{className:`size-3.5 text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:r??t}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c.selectedTable&&`/ ${c.selectedTable}`}),(0,x.jsx)(`div`,{className:`ml-auto`,children:(0,x.jsx)(`button`,{type:`button`,onClick:o,className:`px-2 py-1 rounded text-xs transition-colors ${a?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:`SQL`})})]}),(0,x.jsx)(`div`,{className:`flex-1 overflow-hidden ${a?`max-h-[60%]`:``}`,children:(0,x.jsx)(C,{tableData:c.tableData,schema:c.schema,loading:c.loading,page:c.page,onPageChange:c.setPage,onCellUpdate:c.updateCell})}),a&&(0,x.jsx)(`div`,{className:`border-t border-border h-[40%] shrink-0`,children:(0,x.jsx)(T,{onExecute:c.executeQuery,result:c.queryResult,error:c.queryError,loading:c.queryLoading})})]})]})}export{E as SqliteViewer};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./react-CYzKIDNi.js";import{C as n,E as r,M as i,N as a,P as o,S as s,_ as c,a as l,b as u,c as d,d as f,f as p,g as m,h,i as g,k as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E,v as D,y as O}from"./input-CE3bFwLk.js";import{n as k,t as A}from"./jsx-runtime-wQxeESYQ.js";import{n as j}from"./utils-DC-bdPS3.js";import{t as M}from"./api-client-TUmacMRS.js";var N=k(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),P=k(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),F=k(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),I=k(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),L=e(t(),1),R=A(),ee=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),te=`VisuallyHidden`,z=L.forwardRef((e,t)=>(0,R.jsx)(n.span,{...e,ref:t,style:{...ee,...e.style}}));z.displayName=te;var B=z;function V(e){let t=L.useRef({value:e,previous:e});return L.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var H=`Label`,ne=L.forwardRef((e,t)=>(0,R.jsx)(n.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));ne.displayName=H;var re=ne;function ie(e,[t,n]){return Math.min(n,Math.max(t,e))}var ae=e(o(),1),oe=[` `,`Enter`,`ArrowUp`,`ArrowDown`],se=[` `,`Enter`],U=`Select`,[W,G,ce]=u(U),[K,le]=s(U,[ce,x]),q=x(),[ue,J]=K(U),[de,fe]=K(U),pe=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:u,dir:d,name:f,autoComplete:p,disabled:g,required:_,form:v}=e,y=q(t),[b,x]=L.useState(null),[S,C]=L.useState(null),[w,T]=L.useState(!1),E=h(d),[D,O]=c({prop:r,defaultProp:i??!1,onChange:a,caller:U}),[k,A]=c({prop:o,defaultProp:s,onChange:u,caller:U}),j=L.useRef(null),M=b?v||!!b.closest(`form`):!0,[N,P]=L.useState(new Set),F=Array.from(N).map(e=>e.props.value).join(`;`);return(0,R.jsx)(l,{...y,children:(0,R.jsxs)(ue,{required:_,scope:t,trigger:b,onTriggerChange:x,valueNode:S,onValueNodeChange:C,valueNodeHasChildren:w,onValueNodeHasChildrenChange:T,contentId:m(),value:k,onValueChange:A,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:j,disabled:g,children:[(0,R.jsx)(W.Provider,{scope:t,children:(0,R.jsx)(de,{scope:e.__scopeSelect,onNativeOptionAdd:L.useCallback(e=>{P(t=>new Set(t).add(e))},[]),onNativeOptionRemove:L.useCallback(e=>{P(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),M?(0,R.jsxs)(it,{"aria-hidden":!0,required:_,tabIndex:-1,name:f,autoComplete:p,value:k,onChange:e=>A(e.target.value),disabled:g,form:v,children:[k===void 0?(0,R.jsx)(`option`,{value:``}):null,Array.from(N)]},F):null]})})};pe.displayName=U;var me=`SelectTrigger`,he=L.forwardRef((e,t)=>{let{__scopeSelect:r,disabled:i=!1,...a}=e,o=q(r),s=J(me,r),c=s.disabled||i,l=_(t,s.onTriggerChange),u=G(r),d=L.useRef(`touch`),[f,p,m]=ot(e=>{let t=u().filter(e=>!e.disabled),n=st(t,e,t.find(e=>e.value===s.value));n!==void 0&&s.onValueChange(n.value)}),h=e=>{c||(s.onOpenChange(!0),m()),e&&(s.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,R.jsx)(b,{asChild:!0,...o,children:(0,R.jsx)(n.button,{type:`button`,role:`combobox`,"aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":`none`,dir:s.dir,"data-state":s.open?`open`:`closed`,disabled:c,"data-disabled":c?``:void 0,"data-placeholder":at(s.value)?``:void 0,...a,ref:l,onClick:O(a.onClick,e=>{e.currentTarget.focus(),d.current!==`mouse`&&h(e)}),onPointerDown:O(a.onPointerDown,e=>{d.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(h(e),e.preventDefault())}),onKeyDown:O(a.onKeyDown,e=>{let t=f.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&p(e.key),!(t&&e.key===` `)&&oe.includes(e.key)&&(h(),e.preventDefault())})})})});he.displayName=me;var ge=`SelectValue`,_e=L.forwardRef((e,t)=>{let{__scopeSelect:r,className:i,style:a,children:o,placeholder:s=``,...c}=e,l=J(ge,r),{onValueNodeHasChildrenChange:u}=l,d=o!==void 0,f=_(t,l.onValueNodeChange);return D(()=>{u(d)},[u,d]),(0,R.jsx)(n.span,{...c,ref:f,style:{pointerEvents:`none`},children:at(l.value)?(0,R.jsx)(R.Fragment,{children:s}):o})});_e.displayName=ge;var ve=`SelectIcon`,ye=L.forwardRef((e,t)=>{let{__scopeSelect:r,children:i,...a}=e;return(0,R.jsx)(n.span,{"aria-hidden":!0,...a,ref:t,children:i||`▼`})});ye.displayName=ve;var be=`SelectPortal`,xe=e=>(0,R.jsx)(f,{asChild:!0,...e});xe.displayName=be;var Y=`SelectContent`,Se=L.forwardRef((e,t)=>{let n=J(Y,e.__scopeSelect),[r,i]=L.useState();if(D(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?ae.createPortal((0,R.jsx)(Ce,{scope:e.__scopeSelect,children:(0,R.jsx)(W.Slot,{scope:e.__scopeSelect,children:(0,R.jsx)(`div`,{children:e.children})})}),t):null}return(0,R.jsx)(Ee,{...e,ref:t})});Se.displayName=Y;var X=10,[Ce,Z]=K(Y),we=`SelectContentImpl`,Te=r(`SelectContent.RemoveScroll`),Ee=L.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b,...x}=e,C=J(Y,n),[w,T]=L.useState(null),[D,k]=L.useState(null),A=_(t,e=>T(e)),[j,M]=L.useState(null),[N,P]=L.useState(null),F=G(n),[I,ee]=L.useState(!1),te=L.useRef(!1);L.useEffect(()=>{if(w)return d(w)},[w]),E();let z=L.useCallback(e=>{let[t,...n]=F().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&D&&(D.scrollTop=0),n===r&&D&&(D.scrollTop=D.scrollHeight),n?.focus(),document.activeElement!==i))return},[F,D]),B=L.useCallback(()=>z([j,w]),[z,j,w]);L.useEffect(()=>{I&&B()},[I,B]);let{onOpenChange:V,triggerPointerDownPosRef:H}=C;L.useEffect(()=>{if(w){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(H.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(H.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():w.contains(n.target)||V(!1),document.removeEventListener(`pointermove`,t),H.current=null};return H.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[w,V,H]),L.useEffect(()=>{let e=()=>V(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[V]);let[ne,re]=ot(e=>{let t=F().filter(e=>!e.disabled),n=st(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ie=L.useCallback((e,t,n)=>{let r=!te.current&&!n;(C.value!==void 0&&C.value===t||r)&&(M(e),r&&(te.current=!0))},[C.value]),ae=L.useCallback(()=>w?.focus(),[w]),oe=L.useCallback((e,t,n)=>{let r=!te.current&&!n;(C.value!==void 0&&C.value===t||r)&&P(e)},[C.value]),se=r===`popper`?Ae:Oe,U=se===Ae?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b}:{};return(0,R.jsx)(Ce,{scope:n,content:w,viewport:D,onViewportChange:k,itemRefCallback:ie,selectedItem:j,onItemLeave:ae,itemTextRefCallback:oe,focusSelectedItem:B,selectedItemText:N,position:r,isPositioned:I,searchRef:ne,children:(0,R.jsx)(v,{as:Te,allowPinchZoom:!0,children:(0,R.jsx)(p,{asChild:!0,trapped:C.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:O(i,e=>{C.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,R.jsx)(S,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:(0,R.jsx)(se,{role:`listbox`,id:C.contentId,"data-state":C.open?`open`:`closed`,dir:C.dir,onContextMenu:e=>e.preventDefault(),...x,...U,onPlaced:()=>ee(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...x.style},onKeyDown:O(x.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>z(t)),e.preventDefault()}})})})})})})});Ee.displayName=we;var De=`SelectItemAlignedPosition`,Oe=L.forwardRef((e,t)=>{let{__scopeSelect:r,onPlaced:i,...a}=e,o=J(Y,r),s=Z(Y,r),[c,l]=L.useState(null),[u,d]=L.useState(null),f=_(t,e=>d(e)),p=G(r),m=L.useRef(!1),h=L.useRef(!0),{viewport:g,selectedItem:v,selectedItemText:y,focusSelectedItem:b}=s,x=L.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&u&&g&&v&&y){let e=o.trigger.getBoundingClientRect(),t=u.getBoundingClientRect(),n=o.valueNode.getBoundingClientRect(),r=y.getBoundingClientRect();if(o.dir!==`rtl`){let i=r.left-t.left,a=n.left-i,o=e.left-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-X,d=ie(a,[X,Math.max(X,u-l)]);c.style.minWidth=s+`px`,c.style.left=d+`px`}else{let i=t.right-r.right,a=window.innerWidth-n.right-i,o=window.innerWidth-e.right-a,s=e.width+o,l=Math.max(s,t.width),u=window.innerWidth-X,d=ie(a,[X,Math.max(X,u-l)]);c.style.minWidth=s+`px`,c.style.right=d+`px`}let a=p(),s=window.innerHeight-X*2,l=g.scrollHeight,d=window.getComputedStyle(u),f=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),_=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=f+h+l+b+_,S=Math.min(v.offsetHeight*5,x),C=window.getComputedStyle(g),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-X,D=s-E,O=v.offsetHeight/2,k=v.offsetTop+O,A=f+h+k,j=x-A;if(A<=E){let e=a.length>0&&v===a[a.length-1].ref.current;c.style.bottom=`0px`;let t=u.clientHeight-g.offsetTop-g.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+_);c.style.height=n+`px`}else{let e=a.length>0&&v===a[0].ref.current;c.style.top=`0px`;let t=Math.max(E,f+g.offsetTop+(e?w:0)+O)+j;c.style.height=t+`px`,g.scrollTop=A-E+g.offsetTop}c.style.margin=`${X}px 0`,c.style.minHeight=S+`px`,c.style.maxHeight=s+`px`,i?.(),requestAnimationFrame(()=>m.current=!0)}},[p,o.trigger,o.valueNode,c,u,g,v,y,o.dir,i]);D(()=>x(),[x]);let[S,C]=L.useState();return D(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]),(0,R.jsx)(je,{scope:r,contentWrapper:c,shouldExpandOnScrollRef:m,onScrollButtonChange:L.useCallback(e=>{e&&h.current===!0&&(x(),b?.(),h.current=!1)},[x,b]),children:(0,R.jsx)(`div`,{ref:l,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:S},children:(0,R.jsx)(n.div,{...a,ref:f,style:{boxSizing:`border-box`,maxHeight:`100%`,...a.style}})})})});Oe.displayName=De;var ke=`SelectPopperPosition`,Ae=L.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=X,...a}=e,o=q(n);return(0,R.jsx)(g,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});Ae.displayName=ke;var[je,Me]=K(Y,{}),Ne=`SelectViewport`,Pe=L.forwardRef((e,t)=>{let{__scopeSelect:r,nonce:i,...a}=e,o=Z(Ne,r),s=Me(Ne,r),c=_(t,o.onViewportChange),l=L.useRef(0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:i}),(0,R.jsx)(W.Slot,{scope:r,children:(0,R.jsx)(n.div,{"data-radix-select-viewport":``,role:`presentation`,...a,ref:c,style:{position:`relative`,flex:1,overflow:`hidden auto`,...a.style},onScroll:O(a.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=s;if(r?.current&&n){let e=Math.abs(l.current-t.scrollTop);if(e>0){let r=window.innerHeight-X*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}l.current=t.scrollTop})})})]})});Pe.displayName=Ne;var Fe=`SelectGroup`,[Ie,Le]=K(Fe),Re=L.forwardRef((e,t)=>{let{__scopeSelect:r,...i}=e,a=m();return(0,R.jsx)(Ie,{scope:r,id:a,children:(0,R.jsx)(n.div,{role:`group`,"aria-labelledby":a,...i,ref:t})})});Re.displayName=Fe;var ze=`SelectLabel`,Be=L.forwardRef((e,t)=>{let{__scopeSelect:r,...i}=e,a=Le(ze,r);return(0,R.jsx)(n.div,{id:a.id,...i,ref:t})});Be.displayName=ze;var Ve=`SelectItem`,[He,Ue]=K(Ve),We=L.forwardRef((e,t)=>{let{__scopeSelect:r,value:i,disabled:a=!1,textValue:o,...s}=e,c=J(Ve,r),l=Z(Ve,r),u=c.value===i,[d,f]=L.useState(o??``),[p,h]=L.useState(!1),g=_(t,e=>l.itemRefCallback?.(e,i,a)),v=m(),y=L.useRef(`touch`),b=()=>{a||(c.onValueChange(i),c.onOpenChange(!1))};if(i===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,R.jsx)(He,{scope:r,value:i,disabled:a,textId:v,isSelected:u,onItemTextChange:L.useCallback(e=>{f(t=>t||(e?.textContent??``).trim())},[]),children:(0,R.jsx)(W.ItemSlot,{scope:r,value:i,disabled:a,textValue:d,children:(0,R.jsx)(n.div,{role:`option`,"aria-labelledby":v,"data-highlighted":p?``:void 0,"aria-selected":u&&p,"data-state":u?`checked`:`unchecked`,"aria-disabled":a||void 0,"data-disabled":a?``:void 0,tabIndex:a?void 0:-1,...s,ref:g,onFocus:O(s.onFocus,()=>h(!0)),onBlur:O(s.onBlur,()=>h(!1)),onClick:O(s.onClick,()=>{y.current!==`mouse`&&b()}),onPointerUp:O(s.onPointerUp,()=>{y.current===`mouse`&&b()}),onPointerDown:O(s.onPointerDown,e=>{y.current=e.pointerType}),onPointerMove:O(s.onPointerMove,e=>{y.current=e.pointerType,a?l.onItemLeave?.():y.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:O(s.onPointerLeave,e=>{e.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:O(s.onKeyDown,e=>{l.searchRef?.current!==``&&e.key===` `||(se.includes(e.key)&&b(),e.key===` `&&e.preventDefault())})})})})});We.displayName=Ve;var Q=`SelectItemText`,Ge=L.forwardRef((e,t)=>{let{__scopeSelect:r,className:i,style:a,...o}=e,s=J(Q,r),c=Z(Q,r),l=Ue(Q,r),u=fe(Q,r),[d,f]=L.useState(null),p=_(t,e=>f(e),l.onItemTextChange,e=>c.itemTextRefCallback?.(e,l.value,l.disabled)),m=d?.textContent,h=L.useMemo(()=>(0,R.jsx)(`option`,{value:l.value,disabled:l.disabled,children:m},l.value),[l.disabled,l.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:v}=u;return D(()=>(g(h),()=>v(h)),[g,v,h]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(n.span,{id:l.textId,...o,ref:p}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?ae.createPortal(o.children,s.valueNode):null]})});Ge.displayName=Q;var Ke=`SelectItemIndicator`,qe=L.forwardRef((e,t)=>{let{__scopeSelect:r,...i}=e;return Ue(Ke,r).isSelected?(0,R.jsx)(n.span,{"aria-hidden":!0,...i,ref:t}):null});qe.displayName=Ke;var Je=`SelectScrollUpButton`,Ye=L.forwardRef((e,t)=>{let n=Z(Je,e.__scopeSelect),r=Me(Je,e.__scopeSelect),[i,a]=L.useState(!1),o=_(t,r.onScrollButtonChange);return D(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(Qe,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Ye.displayName=Je;var Xe=`SelectScrollDownButton`,Ze=L.forwardRef((e,t)=>{let n=Z(Xe,e.__scopeSelect),r=Me(Xe,e.__scopeSelect),[i,a]=L.useState(!1),o=_(t,r.onScrollButtonChange);return D(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(Qe,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Ze.displayName=Xe;var Qe=L.forwardRef((e,t)=>{let{__scopeSelect:r,onAutoScroll:i,...a}=e,o=Z(`SelectScrollButton`,r),s=L.useRef(null),c=G(r),l=L.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return L.useEffect(()=>()=>l(),[l]),D(()=>{c().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[c]),(0,R.jsx)(n.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:O(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(i,50))}),onPointerMove:O(a.onPointerMove,()=>{o.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(i,50))}),onPointerLeave:O(a.onPointerLeave,()=>{l()})})}),$e=`SelectSeparator`,et=L.forwardRef((e,t)=>{let{__scopeSelect:r,...i}=e;return(0,R.jsx)(n.div,{"aria-hidden":!0,...i,ref:t})});et.displayName=$e;var tt=`SelectArrow`,nt=L.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=q(n),a=J(tt,n),o=Z(tt,n);return a.open&&o.position===`popper`?(0,R.jsx)(C,{...i,...r,ref:t}):null});nt.displayName=tt;var rt=`SelectBubbleInput`,it=L.forwardRef(({__scopeSelect:e,value:t,...r},i)=>{let a=L.useRef(null),o=_(i,a),s=V(t);return L.useEffect(()=>{let e=a.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(s!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[s,t]),(0,R.jsx)(n.select,{...r,style:{...ee,...r.style},ref:o,defaultValue:t})});it.displayName=rt;function at(e){return e===``||e===void 0}function ot(e){let t=y(e),n=L.useRef(``),r=L.useRef(0),i=L.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=L.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return L.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function st(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ct(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ct(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var lt=pe,ut=he,dt=_e,ft=ye,pt=xe,mt=Se,ht=Pe,gt=We,_t=Ge,vt=qe,yt=Ye,bt=Ze,xt=`Switch`,[St,Ct]=s(xt),[wt,Tt]=St(xt),Et=L.forwardRef((e,t)=>{let{__scopeSwitch:r,name:i,checked:a,defaultChecked:o,required:s,disabled:l,value:u=`on`,onCheckedChange:d,form:f,...p}=e,[m,h]=L.useState(null),g=_(t,e=>h(e)),v=L.useRef(!1),y=m?f||!!m.closest(`form`):!0,[b,x]=c({prop:a,defaultProp:o??!1,onChange:d,caller:xt});return(0,R.jsxs)(wt,{scope:r,checked:b,disabled:l,children:[(0,R.jsx)(n.button,{type:`button`,role:`switch`,"aria-checked":b,"aria-required":s,"data-state":jt(b),"data-disabled":l?``:void 0,disabled:l,value:u,...p,ref:g,onClick:O(e.onClick,e=>{x(e=>!e),y&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})}),y&&(0,R.jsx)(At,{control:m,bubbles:!v.current,name:i,value:u,checked:b,required:s,disabled:l,form:f,style:{transform:`translateX(-100%)`}})]})});Et.displayName=xt;var Dt=`SwitchThumb`,Ot=L.forwardRef((e,t)=>{let{__scopeSwitch:r,...i}=e,a=Tt(Dt,r);return(0,R.jsx)(n.span,{"data-state":jt(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t})});Ot.displayName=Dt;var kt=`SwitchBubbleInput`,At=L.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=L.useRef(null),s=_(o,a),c=V(n),l=w(t);return L.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,R.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});At.displayName=kt;function jt(e){return e?`checked`:`unchecked`}var Mt=Et,Nt=Ot;function $({className:e,...t}){return(0,R.jsx)(re,{"data-slot":`label`,className:j(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function Pt({...e}){return(0,R.jsx)(lt,{"data-slot":`select`,...e})}function Ft({...e}){return(0,R.jsx)(dt,{"data-slot":`select-value`,...e})}function It({className:e,size:t=`default`,children:n,...r}){return(0,R.jsxs)(ut,{"data-slot":`select-trigger`,"data-size":t,className:j(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,R.jsx)(ft,{asChild:!0,children:(0,R.jsx)(i,{className:`size-4 opacity-50`})})]})}function Lt({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,R.jsx)(pt,{children:(0,R.jsxs)(mt,{"data-slot":`select-content`,className:j(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,R.jsx)(zt,{}),(0,R.jsx)(ht,{className:j(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,R.jsx)(Bt,{})]})})}function Rt({className:e,children:t,...n}){return(0,R.jsxs)(gt,{"data-slot":`select-item`,className:j(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,R.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,R.jsx)(vt,{children:(0,R.jsx)(a,{className:`size-4`})})}),(0,R.jsx)(_t,{children:t})]})}function zt({className:e,...t}){return(0,R.jsx)(yt,{"data-slot":`select-scroll-up-button`,className:j(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(P,{className:`size-4`})})}function Bt({className:e,...t}){return(0,R.jsx)(bt,{"data-slot":`select-scroll-down-button`,className:j(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(i,{className:`size-4`})})}function Vt(){return M.get(`/api/accounts`)}function Ht(){return M.get(`/api/accounts/active`)}function Ut(e){return M.post(`/api/accounts`,e)}function Wt(e){return M.del(`/api/accounts/${e}`)}function Gt(e,t){return M.patch(`/api/accounts/${e}`,t)}function Kt(){return M.get(`/api/accounts/settings`)}function qt(e){return M.put(`/api/accounts/settings`,e)}function Jt(e){return M.post(`/api/accounts/${e}/verify`)}function Yt(){return M.get(`/api/accounts/oauth/url`)}function Xt(e,t){return M.post(`/api/accounts/oauth/exchange`,{code:e,state:t})}function Zt(){return M.get(`/api/accounts/usage`)}function Qt(e){return M.post(`/api/accounts/import`,e)}function $t(){return M.get(`/api/settings/ai`)}function en(e){return M.put(`/api/settings/ai`,e)}var tn=[{value:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`},{value:`claude-opus-4-6`,label:`Claude Opus 4.6`},{value:`claude-haiku-4-5`,label:`Claude Haiku 4.5`}],nn=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}],rn=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}];function an({compact:e}={}){let[t,n]=(0,L.useState)(null),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(0);(0,L.useEffect)(()=>{$t().then(n).catch(e=>o(e.message))},[]);let l=t?.default_provider??`claude`,u=t?.providers[l],d=async(e,r)=>{if(t){i(!0),o(null);try{n(await en({providers:{[l]:{[e]:r}}})),c(e=>e+1)}catch(e){o(e.message)}finally{i(!1)}}},f=e?`text-[11px]`:`text-sm`,p=e?`text-xs`:`text-sm`,m=e?`space-y-2`:`space-y-4`,h=e?`space-y-1.5`:`space-y-3`,g=e?`space-y-1`:`space-y-1.5`;return t?(0,R.jsxs)(`div`,{className:m,children:[(0,R.jsx)(`h3`,{className:`${p} font-medium text-text-secondary`,children:`AI Provider`}),(0,R.jsxs)(`div`,{className:h,children:[(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-model`,className:e?f:void 0,children:`Model`}),(0,R.jsxs)(Pt,{value:u?.model??`claude-sonnet-4-6`,onValueChange:e=>d(`model`,e),children:[(0,R.jsx)(It,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,R.jsx)(Ft,{})}),(0,R.jsx)(Lt,{children:tn.map(e=>(0,R.jsx)(Rt,{value:e.value,children:e.label},e.value))})]})]}),(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-base-url`,className:e?f:void 0,children:`Base URL`}),(0,R.jsx)(T,{id:`ai-base-url`,type:`url`,defaultValue:u?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{d(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${s}`)]}),(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-effort`,className:e?f:void 0,children:`Effort`}),(0,R.jsxs)(Pt,{value:u?.effort??`high`,onValueChange:e=>d(`effort`,e),children:[(0,R.jsx)(It,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,R.jsx)(Ft,{})}),(0,R.jsx)(Lt,{children:nn.map(e=>(0,R.jsx)(Rt,{value:e.value,children:e.label},e.value))})]})]}),(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-max-turns`,className:e?f:void 0,children:`Max Turns (1-500)`}),(0,R.jsx)(T,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:u?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||d(`max_turns`,t)}},`turns-${s}`)]}),(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-budget`,className:e?f:void 0,children:`Max Budget (USD)`}),(0,R.jsx)(T,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:u?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);d(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${s}`)]}),(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-thinking`,className:e?f:void 0,children:`Thinking Budget (tokens)`}),(0,R.jsx)(T,{id:`ai-thinking`,type:`number`,min:0,defaultValue:u?.thinking_budget_tokens??``,placeholder:`Disabled`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);d(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${s}`)]}),(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-permission-mode`,className:e?f:void 0,children:`Default Permission Mode`}),(0,R.jsxs)(Pt,{value:u?.permission_mode??`bypassPermissions`,onValueChange:e=>d(`permission_mode`,e),children:[(0,R.jsx)(It,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,R.jsx)(Ft,{})}),(0,R.jsx)(Lt,{children:rn.map(e=>(0,R.jsx)(Rt,{value:e.value,children:e.label},e.value))})]})]}),(0,R.jsxs)(`div`,{className:g,children:[(0,R.jsx)($,{htmlFor:`ai-system-prompt`,className:e?f:void 0,children:`Additional Instructions`}),(0,R.jsx)(`textarea`,{id:`ai-system-prompt`,rows:4,defaultValue:u?.system_prompt??``,placeholder:`Enter additional instructions for Claude...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{d(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${s}`)]})]}),r&&(0,R.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),a&&(0,R.jsx)(`p`,{className:`text-xs text-red-500`,children:a})]}):(0,R.jsxs)(`div`,{className:h,children:[(0,R.jsx)(`h3`,{className:`${p} font-medium text-text-secondary`,children:`AI Provider`}),(0,R.jsx)(`p`,{className:`${f} text-text-subtle`,children:a?`Error: ${a}`:`Loading...`})]})}var on=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Mt,{className:j(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,ref:n,children:(0,R.jsx)(Nt,{className:j(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));on.displayName=Mt.displayName;export{B as C,N as D,P as E,ie as S,F as T,Lt as _,Xt as a,Ft as b,Vt as c,Yt as d,Qt as f,Pt as g,Jt as h,Wt as i,Ht as l,qt as m,an as n,$t as o,Gt as p,Ut as r,Kt as s,on as t,Zt as u,Rt as v,I as w,$ as x,It as y};
@@ -1,4 +1,4 @@
1
- import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{n as r}from"./settings-store-2NQzaOVJ.js";import{n as i}from"./utils-DC-bdPS3.js";import{R as a,z as o}from"./index-BGTzm7B1.js";var s=e(t(),1),c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{for(var i=r>1?void 0:r?l(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&c(t,n,i),i},f=(e,t)=>(n,r)=>t(n,r,e),p=`Terminal input`,m={get:()=>p,set:e=>p=e},h=`Too much output to announce, navigate to rows manually to read`,g={get:()=>h,set:e=>h=e};function _(e){return e.replace(/\r?\n/g,`\r`)}function v(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ee(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function te(e,t,n,r){e.stopPropagation(),e.clipboardData&&ne(e.clipboardData.getData(`text/plain`),t,n,r)}function ne(e,t,n,r){e=_(e),e=v(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function re(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ie(e,t,n,r,i){re(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function y(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ae(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var oe=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},b=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},se=``,ce=` `,le=class e{constructor(){this.fg=0,this.bg=0,this.extended=new x}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},x=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},S=class e extends le{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new x,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?y(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ue=`di$target`,de=`di$dependencies`,C=new Map;function fe(e){return e[de]||[]}function w(e){if(C.has(e))return C.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);pe(t,e,r)};return t._id=e,C.set(e,t),t}function pe(e,t,n){t[ue]===t?t[de].push({id:e,index:n}):(t[de]=[{id:e,index:n}],t[ue]=t)}var T=w(`BufferService`),me=w(`CoreMouseService`),E=w(`CoreService`),he=w(`CharsetService`),ge=w(`InstantiationService`),_e=w(`LogService`),D=w(`OptionsService`),ve=w(`OscLinkService`),ye=w(`UnicodeService`),be=w(`DecorationService`),xe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new S,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+(!l&&t===o-1?1:0),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Se(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};xe=d([f(0,T),f(1,D),f(2,ve)],xe);function Se(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{i as e,t}from"./react-CYzKIDNi.js";import{t as n}from"./jsx-runtime-wQxeESYQ.js";import{n as r}from"./settings-store-2NQzaOVJ.js";import{n as i}from"./utils-DC-bdPS3.js";import{R as a,z as o}from"./index-BjNob0pC.js";var s=e(t(),1),c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{for(var i=r>1?void 0:r?l(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&c(t,n,i),i},f=(e,t)=>(n,r)=>t(n,r,e),p=`Terminal input`,m={get:()=>p,set:e=>p=e},h=`Too much output to announce, navigate to rows manually to read`,g={get:()=>h,set:e=>h=e};function _(e){return e.replace(/\r?\n/g,`\r`)}function v(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ee(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function te(e,t,n,r){e.stopPropagation(),e.clipboardData&&ne(e.clipboardData.getData(`text/plain`),t,n,r)}function ne(e,t,n,r){e=_(e),e=v(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function re(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ie(e,t,n,r,i){re(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function y(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ae(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var oe=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},b=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},se=``,ce=` `,le=class e{constructor(){this.fg=0,this.bg=0,this.extended=new x}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},x=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},S=class e extends le{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new x,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?y(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ue=`di$target`,de=`di$dependencies`,C=new Map;function fe(e){return e[de]||[]}function w(e){if(C.has(e))return C.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);pe(t,e,r)};return t._id=e,C.set(e,t),t}function pe(e,t,n){t[ue]===t?t[de].push({id:e,index:n}):(t[de]=[{id:e,index:n}],t[ue]=t)}var T=w(`BufferService`),me=w(`CoreMouseService`),E=w(`CoreService`),he=w(`CharsetService`),ge=w(`InstantiationService`),_e=w(`LogService`),D=w(`OptionsService`),ve=w(`OscLinkService`),ye=w(`UnicodeService`),be=w(`DecorationService`),xe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new S,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+(!l&&t===o-1?1:0),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Se(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};xe=d([f(0,T),f(1,D),f(2,ve)],xe);function Se(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ce=w(`CharSizeService`),we=w(`CoreBrowserService`),Te=w(`MouseService`),Ee=w(`RenderService`),De=w(`SelectionService`),Oe=w(`CharacterJoinerService`),ke=w(`ThemeService`),Ae=w(`LinkProviderService`),je=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Le.isErrorNoTelemetry(e)?new Le(e.message+`
4
4
 
@@ -39,13 +39,13 @@
39
39
  <link rel="preconnect" href="https://fonts.googleapis.com" />
40
40
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
41
41
  <link href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600;700&family=Geist:wght@400;500;600;700&display=swap" rel="stylesheet" />
42
- <script type="module" crossorigin src="/assets/index-BGTzm7B1.js"></script>
42
+ <script type="module" crossorigin src="/assets/index-BjNob0pC.js"></script>
43
43
  <link rel="modulepreload" crossorigin href="/assets/react-CYzKIDNi.js">
44
44
  <link rel="modulepreload" crossorigin href="/assets/utils-DC-bdPS3.js">
45
45
  <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-wQxeESYQ.js">
46
46
  <link rel="modulepreload" crossorigin href="/assets/input-CE3bFwLk.js">
47
47
  <link rel="modulepreload" crossorigin href="/assets/api-client-TUmacMRS.js">
48
- <link rel="modulepreload" crossorigin href="/assets/switch-BEmt1alu.js">
48
+ <link rel="modulepreload" crossorigin href="/assets/switch-D0FJQVBN.js">
49
49
  <link rel="modulepreload" crossorigin href="/assets/react-rgzL83kk.js">
50
50
  <link rel="modulepreload" crossorigin href="/assets/tab-store-0CKk8cSr.js">
51
51
  <link rel="modulepreload" crossorigin href="/assets/settings-store-2NQzaOVJ.js">
package/dist/web/sw.js CHANGED
@@ -1 +1 @@
1
- try{self[`workbox:core:7.3.0`]&&_()}catch{}var e=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n},t=class extends Error{constructor(t,n){let r=e(t,n);super(r),this.name=t,this.details=n}},n={googleAnalytics:`googleAnalytics`,precache:`precache-v2`,prefix:`workbox`,runtime:`runtime`,suffix:typeof registration<`u`?registration.scope:``},r=e=>[n.prefix,e,n.suffix].filter(e=>e&&e.length>0).join(`-`),i=e=>{for(let t of Object.keys(n))e(t)},a={updateDetails:e=>{i(t=>{typeof e[t]==`string`&&(n[t]=e[t])})},getGoogleAnalyticsName:e=>e||r(n.googleAnalytics),getPrecacheName:e=>e||r(n.precache),getPrefix:()=>n.prefix,getRuntimeName:e=>e||r(n.runtime),getSuffix:()=>n.suffix};function o(e,t){let n=t();return e.waitUntil(n),n}try{self[`workbox:precaching:7.3.0`]&&_()}catch{}var s=`__WB_REVISION__`;function c(e){if(!e)throw new t(`add-to-cache-list-unexpected-type`,{entry:e});if(typeof e==`string`){let t=new URL(e,location.href);return{cacheKey:t.href,url:t.href}}let{revision:n,url:r}=e;if(!r)throw new t(`add-to-cache-list-unexpected-type`,{entry:e});if(!n){let e=new URL(r,location.href);return{cacheKey:e.href,url:e.href}}let i=new URL(r,location.href),a=new URL(r,location.href);return i.searchParams.set(s,n),{cacheKey:i.href,url:a.href}}var l=class{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:e,state:t})=>{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:n})=>{if(e.type===`install`&&t&&t.originalRequest&&t.originalRequest instanceof Request){let e=t.originalRequest.url;n?this.notUpdatedURLs.push(e):this.updatedURLs.push(e)}return n}}},u=class{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:e,params:t})=>{let n=t?.cacheKey||this._precacheController.getCacheKeyForURL(e.url);return n?new Request(n,{headers:e.headers}):e},this._precacheController=e}},d;function f(){if(d===void 0){let e=new Response(``);if(`body`in e)try{new Response(e.body),d=!0}catch{d=!1}d=!1}return d}async function p(e,n){let r=null;if(e.url&&(r=new URL(e.url).origin),r!==self.location.origin)throw new t(`cross-origin-copy-response`,{origin:r});let i=e.clone(),a={headers:new Headers(i.headers),status:i.status,statusText:i.statusText},o=n?n(a):a,s=f()?i.body:await i.blob();return new Response(s,o)}var m=e=>new URL(String(e),location.href).href.replace(RegExp(`^${location.origin}`),``);function h(e,t){let n=new URL(e);for(let e of t)n.searchParams.delete(e);return n.href}async function g(e,t,n,r){let i=h(t.url,n);if(t.url===i)return e.match(t,r);let a=Object.assign(Object.assign({},r),{ignoreSearch:!0}),o=await e.keys(t,a);for(let t of o)if(i===h(t.url,n))return e.match(t,r)}var v=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}},y=new Set;async function b(){for(let e of y)await e()}function x(e){return new Promise(t=>setTimeout(t,e))}try{self[`workbox:strategies:7.3.0`]&&_()}catch{}function S(e){return typeof e==`string`?new Request(e):e}var C=class{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new v,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(let e of this._plugins)this._pluginStateMap.set(e,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){let{event:n}=this,r=S(e);if(r.mode===`navigate`&&n instanceof FetchEvent&&n.preloadResponse){let e=await n.preloadResponse;if(e)return e}let i=this.hasCallback(`fetchDidFail`)?r.clone():null;try{for(let e of this.iterateCallbacks(`requestWillFetch`))r=await e({request:r.clone(),event:n})}catch(e){if(e instanceof Error)throw new t(`plugin-error-request-will-fetch`,{thrownErrorMessage:e.message})}let a=r.clone();try{let e;e=await fetch(r,r.mode===`navigate`?void 0:this._strategy.fetchOptions);for(let t of this.iterateCallbacks(`fetchDidSucceed`))e=await t({event:n,request:a,response:e});return e}catch(e){throw i&&await this.runCallbacks(`fetchDidFail`,{error:e,event:n,originalRequest:i.clone(),request:a.clone()}),e}}async fetchAndCachePut(e){let t=await this.fetch(e),n=t.clone();return this.waitUntil(this.cachePut(e,n)),t}async cacheMatch(e){let t=S(e),n,{cacheName:r,matchOptions:i}=this._strategy,a=await this.getCacheKey(t,`read`),o=Object.assign(Object.assign({},i),{cacheName:r});n=await caches.match(a,o);for(let e of this.iterateCallbacks(`cachedResponseWillBeUsed`))n=await e({cacheName:r,matchOptions:i,cachedResponse:n,request:a,event:this.event})||void 0;return n}async cachePut(e,n){let r=S(e);await x(0);let i=await this.getCacheKey(r,`write`);if(!n)throw new t(`cache-put-with-no-response`,{url:m(i.url)});let a=await this._ensureResponseSafeToCache(n);if(!a)return!1;let{cacheName:o,matchOptions:s}=this._strategy,c=await self.caches.open(o),l=this.hasCallback(`cacheDidUpdate`),u=l?await g(c,i.clone(),[`__WB_REVISION__`],s):null;try{await c.put(i,l?a.clone():a)}catch(e){if(e instanceof Error)throw e.name===`QuotaExceededError`&&await b(),e}for(let e of this.iterateCallbacks(`cacheDidUpdate`))await e({cacheName:o,oldResponse:u,newResponse:a.clone(),request:i,event:this.event});return!0}async getCacheKey(e,t){let n=`${e.url} | ${t}`;if(!this._cacheKeys[n]){let r=e;for(let e of this.iterateCallbacks(`cacheKeyWillBeUsed`))r=S(await e({mode:t,request:r,event:this.event,params:this.params}));this._cacheKeys[n]=r}return this._cacheKeys[n]}hasCallback(e){for(let t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(let n of this.iterateCallbacks(e))await n(t)}*iterateCallbacks(e){for(let t of this._strategy.plugins)if(typeof t[e]==`function`){let n=this._pluginStateMap.get(t);yield r=>{let i=Object.assign(Object.assign({},r),{state:n});return t[e](i)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){for(;this._extendLifetimePromises.length;){let e=this._extendLifetimePromises.splice(0),t=(await Promise.allSettled(e)).find(e=>e.status===`rejected`);if(t)throw t.reason}}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,n=!1;for(let e of this.iterateCallbacks(`cacheWillUpdate`))if(t=await e({request:this.request,response:t,event:this.event})||void 0,n=!0,!t)break;return n||t&&t.status!==200&&(t=void 0),t}},w=class{constructor(e={}){this.cacheName=a.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){let[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});let t=e.event,n=typeof e.request==`string`?new Request(e.request):e.request,r=`params`in e?e.params:void 0,i=new C(this,{event:t,request:n,params:r}),a=this._getResponse(i,n,t);return[a,this._awaitComplete(a,i,n,t)]}async _getResponse(e,n,r){await e.runCallbacks(`handlerWillStart`,{event:r,request:n});let i;try{if(i=await this._handle(n,e),!i||i.type===`error`)throw new t(`no-response`,{url:n.url})}catch(t){if(t instanceof Error){for(let a of e.iterateCallbacks(`handlerDidError`))if(i=await a({error:t,event:r,request:n}),i)break}if(!i)throw t}for(let t of e.iterateCallbacks(`handlerWillRespond`))i=await t({event:r,request:n,response:i});return i}async _awaitComplete(e,t,n,r){let i,a;try{i=await e}catch{}try{await t.runCallbacks(`handlerDidRespond`,{event:r,request:n,response:i}),await t.doneWaiting()}catch(e){e instanceof Error&&(a=e)}if(await t.runCallbacks(`handlerDidComplete`,{event:r,request:n,response:i,error:a}),t.destroy(),a)throw a}},T=class e extends w{constructor(t={}){t.cacheName=a.getPrecacheName(t.cacheName),super(t),this._fallbackToNetwork=t.fallbackToNetwork!==!1,this.plugins.push(e.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){return await t.cacheMatch(e)||(t.event&&t.event.type===`install`?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,n){let r,i=n.params||{};if(this._fallbackToNetwork){let t=i.integrity,a=e.integrity,o=!a||a===t;r=await n.fetch(new Request(e,{integrity:e.mode===`no-cors`?void 0:a||t})),t&&o&&e.mode!==`no-cors`&&(this._useDefaultCacheabilityPluginIfNeeded(),await n.cachePut(e,r.clone()))}else throw new t(`missing-precache-entry`,{cacheName:this.cacheName,url:e.url});return r}async _handleInstall(e,n){this._useDefaultCacheabilityPluginIfNeeded();let r=await n.fetch(e);if(!await n.cachePut(e,r.clone()))throw new t(`bad-precaching-response`,{url:e.url,status:r.status});return r}_useDefaultCacheabilityPluginIfNeeded(){let t=null,n=0;for(let[r,i]of this.plugins.entries())i!==e.copyRedirectedCacheableResponsesPlugin&&(i===e.defaultPrecacheCacheabilityPlugin&&(t=r),i.cacheWillUpdate&&n++);n===0?this.plugins.push(e.defaultPrecacheCacheabilityPlugin):n>1&&t!==null&&this.plugins.splice(t,1)}};T.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:e}){return!e||e.status>=400?null:e}},T.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:e}){return e.redirected?await p(e):e}};var E=class{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:n=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new T({cacheName:a.getPrecacheName(e),plugins:[...t,new u({precacheController:this})],fallbackToNetwork:n}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||=(self.addEventListener(`install`,this.install),self.addEventListener(`activate`,this.activate),!0)}addToCacheList(e){let n=[];for(let r of e){typeof r==`string`?n.push(r):r&&r.revision===void 0&&n.push(r.url);let{cacheKey:e,url:i}=c(r),a=typeof r!=`string`&&r.revision?`reload`:`default`;if(this._urlsToCacheKeys.has(i)&&this._urlsToCacheKeys.get(i)!==e)throw new t(`add-to-cache-list-conflicting-entries`,{firstEntry:this._urlsToCacheKeys.get(i),secondEntry:e});if(typeof r!=`string`&&r.integrity){if(this._cacheKeysToIntegrities.has(e)&&this._cacheKeysToIntegrities.get(e)!==r.integrity)throw new t(`add-to-cache-list-conflicting-integrities`,{url:i});this._cacheKeysToIntegrities.set(e,r.integrity)}if(this._urlsToCacheKeys.set(i,e),this._urlsToCacheModes.set(i,a),n.length>0){let e=`Workbox is precaching URLs without revision info: ${n.join(`, `)}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(e)}}}install(e){return o(e,async()=>{let t=new l;this.strategy.plugins.push(t);for(let[t,n]of this._urlsToCacheKeys){let r=this._cacheKeysToIntegrities.get(n),i=this._urlsToCacheModes.get(t),a=new Request(t,{integrity:r,cache:i,credentials:`same-origin`});await Promise.all(this.strategy.handleAll({params:{cacheKey:n},request:a,event:e}))}let{updatedURLs:n,notUpdatedURLs:r}=t;return{updatedURLs:n,notUpdatedURLs:r}})}activate(e){return o(e,async()=>{let e=await self.caches.open(this.strategy.cacheName),t=await e.keys(),n=new Set(this._urlsToCacheKeys.values()),r=[];for(let i of t)n.has(i.url)||(await e.delete(i),r.push(i.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){let t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){let t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n)return(await self.caches.open(this.strategy.cacheName)).match(n)}createHandlerBoundToURL(e){let n=this.getCacheKeyForURL(e);if(!n)throw new t(`non-precached-url`,{url:e});return t=>(t.request=new Request(e),t.params=Object.assign({cacheKey:n},t.params),this.strategy.handle(t))}},D,O=()=>(D||=new E,D);try{self[`workbox:routing:7.3.0`]&&_()}catch{}var k=e=>e&&typeof e==`object`?e:{handle:e},A=class{constructor(e,t,n=`GET`){this.handler=k(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=k(e)}},j=class extends A{constructor(e,t,n){super(({url:t})=>{let n=e.exec(t.href);if(n&&!(t.origin!==location.origin&&n.index!==0))return n.slice(1)},t,n)}},M=class{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener(`fetch`,(e=>{let{request:t}=e,n=this.handleRequest({request:t,event:e});n&&e.respondWith(n)}))}addCacheListener(){self.addEventListener(`message`,(e=>{if(e.data&&e.data.type===`CACHE_URLS`){let{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(t=>{typeof t==`string`&&(t=[t]);let n=new Request(...t);return this.handleRequest({request:n,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){let n=new URL(e.url,location.href);if(!n.protocol.startsWith(`http`))return;let r=n.origin===location.origin,{params:i,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:r,url:n}),o=a&&a.handler,s=e.method;if(!o&&this._defaultHandlerMap.has(s)&&(o=this._defaultHandlerMap.get(s)),!o)return;let c;try{c=o.handle({url:n,request:e,event:t,params:i})}catch(e){c=Promise.reject(e)}let l=a&&a.catchHandler;return c instanceof Promise&&(this._catchHandler||l)&&(c=c.catch(async r=>{if(l)try{return await l.handle({url:n,request:e,event:t,params:i})}catch(e){e instanceof Error&&(r=e)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw r})),c}findMatchingRoute({url:e,sameOrigin:t,request:n,event:r}){let i=this._routes.get(n.method)||[];for(let a of i){let i,o=a.match({url:e,sameOrigin:t,request:n,event:r});if(o)return i=o,(Array.isArray(i)&&i.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o==`boolean`)&&(i=void 0),{route:a,params:i}}return{}}setDefaultHandler(e,t=`GET`){this._defaultHandlerMap.set(t,k(e))}setCatchHandler(e){this._catchHandler=k(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new t(`unregister-route-but-not-found-with-method`,{method:e.method});let n=this._routes.get(e.method).indexOf(e);if(n>-1)this._routes.get(e.method).splice(n,1);else throw new t(`unregister-route-route-not-registered`)}},N,P=()=>(N||(N=new M,N.addFetchListener(),N.addCacheListener()),N);function F(e,n,r){let i;if(typeof e==`string`){let t=new URL(e,location.href);i=new A(({url:e})=>e.href===t.href,n,r)}else if(e instanceof RegExp)i=new j(e,n,r);else if(typeof e==`function`)i=new A(e,n,r);else if(e instanceof A)i=e;else throw new t(`unsupported-route-type`,{moduleName:`workbox-routing`,funcName:`registerRoute`,paramName:`capture`});return P().registerRoute(i),i}function I(e,t=[]){for(let n of[...e.searchParams.keys()])t.some(e=>e.test(n))&&e.searchParams.delete(n);return e}function*L(e,{ignoreURLParametersMatching:t=[/^utm_/,/^fbclid$/],directoryIndex:n=`index.html`,cleanURLs:r=!0,urlManipulation:i}={}){let a=new URL(e,location.href);a.hash=``,yield a.href;let o=I(a,t);if(yield o.href,n&&o.pathname.endsWith(`/`)){let e=new URL(o.href);e.pathname+=n,yield e.href}if(r){let e=new URL(o.href);e.pathname+=`.html`,yield e.href}if(i){let e=i({url:a});for(let t of e)yield t.href}}var R=class extends A{constructor(e,t){super(({request:n})=>{let r=e.getURLsToCacheKeys();for(let i of L(n.url,t)){let t=r.get(i);if(t)return{cacheKey:t,integrity:e.getIntegrityForCacheKey(t)}}},e.strategy)}};function z(e){F(new R(O(),e))}function B(e){O().precache(e)}function V(e,t){B(e),z(t)}V([{"revision":"1872c500de691dce40960bb85481de07","url":"registerSW.js"},{"revision":"9d5d14c0ffc405778815293d64b16647","url":"index.html"},{"revision":"a0fb34fc84eb148d51812cd62669f20d","url":"icon-512.svg"},{"revision":"a0fb34fc84eb148d51812cd62669f20d","url":"icon-192.svg"},{"revision":"eb9818b9094675c0c5d303168f273345","url":"monacoeditorwork/ts.worker.bundle.js"},{"revision":"9af0be92dcefdc1f1290441cb5ff5d9b","url":"monacoeditorwork/json.worker.bundle.js"},{"revision":"a261b429c39dbb75ae97972d7d005e6d","url":"monacoeditorwork/html.worker.bundle.js"},{"revision":"79953d804e1bbacecfd79b85fd679016","url":"monacoeditorwork/editor.worker.bundle.js"},{"revision":"fdcba0d09aac31df7a0bc652f6e739bd","url":"monacoeditorwork/css.worker.bundle.js"},{"revision":null,"url":"assets/utils-DC-bdPS3.js"},{"revision":null,"url":"assets/use-monaco-theme-Bt1Lr3jH.js"},{"revision":null,"url":"assets/terminal-tab-BrP-ENHg.css"},{"revision":null,"url":"assets/terminal-tab-BiUqECPk.js"},{"revision":null,"url":"assets/table-C0oSLUYn.js"},{"revision":null,"url":"assets/tab-store-0CKk8cSr.js"},{"revision":null,"url":"assets/switch-BEmt1alu.js"},{"revision":null,"url":"assets/sqlite-viewer-BY242odW.js"},{"revision":null,"url":"assets/settings-tab-BZqkWI4u.js"},{"revision":null,"url":"assets/settings-store-2NQzaOVJ.js"},{"revision":null,"url":"assets/react-rgzL83kk.js"},{"revision":null,"url":"assets/react-CYzKIDNi.js"},{"revision":null,"url":"assets/postgres-viewer-DBOv2ha2.js"},{"revision":null,"url":"assets/markdown-renderer-BKgH2iGf.js"},{"revision":null,"url":"assets/keybindings-store-FQhxQ72s.js"},{"revision":null,"url":"assets/jsx-runtime-wQxeESYQ.js"},{"revision":null,"url":"assets/input-CE3bFwLk.js"},{"revision":null,"url":"assets/index-CeNox-VV.css"},{"revision":null,"url":"assets/index-BGTzm7B1.js"},{"revision":null,"url":"assets/git-graph-CKoW0Ky-.js"},{"revision":null,"url":"assets/dist-D9RHR8A4.js"},{"revision":null,"url":"assets/diff-viewer-COSbmidI.js"},{"revision":null,"url":"assets/database-viewer-COaZMlpv.js"},{"revision":null,"url":"assets/columns-2-fz8yNaAo.js"},{"revision":null,"url":"assets/code-editor-BakDn6rL.js"},{"revision":null,"url":"assets/chat-tab-LTwYS5_e.js"},{"revision":null,"url":"assets/api-client-TUmacMRS.js"},{"revision":"79c8870653c8f419f2e3323085e1f4be","url":"manifest.webmanifest"}]),self.addEventListener(`push`,e=>{e.waitUntil(self.clients.matchAll({type:`window`,includeUncontrolled:!0}).then(t=>{if(t.some(e=>e.visibilityState===`visible`))return;let n=e.data?.json()??{title:`PPM`,body:`Chat completed`};return self.registration.showNotification(n.title,{body:n.body,icon:`/icon-192.png`,badge:`/icon-192.png`,tag:`ppm-chat-done`,silent:!1,data:{url:self.location.origin}})}))}),self.addEventListener(`notificationclick`,e=>{e.notification.close(),e.waitUntil(self.clients.matchAll({type:`window`,includeUncontrolled:!0}).then(t=>{for(let e of t)if(e.url.includes(self.location.origin)&&`focus`in e)return e.focus();return self.clients.openWindow(e.notification.data?.url||`/`)}))});
1
+ try{self[`workbox:core:7.3.0`]&&_()}catch{}var e=(e,...t)=>{let n=e;return t.length>0&&(n+=` :: ${JSON.stringify(t)}`),n},t=class extends Error{constructor(t,n){let r=e(t,n);super(r),this.name=t,this.details=n}},n={googleAnalytics:`googleAnalytics`,precache:`precache-v2`,prefix:`workbox`,runtime:`runtime`,suffix:typeof registration<`u`?registration.scope:``},r=e=>[n.prefix,e,n.suffix].filter(e=>e&&e.length>0).join(`-`),i=e=>{for(let t of Object.keys(n))e(t)},a={updateDetails:e=>{i(t=>{typeof e[t]==`string`&&(n[t]=e[t])})},getGoogleAnalyticsName:e=>e||r(n.googleAnalytics),getPrecacheName:e=>e||r(n.precache),getPrefix:()=>n.prefix,getRuntimeName:e=>e||r(n.runtime),getSuffix:()=>n.suffix};function o(e,t){let n=t();return e.waitUntil(n),n}try{self[`workbox:precaching:7.3.0`]&&_()}catch{}var s=`__WB_REVISION__`;function c(e){if(!e)throw new t(`add-to-cache-list-unexpected-type`,{entry:e});if(typeof e==`string`){let t=new URL(e,location.href);return{cacheKey:t.href,url:t.href}}let{revision:n,url:r}=e;if(!r)throw new t(`add-to-cache-list-unexpected-type`,{entry:e});if(!n){let e=new URL(r,location.href);return{cacheKey:e.href,url:e.href}}let i=new URL(r,location.href),a=new URL(r,location.href);return i.searchParams.set(s,n),{cacheKey:i.href,url:a.href}}var l=class{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:e,state:t})=>{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:n})=>{if(e.type===`install`&&t&&t.originalRequest&&t.originalRequest instanceof Request){let e=t.originalRequest.url;n?this.notUpdatedURLs.push(e):this.updatedURLs.push(e)}return n}}},u=class{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:e,params:t})=>{let n=t?.cacheKey||this._precacheController.getCacheKeyForURL(e.url);return n?new Request(n,{headers:e.headers}):e},this._precacheController=e}},d;function f(){if(d===void 0){let e=new Response(``);if(`body`in e)try{new Response(e.body),d=!0}catch{d=!1}d=!1}return d}async function p(e,n){let r=null;if(e.url&&(r=new URL(e.url).origin),r!==self.location.origin)throw new t(`cross-origin-copy-response`,{origin:r});let i=e.clone(),a={headers:new Headers(i.headers),status:i.status,statusText:i.statusText},o=n?n(a):a,s=f()?i.body:await i.blob();return new Response(s,o)}var m=e=>new URL(String(e),location.href).href.replace(RegExp(`^${location.origin}`),``);function h(e,t){let n=new URL(e);for(let e of t)n.searchParams.delete(e);return n.href}async function g(e,t,n,r){let i=h(t.url,n);if(t.url===i)return e.match(t,r);let a=Object.assign(Object.assign({},r),{ignoreSearch:!0}),o=await e.keys(t,a);for(let t of o)if(i===h(t.url,n))return e.match(t,r)}var v=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}},y=new Set;async function b(){for(let e of y)await e()}function x(e){return new Promise(t=>setTimeout(t,e))}try{self[`workbox:strategies:7.3.0`]&&_()}catch{}function S(e){return typeof e==`string`?new Request(e):e}var C=class{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new v,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(let e of this._plugins)this._pluginStateMap.set(e,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){let{event:n}=this,r=S(e);if(r.mode===`navigate`&&n instanceof FetchEvent&&n.preloadResponse){let e=await n.preloadResponse;if(e)return e}let i=this.hasCallback(`fetchDidFail`)?r.clone():null;try{for(let e of this.iterateCallbacks(`requestWillFetch`))r=await e({request:r.clone(),event:n})}catch(e){if(e instanceof Error)throw new t(`plugin-error-request-will-fetch`,{thrownErrorMessage:e.message})}let a=r.clone();try{let e;e=await fetch(r,r.mode===`navigate`?void 0:this._strategy.fetchOptions);for(let t of this.iterateCallbacks(`fetchDidSucceed`))e=await t({event:n,request:a,response:e});return e}catch(e){throw i&&await this.runCallbacks(`fetchDidFail`,{error:e,event:n,originalRequest:i.clone(),request:a.clone()}),e}}async fetchAndCachePut(e){let t=await this.fetch(e),n=t.clone();return this.waitUntil(this.cachePut(e,n)),t}async cacheMatch(e){let t=S(e),n,{cacheName:r,matchOptions:i}=this._strategy,a=await this.getCacheKey(t,`read`),o=Object.assign(Object.assign({},i),{cacheName:r});n=await caches.match(a,o);for(let e of this.iterateCallbacks(`cachedResponseWillBeUsed`))n=await e({cacheName:r,matchOptions:i,cachedResponse:n,request:a,event:this.event})||void 0;return n}async cachePut(e,n){let r=S(e);await x(0);let i=await this.getCacheKey(r,`write`);if(!n)throw new t(`cache-put-with-no-response`,{url:m(i.url)});let a=await this._ensureResponseSafeToCache(n);if(!a)return!1;let{cacheName:o,matchOptions:s}=this._strategy,c=await self.caches.open(o),l=this.hasCallback(`cacheDidUpdate`),u=l?await g(c,i.clone(),[`__WB_REVISION__`],s):null;try{await c.put(i,l?a.clone():a)}catch(e){if(e instanceof Error)throw e.name===`QuotaExceededError`&&await b(),e}for(let e of this.iterateCallbacks(`cacheDidUpdate`))await e({cacheName:o,oldResponse:u,newResponse:a.clone(),request:i,event:this.event});return!0}async getCacheKey(e,t){let n=`${e.url} | ${t}`;if(!this._cacheKeys[n]){let r=e;for(let e of this.iterateCallbacks(`cacheKeyWillBeUsed`))r=S(await e({mode:t,request:r,event:this.event,params:this.params}));this._cacheKeys[n]=r}return this._cacheKeys[n]}hasCallback(e){for(let t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(let n of this.iterateCallbacks(e))await n(t)}*iterateCallbacks(e){for(let t of this._strategy.plugins)if(typeof t[e]==`function`){let n=this._pluginStateMap.get(t);yield r=>{let i=Object.assign(Object.assign({},r),{state:n});return t[e](i)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){for(;this._extendLifetimePromises.length;){let e=this._extendLifetimePromises.splice(0),t=(await Promise.allSettled(e)).find(e=>e.status===`rejected`);if(t)throw t.reason}}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,n=!1;for(let e of this.iterateCallbacks(`cacheWillUpdate`))if(t=await e({request:this.request,response:t,event:this.event})||void 0,n=!0,!t)break;return n||t&&t.status!==200&&(t=void 0),t}},w=class{constructor(e={}){this.cacheName=a.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){let[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});let t=e.event,n=typeof e.request==`string`?new Request(e.request):e.request,r=`params`in e?e.params:void 0,i=new C(this,{event:t,request:n,params:r}),a=this._getResponse(i,n,t);return[a,this._awaitComplete(a,i,n,t)]}async _getResponse(e,n,r){await e.runCallbacks(`handlerWillStart`,{event:r,request:n});let i;try{if(i=await this._handle(n,e),!i||i.type===`error`)throw new t(`no-response`,{url:n.url})}catch(t){if(t instanceof Error){for(let a of e.iterateCallbacks(`handlerDidError`))if(i=await a({error:t,event:r,request:n}),i)break}if(!i)throw t}for(let t of e.iterateCallbacks(`handlerWillRespond`))i=await t({event:r,request:n,response:i});return i}async _awaitComplete(e,t,n,r){let i,a;try{i=await e}catch{}try{await t.runCallbacks(`handlerDidRespond`,{event:r,request:n,response:i}),await t.doneWaiting()}catch(e){e instanceof Error&&(a=e)}if(await t.runCallbacks(`handlerDidComplete`,{event:r,request:n,response:i,error:a}),t.destroy(),a)throw a}},T=class e extends w{constructor(t={}){t.cacheName=a.getPrecacheName(t.cacheName),super(t),this._fallbackToNetwork=t.fallbackToNetwork!==!1,this.plugins.push(e.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){return await t.cacheMatch(e)||(t.event&&t.event.type===`install`?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,n){let r,i=n.params||{};if(this._fallbackToNetwork){let t=i.integrity,a=e.integrity,o=!a||a===t;r=await n.fetch(new Request(e,{integrity:e.mode===`no-cors`?void 0:a||t})),t&&o&&e.mode!==`no-cors`&&(this._useDefaultCacheabilityPluginIfNeeded(),await n.cachePut(e,r.clone()))}else throw new t(`missing-precache-entry`,{cacheName:this.cacheName,url:e.url});return r}async _handleInstall(e,n){this._useDefaultCacheabilityPluginIfNeeded();let r=await n.fetch(e);if(!await n.cachePut(e,r.clone()))throw new t(`bad-precaching-response`,{url:e.url,status:r.status});return r}_useDefaultCacheabilityPluginIfNeeded(){let t=null,n=0;for(let[r,i]of this.plugins.entries())i!==e.copyRedirectedCacheableResponsesPlugin&&(i===e.defaultPrecacheCacheabilityPlugin&&(t=r),i.cacheWillUpdate&&n++);n===0?this.plugins.push(e.defaultPrecacheCacheabilityPlugin):n>1&&t!==null&&this.plugins.splice(t,1)}};T.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:e}){return!e||e.status>=400?null:e}},T.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:e}){return e.redirected?await p(e):e}};var E=class{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:n=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new T({cacheName:a.getPrecacheName(e),plugins:[...t,new u({precacheController:this})],fallbackToNetwork:n}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||=(self.addEventListener(`install`,this.install),self.addEventListener(`activate`,this.activate),!0)}addToCacheList(e){let n=[];for(let r of e){typeof r==`string`?n.push(r):r&&r.revision===void 0&&n.push(r.url);let{cacheKey:e,url:i}=c(r),a=typeof r!=`string`&&r.revision?`reload`:`default`;if(this._urlsToCacheKeys.has(i)&&this._urlsToCacheKeys.get(i)!==e)throw new t(`add-to-cache-list-conflicting-entries`,{firstEntry:this._urlsToCacheKeys.get(i),secondEntry:e});if(typeof r!=`string`&&r.integrity){if(this._cacheKeysToIntegrities.has(e)&&this._cacheKeysToIntegrities.get(e)!==r.integrity)throw new t(`add-to-cache-list-conflicting-integrities`,{url:i});this._cacheKeysToIntegrities.set(e,r.integrity)}if(this._urlsToCacheKeys.set(i,e),this._urlsToCacheModes.set(i,a),n.length>0){let e=`Workbox is precaching URLs without revision info: ${n.join(`, `)}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(e)}}}install(e){return o(e,async()=>{let t=new l;this.strategy.plugins.push(t);for(let[t,n]of this._urlsToCacheKeys){let r=this._cacheKeysToIntegrities.get(n),i=this._urlsToCacheModes.get(t),a=new Request(t,{integrity:r,cache:i,credentials:`same-origin`});await Promise.all(this.strategy.handleAll({params:{cacheKey:n},request:a,event:e}))}let{updatedURLs:n,notUpdatedURLs:r}=t;return{updatedURLs:n,notUpdatedURLs:r}})}activate(e){return o(e,async()=>{let e=await self.caches.open(this.strategy.cacheName),t=await e.keys(),n=new Set(this._urlsToCacheKeys.values()),r=[];for(let i of t)n.has(i.url)||(await e.delete(i),r.push(i.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){let t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){let t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n)return(await self.caches.open(this.strategy.cacheName)).match(n)}createHandlerBoundToURL(e){let n=this.getCacheKeyForURL(e);if(!n)throw new t(`non-precached-url`,{url:e});return t=>(t.request=new Request(e),t.params=Object.assign({cacheKey:n},t.params),this.strategy.handle(t))}},D,O=()=>(D||=new E,D);try{self[`workbox:routing:7.3.0`]&&_()}catch{}var k=e=>e&&typeof e==`object`?e:{handle:e},A=class{constructor(e,t,n=`GET`){this.handler=k(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=k(e)}},j=class extends A{constructor(e,t,n){super(({url:t})=>{let n=e.exec(t.href);if(n&&!(t.origin!==location.origin&&n.index!==0))return n.slice(1)},t,n)}},M=class{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener(`fetch`,(e=>{let{request:t}=e,n=this.handleRequest({request:t,event:e});n&&e.respondWith(n)}))}addCacheListener(){self.addEventListener(`message`,(e=>{if(e.data&&e.data.type===`CACHE_URLS`){let{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(t=>{typeof t==`string`&&(t=[t]);let n=new Request(...t);return this.handleRequest({request:n,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){let n=new URL(e.url,location.href);if(!n.protocol.startsWith(`http`))return;let r=n.origin===location.origin,{params:i,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:r,url:n}),o=a&&a.handler,s=e.method;if(!o&&this._defaultHandlerMap.has(s)&&(o=this._defaultHandlerMap.get(s)),!o)return;let c;try{c=o.handle({url:n,request:e,event:t,params:i})}catch(e){c=Promise.reject(e)}let l=a&&a.catchHandler;return c instanceof Promise&&(this._catchHandler||l)&&(c=c.catch(async r=>{if(l)try{return await l.handle({url:n,request:e,event:t,params:i})}catch(e){e instanceof Error&&(r=e)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw r})),c}findMatchingRoute({url:e,sameOrigin:t,request:n,event:r}){let i=this._routes.get(n.method)||[];for(let a of i){let i,o=a.match({url:e,sameOrigin:t,request:n,event:r});if(o)return i=o,(Array.isArray(i)&&i.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o==`boolean`)&&(i=void 0),{route:a,params:i}}return{}}setDefaultHandler(e,t=`GET`){this._defaultHandlerMap.set(t,k(e))}setCatchHandler(e){this._catchHandler=k(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new t(`unregister-route-but-not-found-with-method`,{method:e.method});let n=this._routes.get(e.method).indexOf(e);if(n>-1)this._routes.get(e.method).splice(n,1);else throw new t(`unregister-route-route-not-registered`)}},N,P=()=>(N||(N=new M,N.addFetchListener(),N.addCacheListener()),N);function F(e,n,r){let i;if(typeof e==`string`){let t=new URL(e,location.href);i=new A(({url:e})=>e.href===t.href,n,r)}else if(e instanceof RegExp)i=new j(e,n,r);else if(typeof e==`function`)i=new A(e,n,r);else if(e instanceof A)i=e;else throw new t(`unsupported-route-type`,{moduleName:`workbox-routing`,funcName:`registerRoute`,paramName:`capture`});return P().registerRoute(i),i}function I(e,t=[]){for(let n of[...e.searchParams.keys()])t.some(e=>e.test(n))&&e.searchParams.delete(n);return e}function*L(e,{ignoreURLParametersMatching:t=[/^utm_/,/^fbclid$/],directoryIndex:n=`index.html`,cleanURLs:r=!0,urlManipulation:i}={}){let a=new URL(e,location.href);a.hash=``,yield a.href;let o=I(a,t);if(yield o.href,n&&o.pathname.endsWith(`/`)){let e=new URL(o.href);e.pathname+=n,yield e.href}if(r){let e=new URL(o.href);e.pathname+=`.html`,yield e.href}if(i){let e=i({url:a});for(let t of e)yield t.href}}var R=class extends A{constructor(e,t){super(({request:n})=>{let r=e.getURLsToCacheKeys();for(let i of L(n.url,t)){let t=r.get(i);if(t)return{cacheKey:t,integrity:e.getIntegrityForCacheKey(t)}}},e.strategy)}};function z(e){F(new R(O(),e))}function B(e){O().precache(e)}function V(e,t){B(e),z(t)}V([{"revision":"1872c500de691dce40960bb85481de07","url":"registerSW.js"},{"revision":"6cfaa08b4ab2d04a62445a5daf7143f5","url":"index.html"},{"revision":"a0fb34fc84eb148d51812cd62669f20d","url":"icon-512.svg"},{"revision":"a0fb34fc84eb148d51812cd62669f20d","url":"icon-192.svg"},{"revision":"eb9818b9094675c0c5d303168f273345","url":"monacoeditorwork/ts.worker.bundle.js"},{"revision":"9af0be92dcefdc1f1290441cb5ff5d9b","url":"monacoeditorwork/json.worker.bundle.js"},{"revision":"a261b429c39dbb75ae97972d7d005e6d","url":"monacoeditorwork/html.worker.bundle.js"},{"revision":"79953d804e1bbacecfd79b85fd679016","url":"monacoeditorwork/editor.worker.bundle.js"},{"revision":"fdcba0d09aac31df7a0bc652f6e739bd","url":"monacoeditorwork/css.worker.bundle.js"},{"revision":null,"url":"assets/utils-DC-bdPS3.js"},{"revision":null,"url":"assets/use-monaco-theme-Bt1Lr3jH.js"},{"revision":null,"url":"assets/terminal-tab-De5HNn69.js"},{"revision":null,"url":"assets/terminal-tab-BrP-ENHg.css"},{"revision":null,"url":"assets/table-C0oSLUYn.js"},{"revision":null,"url":"assets/tab-store-0CKk8cSr.js"},{"revision":null,"url":"assets/switch-D0FJQVBN.js"},{"revision":null,"url":"assets/sqlite-viewer-c5qjZ0JX.js"},{"revision":null,"url":"assets/settings-tab-BqCPHAwC.js"},{"revision":null,"url":"assets/settings-store-2NQzaOVJ.js"},{"revision":null,"url":"assets/react-rgzL83kk.js"},{"revision":null,"url":"assets/react-CYzKIDNi.js"},{"revision":null,"url":"assets/postgres-viewer-DlL-U9dr.js"},{"revision":null,"url":"assets/markdown-renderer-GNvNI0W2.js"},{"revision":null,"url":"assets/keybindings-store-kKJUrmPE.js"},{"revision":null,"url":"assets/jsx-runtime-wQxeESYQ.js"},{"revision":null,"url":"assets/input-CE3bFwLk.js"},{"revision":null,"url":"assets/index-CeNox-VV.css"},{"revision":null,"url":"assets/index-BjNob0pC.js"},{"revision":null,"url":"assets/git-graph-AIb4ycN5.js"},{"revision":null,"url":"assets/dist-D9RHR8A4.js"},{"revision":null,"url":"assets/diff-viewer-DQHmJoFE.js"},{"revision":null,"url":"assets/database-viewer-CqxbPCAF.js"},{"revision":null,"url":"assets/columns-2-fz8yNaAo.js"},{"revision":null,"url":"assets/code-editor-DBx65sCc.js"},{"revision":null,"url":"assets/chat-tab-DuDiXvH8.js"},{"revision":null,"url":"assets/api-client-TUmacMRS.js"},{"revision":"79c8870653c8f419f2e3323085e1f4be","url":"manifest.webmanifest"}]),self.addEventListener(`push`,e=>{e.waitUntil(self.clients.matchAll({type:`window`,includeUncontrolled:!0}).then(t=>{if(t.some(e=>e.visibilityState===`visible`))return;let n=e.data?.json()??{title:`PPM`,body:`Chat completed`};return self.registration.showNotification(n.title,{body:n.body,icon:`/icon-192.png`,badge:`/icon-192.png`,tag:`ppm-chat-done`,silent:!1,data:{url:self.location.origin}})}))}),self.addEventListener(`notificationclick`,e=>{e.notification.close(),e.waitUntil(self.clients.matchAll({type:`window`,includeUncontrolled:!0}).then(t=>{for(let e of t)if(e.url.includes(self.location.origin)&&`focus`in e)return e.focus();return self.clients.openWindow(e.notification.data?.url||`/`)}))});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hienlh/ppm",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "description": "Personal Project Manager — mobile-first web IDE with AI assistance",
5
5
  "author": "hienlh",
6
6
  "license": "MIT",
@@ -18,7 +18,6 @@ import { accountSelector } from "../services/account-selector.service.ts";
18
18
  import { accountService } from "../services/account.service.ts";
19
19
  import { resolve } from "node:path";
20
20
  import { homedir } from "node:os";
21
- import { readFileSync, existsSync } from "node:fs";
22
21
 
23
22
  function getSdkSessionId(ppmId: string): string {
24
23
  return getSessionMapping(ppmId) ?? ppmId;
@@ -50,58 +49,32 @@ export class ClaudeAgentSdkProvider implements AIProvider {
50
49
  /** Fork source: ppmSessionId → sourceSessionId (used on first message to fork) */
51
50
  private forkSources = new Map<string, string>();
52
51
 
53
- /** Auth-related env keys priority: account > project .env > shell env */
52
+ /** Auth-related env keys for diagnostic logging */
54
53
  private readonly AUTH_ENV_KEYS = ["ANTHROPIC_API_KEY", "ANTHROPIC_BASE_URL", "ANTHROPIC_AUTH_TOKEN"];
55
54
 
56
- /**
57
- * Parse project .env file and extract auth-related values.
58
- * Returns actual values (not neutralized) so they can override shell env.
59
- */
60
- private parseProjectEnv(projectPath?: string): Record<string, string> {
61
- if (!projectPath) return {};
62
- try {
63
- const envPath = resolve(projectPath, ".env");
64
- if (!existsSync(envPath)) return {};
65
- const content = readFileSync(envPath, "utf-8");
66
- const parsed: Record<string, string> = {};
67
- for (const line of content.split("\n")) {
68
- const trimmed = line.trim();
69
- if (!trimmed || trimmed.startsWith("#")) continue;
70
- const eqIdx = trimmed.indexOf("=");
71
- if (eqIdx < 0) continue;
72
- const key = trimmed.slice(0, eqIdx).trim();
73
- if (!this.AUTH_ENV_KEYS.includes(key)) continue;
74
- // Strip surrounding quotes
75
- let val = trimmed.slice(eqIdx + 1).trim();
76
- if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
77
- val = val.slice(1, -1);
78
- }
79
- parsed[key] = val;
80
- }
81
- return parsed;
82
- } catch { return {}; }
83
- }
84
-
85
55
  /**
86
56
  * Build env for SDK query.
87
- * Priority: PPM accounts > project .env > shell env.
88
- * - Account mode: inject account token, neutralize conflicting vars.
89
- * TODO: support base_url from PPM AI settings.
90
- * - No account: project .env overrides shell env for auth vars.
57
+ * Priority: PPM settings (accounts + base_url) > shell env.
58
+ * Project .env is intentionally NOT read projects using Claude API
59
+ * have their own ANTHROPIC_API_KEY which would conflict with PPM's SDK auth.
91
60
  */
92
61
  private buildQueryEnv(
93
- projectPath: string | undefined,
62
+ _projectPath: string | undefined,
94
63
  account: { id: string; accessToken: string } | null,
95
64
  ): Record<string, string | undefined> {
96
- const projectEnv = this.parseProjectEnv(projectPath);
97
- // Merge: shell env ← project .env (project wins)
98
- const base = { ...process.env, ...projectEnv };
65
+ const base: Record<string, string | undefined> = { ...process.env };
66
+
67
+ // Settings base_url overrides shell env
68
+ const providerConfig = this.getProviderConfig();
69
+ if (providerConfig.base_url) {
70
+ base.ANTHROPIC_BASE_URL = providerConfig.base_url;
71
+ console.log(`[sdk] ANTHROPIC_BASE_URL from settings: ${providerConfig.base_url}`);
72
+ }
99
73
 
100
74
  // Log auth source for diagnostics
101
75
  for (const key of this.AUTH_ENV_KEYS) {
102
- if (projectEnv[key]) {
103
- console.log(`[sdk] ${key} from project .env (length=${projectEnv[key].length})`);
104
- } else if (process.env[key]) {
76
+ if (key === "ANTHROPIC_BASE_URL" && providerConfig.base_url) continue;
77
+ if (process.env[key]) {
105
78
  console.log(`[sdk] ${key} from shell env (length=${process.env[key]!.length})`);
106
79
  }
107
80
  }
@@ -110,7 +83,6 @@ export class ClaudeAgentSdkProvider implements AIProvider {
110
83
 
111
84
  // Account mode: account token takes highest priority
112
85
  const isOAuthToken = account.accessToken.startsWith("sk-ant-oat");
113
- // TODO: support base_url from PPM AI provider settings
114
86
  if (isOAuthToken) {
115
87
  return {
116
88
  ...base,
@@ -46,6 +46,7 @@ export type PermissionMode = typeof VALID_PERMISSION_MODES[number];
46
46
  export interface AIProviderConfig {
47
47
  type: "agent-sdk" | "mock";
48
48
  api_key_env?: string;
49
+ base_url?: string;
49
50
  // Agent SDK-specific settings (ignored by mock provider)
50
51
  model?: string;
51
52
  effort?: "low" | "medium" | "high";
@@ -109,6 +110,13 @@ export function validateAIProviderConfig(config: Partial<AIProviderConfig>): str
109
110
  if (config.permission_mode != null && !VALID_PERMISSION_MODES.includes(config.permission_mode as any)) {
110
111
  errors.push(`permission_mode must be one of: ${VALID_PERMISSION_MODES.join(", ")}`);
111
112
  }
113
+ if (config.base_url != null) {
114
+ if (typeof config.base_url !== "string") {
115
+ errors.push("base_url must be a string");
116
+ } else if (config.base_url && !/^https?:\/\/.+/.test(config.base_url)) {
117
+ errors.push("base_url must be a valid HTTP(S) URL");
118
+ }
119
+ }
112
120
  if (config.system_prompt != null) {
113
121
  if (typeof config.system_prompt !== "string") {
114
122
  errors.push("system_prompt must be a string");
@@ -101,6 +101,22 @@ export function AISettingsSection({ compact }: { compact?: boolean } = {}) {
101
101
  </Select>
102
102
  </div>
103
103
 
104
+ <div className={fieldGap}>
105
+ <Label htmlFor="ai-base-url" className={compact ? labelSize : undefined}>Base URL</Label>
106
+ <Input
107
+ key={`baseurl-${revision}`}
108
+ id="ai-base-url"
109
+ type="url"
110
+ defaultValue={config?.base_url ?? ""}
111
+ placeholder="https://api.anthropic.com (default)"
112
+ className={compact ? "h-7 text-[11px]" : undefined}
113
+ onBlur={(e) => {
114
+ const val = e.target.value.trim();
115
+ handleSave("base_url", val || undefined);
116
+ }}
117
+ />
118
+ </div>
119
+
104
120
  <div className={fieldGap}>
105
121
  <Label htmlFor="ai-effort" className={compact ? labelSize : undefined}>Effort</Label>
106
122
  <Select
@@ -121,6 +121,7 @@ export function importAccounts(params: { data: string; password: string }): Prom
121
121
  export interface AIProviderSettings {
122
122
  type?: string;
123
123
  api_key_env?: string;
124
+ base_url?: string;
124
125
  model?: string;
125
126
  effort?: string;
126
127
  max_turns?: number;
@@ -1 +0,0 @@
1
- import"./react-CYzKIDNi.js";import"./api-client-TUmacMRS.js";import{x as e}from"./index-BGTzm7B1.js";export{e as useKeybindingsStore};