@augmentd-labs/canvas-web 2.26.21 → 2.26.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DocumentBodyEditor-CE2S2X6g.js → DocumentBodyEditor-8DNmOBS0.js} +1 -1
- package/dist/assets/{DocumentIcon-BS10SIP6.js → DocumentIcon-x299QNu_.js} +1 -1
- package/dist/assets/{EditorOverlay-BUToR_av.js → EditorOverlay-Cv1MaTok.js} +1 -1
- package/dist/assets/{FileForm-BxTixeDm.js → FileForm-DhQhVnoi.js} +1 -1
- package/dist/assets/{FiltersApplet-DNYAQP5F.js → FiltersApplet-gbu4I1fK.js} +1 -1
- package/dist/assets/{HomeFab-CpTZdNyY.js → HomeFab-CXaEEzXy.js} +2 -2
- package/dist/assets/{IdentityFields-C2MPM-Ab.js → IdentityFields-OPEWPlZs.js} +1 -1
- package/dist/assets/{LensApplet-CRa1j2WP.js → LensApplet-FifF2RUs.js} +1 -1
- package/dist/assets/LinkToCard-nR7Lal_o.js +1 -0
- package/dist/assets/{MarkdownEditor-7OqSDr7E.js → MarkdownEditor-CNY-VmKb.js} +2 -2
- package/dist/assets/{MessageComposerDialog-DzLhkHyh.js → MessageComposerDialog-gbD0Gu_b.js} +1 -1
- package/dist/assets/{NextShell-D9gvlKY2.js → NextShell-BIYs9fCL.js} +1 -1
- package/dist/assets/{NotesApplet-CFK86JYj.js → NotesApplet-D94iQKg6.js} +1 -1
- package/dist/assets/ObjectPropertiesCard-ChvWbOpZ.js +8 -0
- package/dist/assets/{ObjectPropertiesCard-C3jt40tM.css → ObjectPropertiesCard-JArcZXXv.css} +1 -1
- package/dist/assets/{PathPickerField-cVs5sZuG.js → PathPickerField-DBe7jykL.js} +1 -1
- package/dist/assets/{PickDocumentsCard-BlicxMqC.js → PickDocumentsCard-Bo224P4q.js} +1 -1
- package/dist/assets/{SketchApplet-D8mkYmK9.js → SketchApplet-ADVOnSLI.js} +1 -1
- package/dist/assets/{SketchEditor-zMrm1npg.js → SketchEditor-CkgRysCG.js} +5 -5
- package/dist/assets/{TerminalApplet-BO2HRp0z.js → TerminalApplet-CkO4uaE3.js} +1 -1
- package/dist/assets/{TextDocumentEditor-7V4aFL8i.js → TextDocumentEditor-COvsHJXH.js} +1 -1
- package/dist/assets/{TodosApplet-swdaBT-2.js → TodosApplet-Bpf1OIH4.js} +1 -1
- package/dist/assets/{TodosWidget-BXF8fYer.js → TodosWidget-BIYqPXUp.js} +1 -1
- package/dist/assets/{UploadProgressList-B2xCVzFR.js → UploadProgressList-BXJr87lI.js} +1 -1
- package/dist/assets/{_agentId_-CHdTYJFu.js → _agentId_-wN8YJoTZ.js} +0 -0
- package/dist/assets/{_contextId_-m9zn5qav.js → _contextId_-CoJraYnP.js} +1 -1
- package/dist/assets/{_workspaceName_-D0z9E9Uy.js → _workspaceName_-CXuIfG46.js} +1 -1
- package/dist/assets/{about-pl0DXTEt.js → about-CT6Ghfkb.js} +1 -1
- package/dist/assets/{add-B30V-yHb.js → add-BzgCpo5S.js} +1 -1
- package/dist/assets/{agents-Bc7_wscP.js → agents-DIJpWCkc.js} +1 -1
- package/dist/assets/{agents-ClK3Y2x0.js → agents-DlLq0q2s.js} +1 -1
- package/dist/assets/{alert-dialog-DIA-tAP5.js → alert-dialog-izlVMXfa.js} +1 -1
- package/dist/assets/{api-tokens-O5iFESo0.js → api-tokens-DDH7LMJ7.js} +1 -1
- package/dist/assets/{appearance-DLo_2WH0.js → appearance-D1EpKWaK.js} +1 -1
- package/dist/assets/{applet-target-DnTa2VAT.js → applet-target-ChiiXVdC.js} +1 -1
- package/dist/assets/{apps-DzFFo5D0.js → apps-DX8oWukQ.js} +1 -1
- package/dist/assets/{auth-CUdpxbLV.js → auth-HZNJB4wv.js} +1 -1
- package/dist/assets/backend-sync-progress-BeI9mDEX.js +7 -0
- package/dist/assets/{button-Bv4zA1qr.js → button-SgR3GVvV.js} +1 -1
- package/dist/assets/content-app-view-DS6Nrz6M.js +1 -0
- package/dist/assets/{context-D_K4g9SQ.js → context-mfIOB8dN.js} +1 -1
- package/dist/assets/{contexts-CgydYDn-2.js → contexts-CRWqFXzJ2.js} +1 -1
- package/dist/assets/{contexts-B6d6Axza.js → contexts-Ef3fHwv6.js} +1 -1
- package/dist/assets/{date-time-picker-BZaA3M9_.js → date-time-picker-B6mkWt-g.js} +1 -1
- package/dist/assets/{devices-D3-_UWM0.js → devices-C3gLuNDv.js} +1 -1
- package/dist/assets/{document-BG_mODBn.js → document-CX543Kcz.js} +1 -1
- package/dist/assets/document-list-SsF3jmuq.js +2 -0
- package/dist/assets/{embedding-m8SZH4oN.js → embedding-BHnBCyUx.js} +1 -1
- package/dist/assets/{embedding-Cjrxh6MN.js → embedding-CEGjemkq.js} +1 -1
- package/dist/assets/{form-panel-Dz96K7Lv.js → form-panel-C34lByEH.js} +1 -1
- package/dist/assets/{home-C5IxNq_5.js → home-3vhobmCu.js} +1 -1
- package/dist/assets/index-CiBgHujl.js +16 -0
- package/dist/assets/{inferd-config-editor-DagMmwW4.js → inferd-config-editor-BHUUFArV.js} +1 -1
- package/dist/assets/{key-bindings-DomR6ZNC.js → key-bindings-BNeY-GEg.js} +1 -1
- package/dist/assets/{label-CNoJOoe0.js → label-Dn4gCMcc.js} +1 -1
- package/dist/assets/{lazy-editor-Cbva8Pe2.js → lazy-editor-BSRnneOo.js} +2 -2
- package/dist/assets/{logs-CdbfY8_H.js → logs-Czn2sPeP.js} +1 -1
- package/dist/assets/{offline-BjMpUv3N.js → offline-CsRyFUg7.js} +1 -1
- package/dist/assets/{page-header-GtTr9Ff_.js → page-header-DkOHw0g-.js} +1 -1
- package/dist/assets/{public-share-DT9Tgn_Y.js → public-share-DXxVwHKT.js} +1 -1
- package/dist/assets/{query-debug-tVbB_8Z6.js → query-debug-BUUG3jpK.js} +1 -1
- package/dist/assets/{registry-BgnkvPjl.js → registry-DTWAywyJ.js} +2 -2
- package/dist/assets/{remotes-DR_iJClb.js → remotes-CdEU1Y5l.js} +1 -1
- package/dist/assets/{roles-DERIgujv.js → roles-BYHLwWCD.js} +1 -1
- package/dist/assets/roles-BpVWTMmp.js +2 -0
- package/dist/assets/settings-DH3ZiQLR.js +14 -0
- package/dist/assets/{settings-DhoHM9AU.js → settings-DNhy58i9.js} +1 -1
- package/dist/assets/{settings-BXOyceZ3.js → settings-DjnFAqIe.js} +1 -1
- package/dist/assets/{settings-B4LC1yCH.js → settings-jWfP7CP8.js} +1 -1
- package/dist/assets/{share-target-CpjVaYVl.js → share-target-CgHlnZLH.js} +1 -1
- package/dist/assets/{shared-B824Ibpc.js → shared-BMoiShd9.js} +1 -1
- package/dist/assets/{shared-1dpCuibu.js → shared-D2uRUNdC.js} +1 -1
- package/dist/assets/sketch-lazy-pbG2cCpW.js +2 -0
- package/dist/assets/{subtree-transfer-dialog-B7s4r78T.js → subtree-transfer-dialog-ChBI5llU.js} +1 -1
- package/dist/assets/{text-documents-D_zDMyhB.js → text-documents-BvDFBVnC.js} +1 -1
- package/dist/assets/ui-Byg1cZDr.js +41 -0
- package/dist/assets/{use-applet-docs-Cry2SFsG.js → use-applet-docs-o5NAUFBk.js} +1 -1
- package/dist/assets/{use-applet-target-mkjQujx6.js → use-applet-target-cO-FiyPQ.js} +1 -1
- package/dist/assets/{use-canvas-pins-CZBfEB5E.js → use-canvas-pins-Bth_Q--t.js} +2 -2
- package/dist/assets/{use-menu-BVkqNEIx.js → use-menu-BiJ8N7sS.js} +1 -1
- package/dist/assets/use-settings-back-CQauYjQ4.js +1 -0
- package/dist/assets/{use-sortable-data-DYIDDI8c.js → use-sortable-data-BW_0sXBs.js} +1 -1
- package/dist/assets/{use-workspace-identity-BVpGHkZq.js → use-workspace-identity-mgaofjsD.js} +1 -1
- package/dist/assets/{useAddTarget-CVRPElxz.js → useAddTarget-DUjaZdBQ.js} +1 -1
- package/dist/assets/{useAgentModels-ndLotMWH.js → useAgentModels-Sa4N8WFd.js} +1 -1
- package/dist/assets/{useDocumentThumbnail-C_rq2rXs.js → useDocumentThumbnail-DYLCC63L.js} +1 -1
- package/dist/assets/{useEditNoteFields-Bigs9ZG8.js → useEditNoteFields-zHEWwDfB.js} +1 -1
- package/dist/assets/{users-C9N-O1QA.js → users-CKz9kOoR.js} +1 -1
- package/dist/assets/{workspace-CJ1PWQ29.js → workspace-DvxC7pw1.js} +1 -1
- package/dist/assets/{workspace-area-menu-Ba_9bGKs.js → workspace-area-menu-UamvRNfd.js} +1 -1
- package/dist/assets/{workspace-content-gate-D8bzGD9i.js → workspace-content-gate-Be4tLYiB.js} +1 -1
- package/dist/assets/{workspace-import-form-D5JA8gzx.js → workspace-import-form-BRwc_oVg.js} +1 -1
- package/dist/assets/{workspaces-Dx5_N57M.js → workspaces-Da_hUIj3.js} +1 -1
- package/dist/assets/{workspaces-BBgdfAM_.js → workspaces-gQY1mczH.js} +1 -1
- package/dist/index.html +36 -36
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/LinkToCard-BZwwE-Dv.js +0 -1
- package/dist/assets/ObjectPropertiesCard-DDcRLpsW.js +0 -8
- package/dist/assets/backend-sync-progress-DWR42uQV.js +0 -7
- package/dist/assets/content-app-view-BUi8HG1r.js +0 -1
- package/dist/assets/document-list-BiogH4tf.js +0 -2
- package/dist/assets/index-DtZS4JJ4.js +0 -16
- package/dist/assets/roles-DswT1Lv0.js +0 -2
- package/dist/assets/settings-CUzf6xEQ.js +0 -14
- package/dist/assets/sketch-lazy-Q58-vPF-.js +0 -2
- package/dist/assets/ui-BSqPn1LJ.js +0 -41
- package/dist/assets/use-settings-back-Dk-DJEUO.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,
|
|
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}?
|
|
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-
|
|
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 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Hr as r,L as i,Mt as a,Nr as o,dn as s,dr as c,fi as l,kr as u,oi as d,ur as f,yt as p}from"./ui-BSqPn1LJ.js";import{t as m}from"./utils-2pl1SbIp.js";import{Gn as h,On as g,wn as _}from"./workspace-CJ1PWQ29.js";import{o as v,t as y}from"./useAddTarget-CVRPElxz.js";import{a as b,i as x,o as S,r as C,s as w,t as T}from"./date-time-picker-BZaA3M9_.js";import{n as E}from"./use-applet-target-mkjQujx6.js";import{n as D,r as O,t as k}from"./shared-1dpCuibu.js";import{n as A,r as j,t as M}from"./use-applet-docs-Cry2SFsG.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:l,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)(s,{className:`inline h-3 w-3 animate-spin`}),F&&(0,P.jsx)(`span`,{className:`whitespace-nowrap`,children:L}),O===`saved`&&(0,P.jsx)(r,{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:l})]})]}),(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)(u,{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:u,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)(f,{className:`h-3.5 w-3.5`}):(0,P.jsx)(c,{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)(l,{className:`h-3.5 w-3.5`}):(0,P.jsx)(d,{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)(s,{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:u?.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:u?.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{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 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{
|
|
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 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Fr as r,Hr as i,L as a,an as o,dn as s,in as c,rr as l}from"./ui-BSqPn1LJ.js";import{t as u}from"./utils-2pl1SbIp.js";import{t as d}from"./button-Bv4zA1qr.js";import{t as f}from"./label-CNoJOoe0.js";import{At as p}from"./workspace-CJ1PWQ29.js";import{o as m,s as h}from"./IdentityFields-C2MPM-Ab.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-CVRPElxz.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),i=!e.supported||e.permission===`denied`,l=!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":i,"aria-label":`Geotag this document`,"aria-describedby":`${t}-hint`,tabIndex:i?-1:0,onClick:()=>!i&&e.setEnabled(!e.enabled),onKeyDown:t=>{i||(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`,i?`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)(o,{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)(c,{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)(a,{className:`h-3.5 w-3.5`})})]})]}),(0,k.jsx)(`p`,{id:`${t}-hint`,className:u(`text-xs`,l?`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)(i,{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)(l,{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,i=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`,i>0?`, ${i} 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)(a,{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-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};
|
|
Binary file
|
|
@@ -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-BZwwE-Dv.js";import{En as u,H as d,K as ee,Vt as te,t as f}from"./workspace-CJ1PWQ29.js";import{r as ne}from"./document-list-BiogH4tf.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-D_K4g9SQ.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-BVkqNEIx.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-BUi8HG1r.js";import{t as we}from"./use-workspace-identity-BVpGHkZq.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-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 +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{L as o,Vr as s,dn as c,zr as l}from"./ui-BSqPn1LJ.js";import{t as u}from"./utils-2pl1SbIp.js";import{t as d}from"./button-Bv4zA1qr.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{$t as g,En as _,K as ee,Nt as te,O as ne,Qt as re,S as v,T as ie,Ut as y,Vt as b,Z as ae,at as oe,b as se,bt as ce,d as le,dn as ue,dt as de,gt as fe,it as pe,o as me,q as x,v as he,vt as ge,yn as S}from"./workspace-CJ1PWQ29.js";import{n as _e,r as ve}from"./use-canvas-pins-CZBfEB5E.js";import{u as ye}from"./ObjectPropertiesCard-DDcRLpsW.js";import{h as be,i as C,r as xe}from"./document-list-BiogH4tf.js";import{n as Se}from"./use-toolbox-Ck_cLGgf.js";import{i as Ce}from"./color-DFEH4BfK.js";import{t as we}from"./geo-CZfs0E-x.js";import{c as Te}from"./backend-sync-progress-DWR42uQV.js";import{a as Ee,i as De,n as Oe,o as ke}from"./workspace-BydSRtST.js";import{n as Ae,r as je,t as Me}from"./url-params-n7kU_WZ-.js";import{i as Ne}from"./use-menu-BVkqNEIx.js";import{n as Pe}from"./last-path-BbXWC3b3.js";import{t as Fe}from"./workspace-area-menu-Ba_9bGKs.js";import{t as Ie}from"./workspace-content-gate-D8bzGD9i.js";import{t as Le}from"./form-panel-Dz96K7Lv.js";import{a as Re,i as ze,n as Be,o as Ve,r as He,s as Ue,t as We}from"./content-app-view-BUi8HG1r.js";import{i as Ge,o as Ke,r as qe}from"./query-debug-tVbB_8Z6.js";var w=`session.open`,Je=`session.set`,Ye=`session.ids`,Xe=`session.materialize`,Ze=`session.close`,T=`session.delta`,E=e(n(),1),D=t();function Qe({workspaceId:e,workspaceName:t}){let[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(new Set),s=t=>`${e}:${t.address}:${t.resyncStartedAt||``}`;(0,E.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 ce(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 l=n.filter(e=>!i.has(s(e)));return l.length?(0,D.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,D.jsxs)(`div`,{role:`status`,className:`mb-2 flex items-center gap-2 text-sm font-medium`,children:[(0,D.jsx)(c,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),(0,D.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`span`,{className:`block`,children:`Scanning storage`}),(0,D.jsx)(`span`,{className:`block truncate text-xs font-normal text-muted-foreground`,title:t,children:t})]}),(0,D.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,...l.map(s)])),children:(0,D.jsx)(o,{"aria-hidden":`true`,className:`h-4 w-4`})})]}),(0,D.jsx)(`div`,{className:`max-h-48 space-y-3 overflow-y-auto`,children:l.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,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:i}),(0,D.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:n===null?`${t} files`:`${t} / ${n}`})]}),(0,D.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,D.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 $e=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:null;function et(e){return`/${e}`.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`}function tt(e,t,n){if(e==null)return[];if(Array.isArray(e))return e.flatMap(e=>tt(e,t,n));if(typeof e==`string`)return[{tree:null,kind:t,path:et(e)}];let r=$e(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:et(e)}))}function O(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 nt(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 rt(e,t,n=new Map){let r=$e(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:et(n)}],ids:O(r),unknown:!1}:{targets:[],ids:[],unknown:!0}}let i=[...tt(r.context,`context`,n),...tt(r.directory,`directory`,n)],a=$e(r.changed);a&&i.push(...tt(a.context,`context`,n),...tt(a.directory,`directory`,n));let o=O(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 k(e,t){return e===t||e===`/`||t===`/`||e.startsWith(`${t}/`)||t.startsWith(`${e}/`)}function it(e,t){if(e.kind&&e.kind!==t.kind||e.tree&&e.tree!==t.tree)return!1;if(t.kind===`context`){let n=e=>et(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 k(e.path,t.path)}function at(e){return rt(`tree.refresh`,{treeName:e?.treeName,path:e?.path||`/`})}function ot(e,t,n){if(e.unknown||e.targets.length&&(t.wholeWorkspace||e.targets.some(e=>it(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 st(e,t,n={}){return m.request(w,{workspace:e,specs:t,opts:n})}function ct(e,t,n){return m.request(Je,{sessionId:e,label:t,spec:n})}function lt(e){return m.request(Ye,{sessionId:e})}function A(e,t={}){return m.request(Xe,{sessionId:e,...t})}function ut(e){return m.request(Ze,{sessionId:e})}function dt(e){return m.on(T,e)}var ft=100;function pt({workspaceRef:e,specs:t,opts:n,enabled:r=!0}){let[i,a]=(0,E.useState)([]),[o,s]=(0,E.useState)(0),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(null),f=(0,E.useRef)([]),p=(0,E.useRef)(new Map),h=(0,E.useRef)(null),g=(0,E.useRef)(null),_=(0,E.useRef)(null),ee=(0,E.useRef)({}),te=(0,E.useRef)(null),ne=(0,E.useMemo)(()=>JSON.stringify(t),[t]),re=(0,E.useMemo)(()=>JSON.stringify(n??{}),[n]),v=(0,E.useCallback)(()=>{let e=p.current;a(f.current.map(t=>e.get(t)).filter(Boolean))},[]),ie=(0,E.useCallback)(async e=>{let t=g.current;if(!t||e.length===0)return[];let n=[];for(let r=0;r<e.length;r+=ft){let i=e.slice(r,r+ft),a=await pe(t,`/`,[],{ids:i,scope:`workspace`,limit:i.length});n.push(...a.payload||[])}return n},[]),y=(0,E.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]),b=(0,E.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 y(a,[],t)},[y]);(0,E.useEffect)(()=>{if(g.current=e??null,!r||!e)return;let t=!1,n=null,i=async()=>{try{let r=await st(e,JSON.parse(ne),JSON.parse(re));if(t){ut(r.sessionId).catch(()=>{});return}n=r.sessionId,h.current=r.sessionId,l(r.sessionId),d(null),f.current=[],p.current=new Map,await b(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&&ut(e).catch(()=>{}),h.current=null,f.current=[],p.current=new Map,l(null),a([]),s(0)}},[e,ne,re,r]),(0,E.useEffect)(()=>{if(!c)return;let e=dt(e=>{if(e.sessionId===c){if(_.current!==null){te.current?.(_.current,ee.current);return}e.ids===void 0?y(e.added??[],e.removed??[],e.count):b(e.ids,e.count)}});return()=>{e?.()}},[c,y,b]);let ae=(0,E.useCallback)(async()=>{let e=h.current;if(e)try{let t=await lt(e);await b(t.ids,t.count)}catch{}},[b]),oe=(0,E.useCallback)(async(e,t)=>{let n=h.current;if(!n)throw Error(`No open query session`);let r=await ct(n,e,t);if(_.current!==null){await te.current?.(_.current,ee.current);return}await b(r.ids,r.count)},[b]),se=(0,E.useCallback)(async(e,t={})=>{let n=h.current;if(!n)throw Error(`No open query session`);if(_.current=e,ee.current=t,e===null){await ae();return}let r=await A(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,ae]);(0,E.useEffect)(()=>{te.current=se},[se]);let ce=(0,E.useCallback)(async(e,t,n={})=>{let r=h.current;if(!r)throw Error(`No open query session`);let i=await A(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 ct(r,e,{ids:i.ids});return await b(a.ids,a.count),i.ids},[b]);return{documents:i,count:o,ready:c!==null,error:u,setCue:oe,resync:ae,rank:se,rankAndPin:ce}}function mt({data:e,className:t}){let[n,r]=(0,E.useState)(!0),{rows:i,gapIndex:a,span:o}=(0,E.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,D.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 c=a>0?i[a].distance:null;return(0,D.jsxs)(`div`,{className:u(`rounded-md border border-border bg-muted/30 text-xs`,t),children:[(0,D.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,D.jsx)(s,{className:`h-3.5 w-3.5`}):(0,D.jsx)(l,{className:`h-3.5 w-3.5`}),`Query debug`,(0,D.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`: image distances for “`,e.query,`” (`,i.length,` nearest, unfloored)`]})]}),n&&(0,D.jsxs)(`div`,{className:`space-y-2 border-t border-border px-3 py-2`,children:[(0,D.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.`,c===null?(0,D.jsxs)(D.Fragment,{children:[` `,(0,D.jsx)(`span`,{className:`text-amber-600 dark:text-amber-500`,children:`No boundary in this window`}),`; the distances step evenly (typical Δ`,o.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,D.jsxs)(D.Fragment,{children:[` A jump at `,(0,D.jsx)(`span`,{className:`font-mono`,children:c.toFixed(4)}),` (Δ`,o.biggest.toFixed(4),`, vs typical Δ`,o.median.toFixed(4),`) stands out (a likely boundary).`]})]}),(0,D.jsx)(`div`,{className:`max-h-56 overflow-y-auto`,children:(0,D.jsx)(`table`,{className:`w-full font-mono text-[11px]`,children:(0,D.jsx)(`tbody`,{children:i.map((e,t)=>(0,D.jsxs)(`tr`,{className:u(`border-b border-border/40 last:border-0`,t===a&&`border-t-2 border-t-amber-500/70`),children:[(0,D.jsx)(`td`,{className:`py-0.5 pr-3 text-muted-foreground`,children:t+1}),(0,D.jsxs)(`td`,{className:`py-0.5 pr-3`,children:[`#`,e.id]}),(0,D.jsx)(`td`,{className:`py-0.5 tabular-nums`,children:e.distance.toFixed(4)}),t===a&&(0,D.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,D.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Range `,o.first.toFixed(4),` – `,o.last.toFixed(4),` (spread `,(o.last-o.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 ht(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 gt=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 gt.keys())e.startsWith(r)&>.delete(e)}function yt(e,t){let n=`${e}\0`;for(let[e,r]of gt){if(!e.startsWith(n))continue;let[,i,a,,,,,,o=`path`]=e.split(`\0`);ot(t,{tree:i,kind:S(i),path:a,wholeWorkspace:o.startsWith(`workspace`)},r.documents.map(e=>Number(e.id)))&>.delete(e)}}function bt(e,t){yt(t?.workspaceName??e,at(t))}function xt(){let{workspaceName:e}=r();return e?(0,D.jsx)(Ie,{workspaceName:e,children:(0,D.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),Ie=(()=>{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]:[]})(),[w,Je]=(0,E.useState)(null),[Ye,Xe]=(0,E.useState)(!0),[Ze,T]=(0,E.useState)([]),[$e,et]=(0,E.useState)(!1),[tt,O]=(0,E.useState)(0),k=qe(),[it,st]=(0,E.useState)(null),[ct,lt]=(0,E.useState)(k);ct!==k&&(lt(k),k||st(null));let[A,ut]=(0,E.useState)(`path`),[dt,ft]=(0,E.useState)(!1),[_t,xt]=(0,E.useState)(null),[M,St]=(0,E.useState)(null),[wt,Tt]=(0,E.useState)(``),[Et,Dt]=(0,E.useState)(!1),[Ot,kt]=(0,E.useState)(!1),[At,jt]=(0,E.useState)(!1),[N,Mt]=(0,E.useState)(null),[P,F]=(0,E.useState)(1),[I,Nt]=(0,E.useState)(50),[L,Pt]=(0,E.useState)(Ie),[Ft,It]=(0,E.useState)(null),{state:R,saveFilters:Lt,setSort:Rt,setAccentColor:zt,setMapDocuments:Bt}=Se(),Vt=R.filters.features.allOf,z=R.filters.features.anyOf,Ht=R.filters.features.noneOf,Ut=De(R.filters.timeline),Wt=Ee(R.filters.geo),Gt=ke(R.filters.lens,R.filters.geo.includeUnlocated),B=R.filters.lens.ids,Kt=[...Ut,...Wt,...Gt],qt=R.filters.sort??Oe,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=Ae(n.pathname).path,H=t??`context`,U=H===`backends`,[Xt,Zt]=(0,E.useState)([]);(0,E.useEffect)(()=>{!U||!e||ce(e).then(Zt).catch(()=>Zt([]))},[U,e]);let Qt=U?me(V,Xt):null,[$t,en]=(0,E.useState)(!1),tn=`${H}\0${V}`,[nn,rn]=(0,E.useState)(tn);nn!==tn&&(rn(tn),en(!1));let W=l.get(`layer`)===`1`,G=l.get(`layerId`)||null,[K,an]=(0,E.useState)(null),[q,on]=(0,E.useState)(null),sn=(0,E.useRef)(null);(0,E.useEffect)(()=>{sn.current=q},[q]);let[cn,ln]=(0,E.useState)(`left`),[un,dn]=(0,E.useState)([]),{openM1Drawer:fn,openM2Drawer:pn,goBack:mn}=Ne(),[hn,gn]=(0,E.useState)([]),J=(0,E.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,E.useRef)(null);(0,E.useEffect)(()=>{!e||!K||W||_n.current===`${e}/${H}`&&(V!==`/`&&!J||Pe(e,H,V))},[e,K,W,V,J,H]);let vn=(0,E.useMemo)(()=>W||A===`workspace`||L.length>0||S(H)!==`directory`?[]:ht(K,V),[K,V,H,W,A,L]),yn=W?null:V===`/`?K:J,X=be(),bn=`${H}\0${V}`,[xn,Sn]=(0,E.useState)(null),Cn=xn?.key===bn?xn.views:Ve(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??ze.id,Z=wn.find(e=>e.id===Tn)??wn[0]??ze;(0,E.useEffect)(()=>{X?.selectView(Z)},[Z,X]);let En=U?void 0:X?.schema??Re(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}),_(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}=_e(),In=w?.name,Q=(0,E.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,E.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=Ce(w?.color)||null;(0,E.useEffect)(()=>(zt(Hn),()=>zt(null)),[Hn,zt]);let Un=(0,E.useCallback)(async t=>{let n=B;if(t?.anyOf?.length&&z.length&&(n=((await x(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 x(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,E.useEffect)(()=>{e&&(async()=>{Xe(!0);try{let t=await p.get(`${f.workspaces}/${e}`),n;n=t&&`workspace`in t?t.workspace:t,Je(n)}catch(t){let n=t instanceof Error?t.message:`Failed to fetch workspace ${e}`;s({title:`Error`,description:n,variant:`destructive`}),Je(null)}finally{Xe(!1)}})()},[e,s]),(0,E.useEffect)(()=>{let e=e=>{let t=e.detail?.workspace;t&&Je(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}=pt({workspaceRef:e,specs:(0,E.useMemo)(()=>{let e={features:{allOf:Dn,anyOf:z,noneOf:Ht},filters:Kt};return A!==`workspace`&&(S(H)===`directory`?e.directory={tree:H,path:V}:e.context=V),[{label:`scope`,spec:e}]},[Yt,V,H,A,En]),opts:(0,E.useMemo)(()=>({mode:`live`,debounceMs:150}),[]),enabled:Wn}),Zn=Wn&&qn,Qn=(0,E.useRef)(!1);(0,E.useEffect)(()=>{Qn.current=Zn},[Zn]);let $n=L.length===1?L[0].trim():``;(0,E.useEffect)(()=>{qn&&Xn($n?{text:$n}:null,{limit:I,offset:(P-1)*I}).catch(()=>{})},[qn,$n,I,P,Xn]);let er=(B??[]).join(`,`);(0,E.useEffect)(()=>{qn&&Jn(`lens`,{ids:B??[]}).catch(()=>{})},[qn,er,Jn,B]);let tr=Zn?Gn:Ze,nr=Zn?Kn:tt,rr=(0,E.useRef)(new Set);(0,E.useEffect)(()=>{rr.current=new Set(tr.map(e=>Number(e.id)))},[tr]);let ir=R.geoSelection;(0,E.useEffect)(()=>{Bt(tr,w?.name??null)},[tr,w?.name,Bt]),(0,E.useEffect)(()=>()=>Bt([]),[Bt]);let ar=(0,E.useMemo)(()=>ir?tr.filter(e=>we(e,ir,R.filters.geo.includeUnlocated)):tr,[tr,ir,R.filters.geo.includeUnlocated]),or=le(V,Dn,{treeName:H,treeType:S(H),scope:A,queries:L,anyOf:z,noneOf:Ht,filters:Kt,ids:B,layerId:W&&G?G:void 0}),sr=JSON.stringify([e,or]),[cr,lr]=(0,E.useState)(``),[ur,dr]=(0,E.useState)(!1),fr=(0,E.useRef)(!1),pr=$e||ur||cr!==sr||Zn||!!ir,mr=(0,E.useRef)(0),hr=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>{mr.current++,hr.current=null},[]);let gr=(0,E.useRef)(``),$=(0,E.useCallback)(async t=>{if(!e)return;if(Te(H,V)){mr.current++,hr.current=null,gr.current=``,T([]),O(0),et(!1);return}if(Qn.current)return;let n=`${$t&&Qt?`${A}:unfiled`:A}:${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${k}`;if(t?.silent&&hr.current?.key===c){hr.current.refreshPending=!0;return}let l=++mr.current,u=t?.silent||r||k?void 0:gt.get(o);u&&(T(u.documents),O(u.totalCount),lr(sr),et(!1)),(t?.silent??(a||!!u))||et(!0);let d={key:c,refreshPending:!1};hr.current=d;try{let t;t=$t&&Qt?await ge(e,Qt.driver,Qt.address,{linked:!1,limit:I,offset:(P-1)*I}):W&&G&&A!==`workspace`?await oe(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:A,debug:k&&L.length>0,debugLimit:200});let n=t.payload||[],i=t.totalCount||t.count||0;if(!r&&!d.refreshPending&>.set(o,{documents:n,totalCount:i}),l!==mr.current)return;let s=t.debug,c=s?.imageDistances??s?.distances??null;st(c?{query:L[L.length-1]??``,distances:c}:null),T(a?e=>e.length===n.length&&e.every((e,t)=>e.id===n[t].id)?e:n:n),O(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`}),T([]),O(0)}finally{hr.current===d&&(hr.current=null),l===mr.current&&et(!1),l===mr.current&&d.refreshPending&&$({silent:!0})}},[e,V,H,G,W,P,I,w?.status,L,Jt,A,$t,k,En]);(0,E.useEffect)(()=>{$()},[$]),(0,E.useEffect)(()=>{let t=t=>{let n=t.detail;!n||n.workspaceName!==e||(on({treeName:n.treeName||`context`,path:je(n.path||`/`)}),ln(`left`))};return window.addEventListener(`workspace:open-to-side`,t),()=>window.removeEventListener(`workspace:open-to-side`,t)},[e,H,V]),(0,E.useEffect)(()=>{let t=t=>{let n=t.detail;if(!(n?.workspaceName&&n.workspaceName!==e)&&(e&&bt(e,n),ot(at(n),{tree:H,kind:S(H),path:V,wholeWorkspace:A===`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,A,Yn]);let _r=w?.name,vr=w?.id;(0,E.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=()=>{te(e).then(e=>{a||(i=nt(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=rt(t,n,i);yt(e,r);let a={tree:H,kind:S(H),path:V,wholeWorkspace:A===`workspace`},f=sn.current;f&&ot(r,{tree:f.treeName,kind:S(f.treeName),path:f.path})&&(u=f),ot(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,A,$,Yn]);let yr=`${V}\0${H}\0${G??``}\0${A}`,[br,xr]=(0,E.useState)(yr);br!==yr&&(xr(yr),F(1),It(null));let Sr=`${V}\0${H}\0${G??``}`,[Cr,wr]=(0,E.useState)(Sr);Cr!==Sr&&(wr(Sr),ut(`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,E.useState)(!1);Dr!==Er&&(Or(Er),Er&&Tr(V,!1)),(0,E.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,E.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`),...Ie]),[jr,Mr]=(0,E.useState)(Ar);jr!==Ar&&(Mr(Ar),Pt(Ie),F(1));let Nr=`${Ar}\0${Y??``}\0${An}\0${V}\0${Ft??``}`,[Pr,Fr]=(0,E.useState)(Nr);Pr!==Nr&&(Fr(Nr),l.has(`q`)||Ie.length>0||Y!==`canvas`||Ft===V||(Pt(An?[An]:[]),F(1)));let Ir=(0,E.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,E.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,E.useEffect)(()=>{let t=!1;if(!e)return;let n=0,r=!1,i=(i=!1)=>{let a=++n;i&&fe(e,H),ee(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=C(e,vr);return()=>{t=!0,o(),window.removeEventListener(`workspace:tree:refresh`,a)}},[e,H,vr]),!(e&&Y===`canvas`&&!W)&&N!==null&&Mt(null),(0,E.useEffect)(()=>{let t=!1;if(!(!e||Y!==`canvas`||W))return ae(e,V,H).then(e=>{t||Mt(e)}).catch(()=>{t||Mt(null)}),()=>{t=!0}},[e,V,H,Y,W]);let Br=async()=>{if(w){ft(!0);try{let t=await ue(e||w.id);Je(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{ft(!1)}}},Vr=async t=>{if(!w)return;let n=c({title:`Removing…`,description:`Document from "${V}"`});try{await re(e||w.id,[t],V,[],H,Yr,{trashIfOrphaned:!0}),j(e||w.id,H,V),T(e=>e.filter(e=>e.id!==t)),O(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(!w)return;let n=c({title:`Deleting…`,description:`Document from "${V}"`});try{await ie(e||w.id,[t],V,[],H,Yr),j(e||w.id,H,V),T(e=>e.filter(e=>e.id!==t)),O(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(!w)return;let n=c({title:`Removing…`,description:`${t.length} document(s) from "${V}"`});try{await re(e||w.id,t,V,[],H,Yr,{trashIfOrphaned:!0}),j(e||w.id,H,V),T(e=>e.filter(e=>!t.includes(e.id))),O(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(!w)return;let n=c({title:`Deleting…`,description:`${t.length} document(s)`});try{await ie(e||w.id,t,V,[],H,Yr),j(e||w.id,H,V),T(e=>e.filter(e=>!t.includes(e.id))),O(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(!w)return;let n=c({title:`Destroying…`,description:`Document and its backend copies`});try{let r=await ne(e||w.id,[t]);if(r.failed?.length){n.fail({title:`Error`,description:r.failed[0].reason,variant:`destructive`});return}T(e=>e.filter(e=>e.id!==t)),O(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(!w)return;let n=c({title:`Destroying…`,description:`${t.length} document(s) and their backend copies`});try{let r=await ne(e||w.id,t),i=new Set(r.successful?.filter(e=>e.docDeleted).map(e=>e.id)??[]);T(e=>e.filter(e=>!i.has(e.id))),O(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=S(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 b(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=S(a);await re(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&&(xe(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(!w||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 y(e||w.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||w.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 se(e,r,H,M.captureView?{metadata:{toolbox:i},querySpec:{features:i.features,filters:[...De(R.filters.timeline),...Ee(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 ee(e,H,{force:!0});an(t)}catch{}window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),o(Me(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 he(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 g(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(Me(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,E.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=S(i.treeName),l=c({title:t?`Moving…`:`Copying…`,description:`${a.length} document(s) → "${i.path}"`});try{if(!await b(e,i.path,a,i.treeName,o)){l.done();return}if(j(e,i.treeName,i.path),t){let t=S(r.treeName);await re(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,E.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]),Ye)return(0,D.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,D.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,D.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading workspace...`})]})});if(!w)return(0,D.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,D.jsx)(He,{views:wn,activeId:Tn,onSelect:On,onSave:kn,accentColor:Ce(w.color),onOpenToSide:e=>{on({treeName:H,path:V,viewId:e}),ln(`right`)}}):void 0,si=Qt||w.status!==`active`?(0,D.jsxs)(D.Fragment,{children:[Qt&&(0,D.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`}),w.status!==`active`&&(0,D.jsx)(`button`,{type:`button`,onClick:Br,disabled:dt,className:`min-h-10 rounded-md border px-2 text-xs`,children:dt?`Starting…`:`Start`})]}):void 0,ci=Te(H,V)?V===`/Trash`?(0,D.jsx)(`div`,{className:`h-full overflow-auto p-4`,children:(0,D.jsx)(Ge,{workspaceName:e||w.id})}):(0,D.jsx)(Ke,{workspace:e||w.id,path:V,onNavigate:t=>o(Me(e,t,`backends`))},e):(0,D.jsx)(Ue,{navigationTabs:oi,navigationActions:si,onBack:mn,accentColor:Ce(w.color),urlType:W?S(H)===`directory`?`${H}-layer`:`context-layer`:Y===`canvas`?`canvas`:S(H)===`directory`?H:`context`,urlDisplay:Vn,contextPath:V,treeName:H,workspaceId:e||w.id,workspaceLabel:w.label||w.name,workspaceIcon:w.icon,documentSchema:En,documents:ar,isLoading:$e,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(Me(e,t,H)),folders:vn,onOpenFolder:t=>o(Me(e,je(t),H)),scope:A,onScopeChange:ut,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:k&&it?(0,D.jsx)(mt,{data:it,className:`mb-3`}):null,children:ai&&J?(0,D.jsx)(ve,{workspaceId:e||w.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,D.jsx)(Be,{documents:ar,workspaceId:e||w.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,D.jsx)(We,{app:Z.app,workspaceId:e||w.id,treeName:H,path:V}):null});return(0,D.jsxs)(Fe,{workspaceId:e||w.id,treeName:H,path:V,headerOnly:!0,className:`relative flex flex-col h-full min-h-0`,children:[(0,D.jsx)(Qe,{workspaceId:w.id,workspaceName:w.label||w.name},w.id),Te(H,V)&&(0,D.jsx)(ye,{workspace:w.label||w.name,workspaceIcon:w.icon,tree:H,path:V,onBack:mn,onBrowseTree:()=>pn(`workspaces`,`detail`,e||w.id),onBrowseWorkspaces:()=>fn(`workspaces`),onNavigatePath:t=>o(Me(e,t,H)),accentColor:Ce(w.color)}),M&&(0,D.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,D.jsx)(Le,{title:`New canvas`,onClose:()=>St(null),children:(0,D.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ei()},className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{htmlFor:`canvas-name`,className:`mb-1 block text-sm font-medium`,children:`Name`}),(0,D.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,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`mb-1 block text-sm font-medium`,children:`Parent path`}),(0,D.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,D.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,D.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:M.captureView,onChange:e=>St({...M,captureView:e.target.checked})}),(0,D.jsxs)(`span`,{children:[`Capture the current view`,(0,D.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Freezes the active filters, search and sort into the canvas.`})]})]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(d,{type:`submit`,disabled:!wt.trim()||Et,children:Et?`Creating…`:`Create canvas`}),(0,D.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>St(null),children:`Cancel`})]})]})})}),(0,D.jsxs)(`div`,{"data-canvas-panes":!0,className:`flex-1 min-h-0 flex gap-2`,children:[(0,D.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,D.jsx)(Ct,{workspaceName:e,workspaceLabel:w.label||w.name,workspaceIcon:w.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}=Ne(),{showToast:m,showProgress:g}=h(),[_,te]=(0,E.useState)(null),[v,y]=(0,E.useState)([]),[ae,oe]=(0,E.useState)(!1),[se,ce]=(0,E.useState)(0),[le,ue]=(0,E.useState)(1),[de,me]=(0,E.useState)(50),x=S(r.treeName),he=St(_,r.path),ge=he?.type===`canvas`,_e=(0,E.useMemo)(()=>x===`directory`?ht(_,r.path):[],[_,r.path,x]),ve=r.viewId?Ve(he?.metadata).find(e=>e.id===r.viewId)??null:null,ye=`${e}://${r.path===`/`?``:r.path.replace(/^\//,``)}`,be=Re(ve),C=(0,E.useCallback)(async()=>{if(Te(r.treeName,r.path)){y([]),ce(0),oe(!1);return}let t=vt(e,r.treeName,r.path,le,de,``,be??``),n=gt.get(t);if(n){y(n.documents),ce(n.totalCount);return}oe(!0);try{let n=await pe(e,r.path,be?[be]:[],{limit:de,page:le,treeName:r.treeName,treeType:x}),i=n.payload||[],a=n.totalCount||n.count||0;y(i),ce(a),gt.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([]),ce(0)}finally{oe(!1)}},[e,r.path,r.treeName,x,de,le,m,be]);(0,E.useEffect)(()=>{let t=!1,n=0,i=!1,a=(a=!1)=>{let o=++n;a&&fe(e,r.treeName),ee(e,r.treeName).then(e=>{!t&&o===n&&(i=!0,te(e))}).catch(()=>{!t&&o===n&&!i&&te(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,E.useEffect)(()=>{C()},[C]),(0,E.useEffect)(()=>{let t=t=>{let n=t.detail;n?.workspaceName&&n.workspaceName!==e||(bt(e,n),ot(at(n),{tree:r.treeName,kind:S(r.treeName),path:r.path})&&(j(e,r.treeName,r.path),C()))};return window.addEventListener(`workspace:documents:refresh`,t),()=>window.removeEventListener(`workspace:documents:refresh`,t)},[C,e,r.treeName,r.path]);let xe=(0,E.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 b(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=S(c);await re(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 C(),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,C,g,a,o]),Se=(0,E.useCallback)(()=>{j(e,r.treeName,r.path),C()},[e,r.treeName,r.path,C]),Ce=(0,E.useCallback)(async t=>{let n=g({title:`Removing…`,description:`${t.length} document(s) from "${r.path}"`});try{await re(e,t,r.path,[],r.treeName,x),Se(),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,Se,g]),we=(0,E.useCallback)(async t=>{let n=g({title:`Deleting…`,description:`${t.length} document(s)`});try{await ie(e,t,r.path,[],r.treeName,x),Se(),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,Se,g]),Ee=(0,E.useCallback)(async t=>{let n=g({title:`Destroying…`,description:`${t.length} document(s) and their backend copies`});try{let r=await ne(e,t);if(r.failed?.length&&!r.successful?.length){n.fail({title:`Error`,description:r.failed[0].reason,variant:`destructive`});return}Se();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,Se,g]);return(0,D.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,D.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`}),Te(r.treeName,r.path)?r.path===`/Trash`?(0,D.jsx)(`div`,{className:`h-full overflow-auto p-4`,children:(0,D.jsx)(Ge,{workspaceName:e})}):(0,D.jsx)(Ke,{workspace:e,path:r.path,onNavigate:l||(()=>{})}):(0,D.jsx)(Ue,{frameContent:!1,onBrowseWorkspaces:()=>f(`workspaces`),onBrowseTree:()=>p(`workspaces`,`detail`,e),urlType:ge?`canvas`:x===`directory`?r.treeName:`context`,urlDisplay:ye,contextPath:r.path,treeName:r.treeName,workspaceId:e,workspaceLabel:t,workspaceIcon:n,documentSchema:be,documents:v,isLoading:ae,totalCount:se,currentPage:le,pageSize:de,onPageChange:ue,onPageSizeChange:e=>{me(e),ue(1)},onRemoveDocument:r.path===`/`?void 0:e=>Ce([e]),onRemoveDocuments:r.path===`/`?void 0:Ce,onDeleteDocument:e=>we([e]),onDeleteDocuments:we,onDestroyDocument:e=>Ee([e]),onDestroyDocuments:Ee,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:xe,onSelectionChange:c,pastedDocumentIds:a?.documentIds,linkTree:_,folders:_e,onOpenFolder:l,onNavigatePath:l,canvasInfo:ge?{label:he?.label,description:he?.description,color:he?.color}:void 0,children:ve?.kind===`columns`?(0,D.jsx)(Be,{documents:v,workspaceId:e,columns:ve.columns??[],onColumnsChange:()=>{},readOnly:!0}):ve?.kind===`app`&&ve.app&&ve.app!==`notes`?(0,D.jsx)(We,{app:ve.app,workspaceId:e,treeName:r.treeName,path:r.path}):null})]})}export{xt 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{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{$t as g,En as _,K as ee,Nt as te,O as ne,Qt as re,S as v,T as ie,Ut as y,Vt as b,Z as ae,at as oe,b as se,bt as ce,d as le,dn as ue,dt as de,gt as fe,it as pe,o as me,q as x,v as he,vt as ge,yn as S}from"./workspace-DvxC7pw1.js";import{n as _e,r as ve}from"./use-canvas-pins-Bth_Q--t.js";import{u as ye}from"./ObjectPropertiesCard-ChvWbOpZ.js";import{h as be,i as C,r as xe}from"./document-list-SsF3jmuq.js";import{n as Se}from"./use-toolbox-Ck_cLGgf.js";import{i as Ce}from"./color-DFEH4BfK.js";import{t as we}from"./geo-CZfs0E-x.js";import{c as Te}from"./backend-sync-progress-BeI9mDEX.js";import{a as Ee,i as De,n as Oe,o as ke}from"./workspace-BydSRtST.js";import{n as Ae,r as je,t as Me}from"./url-params-n7kU_WZ-.js";import{i as Ne}from"./use-menu-BiJ8N7sS.js";import{n as Pe}from"./last-path-BbXWC3b3.js";import{t as Fe}from"./workspace-area-menu-UamvRNfd.js";import{t as Ie}from"./workspace-content-gate-Be4tLYiB.js";import{t as Le}from"./form-panel-C34lByEH.js";import{a as Re,i as ze,n as Be,o as Ve,r as He,s as Ue,t as We}from"./content-app-view-DS6Nrz6M.js";import{i as Ge,o as Ke,r as qe}from"./query-debug-BUUG3jpK.js";var w=`session.open`,Je=`session.set`,Ye=`session.ids`,Xe=`session.materialize`,Ze=`session.close`,T=`session.delta`,E=e(n(),1),D=t();function Qe({workspaceId:e,workspaceName:t}){let[n,r]=(0,E.useState)([]),[i,a]=(0,E.useState)(new Set),o=t=>`${e}:${t.address}:${t.resyncStartedAt||``}`;(0,E.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 ce(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,D.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,D.jsxs)(`div`,{role:`status`,className:`mb-2 flex items-center gap-2 text-sm font-medium`,children:[(0,D.jsx)(l,{"aria-hidden":`true`,className:`h-4 w-4 animate-spin`}),(0,D.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`span`,{className:`block`,children:`Scanning storage`}),(0,D.jsx)(`span`,{className:`block truncate text-xs font-normal text-muted-foreground`,title:t,children:t})]}),(0,D.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,D.jsx)(c,{"aria-hidden":`true`,className:`h-4 w-4`})})]}),(0,D.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,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:i}),(0,D.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:n===null?`${t} files`:`${t} / ${n}`})]}),(0,D.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,D.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 $e=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:null;function et(e){return`/${e}`.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`}function tt(e,t,n){if(e==null)return[];if(Array.isArray(e))return e.flatMap(e=>tt(e,t,n));if(typeof e==`string`)return[{tree:null,kind:t,path:et(e)}];let r=$e(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:et(e)}))}function O(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 nt(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 rt(e,t,n=new Map){let r=$e(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:et(n)}],ids:O(r),unknown:!1}:{targets:[],ids:[],unknown:!0}}let i=[...tt(r.context,`context`,n),...tt(r.directory,`directory`,n)],a=$e(r.changed);a&&i.push(...tt(a.context,`context`,n),...tt(a.directory,`directory`,n));let o=O(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 k(e,t){return e===t||e===`/`||t===`/`||e.startsWith(`${t}/`)||t.startsWith(`${e}/`)}function it(e,t){if(e.kind&&e.kind!==t.kind||e.tree&&e.tree!==t.tree)return!1;if(t.kind===`context`){let n=e=>et(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 k(e.path,t.path)}function at(e){return rt(`tree.refresh`,{treeName:e?.treeName,path:e?.path||`/`})}function ot(e,t,n){if(e.unknown||e.targets.length&&(t.wholeWorkspace||e.targets.some(e=>it(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 st(e,t,n={}){return m.request(w,{workspace:e,specs:t,opts:n})}function ct(e,t,n){return m.request(Je,{sessionId:e,label:t,spec:n})}function lt(e){return m.request(Ye,{sessionId:e})}function A(e,t={}){return m.request(Xe,{sessionId:e,...t})}function ut(e){return m.request(Ze,{sessionId:e})}function dt(e){return m.on(T,e)}var ft=100;function pt({workspaceRef:e,specs:t,opts:n,enabled:r=!0}){let[i,a]=(0,E.useState)([]),[o,s]=(0,E.useState)(0),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(null),f=(0,E.useRef)([]),p=(0,E.useRef)(new Map),h=(0,E.useRef)(null),g=(0,E.useRef)(null),_=(0,E.useRef)(null),ee=(0,E.useRef)({}),te=(0,E.useRef)(null),ne=(0,E.useMemo)(()=>JSON.stringify(t),[t]),re=(0,E.useMemo)(()=>JSON.stringify(n??{}),[n]),v=(0,E.useCallback)(()=>{let e=p.current;a(f.current.map(t=>e.get(t)).filter(Boolean))},[]),ie=(0,E.useCallback)(async e=>{let t=g.current;if(!t||e.length===0)return[];let n=[];for(let r=0;r<e.length;r+=ft){let i=e.slice(r,r+ft),a=await pe(t,`/`,[],{ids:i,scope:`workspace`,limit:i.length});n.push(...a.payload||[])}return n},[]),y=(0,E.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]),b=(0,E.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 y(a,[],t)},[y]);(0,E.useEffect)(()=>{if(g.current=e??null,!r||!e)return;let t=!1,n=null,i=async()=>{try{let r=await st(e,JSON.parse(ne),JSON.parse(re));if(t){ut(r.sessionId).catch(()=>{});return}n=r.sessionId,h.current=r.sessionId,l(r.sessionId),d(null),f.current=[],p.current=new Map,await b(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&&ut(e).catch(()=>{}),h.current=null,f.current=[],p.current=new Map,l(null),a([]),s(0)}},[e,ne,re,r]),(0,E.useEffect)(()=>{if(!c)return;let e=dt(e=>{if(e.sessionId===c){if(_.current!==null){te.current?.(_.current,ee.current);return}e.ids===void 0?y(e.added??[],e.removed??[],e.count):b(e.ids,e.count)}});return()=>{e?.()}},[c,y,b]);let ae=(0,E.useCallback)(async()=>{let e=h.current;if(e)try{let t=await lt(e);await b(t.ids,t.count)}catch{}},[b]),oe=(0,E.useCallback)(async(e,t)=>{let n=h.current;if(!n)throw Error(`No open query session`);let r=await ct(n,e,t);if(_.current!==null){await te.current?.(_.current,ee.current);return}await b(r.ids,r.count)},[b]),se=(0,E.useCallback)(async(e,t={})=>{let n=h.current;if(!n)throw Error(`No open query session`);if(_.current=e,ee.current=t,e===null){await ae();return}let r=await A(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,ae]);(0,E.useEffect)(()=>{te.current=se},[se]);let ce=(0,E.useCallback)(async(e,t,n={})=>{let r=h.current;if(!r)throw Error(`No open query session`);let i=await A(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 ct(r,e,{ids:i.ids});return await b(a.ids,a.count),i.ids},[b]);return{documents:i,count:o,ready:c!==null,error:u,setCue:oe,resync:ae,rank:se,rankAndPin:ce}}function mt({data:e,className:t}){let[n,r]=(0,E.useState)(!0),{rows:i,gapIndex:a,span:c}=(0,E.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,D.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,D.jsxs)(`div`,{className:u(`rounded-md border border-border bg-muted/30 text-xs`,t),children:[(0,D.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,D.jsx)(s,{className:`h-3.5 w-3.5`}):(0,D.jsx)(o,{className:`h-3.5 w-3.5`}),`Query debug`,(0,D.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`: image distances for “`,e.query,`” (`,i.length,` nearest, unfloored)`]})]}),n&&(0,D.jsxs)(`div`,{className:`space-y-2 border-t border-border px-3 py-2`,children:[(0,D.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,D.jsxs)(D.Fragment,{children:[` `,(0,D.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,D.jsxs)(D.Fragment,{children:[` A jump at `,(0,D.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,D.jsx)(`div`,{className:`max-h-56 overflow-y-auto`,children:(0,D.jsx)(`table`,{className:`w-full font-mono text-[11px]`,children:(0,D.jsx)(`tbody`,{children:i.map((e,t)=>(0,D.jsxs)(`tr`,{className:u(`border-b border-border/40 last:border-0`,t===a&&`border-t-2 border-t-amber-500/70`),children:[(0,D.jsx)(`td`,{className:`py-0.5 pr-3 text-muted-foreground`,children:t+1}),(0,D.jsxs)(`td`,{className:`py-0.5 pr-3`,children:[`#`,e.id]}),(0,D.jsx)(`td`,{className:`py-0.5 tabular-nums`,children:e.distance.toFixed(4)}),t===a&&(0,D.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,D.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 ht(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 gt=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 gt.keys())e.startsWith(r)&>.delete(e)}function yt(e,t){let n=`${e}\0`;for(let[e,r]of gt){if(!e.startsWith(n))continue;let[,i,a,,,,,,o=`path`]=e.split(`\0`);ot(t,{tree:i,kind:S(i),path:a,wholeWorkspace:o.startsWith(`workspace`)},r.documents.map(e=>Number(e.id)))&>.delete(e)}}function bt(e,t){yt(t?.workspaceName??e,at(t))}function xt(){let{workspaceName:e}=r();return e?(0,D.jsx)(Ie,{workspaceName:e,children:(0,D.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),Ie=(()=>{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]:[]})(),[w,Je]=(0,E.useState)(null),[Ye,Xe]=(0,E.useState)(!0),[Ze,T]=(0,E.useState)([]),[$e,et]=(0,E.useState)(!1),[tt,O]=(0,E.useState)(0),k=qe(),[it,st]=(0,E.useState)(null),[ct,lt]=(0,E.useState)(k);ct!==k&&(lt(k),k||st(null));let[A,ut]=(0,E.useState)(`path`),[dt,ft]=(0,E.useState)(!1),[_t,xt]=(0,E.useState)(null),[M,St]=(0,E.useState)(null),[wt,Tt]=(0,E.useState)(``),[Et,Dt]=(0,E.useState)(!1),[Ot,kt]=(0,E.useState)(!1),[At,jt]=(0,E.useState)(!1),[N,Mt]=(0,E.useState)(null),[P,F]=(0,E.useState)(1),[I,Nt]=(0,E.useState)(50),[L,Pt]=(0,E.useState)(Ie),[Ft,It]=(0,E.useState)(null),{state:R,saveFilters:Lt,setSort:Rt,setAccentColor:zt,setMapDocuments:Bt}=Se(),Vt=R.filters.features.allOf,z=R.filters.features.anyOf,Ht=R.filters.features.noneOf,Ut=De(R.filters.timeline),Wt=Ee(R.filters.geo),Gt=ke(R.filters.lens,R.filters.geo.includeUnlocated),B=R.filters.lens.ids,Kt=[...Ut,...Wt,...Gt],qt=R.filters.sort??Oe,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=Ae(n.pathname).path,H=t??`context`,U=H===`backends`,[Xt,Zt]=(0,E.useState)([]);(0,E.useEffect)(()=>{!U||!e||ce(e).then(Zt).catch(()=>Zt([]))},[U,e]);let Qt=U?me(V,Xt):null,[$t,en]=(0,E.useState)(!1),tn=`${H}\0${V}`,[nn,rn]=(0,E.useState)(tn);nn!==tn&&(rn(tn),en(!1));let W=l.get(`layer`)===`1`,G=l.get(`layerId`)||null,[K,an]=(0,E.useState)(null),[q,on]=(0,E.useState)(null),sn=(0,E.useRef)(null);(0,E.useEffect)(()=>{sn.current=q},[q]);let[cn,ln]=(0,E.useState)(`left`),[un,dn]=(0,E.useState)([]),{openM1Drawer:fn,openM2Drawer:pn,goBack:mn}=Ne(),[hn,gn]=(0,E.useState)([]),J=(0,E.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,E.useRef)(null);(0,E.useEffect)(()=>{!e||!K||W||_n.current===`${e}/${H}`&&(V!==`/`&&!J||Pe(e,H,V))},[e,K,W,V,J,H]);let vn=(0,E.useMemo)(()=>W||A===`workspace`||L.length>0||S(H)!==`directory`?[]:ht(K,V),[K,V,H,W,A,L]),yn=W?null:V===`/`?K:J,X=be(),bn=`${H}\0${V}`,[xn,Sn]=(0,E.useState)(null),Cn=xn?.key===bn?xn.views:Ve(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??ze.id,Z=wn.find(e=>e.id===Tn)??wn[0]??ze;(0,E.useEffect)(()=>{X?.selectView(Z)},[Z,X]);let En=U?void 0:X?.schema??Re(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}),_(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}=_e(),In=w?.name,Q=(0,E.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,E.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=Ce(w?.color)||null;(0,E.useEffect)(()=>(zt(Hn),()=>zt(null)),[Hn,zt]);let Un=(0,E.useCallback)(async t=>{let n=B;if(t?.anyOf?.length&&z.length&&(n=((await x(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 x(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,E.useEffect)(()=>{e&&(async()=>{Xe(!0);try{let t=await p.get(`${f.workspaces}/${e}`),n;n=t&&`workspace`in t?t.workspace:t,Je(n)}catch(t){let n=t instanceof Error?t.message:`Failed to fetch workspace ${e}`;s({title:`Error`,description:n,variant:`destructive`}),Je(null)}finally{Xe(!1)}})()},[e,s]),(0,E.useEffect)(()=>{let e=e=>{let t=e.detail?.workspace;t&&Je(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}=pt({workspaceRef:e,specs:(0,E.useMemo)(()=>{let e={features:{allOf:Dn,anyOf:z,noneOf:Ht},filters:Kt};return A!==`workspace`&&(S(H)===`directory`?e.directory={tree:H,path:V}:e.context=V),[{label:`scope`,spec:e}]},[Yt,V,H,A,En]),opts:(0,E.useMemo)(()=>({mode:`live`,debounceMs:150}),[]),enabled:Wn}),Zn=Wn&&qn,Qn=(0,E.useRef)(!1);(0,E.useEffect)(()=>{Qn.current=Zn},[Zn]);let $n=L.length===1?L[0].trim():``;(0,E.useEffect)(()=>{qn&&Xn($n?{text:$n}:null,{limit:I,offset:(P-1)*I}).catch(()=>{})},[qn,$n,I,P,Xn]);let er=(B??[]).join(`,`);(0,E.useEffect)(()=>{qn&&Jn(`lens`,{ids:B??[]}).catch(()=>{})},[qn,er,Jn,B]);let tr=Zn?Gn:Ze,nr=Zn?Kn:tt,rr=(0,E.useRef)(new Set);(0,E.useEffect)(()=>{rr.current=new Set(tr.map(e=>Number(e.id)))},[tr]);let ir=R.geoSelection;(0,E.useEffect)(()=>{Bt(tr,w?.name??null)},[tr,w?.name,Bt]),(0,E.useEffect)(()=>()=>Bt([]),[Bt]);let ar=(0,E.useMemo)(()=>ir?tr.filter(e=>we(e,ir,R.filters.geo.includeUnlocated)):tr,[tr,ir,R.filters.geo.includeUnlocated]),or=le(V,Dn,{treeName:H,treeType:S(H),scope:A,queries:L,anyOf:z,noneOf:Ht,filters:Kt,ids:B,layerId:W&&G?G:void 0}),sr=JSON.stringify([e,or]),[cr,lr]=(0,E.useState)(``),[ur,dr]=(0,E.useState)(!1),fr=(0,E.useRef)(!1),pr=$e||ur||cr!==sr||Zn||!!ir,mr=(0,E.useRef)(0),hr=(0,E.useRef)(null);(0,E.useEffect)(()=>()=>{mr.current++,hr.current=null},[]);let gr=(0,E.useRef)(``),$=(0,E.useCallback)(async t=>{if(!e)return;if(Te(H,V)){mr.current++,hr.current=null,gr.current=``,T([]),O(0),et(!1);return}if(Qn.current)return;let n=`${$t&&Qt?`${A}:unfiled`:A}:${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${k}`;if(t?.silent&&hr.current?.key===c){hr.current.refreshPending=!0;return}let l=++mr.current,u=t?.silent||r||k?void 0:gt.get(o);u&&(T(u.documents),O(u.totalCount),lr(sr),et(!1)),(t?.silent??(a||!!u))||et(!0);let d={key:c,refreshPending:!1};hr.current=d;try{let t;t=$t&&Qt?await ge(e,Qt.driver,Qt.address,{linked:!1,limit:I,offset:(P-1)*I}):W&&G&&A!==`workspace`?await oe(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:A,debug:k&&L.length>0,debugLimit:200});let n=t.payload||[],i=t.totalCount||t.count||0;if(!r&&!d.refreshPending&>.set(o,{documents:n,totalCount:i}),l!==mr.current)return;let s=t.debug,c=s?.imageDistances??s?.distances??null;st(c?{query:L[L.length-1]??``,distances:c}:null),T(a?e=>e.length===n.length&&e.every((e,t)=>e.id===n[t].id)?e:n:n),O(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`}),T([]),O(0)}finally{hr.current===d&&(hr.current=null),l===mr.current&&et(!1),l===mr.current&&d.refreshPending&&$({silent:!0})}},[e,V,H,G,W,P,I,w?.status,L,Jt,A,$t,k,En]);(0,E.useEffect)(()=>{$()},[$]),(0,E.useEffect)(()=>{let t=t=>{let n=t.detail;!n||n.workspaceName!==e||(on({treeName:n.treeName||`context`,path:je(n.path||`/`)}),ln(`left`))};return window.addEventListener(`workspace:open-to-side`,t),()=>window.removeEventListener(`workspace:open-to-side`,t)},[e,H,V]),(0,E.useEffect)(()=>{let t=t=>{let n=t.detail;if(!(n?.workspaceName&&n.workspaceName!==e)&&(e&&bt(e,n),ot(at(n),{tree:H,kind:S(H),path:V,wholeWorkspace:A===`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,A,Yn]);let _r=w?.name,vr=w?.id;(0,E.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=()=>{te(e).then(e=>{a||(i=nt(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=rt(t,n,i);yt(e,r);let a={tree:H,kind:S(H),path:V,wholeWorkspace:A===`workspace`},f=sn.current;f&&ot(r,{tree:f.treeName,kind:S(f.treeName),path:f.path})&&(u=f),ot(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,A,$,Yn]);let yr=`${V}\0${H}\0${G??``}\0${A}`,[br,xr]=(0,E.useState)(yr);br!==yr&&(xr(yr),F(1),It(null));let Sr=`${V}\0${H}\0${G??``}`,[Cr,wr]=(0,E.useState)(Sr);Cr!==Sr&&(wr(Sr),ut(`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,E.useState)(!1);Dr!==Er&&(Or(Er),Er&&Tr(V,!1)),(0,E.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,E.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`),...Ie]),[jr,Mr]=(0,E.useState)(Ar);jr!==Ar&&(Mr(Ar),Pt(Ie),F(1));let Nr=`${Ar}\0${Y??``}\0${An}\0${V}\0${Ft??``}`,[Pr,Fr]=(0,E.useState)(Nr);Pr!==Nr&&(Fr(Nr),l.has(`q`)||Ie.length>0||Y!==`canvas`||Ft===V||(Pt(An?[An]:[]),F(1)));let Ir=(0,E.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,E.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,E.useEffect)(()=>{let t=!1;if(!e)return;let n=0,r=!1,i=(i=!1)=>{let a=++n;i&&fe(e,H),ee(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=C(e,vr);return()=>{t=!0,o(),window.removeEventListener(`workspace:tree:refresh`,a)}},[e,H,vr]),!(e&&Y===`canvas`&&!W)&&N!==null&&Mt(null),(0,E.useEffect)(()=>{let t=!1;if(!(!e||Y!==`canvas`||W))return ae(e,V,H).then(e=>{t||Mt(e)}).catch(()=>{t||Mt(null)}),()=>{t=!0}},[e,V,H,Y,W]);let Br=async()=>{if(w){ft(!0);try{let t=await ue(e||w.id);Je(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{ft(!1)}}},Vr=async t=>{if(!w)return;let n=c({title:`Removing…`,description:`Document from "${V}"`});try{await re(e||w.id,[t],V,[],H,Yr,{trashIfOrphaned:!0}),j(e||w.id,H,V),T(e=>e.filter(e=>e.id!==t)),O(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(!w)return;let n=c({title:`Deleting…`,description:`Document from "${V}"`});try{await ie(e||w.id,[t],V,[],H,Yr),j(e||w.id,H,V),T(e=>e.filter(e=>e.id!==t)),O(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(!w)return;let n=c({title:`Removing…`,description:`${t.length} document(s) from "${V}"`});try{await re(e||w.id,t,V,[],H,Yr,{trashIfOrphaned:!0}),j(e||w.id,H,V),T(e=>e.filter(e=>!t.includes(e.id))),O(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(!w)return;let n=c({title:`Deleting…`,description:`${t.length} document(s)`});try{await ie(e||w.id,t,V,[],H,Yr),j(e||w.id,H,V),T(e=>e.filter(e=>!t.includes(e.id))),O(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(!w)return;let n=c({title:`Destroying…`,description:`Document and its backend copies`});try{let r=await ne(e||w.id,[t]);if(r.failed?.length){n.fail({title:`Error`,description:r.failed[0].reason,variant:`destructive`});return}T(e=>e.filter(e=>e.id!==t)),O(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(!w)return;let n=c({title:`Destroying…`,description:`${t.length} document(s) and their backend copies`});try{let r=await ne(e||w.id,t),i=new Set(r.successful?.filter(e=>e.docDeleted).map(e=>e.id)??[]);T(e=>e.filter(e=>!i.has(e.id))),O(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=S(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 b(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=S(a);await re(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&&(xe(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(!w||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 y(e||w.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||w.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 se(e,r,H,M.captureView?{metadata:{toolbox:i},querySpec:{features:i.features,filters:[...De(R.filters.timeline),...Ee(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 ee(e,H,{force:!0});an(t)}catch{}window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),o(Me(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 he(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 g(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(Me(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,E.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=S(i.treeName),l=c({title:t?`Moving…`:`Copying…`,description:`${a.length} document(s) → "${i.path}"`});try{if(!await b(e,i.path,a,i.treeName,o)){l.done();return}if(j(e,i.treeName,i.path),t){let t=S(r.treeName);await re(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,E.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]),Ye)return(0,D.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,D.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,D.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading workspace...`})]})});if(!w)return(0,D.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,D.jsx)(He,{views:wn,activeId:Tn,onSelect:On,onSave:kn,accentColor:Ce(w.color),onOpenToSide:e=>{on({treeName:H,path:V,viewId:e}),ln(`right`)}}):void 0,si=Qt||w.status!==`active`?(0,D.jsxs)(D.Fragment,{children:[Qt&&(0,D.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`}),w.status!==`active`&&(0,D.jsx)(`button`,{type:`button`,onClick:Br,disabled:dt,className:`min-h-10 rounded-md border px-2 text-xs`,children:dt?`Starting…`:`Start`})]}):void 0,ci=Te(H,V)?V===`/Trash`?(0,D.jsx)(`div`,{className:`h-full overflow-auto p-4`,children:(0,D.jsx)(Ge,{workspaceName:e||w.id})}):(0,D.jsx)(Ke,{workspace:e||w.id,path:V,onNavigate:t=>o(Me(e,t,`backends`))},e):(0,D.jsx)(Ue,{navigationTabs:oi,navigationActions:si,onBack:mn,accentColor:Ce(w.color),urlType:W?S(H)===`directory`?`${H}-layer`:`context-layer`:Y===`canvas`?`canvas`:S(H)===`directory`?H:`context`,urlDisplay:Vn,contextPath:V,treeName:H,workspaceId:e||w.id,workspaceLabel:w.label||w.name,workspaceIcon:w.icon,documentSchema:En,documents:ar,isLoading:$e,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(Me(e,t,H)),folders:vn,onOpenFolder:t=>o(Me(e,je(t),H)),scope:A,onScopeChange:ut,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:k&&it?(0,D.jsx)(mt,{data:it,className:`mb-3`}):null,children:ai&&J?(0,D.jsx)(ve,{workspaceId:e||w.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,D.jsx)(Be,{documents:ar,workspaceId:e||w.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,D.jsx)(We,{app:Z.app,workspaceId:e||w.id,treeName:H,path:V}):null});return(0,D.jsxs)(Fe,{workspaceId:e||w.id,treeName:H,path:V,headerOnly:!0,className:`relative flex flex-col h-full min-h-0`,children:[(0,D.jsx)(Qe,{workspaceId:w.id,workspaceName:w.label||w.name},w.id),Te(H,V)&&(0,D.jsx)(ye,{workspace:w.label||w.name,workspaceIcon:w.icon,tree:H,path:V,onBack:mn,onBrowseTree:()=>pn(`workspaces`,`detail`,e||w.id),onBrowseWorkspaces:()=>fn(`workspaces`),onNavigatePath:t=>o(Me(e,t,H)),accentColor:Ce(w.color)}),M&&(0,D.jsx)(`div`,{className:`shrink-0 px-2 pt-2`,children:(0,D.jsx)(Le,{title:`New canvas`,onClose:()=>St(null),children:(0,D.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),ei()},className:`space-y-4`,children:[(0,D.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`label`,{htmlFor:`canvas-name`,className:`mb-1 block text-sm font-medium`,children:`Name`}),(0,D.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,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`mb-1 block text-sm font-medium`,children:`Parent path`}),(0,D.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,D.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,D.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:M.captureView,onChange:e=>St({...M,captureView:e.target.checked})}),(0,D.jsxs)(`span`,{children:[`Capture the current view`,(0,D.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Freezes the active filters, search and sort into the canvas.`})]})]}),(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(d,{type:`submit`,disabled:!wt.trim()||Et,children:Et?`Creating…`:`Create canvas`}),(0,D.jsx)(d,{type:`button`,variant:`outline`,onClick:()=>St(null),children:`Cancel`})]})]})})}),(0,D.jsxs)(`div`,{"data-canvas-panes":!0,className:`flex-1 min-h-0 flex gap-2`,children:[(0,D.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,D.jsx)(Ct,{workspaceName:e,workspaceLabel:w.label||w.name,workspaceIcon:w.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}=Ne(),{showToast:m,showProgress:g}=h(),[_,te]=(0,E.useState)(null),[v,y]=(0,E.useState)([]),[ae,oe]=(0,E.useState)(!1),[se,ce]=(0,E.useState)(0),[le,ue]=(0,E.useState)(1),[de,me]=(0,E.useState)(50),x=S(r.treeName),he=St(_,r.path),ge=he?.type===`canvas`,_e=(0,E.useMemo)(()=>x===`directory`?ht(_,r.path):[],[_,r.path,x]),ve=r.viewId?Ve(he?.metadata).find(e=>e.id===r.viewId)??null:null,ye=`${e}://${r.path===`/`?``:r.path.replace(/^\//,``)}`,be=Re(ve),C=(0,E.useCallback)(async()=>{if(Te(r.treeName,r.path)){y([]),ce(0),oe(!1);return}let t=vt(e,r.treeName,r.path,le,de,``,be??``),n=gt.get(t);if(n){y(n.documents),ce(n.totalCount);return}oe(!0);try{let n=await pe(e,r.path,be?[be]:[],{limit:de,page:le,treeName:r.treeName,treeType:x}),i=n.payload||[],a=n.totalCount||n.count||0;y(i),ce(a),gt.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([]),ce(0)}finally{oe(!1)}},[e,r.path,r.treeName,x,de,le,m,be]);(0,E.useEffect)(()=>{let t=!1,n=0,i=!1,a=(a=!1)=>{let o=++n;a&&fe(e,r.treeName),ee(e,r.treeName).then(e=>{!t&&o===n&&(i=!0,te(e))}).catch(()=>{!t&&o===n&&!i&&te(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,E.useEffect)(()=>{C()},[C]),(0,E.useEffect)(()=>{let t=t=>{let n=t.detail;n?.workspaceName&&n.workspaceName!==e||(bt(e,n),ot(at(n),{tree:r.treeName,kind:S(r.treeName),path:r.path})&&(j(e,r.treeName,r.path),C()))};return window.addEventListener(`workspace:documents:refresh`,t),()=>window.removeEventListener(`workspace:documents:refresh`,t)},[C,e,r.treeName,r.path]);let xe=(0,E.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 b(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=S(c);await re(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 C(),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,C,g,a,o]),Se=(0,E.useCallback)(()=>{j(e,r.treeName,r.path),C()},[e,r.treeName,r.path,C]),Ce=(0,E.useCallback)(async t=>{let n=g({title:`Removing…`,description:`${t.length} document(s) from "${r.path}"`});try{await re(e,t,r.path,[],r.treeName,x),Se(),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,Se,g]),we=(0,E.useCallback)(async t=>{let n=g({title:`Deleting…`,description:`${t.length} document(s)`});try{await ie(e,t,r.path,[],r.treeName,x),Se(),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,Se,g]),Ee=(0,E.useCallback)(async t=>{let n=g({title:`Destroying…`,description:`${t.length} document(s) and their backend copies`});try{let r=await ne(e,t);if(r.failed?.length&&!r.successful?.length){n.fail({title:`Error`,description:r.failed[0].reason,variant:`destructive`});return}Se();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,Se,g]);return(0,D.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,D.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`}),Te(r.treeName,r.path)?r.path===`/Trash`?(0,D.jsx)(`div`,{className:`h-full overflow-auto p-4`,children:(0,D.jsx)(Ge,{workspaceName:e})}):(0,D.jsx)(Ke,{workspace:e,path:r.path,onNavigate:l||(()=>{})}):(0,D.jsx)(Ue,{frameContent:!1,onBrowseWorkspaces:()=>f(`workspaces`),onBrowseTree:()=>p(`workspaces`,`detail`,e),urlType:ge?`canvas`:x===`directory`?r.treeName:`context`,urlDisplay:ye,contextPath:r.path,treeName:r.treeName,workspaceId:e,workspaceLabel:t,workspaceIcon:n,documentSchema:be,documents:v,isLoading:ae,totalCount:se,currentPage:le,pageSize:de,onPageChange:ue,onPageSizeChange:e=>{me(e),ue(1)},onRemoveDocument:r.path===`/`?void 0:e=>Ce([e]),onRemoveDocuments:r.path===`/`?void 0:Ce,onDeleteDocument:e=>we([e]),onDeleteDocuments:we,onDestroyDocument:e=>Ee([e]),onDestroyDocuments:Ee,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:xe,onSelectionChange:c,pastedDocumentIds:a?.documentIds,linkTree:_,folders:_e,onOpenFolder:l,onNavigatePath:l,canvasInfo:ge?{label:he?.label,description:he?.description,color:he?.color}:void 0,children:ve?.kind===`columns`?(0,D.jsx)(Be,{documents:v,workspaceId:e,columns:ve.columns??[],onColumnsChange:()=>{},readOnly:!0}):ve?.kind===`app`&&ve.app&&ve.app!==`notes`?(0,D.jsx)(We,{app:ve.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-
|
|
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 +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-
|
|
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};
|