@augmentd-labs/canvas-web 2.26.22 → 2.26.24

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.
Files changed (79) hide show
  1. package/dist/assets/{FileForm-DhQhVnoi.js → FileForm-CqJpRbXv.js} +1 -1
  2. package/dist/assets/{FiltersApplet-gbu4I1fK.js → FiltersApplet-CcYMBq-Q.js} +1 -1
  3. package/dist/assets/{HomeFab-CXaEEzXy.js → HomeFab-D2pLJ9oc.js} +1 -1
  4. package/dist/assets/{IdentityFields-OPEWPlZs.js → IdentityFields-Bti7ojF3.js} +1 -1
  5. package/dist/assets/{LensApplet-FifF2RUs.js → LensApplet-DibGKbKC.js} +1 -1
  6. package/dist/assets/LinkToCard-5dg0jvSY.js +1 -0
  7. package/dist/assets/{NextShell-BIYs9fCL.js → NextShell-UX4Efo0u.js} +1 -1
  8. package/dist/assets/{NotesApplet-D94iQKg6.js → NotesApplet-DJp9Wuwt.js} +1 -1
  9. package/dist/assets/{ObjectPropertiesCard-ChvWbOpZ.js → ObjectPropertiesCard-BIBMvx_i.js} +4 -4
  10. package/dist/assets/{PathPickerField-DBe7jykL.js → PathPickerField-fZazwxCN.js} +1 -1
  11. package/dist/assets/{PickDocumentsCard-Bo224P4q.js → PickDocumentsCard-DamtV7fN.js} +1 -1
  12. package/dist/assets/{SketchApplet-ADVOnSLI.js → SketchApplet-DDIg411i.js} +1 -1
  13. package/dist/assets/{SketchEditor-CkgRysCG.js → SketchEditor-CKPPuZt3.js} +1 -1
  14. package/dist/assets/{TerminalApplet-CkO4uaE3.js → TerminalApplet-wGJG1PPc.js} +1 -1
  15. package/dist/assets/{TextDocumentEditor-COvsHJXH.js → TextDocumentEditor-CRre32cj.js} +1 -1
  16. package/dist/assets/{TodosApplet-Bpf1OIH4.js → TodosApplet-CleBd4uU.js} +1 -1
  17. package/dist/assets/{TodosWidget-BIYqPXUp.js → TodosWidget-CxiqmDuJ.js} +1 -1
  18. package/dist/assets/{UploadProgressList-BXJr87lI.js → UploadProgressList-DRJzjy6A.js} +1 -1
  19. package/dist/assets/{_agentId_-wN8YJoTZ.js → _agentId_--jQP7aTv.js} +0 -0
  20. package/dist/assets/{_contextId_-CoJraYnP.js → _contextId_-D6nNA8hC.js} +1 -1
  21. package/dist/assets/_workspaceName_-DfHnlgVg.js +1 -0
  22. package/dist/assets/{about-CT6Ghfkb.js → about-DVlaoa-W.js} +1 -1
  23. package/dist/assets/{add-BzgCpo5S.js → add-Bq99uA2R.js} +1 -1
  24. package/dist/assets/{agents-DIJpWCkc.js → agents-CRnO7j5E.js} +1 -1
  25. package/dist/assets/{appearance-D1EpKWaK.js → appearance-BAH_8zeF.js} +1 -1
  26. package/dist/assets/{applet-target-ChiiXVdC.js → applet-target-C_gBgU-Z.js} +1 -1
  27. package/dist/assets/{apps-DX8oWukQ.js → apps-EwUooEtp.js} +1 -1
  28. package/dist/assets/backend-sync-progress-pZrhQPk3.js +7 -0
  29. package/dist/assets/{content-app-view-DS6Nrz6M.js → content-app-view-BF-k-5Y7.js} +1 -1
  30. package/dist/assets/{context-mfIOB8dN.js → context-DQoZFMDQ.js} +1 -1
  31. package/dist/assets/{contexts-CRWqFXzJ2.js → contexts-CvMtPd1N2.js} +1 -1
  32. package/dist/assets/{date-time-picker-B6mkWt-g.js → date-time-picker-DebNUTx3.js} +1 -1
  33. package/dist/assets/{document-CX543Kcz.js → document-DOp6AbOi.js} +1 -1
  34. package/dist/assets/document-list-Dsf1DVEx.js +2 -0
  35. package/dist/assets/embedding-B5JiUA9X.js +1 -0
  36. package/dist/assets/{embedding-BHnBCyUx.js → embedding-B7cWrpy0.js} +1 -1
  37. package/dist/assets/{home-3vhobmCu.js → home-Dc60CSIJ.js} +1 -1
  38. package/dist/assets/{index-CiBgHujl.js → index-D5Q9EUVc.js} +6 -6
  39. package/dist/assets/inferd-config-editor--MDmN_7w.js +1 -0
  40. package/dist/assets/{key-bindings-BNeY-GEg.js → key-bindings-Bqkl5tDH.js} +1 -1
  41. package/dist/assets/{offline-CsRyFUg7.js → offline-COOUcZsG.js} +1 -1
  42. package/dist/assets/{public-share-DXxVwHKT.js → public-share-g_wBd6BW.js} +1 -1
  43. package/dist/assets/{query-debug-BUUG3jpK.js → query-debug-CrPsUwT-.js} +1 -1
  44. package/dist/assets/{registry-DTWAywyJ.js → registry-DIfZf6LB.js} +2 -2
  45. package/dist/assets/{roles-BYHLwWCD.js → roles-Bo9GZdOk.js} +1 -1
  46. package/dist/assets/{settings-DNhy58i9.js → settings-BeN2UmZL.js} +1 -1
  47. package/dist/assets/{settings-DjnFAqIe.js → settings-CzxxI2yw.js} +1 -1
  48. package/dist/assets/{settings-jWfP7CP8.js → settings-Dl1FnW9g.js} +1 -1
  49. package/dist/assets/settings-DqHAUBU4.js +14 -0
  50. package/dist/assets/{share-target-CgHlnZLH.js → share-target-BWFFRO5O.js} +1 -1
  51. package/dist/assets/{shared-BMoiShd9.js → shared-B5Pvz8wr.js} +1 -1
  52. package/dist/assets/{shared-D2uRUNdC.js → shared-BQZGA3ph.js} +1 -1
  53. package/dist/assets/{sketch-lazy-pbG2cCpW.js → sketch-lazy-C4pjV1WK.js} +2 -2
  54. package/dist/assets/{text-documents-BvDFBVnC.js → text-documents-0P9jkIpu.js} +2 -2
  55. package/dist/assets/{use-applet-docs-o5NAUFBk.js → use-applet-docs-D5eXpITp.js} +1 -1
  56. package/dist/assets/{use-applet-target-cO-FiyPQ.js → use-applet-target-gXPvZGgx.js} +1 -1
  57. package/dist/assets/use-canvas-pins-CbAxLLTU.js +3 -0
  58. package/dist/assets/{use-workspace-identity-mgaofjsD.js → use-workspace-identity-BCrrvfeE.js} +1 -1
  59. package/dist/assets/{useAddTarget-DUjaZdBQ.js → useAddTarget-CqnDU0Om.js} +1 -1
  60. package/dist/assets/{useAgentModels-Sa4N8WFd.js → useAgentModels-CYDYTjgG.js} +1 -1
  61. package/dist/assets/{useDocumentThumbnail-DYLCC63L.js → useDocumentThumbnail-DunxmU1A.js} +1 -1
  62. package/dist/assets/{useEditNoteFields-zHEWwDfB.js → useEditNoteFields-BehI0vog.js} +1 -1
  63. package/dist/assets/workspace-CrSpR4xf.js +1 -0
  64. package/dist/assets/{workspace-area-menu-UamvRNfd.js → workspace-area-menu-CP5OWZNX.js} +1 -1
  65. package/dist/assets/{workspace-content-gate-Be4tLYiB.js → workspace-content-gate-9okuA7J7.js} +1 -1
  66. package/dist/assets/{workspace-import-form-BRwc_oVg.js → workspace-import-form-aR-DwHf6.js} +1 -1
  67. package/dist/assets/{workspaces-gQY1mczH.js → workspaces-B9gcHMCE.js} +1 -1
  68. package/dist/index.html +25 -25
  69. package/dist/sw.js +1 -1
  70. package/package.json +2 -2
  71. package/dist/assets/LinkToCard-nR7Lal_o.js +0 -1
  72. package/dist/assets/_workspaceName_-CXuIfG46.js +0 -1
  73. package/dist/assets/backend-sync-progress-BeI9mDEX.js +0 -7
  74. package/dist/assets/document-list-SsF3jmuq.js +0 -2
  75. package/dist/assets/embedding-CEGjemkq.js +0 -1
  76. package/dist/assets/inferd-config-editor-BHUUFArV.js +0 -1
  77. package/dist/assets/settings-DH3ZiQLR.js +0 -14
  78. package/dist/assets/use-canvas-pins-Bth_Q--t.js +0 -3
  79. package/dist/assets/workspace-DvxC7pw1.js +0 -1
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{L as r,Nt as i}from"./ui-Byg1cZDr.js";import{n as a}from"./use-applet-target-cO-FiyPQ.js";var o=e(n(),1),s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{for(var i=r>1?void 0:r?c(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&&s(t,n,i),i},d=(e,t)=>(n,r)=>t(n,r,e),f=`Terminal input`,p={get:()=>f,set:e=>f=e},m=`Too much output to announce, navigate to rows manually to read`,h={get:()=>m,set:e=>m=e};function g(e){return e.replace(/\r?\n/g,`\r`)}function _(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function v(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ee(e,t,n,r){e.stopPropagation(),e.clipboardData&&te(e.clipboardData.getData(`text/plain`),t,n,r)}function te(e,t,n,r){e=g(e),e=_(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ne(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 re(e,t,n,r,i){ne(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ie(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}},se=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}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}},y=``,ce=` `,le=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ue}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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ue=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}},b=class e extends le{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ue,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?ie(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()]}},de=`di$target`,fe=`di$dependencies`,pe=new Map;function x(e){return e[fe]||[]}function S(e){if(pe.has(e))return pe.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);me(t,e,r)};return t._id=e,pe.set(e,t),t}function me(e,t,n){t[de]===t?t[fe].push({id:e,index:n}):(t[fe]=[{id:e,index:n}],t[de]=t)}var C=S(`BufferService`),he=S(`CoreMouseService`),ge=S(`CoreService`),w=S(`CharsetService`),_e=S(`InstantiationService`),ve=S(`LogService`),T=S(`OptionsService`),ye=S(`OscLinkService`),be=S(`UnicodeService`),xe=S(`DecorationService`),Se=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 b,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}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),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):Ce(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)}};Se=u([d(0,C),d(1,T),d(2,ye)],Se);function Ce(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{L as r,Nt as i}from"./ui-Byg1cZDr.js";import{n as a}from"./use-applet-target-gXPvZGgx.js";var o=e(n(),1),s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{for(var i=r>1?void 0:r?c(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&&s(t,n,i),i},d=(e,t)=>(n,r)=>t(n,r,e),f=`Terminal input`,p={get:()=>f,set:e=>f=e},m=`Too much output to announce, navigate to rows manually to read`,h={get:()=>m,set:e=>m=e};function g(e){return e.replace(/\r?\n/g,`\r`)}function _(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function v(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function ee(e,t,n,r){e.stopPropagation(),e.clipboardData&&te(e.clipboardData.getData(`text/plain`),t,n,r)}function te(e,t,n,r){e=g(e),e=_(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function ne(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 re(e,t,n,r,i){ne(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ie(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}},se=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}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}},y=``,ce=` `,le=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ue}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)}isBgDefault(){return!(this.bg&50331648)}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):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},ue=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}},b=class e extends le{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ue,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?ie(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()]}},de=`di$target`,fe=`di$dependencies`,pe=new Map;function x(e){return e[fe]||[]}function S(e){if(pe.has(e))return pe.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);me(t,e,r)};return t._id=e,pe.set(e,t),t}function me(e,t,n){t[de]===t?t[fe].push({id:e,index:n}):(t[fe]=[{id:e,index:n}],t[de]=t)}var C=S(`BufferService`),he=S(`CoreMouseService`),ge=S(`CoreService`),w=S(`CharsetService`),_e=S(`InstantiationService`),ve=S(`LogService`),T=S(`OptionsService`),ye=S(`OscLinkService`),be=S(`UnicodeService`),xe=S(`DecorationService`),Se=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 b,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}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),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):Ce(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)}};Se=u([d(0,C),d(1,T),d(2,ye)],Se);function Ce(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 we=S(`CharSizeService`),Te=S(`CoreBrowserService`),Ee=S(`MouseService`),De=S(`RenderService`),Oe=S(`SelectionService`),ke=S(`CharacterJoinerService`),Ae=S(`ThemeService`),je=S(`LinkProviderService`),Me=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Re.isErrorNoTelemetry(e)?new Re(e.message+`
4
4
 
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ct as r}from"./ui-Byg1cZDr.js";import{t as i}from"./button-SgR3GVvV.js";import{In as a,Un as o}from"./workspace-DvxC7pw1.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./text-documents-BvDFBVnC.js";import{t as p}from"./useToastHelpers-CRrpIIdY.js";import{t as m}from"./note-save-status-DPz4VzL6.js";import{t as h}from"./useEditNoteFields-zHEWwDfB.js";import{t as g}from"./DocumentBodyEditor-8DNmOBS0.js";import{t as _}from"./EditorOverlay-Cv1MaTok.js";var v=e(n(),1),y=t();function b({doc:e,workspaceName:t,onSaved:n,onClose:b,onDetails:x}){let{showSuccessToast:S,showErrorToast:C}=p(),w=e.schema===o,T=c(e),E=T&&s(e),D=d(e)??`markdown`,O=u(t,e.id,{mode:`text`,enabled:T&&!E,maxTextLength:l,version:e.checksumArray?.[0]??null}),[k,A]=(0,v.useState)(w?String(e.data?.content??``):``),j=h(e,t,w),M=w?j.content:k,N=w?j.setContent:A,[P,F]=(0,v.useState)(null),I=`${e.id}:${e.checksumArray?.[0]??``}`;T&&O.text!=null&&P!==I&&(F(I),N(O.text));let[L,R]=(0,v.useState)(!1),z=w||O.text!=null&&!O.loading,B=async()=>{R(!0);try{let r;w?await j.save():r=await f(t,e,M),S(`Document saved`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),n(r)}catch(e){C(e instanceof Error?e.message:`Failed to save document`)}finally{R(!1)}},V=w?String(e.data?.title??`Note`):a(e)||`document-${e.id}`;return(0,y.jsx)(_,{onClose:b,onDetails:x,title:(0,y.jsx)(`span`,{className:`truncate text-sm font-medium`,children:V}),actions:(0,y.jsxs)(y.Fragment,{children:[w&&(0,y.jsx)(m,{...j,onRetry:j.save}),(0,y.jsxs)(i,{size:`sm`,onClick:B,disabled:L||!z||E,children:[(0,y.jsx)(r,{className:`mr-1.5 h-4 w-4`}),L?`Saving…`:`Save`]})]}),children:(0,y.jsx)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-4 md:px-8`,children:(0,y.jsx)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-full flex-1 flex-col overflow-auto md:w-[700px] md:min-w-[320px] md:resize-x`,children:E?(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This file is too large to edit here (`,`>`,Math.round(l/1e3),` kB) — download it instead.`]}):O.error?(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:O.error}):z?(0,y.jsx)(g,{kind:w?`markdown`:D,value:M,onChange:N,placeholder:w?`Write your note…`:void 0,fill:!0}):(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading content…`})})})})}export{b as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ct as r}from"./ui-Byg1cZDr.js";import{t as i}from"./button-SgR3GVvV.js";import{Mn as a,zn as o}from"./workspace-CrSpR4xf.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./text-documents-0P9jkIpu.js";import{t as p}from"./useToastHelpers-CRrpIIdY.js";import{t as m}from"./note-save-status-DPz4VzL6.js";import{t as h}from"./useEditNoteFields-BehI0vog.js";import{t as g}from"./DocumentBodyEditor-8DNmOBS0.js";import{t as _}from"./EditorOverlay-Cv1MaTok.js";var v=e(n(),1),y=t();function b({doc:e,workspaceName:t,onSaved:n,onClose:b,onDetails:x}){let{showSuccessToast:S,showErrorToast:C}=p(),w=e.schema===o,T=c(e),E=T&&s(e),D=d(e)??`markdown`,O=u(t,e.id,{mode:`text`,enabled:T&&!E,maxTextLength:l,version:e.checksumArray?.[0]??null}),[k,A]=(0,v.useState)(w?String(e.data?.content??``):``),j=h(e,t,w),M=w?j.content:k,N=w?j.setContent:A,[P,F]=(0,v.useState)(null),I=`${e.id}:${e.checksumArray?.[0]??``}`;T&&O.text!=null&&P!==I&&(F(I),N(O.text));let[L,R]=(0,v.useState)(!1),z=w||O.text!=null&&!O.loading,B=async()=>{R(!0);try{let r;w?await j.save():r=await f(t,e,M),S(`Document saved`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),n(r)}catch(e){C(e instanceof Error?e.message:`Failed to save document`)}finally{R(!1)}},V=w?String(e.data?.title??`Note`):a(e)||`document-${e.id}`;return(0,y.jsx)(_,{onClose:b,onDetails:x,title:(0,y.jsx)(`span`,{className:`truncate text-sm font-medium`,children:V}),actions:(0,y.jsxs)(y.Fragment,{children:[w&&(0,y.jsx)(m,{...j,onRetry:j.save}),(0,y.jsxs)(i,{size:`sm`,onClick:B,disabled:L||!z||E,children:[(0,y.jsx)(r,{className:`mr-1.5 h-4 w-4`}),L?`Saving…`:`Save`]})]}),children:(0,y.jsx)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-4 md:px-8`,children:(0,y.jsx)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-full flex-1 flex-col overflow-auto md:w-[700px] md:min-w-[320px] md:resize-x`,children:E?(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This file is too large to edit here (`,`>`,Math.round(l/1e3),` kB) — download it instead.`]}):O.error?(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:O.error}):z?(0,y.jsx)(g,{kind:w?`markdown`:D,value:M,onChange:N,placeholder:w?`Write your note…`:void 0,fill:!0}):(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading content…`})})})})}export{b as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ar as r,L as i,Nt as a,Pr as o,Ur as s,dr as c,fn as l,fr as u,pi as d,si as f,yt as p}from"./ui-Byg1cZDr.js";import{t as m}from"./utils-2pl1SbIp.js";import{Gn as h,On as g,wn as _}from"./workspace-DvxC7pw1.js";import{o as v,t as y}from"./useAddTarget-DUjaZdBQ.js";import{a as b,i as x,o as S,r as C,s as w,t as T}from"./date-time-picker-B6mkWt-g.js";import{n as E}from"./use-applet-target-cO-FiyPQ.js";import{n as D,r as O,t as k}from"./shared-D2uRUNdC.js";import{n as A,r as j,t as M}from"./use-applet-docs-o5NAUFBk.js";var N=e(n(),1),P=t(),F=`2.1`,I=new Set([`completed`,`cancelled`]);function L({doc:e,updateWorkspace:t,registerEl:n,registerBody:i,highlighted:a,onLinkTo:c,onDelete:u,onStatusSaved:d}){let[f,p]=(0,N.useState)(String(e.data?.title??``)),[h,v]=(0,N.useState)(String(e.data?.description??``)),[y,x]=(0,N.useState)(e.data?.status||`pending`),[w,E]=(0,N.useState)(b(e.data?.dueDate)),[O,j]=(0,N.useState)(`idle`),{replicating:F,label:L}=g(e),R=(0,N.useRef)({title:String(e.data?.title??``),description:String(e.data?.description??``)}),z=(0,N.useRef)(null),B=(0,N.useRef)(0),V=(0,N.useCallback)(async n=>{if(!t||!n.title.trim())return!1;let r=++B.current;j(`saving`);try{let i=S(n.due),a={...e.data||{},title:n.title.trim(),...n.description.trim()?{description:n.description.trim()}:{description:void 0},status:n.status,completed:n.status===`completed`};return i?a.dueDate=i:delete a.dueDate,await _(t,{id:e.id,schema:e.schema,schemaVersion:e.schemaVersion,data:a,metadata:e.metadata}),r!==B.current||(R.current={title:n.title,description:n.description},j(`saved`),setTimeout(()=>j(e=>e===`saved`?`idle`:e),1500),!0)}catch{return r===B.current&&j(`error`),!1}},[e.id,e.schema,e.schemaVersion,e.data,e.metadata,t]),H=(0,N.useCallback)((e,t)=>{(e!==R.current.title||t!==R.current.description)&&(j(`dirty`),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>V({title:e,description:t,status:y,due:w}),M))},[V,y,w]),U=(0,N.useCallback)(()=>{z.current&&=(clearTimeout(z.current),null),V({title:f,description:h,status:y,due:w})},[V,f,h,y,w]);(0,N.useEffect)(()=>()=>{z.current&&clearTimeout(z.current)},[]);let W=(0,N.useCallback)(async()=>{let t=y,n=y===`completed`?`pending`:`completed`;x(n),await V({title:f,description:h,status:n,due:w})?d(e.id,n):x(t)},[y,V,f,h,w,e.id,d]),G=(0,N.useCallback)(e=>{E(e),z.current&&=(clearTimeout(z.current),null),V({title:f,description:h,status:y,due:e})},[V,f,h,y]),K=I.has(y);return(0,P.jsxs)(`div`,{ref:t=>n(e.id,t),className:m(`group border-t border-border/60 px-4 py-3 transition-colors`,a&&`bg-primary/5`),children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:[(0,P.jsxs)(`span`,{className:`shrink-0`,children:[A(e.createdAt),` · #`,e.id,y!==`pending`&&(0,P.jsxs)(`span`,{children:[` · `,C[y]??y]})]}),(0,P.jsx)(T,{value:w,onChange:G,compact:!0,placeholder:`No due date`,className:`w-[168px] shrink-0 normal-case tracking-normal`})]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/70`,children:[O===`saving`&&(0,P.jsx)(l,{className:`inline h-3 w-3 animate-spin`}),F&&(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:L}),O===`saved`&&(0,P.jsx)(s,{className:`inline h-3 w-3 text-success`}),O===`dirty`&&`·`,O===`error`&&(0,P.jsx)(`span`,{className:`text-destructive`,children:`save failed`}),(0,P.jsx)(D,{onLinkTo:c,onDelete:u})]})]}),(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:W,className:`mt-0.5 shrink-0 text-muted-foreground transition-colors hover:text-foreground`,"aria-label":K?`Mark as pending`:`Mark as completed`,title:K?`Mark as pending`:`Mark as completed`,children:K?(0,P.jsx)(o,{className:`h-4 w-4 text-success`}):(0,P.jsx)(r,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`input`,{value:f,onChange:e=>{p(e.target.value),H(e.target.value,h)},onBlur:U,placeholder:`Untitled`,spellCheck:!1,className:m(`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold outline-none placeholder:text-muted-foreground/50`,K?`text-muted-foreground line-through`:`text-foreground`)}),(0,P.jsx)(k,{value:h,onChange:e=>{v(e),H(f,e)},onBlur:U,placeholder:`Description…`,innerRef:t=>i(e.id,t)})]})]})]})}function R({target:e,onCreated:t,onCancel:n}){let[r,a]=(0,N.useState)(``),[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(w()),[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(null);return(0,P.jsxs)(`div`,{className:`border-t border-border/60 bg-muted/30 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between`,children:[(0,P.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:`New todo`}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Discard draft`,children:(0,P.jsx)(i,{className:`h-3 w-3`})})]}),(0,P.jsx)(`input`,{value:r,onChange:e=>a(e.target.value),placeholder:`What needs doing?`,autoFocus:!0,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,P.jsx)(k,{value:o,onChange:s,placeholder:`Description (optional)…`}),(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsx)(T,{value:c,onChange:l,compact:!0,placeholder:`No due date`,className:`w-[188px]`})}),f&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:f}),(0,P.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!r.trim()||!e||u)){d(!0),p(null);try{await v(e,[{schema:h,schemaVersion:F,data:x({title:r,description:o,status:`pending`,priority:``,due:c}),metadata:{features:[]}}]),t()}catch(e){p(e instanceof Error?e.message:`Failed to create todo`),d(!1)}}},disabled:!r.trim()||u,className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground disabled:opacity-50`,children:u?`Saving…`:`Save todo`})})]})}function z({autoAdd:e=!1}){let t=E(),{docs:n,setDocs:r,loading:i,error:o,scope:s,reload:g,removeDoc:_}=j(t,h),[v,b]=(0,N.useState)(``),[x,S]=(0,N.useState)(0),[C,w]=(0,N.useState)(`desc`),[T,D]=(0,N.useState)(!1),[k,A]=(0,N.useState)(e),[M,F]=(0,N.useState)(null),z=(0,N.useRef)(new Map),B=(0,N.useRef)(new Map),V=(0,N.useCallback)((e,t)=>{t?z.current.set(e,t):z.current.delete(e)},[]),H=(0,N.useCallback)((e,t)=>{t?B.current.set(e,t):B.current.delete(e)},[]),U=(0,N.useCallback)(async e=>{let t=e.data?.title?`"${e.data.title}"`:`#${e.id}`;if(window.confirm(`Delete todo ${t}?\n\nIt is removed from this path and moves to the workspace trash if nothing else links it.`))try{await _(e.id)}catch{}},[_]),W=(0,N.useCallback)((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data||{},status:t,completed:t===`completed`}}:n))},[r]),G=(0,N.useMemo)(()=>{let e=T?[...n]:n.filter(e=>!I.has(String(e.data?.status??`pending`)));return e.sort((e,t)=>{let n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();return C===`asc`?n:-n}),e},[n,C,T]),K=(0,N.useMemo)(()=>n.filter(e=>I.has(String(e.data?.status??`pending`))).length,[n]),q=(0,N.useMemo)(()=>{let e=v.trim().toLowerCase();if(!e)return[];let t=[];for(let n of G){let r=String(n.data?.description??``),i=String(n.data?.title??``),a=r.toLowerCase().indexOf(e);a>=0?t.push({docId:n.id,offset:a}):i.toLowerCase().includes(e)&&t.push({docId:n.id,offset:-1})}return t},[v,G]),J=q.length?q[Math.min(x,q.length-1)]:null;(0,N.useEffect)(()=>{J&&z.current.get(J.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[J]);let Y=(0,N.useCallback)(e=>{if(!q.length)return;let t=e?(x+1)%q.length:x;e&&S(t);let n=q[t],r=B.current.get(n.docId);r&&n.offset>=0&&(r.focus(),r.setSelectionRange(n.offset,n.offset+v.trim().length)),z.current.get(n.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[q,x,v]);return t?(0,P.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(p,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,P.jsx)(`input`,{value:v,onChange:e=>{b(e.target.value),S(0)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Y(!0))},placeholder:`Search todos…`,spellCheck:!1,className:`w-full rounded-md border border-input bg-transparent py-1 pl-7 pr-14 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`}),v.trim()&&(0,P.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-[10px] tabular-nums text-muted-foreground`,children:q.length?`${Math.min(x+1,q.length)}/${q.length}`:`0/0`})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>D(e=>!e),className:m(`rounded-md border p-1.5 transition-colors`,T?`border-foreground text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),title:T?`Hide done items`:`Show done items${K?` (${K})`:``}`,"aria-label":T?`Hide done items`:`Show done items`,children:T?(0,P.jsx)(c,{className:`h-3.5 w-3.5`}):(0,P.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>w(e=>e===`desc`?`asc`:`desc`),className:`rounded-md border border-border p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:C===`desc`?`Newest first (click for oldest first)`:`Oldest first (click for newest first)`,"aria-label":`Toggle sort order`,children:C===`desc`?(0,P.jsx)(d,{className:`h-3.5 w-3.5`}):(0,P.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1.5 text-xs text-primary-foreground`,title:`Add a todo`,children:[(0,P.jsx)(a,{className:`h-3.5 w-3.5`}),`Todo`]})]}),(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[k&&(0,P.jsx)(R,{target:t,onCreated:()=>{A(!1),g()},onCancel:()=>A(!1)}),i&&!n.length&&(0,P.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,P.jsx)(l,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),o&&(0,P.jsx)(`p`,{className:`px-4 py-6 text-center text-sm text-destructive`,children:o}),!i&&!o&&!G.length&&!k&&(0,P.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:K?`Nothing pending - ${K} done item${K>1?`s`:``} hidden.`:`No todos here yet - add the first one.`}),G.map(e=>(0,P.jsx)(L,{doc:e,updateWorkspace:s?.workspaceName??null,registerEl:V,registerBody:H,highlighted:J?.docId===e.id,onLinkTo:()=>F(e.id),onDelete:()=>U(e),onStatusSaved:W},e.id))]}),M!==null&&(0,P.jsx)(O,{documentId:M,workspaceName:s?.workspaceName,onClose:()=>F(null)})]}):(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:y(t)})}export{z as TodosApplet};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ar as r,L as i,Nt as a,Pr as o,Ur as s,dr as c,fn as l,fr as u,pi as d,si as f,yt as p}from"./ui-Byg1cZDr.js";import{t as m}from"./utils-2pl1SbIp.js";import{Vn as h,bn as g,wn as _}from"./workspace-CrSpR4xf.js";import{o as v,t as y}from"./useAddTarget-CqnDU0Om.js";import{a as b,i as x,o as S,r as C,s as w,t as T}from"./date-time-picker-DebNUTx3.js";import{n as E}from"./use-applet-target-gXPvZGgx.js";import{n as D,r as O,t as k}from"./shared-BQZGA3ph.js";import{n as A,r as j,t as M}from"./use-applet-docs-D5eXpITp.js";var N=e(n(),1),P=t(),F=`2.1`,I=new Set([`completed`,`cancelled`]);function L({doc:e,updateWorkspace:t,registerEl:n,registerBody:i,highlighted:a,onLinkTo:c,onDelete:u,onStatusSaved:d}){let[f,p]=(0,N.useState)(String(e.data?.title??``)),[h,v]=(0,N.useState)(String(e.data?.description??``)),[y,x]=(0,N.useState)(e.data?.status||`pending`),[w,E]=(0,N.useState)(b(e.data?.dueDate)),[O,j]=(0,N.useState)(`idle`),{replicating:F,label:L}=_(e),R=(0,N.useRef)({title:String(e.data?.title??``),description:String(e.data?.description??``)}),z=(0,N.useRef)(null),B=(0,N.useRef)(0),V=(0,N.useCallback)(async n=>{if(!t||!n.title.trim())return!1;let r=++B.current;j(`saving`);try{let i=S(n.due),a={...e.data||{},title:n.title.trim(),...n.description.trim()?{description:n.description.trim()}:{description:void 0},status:n.status,completed:n.status===`completed`};return i?a.dueDate=i:delete a.dueDate,await g(t,{id:e.id,schema:e.schema,schemaVersion:e.schemaVersion,data:a,metadata:e.metadata}),r!==B.current||(R.current={title:n.title,description:n.description},j(`saved`),setTimeout(()=>j(e=>e===`saved`?`idle`:e),1500),!0)}catch{return r===B.current&&j(`error`),!1}},[e.id,e.schema,e.schemaVersion,e.data,e.metadata,t]),H=(0,N.useCallback)((e,t)=>{(e!==R.current.title||t!==R.current.description)&&(j(`dirty`),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>V({title:e,description:t,status:y,due:w}),M))},[V,y,w]),U=(0,N.useCallback)(()=>{z.current&&=(clearTimeout(z.current),null),V({title:f,description:h,status:y,due:w})},[V,f,h,y,w]);(0,N.useEffect)(()=>()=>{z.current&&clearTimeout(z.current)},[]);let W=(0,N.useCallback)(async()=>{let t=y,n=y===`completed`?`pending`:`completed`;x(n),await V({title:f,description:h,status:n,due:w})?d(e.id,n):x(t)},[y,V,f,h,w,e.id,d]),G=(0,N.useCallback)(e=>{E(e),z.current&&=(clearTimeout(z.current),null),V({title:f,description:h,status:y,due:e})},[V,f,h,y]),K=I.has(y);return(0,P.jsxs)(`div`,{ref:t=>n(e.id,t),className:m(`group border-t border-border/60 px-4 py-3 transition-colors`,a&&`bg-primary/5`),children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:[(0,P.jsxs)(`span`,{className:`shrink-0`,children:[A(e.createdAt),` · #`,e.id,y!==`pending`&&(0,P.jsxs)(`span`,{children:[` · `,C[y]??y]})]}),(0,P.jsx)(T,{value:w,onChange:G,compact:!0,placeholder:`No due date`,className:`w-[168px] shrink-0 normal-case tracking-normal`})]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/70`,children:[O===`saving`&&(0,P.jsx)(l,{className:`inline h-3 w-3 animate-spin`}),F&&(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:L}),O===`saved`&&(0,P.jsx)(s,{className:`inline h-3 w-3 text-success`}),O===`dirty`&&`·`,O===`error`&&(0,P.jsx)(`span`,{className:`text-destructive`,children:`save failed`}),(0,P.jsx)(D,{onLinkTo:c,onDelete:u})]})]}),(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:W,className:`mt-0.5 shrink-0 text-muted-foreground transition-colors hover:text-foreground`,"aria-label":K?`Mark as pending`:`Mark as completed`,title:K?`Mark as pending`:`Mark as completed`,children:K?(0,P.jsx)(o,{className:`h-4 w-4 text-success`}):(0,P.jsx)(r,{className:`h-4 w-4`})}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`input`,{value:f,onChange:e=>{p(e.target.value),H(e.target.value,h)},onBlur:U,placeholder:`Untitled`,spellCheck:!1,className:m(`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold outline-none placeholder:text-muted-foreground/50`,K?`text-muted-foreground line-through`:`text-foreground`)}),(0,P.jsx)(k,{value:h,onChange:e=>{v(e),H(f,e)},onBlur:U,placeholder:`Description…`,innerRef:t=>i(e.id,t)})]})]})]})}function R({target:e,onCreated:t,onCancel:n}){let[r,a]=(0,N.useState)(``),[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(w()),[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(null);return(0,P.jsxs)(`div`,{className:`border-t border-border/60 bg-muted/30 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between`,children:[(0,P.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:`New todo`}),(0,P.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Discard draft`,children:(0,P.jsx)(i,{className:`h-3 w-3`})})]}),(0,P.jsx)(`input`,{value:r,onChange:e=>a(e.target.value),placeholder:`What needs doing?`,autoFocus:!0,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,P.jsx)(k,{value:o,onChange:s,placeholder:`Description (optional)…`}),(0,P.jsx)(`div`,{className:`mt-2`,children:(0,P.jsx)(T,{value:c,onChange:l,compact:!0,placeholder:`No due date`,className:`w-[188px]`})}),f&&(0,P.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:f}),(0,P.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{if(!(!r.trim()||!e||u)){d(!0),p(null);try{await v(e,[{schema:h,schemaVersion:F,data:x({title:r,description:o,status:`pending`,priority:``,due:c}),metadata:{features:[]}}]),t()}catch(e){p(e instanceof Error?e.message:`Failed to create todo`),d(!1)}}},disabled:!r.trim()||u,className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground disabled:opacity-50`,children:u?`Saving…`:`Save todo`})})]})}function z({autoAdd:e=!1}){let t=E(),{docs:n,setDocs:r,loading:i,error:o,scope:s,reload:g,removeDoc:_}=j(t,h),[v,b]=(0,N.useState)(``),[x,S]=(0,N.useState)(0),[C,w]=(0,N.useState)(`desc`),[T,D]=(0,N.useState)(!1),[k,A]=(0,N.useState)(e),[M,F]=(0,N.useState)(null),z=(0,N.useRef)(new Map),B=(0,N.useRef)(new Map),V=(0,N.useCallback)((e,t)=>{t?z.current.set(e,t):z.current.delete(e)},[]),H=(0,N.useCallback)((e,t)=>{t?B.current.set(e,t):B.current.delete(e)},[]),U=(0,N.useCallback)(async e=>{let t=e.data?.title?`"${e.data.title}"`:`#${e.id}`;if(window.confirm(`Delete todo ${t}?\n\nIt is removed from this path and moves to the workspace trash if nothing else links it.`))try{await _(e.id)}catch{}},[_]),W=(0,N.useCallback)((e,t)=>{r(n=>n.map(n=>n.id===e?{...n,data:{...n.data||{},status:t,completed:t===`completed`}}:n))},[r]),G=(0,N.useMemo)(()=>{let e=T?[...n]:n.filter(e=>!I.has(String(e.data?.status??`pending`)));return e.sort((e,t)=>{let n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();return C===`asc`?n:-n}),e},[n,C,T]),K=(0,N.useMemo)(()=>n.filter(e=>I.has(String(e.data?.status??`pending`))).length,[n]),q=(0,N.useMemo)(()=>{let e=v.trim().toLowerCase();if(!e)return[];let t=[];for(let n of G){let r=String(n.data?.description??``),i=String(n.data?.title??``),a=r.toLowerCase().indexOf(e);a>=0?t.push({docId:n.id,offset:a}):i.toLowerCase().includes(e)&&t.push({docId:n.id,offset:-1})}return t},[v,G]),J=q.length?q[Math.min(x,q.length-1)]:null;(0,N.useEffect)(()=>{J&&z.current.get(J.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[J]);let Y=(0,N.useCallback)(e=>{if(!q.length)return;let t=e?(x+1)%q.length:x;e&&S(t);let n=q[t],r=B.current.get(n.docId);r&&n.offset>=0&&(r.focus(),r.setSelectionRange(n.offset,n.offset+v.trim().length)),z.current.get(n.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[q,x,v]);return t?(0,P.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(p,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,P.jsx)(`input`,{value:v,onChange:e=>{b(e.target.value),S(0)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Y(!0))},placeholder:`Search todos…`,spellCheck:!1,className:`w-full rounded-md border border-input bg-transparent py-1 pl-7 pr-14 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`}),v.trim()&&(0,P.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-[10px] tabular-nums text-muted-foreground`,children:q.length?`${Math.min(x+1,q.length)}/${q.length}`:`0/0`})]}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>D(e=>!e),className:m(`rounded-md border p-1.5 transition-colors`,T?`border-foreground text-foreground`:`border-border text-muted-foreground hover:bg-muted hover:text-foreground`),title:T?`Hide done items`:`Show done items${K?` (${K})`:``}`,"aria-label":T?`Hide done items`:`Show done items`,children:T?(0,P.jsx)(c,{className:`h-3.5 w-3.5`}):(0,P.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>w(e=>e===`desc`?`asc`:`desc`),className:`rounded-md border border-border p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:C===`desc`?`Newest first (click for oldest first)`:`Oldest first (click for newest first)`,"aria-label":`Toggle sort order`,children:C===`desc`?(0,P.jsx)(d,{className:`h-3.5 w-3.5`}):(0,P.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1.5 text-xs text-primary-foreground`,title:`Add a todo`,children:[(0,P.jsx)(a,{className:`h-3.5 w-3.5`}),`Todo`]})]}),(0,P.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[k&&(0,P.jsx)(R,{target:t,onCreated:()=>{A(!1),g()},onCancel:()=>A(!1)}),i&&!n.length&&(0,P.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,P.jsx)(l,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),o&&(0,P.jsx)(`p`,{className:`px-4 py-6 text-center text-sm text-destructive`,children:o}),!i&&!o&&!G.length&&!k&&(0,P.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:K?`Nothing pending - ${K} done item${K>1?`s`:``} hidden.`:`No todos here yet - add the first one.`}),G.map(e=>(0,P.jsx)(L,{doc:e,updateWorkspace:s?.workspaceName??null,registerEl:V,registerBody:H,highlighted:J?.docId===e.id,onLinkTo:()=>F(e.id),onDelete:()=>U(e),onStatusSaved:W},e.id))]}),M!==null&&(0,P.jsx)(O,{documentId:M,workspaceName:s?.workspaceName,onClose:()=>F(null)})]}):(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:y(t)})}export{z as TodosApplet};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ur as r,fn as i,mn as a,qr as o,tr as s}from"./ui-Byg1cZDr.js";import{Gn as c,On as l}from"./workspace-DvxC7pw1.js";import{_ as u,g as d,h as f,m as p,p as m}from"./ObjectPropertiesCard-ChvWbOpZ.js";import{r as h}from"./date-time-picker-B6mkWt-g.js";import{n as g}from"./use-document-modal-PG8bQyIB.js";var _=e(n(),1),v=new Map;function y(e){v.set(e.type,e)}function b(e){return v.get(e)}function x(){return[...v.values()]}var S=450,C=10;function w(e,t){let{open:n}=g(),r=(0,_.useRef)(null),i=(0,_.useRef)(null),a=(0,_.useRef)(!1),o=()=>{e&&n(e,t)},s=()=>{r.current&&=(clearTimeout(r.current),null)};return{activationProps:{role:`button`,tabIndex:0,onClick:()=>{if(a.current){a.current=!1;return}o()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},onContextMenu:e=>{e.preventDefault(),o()},onPointerDown:e=>{e.pointerType===`touch`&&(i.current={x:e.clientX,y:e.clientY},a.current=!1,s(),r.current=setTimeout(()=>{a.current=!0,o()},S))},onPointerMove:e=>{i.current&&Math.hypot(e.clientX-i.current.x,e.clientY-i.current.y)>C&&s()},onPointerUp:s,onPointerCancel:s,onPointerLeave:s},stopRowActivation:e=>e.stopPropagation()}}var T=t(),E=`data/schema/task`;function D({doc:e,workspaceId:t,readOnly:n,onChanged:a}){let c=u(e),[g,v]=(0,_.useState)(!1),{replicating:y,label:b}=l(e),x=c.status===`completed`,S=c.status??`pending`,C=f(c),{activationProps:E,stopRowActivation:D}=w(e,t),O=async()=>{if(!(n||g)){v(!0);try{await d(t,e,x?`pending`:`completed`),a()}catch{}finally{v(!1)}}};return(0,T.jsxs)(`div`,{...E,title:`Open details`,className:`canvas-no-drag flex cursor-pointer items-start gap-2.5 rounded-md border bg-card px-2.5 py-2 transition-colors hover:bg-accent/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${y?`opacity-60`:``}`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:e=>{D(e),O()},disabled:n||g||y,"aria-pressed":x,title:x?`Mark not done`:`Mark done`,className:`canvas-no-drag mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-colors ${x?`border-success bg-success text-success-foreground`:`border-input hover:border-success`} ${n?`cursor-default opacity-70`:``}`,children:g?(0,T.jsx)(i,{className:`h-2.5 w-2.5 animate-spin`}):x&&(0,T.jsx)(r,{className:`h-3 w-3`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate text-sm ${x?`text-muted-foreground line-through`:``}`,children:c.title||`Todo ${e.id}`}),(0,T.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,T.jsx)(`span`,{className:`rounded-full px-1.5 py-0.5 ${m[S]}`,children:h[S]}),c.dueDate&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 ${C?`font-medium text-destructive`:`text-muted-foreground`}`,children:[(0,T.jsx)(o,{className:`h-3 w-3`}),p(c.dueDate)]}),typeof c.priority==`number`&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-muted-foreground`,children:[(0,T.jsx)(s,{className:`h-3 w-3`}),`P`,c.priority]}),y&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(i,{className:`h-3 w-3 animate-spin`}),b]})]})]})]})}function O({config:e,setConfig:t,canvas:n}){let r=typeof e.pageSize==`number`?e.pageSize:50,[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!0),[l,d]=(0,_.useState)(0),f=n.interactive===!1,p=n.readOnly!==!0,[m,h]=(0,_.useState)(e.hideDone===!0),g=p?e.hideDone===!0:m,v=n=>{p?t({...e,hideDone:n}):h(n)};(0,_.useEffect)(()=>{let e=!1;return(async()=>{s(!0);try{let t=await n.fetchDocuments({limit:r,allOf:[E],sortBy:`tasks`,order:`asc`});if(e)return;a((t.payload||[]).filter(e=>e.schema===c))}catch{e||a([])}finally{e||s(!1)}})(),()=>{e=!0}},[n,r,l]),(0,_.useEffect)(()=>{let e=()=>d(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]);let y=(0,_.useCallback)(()=>d(e=>e+1),[]),b=g?i.filter(e=>u(e).status!==`completed`):i,x=i.filter(e=>{let t=u(e).status;return t!==`completed`&&t!==`cancelled`}).length;return(0,T.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,T.jsxs)(`div`,{className:`canvas-no-drag flex items-center justify-between gap-2 border-b px-1 pb-2`,children:[(0,T.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[x,` open`]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>v(e.target.checked),className:`h-3 w-3`}),`Hide done`]})]}),(0,T.jsx)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto p-1`,children:o&&i.length===0?(0,T.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:`Loading todos…`}):b.length===0?(0,T.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:`No todos in this canvas' context.`}):b.map(e=>(0,T.jsx)(D,{doc:e,workspaceId:n.workspaceId,readOnly:f,onChanged:y},e.id))})]})}y({type:`todos`,name:`Todos`,icon:a,defaultSize:{w:4,h:6,minW:3,minH:3},mobileHeight:.6,defaultConfig:{pageSize:50,hideDone:!1},component:O});export{y as a,x as i,w as n,b as r,D as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ur as r,fn as i,mn as a,qr as o,tr as s}from"./ui-Byg1cZDr.js";import{Vn as c,wn as l}from"./workspace-CrSpR4xf.js";import{_ as u,g as d,h as f,m as p,p as m}from"./ObjectPropertiesCard-BIBMvx_i.js";import{r as h}from"./date-time-picker-DebNUTx3.js";import{n as g}from"./use-document-modal-PG8bQyIB.js";var _=e(n(),1),v=new Map;function y(e){v.set(e.type,e)}function b(e){return v.get(e)}function x(){return[...v.values()]}var S=450,C=10;function w(e,t){let{open:n}=g(),r=(0,_.useRef)(null),i=(0,_.useRef)(null),a=(0,_.useRef)(!1),o=()=>{e&&n(e,t)},s=()=>{r.current&&=(clearTimeout(r.current),null)};return{activationProps:{role:`button`,tabIndex:0,onClick:()=>{if(a.current){a.current=!1;return}o()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},onContextMenu:e=>{e.preventDefault(),o()},onPointerDown:e=>{e.pointerType===`touch`&&(i.current={x:e.clientX,y:e.clientY},a.current=!1,s(),r.current=setTimeout(()=>{a.current=!0,o()},S))},onPointerMove:e=>{i.current&&Math.hypot(e.clientX-i.current.x,e.clientY-i.current.y)>C&&s()},onPointerUp:s,onPointerCancel:s,onPointerLeave:s},stopRowActivation:e=>e.stopPropagation()}}var T=t(),E=`data/schema/task`;function D({doc:e,workspaceId:t,readOnly:n,onChanged:a}){let c=u(e),[g,v]=(0,_.useState)(!1),{replicating:y,label:b}=l(e),x=c.status===`completed`,S=c.status??`pending`,C=f(c),{activationProps:E,stopRowActivation:D}=w(e,t),O=async()=>{if(!(n||g)){v(!0);try{await d(t,e,x?`pending`:`completed`),a()}catch{}finally{v(!1)}}};return(0,T.jsxs)(`div`,{...E,title:`Open details`,className:`canvas-no-drag flex cursor-pointer items-start gap-2.5 rounded-md border bg-card px-2.5 py-2 transition-colors hover:bg-accent/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring ${y?`opacity-60`:``}`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:e=>{D(e),O()},disabled:n||g||y,"aria-pressed":x,title:x?`Mark not done`:`Mark done`,className:`canvas-no-drag mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-colors ${x?`border-success bg-success text-success-foreground`:`border-input hover:border-success`} ${n?`cursor-default opacity-70`:``}`,children:g?(0,T.jsx)(i,{className:`h-2.5 w-2.5 animate-spin`}):x&&(0,T.jsx)(r,{className:`h-3 w-3`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsx)(`div`,{className:`truncate text-sm ${x?`text-muted-foreground line-through`:``}`,children:c.title||`Todo ${e.id}`}),(0,T.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,T.jsx)(`span`,{className:`rounded-full px-1.5 py-0.5 ${m[S]}`,children:h[S]}),c.dueDate&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 ${C?`font-medium text-destructive`:`text-muted-foreground`}`,children:[(0,T.jsx)(o,{className:`h-3 w-3`}),p(c.dueDate)]}),typeof c.priority==`number`&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-muted-foreground`,children:[(0,T.jsx)(s,{className:`h-3 w-3`}),`P`,c.priority]}),y&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,role:`status`,children:[(0,T.jsx)(i,{className:`h-3 w-3 animate-spin`}),b]})]})]})]})}function O({config:e,setConfig:t,canvas:n}){let r=typeof e.pageSize==`number`?e.pageSize:50,[i,a]=(0,_.useState)([]),[o,s]=(0,_.useState)(!0),[l,d]=(0,_.useState)(0),f=n.interactive===!1,p=n.readOnly!==!0,[m,h]=(0,_.useState)(e.hideDone===!0),g=p?e.hideDone===!0:m,v=n=>{p?t({...e,hideDone:n}):h(n)};(0,_.useEffect)(()=>{let e=!1;return(async()=>{s(!0);try{let t=await n.fetchDocuments({limit:r,allOf:[E],sortBy:`tasks`,order:`asc`});if(e)return;a((t.payload||[]).filter(e=>e.schema===c))}catch{e||a([])}finally{e||s(!1)}})(),()=>{e=!0}},[n,r,l]),(0,_.useEffect)(()=>{let e=()=>d(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]);let y=(0,_.useCallback)(()=>d(e=>e+1),[]),b=g?i.filter(e=>u(e).status!==`completed`):i,x=i.filter(e=>{let t=u(e).status;return t!==`completed`&&t!==`cancelled`}).length;return(0,T.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,T.jsxs)(`div`,{className:`canvas-no-drag flex items-center justify-between gap-2 border-b px-1 pb-2`,children:[(0,T.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[x,` open`]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>v(e.target.checked),className:`h-3 w-3`}),`Hide done`]})]}),(0,T.jsx)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto p-1`,children:o&&i.length===0?(0,T.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:`Loading todos…`}):b.length===0?(0,T.jsx)(`div`,{className:`p-3 text-sm text-muted-foreground`,children:`No todos in this canvas' context.`}):b.map(e=>(0,T.jsx)(D,{doc:e,workspaceId:n.workspaceId,readOnly:f,onChanged:y},e.id))})]})}y({type:`todos`,name:`Todos`,icon:a,defaultSize:{w:4,h:6,minW:3,minH:3},mobileHeight:.6,defaultConfig:{pageSize:50,hideDone:!1},component:O});export{y as a,x as i,w as n,b as r,D as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ir as r,L as i,Ur as a,an as o,fn as s,ir as c,on as l}from"./ui-Byg1cZDr.js";import{t as u}from"./utils-2pl1SbIp.js";import{t as d}from"./button-SgR3GVvV.js";import{t as f}from"./label-Dn4gCMcc.js";import{At as p}from"./workspace-DvxC7pw1.js";import{o as m,s as h}from"./IdentityFields-OPEWPlZs.js";import{n as g}from"./tags-YamdPoBK.js";import{a as _,i as v,l as y,o as b,r as x}from"./useAddTarget-DUjaZdBQ.js";import{r as S}from"./relation-events-CKio19hE.js";import{a as C,n as w,r as T}from"./blobs-WiXP9QRi.js";import{t as E}from"./sha256-65KIjGvZ.js";var D=e(n(),1);function O(e){let[t,n]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(!e)return;let t=!1;return p(e).then(r=>{t||n({workspace:e,tags:r})}).catch(()=>{}),()=>{t=!0}},[e]),t&&t.workspace===e?t.tags:[]}var k=t();function A(e){if(e.manual){let t=`${e.manual.lat.toFixed(5)}, ${e.manual.lon.toFixed(5)}`;return e.manualLabel?`${e.manualLabel} · ${t}`:`Custom pin · ${t}`}if(!e.supported)return`Needs a secure (https) connection, or pick a point on the map`;if(e.permission===`denied`)return`Blocked. Allow location for this site, or pick a point on the map`;if(e.error)return e.error;if(e.busy)return`Getting your location…`;if(e.enabled&&e.fix){let{lat:t,lon:n,accuracy:r}=e.fix;return`${t.toFixed(5)}, ${n.toFixed(5)}${r==null?``:` · ±${r} m`}`}return e.enabled?`Location will be attached when you save`:`Attach where you are, or pick any point on the map`}function j({geotag:e,idPrefix:t=`geotag`}){let[n,r]=(0,D.useState)(!1),a=!e.supported||e.permission===`denied`,c=!e.manual&&(!e.supported||e.permission===`denied`||!!e.error);return(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{role:`switch`,"aria-checked":e.enabled,"aria-disabled":a,"aria-label":`Geotag this document`,"aria-describedby":`${t}-hint`,tabIndex:a?-1:0,onClick:()=>!a&&e.setEnabled(!e.enabled),onKeyDown:t=>{a||(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),e.setEnabled(!e.enabled))},className:u(`flex flex-1 items-center justify-between gap-3 select-none outline-none rounded focus-visible:ring-2 focus-visible:ring-ring`,a?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[e.busy?(0,k.jsx)(s,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):(0,k.jsx)(l,{className:u(`h-4 w-4 shrink-0`,e.enabled?`text-info`:`text-muted-foreground`)}),`Geotag`]}),(0,k.jsx)(`div`,{className:u(`relative h-5 w-10 shrink-0 rounded-full transition-colors`,e.enabled?`bg-info`:`bg-muted-foreground/30`),children:(0,k.jsx)(`div`,{className:u(`absolute top-[2px] h-4 w-4 rounded-full bg-background shadow-elevation-1 transition-transform`,e.enabled?`translate-x-[22px]`:`translate-x-[2px]`)})})]}),(0,k.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),title:`Pick a point on the map`,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,k.jsx)(o,{className:`h-3.5 w-3.5`}),e.manual?`Change pin`:`Pick on map`]}),e.manual&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>e.setManual(null),"aria-label":`Remove custom pin`,title:`Remove custom pin`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,k.jsx)(i,{className:`h-3.5 w-3.5`})})]})]}),(0,k.jsx)(`p`,{id:`${t}-hint`,className:u(`text-xs`,c?`text-warning`:`text-muted-foreground`),children:A(e)}),n&&(0,k.jsx)(m,{initial:e.manual??e.fix??null,onPick:t=>e.setManual(t),onClose:()=>r(!1)})]})}var M=`data/schema/file`,N=`3.0`;function P(e){let[t,n]=(0,D.useState)([]),[r,i]=(0,D.useState)(``);return{tags:t,setTags:n,comment:r,setComment:i,suggestions:O(e),geotag:S()}}function F(e,t,n={}){let r=g(n.tags??[]),i=n.comment?.trim();return{schema:M,schemaVersion:N,data:{},checksumArray:[`sha256/${e.checksum}`],locations:[{url:e.url,metadata:{filename:t.name}}],...i?{comment:i}:{},metadata:{contentType:t.type,size:e.size,...r.length?{features:r}:{},...n.geo?{geo:n.geo}:{}}}}var I=`flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;function L({fields:e,idPrefix:t=`file`,multiple:n=!1}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsx)(f,{children:`Tags`}),(0,k.jsx)(h,{tags:e.tags,onChange:e.setTags,suggestions:e.suggestions})]}),(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsx)(f,{htmlFor:`${t}-comment`,children:`Comment`}),(0,k.jsx)(`textarea`,{id:`${t}-comment`,value:e.comment,onChange:t=>e.setComment(t.target.value),rows:3,placeholder:`Optional; searchable, and the only text a photo has`,className:I}),n&&e.tags.length+e.comment.trim().length>0&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Applied to every file in this upload`})]}),(0,k.jsx)(j,{geotag:e.geotag,idPrefix:`${t}-geotag`})]})}var R=3;function z(e){return`${e.name}:${e.size}:${e.lastModified}`}function B(e=[]){let[t,n]=(0,D.useState)(()=>e.map(e=>({id:z(e),file:e,status:`queued`,progress:0}))),[r,i]=(0,D.useState)(!1),a=(0,D.useRef)(t),o=(0,D.useRef)(null),s=(0,D.useRef)(null);(0,D.useEffect)(()=>()=>s.current?.abort(),[]);let c=(0,D.useCallback)(e=>{a.current=e,n(e)},[]),l=(0,D.useCallback)((e,t)=>{let r=a.current.map(n=>n.id===e?{...n,...t}:n);a.current=r,n(r)},[]),u=(0,D.useCallback)(e=>{let t=new Set(a.current.map(e=>e.id)),n=e.filter(e=>!t.has(z(e))).map(e=>({id:z(e),file:e,status:`queued`,progress:0}));n.length&&c([...a.current,...n])},[c]),d=(0,D.useCallback)(e=>{c(a.current.filter(t=>t.id!==e))},[c]),f=(0,D.useCallback)(()=>{s.current?.abort(),s.current=null,c([]),i(!1)},[c]),p=(0,D.useCallback)(()=>{s.current?.abort()},[]);return{items:t,running:r,addFiles:u,removeItem:d,reset:f,start:(0,D.useCallback)(async(e,t)=>{if(!e)throw Error(`No active workspace or context to add to`);let{workspaceName:n,treeName:r,path:u}=await _(e),d=r===`backends`?await v(n,u):null,f=JSON.stringify([n,r,u]);o.current!==null&&o.current!==f&&c(a.current.map(({id:e,file:t})=>({id:e,file:t,status:`queued`,progress:0}))),o.current=f;let p=new AbortController;s.current=p,i(!0);let m=a.current.filter(e=>e.status!==`done`);for(let e of m)l(e.id,{status:`queued`,progress:0,error:void 0});try{if(d){let e=0;await Promise.all(Array.from({length:Math.min(R,m.length)},async()=>{for(;e<m.length&&!p.signal.aborted;){let t=m[e++];try{l(t.id,{status:`uploading`,progress:0,resumed:!1});let e=await T(n,{...d,key:y(d.key,t.file.name)},t.file,{signal:p.signal,onProgress:(e,n)=>l(t.id,{progress:n?e/n:0})});l(t.id,{status:`done`,progress:1,docId:e.docId??void 0})}catch(e){l(t.id,{status:`error`,error:e instanceof Error?e.message:`Upload failed`})}}}))}else{let r=new Map;for(let e of m){if(p.signal.aborted)throw new DOMException(`cancelled`,`AbortError`);if(!(e.file.size>=8388608)){l(e.id,{status:`hashing`});try{let t=await E(e.file,t=>l(e.id,{progress:t}));r.set(e.id,t),l(e.id,{status:`checking`,progress:0})}catch(t){l(e.id,{status:`error`,error:t instanceof Error?t.message:`Failed to read file`})}}}let i={};if(r.size)try{i=await w(n,[...new Set(r.values())])}catch{i={}}let a=m.filter(e=>r.has(e.id)||e.file.size>=8388608),o=0;await Promise.all(Array.from({length:Math.min(R,a.length)},async()=>{for(;o<a.length;){if(p.signal.aborted)return;let s=a[o++],c=r.get(s.id);try{let r=c?i[c]??null:null;r?l(s.id,{status:`linking`,progress:1,resumed:!0}):(l(s.id,{status:`uploading`,progress:0}),r=await C(n,s.file,{sha256:c,signal:p.signal,onProgress:(e,t)=>l(s.id,{progress:t?e/t:0})}),l(s.id,{status:`linking`,progress:1}));let a=await b(e,[t(r,s.file)],{refresh:!1});l(s.id,{status:`done`,docId:a[0]})}catch(e){let t=e instanceof DOMException&&e.name===`AbortError`;l(s.id,{status:`error`,error:t?`Cancelled`:e instanceof Error?e.message:`Upload failed`})}}}))}}finally{if(p.signal.aborted)for(let e of a.current)e.status!==`done`&&e.status!==`error`&&l(e.id,{status:`error`,error:`Cancelled`});i(!1),s.current===p&&(s.current=null),a.current.some(e=>e.status===`done`)&&x(e)}let h=a.current;return{done:h.filter(e=>e.status===`done`).length,resumed:h.filter(e=>e.status===`done`&&e.resumed).length,failed:h.filter(e=>e.status===`error`).length,total:h.length,docIds:h.flatMap(e=>e.status===`done`&&e.docId!=null?[e.docId]:[])}},[l,c]),cancel:p}}function V(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function H(e){switch(e.status){case`hashing`:return`hashing`;case`checking`:return`checking`;case`uploading`:return`${Math.round(e.progress*100)}%`;case`linking`:return`saving`;case`done`:return e.resumed?`already uploaded`:`done`;case`error`:return e.error||`failed`;default:return V(e.file.size)}}function U({item:e}){switch(e.status){case`done`:return(0,k.jsx)(a,{className:`h-3.5 w-3.5 shrink-0 text-green-600 dark:text-green-500`});case`error`:return(0,k.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-destructive`});case`queued`:return(0,k.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`});default:return(0,k.jsx)(s,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`})}}function W({item:e}){if(e.status===`queued`)return null;let t=e.status===`done`||e.status===`error`||e.status===`linking`?1:e.status===`checking`?0:e.progress;return(0,k.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,k.jsx)(`div`,{className:u(`h-full rounded-full transition-[width] duration-normal`,e.status===`error`?`bg-destructive`:e.status===`done`?`bg-green-600 dark:bg-green-500`:`bg-primary`),style:{width:`${Math.round(t*100)}%`}})})}function G({items:e,running:t,onRemove:n}){let r=e.filter(e=>e.status===`done`).length,a=e.filter(e=>e.status===`error`).length;return(0,k.jsx)(k.Fragment,{children:e.length>0&&(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsxs)(f,{children:[e.length,` file(s)`,r>0&&(0,k.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`— `,r,` done`,a>0?`, ${a} failed`:``]})]}),(0,k.jsx)(`ul`,{className:`max-h-48 space-y-1 overflow-y-auto`,children:e.map(e=>(0,k.jsxs)(`li`,{className:`flex flex-col gap-1 rounded border border-input px-2 py-1 text-sm`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(U,{item:e}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,title:e.file.name,children:e.file.name}),(0,k.jsx)(`span`,{className:u(`shrink-0 text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),title:e.status===`error`?e.error:void 0,children:H(e)}),!t&&e.status!==`done`&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Remove ${e.file.name}`,children:(0,k.jsx)(i,{className:`h-3.5 w-3.5`})})]}),(0,k.jsx)(W,{item:e})]},e.id))})]})})}function K({items:e,running:t,onCancel:n}){return(0,k.jsxs)(`div`,{className:`space-y-4 overflow-y-auto p-4`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-medium`,children:`Uploading files`}),!t&&(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Preparing / finishing upload…`}),(0,k.jsx)(G,{items:e,running:!0,onRemove:()=>{}}),(0,k.jsx)(d,{variant:`outline`,size:`sm`,disabled:!t,onClick:n,children:`Cancel upload`})]})}export{F as a,O as c,L as i,K as n,P as o,B as r,j as s,G as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ir as r,L as i,Ur as a,an as o,fn as s,ir as c,on as l}from"./ui-Byg1cZDr.js";import{t as u}from"./utils-2pl1SbIp.js";import{t as d}from"./button-SgR3GVvV.js";import{t as f}from"./label-Dn4gCMcc.js";import{At as p}from"./workspace-CrSpR4xf.js";import{o as m,s as h}from"./IdentityFields-Bti7ojF3.js";import{n as g}from"./tags-YamdPoBK.js";import{a as _,i as v,l as y,o as b,r as x}from"./useAddTarget-CqnDU0Om.js";import{r as S}from"./relation-events-CKio19hE.js";import{a as C,n as w,r as T}from"./blobs-WiXP9QRi.js";import{t as E}from"./sha256-65KIjGvZ.js";var D=e(n(),1);function O(e){let[t,n]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(!e)return;let t=!1;return p(e).then(r=>{t||n({workspace:e,tags:r})}).catch(()=>{}),()=>{t=!0}},[e]),t&&t.workspace===e?t.tags:[]}var k=t();function A(e){if(e.manual){let t=`${e.manual.lat.toFixed(5)}, ${e.manual.lon.toFixed(5)}`;return e.manualLabel?`${e.manualLabel} · ${t}`:`Custom pin · ${t}`}if(!e.supported)return`Needs a secure (https) connection, or pick a point on the map`;if(e.permission===`denied`)return`Blocked. Allow location for this site, or pick a point on the map`;if(e.error)return e.error;if(e.busy)return`Getting your location…`;if(e.enabled&&e.fix){let{lat:t,lon:n,accuracy:r}=e.fix;return`${t.toFixed(5)}, ${n.toFixed(5)}${r==null?``:` · ±${r} m`}`}return e.enabled?`Location will be attached when you save`:`Attach where you are, or pick any point on the map`}function j({geotag:e,idPrefix:t=`geotag`}){let[n,r]=(0,D.useState)(!1),a=!e.supported||e.permission===`denied`,c=!e.manual&&(!e.supported||e.permission===`denied`||!!e.error);return(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{role:`switch`,"aria-checked":e.enabled,"aria-disabled":a,"aria-label":`Geotag this document`,"aria-describedby":`${t}-hint`,tabIndex:a?-1:0,onClick:()=>!a&&e.setEnabled(!e.enabled),onKeyDown:t=>{a||(t.key===` `||t.key===`Enter`)&&(t.preventDefault(),e.setEnabled(!e.enabled))},className:u(`flex flex-1 items-center justify-between gap-3 select-none outline-none rounded focus-visible:ring-2 focus-visible:ring-ring`,a?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2 text-sm text-foreground`,children:[e.busy?(0,k.jsx)(s,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):(0,k.jsx)(l,{className:u(`h-4 w-4 shrink-0`,e.enabled?`text-info`:`text-muted-foreground`)}),`Geotag`]}),(0,k.jsx)(`div`,{className:u(`relative h-5 w-10 shrink-0 rounded-full transition-colors`,e.enabled?`bg-info`:`bg-muted-foreground/30`),children:(0,k.jsx)(`div`,{className:u(`absolute top-[2px] h-4 w-4 rounded-full bg-background shadow-elevation-1 transition-transform`,e.enabled?`translate-x-[22px]`:`translate-x-[2px]`)})})]}),(0,k.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),title:`Pick a point on the map`,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,k.jsx)(o,{className:`h-3.5 w-3.5`}),e.manual?`Change pin`:`Pick on map`]}),e.manual&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>e.setManual(null),"aria-label":`Remove custom pin`,title:`Remove custom pin`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,k.jsx)(i,{className:`h-3.5 w-3.5`})})]})]}),(0,k.jsx)(`p`,{id:`${t}-hint`,className:u(`text-xs`,c?`text-warning`:`text-muted-foreground`),children:A(e)}),n&&(0,k.jsx)(m,{initial:e.manual??e.fix??null,onPick:t=>e.setManual(t),onClose:()=>r(!1)})]})}var M=`data/schema/file`,N=`3.0`;function P(e){let[t,n]=(0,D.useState)([]),[r,i]=(0,D.useState)(``);return{tags:t,setTags:n,comment:r,setComment:i,suggestions:O(e),geotag:S()}}function F(e,t,n={}){let r=g(n.tags??[]),i=n.comment?.trim();return{schema:M,schemaVersion:N,data:{},checksumArray:[`sha256/${e.checksum}`],locations:[{url:e.url,metadata:{filename:t.name}}],...i?{comment:i}:{},metadata:{contentType:t.type,size:e.size,...r.length?{features:r}:{},...n.geo?{geo:n.geo}:{}}}}var I=`flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-elevation-1 transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;function L({fields:e,idPrefix:t=`file`,multiple:n=!1}){return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsx)(f,{children:`Tags`}),(0,k.jsx)(h,{tags:e.tags,onChange:e.setTags,suggestions:e.suggestions})]}),(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsx)(f,{htmlFor:`${t}-comment`,children:`Comment`}),(0,k.jsx)(`textarea`,{id:`${t}-comment`,value:e.comment,onChange:t=>e.setComment(t.target.value),rows:3,placeholder:`Optional; searchable, and the only text a photo has`,className:I}),n&&e.tags.length+e.comment.trim().length>0&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Applied to every file in this upload`})]}),(0,k.jsx)(j,{geotag:e.geotag,idPrefix:`${t}-geotag`})]})}var R=3;function z(e){return`${e.name}:${e.size}:${e.lastModified}`}function B(e=[]){let[t,n]=(0,D.useState)(()=>e.map(e=>({id:z(e),file:e,status:`queued`,progress:0}))),[r,i]=(0,D.useState)(!1),a=(0,D.useRef)(t),o=(0,D.useRef)(null),s=(0,D.useRef)(null);(0,D.useEffect)(()=>()=>s.current?.abort(),[]);let c=(0,D.useCallback)(e=>{a.current=e,n(e)},[]),l=(0,D.useCallback)((e,t)=>{let r=a.current.map(n=>n.id===e?{...n,...t}:n);a.current=r,n(r)},[]),u=(0,D.useCallback)(e=>{let t=new Set(a.current.map(e=>e.id)),n=e.filter(e=>!t.has(z(e))).map(e=>({id:z(e),file:e,status:`queued`,progress:0}));n.length&&c([...a.current,...n])},[c]),d=(0,D.useCallback)(e=>{c(a.current.filter(t=>t.id!==e))},[c]),f=(0,D.useCallback)(()=>{s.current?.abort(),s.current=null,c([]),i(!1)},[c]),p=(0,D.useCallback)(()=>{s.current?.abort()},[]);return{items:t,running:r,addFiles:u,removeItem:d,reset:f,start:(0,D.useCallback)(async(e,t)=>{if(!e)throw Error(`No active workspace or context to add to`);let{workspaceName:n,treeName:r,path:u}=await _(e),d=r===`backends`?await v(n,u):null,f=JSON.stringify([n,r,u]);o.current!==null&&o.current!==f&&c(a.current.map(({id:e,file:t})=>({id:e,file:t,status:`queued`,progress:0}))),o.current=f;let p=new AbortController;s.current=p,i(!0);let m=a.current.filter(e=>e.status!==`done`);for(let e of m)l(e.id,{status:`queued`,progress:0,error:void 0});try{if(d){let e=0;await Promise.all(Array.from({length:Math.min(R,m.length)},async()=>{for(;e<m.length&&!p.signal.aborted;){let t=m[e++];try{l(t.id,{status:`uploading`,progress:0,resumed:!1});let e=await T(n,{...d,key:y(d.key,t.file.name)},t.file,{signal:p.signal,onProgress:(e,n)=>l(t.id,{progress:n?e/n:0})});l(t.id,{status:`done`,progress:1,docId:e.docId??void 0})}catch(e){l(t.id,{status:`error`,error:e instanceof Error?e.message:`Upload failed`})}}}))}else{let r=new Map;for(let e of m){if(p.signal.aborted)throw new DOMException(`cancelled`,`AbortError`);if(!(e.file.size>=8388608)){l(e.id,{status:`hashing`});try{let t=await E(e.file,t=>l(e.id,{progress:t}));r.set(e.id,t),l(e.id,{status:`checking`,progress:0})}catch(t){l(e.id,{status:`error`,error:t instanceof Error?t.message:`Failed to read file`})}}}let i={};if(r.size)try{i=await w(n,[...new Set(r.values())])}catch{i={}}let a=m.filter(e=>r.has(e.id)||e.file.size>=8388608),o=0;await Promise.all(Array.from({length:Math.min(R,a.length)},async()=>{for(;o<a.length;){if(p.signal.aborted)return;let s=a[o++],c=r.get(s.id);try{let r=c?i[c]??null:null;r?l(s.id,{status:`linking`,progress:1,resumed:!0}):(l(s.id,{status:`uploading`,progress:0}),r=await C(n,s.file,{sha256:c,signal:p.signal,onProgress:(e,t)=>l(s.id,{progress:t?e/t:0})}),l(s.id,{status:`linking`,progress:1}));let a=await b(e,[t(r,s.file)],{refresh:!1});l(s.id,{status:`done`,docId:a[0]})}catch(e){let t=e instanceof DOMException&&e.name===`AbortError`;l(s.id,{status:`error`,error:t?`Cancelled`:e instanceof Error?e.message:`Upload failed`})}}}))}}finally{if(p.signal.aborted)for(let e of a.current)e.status!==`done`&&e.status!==`error`&&l(e.id,{status:`error`,error:`Cancelled`});i(!1),s.current===p&&(s.current=null),a.current.some(e=>e.status===`done`)&&x(e)}let h=a.current;return{done:h.filter(e=>e.status===`done`).length,resumed:h.filter(e=>e.status===`done`&&e.resumed).length,failed:h.filter(e=>e.status===`error`).length,total:h.length,docIds:h.flatMap(e=>e.status===`done`&&e.docId!=null?[e.docId]:[])}},[l,c]),cancel:p}}function V(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function H(e){switch(e.status){case`hashing`:return`hashing`;case`checking`:return`checking`;case`uploading`:return`${Math.round(e.progress*100)}%`;case`linking`:return`saving`;case`done`:return e.resumed?`already uploaded`:`done`;case`error`:return e.error||`failed`;default:return V(e.file.size)}}function U({item:e}){switch(e.status){case`done`:return(0,k.jsx)(a,{className:`h-3.5 w-3.5 shrink-0 text-green-600 dark:text-green-500`});case`error`:return(0,k.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-destructive`});case`queued`:return(0,k.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`});default:return(0,k.jsx)(s,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`})}}function W({item:e}){if(e.status===`queued`)return null;let t=e.status===`done`||e.status===`error`||e.status===`linking`?1:e.status===`checking`?0:e.progress;return(0,k.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,k.jsx)(`div`,{className:u(`h-full rounded-full transition-[width] duration-normal`,e.status===`error`?`bg-destructive`:e.status===`done`?`bg-green-600 dark:bg-green-500`:`bg-primary`),style:{width:`${Math.round(t*100)}%`}})})}function G({items:e,running:t,onRemove:n}){let r=e.filter(e=>e.status===`done`).length,a=e.filter(e=>e.status===`error`).length;return(0,k.jsx)(k.Fragment,{children:e.length>0&&(0,k.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,k.jsxs)(f,{children:[e.length,` file(s)`,r>0&&(0,k.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`— `,r,` done`,a>0?`, ${a} failed`:``]})]}),(0,k.jsx)(`ul`,{className:`max-h-48 space-y-1 overflow-y-auto`,children:e.map(e=>(0,k.jsxs)(`li`,{className:`flex flex-col gap-1 rounded border border-input px-2 py-1 text-sm`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(U,{item:e}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,title:e.file.name,children:e.file.name}),(0,k.jsx)(`span`,{className:u(`shrink-0 text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),title:e.status===`error`?e.error:void 0,children:H(e)}),!t&&e.status!==`done`&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Remove ${e.file.name}`,children:(0,k.jsx)(i,{className:`h-3.5 w-3.5`})})]}),(0,k.jsx)(W,{item:e})]},e.id))})]})})}function K({items:e,running:t,onCancel:n}){return(0,k.jsxs)(`div`,{className:`space-y-4 overflow-y-auto p-4`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-medium`,children:`Uploading files`}),!t&&(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Preparing / finishing upload…`}),(0,k.jsx)(G,{items:e,running:!0,onRemove:()=>{}}),(0,k.jsx)(d,{variant:`outline`,size:`sm`,disabled:!t,onClick:n,children:`Cancel upload`})]})}export{F as a,O as c,L as i,K as n,P as o,B as r,j as s,G as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as i,h as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./socket-CtH3EU9m.js";import{n as s}from"./use-toast-BlLDqSUO.js";import{o as c,s as l}from"./LinkToCard-nR7Lal_o.js";import{En as u,H as d,K as ee,Vt as te,t as f}from"./workspace-DvxC7pw1.js";import{r as ne}from"./document-list-SsF3jmuq.js";import{n as re}from"./use-toolbox-Ck_cLGgf.js";import{E as ie,_ as ae,a as oe,b as se,i as ce,l as le,o as ue}from"./context-mfIOB8dN.js";import{i as de}from"./color-DFEH4BfK.js";import{t as fe}from"./geo-CZfs0E-x.js";import{a as pe,i as me,o as he}from"./workspace-BydSRtST.js";import{i as ge}from"./use-menu-BiJ8N7sS.js";import{a as _e,i as ve,n as ye,o as be,r as xe,s as Se,t as Ce}from"./content-app-view-DS6Nrz6M.js";import{t as we}from"./use-workspace-identity-mgaofjsD.js";var p=e(n(),1),m=t();function Te(e,t){if(!e||!t)return`/`;let n=`${t}://`;if(!e.startsWith(n))return`/`;let r=e.slice(n.length).replace(/^\/+/,``).replace(/\/+$/,``);return r?`/${r}`:`/`}function h(){let{contextId:e}=r(),t=a(),n=i(),h=new URLSearchParams(t.search).get(`ownerId`)||void 0,g=(0,p.useMemo)(()=>{let e=new URLSearchParams(t.search),n=e.getAll(`q`).map(e=>e.trim()).filter(Boolean),r=(e.get(`search`)||``).trim();return n.length?n:r?[r]:[]},[t.search]),{showToast:_,showProgress:Ee}=s(),{state:v,saveFilters:De,setSort:Oe,setAccentColor:y,setMapDocuments:b}=re(),{openM1Drawer:ke,openM2Drawer:Ae,goBack:je}=ge(),Me=v.filters.features.allOf,Ne=v.filters.features.anyOf,Pe=v.filters.features.noneOf,Fe=[...me(v.filters.timeline),...pe(v.filters.geo),...he(v.filters.lens,v.filters.geo.includeUnlocated)],x=JSON.stringify({a:Me,b:Ne,c:Pe,d:Fe,ids:v.filters.lens.ids,sort:v.filters.sort,geoSelection:v.geoSelection,includeUnlocated:v.filters.geo.includeUnlocated}),S=(0,p.useMemo)(()=>JSON.parse(x),[x]),[C,w]=(0,p.useState)(null),[Ie,Le]=(0,p.useState)(!0),[Re,ze]=(0,p.useState)(null),[T,E]=(0,p.useState)([]),[Be,Ve]=(0,p.useState)(!1),[He,D]=(0,p.useState)(0),[Ue,We]=(0,p.useState)([]),[O,k]=(0,p.useState)(1),[A,Ge]=(0,p.useState)(50),[j,M]=(0,p.useState)(g),[N,P]=(0,p.useState)(!1),[F,I]=(0,p.useState)(null),[L,Ke]=(0,p.useState)(!1),R=(0,p.useRef)(!1),z=F?.id===C?.id&&F?.url===C?.url?F?.path:null,qe=new URLSearchParams(t.search).get(`layer`),B=!!h,Je=we(B?void 0:C?.workspaceName||C?.workspaceId),V=C?Te(C.url,C.workspaceName):`/`,Ye=qe?`context-layer`:`context`,H=!v.liveEnabled&&typeof C?.metadata?.toolboxSearchQuery==`string`?C.metadata.toolboxSearchQuery:``,U=B?null:C?.workspaceName??null,[Xe,Ze]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!U)return;let e=!1;return ee(U,f).then(t=>{e||Ze({key:U,tree:t})}).catch(()=>{e||Ze({key:U,tree:null})}),()=>{e=!0}},[U]);let W=U&&Xe?.key===U?Xe.tree:null,G=!qe&&!B&&W?V===`/`?W:d(W,V):null,K=`${C?.workspaceName??``}\0${V}`,[q,Qe]=(0,p.useState)(null),J=q?.key===K?q.views:be(G?.metadata),Y=q?.key===K?q.activeId:J[0]?.id??ve.id,X=J.find(e=>e.id===Y)??J[0]??ve,Z=_e(X),$e=e=>{k(1),Qe({key:K,views:J,activeId:e})},et=(e,t)=>{t&&t!==Y&&k(1),Qe({key:K,views:e,activeId:t??Y}),C?.workspaceName&&u(C.workspaceName,V,{metadata:{...G?.metadata??{},views:e}},f).catch(()=>{_({title:`View not saved`,description:`Could not persist views to the layer`,variant:`destructive`})})},tt=(0,p.useRef)(null);(0,p.useEffect)(()=>()=>tt.current?.abort(),[]);let Q=(0,p.useCallback)(async()=>{if(!e)return;tt.current?.abort();let t=new AbortController;tt.current=t,Ve(!0);try{let n=await ue(e,Z?[...S.a,Z]:S.a,S.d,{...S.sort,geoSelection:S.geoSelection,includeUnlocated:S.includeUnlocated,ids:S.ids,signal:t.signal,limit:A,page:O,queries:j.length?j:void 0,anyOf:S.b,noneOf:S.c,applyContextSpec:!1},h);if(t.signal.aborted)return;E(n),D(n.totalCount||n.count||n.length)}catch(e){if(t.signal.aborted)return;_({title:`Error`,description:e instanceof Error?e.message:`Failed to fetch documents`,variant:`destructive`}),E([]),D(0)}finally{t.signal.aborted||Ve(!1)}},[e,O,A,h,j,S,_,Z]),nt=(0,p.useCallback)(async()=>{if(e){Le(!0);try{let t=B?await oe(e,h):await oe(e);if(!t)throw Error(`No context data received.`);let n=t.workspace,r=t.workspaceId||(typeof n==`string`?n:n?.id)||``,i=t.workspaceName||(typeof n==`string`?n:n?.name)||``;w({id:t.id,userId:t.userId,url:t.url,baseUrl:t.baseUrl||null,path:t.path||null,pathArray:t.pathArray||[],workspaceId:r,workspaceName:i,acl:t.acl||{},createdAt:t.createdAt,updatedAt:t.updatedAt,locked:t.locked||!1,serverContextArray:t.serverContextArray||[],clientContextArray:t.clientContextArray||[],contextBitmapArray:t.contextBitmapArray||[],featureBitmapArray:t.featureBitmapArray||[],filterArray:t.filterArray||[],pendingUrl:t.pendingUrl||null,description:t.description||null,metadata:t.metadata||{},name:t.name??null,color:t.color??null,icon:t.icon??null}),ze(null)}catch(t){let n=t instanceof Error?t.message:`Failed to fetch context ${e}`;ze(n),w(null),_({title:`Error`,description:n,variant:`destructive`})}Le(!1)}},[e,h,B,_]);(0,p.useEffect)(()=>{nt()},[nt]);let rt=de(C?.color)||null;(0,p.useEffect)(()=>(y(rt),()=>y(null)),[rt,y]);let it=v.geoSelection,at=C?.workspaceName||C?.workspaceId||null;(0,p.useEffect)(()=>{b(T,at)},[T,at,b]),(0,p.useEffect)(()=>()=>b([]),[b]);let ot=(0,p.useMemo)(()=>it?T.filter(e=>fe(e,it,v.filters.geo.includeUnlocated)):T,[T,it,v.filters.geo.includeUnlocated]),st=C?.id,ct=C?.url;(0,p.useEffect)(()=>{st&&Q()},[st,ct,Q]),(0,p.useEffect)(()=>{let e=()=>Q();return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[Q]);let[lt,ut]=(0,p.useState)(x);lt!==x&&(ut(x),k(1));let[dt,ft]=(0,p.useState)(e);dt!==e&&(ft(e),k(1),P(!1));let[pt,mt]=(0,p.useState)(g);pt!==g&&(mt(g),M(g),k(1));let[ht,gt]=(0,p.useState)({urlSearchQueries:g,ignoreSavedSearch:N,savedContextSearchQuery:H});(ht.urlSearchQueries!==g||ht.ignoreSavedSearch!==N||ht.savedContextSearchQuery!==H)&&(gt({urlSearchQueries:g,ignoreSavedSearch:N,savedContextSearchQuery:H}),!new URLSearchParams(t.search).has(`q`)&&!g.length&&!N&&(M(H?[H]:[]),k(1)));let $=(0,p.useCallback)(e=>{let r=new URLSearchParams(t.search);r.delete(`q`),r.delete(`search`);for(let t of e)r.append(`q`,t);let i=r.toString();n(`${t.pathname}${i?`?${i}`:``}${t.hash}`)},[t.pathname,t.search,t.hash,n]),_t=(0,p.useCallback)(e=>{let t=e.trim();if(!t)return;P(!1);let n=j.includes(t)?j:[...j,t];M(n),$(n)},[j,$]),vt=(0,p.useCallback)(e=>{let t=e<0?[]:j.filter((t,n)=>n!==e);t.length===0&&P(!0),M(t),$(t)},[j,$]),yt=(j[0]||``).trim(),bt=!!v.activeContextType&&(v.isDirty||yt!==(v.savedSearchQuery||H||``));(0,p.useEffect)(()=>{if(!e)return;let t=`context:${h?`${h}/`:``}${e}`,n=()=>o.emit(`subscribe`,{channel:t}),r=()=>o.emit(`unsubscribe`,{channel:t}),i=o.on(`connect`,n);n();let a=new Map,s=(t,n)=>{let r=Date.now(),i=`${t}:${n?.id||n?.contextId||e}`;return(a.get(i)||0)+1e3>r?!1:(a.set(i,r),!0)},c=t=>{let n=t,r=n?.context||n;(r?.id===e||r?.contextId===e)&&s(`ctx:updated`,r)&&(w(e=>e?{...e,...r}:null),r.url&&Q())},l=t=>{let n=t,r=n?.id||n?.contextId||n?.context?.id,i=n?.url||n?.context?.url;r===e&&typeof i==`string`&&s(`ctx:url`,n)&&(w(e=>e?{...e,url:i}:null),Q())},u=t=>{let n=t;(n?.contextId||n?.id||n?.context?.id)===e&&s(`doc:changed`,n)&&Q()},d=[[`context.updated`,c],[`context:updated`,c],[`context.url.set`,l],[`context:url:set`,l],[`document.inserted`,u],[`document.updated`,u],[`document.removed`,u],[`document.removed.batch`,u],[`document.linked`,u],[`document.unlinked`,u],[`document.linked.batch`,u],[`document.unlinked.batch`,u],[`document.deleted`,u],[`document.deleted.batch`,u]];return d.forEach(([e,t])=>o.on(e,t)),()=>{i(),r(),d.forEach(([e,t])=>o.off(e,t))}},[e,h,Q]);let xt=async e=>{if(C)try{await se(C.id,[e],h,V),E(t=>t.filter(t=>t.id!==e)),D(e=>Math.max(0,e-1)),_({title:`Success`,description:`Document removed from context.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to remove document`,variant:`destructive`})}},St=async e=>{if(C)try{await ce(C.id,[e],h,V),E(t=>t.filter(t=>t.id!==e)),D(e=>Math.max(0,e-1)),_({title:`Success`,description:`Document deleted.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to delete document`,variant:`destructive`})}},Ct=async e=>{if(C)try{await se(C.id,e,h,V),E(t=>t.filter(t=>!e.includes(t.id))),D(t=>Math.max(0,t-e.length)),_({title:`Success`,description:`${e.length} document(s) removed.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to remove documents`,variant:`destructive`})}},wt=async e=>{if(C)try{await ce(C.id,e,h,V),E(t=>t.filter(t=>!e.includes(t.id))),D(t=>Math.max(0,t-e.length)),_({title:`Success`,description:`${e.length} document(s) deleted.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to delete documents`,variant:`destructive`})}},Tt=e=>{We(e),_({title:`Copied`,description:`${e.length} document(s) copied to clipboard`})},Et=async(e,t,n={})=>{if(!C)return!1;let r=Ee({title:`Pasting…`,description:`${t.length} document(s) → "${e}"`});try{let i=n.targetTreeName&&!B?await te(C.workspaceName||C.workspaceId,e,t,n.targetTreeName,n.targetTreeType):await ae(C.id,e,t,h);return r.done(i?{title:`Success`,description:`${t.length} document(s) pasted to "${e}"`}:void 0),i&&(We([]),await Q()),i}catch(e){return r.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to paste documents`,variant:`destructive`}),!1}},Dt=async(e,t)=>{if(!C)return!1;try{let n=await le(C.workspaceId,t,e);return n&&(ne(C.workspaceName||C.workspaceId,`context`,t),_({title:`Success`,description:`Imported ${e.length} document(s) to "${t}"`})),n}catch(e){return _({title:`Error`,description:e instanceof Error?e.message:`Failed to import documents`,variant:`destructive`}),!1}},Ot=async()=>{if(!C||!z||B||R.current)return;let e={id:C.id,url:C.url,path:z};R.current=!0,Ke(!0);try{let t=await ie(e.id,`${C.workspaceName}://${e.path.replace(/^\/+/,``)}`);w(n=>n?.id===e.id&&n.url===e.url?{...n,url:t.url,path:e.path}:n),I(null),k(1),window.dispatchEvent(new CustomEvent(`contexts:refresh`,{detail:{contextId:e.id}})),_({title:`Saved`,description:`Context path updated`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Could not update context path`,variant:`destructive`})}finally{R.current=!1,Ke(!1)}};if(Ie)return(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,m.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading context...`})]})});if(Re&&!C)return(0,m.jsxs)(`div`,{className:`flex items-center justify-center h-full text-destructive`,children:[`Error: `,Re]});if(!C)return(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Context not found.`});let kt=de(C.color);return(0,m.jsx)(`div`,{className:`flex flex-col h-full min-h-0`,children:(0,m.jsx)(Se,{onBack:je,accentColor:kt,navigationTabs:G?(0,m.jsx)(xe,{views:J,activeId:Y,onSelect:$e,onSave:et,accentColor:kt}):void 0,workspaceLabel:Je?.label||C.workspaceName||C.workspaceId,workspaceIcon:Je?.icon,treeName:f,urlType:Ye,urlDisplay:C.url,contextPath:V,workspaceId:C.workspaceName||C.workspaceId,documentSchema:Z,linkTree:W,documents:ot,isLoading:Be,totalCount:He,currentPage:O,pageSize:A,onPageChange:k,onPageSizeChange:e=>{Ge(e),k(1)},onRemoveDocument:V===`/`?void 0:xt,onDeleteDocument:St,onRemoveDocuments:V===`/`?void 0:Ct,onDeleteDocuments:wt,onCopyDocuments:Tt,onPasteDocuments:Et,onImportDocuments:B?void 0:Dt,pastedDocumentIds:Ue,backendSearchQueries:j,onBackendSearch:_t,serverSort:v.filters.sort,onServerSortChange:Oe,onRemoveBackendQuery:vt,canSaveChanges:bt,isSavingChanges:v.isSaving,onSaveChanges:De,onBrowseTree:!B&&e?()=>Ae(`contexts`,`detail`,e):void 0,onBrowseWorkspaces:()=>ke(`workspaces`),onNavigatePath:B?void 0:e=>{R.current||I({id:C.id,url:C.url,path:e})},contentBanner:z?(0,m.jsxs)(`div`,{className:`border-b bg-warning/10 px-4 py-2`,role:`status`,children:[(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Set this context to the selected path? Contents stay at the current path until you apply it.`}),(0,m.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,m.jsx)(l,{items:c(z,C.workspaceName),label:`Selected context path`}),(0,m.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>void Ot(),className:`shrink-0 rounded border px-3 py-1 text-sm hover:bg-accent disabled:opacity-50`,children:L?`Setting…`:`Set`}),(0,m.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>I(null),className:`shrink-0 rounded px-2 py-1 text-sm hover:bg-accent disabled:opacity-50`,children:`Cancel`})]})]}):void 0,children:X.kind===`columns`?(0,m.jsx)(ye,{documents:ot,workspaceId:C.workspaceName||C.workspaceId,columns:X.columns??[],onColumnsChange:e=>et(J.map(t=>t.id===X.id?{...t,columns:e}:t))}):X.kind===`app`&&X.app&&X.app!==`notes`?(0,m.jsx)(Ce,{app:X.app,contextId:e,workspaceId:C.workspaceName||C.workspaceId,treeName:f,path:V}):null})})}export{h as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as i,h as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./socket-CtH3EU9m.js";import{n as s}from"./use-toast-BlLDqSUO.js";import{o as c,s as l}from"./LinkToCard-5dg0jvSY.js";import{Bt as u,H as d,K as ee,Sn as te,t as f}from"./workspace-CrSpR4xf.js";import{r as ne}from"./document-list-Dsf1DVEx.js";import{n as re}from"./use-toolbox-Ck_cLGgf.js";import{E as ie,_ as ae,a as oe,b as se,i as ce,l as le,o as ue}from"./context-DQoZFMDQ.js";import{i as de}from"./color-DFEH4BfK.js";import{t as fe}from"./geo-CZfs0E-x.js";import{a as pe,i as me,o as he}from"./workspace-BydSRtST.js";import{i as ge}from"./use-menu-BiJ8N7sS.js";import{a as _e,i as ve,n as ye,o as be,r as xe,s as Se,t as Ce}from"./content-app-view-BF-k-5Y7.js";import{t as we}from"./use-workspace-identity-BCrrvfeE.js";var p=e(n(),1),m=t();function Te(e,t){if(!e||!t)return`/`;let n=`${t}://`;if(!e.startsWith(n))return`/`;let r=e.slice(n.length).replace(/^\/+/,``).replace(/\/+$/,``);return r?`/${r}`:`/`}function h(){let{contextId:e}=r(),t=a(),n=i(),h=new URLSearchParams(t.search).get(`ownerId`)||void 0,g=(0,p.useMemo)(()=>{let e=new URLSearchParams(t.search),n=e.getAll(`q`).map(e=>e.trim()).filter(Boolean),r=(e.get(`search`)||``).trim();return n.length?n:r?[r]:[]},[t.search]),{showToast:_,showProgress:Ee}=s(),{state:v,saveFilters:De,setSort:Oe,setAccentColor:y,setMapDocuments:b}=re(),{openM1Drawer:ke,openM2Drawer:Ae,goBack:je}=ge(),Me=v.filters.features.allOf,Ne=v.filters.features.anyOf,Pe=v.filters.features.noneOf,Fe=[...me(v.filters.timeline),...pe(v.filters.geo),...he(v.filters.lens,v.filters.geo.includeUnlocated)],x=JSON.stringify({a:Me,b:Ne,c:Pe,d:Fe,ids:v.filters.lens.ids,sort:v.filters.sort,geoSelection:v.geoSelection,includeUnlocated:v.filters.geo.includeUnlocated}),S=(0,p.useMemo)(()=>JSON.parse(x),[x]),[C,w]=(0,p.useState)(null),[Ie,Le]=(0,p.useState)(!0),[Re,ze]=(0,p.useState)(null),[T,E]=(0,p.useState)([]),[Be,Ve]=(0,p.useState)(!1),[He,D]=(0,p.useState)(0),[Ue,We]=(0,p.useState)([]),[O,k]=(0,p.useState)(1),[A,Ge]=(0,p.useState)(50),[j,M]=(0,p.useState)(g),[N,P]=(0,p.useState)(!1),[F,I]=(0,p.useState)(null),[L,Ke]=(0,p.useState)(!1),R=(0,p.useRef)(!1),z=F?.id===C?.id&&F?.url===C?.url?F?.path:null,qe=new URLSearchParams(t.search).get(`layer`),B=!!h,Je=we(B?void 0:C?.workspaceName||C?.workspaceId),V=C?Te(C.url,C.workspaceName):`/`,Ye=qe?`context-layer`:`context`,H=!v.liveEnabled&&typeof C?.metadata?.toolboxSearchQuery==`string`?C.metadata.toolboxSearchQuery:``,U=B?null:C?.workspaceName??null,[Xe,Ze]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!U)return;let e=!1;return ee(U,f).then(t=>{e||Ze({key:U,tree:t})}).catch(()=>{e||Ze({key:U,tree:null})}),()=>{e=!0}},[U]);let W=U&&Xe?.key===U?Xe.tree:null,G=!qe&&!B&&W?V===`/`?W:d(W,V):null,K=`${C?.workspaceName??``}\0${V}`,[q,Qe]=(0,p.useState)(null),J=q?.key===K?q.views:be(G?.metadata),Y=q?.key===K?q.activeId:J[0]?.id??ve.id,X=J.find(e=>e.id===Y)??J[0]??ve,Z=_e(X),$e=e=>{k(1),Qe({key:K,views:J,activeId:e})},et=(e,t)=>{t&&t!==Y&&k(1),Qe({key:K,views:e,activeId:t??Y}),C?.workspaceName&&te(C.workspaceName,V,{metadata:{...G?.metadata??{},views:e}},f).catch(()=>{_({title:`View not saved`,description:`Could not persist views to the layer`,variant:`destructive`})})},tt=(0,p.useRef)(null);(0,p.useEffect)(()=>()=>tt.current?.abort(),[]);let Q=(0,p.useCallback)(async()=>{if(!e)return;tt.current?.abort();let t=new AbortController;tt.current=t,Ve(!0);try{let n=await ue(e,Z?[...S.a,Z]:S.a,S.d,{...S.sort,geoSelection:S.geoSelection,includeUnlocated:S.includeUnlocated,ids:S.ids,signal:t.signal,limit:A,page:O,queries:j.length?j:void 0,anyOf:S.b,noneOf:S.c,applyContextSpec:!1},h);if(t.signal.aborted)return;E(n),D(n.totalCount||n.count||n.length)}catch(e){if(t.signal.aborted)return;_({title:`Error`,description:e instanceof Error?e.message:`Failed to fetch documents`,variant:`destructive`}),E([]),D(0)}finally{t.signal.aborted||Ve(!1)}},[e,O,A,h,j,S,_,Z]),nt=(0,p.useCallback)(async()=>{if(e){Le(!0);try{let t=B?await oe(e,h):await oe(e);if(!t)throw Error(`No context data received.`);let n=t.workspace,r=t.workspaceId||(typeof n==`string`?n:n?.id)||``,i=t.workspaceName||(typeof n==`string`?n:n?.name)||``;w({id:t.id,userId:t.userId,url:t.url,baseUrl:t.baseUrl||null,path:t.path||null,pathArray:t.pathArray||[],workspaceId:r,workspaceName:i,acl:t.acl||{},createdAt:t.createdAt,updatedAt:t.updatedAt,locked:t.locked||!1,serverContextArray:t.serverContextArray||[],clientContextArray:t.clientContextArray||[],contextBitmapArray:t.contextBitmapArray||[],featureBitmapArray:t.featureBitmapArray||[],filterArray:t.filterArray||[],pendingUrl:t.pendingUrl||null,description:t.description||null,metadata:t.metadata||{},name:t.name??null,color:t.color??null,icon:t.icon??null}),ze(null)}catch(t){let n=t instanceof Error?t.message:`Failed to fetch context ${e}`;ze(n),w(null),_({title:`Error`,description:n,variant:`destructive`})}Le(!1)}},[e,h,B,_]);(0,p.useEffect)(()=>{nt()},[nt]);let rt=de(C?.color)||null;(0,p.useEffect)(()=>(y(rt),()=>y(null)),[rt,y]);let it=v.geoSelection,at=C?.workspaceName||C?.workspaceId||null;(0,p.useEffect)(()=>{b(T,at)},[T,at,b]),(0,p.useEffect)(()=>()=>b([]),[b]);let ot=(0,p.useMemo)(()=>it?T.filter(e=>fe(e,it,v.filters.geo.includeUnlocated)):T,[T,it,v.filters.geo.includeUnlocated]),st=C?.id,ct=C?.url;(0,p.useEffect)(()=>{st&&Q()},[st,ct,Q]),(0,p.useEffect)(()=>{let e=()=>Q();return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[Q]);let[lt,ut]=(0,p.useState)(x);lt!==x&&(ut(x),k(1));let[dt,ft]=(0,p.useState)(e);dt!==e&&(ft(e),k(1),P(!1));let[pt,mt]=(0,p.useState)(g);pt!==g&&(mt(g),M(g),k(1));let[ht,gt]=(0,p.useState)({urlSearchQueries:g,ignoreSavedSearch:N,savedContextSearchQuery:H});(ht.urlSearchQueries!==g||ht.ignoreSavedSearch!==N||ht.savedContextSearchQuery!==H)&&(gt({urlSearchQueries:g,ignoreSavedSearch:N,savedContextSearchQuery:H}),!new URLSearchParams(t.search).has(`q`)&&!g.length&&!N&&(M(H?[H]:[]),k(1)));let $=(0,p.useCallback)(e=>{let r=new URLSearchParams(t.search);r.delete(`q`),r.delete(`search`);for(let t of e)r.append(`q`,t);let i=r.toString();n(`${t.pathname}${i?`?${i}`:``}${t.hash}`)},[t.pathname,t.search,t.hash,n]),_t=(0,p.useCallback)(e=>{let t=e.trim();if(!t)return;P(!1);let n=j.includes(t)?j:[...j,t];M(n),$(n)},[j,$]),vt=(0,p.useCallback)(e=>{let t=e<0?[]:j.filter((t,n)=>n!==e);t.length===0&&P(!0),M(t),$(t)},[j,$]),yt=(j[0]||``).trim(),bt=!!v.activeContextType&&(v.isDirty||yt!==(v.savedSearchQuery||H||``));(0,p.useEffect)(()=>{if(!e)return;let t=`context:${h?`${h}/`:``}${e}`,n=()=>o.emit(`subscribe`,{channel:t}),r=()=>o.emit(`unsubscribe`,{channel:t}),i=o.on(`connect`,n);n();let a=new Map,s=(t,n)=>{let r=Date.now(),i=`${t}:${n?.id||n?.contextId||e}`;return(a.get(i)||0)+1e3>r?!1:(a.set(i,r),!0)},c=t=>{let n=t,r=n?.context||n;(r?.id===e||r?.contextId===e)&&s(`ctx:updated`,r)&&(w(e=>e?{...e,...r}:null),r.url&&Q())},l=t=>{let n=t,r=n?.id||n?.contextId||n?.context?.id,i=n?.url||n?.context?.url;r===e&&typeof i==`string`&&s(`ctx:url`,n)&&(w(e=>e?{...e,url:i}:null),Q())},u=t=>{let n=t;(n?.contextId||n?.id||n?.context?.id)===e&&s(`doc:changed`,n)&&Q()},d=[[`context.updated`,c],[`context:updated`,c],[`context.url.set`,l],[`context:url:set`,l],[`document.inserted`,u],[`document.updated`,u],[`document.removed`,u],[`document.removed.batch`,u],[`document.linked`,u],[`document.unlinked`,u],[`document.linked.batch`,u],[`document.unlinked.batch`,u],[`document.deleted`,u],[`document.deleted.batch`,u]];return d.forEach(([e,t])=>o.on(e,t)),()=>{i(),r(),d.forEach(([e,t])=>o.off(e,t))}},[e,h,Q]);let xt=async e=>{if(C)try{await se(C.id,[e],h,V),E(t=>t.filter(t=>t.id!==e)),D(e=>Math.max(0,e-1)),_({title:`Success`,description:`Document removed from context.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to remove document`,variant:`destructive`})}},St=async e=>{if(C)try{await ce(C.id,[e],h,V),E(t=>t.filter(t=>t.id!==e)),D(e=>Math.max(0,e-1)),_({title:`Success`,description:`Document deleted.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to delete document`,variant:`destructive`})}},Ct=async e=>{if(C)try{await se(C.id,e,h,V),E(t=>t.filter(t=>!e.includes(t.id))),D(t=>Math.max(0,t-e.length)),_({title:`Success`,description:`${e.length} document(s) removed.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to remove documents`,variant:`destructive`})}},wt=async e=>{if(C)try{await ce(C.id,e,h,V),E(t=>t.filter(t=>!e.includes(t.id))),D(t=>Math.max(0,t-e.length)),_({title:`Success`,description:`${e.length} document(s) deleted.`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Failed to delete documents`,variant:`destructive`})}},Tt=e=>{We(e),_({title:`Copied`,description:`${e.length} document(s) copied to clipboard`})},Et=async(e,t,n={})=>{if(!C)return!1;let r=Ee({title:`Pasting…`,description:`${t.length} document(s) → "${e}"`});try{let i=n.targetTreeName&&!B?await u(C.workspaceName||C.workspaceId,e,t,n.targetTreeName,n.targetTreeType):await ae(C.id,e,t,h);return r.done(i?{title:`Success`,description:`${t.length} document(s) pasted to "${e}"`}:void 0),i&&(We([]),await Q()),i}catch(e){return r.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to paste documents`,variant:`destructive`}),!1}},Dt=async(e,t)=>{if(!C)return!1;try{let n=await le(C.workspaceId,t,e);return n&&(ne(C.workspaceName||C.workspaceId,`context`,t),_({title:`Success`,description:`Imported ${e.length} document(s) to "${t}"`})),n}catch(e){return _({title:`Error`,description:e instanceof Error?e.message:`Failed to import documents`,variant:`destructive`}),!1}},Ot=async()=>{if(!C||!z||B||R.current)return;let e={id:C.id,url:C.url,path:z};R.current=!0,Ke(!0);try{let t=await ie(e.id,`${C.workspaceName}://${e.path.replace(/^\/+/,``)}`);w(n=>n?.id===e.id&&n.url===e.url?{...n,url:t.url,path:e.path}:n),I(null),k(1),window.dispatchEvent(new CustomEvent(`contexts:refresh`,{detail:{contextId:e.id}})),_({title:`Saved`,description:`Context path updated`})}catch(e){_({title:`Error`,description:e instanceof Error?e.message:`Could not update context path`,variant:`destructive`})}finally{R.current=!1,Ke(!1)}};if(Ie)return(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,m.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading context...`})]})});if(Re&&!C)return(0,m.jsxs)(`div`,{className:`flex items-center justify-center h-full text-destructive`,children:[`Error: `,Re]});if(!C)return(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Context not found.`});let kt=de(C.color);return(0,m.jsx)(`div`,{className:`flex flex-col h-full min-h-0`,children:(0,m.jsx)(Se,{onBack:je,accentColor:kt,navigationTabs:G?(0,m.jsx)(xe,{views:J,activeId:Y,onSelect:$e,onSave:et,accentColor:kt}):void 0,workspaceLabel:Je?.label||C.workspaceName||C.workspaceId,workspaceIcon:Je?.icon,treeName:f,urlType:Ye,urlDisplay:C.url,contextPath:V,workspaceId:C.workspaceName||C.workspaceId,documentSchema:Z,linkTree:W,documents:ot,isLoading:Be,totalCount:He,currentPage:O,pageSize:A,onPageChange:k,onPageSizeChange:e=>{Ge(e),k(1)},onRemoveDocument:V===`/`?void 0:xt,onDeleteDocument:St,onRemoveDocuments:V===`/`?void 0:Ct,onDeleteDocuments:wt,onCopyDocuments:Tt,onPasteDocuments:Et,onImportDocuments:B?void 0:Dt,pastedDocumentIds:Ue,backendSearchQueries:j,onBackendSearch:_t,serverSort:v.filters.sort,onServerSortChange:Oe,onRemoveBackendQuery:vt,canSaveChanges:bt,isSavingChanges:v.isSaving,onSaveChanges:De,onBrowseTree:!B&&e?()=>Ae(`contexts`,`detail`,e):void 0,onBrowseWorkspaces:()=>ke(`workspaces`),onNavigatePath:B?void 0:e=>{R.current||I({id:C.id,url:C.url,path:e})},contentBanner:z?(0,m.jsxs)(`div`,{className:`border-b bg-warning/10 px-4 py-2`,role:`status`,children:[(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Set this context to the selected path? Contents stay at the current path until you apply it.`}),(0,m.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,m.jsx)(l,{items:c(z,C.workspaceName),label:`Selected context path`}),(0,m.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>void Ot(),className:`shrink-0 rounded border px-3 py-1 text-sm hover:bg-accent disabled:opacity-50`,children:L?`Setting…`:`Set`}),(0,m.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>I(null),className:`shrink-0 rounded px-2 py-1 text-sm hover:bg-accent disabled:opacity-50`,children:`Cancel`})]})]}):void 0,children:X.kind===`columns`?(0,m.jsx)(ye,{documents:ot,workspaceId:C.workspaceName||C.workspaceId,columns:X.columns??[],onColumnsChange:e=>et(J.map(t=>t.id===X.id?{...t,columns:e}:t))}):X.kind===`app`&&X.app&&X.app!==`notes`?(0,m.jsx)(Ce,{app:X.app,contextId:e,workspaceId:C.workspaceName||C.workspaceId,treeName:f,path:V}):null})})}export{h as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as i,h as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Br as o,Hr as s,L as c,fn as l}from"./ui-Byg1cZDr.js";import{t as u}from"./utils-2pl1SbIp.js";import{t as d}from"./button-SgR3GVvV.js";import{c as f,t as p}from"./api-CA6WiiYM.js";import{t as m}from"./socket-CtH3EU9m.js";import{n as h}from"./use-toast-BlLDqSUO.js";import{Bt as ee,Ht as g,Jt as _,K as te,Nt as ne,O as re,S as v,Sn as ie,T as ae,Yt as y,Z as oe,at as se,b as ce,bt as le,d as ue,dt as de,gt as fe,hn as b,it as pe,o as me,q as he,sn as x,v as ge,vt as _e}from"./workspace-CrSpR4xf.js";import{n as ve,r as ye}from"./use-canvas-pins-CbAxLLTU.js";import{u as be}from"./ObjectPropertiesCard-BIBMvx_i.js";import{h as xe,i as S,r as Se}from"./document-list-Dsf1DVEx.js";import{n as Ce}from"./use-toolbox-Ck_cLGgf.js";import{i as we}from"./color-DFEH4BfK.js";import{t as Te}from"./geo-CZfs0E-x.js";import{c as Ee}from"./backend-sync-progress-pZrhQPk3.js";import{a as De,i as Oe,n as ke,o as Ae}from"./workspace-BydSRtST.js";import{n as je,r as Me,t as Ne}from"./url-params-n7kU_WZ-.js";import{i as Pe}from"./use-menu-BiJ8N7sS.js";import{n as Fe}from"./last-path-BbXWC3b3.js";import{t as Ie}from"./workspace-area-menu-CP5OWZNX.js";import{t as Le}from"./workspace-content-gate-9okuA7J7.js";import{t as Re}from"./form-panel-C34lByEH.js";import{a as ze,i as Be,n as Ve,o as He,r as Ue,s as We,t as Ge}from"./content-app-view-BF-k-5Y7.js";import{i as Ke,o as qe,r as Je}from"./query-debug-CrPsUwT-.js";var C=`session.open`,Ye=`session.set`,Xe=`session.ids`,Ze=`session.materialize`,Qe=`session.close`,w=`session.delta`,T=e(n(),1),E=t();function $e({workspaceId:e,workspaceName:t}){let[n,r]=(0,T.useState)([]),[i,a]=(0,T.useState)(new Set),o=t=>`${e}:${t.address}:${t.resyncStartedAt||``}`;(0,T.useEffect)(()=>{let t=!1,n=!1,i=!1,a=0,o=new Map,s=new Map,c=(e,t)=>{let n=e.filter(e=>e.address!==t.backend);if(!t.resyncing)return n;let r=e.find(e=>e.address===t.backend)||s.get(t.backend);return[...n,{address:t.backend,config:r?.config,resyncStartedAt:r?.resyncStartedAt||new Date().toISOString(),progress:t.progress??r?.progress}]},l=async()=>{if(n){i=!0;return}n=!0;let u=a;try{let n=await le(e);if(!t){s=new Map(n.map(e=>[e.address,e]));let e=n.filter(e=>e.resyncing);for(let t of o.values())t.version>u&&(e=c(e,t.event));r(e)}}catch{}finally{n=!1,i&&!t&&(i=!1,l())}},u=t=>{t.workspaceId!==e||!t.backend||typeof t.resyncing!=`boolean`||(o.set(t.backend,{version:++a,event:t}),r(e=>c(e,t)))},d=t=>{t.workspaceId===e&&l()};l();let f=m.on(`connect`,l);return m.on(`backend.resync.changed`,u),m.on(`backend.changed`,d),window.addEventListener(`focus`,l),()=>{t=!0,f?.(),m.off(`backend.resync.changed`,u),m.off(`backend.changed`,d),window.removeEventListener(`focus`,l)}},[e]);let s=n.filter(e=>!i.has(o(e)));return s.length?(0,E.jsxs)(`aside`,{"aria-label":`Storage scans for ${t}`,className:`absolute bottom-5 right-5 z-50 w-72 max-w-[calc(100vw-2.5rem)] rounded-lg border bg-popover/95 p-3 text-popover-foreground shadow-lg backdrop-blur`,children:[(0,E.jsxs)(`div`,{role:`status`,className:`mb-2 flex items-center gap-2 text-sm font-medium`,children:[(0,E.jsx)(l,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),(0,E.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,E.jsx)(`span`,{className:`block`,children:`Scanning storage`}),(0,E.jsx)(`span`,{className:`block truncate text-xs font-normal text-muted-foreground`,title:t,children:t})]}),(0,E.jsx)(`button`,{type:`button`,"aria-label":`Hide scan progress for ${t}`,title:`Hide progress; scanning continues`,className:`rounded p-1 hover:bg-muted focus-visible:outline focus-visible:outline-2`,onClick:()=>a(e=>new Set([...e,...s.map(o)])),children:(0,E.jsx)(c,{"aria-hidden":`true`,className:`h-4 w-4`})})]}),(0,E.jsx)(`div`,{className:`max-h-48 space-y-3 overflow-y-auto`,children:s.map(e=>{let{scanned:t=0,total:n=null}=e.progress||{},r=n&&n>0?Math.min(100,Math.round(t/n*100)):null,i=typeof e.config?.label==`string`?e.config.label:e.address;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,E.jsx)(`span`,{className:`truncate`,children:i}),(0,E.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:n===null?`${t} files`:`${t} / ${n}`})]}),(0,E.jsx)(`div`,{role:`progressbar`,"aria-label":`Scanning ${i}`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r??void 0,className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-primary ${r===null?`animate-pulse`:`transition-all`}`,style:{width:r===null?`35%`:`${r}%`}})})]},e.address)})})]}):null}var et=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:null;function tt(e){return`/${e}`.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`}function nt(e,t,n){if(e==null)return[];if(Array.isArray(e))return e.flatMap(e=>nt(e,t,n));if(typeof e==`string`)return[{tree:null,kind:t,path:tt(e)}];let r=et(e);if(!r)return[];let i=r.tree??r.treeId,a=typeof i==`string`?n.get(i)??null:null;return[].concat(r.paths??r.path??`/`).filter(e=>typeof e==`string`).map(e=>({tree:a,kind:t,path:tt(e)}))}function D(e){let t=[],n=e=>{let n=Number(e);Number.isSafeInteger(n)&&n>0&&t.push(n)};return Array.isArray(e.ids)&&e.ids.forEach(n),Array.isArray(e.documentIds)&&e.documentIds.forEach(n),e.id!=null&&n(e.id),e.documentId!=null&&n(e.documentId),t}function rt(e){let t=new Map;for(let n of e)t.set(n.id,n.name),t.set(n.name,n.name);return t}function it(e,t,n=new Map){let r=et(t);if(!r)return{targets:[],ids:[],unknown:!0};if(e.startsWith(`tree.`)){let e=typeof r.treeName==`string`?r.treeName:null,t=r.treeType===`directory`||r.treeType===`context`?r.treeType:null,n=r.contextSpec??r.path;return typeof n==`string`?{targets:[{tree:e,kind:t,path:tt(n)}],ids:D(r),unknown:!1}:{targets:[],ids:[],unknown:!0}}let i=[...nt(r.context,`context`,n),...nt(r.directory,`directory`,n)],a=et(r.changed);a&&i.push(...nt(a.context,`context`,n),...nt(a.directory,`directory`,n));let o=D(r);if(i.length)return{targets:i,ids:o,unknown:!1};let s=r.reason===`content`||r.reason===`relations`;return e.startsWith(`document.updated`)&&s&&o.length?{targets:[],ids:o,unknown:!1}:{targets:[],ids:o,unknown:!0}}function O(e,t){return e===t||e===`/`||t===`/`||e.startsWith(`${t}/`)||t.startsWith(`${e}/`)}function at(e,t){if(e.kind&&e.kind!==t.kind||e.tree&&e.tree!==t.tree)return!1;if(t.kind===`context`){let n=e=>tt(e).split(`/`).filter(Boolean).map(e=>e.normalize(`NFKC`).trim().replace(/\s+/g,` `).replace(/[^\p{L}\p{N}\p{M} .+_@-]/gu,`_`).replace(/_+/g,`_`).toLowerCase()||`_`),r=new Set(n(e.path)),i=n(t.path);return r.size===0||i.length===0||i.some(e=>r.has(e))}return O(e.path,t.path)}function ot(e){return it(`tree.refresh`,{treeName:e?.treeName,path:e?.path||`/`})}function st(e,t,n){if(e.unknown||e.targets.length&&(t.wholeWorkspace||e.targets.some(e=>at(e,t))))return!0;if(e.ids.length&&n){let t=n instanceof Set?n:new Set(n);if(e.ids.some(e=>t.has(e)))return!0}return!1}function ct(e,t,n={}){return m.request(C,{workspace:e,specs:t,opts:n})}function lt(e,t,n){return m.request(Ye,{sessionId:e,label:t,spec:n})}function ut(e){return m.request(Xe,{sessionId:e})}function k(e,t={}){return m.request(Ze,{sessionId:e,...t})}function dt(e){return m.request(Qe,{sessionId:e})}function ft(e){return m.on(w,e)}var pt=100;function mt({workspaceRef:e,specs:t,opts:n,enabled:r=!0}){let[i,a]=(0,T.useState)([]),[o,s]=(0,T.useState)(0),[c,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(null),f=(0,T.useRef)([]),p=(0,T.useRef)(new Map),h=(0,T.useRef)(null),ee=(0,T.useRef)(null),g=(0,T.useRef)(null),_=(0,T.useRef)({}),te=(0,T.useRef)(null),ne=(0,T.useMemo)(()=>JSON.stringify(t),[t]),re=(0,T.useMemo)(()=>JSON.stringify(n??{}),[n]),v=(0,T.useCallback)(()=>{let e=p.current;a(f.current.map(t=>e.get(t)).filter(Boolean))},[]),ie=(0,T.useCallback)(async e=>{let t=ee.current;if(!t||e.length===0)return[];let n=[];for(let r=0;r<e.length;r+=pt){let i=e.slice(r,r+pt),a=await pe(t,`/`,[],{ids:i,scope:`workspace`,limit:i.length});n.push(...a.payload||[])}return n},[]),ae=(0,T.useCallback)(async(e,t,n)=>{if(t.length>0){let e=new Set(t);f.current=f.current.filter(t=>!e.has(t));for(let t of e)p.current.delete(t)}let r=e.filter(e=>!p.current.has(e)),i=new Set(f.current);for(let t of e)i.has(t)||(f.current.push(t),i.add(t));if(n!==null&&s(n),v(),r.length===0)return;let a=await ie(r);for(let e of a)p.current.set(e.id,e);let o=new Set(a.map(e=>e.id)),c=r.filter(e=>!o.has(e));if(c.length>0){let e=new Set(c);f.current=f.current.filter(t=>!e.has(t))}v()},[ie,v]),y=(0,T.useCallback)(async(e,t)=>{let n=e??[],r=new Set(n);f.current=f.current.filter(e=>r.has(e));for(let e of p.current.keys())r.has(e)||p.current.delete(e);let i=new Set(f.current),a=n.filter(e=>!i.has(e));await ae(a,[],t)},[ae]);(0,T.useEffect)(()=>{if(ee.current=e??null,!r||!e)return;let t=!1,n=null,i=async()=>{try{let r=await ct(e,JSON.parse(ne),JSON.parse(re));if(t){dt(r.sessionId).catch(()=>{});return}n=r.sessionId,h.current=r.sessionId,l(r.sessionId),d(null),f.current=[],p.current=new Map,await y(r.ids,r.count)}catch(e){if(t)return;d(e instanceof Error?e.message:`Failed to open query session`),l(null),h.current=null}};i();let o=m.on(`connect`,()=>{i()});return()=>{t=!0,o?.();let e=n??h.current;e&&dt(e).catch(()=>{}),h.current=null,f.current=[],p.current=new Map,l(null),a([]),s(0)}},[e,ne,re,r]),(0,T.useEffect)(()=>{if(!c)return;let e=ft(e=>{if(e.sessionId===c){if(g.current!==null){te.current?.(g.current,_.current);return}e.ids===void 0?ae(e.added??[],e.removed??[],e.count):y(e.ids,e.count)}});return()=>{e?.()}},[c,ae,y]);let oe=(0,T.useCallback)(async()=>{let e=h.current;if(e)try{let t=await ut(e);await y(t.ids,t.count)}catch{}},[y]),se=(0,T.useCallback)(async(e,t)=>{let n=h.current;if(!n)throw Error(`No open query session`);let r=await lt(n,e,t);if(g.current!==null){await te.current?.(g.current,_.current);return}await y(r.ids,r.count)},[y]),ce=(0,T.useCallback)(async(e,t={})=>{let n=h.current;if(!n)throw Error(`No open query session`);if(g.current=e,_.current=t,e===null){await oe();return}let r=await k(n,{match:e,...t});for(let e of r.documents)p.current.set(e.id,e);f.current=r.ids,s(r.totalCount),v()},[v,oe]);(0,T.useEffect)(()=>{te.current=ce},[ce]);let le=(0,T.useCallback)(async(e,t,n={})=>{let r=h.current;if(!r)throw Error(`No open query session`);let i=await k(r,{match:t,limit:n.limit??100,...n.mode?{mode:n.mode}:{}});for(let e of i.documents)p.current.set(e.id,e);let a=await lt(r,e,{ids:i.ids});return await y(a.ids,a.count),i.ids},[y]);return{documents:i,count:o,ready:c!==null,error:u,setCue:se,resync:oe,rank:ce,rankAndPin:le}}function ht({data:e,className:t}){let[n,r]=(0,T.useState)(!0),{rows:i,gapIndex:a,span:c}=(0,T.useMemo)(()=>{let t=[...e.distances].sort((e,t)=>e.distance-t.distance),n=[];for(let e=1;e<t.length;e++)n.push(t[e].distance-t[e-1].distance);let r=n.length?[...n].sort((e,t)=>e-t)[Math.floor(n.length/2)]:0,i=-1,a=0;for(let e=0;e<n.length;e++)n[e]>a&&(a=n[e],i=e+1);let o=i>0&&a>=Math.max(r*4,1e-6),s=t[0]?.distance??0,c=t[t.length-1]?.distance??0;return{rows:t,gapIndex:o?i:-1,span:{first:s,last:c,biggest:a,median:r}}},[e.distances]);if(i.length===0)return(0,E.jsxs)(`div`,{className:u(`rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground`,t),children:[`Query debug: no image distances for “`,e.query,`”. The dense side returned nothing: either no photos are embedded in this scope, or the image space is not ready.`]});let l=a>0?i[a].distance:null;return(0,E.jsxs)(`div`,{className:u(`rounded-md border border-border bg-muted/30 text-xs`,t),children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center gap-1.5 px-3 py-2 text-left font-medium`,children:[n?(0,E.jsx)(s,{className:`h-3.5 w-3.5`}):(0,E.jsx)(o,{className:`h-3.5 w-3.5`}),`Query debug`,(0,E.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`: image distances for “`,e.query,`” (`,i.length,` nearest, unfloored)`]})]}),n&&(0,E.jsxs)(`div`,{className:`space-y-2 border-t border-border px-3 py-2`,children:[(0,E.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Best-first cosine distance (0 = identical). Scroll to where the photos stop being relevant and set the image relevance floor just above that value in Settings → Database → Search tuning.`,l===null?(0,E.jsxs)(E.Fragment,{children:[` `,(0,E.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:`No boundary in this window`}),`; the distances step evenly (typical Δ`,c.median.toFixed(4),`), so there is nothing here to set a floor from. Relevance probably ends further down the list than this window reaches, or the model is not separating this query at all.`]}):(0,E.jsxs)(E.Fragment,{children:[` A jump at `,(0,E.jsx)(`span`,{className:`font-mono`,children:l.toFixed(4)}),` (Δ`,c.biggest.toFixed(4),`, vs typical Δ`,c.median.toFixed(4),`) stands out (a likely boundary).`]})]}),(0,E.jsx)(`div`,{className:`max-h-56 overflow-y-auto`,children:(0,E.jsx)(`table`,{className:`w-full font-mono text-[11px]`,children:(0,E.jsx)(`tbody`,{children:i.map((e,t)=>(0,E.jsxs)(`tr`,{className:u(`border-b border-border/40 last:border-0`,t===a&&`border-t-2 border-t-amber-500/70`),children:[(0,E.jsx)(`td`,{className:`py-0.5 pr-3 text-muted-foreground`,children:t+1}),(0,E.jsxs)(`td`,{className:`py-0.5 pr-3`,children:[`#`,e.id]}),(0,E.jsx)(`td`,{className:`py-0.5 tabular-nums`,children:e.distance.toFixed(4)}),t===a&&(0,E.jsx)(`td`,{className:`py-0.5 pl-2 font-sans text-[10px] text-amber-600 dark:text-amber-500`,children:`← biggest gap`})]},e.id))})})}),(0,E.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Range `,c.first.toFixed(4),` – `,c.last.toFixed(4),` (spread `,(c.last-c.first).toFixed(4),`) over `,i.length,` rows. Absolute values shift with the model and are not comparable across models. After a re-embed every floor has to be picked again. A spread this narrow relative to the range means ranking is doing the work, not distance.`]})]})]})}function gt(e,t){if(!e)return[];let n=t.split(`/`).filter(Boolean),r=e;for(let e of n)if(r=r?.children?.find(t=>t.name===e)??null,!r)return[];let i=n.length?`/${n.join(`/`)}`:``,a=(r.children??[]).filter(e=>e.type!==`canvas`).map(e=>({name:e.name,path:`${i}/${e.name}`,label:e.label,color:e.color,childCount:e.children?.length??0})).sort((e,t)=>(e.label||e.name).localeCompare(t.label||t.name,void 0,{numeric:!0,sensitivity:`base`}));return n.length>0&&a.unshift({name:`..`,path:n.length>1?`/${n.slice(0,-1).join(`/`)}`:`/`,isParent:!0}),a}var A=new Map;function _t(e,t,n){return`${e}\0${t}\0${n}`}function vt(e,t,n,r,i,a,o=``,s=``,c=`path`){return`${_t(e,t,n)}\0${r}\0${i}\0${a}\0${o}\0${s}\0${c}`}function j(e,t,n){let r=_t(e,t,n);for(let e of A.keys())e.startsWith(r)&&A.delete(e)}function yt(e,t){let n=`${e}\0`;for(let[e,r]of A){if(!e.startsWith(n))continue;let[,i,a,,,,,,o=`path`]=e.split(`\0`);st(t,{tree:i,kind:b(i),path:a,wholeWorkspace:o.startsWith(`workspace`)},r.documents.map(e=>Number(e.id)))&&A.delete(e)}}function bt(e,t){yt(t?.workspaceName??e,ot(t))}function xt(){let{workspaceName:e}=r();return e?(0,E.jsx)(Le,{workspaceName:e,children:(0,E.jsx)(M,{})}):null}function M(){let{workspaceName:e,treeName:t}=r(),n=a(),o=i(),{showToast:s,showProgress:c}=h(),l=new URLSearchParams(n.search),Le=(()=>{let e=l.getAll(`q`).map(e=>e.trim()).filter(Boolean);if(e.length>0)return e;let t=(l.get(`search`)||``).trim();return t?[t]:[]})(),[C,Ye]=(0,T.useState)(null),[Xe,Ze]=(0,T.useState)(!0),[Qe,w]=(0,T.useState)([]),[et,tt]=(0,T.useState)(!1),[nt,D]=(0,T.useState)(0),O=Je(),[at,ct]=(0,T.useState)(null),[lt,ut]=(0,T.useState)(O);lt!==O&&(ut(O),O||ct(null));let[k,dt]=(0,T.useState)(`path`),[ft,pt]=(0,T.useState)(!1),[_t,xt]=(0,T.useState)(null),[M,St]=(0,T.useState)(null),[wt,Tt]=(0,T.useState)(``),[Et,Dt]=(0,T.useState)(!1),[Ot,kt]=(0,T.useState)(!1),[At,jt]=(0,T.useState)(!1),[N,Mt]=(0,T.useState)(null),[P,F]=(0,T.useState)(1),[I,Nt]=(0,T.useState)(50),[L,Pt]=(0,T.useState)(Le),[Ft,It]=(0,T.useState)(null),{state:R,saveFilters:Lt,setSort:Rt,setAccentColor:zt,setMapDocuments:Bt}=Ce(),Vt=R.filters.features.allOf,z=R.filters.features.anyOf,Ht=R.filters.features.noneOf,Ut=Oe(R.filters.timeline),Wt=De(R.filters.geo),Gt=Ae(R.filters.lens,R.filters.geo.includeUnlocated),B=R.filters.lens.ids,Kt=[...Ut,...Wt,...Gt],qt=R.filters.sort??ke,Jt=JSON.stringify({a:Vt,b:z,c:Ht,d:Kt,i:B,s:qt}),Yt=JSON.stringify({a:Vt,b:z,c:Ht,d:Kt,s:qt}),V=je(n.pathname).path,H=t??`context`,U=H===`backends`,[Xt,Zt]=(0,T.useState)([]);(0,T.useEffect)(()=>{!U||!e||le(e).then(Zt).catch(()=>Zt([]))},[U,e]);let Qt=U?me(V,Xt):null,[$t,en]=(0,T.useState)(!1),tn=`${H}\0${V}`,[nn,rn]=(0,T.useState)(tn);nn!==tn&&(rn(tn),en(!1));let W=l.get(`layer`)===`1`,G=l.get(`layerId`)||null,[K,an]=(0,T.useState)(null),[q,on]=(0,T.useState)(null),sn=(0,T.useRef)(null);(0,T.useEffect)(()=>{sn.current=q},[q]);let[cn,ln]=(0,T.useState)(`left`),[un,dn]=(0,T.useState)([]),{openM1Drawer:fn,openM2Drawer:pn,goBack:mn}=Pe(),[hn,gn]=(0,T.useState)([]),J=(0,T.useMemo)(()=>{if(!K||V===`/`||W)return null;let e=V.split(`/`).filter(Boolean),t=K;for(let n of e)if(t=t?.children?.find(e=>e.name===n)??null,!t)return null;return t},[K,V,W]),Y=J?.type===`canvas`?`canvas`:null,_n=(0,T.useRef)(null);(0,T.useEffect)(()=>{!e||!K||W||_n.current===`${e}/${H}`&&(V!==`/`&&!J||Fe(e,H,V))},[e,K,W,V,J,H]);let vn=(0,T.useMemo)(()=>W||k===`workspace`||L.length>0||b(H)!==`directory`?[]:gt(K,V),[K,V,H,W,k,L]),yn=W?null:V===`/`?K:J,X=xe(),bn=`${H}\0${V}`,[xn,Sn]=(0,T.useState)(null),Cn=xn?.key===bn?xn.views:He(yn?.metadata),wn=X?.pinned&&X.view?[X.view,...Cn.filter(e=>e.id!==X.view.id)]:Cn,Tn=X?.pinned&&X.view?X.view.id:xn?.key===bn?xn.activeId:wn[0]?.id??Be.id,Z=wn.find(e=>e.id===Tn)??wn[0]??Be;(0,T.useEffect)(()=>{X?.selectView(Z)},[Z,X]);let En=U?void 0:X?.schema??ze(Z),Dn=En?[...Vt,En]:Vt,On=e=>{let t=wn.find(t=>t.id===e);t&&X?.selectView(t),F(1),dn([]),Sn({key:bn,views:wn,activeId:e})},kn=(t,n)=>{n&&n!==Tn&&(F(1),dn([]));let r=t.find(e=>e.id===(n??Tn));r&&X?.selectView(r),Sn({key:bn,views:t,activeId:n??Tn}),ie(e,V,{metadata:{...yn?.metadata??{},views:t}},H).catch(()=>{s({title:`View not saved`,description:`Could not persist views to the layer`,variant:`destructive`})})},An=Y===`canvas`&&typeof J?.querySpec?.query==`string`?J.querySpec.query:``,jn=Y===`canvas`?{label:J?.label,description:J?.description,color:J?.color}:null,{isPinned:Mn,pin:Nn,unpin:Pn,pins:Fn}=ve(),In=C?.name,Q=(0,T.useMemo)(()=>In&&Y===`canvas`&&!W?{workspaceName:In,treeName:H,path:V}:null,[In,Y,W,H,V]),Ln=Q?Mn(Q):!1,Rn=J?.id,zn=J?.label,Bn=(0,T.useCallback)(async()=>{if(Q)try{let e=Fn.find(e=>e.workspaceName===Q.workspaceName&&e.treeName===Q.treeName&&e.path===Q.path);e?await Pn(e.id):await Nn({...Q,layerId:Rn,label:zn})}catch(e){console.error(`Failed to update home pins:`,e)}},[Q,Fn,Nn,Pn,Rn,zn]),Vn=e?`${e}://${V===`/`?``:V.replace(/^\//,``)}`:``,Hn=we(C?.color)||null;(0,T.useEffect)(()=>(zt(Hn),()=>zt(null)),[Hn,zt]);let Un=(0,T.useCallback)(async t=>{let n=B;if(t?.anyOf?.length&&z.length&&(n=((await he(e,V,H,{limit:0,anyOf:z,ids:B,applyCanvasSpec:!1})).payload||[]).map(e=>e.id),!n.length))return{payload:[],count:0,totalCount:0};let r=await he(e,V,H,{limit:t?.limit,offset:t?.offset,page:t?.page,sortBy:t?.sortBy,order:t?.order,allOf:[...Vt,...t?.allOf??[]],anyOf:t?.anyOf?.length?t.anyOf:z,noneOf:Ht,filters:Kt,ids:n,queries:[...L,...t?.queries??[],...t?.q?[t.q]:[]],applyCanvasSpec:!1});return{payload:r.payload||[],count:r.count??void 0,totalCount:r.totalCount??void 0}},[e,V,H,Jt,L]);(0,T.useEffect)(()=>{e&&(async()=>{Ze(!0);try{let t=await p.get(`${f.workspaces}/${e}`),n;n=t&&`workspace`in t?t.workspace:t,Ye(n)}catch(t){let n=t instanceof Error?t.message:`Failed to fetch workspace ${e}`;s({title:`Error`,description:n,variant:`destructive`}),Ye(null)}finally{Ze(!1)}})()},[e,s]),(0,T.useEffect)(()=>{let e=e=>{let t=e.detail?.workspace;t&&Ye(e=>e&&(t===e.name||t===e.id)&&e.status!==`active`?{...e,status:`active`}:e)};return window.addEventListener(`workspace:autostarted`,e),()=>window.removeEventListener(`workspace:autostarted`,e)},[]);let Wn=(B?.length??0)>0&&!W&&!($t&&Qt)&&L.length<=1,{documents:Gn,count:Kn,ready:qn,setCue:Jn,resync:Yn,rank:Xn}=mt({workspaceRef:e,specs:(0,T.useMemo)(()=>{let e={features:{allOf:Dn,anyOf:z,noneOf:Ht},filters:Kt};return k!==`workspace`&&(b(H)===`directory`?e.directory={tree:H,path:V}:e.context=V),[{label:`scope`,spec:e}]},[Yt,V,H,k,En]),opts:(0,T.useMemo)(()=>({mode:`live`,debounceMs:150}),[]),enabled:Wn}),Zn=Wn&&qn,Qn=(0,T.useRef)(!1);(0,T.useEffect)(()=>{Qn.current=Zn},[Zn]);let $n=L.length===1?L[0].trim():``;(0,T.useEffect)(()=>{qn&&Xn($n?{text:$n}:null,{limit:I,offset:(P-1)*I}).catch(()=>{})},[qn,$n,I,P,Xn]);let er=(B??[]).join(`,`);(0,T.useEffect)(()=>{qn&&Jn(`lens`,{ids:B??[]}).catch(()=>{})},[qn,er,Jn,B]);let tr=Zn?Gn:Qe,nr=Zn?Kn:nt,rr=(0,T.useRef)(new Set);(0,T.useEffect)(()=>{rr.current=new Set(tr.map(e=>Number(e.id)))},[tr]);let ir=R.geoSelection;(0,T.useEffect)(()=>{Bt(tr,C?.name??null)},[tr,C?.name,Bt]),(0,T.useEffect)(()=>()=>Bt([]),[Bt]);let ar=(0,T.useMemo)(()=>ir?tr.filter(e=>Te(e,ir,R.filters.geo.includeUnlocated)):tr,[tr,ir,R.filters.geo.includeUnlocated]),or=ue(V,Dn,{treeName:H,treeType:b(H),scope:k,queries:L,anyOf:z,noneOf:Ht,filters:Kt,ids:B,layerId:W&&G?G:void 0}),sr=JSON.stringify([e,or]),[cr,lr]=(0,T.useState)(``),[ur,dr]=(0,T.useState)(!1),fr=(0,T.useRef)(!1),pr=et||ur||cr!==sr||Zn||!!ir,mr=(0,T.useRef)(0),hr=(0,T.useRef)(null);(0,T.useEffect)(()=>()=>{mr.current++,hr.current=null},[]);let gr=(0,T.useRef)(``),$=(0,T.useCallback)(async t=>{if(!e)return;if(Ee(H,V)){mr.current++,hr.current=null,gr.current=``,w([]),D(0),tt(!1);return}if(Qn.current)return;let n=`${$t&&Qt?`${k}:unfiled`:k}:${En??``}`,r=(B?.length??0)>0,i=vt(e,H,V,P,I,L.join(`␟`),Yt,W&&G?G:``,n),a=r&&i===gr.current;gr.current=i;let o=vt(e,H,V,P,I,L.join(`␟`),Jt,W&&G?G:``,n),c=`${o}\0${O}`;if(t?.silent&&hr.current?.key===c){hr.current.refreshPending=!0;return}let l=++mr.current,u=t?.silent||r||O?void 0:A.get(o);u&&(w(u.documents),D(u.totalCount),lr(sr),tt(!1)),(t?.silent??(a||!!u))||tt(!0);let d={key:c,refreshPending:!1};hr.current=d;try{let t;t=$t&&Qt?await _e(e,Qt.driver,Qt.address,{linked:!1,limit:I,offset:(P-1)*I}):W&&G&&k!==`workspace`?await se(e,H,G,{limit:I,page:P,queries:L,allOf:Dn,anyOf:z,noneOf:Ht,filters:Kt,ids:B,sortBy:qt.sortBy||void 0,order:qt.order}):await pe(e,V,Dn,{limit:I,page:P,treeName:H,treeType:H===`directory`||H===`backends`?`directory`:`context`,queries:L,anyOf:z,noneOf:Ht,filters:Kt,ids:B,sortBy:qt.sortBy||void 0,order:qt.order,scope:k,debug:O&&L.length>0,debugLimit:200});let n=t.payload||[],i=t.totalCount||t.count||0;if(!r&&!d.refreshPending&&A.set(o,{documents:n,totalCount:i}),l!==mr.current)return;let s=t.debug,c=s?.imageDistances??s?.distances??null;ct(c?{query:L[L.length-1]??``,distances:c}:null),w(a?e=>e.length===n.length&&e.every((e,t)=>e.id===n[t].id)?e:n:n),D(i),lr(sr)}catch(e){if(l!==mr.current)return;let t=e instanceof Error?e.message:`Failed to fetch documents`;s({title:`Error`,description:t,variant:`destructive`}),w([]),D(0)}finally{hr.current===d&&(hr.current=null),l===mr.current&&tt(!1),l===mr.current&&d.refreshPending&&$({silent:!0})}},[e,V,H,G,W,P,I,C?.status,L,Jt,k,$t,O,En]);(0,T.useEffect)(()=>{$()},[$]),(0,T.useEffect)(()=>{let t=t=>{let n=t.detail;!n||n.workspaceName!==e||(on({treeName:n.treeName||`context`,path:Me(n.path||`/`)}),ln(`left`))};return window.addEventListener(`workspace:open-to-side`,t),()=>window.removeEventListener(`workspace:open-to-side`,t)},[e,H,V]),(0,T.useEffect)(()=>{let t=t=>{let n=t.detail;if(!(n?.workspaceName&&n.workspaceName!==e)&&(e&&bt(e,n),st(ot(n),{tree:H,kind:b(H),path:V,wholeWorkspace:k===`workspace`}))){if(e&&j(e,H,V),Qn.current){Yn();return}$({silent:!0})}};return window.addEventListener(`workspace:documents:refresh`,t),()=>window.removeEventListener(`workspace:documents:refresh`,t)},[$,e,V,H,k,Yn]);let _r=C?.name,vr=C?.id;(0,T.useEffect)(()=>{if(!e||!_r&&!vr)return;let t=[_r,vr].filter(Boolean).map(e=>`workspace:${e}`),n=()=>t.forEach(e=>m.emit(`subscribe`,{channel:e}));n();let r=m.on(`connect`,n),i=new Map,a=!1,o=()=>{ne(e).then(e=>{a||(i=rt(e))}).catch(()=>{})};o();let s=null,c=0,l=!1,u=null,d=()=>{if(s=null,c=Date.now(),u){let{treeName:t,path:n}=u;u=null,window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e,treeName:t,path:n}}))}if(l){if(l=!1,Qn.current){Yn();return}$({silent:!0})}},f=t=>n=>{(t.startsWith(`tree.created`)||t.startsWith(`tree.renamed`))&&o();let r=it(t,n,i);yt(e,r);let a={tree:H,kind:b(H),path:V,wholeWorkspace:k===`workspace`},f=sn.current;f&&st(r,{tree:f.treeName,kind:b(f.treeName),path:f.path})&&(u=f),st(r,a,rr.current)&&(l=!0),!(!l&&!u)&&(s||=setTimeout(d,Math.max(200,c+1500-Date.now())))},p=[`document.inserted`,`document.inserted.batch`,`document.updated`,`document.removed`,`document.deleted`,`document.removed.batch`,`document.deleted.batch`,`document.linked`,`document.unlinked`,`document.linked.batch`,`document.unlinked.batch`,`tree.document.inserted`,`tree.document.inserted.batch`,`tree.document.removed`,`tree.document.removed.batch`,`tree.document.deleted`,`tree.document.deleted.batch`,`tree.layer.merged`,`tree.layer.subtracted`,`tree.created`,`tree.renamed`].map(e=>[e,f(e)]);return p.forEach(([e,t])=>m.on(e,t)),()=>{a=!0,s&&clearTimeout(s),r?.(),p.forEach(([e,t])=>m.off(e,t))}},[e,vr,_r,H,V,k,$,Yn]);let yr=`${V}\0${H}\0${G??``}\0${k}`,[br,xr]=(0,T.useState)(yr);br!==yr&&(xr(yr),F(1),It(null));let Sr=`${V}\0${H}\0${G??``}`,[Cr,wr]=(0,T.useState)(Sr);Cr!==Sr&&(wr(Sr),dt(`path`));let Tr=(e,t)=>{let n=e===`/`?`canvas`:e.split(`/`).pop()||`canvas`;Tt(n),St({parentPath:e,captureView:t})},Er=l.get(`createCanvas`)===`1`,[Dr,Or]=(0,T.useState)(!1);Dr!==Er&&(Or(Er),Er&&Tr(V,!1)),(0,T.useEffect)(()=>{if(!Er)return;let e=new URLSearchParams(n.search);e.delete(`createCanvas`);let t=e.toString();o(`${n.pathname}${t?`?${t}`:``}${n.hash}`,{replace:!0})},[Er,V]);let kr=(0,T.useCallback)(e=>{let t=new URLSearchParams(n.search);t.delete(`q`),t.delete(`search`);for(let n of e)t.append(`q`,n);let r=t.toString();o(`${n.pathname}${r?`?${r}`:``}${n.hash}`)},[n.pathname,n.search,n.hash,o]),Ar=JSON.stringify([l.has(`q`),...Le]),[jr,Mr]=(0,T.useState)(Ar);jr!==Ar&&(Mr(Ar),Pt(Le),F(1));let Nr=`${Ar}\0${Y??``}\0${An}\0${V}\0${Ft??``}`,[Pr,Fr]=(0,T.useState)(Nr);Pr!==Nr&&(Fr(Nr),l.has(`q`)||Le.length>0||Y!==`canvas`||Ft===V||(Pt(An?[An]:[]),F(1)));let Ir=(0,T.useCallback)(e=>{let t=e.trim();t&&(It(null),Pt(e=>{if(e.includes(t))return e;let n=[...e,t];return kr(n),F(1),n}))},[kr,It,Pt,F]),Lr=(0,T.useCallback)(e=>{Pt(t=>{let n=e<0?[]:t.filter((t,n)=>n!==e);return n.length===0&&It(V),kr(n),F(1),n})},[kr,V,It,Pt,F]),Rr=L.join(` `).trim(),zr=!!R.activeContextType&&(R.isDirty||Rr!==(Y===`canvas`?An:R.savedSearchQuery||``));!e&&K!==null&&an(null),(0,T.useEffect)(()=>{let t=!1;if(!e)return;let n=0,r=!1,i=(i=!1)=>{let a=++n;i&&fe(e,H),te(e,H).then(i=>{!t&&a===n&&(r=!0,_n.current=`${e}/${H}`,an(i))}).catch(()=>{!t&&a===n&&!r&&an(null)})};i(!1);let a=t=>{let n=t.detail;n?.workspaceName&&n.workspaceName!==e||n?.treeName&&n.treeName!==H||i(!n?.cacheInvalidated)};window.addEventListener(`workspace:tree:refresh`,a);let o=S(e,vr);return()=>{t=!0,o(),window.removeEventListener(`workspace:tree:refresh`,a)}},[e,H,vr]),!(e&&Y===`canvas`&&!W)&&N!==null&&Mt(null),(0,T.useEffect)(()=>{let t=!1;if(!(!e||Y!==`canvas`||W))return oe(e,V,H).then(e=>{t||Mt(e)}).catch(()=>{t||Mt(null)}),()=>{t=!0}},[e,V,H,Y,W]);let Br=async()=>{if(C){pt(!0);try{let t=await x(e||C.id);Ye(t),s({title:`Success`,description:`Workspace started successfully`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){let t=e instanceof Error?e.message:`Failed to start workspace`;s({title:`Error`,description:t,variant:`destructive`})}finally{pt(!1)}}},Vr=async t=>{if(!C)return;let n=c({title:`Removing…`,description:`Document from "${V}"`});try{await _(e||C.id,[t],V,[],H,Yr,{trashIfOrphaned:!0}),j(e||C.id,H,V),w(e=>e.filter(e=>e.id!==t)),D(e=>Math.max(0,e-1)),n.done({title:`Success`,description:`Document removed from workspace path.`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to remove document`,variant:`destructive`})}},Hr=async t=>{if(!C)return;let n=c({title:`Deleting…`,description:`Document from "${V}"`});try{await ae(e||C.id,[t],V,[],H,Yr),j(e||C.id,H,V),w(e=>e.filter(e=>e.id!==t)),D(e=>Math.max(0,e-1)),n.done({title:`Success`,description:`Document deleted.`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to delete document`,variant:`destructive`})}},Ur=async t=>{if(!C)return;let n=c({title:`Removing…`,description:`${t.length} document(s) from "${V}"`});try{await _(e||C.id,t,V,[],H,Yr,{trashIfOrphaned:!0}),j(e||C.id,H,V),w(e=>e.filter(e=>!t.includes(e.id))),D(e=>Math.max(0,e-t.length)),n.done({title:`Success`,description:`${t.length} document(s) removed.`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to remove documents`,variant:`destructive`})}},Wr=async t=>{if(!C)return;let n=c({title:`Deleting…`,description:`${t.length} document(s)`});try{await ae(e||C.id,t,V,[],H,Yr),j(e||C.id,H,V),w(e=>e.filter(e=>!t.includes(e.id))),D(e=>Math.max(0,e-t.length)),n.done({title:`Success`,description:`${t.length} document(s) deleted.`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to delete documents`,variant:`destructive`})}},Gr=async t=>{if(!C)return;let n=c({title:`Destroying…`,description:`Document and its backend copies`});try{let r=await re(e||C.id,[t]);if(r.failed?.length){n.fail({title:`Error`,description:r.failed[0].reason,variant:`destructive`});return}w(e=>e.filter(e=>e.id!==t)),D(e=>Math.max(0,e-1)),n.done({title:`Destroyed`,description:`Document removed from all backends.`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to destroy document`,variant:`destructive`})}},Kr=async t=>{if(!C)return;let n=c({title:`Destroying…`,description:`${t.length} document(s) and their backend copies`});try{let r=await re(e||C.id,t),i=new Set(r.successful?.filter(e=>e.docDeleted).map(e=>e.id)??[]);w(e=>e.filter(e=>!i.has(e.id))),D(e=>Math.max(0,e-i.size));let a=[r.successful?.length?`${r.successful.length} destroyed`:null,r.failed?.length?`${r.failed.length} failed`:null].filter(Boolean).join(`, `);r.failed?.length?n.fail({title:`Destroy incomplete`,description:a,variant:`destructive`}):n.done({title:`Destroyed`,description:a||`No documents destroyed`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to destroy documents`,variant:`destructive`})}},qr=e=>{xt({documentIds:e,operation:`copy`,sourcePath:V,sourceTreeName:H}),window.dispatchEvent(new CustomEvent(`documents:clipboard`,{detail:{documentIds:e,operation:`copy`}})),s({title:`Copied`,description:`${e.length} document(s) copied to clipboard`})},Jr=e=>{xt({documentIds:e,operation:`cut`,sourcePath:V,sourceTreeName:H}),window.dispatchEvent(new CustomEvent(`documents:clipboard`,{detail:{documentIds:e,operation:`cut`}})),s({title:`Cut`,description:`${e.length} document(s) cut to clipboard`})},Yr=b(H),Xr=async(t,n,r={})=>{if(!e)return!1;let i=r.targetTreeName??H,a=r.targetTreeType??Yr,o=r.move??_t?.operation===`cut`,s=c({title:o?`Moving…`:`Pasting…`,description:`${n.length} document(s) → "${t}"`});try{let c=await ee(e,t,n,i,a);if(c){j(e,i,t);let a=r.sourceTreeName||_t?.sourceTreeName,c=r.sourcePath||_t?.sourcePath;if((r.move??_t?.operation===`cut`)&&c&&a){let t=b(a);await _(e,n,c,[],a,t),j(e,a,c),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e,path:c,treeName:a}}))}s.done({title:`Success`,description:`${n.length} document(s) ${o?`moved`:`pasted`} to "${t}"`}),xt(null),window.dispatchEvent(new CustomEvent(`documents:clipboard`,{detail:null}));let l=performance.now();await $(),console.info(`[paste] list refresh ${Math.round(performance.now()-l)} ms`),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e,path:t,treeName:i}}))}else s.done();return c}catch(e){return s.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to paste documents`,variant:`destructive`}),!1}},Zr=async(t,n)=>{if(!e)return!1;try{let r=(await de(e,n,t,H,Yr)).length>0;return r&&(Se(e,H,n),s({title:`Success`,description:`Imported ${t.length} document(s) to "${n}"`})),r}catch(e){return s({title:`Error`,description:e instanceof Error?e.message:`Failed to import documents`,variant:`destructive`}),!1}},Qr=async()=>{if(!C||nr===0||pr||fr.current||window.prompt(`Type PURGE to permanently delete all ${nr} matching documents across all pages.`)!==`PURGE`)return;fr.current=!0,dr(!0);let t=c({title:`Purging…`,description:`${nr} matching document(s)`});try{let n=await g(e||C.id,or,nr);n.deleted===n.requested?t.done({title:`Success`,description:`${n.deleted} document(s) purged.`}):t.fail({title:`Purge incomplete`,description:`${n.deleted} of ${n.requested} document(s) purged. Refresh and review the remaining results before retrying.`})}catch(e){t.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to purge documents`,variant:`destructive`})}finally{j(e||C.id,H,V),await $({silent:!0}),fr.current=!1,dr(!1)}},$r=()=>Tr(V,!0),ei=async()=>{if(!(!e||!M||!wt.trim())){Dt(!0);try{let t=wt.trim(),n=M.parentPath,r=n===`/`?`/${t}`:`${n}/${t}`,i={...R.filters,features:{...R.filters.features,allOf:Dn}};await ce(e,r,H,M.captureView?{metadata:{toolbox:i},querySpec:{features:i.features,filters:[...Oe(R.filters.timeline),...De(R.filters.geo)],query:Rr||void 0,sort:R.filters.sort?.sortBy?R.filters.sort:null}}:{}),St(null),fe(e,H);try{let t=await te(e,H,{force:!0});an(t)}catch{}window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),o(Ne(e,r,H))}catch(e){s({title:`Error`,description:e instanceof Error?e.message:`Failed to create canvas`,variant:`destructive`})}finally{Dt(!1)}}},ti=async()=>{if(!(!e||Y!==`canvas`)){kt(!0);try{let t=N||await ge(e,V,H);Mt(t);let n=`${window.location.origin}${t.url}`;await navigator.clipboard?.writeText(n),s({title:`Public canvas link copied`,description:n})}catch(e){s({title:`Error`,description:e instanceof Error?e.message:`Failed to share canvas`,variant:`destructive`})}finally{kt(!1)}}},ni=async()=>{if(N){kt(!0);try{await v(N.code),Mt(null),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e,treeName:H}})),s({title:`Canvas unshared`,description:`The public link no longer works.`})}catch(e){s({title:`Error`,description:e instanceof Error?e.message:`Failed to unshare canvas`,variant:`destructive`})}finally{kt(!1)}}},ri=async()=>{if(!e||Y!==`canvas`||V===`/`)return;let t=jn?.label||V.split(`/`).pop()||`canvas`,n=N?` Its public link will stop working.`:``;if(window.confirm(`Delete canvas "${t}"? This cannot be undone.${n}`)){jt(!0);try{if(N)await v(N.code),Mt(null);else if(J?.locked){s({title:`Canvas is locked`,description:`Unlock it before deleting.`,variant:`destructive`});return}await y(e,V,!1,H);let n=V.split(`/`).filter(Boolean);n.pop();let r=n.length?`/${n.join(`/`)}`:`/`;window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e,treeName:H}})),o(Ne(e,r,H)),s({title:`Canvas deleted`,description:`"${t}" was removed.`})}catch(e){s({title:`Error`,description:e instanceof Error?e.message:`Failed to delete canvas`,variant:`destructive`})}finally{jt(!1)}}},ii=(0,T.useCallback)(async t=>{if(!e||!q)return;let n={treeName:H,path:V},r=cn===`left`?n:q,i=cn===`left`?q:n,a=cn===`left`?un:hn;if(a.length===0){s({title:`Nothing selected`,description:`Tick documents in the focused pane first.`});return}let o=b(i.treeName),l=c({title:t?`Moving…`:`Copying…`,description:`${a.length} document(s) → "${i.path}"`});try{if(!await ee(e,i.path,a,i.treeName,o)){l.done();return}if(j(e,i.treeName,i.path),t){let t=b(r.treeName);await _(e,a,r.path,[],r.treeName,t),j(e,r.treeName,r.path)}[r,i].forEach(t=>window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e,path:t.path,treeName:t.treeName}}))),l.done({title:t?`Moved`:`Copied`,description:`${a.length} document(s) → "${i.path}"`})}catch(e){l.fail({title:`Error`,description:e instanceof Error?e.message:`Transfer failed`,variant:`destructive`})}},[e,q,cn,H,V,un,hn,s,c]);if((0,T.useEffect)(()=>{if(!q)return;let e=e=>{if(e.key!==`F5`&&e.key!==`F6`)return;let t=e.target;t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&(e.preventDefault(),ii(e.key===`F6`))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[q,ii]),Xe)return(0,E.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,E.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,E.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),(0,E.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading workspace...`})]})});if(!C)return(0,E.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Workspace not found.`});let ai=Y===`canvas`&&!W&&!!J,oi=!ai&&!U&&yn?(0,E.jsx)(Ue,{views:wn,activeId:Tn,onSelect:On,onSave:kn,accentColor:we(C.color),onOpenToSide:e=>{on({treeName:H,path:V,viewId:e}),ln(`right`)}}):void 0,si=Qt||C.status!==`active`?(0,E.jsxs)(E.Fragment,{children:[Qt&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{en(!$t),F(1)},"aria-pressed":$t,className:u(`min-h-10 rounded-md border px-2 text-xs`,$t&&`bg-warning/15 text-warning`),children:`Unfiled only`}),C.status!==`active`&&(0,E.jsx)(`button`,{type:`button`,onClick:Br,disabled:ft,className:`min-h-10 rounded-md border px-2 text-xs`,children:ft?`Starting…`:`Start`})]}):void 0,ci=Ee(H,V)?V===`/Trash`?(0,E.jsx)(`div`,{className:`h-full overflow-auto p-4`,children:(0,E.jsx)(Ke,{workspaceName:e||C.id})}):(0,E.jsx)(qe,{workspace:e||C.id,path:V,onNavigate:t=>o(Ne(e,t,`backends`))},e):(0,E.jsx)(We,{navigationTabs:oi,navigationActions:si,onBack:mn,accentColor:we(C.color),urlType:W?b(H)===`directory`?`${H}-layer`:`context-layer`:Y===`canvas`?`canvas`:b(H)===`directory`?H:`context`,urlDisplay:Vn,contextPath:V,treeName:H,workspaceId:e||C.id,workspaceLabel:C.label||C.name,workspaceIcon:C.icon,documentSchema:En,documents:ar,isLoading:et,totalCount:nr,currentPage:P,pageSize:I,onPageChange:F,onPageSizeChange:e=>{Nt(e),F(1)},onRemoveDocument:V===`/`?void 0:Vr,onDeleteDocument:Hr,onDestroyDocument:Gr,onRemoveDocuments:V===`/`?void 0:Ur,onDeleteDocuments:Wr,onDestroyDocuments:Kr,onCopyDocuments:qr,onCutDocuments:Jr,onPasteDocuments:U?void 0:Xr,onImportDocuments:U?void 0:Zr,onSelectionChange:dn,onBrowseTree:()=>pn(`workspaces`,`detail`,e??null),onBrowseWorkspaces:()=>fn(`workspaces`),onNavigatePath:t=>o(Ne(e,t,H)),folders:vn,onOpenFolder:t=>o(Ne(e,Me(t),H)),scope:k,onScopeChange:dt,pastedDocumentIds:_t?.documentIds,linkTree:K,onPurgeDocuments:U?void 0:Qr,disablePurgeDocuments:pr,canvasInfo:jn??void 0,isCanvasPinned:Ln,onTogglePinCanvas:Q?Bn:void 0,onSaveAsCanvas:K&&Y!==`canvas`&&!W&&!U?$r:void 0,onShareCanvas:Y===`canvas`&&!W?ti:void 0,onUnshareCanvas:N?ni:void 0,onDeleteCanvas:Y===`canvas`&&!W?ri:void 0,isSharingCanvas:Ot,isDeletingCanvas:At,isCanvasShared:!!N,isCanvasLocked:!!J?.locked,backendSearchQueries:L,onBackendSearch:Ir,serverSort:R.filters.sort,onServerSortChange:Rt,onRemoveBackendQuery:Lr,canSaveChanges:zr,isSavingChanges:R.isSaving,onSaveChanges:Lt,contentBanner:O&&at?(0,E.jsx)(ht,{data:at,className:`mb-3`}):null,children:ai&&J?(0,E.jsx)(ye,{workspaceId:e||C.id,treeName:H,path:V,layerId:J.id,querySpec:J.querySpec,metadata:J.metadata,isLocked:!!J.locked,fetchDocuments:R.isDirty?Un:void 0}):!U&&Z.kind===`columns`?(0,E.jsx)(Ve,{documents:ar,workspaceId:e||C.id,columns:Z.columns??[],onColumnsChange:e=>kn(wn.map(t=>t.id===Z.id?{...t,columns:e}:t))}):!U&&Z.kind===`app`&&Z.app&&Z.app!==`notes`?(0,E.jsx)(Ge,{app:Z.app,workspaceId:e||C.id,treeName:H,path:V}):null});return(0,E.jsxs)(Ie,{workspaceId:e||C.id,treeName:H,path:V,headerOnly:!0,className:`relative flex flex-col h-full min-h-0`,children:[(0,E.jsx)($e,{workspaceId:C.id,workspaceName:C.label||C.name},C.id),Ee(H,V)&&(0,E.jsx)(be,{workspace:C.label||C.name,workspaceIcon:C.icon,tree:H,path:V,onBack:mn,onBrowseTree:()=>pn(`workspaces`,`detail`,e||C.id),onBrowseWorkspaces:()=>fn(`workspaces`),onNavigatePath:t=>o(Ne(e,t,H)),accentColor:we(C.color)}),M&&(0,E.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,E.jsx)(Re,{title:`New canvas`,onClose:()=>St(null),children:(0,E.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ei()},className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`canvas-name`,className:`mb-1 block text-sm font-medium`,children:`Name`}),(0,E.jsx)(`input`,{id:`canvas-name`,className:`w-full rounded-md border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary`,placeholder:`Canvas name…`,value:wt,onChange:e=>Tt(e.target.value),onKeyDown:e=>{e.key===`Escape`&&St(null)},autoFocus:!0})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`mb-1 block text-sm font-medium`,children:`Parent path`}),(0,E.jsx)(`div`,{className:`flex h-10 items-center rounded-md bg-muted px-3 font-mono text-sm text-muted-foreground`,children:M.parentPath===`/`?`/`:M.parentPath})]})]}),(0,E.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,E.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:M.captureView,onChange:e=>St({...M,captureView:e.target.checked})}),(0,E.jsxs)(`span`,{children:[`Capture the current view`,(0,E.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Freezes the active filters, search and sort into the canvas.`})]})]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(d,{type:`submit`,disabled:!wt.trim()||Et,children:Et?`Creating…`:`Create canvas`}),(0,E.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>St(null),children:`Cancel`})]})]})})}),(0,E.jsxs)(`div`,{"data-canvas-panes":!0,className:`flex-1 min-h-0 flex gap-2`,children:[(0,E.jsx)(`div`,{"data-canvas-pane":!0,className:u(`flex-1 min-w-0 bg-background overflow-hidden`,q&&(cn===`left`?`ring-2 ring-primary`:`ring-1 ring-primary/20`)),onMouseDown:e=>{e.target.closest(`button,input,textarea,select,a`)||ln(`left`)},children:ci}),q&&e&&(0,E.jsx)(Ct,{workspaceName:e,workspaceLabel:C.label||C.name,workspaceIcon:C.icon,pane:q,isFocused:cn===`right`,clipboard:_t,setClipboard:xt,onFocus:()=>ln(`right`),onSelectionChange:gn,onNavigate:e=>on(t=>t&&{...t,path:e,viewId:void 0}),onClose:()=>{on(null),ln(`left`),gn([])}})]})]})}function St(e,t){if(!e||t===`/`)return e;let n=e;for(let e of t.split(`/`).filter(Boolean))if(n=n?.children?.find(t=>t.name===e)??null,!n)return null;return n}function Ct({workspaceName:e,workspaceLabel:t,workspaceIcon:n,pane:r,isFocused:i=!1,clipboard:a,setClipboard:o,onFocus:s,onSelectionChange:c,onNavigate:l,onClose:d}){let{openM1Drawer:f,openM2Drawer:p}=Pe(),{showToast:m,showProgress:g}=h(),[ne,v]=(0,T.useState)(null),[ie,y]=(0,T.useState)([]),[oe,se]=(0,T.useState)(!1),[ce,le]=(0,T.useState)(0),[ue,de]=(0,T.useState)(1),[me,he]=(0,T.useState)(50),x=b(r.treeName),ge=St(ne,r.path),_e=ge?.type===`canvas`,ve=(0,T.useMemo)(()=>x===`directory`?gt(ne,r.path):[],[ne,r.path,x]),ye=r.viewId?He(ge?.metadata).find(e=>e.id===r.viewId)??null:null,be=`${e}://${r.path===`/`?``:r.path.replace(/^\//,``)}`,xe=ze(ye),S=(0,T.useCallback)(async()=>{if(Ee(r.treeName,r.path)){y([]),le(0),se(!1);return}let t=vt(e,r.treeName,r.path,ue,me,``,xe??``),n=A.get(t);if(n){y(n.documents),le(n.totalCount);return}se(!0);try{let n=await pe(e,r.path,xe?[xe]:[],{limit:me,page:ue,treeName:r.treeName,treeType:x}),i=n.payload||[],a=n.totalCount||n.count||0;y(i),le(a),A.set(t,{documents:i,totalCount:a})}catch(e){m({title:`Error`,description:e instanceof Error?e.message:`Failed to fetch side pane documents`,variant:`destructive`}),y([]),le(0)}finally{se(!1)}},[e,r.path,r.treeName,x,me,ue,m,xe]);(0,T.useEffect)(()=>{let t=!1,n=0,i=!1,a=(a=!1)=>{let o=++n;a&&fe(e,r.treeName),te(e,r.treeName).then(e=>{!t&&o===n&&(i=!0,v(e))}).catch(()=>{!t&&o===n&&!i&&v(null)})};a(!1);let o=t=>{let n=t.detail;n?.workspaceName&&n.workspaceName!==e||n?.treeName&&n.treeName!==r.treeName||a(!n?.cacheInvalidated)};return window.addEventListener(`workspace:tree:refresh`,o),()=>{t=!0,window.removeEventListener(`workspace:tree:refresh`,o)}},[e,r.treeName]),(0,T.useEffect)(()=>{S()},[S]),(0,T.useEffect)(()=>{let t=t=>{let n=t.detail;n?.workspaceName&&n.workspaceName!==e||(bt(e,n),st(ot(n),{tree:r.treeName,kind:b(r.treeName),path:r.path})&&(j(e,r.treeName,r.path),S()))};return window.addEventListener(`workspace:documents:refresh`,t),()=>window.removeEventListener(`workspace:documents:refresh`,t)},[S,e,r.treeName,r.path]);let Se=(0,T.useCallback)(async(t,n,i={})=>{let s=i.targetTreeName??r.treeName,c=i.targetTreeType??x,l=i.move??a?.operation===`cut`,u=g({title:l?`Moving…`:`Pasting…`,description:`${n.length} document(s) → "${t}"`});try{let r=await ee(e,t,n,s,c);if(r){j(e,s,t);let r=i.sourcePath||a?.sourcePath,c=i.sourceTreeName||a?.sourceTreeName;if((i.move??a?.operation===`cut`)&&r&&c){let t=b(c);await _(e,n,r,[],c,t),j(e,c,r),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e,path:r,treeName:c}}))}u.done({title:`Success`,description:`${n.length} document(s) ${l?`moved`:`pasted`} to "${t}"`}),o(null),await S(),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e,path:t,treeName:s}}))}else u.done();return r}catch(e){return u.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to paste documents`,variant:`destructive`}),!1}},[e,r.treeName,x,S,g,a,o]),Ce=(0,T.useCallback)(()=>{j(e,r.treeName,r.path),S()},[e,r.treeName,r.path,S]),we=(0,T.useCallback)(async t=>{let n=g({title:`Removing…`,description:`${t.length} document(s) from "${r.path}"`});try{await _(e,t,r.path,[],r.treeName,x),Ce(),n.done({title:`Removed`,description:`${t.length} document(s) removed from "${r.path}"`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to remove documents`,variant:`destructive`})}},[e,r.path,r.treeName,x,Ce,g]),Te=(0,T.useCallback)(async t=>{let n=g({title:`Deleting…`,description:`${t.length} document(s)`});try{await ae(e,t,r.path,[],r.treeName,x),Ce(),n.done({title:`Deleted`,description:`${t.length} document(s) deleted.`})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to delete documents`,variant:`destructive`})}},[e,r.path,r.treeName,x,Ce,g]),De=(0,T.useCallback)(async t=>{let n=g({title:`Destroying…`,description:`${t.length} document(s) and their backend copies`});try{let r=await re(e,t);if(r.failed?.length&&!r.successful?.length){n.fail({title:`Error`,description:r.failed[0].reason,variant:`destructive`});return}Ce();let i=`${r.successful?.length??0} document(s) destroyed${r.failed?.length?` · ${r.failed.length} failed`:``}.`;r.failed?.length?n.fail({title:`Destroy incomplete`,description:i,variant:`destructive`}):n.done({title:`Destroyed`,description:i})}catch(e){n.fail({title:`Error`,description:e instanceof Error?e.message:`Failed to destroy documents`,variant:`destructive`})}},[e,Ce,g]);return(0,E.jsxs)(`div`,{className:u(`relative flex-1 min-w-0 rounded-(--sheet-radius) border bg-background overflow-hidden`,i?`ring-2 ring-primary`:`ring-1 ring-primary/20`),onMouseDown:e=>{e.target.closest(`button,input,textarea,select,a`)||s()},children:[d&&(0,E.jsx)(`button`,{type:`button`,onClick:d,className:`absolute right-2 top-2 z-10 px-2 py-1 text-xs rounded-md border bg-background/90 hover:bg-accent`,children:`Close`}),Ee(r.treeName,r.path)?r.path===`/Trash`?(0,E.jsx)(`div`,{className:`h-full overflow-auto p-4`,children:(0,E.jsx)(Ke,{workspaceName:e})}):(0,E.jsx)(qe,{workspace:e,path:r.path,onNavigate:l||(()=>{})}):(0,E.jsx)(We,{frameContent:!1,onBrowseWorkspaces:()=>f(`workspaces`),onBrowseTree:()=>p(`workspaces`,`detail`,e),urlType:_e?`canvas`:x===`directory`?r.treeName:`context`,urlDisplay:be,contextPath:r.path,treeName:r.treeName,workspaceId:e,workspaceLabel:t,workspaceIcon:n,documentSchema:xe,documents:ie,isLoading:oe,totalCount:ce,currentPage:ue,pageSize:me,onPageChange:de,onPageSizeChange:e=>{he(e),de(1)},onRemoveDocument:r.path===`/`?void 0:e=>we([e]),onRemoveDocuments:r.path===`/`?void 0:we,onDeleteDocument:e=>Te([e]),onDeleteDocuments:Te,onDestroyDocument:e=>De([e]),onDestroyDocuments:De,onCopyDocuments:e=>{o({documentIds:e,operation:`copy`,sourcePath:r.path,sourceTreeName:r.treeName}),window.dispatchEvent(new CustomEvent(`documents:clipboard`,{detail:{documentIds:e,operation:`copy`}}))},onCutDocuments:e=>{o({documentIds:e,operation:`cut`,sourcePath:r.path,sourceTreeName:r.treeName}),window.dispatchEvent(new CustomEvent(`documents:clipboard`,{detail:{documentIds:e,operation:`cut`}}))},onPasteDocuments:r.treeName===`backends`?void 0:Se,onSelectionChange:c,pastedDocumentIds:a?.documentIds,linkTree:ne,folders:ve,onOpenFolder:l,onNavigatePath:l,canvasInfo:_e?{label:ge?.label,description:ge?.description,color:ge?.color}:void 0,children:ye?.kind===`columns`?(0,E.jsx)(Ve,{documents:ie,workspaceId:e,columns:ye.columns??[],onColumnsChange:()=>{},readOnly:!0}):ye?.kind===`app`&&ye.app&&ye.app!==`notes`?(0,E.jsx)(Ge,{app:ye.app,workspaceId:e,treeName:r.treeName,path:r.path}):null})]})}export{xt as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./api-CA6WiiYM.js";import{n as i}from"./page-header-DkOHw0g-.js";import{t as a}from"./use-settings-back-CQauYjQ4.js";var o=e(n(),1),s=t();function c(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`}function l({name:e,version:t,detail:n}){return(0,s.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 px-4 py-2.5`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e}),n&&(0,s.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:n})]}),(0,s.jsx)(`code`,{className:`text-xs text-muted-foreground shrink-0`,children:t})]})}function u(){let[e,t]=(0,o.useState)(null),[n,u]=(0,o.useState)(null);(0,o.useEffect)(()=>{let e=!0;return r.get(`/ping`,{skipAuth:!0}).then(n=>{e&&t(n??{})}).catch(t=>{e&&u(t instanceof Error?t.message:`Failed to reach the server`)}),()=>{e=!1}},[]);let d=[e?.commit?`commit ${e.commit.slice(0,7)}`:null,typeof e?.uptime==`number`?`up ${c(e.uptime)}`:null].filter(Boolean).join(` · `),f=Object.entries(e?.components??{}).sort(([e],[t])=>e.localeCompare(t));return(0,s.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,s.jsx)(i,{className:`mb-6`,title:`About`,onBack:a(),description:`Versions of every Canvas component this installation is running.`}),(0,s.jsxs)(`div`,{className:`space-y-6`,children:[(0,s.jsxs)(`section`,{className:`rounded-md border border-border divide-y divide-border`,children:[(0,s.jsx)(l,{name:`Canvas Web`,detail:`this interface`,version:`v2.26.22`}),e?.version&&(0,s.jsx)(l,{name:e.productName||e.appName||`Canvas Server`,detail:d||void 0,version:`v${e.version}`})]}),f.length>0&&(0,s.jsxs)(`section`,{children:[(0,s.jsx)(`h2`,{className:`mb-2 px-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Server components`}),(0,s.jsx)(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:f.map(([e,t])=>(0,s.jsx)(l,{name:e,version:`v${t}`},e))})]}),n&&(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Server details unavailable: `,n]}),e?.sourceUrl&&(0,s.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.license?`Licensed ${e.license}. `:``,(0,s.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Get the source code`}),`.`]})]})]})}export{u as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./api-CA6WiiYM.js";import{n as i}from"./page-header-DkOHw0g-.js";import{t as a}from"./use-settings-back-CQauYjQ4.js";var o=e(n(),1),s=t();function c(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`}function l({name:e,version:t,detail:n}){return(0,s.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 px-4 py-2.5`,children:[(0,s.jsxs)(`div`,{className:`min-w-0`,children:[(0,s.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e}),n&&(0,s.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:n})]}),(0,s.jsx)(`code`,{className:`text-xs text-muted-foreground shrink-0`,children:t})]})}function u(){let[e,t]=(0,o.useState)(null),[n,u]=(0,o.useState)(null);(0,o.useEffect)(()=>{let e=!0;return r.get(`/ping`,{skipAuth:!0}).then(n=>{e&&t(n??{})}).catch(t=>{e&&u(t instanceof Error?t.message:`Failed to reach the server`)}),()=>{e=!1}},[]);let d=[e?.commit?`commit ${e.commit.slice(0,7)}`:null,typeof e?.uptime==`number`?`up ${c(e.uptime)}`:null].filter(Boolean).join(` · `),f=Object.entries(e?.components??{}).sort(([e],[t])=>e.localeCompare(t));return(0,s.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,s.jsx)(i,{className:`mb-6`,title:`About`,onBack:a(),description:`Versions of every Canvas component this installation is running.`}),(0,s.jsxs)(`div`,{className:`space-y-6`,children:[(0,s.jsxs)(`section`,{className:`rounded-md border border-border divide-y divide-border`,children:[(0,s.jsx)(l,{name:`Canvas Web`,detail:`this interface`,version:`v2.26.24`}),e?.version&&(0,s.jsx)(l,{name:e.productName||e.appName||`Canvas Server`,detail:d||void 0,version:`v${e.version}`})]}),f.length>0&&(0,s.jsxs)(`section`,{children:[(0,s.jsx)(`h2`,{className:`mb-2 px-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Server components`}),(0,s.jsx)(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:f.map(([e,t])=>(0,s.jsx)(l,{name:e,version:`v${t}`},e))})]}),n&&(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Server details unavailable: `,n]}),e?.sourceUrl&&(0,s.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.license?`Licensed ${e.license}. `:``,(0,s.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`Get the source code`}),`.`]})]})]})}export{u as default};
@@ -1 +1 @@
1
- import{l as e}from"./code-editor-BOIngd5F.js";import{_ as t,a as n,g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./HomeFab-CXaEEzXy.js";var a=e(),o=[`note`,`todo`,`link`,`file`,`photo`];function s(){let{kind:e}=t(),s=r();return e===`sketch`?(0,a.jsx)(n,{to:`/apps/sketch?add=1`,replace:!0}):!e||!o.includes(e)?(0,a.jsx)(n,{to:`/home`,replace:!0}):(0,a.jsx)(i,{initialKind:e,onInitialCardClose:()=>s(`/home`)})}export{s as default};
1
+ import{l as e}from"./code-editor-BOIngd5F.js";import{_ as t,a as n,g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./HomeFab-D2pLJ9oc.js";var a=e(),o=[`note`,`todo`,`link`,`file`,`photo`];function s(){let{kind:e}=t(),s=r();return e===`sketch`?(0,a.jsx)(n,{to:`/apps/sketch?add=1`,replace:!0}):!e||!o.includes(e)?(0,a.jsx)(n,{to:`/home`,replace:!0}):(0,a.jsx)(i,{initialKind:e,onInitialCardClose:()=>s(`/home`)})}export{s as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Ft as i,I as a,Nt as o,Xr as s,nn as c,rt as l,xr as u}from"./ui-Byg1cZDr.js";import{t as d}from"./button-SgR3GVvV.js";import{t as f}from"./input-BOtCd4HP.js";import{n as p}from"./use-toast-BlLDqSUO.js";import{t as m}from"./color-DFEH4BfK.js";import{$ as h,Et as g,I as _,Q as v,q as y}from"./index-CiBgHujl.js";import{n as b}from"./page-header-DkOHw0g-.js";import{n as ee,r as x,t as te}from"./useAgentModels-Sa4N8WFd.js";import{t as ne}from"./form-panel-C34lByEH.js";import{t as re}from"./use-create-panel-DhSNIGtr.js";import{n as ie,t as ae}from"./useSocketSubscription-ifW-vnlb.js";var S=e(n(),1),C=t();function w({agent:e,onStart:t,onStop:n,onEnter:r}){let[o,f]=(0,S.useState)(!1),p=async()=>{f(!0);try{await t(e.name)}finally{f(!1)}},m=async()=>{f(!0);try{await n(e.name)}finally{f(!1)}},h=()=>{switch(e.status){case`active`:return(0,C.jsx)(u,{className:`h-4 w-4 text-success`});case`inactive`:return(0,C.jsx)(u,{className:`h-4 w-4 text-warning`});case`error`:return(0,C.jsx)(u,{className:`h-4 w-4 text-destructive`});default:return(0,C.jsx)(u,{className:`h-4 w-4 text-muted-foreground`})}},g=()=>{switch(e.llmProvider){case`anthropic`:return(0,C.jsx)(s,{className:`h-4 w-4 text-warning`});case`openai`:return(0,C.jsx)(s,{className:`h-4 w-4 text-success`});case`ollama`:return(0,C.jsx)(a,{className:`h-4 w-4 text-info`});default:return(0,C.jsx)(s,{className:`h-4 w-4 text-muted-foreground`})}},_=()=>{switch(e.status){case`active`:return`text-success bg-success-subtle border-success`;case`inactive`:return`text-warning bg-warning-subtle border-warning`;case`error`:return`text-destructive bg-destructive-subtle border-destructive`;case`available`:return`text-info bg-info-subtle border-info`;default:return`text-foreground bg-muted border-border`}},v=e.status===`available`||e.status===`inactive`,y=e.status===`active`;return(0,C.jsxs)(`div`,{className:`border rounded-lg p-4 space-y-4 hover:shadow-elevation-2 transition-shadow bg-card`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[g(),(0,C.jsx)(`h3`,{className:`text-lg font-semibold truncate`,children:e.label||e.name}),e.color&&(0,C.jsx)(`div`,{className:`w-4 h-4 rounded border flex-shrink-0`,style:{backgroundColor:e.color},title:`Color: ${e.color}`})]}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground font-mono`,children:e.name}),e.description&&(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:e.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[h(),(0,C.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs font-medium border ${_()}`,children:e.status})]})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Provider:`}),(0,C.jsx)(`div`,{className:`font-medium capitalize`,children:e.llmProvider})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Model:`}),(0,C.jsx)(`div`,{className:`font-mono text-xs`,children:e.model})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Created:`}),(0,C.jsx)(`div`,{children:new Date(e.createdAt).toLocaleDateString()})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Last Access:`}),(0,C.jsx)(`div`,{children:e.lastAccessed?new Date(e.lastAccessed).toLocaleDateString():`Never`})]})]}),e.config.mcp?.servers&&e.config.mcp.servers.length>0&&(0,C.jsxs)(`div`,{className:`text-sm`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`MCP Servers:`}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.config.mcp.servers.map((e,t)=>(0,C.jsx)(`span`,{className:`px-2 py-1 bg-secondary text-secondary-foreground rounded text-xs`,children:e.name},t))})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 pt-2 border-t`,children:[v&&(0,C.jsxs)(d,{onClick:p,disabled:o,size:`sm`,variant:`outline`,className:`flex-1`,children:[(0,C.jsx)(i,{className:`mr-2 h-4 w-4`}),`Start`]}),y&&(0,C.jsxs)(d,{onClick:m,disabled:o,size:`sm`,variant:`outline`,className:`flex-1`,children:[(0,C.jsx)(l,{className:`mr-2 h-4 w-4`}),`Stop`]}),(0,C.jsxs)(d,{onClick:()=>r(e.name),size:`sm`,className:`flex-1`,children:[(0,C.jsx)(c,{className:`mr-2 h-4 w-4`}),`Chat`]})]})]})}function T(){let e={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`},t={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`},[n,i]=(0,S.useState)([]),[a,s]=(0,S.useState)(!0),[c,l]=(0,S.useState)(null),[u,T]=(0,S.useState)(``),[E,D]=(0,S.useState)(``),[O,k]=(0,S.useState)(m()),[A,j]=(0,S.useState)(``),[M,oe]=(0,S.useState)(`anthropic`),[N,P]=(0,S.useState)(t.anthropic),[F,I]=(0,S.useState)({apiKey:``,baseUrl:e.anthropic,maxTokens:4096,temperature:.7,topP:1,frequencyPenalty:0,presencePenalty:0,numCtx:4096}),L=te(M,F.apiKey,F.baseUrl),R=L.models.find(e=>e.id===N),[z,B]=(0,S.useState)(``),[V,H]=(0,S.useState)(``),[U,W]=(0,S.useState)(``),[G,K]=(0,S.useState)(``),[q,J]=(0,S.useState)(!1),Y=g(),[X,Z]=re(),{showToast:Q}=p(),se=r(),$=ie();ae($,`agent`,{"agent:status:changed":e=>{i(t=>t.map(t=>t.id===e.agentId?{...t,status:e.status,isActive:e.isActive}:t))},"agent:created":e=>{i(t=>[...t,e.agent])},"agent:deleted":e=>{i(t=>t.filter(t=>t.id!==e.agentId))}});let ce=n=>{oe(n),P(t[n]),I({apiKey:``,baseUrl:e[n],maxTokens:4096,temperature:.7,topP:1,frequencyPenalty:0,presencePenalty:0,numCtx:4096})};(0,S.useEffect)(()=>((async()=>{try{s(!0);let e=await y();i(e),l(null)}catch(e){console.error(`Agent fetch error:`,e);let t=`Failed to fetch agents`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch agents`}l(t),Q({title:`Error`,description:t,variant:`destructive`})}finally{s(!1)}})(),()=>{}),[$,Q]);let le=async t=>{if(t.preventDefault(),u.trim()){J(!0);try{let t=G.trim()||x(z,V,U),n={name:u,label:A||u,description:E||void 0,color:O,llmProvider:M,model:N,apiKey:F.apiKey.trim()||void 0,baseUrl:F.baseUrl.trim()||void 0,config:{type:M,model:N,identity:{role:z.trim()||void 0,identity:V.trim()||void 0,instructions:U.trim()||void 0},prompts:t?{system:t}:void 0,connectors:{[M]:{maxTokens:F.maxTokens,...M===`anthropic`?{}:{temperature:F.temperature},topP:F.topP,frequencyPenalty:F.frequencyPenalty,presencePenalty:F.presencePenalty,...M===`ollama`?{numCtx:F.numCtx}:{}}}},mcp:{enabled:!0,servers:[{name:`weather`,command:`node`,args:[`src/managers/agent/mcp-servers/weather.js`]}]}},r=await _(n);i(e=>[...e,r]),T(``),D(``),k(m()),j(``),K(``),B(``),H(``),W(``),I({apiKey:``,baseUrl:e[M],maxTokens:4096,temperature:.7,topP:1,frequencyPenalty:0,presencePenalty:0,numCtx:4096}),Q({title:`Success`,description:`Agent '${r.label||r.name}' created.`}),Z(!1)}catch(e){console.error(`Agent creation error:`,e);let t=`Failed to create agent`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to create agent`}Q({title:`Error`,description:t,variant:`destructive`})}finally{J(!1)}}},ue=async e=>{try{let t=await v(e);i(e=>e.map(e=>e.name===t.name?t:e)),Q({title:`Success`,description:`Agent '${t.label||t.name}' started.`})}catch(e){console.error(`Agent start error:`,e);let t=`Failed to start agent`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to start agent`}Q({title:`Error`,description:t,variant:`destructive`})}},de=async e=>{try{await h(e),i(t=>t.map(t=>t.name===e?{...t,status:`inactive`,isActive:!1}:t)),Q({title:`Success`,description:`Agent '${e}' stopped.`})}catch(e){console.error(`Agent stop error:`,e);let t=`Failed to stop agent`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to stop agent`}Q({title:`Error`,description:t,variant:`destructive`})}},fe=e=>{se(`/agents/${e}`)};return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(b,{title:`AI Agents`,description:`Create and manage your AI agents with multiple LLM providers`,actions:!Y.local&&!X&&(0,C.jsxs)(d,{onClick:()=>Z(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create agent`,title:`Create agent`,children:[(0,C.jsx)(o,{className:`h-4 w-4 sm:mr-2`}),(0,C.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Agent`})]})}),!Y.local&&X&&(0,C.jsx)(ne,{title:`Create New Agent`,onClose:()=>Z(!1),children:(0,C.jsxs)(`form`,{onSubmit:le,className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsx)(f,{value:u,onChange:e=>T(e.target.value),placeholder:`Agent Name (e.g., 'my-assistant')`,disabled:q}),(0,C.jsx)(f,{value:A,onChange:e=>j(e.target.value),placeholder:`Agent Label (display name, optional)`,disabled:q})]}),(0,C.jsx)(f,{value:E,onChange:e=>D(e.target.value),placeholder:`Description (optional)`,disabled:q}),(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-provider`,className:`text-sm font-medium`,children:`LLM Provider`}),(0,C.jsxs)(`select`,{id:`agent-provider`,value:M,onChange:e=>ce(e.target.value),className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-ring`,disabled:q,children:[(0,C.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,C.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,C.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-model`,className:`text-sm font-medium`,children:`Model`}),(0,C.jsx)(ee,{id:`agent-model`,value:N,onChange:(e,t)=>{P(e),t?.maxTokens&&I(e=>({...e,maxTokens:t.maxTokens}))},...L,disabled:q})]})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsx)(`h3`,{className:`text-lg font-medium`,children:`Persona`}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-role`,className:`text-sm font-medium`,children:`Role`}),(0,C.jsx)(f,{id:`agent-role`,value:z,onChange:e=>B(e.target.value),placeholder:`e.g. Software Engineer`,disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-identity`,className:`text-sm font-medium`,children:`Identity`}),(0,C.jsx)(`textarea`,{id:`agent-identity`,value:V,onChange:e=>H(e.target.value),placeholder:`Who this agent is…`,disabled:q,className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm min-h-[80px] resize-y`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-instructions`,className:`text-sm font-medium`,children:`Instructions`}),(0,C.jsx)(`textarea`,{id:`agent-instructions`,value:U,onChange:e=>W(e.target.value),placeholder:`Behavioral instructions…`,disabled:q,className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm min-h-[80px] resize-y`})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`system-prompt`,className:`text-sm font-medium`,children:`System Prompt (Optional Override)`}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Built from Role, Identity and Instructions unless you enter an override.`}),(0,C.jsx)(`textarea`,{id:`system-prompt`,value:G,onChange:e=>K(e.target.value),placeholder:x(z,V,U)||`System prompt sent to the LLM…`,className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-ring min-h-[80px] resize-y`,disabled:q})]}),(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`api-key`,className:`text-sm font-medium`,children:`API Key (Optional)`}),(0,C.jsx)(f,{id:`api-key`,type:`password`,value:F.apiKey,onChange:e=>I(t=>({...t,apiKey:e.target.value})),placeholder:`Enter your API key`,disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`baseUrl`,className:`text-sm font-medium`,children:`Base URL (Optional)`}),(0,C.jsx)(f,{id:`baseUrl`,value:F.baseUrl,onChange:e=>I(t=>({...t,baseUrl:e.target.value})),placeholder:e[M],disabled:q})]})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsx)(`h3`,{className:`text-lg font-medium`,children:`LLM Parameters`}),(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`max-tokens`,className:`text-sm font-medium`,children:`Max Output Tokens`}),(0,C.jsx)(f,{id:`max-tokens`,type:`number`,min:`1`,max:R?.maxTokens,value:F.maxTokens,onChange:e=>I(t=>({...t,maxTokens:parseInt(e.target.value)||4096})),disabled:q})]}),M!==`anthropic`&&(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`temperature`,className:`text-sm font-medium`,children:`Temperature`}),(0,C.jsx)(f,{id:`temperature`,type:`number`,min:`0`,max:`2`,step:`0.1`,value:F.temperature,onChange:e=>I(t=>({...t,temperature:Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber})),disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`top-p`,className:`text-sm font-medium`,children:`Top P`}),(0,C.jsx)(f,{id:`top-p`,type:`number`,min:`0`,max:`1`,step:`0.1`,value:F.topP,onChange:e=>I(t=>({...t,topP:Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber})),disabled:q})]}),M===`ollama`&&(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`num-ctx`,className:`text-sm font-medium`,children:`Context Length`}),(0,C.jsx)(f,{id:`num-ctx`,type:`number`,min:`1024`,max:R?.contextWindow,value:F.numCtx,onChange:e=>I(t=>({...t,numCtx:parseInt(e.target.value)||4096})),disabled:q})]})]}),M!==`ollama`&&(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`frequency-penalty`,className:`text-sm font-medium`,children:`Frequency Penalty`}),(0,C.jsx)(f,{id:`frequency-penalty`,type:`number`,min:`-2`,max:`2`,step:`0.1`,value:F.frequencyPenalty,onChange:e=>I(t=>({...t,frequencyPenalty:parseFloat(e.target.value)||0})),disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`presence-penalty`,className:`text-sm font-medium`,children:`Presence Penalty`}),(0,C.jsx)(f,{id:`presence-penalty`,type:`number`,min:`-2`,max:`2`,step:`0.1`,value:F.presencePenalty,onChange:e=>I(t=>({...t,presencePenalty:parseFloat(e.target.value)||0})),disabled:q})]})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`label`,{htmlFor:`agent-color`,className:`text-sm font-medium`,children:`Agent Color`}),(0,C.jsx)(f,{id:`agent-color`,type:`color`,value:O,onChange:e=>k(e.target.value),className:`h-10 w-16 p-1`,disabled:q}),(0,C.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>k(m()),disabled:q,children:`Randomize`})]}),(0,C.jsxs)(d,{type:`submit`,disabled:q||!u.trim(),children:[(0,C.jsx)(o,{className:`mr-2 h-4 w-4`}),`Create Agent`]})]})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Agents`}),a&&(0,C.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading agents...`}),c&&(0,C.jsx)(`div`,{className:`text-center text-destructive`,children:(0,C.jsx)(`p`,{children:c})}),!a&&!c&&n.length===0&&(0,C.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No agents found`}),n.length>0&&(0,C.jsx)(`div`,{className:`grid gap-4`,children:n.map(e=>(0,C.jsx)(w,{agent:e,onStart:ue,onStop:de,onEnter:fe},e.id))})]})]})}export{T as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Ft as i,I as a,Nt as o,Xr as s,nn as c,rt as l,xr as u}from"./ui-Byg1cZDr.js";import{t as d}from"./button-SgR3GVvV.js";import{t as f}from"./input-BOtCd4HP.js";import{n as p}from"./use-toast-BlLDqSUO.js";import{t as m}from"./color-DFEH4BfK.js";import{$ as h,Et as g,I as _,Q as v,q as y}from"./index-D5Q9EUVc.js";import{n as b}from"./page-header-DkOHw0g-.js";import{n as ee,r as x,t as te}from"./useAgentModels-CYDYTjgG.js";import{t as ne}from"./form-panel-C34lByEH.js";import{t as re}from"./use-create-panel-DhSNIGtr.js";import{n as ie,t as ae}from"./useSocketSubscription-ifW-vnlb.js";var S=e(n(),1),C=t();function w({agent:e,onStart:t,onStop:n,onEnter:r}){let[o,f]=(0,S.useState)(!1),p=async()=>{f(!0);try{await t(e.name)}finally{f(!1)}},m=async()=>{f(!0);try{await n(e.name)}finally{f(!1)}},h=()=>{switch(e.status){case`active`:return(0,C.jsx)(u,{className:`h-4 w-4 text-success`});case`inactive`:return(0,C.jsx)(u,{className:`h-4 w-4 text-warning`});case`error`:return(0,C.jsx)(u,{className:`h-4 w-4 text-destructive`});default:return(0,C.jsx)(u,{className:`h-4 w-4 text-muted-foreground`})}},g=()=>{switch(e.llmProvider){case`anthropic`:return(0,C.jsx)(s,{className:`h-4 w-4 text-warning`});case`openai`:return(0,C.jsx)(s,{className:`h-4 w-4 text-success`});case`ollama`:return(0,C.jsx)(a,{className:`h-4 w-4 text-info`});default:return(0,C.jsx)(s,{className:`h-4 w-4 text-muted-foreground`})}},_=()=>{switch(e.status){case`active`:return`text-success bg-success-subtle border-success`;case`inactive`:return`text-warning bg-warning-subtle border-warning`;case`error`:return`text-destructive bg-destructive-subtle border-destructive`;case`available`:return`text-info bg-info-subtle border-info`;default:return`text-foreground bg-muted border-border`}},v=e.status===`available`||e.status===`inactive`,y=e.status===`active`;return(0,C.jsxs)(`div`,{className:`border rounded-lg p-4 space-y-4 hover:shadow-elevation-2 transition-shadow bg-card`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[g(),(0,C.jsx)(`h3`,{className:`text-lg font-semibold truncate`,children:e.label||e.name}),e.color&&(0,C.jsx)(`div`,{className:`w-4 h-4 rounded border flex-shrink-0`,style:{backgroundColor:e.color},title:`Color: ${e.color}`})]}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground font-mono`,children:e.name}),e.description&&(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:e.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[h(),(0,C.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs font-medium border ${_()}`,children:e.status})]})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Provider:`}),(0,C.jsx)(`div`,{className:`font-medium capitalize`,children:e.llmProvider})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Model:`}),(0,C.jsx)(`div`,{className:`font-mono text-xs`,children:e.model})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Created:`}),(0,C.jsx)(`div`,{children:new Date(e.createdAt).toLocaleDateString()})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Last Access:`}),(0,C.jsx)(`div`,{children:e.lastAccessed?new Date(e.lastAccessed).toLocaleDateString():`Never`})]})]}),e.config.mcp?.servers&&e.config.mcp.servers.length>0&&(0,C.jsxs)(`div`,{className:`text-sm`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`MCP Servers:`}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.config.mcp.servers.map((e,t)=>(0,C.jsx)(`span`,{className:`px-2 py-1 bg-secondary text-secondary-foreground rounded text-xs`,children:e.name},t))})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 pt-2 border-t`,children:[v&&(0,C.jsxs)(d,{onClick:p,disabled:o,size:`sm`,variant:`outline`,className:`flex-1`,children:[(0,C.jsx)(i,{className:`mr-2 h-4 w-4`}),`Start`]}),y&&(0,C.jsxs)(d,{onClick:m,disabled:o,size:`sm`,variant:`outline`,className:`flex-1`,children:[(0,C.jsx)(l,{className:`mr-2 h-4 w-4`}),`Stop`]}),(0,C.jsxs)(d,{onClick:()=>r(e.name),size:`sm`,className:`flex-1`,children:[(0,C.jsx)(c,{className:`mr-2 h-4 w-4`}),`Chat`]})]})]})}function T(){let e={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`},t={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`},[n,i]=(0,S.useState)([]),[a,s]=(0,S.useState)(!0),[c,l]=(0,S.useState)(null),[u,T]=(0,S.useState)(``),[E,D]=(0,S.useState)(``),[O,k]=(0,S.useState)(m()),[A,j]=(0,S.useState)(``),[M,oe]=(0,S.useState)(`anthropic`),[N,P]=(0,S.useState)(t.anthropic),[F,I]=(0,S.useState)({apiKey:``,baseUrl:e.anthropic,maxTokens:4096,temperature:.7,topP:1,frequencyPenalty:0,presencePenalty:0,numCtx:4096}),L=te(M,F.apiKey,F.baseUrl),R=L.models.find(e=>e.id===N),[z,B]=(0,S.useState)(``),[V,H]=(0,S.useState)(``),[U,W]=(0,S.useState)(``),[G,K]=(0,S.useState)(``),[q,J]=(0,S.useState)(!1),Y=g(),[X,Z]=re(),{showToast:Q}=p(),se=r(),$=ie();ae($,`agent`,{"agent:status:changed":e=>{i(t=>t.map(t=>t.id===e.agentId?{...t,status:e.status,isActive:e.isActive}:t))},"agent:created":e=>{i(t=>[...t,e.agent])},"agent:deleted":e=>{i(t=>t.filter(t=>t.id!==e.agentId))}});let ce=n=>{oe(n),P(t[n]),I({apiKey:``,baseUrl:e[n],maxTokens:4096,temperature:.7,topP:1,frequencyPenalty:0,presencePenalty:0,numCtx:4096})};(0,S.useEffect)(()=>((async()=>{try{s(!0);let e=await y();i(e),l(null)}catch(e){console.error(`Agent fetch error:`,e);let t=`Failed to fetch agents`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch agents`}l(t),Q({title:`Error`,description:t,variant:`destructive`})}finally{s(!1)}})(),()=>{}),[$,Q]);let le=async t=>{if(t.preventDefault(),u.trim()){J(!0);try{let t=G.trim()||x(z,V,U),n={name:u,label:A||u,description:E||void 0,color:O,llmProvider:M,model:N,apiKey:F.apiKey.trim()||void 0,baseUrl:F.baseUrl.trim()||void 0,config:{type:M,model:N,identity:{role:z.trim()||void 0,identity:V.trim()||void 0,instructions:U.trim()||void 0},prompts:t?{system:t}:void 0,connectors:{[M]:{maxTokens:F.maxTokens,...M===`anthropic`?{}:{temperature:F.temperature},topP:F.topP,frequencyPenalty:F.frequencyPenalty,presencePenalty:F.presencePenalty,...M===`ollama`?{numCtx:F.numCtx}:{}}}},mcp:{enabled:!0,servers:[{name:`weather`,command:`node`,args:[`src/managers/agent/mcp-servers/weather.js`]}]}},r=await _(n);i(e=>[...e,r]),T(``),D(``),k(m()),j(``),K(``),B(``),H(``),W(``),I({apiKey:``,baseUrl:e[M],maxTokens:4096,temperature:.7,topP:1,frequencyPenalty:0,presencePenalty:0,numCtx:4096}),Q({title:`Success`,description:`Agent '${r.label||r.name}' created.`}),Z(!1)}catch(e){console.error(`Agent creation error:`,e);let t=`Failed to create agent`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to create agent`}Q({title:`Error`,description:t,variant:`destructive`})}finally{J(!1)}}},ue=async e=>{try{let t=await v(e);i(e=>e.map(e=>e.name===t.name?t:e)),Q({title:`Success`,description:`Agent '${t.label||t.name}' started.`})}catch(e){console.error(`Agent start error:`,e);let t=`Failed to start agent`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to start agent`}Q({title:`Error`,description:t,variant:`destructive`})}},de=async e=>{try{await h(e),i(t=>t.map(t=>t.name===e?{...t,status:`inactive`,isActive:!1}:t)),Q({title:`Success`,description:`Agent '${e}' stopped.`})}catch(e){console.error(`Agent stop error:`,e);let t=`Failed to stop agent`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to stop agent`}Q({title:`Error`,description:t,variant:`destructive`})}},fe=e=>{se(`/agents/${e}`)};return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(b,{title:`AI Agents`,description:`Create and manage your AI agents with multiple LLM providers`,actions:!Y.local&&!X&&(0,C.jsxs)(d,{onClick:()=>Z(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create agent`,title:`Create agent`,children:[(0,C.jsx)(o,{className:`h-4 w-4 sm:mr-2`}),(0,C.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Agent`})]})}),!Y.local&&X&&(0,C.jsx)(ne,{title:`Create New Agent`,onClose:()=>Z(!1),children:(0,C.jsxs)(`form`,{onSubmit:le,className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsx)(f,{value:u,onChange:e=>T(e.target.value),placeholder:`Agent Name (e.g., 'my-assistant')`,disabled:q}),(0,C.jsx)(f,{value:A,onChange:e=>j(e.target.value),placeholder:`Agent Label (display name, optional)`,disabled:q})]}),(0,C.jsx)(f,{value:E,onChange:e=>D(e.target.value),placeholder:`Description (optional)`,disabled:q}),(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-provider`,className:`text-sm font-medium`,children:`LLM Provider`}),(0,C.jsxs)(`select`,{id:`agent-provider`,value:M,onChange:e=>ce(e.target.value),className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-ring`,disabled:q,children:[(0,C.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,C.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,C.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-model`,className:`text-sm font-medium`,children:`Model`}),(0,C.jsx)(ee,{id:`agent-model`,value:N,onChange:(e,t)=>{P(e),t?.maxTokens&&I(e=>({...e,maxTokens:t.maxTokens}))},...L,disabled:q})]})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsx)(`h3`,{className:`text-lg font-medium`,children:`Persona`}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-role`,className:`text-sm font-medium`,children:`Role`}),(0,C.jsx)(f,{id:`agent-role`,value:z,onChange:e=>B(e.target.value),placeholder:`e.g. Software Engineer`,disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-identity`,className:`text-sm font-medium`,children:`Identity`}),(0,C.jsx)(`textarea`,{id:`agent-identity`,value:V,onChange:e=>H(e.target.value),placeholder:`Who this agent is…`,disabled:q,className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm min-h-[80px] resize-y`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`agent-instructions`,className:`text-sm font-medium`,children:`Instructions`}),(0,C.jsx)(`textarea`,{id:`agent-instructions`,value:U,onChange:e=>W(e.target.value),placeholder:`Behavioral instructions…`,disabled:q,className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm min-h-[80px] resize-y`})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`system-prompt`,className:`text-sm font-medium`,children:`System Prompt (Optional Override)`}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Built from Role, Identity and Instructions unless you enter an override.`}),(0,C.jsx)(`textarea`,{id:`system-prompt`,value:G,onChange:e=>K(e.target.value),placeholder:x(z,V,U)||`System prompt sent to the LLM…`,className:`w-full mt-1 px-3 py-2 border border-input bg-background rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-ring min-h-[80px] resize-y`,disabled:q})]}),(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`api-key`,className:`text-sm font-medium`,children:`API Key (Optional)`}),(0,C.jsx)(f,{id:`api-key`,type:`password`,value:F.apiKey,onChange:e=>I(t=>({...t,apiKey:e.target.value})),placeholder:`Enter your API key`,disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`baseUrl`,className:`text-sm font-medium`,children:`Base URL (Optional)`}),(0,C.jsx)(f,{id:`baseUrl`,value:F.baseUrl,onChange:e=>I(t=>({...t,baseUrl:e.target.value})),placeholder:e[M],disabled:q})]})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsx)(`h3`,{className:`text-lg font-medium`,children:`LLM Parameters`}),(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`max-tokens`,className:`text-sm font-medium`,children:`Max Output Tokens`}),(0,C.jsx)(f,{id:`max-tokens`,type:`number`,min:`1`,max:R?.maxTokens,value:F.maxTokens,onChange:e=>I(t=>({...t,maxTokens:parseInt(e.target.value)||4096})),disabled:q})]}),M!==`anthropic`&&(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`temperature`,className:`text-sm font-medium`,children:`Temperature`}),(0,C.jsx)(f,{id:`temperature`,type:`number`,min:`0`,max:`2`,step:`0.1`,value:F.temperature,onChange:e=>I(t=>({...t,temperature:Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber})),disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`top-p`,className:`text-sm font-medium`,children:`Top P`}),(0,C.jsx)(f,{id:`top-p`,type:`number`,min:`0`,max:`1`,step:`0.1`,value:F.topP,onChange:e=>I(t=>({...t,topP:Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber})),disabled:q})]}),M===`ollama`&&(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`num-ctx`,className:`text-sm font-medium`,children:`Context Length`}),(0,C.jsx)(f,{id:`num-ctx`,type:`number`,min:`1024`,max:R?.contextWindow,value:F.numCtx,onChange:e=>I(t=>({...t,numCtx:parseInt(e.target.value)||4096})),disabled:q})]})]}),M!==`ollama`&&(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`frequency-penalty`,className:`text-sm font-medium`,children:`Frequency Penalty`}),(0,C.jsx)(f,{id:`frequency-penalty`,type:`number`,min:`-2`,max:`2`,step:`0.1`,value:F.frequencyPenalty,onChange:e=>I(t=>({...t,frequencyPenalty:parseFloat(e.target.value)||0})),disabled:q})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`presence-penalty`,className:`text-sm font-medium`,children:`Presence Penalty`}),(0,C.jsx)(f,{id:`presence-penalty`,type:`number`,min:`-2`,max:`2`,step:`0.1`,value:F.presencePenalty,onChange:e=>I(t=>({...t,presencePenalty:parseFloat(e.target.value)||0})),disabled:q})]})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`label`,{htmlFor:`agent-color`,className:`text-sm font-medium`,children:`Agent Color`}),(0,C.jsx)(f,{id:`agent-color`,type:`color`,value:O,onChange:e=>k(e.target.value),className:`h-10 w-16 p-1`,disabled:q}),(0,C.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>k(m()),disabled:q,children:`Randomize`})]}),(0,C.jsxs)(d,{type:`submit`,disabled:q||!u.trim(),children:[(0,C.jsx)(o,{className:`mr-2 h-4 w-4`}),`Create Agent`]})]})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Agents`}),a&&(0,C.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading agents...`}),c&&(0,C.jsx)(`div`,{className:`text-center text-destructive`,children:(0,C.jsx)(`p`,{children:c})}),!a&&!c&&n.length===0&&(0,C.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No agents found`}),n.length>0&&(0,C.jsx)(`div`,{className:`grid gap-4`,children:n.map(e=>(0,C.jsx)(w,{agent:e,onStart:ue,onStop:de,onEnter:fe},e.id))})]})]})}export{T as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Jt as r,Ur as i,Yt as a,et as o}from"./ui-Byg1cZDr.js";import{t as s}from"./utils-2pl1SbIp.js";import{a as c,i as l,n as u,o as d,r as f,s as p,t as m}from"./document-open-mode-DoImW-xs.js";import{d as h,f as g,l as _,o as v,s as y,u as b}from"./use-menu-BiJ8N7sS.js";import{t as x}from"./use-theme-DaxpiICf.js";import{a as S,bt as C,c as w,d as T,f as E,i as D,l as O,m as k,n as A,o as j,p as M,r as N,s as P,t as F,u as I,vt as L,yt as R}from"./index-CiBgHujl.js";import{n as z}from"./page-header-DkOHw0g-.js";import{t as B}from"./use-settings-back-CQauYjQ4.js";var V=e(n(),1),H=t(),U={system:a,light:o,dark:r};function W(){let{theme:e,scheme:t,density:n,resolvedScheme:r,setTheme:a,setScheme:o,setDensity:S,reset:w}=x(),T=l(),D=u(),O=h(),A=p(),j=C(),N=g();return(0,H.jsxs)(`div`,{className:`space-y-8`,children:[(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Theme`,description:`Palette, shape and typography. Each theme defines its own light and dark variants.`}),(0,H.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:k.map(t=>{let n=t.id===e;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>a(t.id),"aria-pressed":n,className:s(`focus-ring group flex flex-col gap-3 rounded-lg border p-4 text-left transition-colors`,n?`border-primary bg-accent`:`border-border hover:border-muted-foreground/40 hover:bg-accent/50`),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:t.name}),n&&(0,H.jsx)(i,{className:`size-4 shrink-0 text-primary`})]}),(0,H.jsx)(`div`,{className:`flex gap-1.5`,"aria-hidden":!0,children:t.swatches.map(e=>(0,H.jsx)(`span`,{className:`size-6 rounded-full border border-border`,style:{backgroundColor:e}},e))}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]},t.id)})})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Colour scheme`,description:t===`system`?`Following your system setting, currently ${r}.`:`Overrides your system setting.`}),(0,H.jsx)(Y,{options:M.map(e=>{let t=U[e.id];return{id:e.id,label:e.name,icon:(0,H.jsx)(t,{className:`size-4 shrink-0`})}}),value:t,onChange:o})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Density`,description:`Controls row height, hit-target size and shell spacing across the whole app.`}),(0,H.jsx)(Y,{options:E.map(e=>({id:e.id,label:e.name,title:e.description})),value:n,onChange:S}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:E.find(e=>e.id===n)?.description})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Layout`,description:`How menus and content share the screen. Device-local, like the wallpaper.`}),(0,H.jsx)(Y,{options:y.map(e=>({id:e.id,label:e.name,title:e.description})),value:O,onChange:_}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:y.find(e=>e.id===O)?.description}),O===`strip`&&(0,H.jsxs)(`div`,{className:`mt-4`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Navigation keys`}),(0,H.jsx)(Y,{options:v.map(e=>({id:e.id,label:e.name,title:e.description})),value:N,onChange:b}),(0,H.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[v.find(e=>e.id===N)?.description,` `,`Left and right walk the columns, up and down switch pin rows.`]})]})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Tree style`,description:`How workspace and context trees are drawn in the menu. Device-local.`}),(0,H.jsx)(Y,{options:L.map(e=>({id:e.id,label:e.name,title:e.description})),value:j,onChange:R}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:L.find(e=>e.id===j)?.description})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Open documents`,description:`Choose how documents open from lists, tiles and boards. Saved on this device.`}),(0,H.jsx)(Y,{options:[{id:`modal`,label:`Modal`},{id:`side`,label:`Side reading pane`}],value:D,onChange:m}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`The reading pane opens beside the content and updates as you select another document. On small screens it opens as a drawer.`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Always-on content area`,description:`Keep a reading pane beside document lists on tablets and desktops. Remember the selected item in each folder, or show the first available item.`}),(0,H.jsx)(Y,{options:[{id:`on`,label:`On`},{id:`off`,label:`Off`}],value:T?`on`:`off`,onChange:e=>f(e===`on`)}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`On by default. The reader uses roughly half the screen; drag its divider to resize. Phones keep tap-to-open navigation. When enabled, list selections use this pane regardless of the Open documents setting.`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Document tiles`,description:`Choose the photo and media layout for tile view. Saved on this device.`}),(0,H.jsx)(Y,{options:c,value:A,onChange:d})]}),(0,H.jsx)(G,{}),(0,H.jsx)(`section`,{children:(0,H.jsx)(`button`,{type:`button`,onClick:()=>{w(),m(`modal`)},className:`focus-ring rounded-md text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline`,children:`Reset to defaults`})})]})}function G(){let[e,t]=(0,V.useState)(j),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(!0),[o,s]=(0,V.useState)(!1),c=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=!1;return w().then(()=>{e||(t(j()),a(!1))}),()=>{e=!0}},[]);let l=async(e,n)=>{if(!c.current){c.current=!0,s(!0);try{let i=n?{...e,image:await P(n)}:e;await O(i),t(i),r(null)}catch(e){r(e instanceof Error&&e.name!==`QuotaExceededError`?e.message:`Could not store the wallpaper. Free some browser storage or try a smaller image.`)}finally{c.current=!1,s(!1)}}},u=t=>{t&&l(e,t)},d=e.image!==null&&N(e.image)===null,f=I(e.image);return(0,H.jsx)(`section`,{children:(0,H.jsxs)(`fieldset`,{disabled:i||o,className:`min-w-0`,children:[(0,H.jsx)(J,{title:`Wallpaper`,description:`Background image for the desk behind all panels. Without one, the theme's desk color shows (the default).`}),(0,H.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Wallpaper`,className:`grid grid-cols-3 gap-3 sm:grid-cols-4 lg:grid-cols-6`,children:[(0,H.jsx)(q,{label:`None`,isActive:e.image===null,onSelect:()=>l({...e,image:null}),children:(0,H.jsx)(`span`,{className:`flex size-full items-center justify-center surface-desk text-xs text-muted-foreground`,style:{backgroundImage:`none`},children:`None`})}),F.map(t=>(0,H.jsx)(q,{label:t.title,title:`${t.title} — suits the ${t.scheme} scheme`,isActive:N(e.image)===t.id,onSelect:()=>l({...e,image:D(t.id)}),children:(0,H.jsx)(`img`,{src:S(t),alt:``,loading:`lazy`,className:`size-full object-cover`,style:{backgroundColor:t.background}})},t.id)),d&&(0,H.jsx)(q,{label:`Your image`,isActive:!0,onSelect:()=>{},children:(0,H.jsx)(`img`,{src:e.image??void 0,alt:``,className:`size-full object-cover`})})]}),(0,H.jsx)(K,{}),(0,H.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`h-20 w-32 shrink-0 rounded-md border surface-desk`,style:f?{backgroundImage:f,backgroundSize:T(e.fit),backgroundPosition:`center`,backgroundRepeat:`no-repeat`}:void 0,"aria-hidden":!0}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(`label`,{className:`focus-ring inline-flex cursor-pointer items-center rounded-md border px-3 py-1.5 text-sm hover:bg-accent/50`,children:[d?`Change image…`:`Use your own image…`,(0,H.jsx)(`input`,{type:`file`,accept:`image/*,.gif`,className:`hidden`,onChange:e=>{u(e.target.files?.[0]),e.target.value=``}})]}),e.image&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>l({...e,image:null}),className:`focus-ring rounded-md border px-3 py-1.5 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:`Remove`})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Images and animated GIFs up to 10 MB. Stored on this device.`}),(0,H.jsx)(Y,{options:A.map(e=>({id:e.id,label:e.label,title:e.description})),value:e.fit,onChange:t=>l({...e,fit:t})}),n&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:n}),o&&(0,H.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Saving wallpaper…`})]})]})]})})}function K(){let e=F.filter(e=>e.author!==`Canvas`);return e.length===0?null:(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:e.map((e,t)=>(0,H.jsxs)(`span`,{children:[t>0&&` · `,e.title,` © `,e.author,e.source&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`a`,{href:e.source,target:`_blank`,rel:`noreferrer noopener`,className:`focus-ring underline underline-offset-2 hover:text-foreground`,children:new URL(e.source).hostname})]})]},e.id))})}function q({label:e,title:t,isActive:n,onSelect:r,children:a}){return(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e,title:t??e,onClick:r,className:s(`focus-ring group relative aspect-video overflow-hidden rounded-md border transition-colors`,n?`border-primary ring-1 ring-primary`:`border-border hover:border-muted-foreground/40`),children:[a,n&&(0,H.jsx)(`span`,{className:`absolute right-1 top-1 rounded-full bg-primary p-0.5 text-primary-foreground`,children:(0,H.jsx)(i,{className:`size-3`})})]})}function J({title:e,description:t}){return(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function Y({options:e,value:t,onChange:n}){return(0,H.jsx)(`div`,{role:`radiogroup`,className:`inline-flex flex-wrap gap-1 rounded-lg bg-muted p-1`,children:e.map(e=>{let r=e.id===t;return(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,title:e.title,onClick:()=>n(e.id),className:s(`focus-ring flex h-control items-center gap-2 rounded-md px-3 text-sm transition-colors`,r?`bg-card text-foreground shadow-elevation-1`:`text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)})})}function X(){return(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,H.jsx)(z,{className:`mb-6`,title:`Appearance`,onBack:B(),description:`Theme, colour scheme and density. Changes apply immediately and are remembered on this device.`}),(0,H.jsx)(W,{})]})}export{X as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Jt as r,Ur as i,Yt as a,et as o}from"./ui-Byg1cZDr.js";import{t as s}from"./utils-2pl1SbIp.js";import{a as c,i as l,n as u,o as d,r as f,s as p,t as m}from"./document-open-mode-DoImW-xs.js";import{d as h,f as g,l as _,o as v,s as y,u as b}from"./use-menu-BiJ8N7sS.js";import{t as x}from"./use-theme-DaxpiICf.js";import{a as S,bt as C,c as w,d as T,f as E,i as D,l as O,m as k,n as A,o as j,p as M,r as N,s as P,t as F,u as I,vt as L,yt as R}from"./index-D5Q9EUVc.js";import{n as z}from"./page-header-DkOHw0g-.js";import{t as B}from"./use-settings-back-CQauYjQ4.js";var V=e(n(),1),H=t(),U={system:a,light:o,dark:r};function W(){let{theme:e,scheme:t,density:n,resolvedScheme:r,setTheme:a,setScheme:o,setDensity:S,reset:w}=x(),T=l(),D=u(),O=h(),A=p(),j=C(),N=g();return(0,H.jsxs)(`div`,{className:`space-y-8`,children:[(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Theme`,description:`Palette, shape and typography. Each theme defines its own light and dark variants.`}),(0,H.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:k.map(t=>{let n=t.id===e;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>a(t.id),"aria-pressed":n,className:s(`focus-ring group flex flex-col gap-3 rounded-lg border p-4 text-left transition-colors`,n?`border-primary bg-accent`:`border-border hover:border-muted-foreground/40 hover:bg-accent/50`),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:t.name}),n&&(0,H.jsx)(i,{className:`size-4 shrink-0 text-primary`})]}),(0,H.jsx)(`div`,{className:`flex gap-1.5`,"aria-hidden":!0,children:t.swatches.map(e=>(0,H.jsx)(`span`,{className:`size-6 rounded-full border border-border`,style:{backgroundColor:e}},e))}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]},t.id)})})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Colour scheme`,description:t===`system`?`Following your system setting, currently ${r}.`:`Overrides your system setting.`}),(0,H.jsx)(Y,{options:M.map(e=>{let t=U[e.id];return{id:e.id,label:e.name,icon:(0,H.jsx)(t,{className:`size-4 shrink-0`})}}),value:t,onChange:o})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Density`,description:`Controls row height, hit-target size and shell spacing across the whole app.`}),(0,H.jsx)(Y,{options:E.map(e=>({id:e.id,label:e.name,title:e.description})),value:n,onChange:S}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:E.find(e=>e.id===n)?.description})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Layout`,description:`How menus and content share the screen. Device-local, like the wallpaper.`}),(0,H.jsx)(Y,{options:y.map(e=>({id:e.id,label:e.name,title:e.description})),value:O,onChange:_}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:y.find(e=>e.id===O)?.description}),O===`strip`&&(0,H.jsxs)(`div`,{className:`mt-4`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Navigation keys`}),(0,H.jsx)(Y,{options:v.map(e=>({id:e.id,label:e.name,title:e.description})),value:N,onChange:b}),(0,H.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[v.find(e=>e.id===N)?.description,` `,`Left and right walk the columns, up and down switch pin rows.`]})]})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Tree style`,description:`How workspace and context trees are drawn in the menu. Device-local.`}),(0,H.jsx)(Y,{options:L.map(e=>({id:e.id,label:e.name,title:e.description})),value:j,onChange:R}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:L.find(e=>e.id===j)?.description})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Open documents`,description:`Choose how documents open from lists, tiles and boards. Saved on this device.`}),(0,H.jsx)(Y,{options:[{id:`modal`,label:`Modal`},{id:`side`,label:`Side reading pane`}],value:D,onChange:m}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`The reading pane opens beside the content and updates as you select another document. On small screens it opens as a drawer.`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Always-on content area`,description:`Keep a reading pane beside document lists on tablets and desktops. Remember the selected item in each folder, or show the first available item.`}),(0,H.jsx)(Y,{options:[{id:`on`,label:`On`},{id:`off`,label:`Off`}],value:T?`on`:`off`,onChange:e=>f(e===`on`)}),(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`On by default. The reader uses roughly half the screen; drag its divider to resize. Phones keep tap-to-open navigation. When enabled, list selections use this pane regardless of the Open documents setting.`})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(J,{title:`Document tiles`,description:`Choose the photo and media layout for tile view. Saved on this device.`}),(0,H.jsx)(Y,{options:c,value:A,onChange:d})]}),(0,H.jsx)(G,{}),(0,H.jsx)(`section`,{children:(0,H.jsx)(`button`,{type:`button`,onClick:()=>{w(),m(`modal`)},className:`focus-ring rounded-md text-sm text-muted-foreground underline-offset-4 hover:text-foreground hover:underline`,children:`Reset to defaults`})})]})}function G(){let[e,t]=(0,V.useState)(j),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(!0),[o,s]=(0,V.useState)(!1),c=(0,V.useRef)(!1);(0,V.useEffect)(()=>{let e=!1;return w().then(()=>{e||(t(j()),a(!1))}),()=>{e=!0}},[]);let l=async(e,n)=>{if(!c.current){c.current=!0,s(!0);try{let i=n?{...e,image:await P(n)}:e;await O(i),t(i),r(null)}catch(e){r(e instanceof Error&&e.name!==`QuotaExceededError`?e.message:`Could not store the wallpaper. Free some browser storage or try a smaller image.`)}finally{c.current=!1,s(!1)}}},u=t=>{t&&l(e,t)},d=e.image!==null&&N(e.image)===null,f=I(e.image);return(0,H.jsx)(`section`,{children:(0,H.jsxs)(`fieldset`,{disabled:i||o,className:`min-w-0`,children:[(0,H.jsx)(J,{title:`Wallpaper`,description:`Background image for the desk behind all panels. Without one, the theme's desk color shows (the default).`}),(0,H.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Wallpaper`,className:`grid grid-cols-3 gap-3 sm:grid-cols-4 lg:grid-cols-6`,children:[(0,H.jsx)(q,{label:`None`,isActive:e.image===null,onSelect:()=>l({...e,image:null}),children:(0,H.jsx)(`span`,{className:`flex size-full items-center justify-center surface-desk text-xs text-muted-foreground`,style:{backgroundImage:`none`},children:`None`})}),F.map(t=>(0,H.jsx)(q,{label:t.title,title:`${t.title} — suits the ${t.scheme} scheme`,isActive:N(e.image)===t.id,onSelect:()=>l({...e,image:D(t.id)}),children:(0,H.jsx)(`img`,{src:S(t),alt:``,loading:`lazy`,className:`size-full object-cover`,style:{backgroundColor:t.background}})},t.id)),d&&(0,H.jsx)(q,{label:`Your image`,isActive:!0,onSelect:()=>{},children:(0,H.jsx)(`img`,{src:e.image??void 0,alt:``,className:`size-full object-cover`})})]}),(0,H.jsx)(K,{}),(0,H.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`h-20 w-32 shrink-0 rounded-md border surface-desk`,style:f?{backgroundImage:f,backgroundSize:T(e.fit),backgroundPosition:`center`,backgroundRepeat:`no-repeat`}:void 0,"aria-hidden":!0}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsxs)(`label`,{className:`focus-ring inline-flex cursor-pointer items-center rounded-md border px-3 py-1.5 text-sm hover:bg-accent/50`,children:[d?`Change image…`:`Use your own image…`,(0,H.jsx)(`input`,{type:`file`,accept:`image/*,.gif`,className:`hidden`,onChange:e=>{u(e.target.files?.[0]),e.target.value=``}})]}),e.image&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>l({...e,image:null}),className:`focus-ring rounded-md border px-3 py-1.5 text-sm text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:`Remove`})]}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Images and animated GIFs up to 10 MB. Stored on this device.`}),(0,H.jsx)(Y,{options:A.map(e=>({id:e.id,label:e.label,title:e.description})),value:e.fit,onChange:t=>l({...e,fit:t})}),n&&(0,H.jsx)(`p`,{className:`text-xs text-destructive`,children:n}),o&&(0,H.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:`Saving wallpaper…`})]})]})]})})}function K(){let e=F.filter(e=>e.author!==`Canvas`);return e.length===0?null:(0,H.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:e.map((e,t)=>(0,H.jsxs)(`span`,{children:[t>0&&` · `,e.title,` © `,e.author,e.source&&(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`a`,{href:e.source,target:`_blank`,rel:`noreferrer noopener`,className:`focus-ring underline underline-offset-2 hover:text-foreground`,children:new URL(e.source).hostname})]})]},e.id))})}function q({label:e,title:t,isActive:n,onSelect:r,children:a}){return(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e,title:t??e,onClick:r,className:s(`focus-ring group relative aspect-video overflow-hidden rounded-md border transition-colors`,n?`border-primary ring-1 ring-primary`:`border-border hover:border-muted-foreground/40`),children:[a,n&&(0,H.jsx)(`span`,{className:`absolute right-1 top-1 rounded-full bg-primary p-0.5 text-primary-foreground`,children:(0,H.jsx)(i,{className:`size-3`})})]})}function J({title:e,description:t}){return(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function Y({options:e,value:t,onChange:n}){return(0,H.jsx)(`div`,{role:`radiogroup`,className:`inline-flex flex-wrap gap-1 rounded-lg bg-muted p-1`,children:e.map(e=>{let r=e.id===t;return(0,H.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,title:e.title,onClick:()=>n(e.id),className:s(`focus-ring flex h-control items-center gap-2 rounded-md px-3 text-sm transition-colors`,r?`bg-card text-foreground shadow-elevation-1`:`text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)})})}function X(){return(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,H.jsx)(z,{className:`mb-6`,title:`Appearance`,onBack:B(),description:`Theme, colour scheme and density. Changes apply immediately and are remembered on this device.`}),(0,H.jsx)(W,{})]})}export{X as default};
@@ -1 +1 @@
1
- import{l as e}from"./code-editor-BOIngd5F.js";import{t}from"./use-applet-target-cO-FiyPQ.js";var n=e();function r({target:e,children:r}){return(0,n.jsx)(t.Provider,{value:e,children:r})}export{r as t};
1
+ import{l as e}from"./code-editor-BOIngd5F.js";import{t}from"./use-applet-target-gXPvZGgx.js";var n=e();function r({target:e,children:r}){return(0,n.jsx)(t.Provider,{value:e,children:r})}export{r as t};