/ releases / firefox-mv3 / chunks / workspace-dashboard-D-5QAwcO.js
workspace-dashboard-D-5QAwcO.js
 1  var Ti=Object.defineProperty;var Mi=(O,s,c)=>s in O?Ti(O,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):O[s]=c;var Ja=(O,s,c)=>Mi(O,typeof s!="symbol"?s+"":s,c);import{l as C,m as Ft,z as Kt,k as a,f as u,g as e,s as b,B as me,c as o,a as i,i as x,A as Zt,h as n,j as jt,u as ee,w as Me,D as Ct,t as L,n as E,e as is,d as oa,p as dt,v as Fe,C as vt,x as Oe,E as Ii,q as Fa,r as wa,o as Ps,$ as Ai,b as rs,y as Ei}from"./global-imVxZN8Y.js";import{p as qt,M as sa,I as os,B as Pe,e as wt,i as ea,s as Ia,h as Pi,a as zi,A as Li,C as bs,T as Ri,b as ys,g as xs,W as Wi,c as Xr}from"./ArchivedWorkspacesModal-DYdYQ66b.js";import{g as Qa,w as Wt,b as ra,T as Na,h as qa,a as Bi,P as Es,t as Cs}from"./workspace-sync-C-pBiGKB.js";const Qr="Mnemonic";function Zr(O,s={}){if(!O)return null;const{includeDate:c=!0,includeTime:p=!0,relative:d=!1}=s;try{const f=new Date(O);if(isNaN(f.getTime()))return console.warn("[formatUtcToLocal] Invalid timestamp:",O),null;if(d){const M=new Date().getTime()-f.getTime(),j=Math.floor(M/1e3),H=Math.floor(j/60),se=Math.floor(H/60),Y=Math.floor(se/24);if(j<60)return"just now";if(H<60)return`${H}m ago`;if(se<24)return`${se}h ago`;if(Y<7)return`${Y}d ago`}const g={};return c&&(g.year="numeric",g.month="short",g.day="numeric"),p&&(g.hour="2-digit",g.minute="2-digit"),f.toLocaleString(void 0,g)}catch(f){return console.error("[formatUtcToLocal] Failed to format timestamp:",f),null}}function Di(){var s,c,p;return typeof C<"u"&&((p=(c=(s=C.runtime)==null?void 0:s.getURL)==null?void 0:c.call(s,"/"))==null?void 0:p.includes("moz-extension"))?(navigator.userAgent.toLowerCase().includes("librewolf"),"LibreWolf"):"Chromium"}function Ni(O){return(O.split(`
 2  `)[0]||"").replace(/^#+\s*/,"").trim()||"Untitled"}function qi(O){return O.split(`
 3  `).slice(1).join(`
 4  `).trim()}function Ss(O,s){const c=O.properties||{};return{blockUuid:O.uuid,workspaceId:s,title:Ni(O.content),content:qi(O.content),rawContent:O.content,created:c.created||new Date().toISOString(),modified:c.modified}}function La(O){var s;for(const c of O){if((s=c.content)!=null&&s.toLowerCase().includes("## notes"))return c;if(c.children){const p=La(c.children);if(p)return p}}return null}function ns(O){var s;for(const c of O){if((s=c.content)!=null&&s.toLowerCase().includes("## attachments"))return c;if(c.children){const p=ns(c.children);if(p)return p}}return null}class Oi{constructor(){Ja(this,"client");this.client=Qa()}getConnectionState(){return this.client.getConnectionState()}async checkConnection(){return this.client.checkConnection()}getWorkspacePageName(s,c){const p=s.name.replace(/[/\\]/g,"-"),d=Di();if(s.type==="child"&&c){const f=c.replace(/[/\\]/g,"-");return`${Qr}/${d}/${f}/${p}`}return`${Qr}/${d}/${p}`}async initializeWorkspacePage(s,c){const p=this.getWorkspacePageName(s,c);console.log("[Logseq] Initializing workspace page:",p),await this.client.getOrCreatePage(p);const d=await this.client.getPageBlocksTree(p);if(!d.some(g=>{var w;return((w=g.properties)==null?void 0:w["workspace-id"])===s.id})&&d.length>0){const g=d[0];await this.client.setBlockProperties(g.uuid,{type:`workspace-${s.type}`,"workspace-id":s.id,created:new Date().toISOString()}),La(d)||await this.client.insertBlock(g.uuid,"## Notes",{sibling:!0})}else if(d.length===0){await this.client.appendBlockToPage(p,`# ${s.name}`);const g=await this.client.getPageBlocksTree(p);g[0]&&(await this.client.setBlockProperties(g[0].uuid,{type:`workspace-${s.type}`,"workspace-id":s.id,created:new Date().toISOString()}),await this.client.insertBlock(g[0].uuid,"## Notes",{sibling:!0}))}return p}async getWorkspaceNotes(s,c){if(!this.client.getConnectionState().available)return console.warn("[Logseq] Not connected, cannot get notes"),[];const d=this.getWorkspacePageName(s,c);try{const f=await this.client.getPageBlocksTree(d),g=La(f);return!g||!g.children?[]:g.children.map(w=>Ss(w,s.id))}catch(f){return console.error("[Logseq] Failed to get workspace notes:",f),[]}}async getNote(s,c){if(!this.client.getConnectionState().available)return null;try{const d=await this.client.getBlock(s);return d?Ss(d,c):null}catch(d){return console.error("[Logseq] Failed to get note:",d),null}}async createNote(s,c,p,d){if(!this.client.getConnectionState().available)throw new Error("Logseq is not connected");const g=this.getWorkspacePageName(s,d);try{await this.initializeWorkspacePage(s,d);const w=await this.client.getPageBlocksTree(g);let M=La(w);if(!M){const se=w[0];if(se&&(M=await this.client.insertBlock(se.uuid,"## Notes",{sibling:!0})),!M)throw new Error("Could not find or create Notes section")}const j=`### ${c}
 5  ${p}`,H=await this.client.insertBlock(M.uuid,j,{properties:{created:new Date().toISOString()}});if(!H)throw new Error("Failed to create note block");return console.log("[Logseq] Created note:",c),Ss(H,s.id)}catch(w){throw console.error("[Logseq] Failed to create note:",w),w}}async updateNote(s,c,p){if(!this.client.getConnectionState().available)throw new Error("Logseq is not connected");try{const f=`### ${c}
 6  ${p}`;await this.client.updateBlock(s,f),await this.client.setBlockProperties(s,{modified:new Date().toISOString()}),console.log("[Logseq] Updated note:",c)}catch(f){throw console.error("[Logseq] Failed to update note:",f),f}}async deleteNote(s){if(!this.client.getConnectionState().available)throw new Error("Logseq is not connected");try{await this.client.deleteBlock(s),console.log("[Logseq] Deleted note:",s)}catch(p){throw console.error("[Logseq] Failed to delete note:",p),p}}async getWorkspaceNoteContent(s,c){return(await this.getWorkspaceNoteWithMetadata(s,c)).content}async getWorkspaceNoteWithMetadata(s,c){var f;if(!this.client.getConnectionState().available)return{content:"",modifiedUtc:null};const d=this.getWorkspacePageName(s,c);try{if(!await this.client.getOrCreatePage(d))return{content:"",modifiedUtc:null};const w=await this.client.getPageBlocksTree(d),M=La(w);if(!M)return{content:"",modifiedUtc:null};const j=((f=M.properties)==null?void 0:f["notes-modified"])||null;if(!M.children||M.children.length===0)return{content:"",modifiedUtc:j};const H=(se,Y=0)=>se.map(re=>{let P="  ".repeat(Y)+re.content;return re.children&&re.children.length>0&&(P+=`
 7  `+H(re.children,Y+1)),P}).join(`
 8  `);return{content:H(M.children),modifiedUtc:j}}catch(g){return console.error("[Logseq] Failed to get workspace note content:",g),{content:"",modifiedUtc:null}}}async setWorkspaceNoteContent(s,c,p){if(!this.client.getConnectionState().available)throw new Error("Logseq is not connected");const f=this.getWorkspacePageName(s,p);try{await this.initializeWorkspacePage(s,p);const g=await this.client.getPageBlocksTree(f);let w=La(g);if(!w){const M=g[0];if(M&&(w=await this.client.insertBlock(M.uuid,"## Notes",{sibling:!0})),!w)throw new Error("Could not create Notes section")}if(w.children)for(const M of w.children)await this.client.deleteBlock(M.uuid);c.trim()&&await this.client.insertBlock(w.uuid,c),await this.client.setBlockProperties(w.uuid,{"notes-modified":new Date().toISOString()}),console.log("[Logseq] Updated workspace note content")}catch(g){throw console.error("[Logseq] Failed to set workspace note content:",g),g}}async addAttachmentReference(s,c,p,d){if(!this.client.getConnectionState().available)throw new Error("Logseq is not connected");const g=this.getWorkspacePageName(s,d);try{await this.initializeWorkspacePage(s,d);const w=await this.client.getPageBlocksTree(g);let M=ns(w);if(!M){const Y=La(w)||w[w.length-1];if(Y&&(M=await this.client.insertBlock(Y.uuid,"## Attachments",{sibling:!0})),!M)throw new Error("Could not create Attachments section")}const j=`../${p}`,H=`[${c}](${j})`;if(M.children&&M.children.find(Y=>Y.content.includes(p))){console.log("[Logseq] Attachment reference already exists:",c);return}await this.client.insertBlock(M.uuid,H),console.log("[Logseq] Added attachment reference:",c)}catch(w){throw console.error("[Logseq] Failed to add attachment reference:",w),w}}async removeAttachmentReference(s,c,p){if(!this.client.getConnectionState().available)throw new Error("Logseq is not connected");const f=this.getWorkspacePageName(s,p);try{const g=await this.client.getPageBlocksTree(f),w=ns(g);if(!w||!w.children)return console.log("[Logseq] No attachments section found"),!1;const M=w.children.find(j=>j.content.includes(c));return M?(await this.client.deleteBlock(M.uuid),console.log("[Logseq] Removed attachment reference:",c),!0):(console.log("[Logseq] Attachment reference not found:",c),!1)}catch(g){throw console.error("[Logseq] Failed to remove attachment reference:",g),g}}async getAttachmentReferences(s,c){if(!this.client.getConnectionState().available)return[];const d=this.getWorkspacePageName(s,c);try{const f=await this.client.getPageBlocksTree(d),g=ns(f);if(!g||!g.children)return[];const w=[];for(const M of g.children){const j=M.content.match(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/);j&&w.push({fileName:j[1],assetPath:j[2],blockUuid:M.uuid})}return w}catch(f){return console.error("[Logseq] Failed to get attachment references:",f),[]}}}let Ts=null;function Fi(){return Ts||(Ts=new Oi),Ts}function eo(){return{tasks:new Map,loading:!1,error:null,filter:{showCompleted:!1},lastUpdated:null}}class ji{constructor(){Ja(this,"state",eo());Ja(this,"listeners",new Set)}subscribe(s){return this.listeners.add(s),()=>this.listeners.delete(s)}notify(){this.listeners.forEach(s=>s())}getState(){return this.state}getTasks(){return this.state.tasks}isLoading(){return this.state.loading}getError(){return this.state.error}getFilter(){return this.state.filter}async enrichTask(s){const c=s.projectId,p=await Wt.getWorkspaceId(c),f=(await Wt.getAllMappings()).find(g=>g.todoistProjectId===c);return!p||!f?null:{...s,workspaceId:p,workspaceName:f.workspaceName}}async loadWorkspaceTasks(s){const c=await Wt.getProjectId(s);if(!c){this.state.error="Workspace not synced to Todoist",this.notify();return}this.state.loading=!0,this.state.error=null,this.notify();try{const p=await ra.getProjectTasks(c),d=[];for(const g of p){const w=await this.enrichTask(g);w&&d.push(w)}const f=new Map(this.state.tasks);for(const[g,w]of f)w.workspaceId===s&&f.delete(g);for(const g of d)f.set(g.id,g);this.state.tasks=f,this.state.lastUpdated=new Date().toISOString()}catch(p){const d=p instanceof Na?p:qa(p);this.state.error=d.getUserMessage()}finally{this.state.loading=!1,this.notify()}}async loadAllTasks(){this.state.loading=!0,this.state.error=null,this.notify();try{const s=await ra.getAllWorkspaceTasks(),c=[];for(const p of s){const d=await this.enrichTask(p);d&&c.push(d)}this.state.tasks=new Map(c.map(p=>[p.id,p])),this.state.lastUpdated=new Date().toISOString()}catch(s){const c=s instanceof Na?s:qa(s);this.state.error=c.getUserMessage()}finally{this.state.loading=!1,this.notify()}}async createTask(s,c){const p=await Wt.getProjectId(s);if(!p)return this.state.error="Workspace not synced to Todoist. Click sync to create the project.",this.notify(),null;try{const d=await ra.createTask(p,c),f=await this.enrichTask(d);if(f){const g=new Map(this.state.tasks);g.set(f.id,f),this.state.tasks=g,this.notify()}return f}catch(d){const f=d instanceof Na?d:qa(d);return f.code==="NOT_FOUND"?(await Wt.removeMapping(s,!1),this.state.error="Project not found in Todoist. Click sync to recreate."):this.state.error=f.getUserMessage(),this.notify(),null}}async updateTask(s){try{const c=await ra.updateTask(s),p=await this.enrichTask(c);if(p){const d=new Map(this.state.tasks);d.set(p.id,p),this.state.tasks=d,this.notify()}return p}catch(c){const p=c instanceof Na?c:qa(c);return this.state.error=p.getUserMessage(),this.notify(),null}}async toggleComplete(s){const c=this.state.tasks.get(s);if(!c)return!1;try{c.isCompleted?await ra.reopenTask(s):await ra.completeTask(s);const p=new Map(this.state.tasks),d=p.get(s);return d&&(p.set(s,{...d,isCompleted:!d.isCompleted}),this.state.tasks=p,this.notify()),!0}catch(p){const d=p instanceof Na?p:qa(p);return this.state.error=d.getUserMessage(),this.notify(),!1}}async deleteTask(s){try{await ra.deleteTask(s);const c=new Map(this.state.tasks);return c.delete(s),this.state.tasks=c,this.notify(),!0}catch(c){const p=c instanceof Na?c:qa(c);return this.state.error=p.getUserMessage(),this.notify(),!1}}setFilter(s){this.state.filter={...this.state.filter,...s},this.notify()}toggleShowCompleted(){this.state.filter.showCompleted=!this.state.filter.showCompleted,this.notify()}clearError(){this.state.error=null,this.notify()}clear(){this.state=eo(),this.notify()}getWorkspaceTasks(s){var f,g;const{tasks:c,filter:p}=this.state,d=[];for(const w of c.values())w.workspaceId===s&&(!p.showCompleted&&w.isCompleted||p.priority&&w.priority!==p.priority||p.dueBefore&&((f=w.due)!=null&&f.date)&&w.due.date>p.dueBefore||p.dueAfter&&((g=w.due)!=null&&g.date)&&w.due.date<p.dueAfter||p.labels&&p.labels.length>0&&(!w.labels||!p.labels.some(M=>w.labels.includes(M)))||d.push(w));return d.sort((w,M)=>{var j,H,se,Y;return w.isCompleted!==M.isCompleted?w.isCompleted?1:-1:((j=w.due)==null?void 0:j.date)!==((H=M.due)==null?void 0:H.date)?(se=w.due)!=null&&se.date?(Y=M.due)!=null&&Y.date?w.due.date.localeCompare(M.due.date):-1:1:(M.priority||1)-(w.priority||1)})}getWorkspaceTaskCounts(s){const c=Array.from(this.state.tasks.values()).filter(f=>f.workspaceId===s),p=new Date().toISOString().split("T")[0],d=c.filter(f=>{var g;return!f.isCompleted&&((g=f.due)==null?void 0:g.date)&&f.due.date<p});return{total:c.length,active:c.filter(f=>!f.isCompleted).length,completed:c.filter(f=>f.isCompleted).length,overdue:d.length}}}const ka=new ji;function Ui(O,s){return`logseq://graph/${encodeURIComponent(O)}?page=${encodeURIComponent(s)}`}function Xa(O,s,c,p){return{id:crypto.randomUUID(),type:O,title:s,value:c,createdAt:new Date().toISOString(),favIconUrl:p}}function Ms(O,s,c){return{id:crypto.randomUUID(),type:"attachment",title:O,value:s,createdAt:new Date().toISOString(),attachment:c}}function ao(O){try{const s=new URL(O);return s.protocol==="http:"||s.protocol==="https:"}catch{return!1}}function Hi(O){const s=O.match(/^#\s+(.+)$/m);if(s)return s[1].trim();const c=O.split(`
 9  `).find(p=>p.trim());return c&&c.length<=100?c.trim():null}var Vi=u("<!> <!>",1),$i=u("<option> </option>"),Gi=u('<p class="mt-1 text-xs text-status-warning">No parent workspaces available. Create a parent first.</p>'),Ki=u('<div><label class="block text-sm font-mono text-text-secondary mb-1.5">Parent Workspace</label> <select class="w-full bg-mnemonic-bg-dark border border-phosphor-dark/50 rounded px-3 py-2 text-text-primary font-mono text-sm focus:outline-none focus:border-phosphor focus:ring-1 focus:ring-phosphor"></select> <!></div>'),Yi=u('<p class="text-sm text-status-error"> </p>'),Ji=u('<form class="space-y-4"><!> <!> <!></form>');function Xi(O,s){Ft(s,!0);let c=qt(s,"open",15),p=qt(s,"type",3,"standalone"),d=qt(s,"parentWorkspaces",19,()=>[]),f=b(""),g=b(""),w=b(""),M=b(!1);const j="parent-workspace-select";Kt(()=>{var re;c()&&(a(f,""),a(g,s.selectedParentId||(((re=d()[0])==null?void 0:re.id)??""),!0),a(w,""),a(M,!1))});const H=me(()=>p()==="parent"?"Create Parent Workspace":p()==="child"?"Create Child Workspace":"Create Standalone Workspace");async function se(){var re;if(!e(f).trim()){a(w,"Name is required");return}if(p()==="child"&&!e(g)){a(w,"Please select a parent workspace");return}a(M,!0),a(w,"");try{(re=s.oncreate)==null||re.call(s,{name:e(f).trim(),type:p(),parentId:p()==="child"?e(g):void 0}),c(!1)}catch(Z){a(w,Z instanceof Error?Z.message:"Failed to create workspace",!0)}finally{a(M,!1)}}function Y(){var re;c(!1),(re=s.onclose)==null||re.call(s)}sa(O,{get title(){return e(H)},onclose:Y,get open(){return c()},set open(Z){c(Z)},footer:Z=>{var P=Vi(),q=ee(P);Pe(q,{variant:"ghost",onclick:Y,children:(G,de)=>{var ce=Me("Cancel");n(G,ce)},$$slots:{default:!0}});var te=i(q,2);{let G=me(()=>!e(f).trim()||p()==="child"&&!e(g));Pe(te,{variant:"primary",get loading(){return e(M)},get disabled(){return e(G)},onclick:se,children:(de,ce)=>{var F=Me("Create");n(de,F)},$$slots:{default:!0}})}n(Z,P)},children:(Z,P)=>{var q=Ji(),te=o(q);{let W=me(()=>e(w)&&!e(f).trim()?e(w):void 0);os(te,{label:"Workspace Name",placeholder:"Enter workspace name",get error(){return e(W)},get value(){return e(f)},set value(R){a(f,R,!0)}})}var G=i(te,2);{var de=W=>{var R=Ki(),U=o(R);Ct(U,"for",j);var ie=i(U,2);Ct(ie,"id",j),wt(ie,21,d,A=>A.id,(A,S)=>{var $=$i(),D=o($),K={};L(()=>{E(D,e(S).name),K!==(K=e(S).id)&&($.value=($.__value=e(S).id)??"")}),n(A,$)});var B=i(ie,2);{var V=A=>{var S=Gi();n(A,S)};x(B,A=>{d().length===0&&A(V)})}is(ie,()=>e(g),A=>a(g,A)),n(W,R)};x(G,W=>{p()==="child"&&W(de)})}var ce=i(G,2);{var F=W=>{var R=Yi(),U=o(R);L(()=>E(U,e(w))),n(W,R)};x(ce,W=>{e(w)&&e(f).trim()&&W(F)})}Zt("submit",q,W=>{W.preventDefault(),se()}),n(Z,q)},$$slots:{footer:!0,default:!0}}),jt()}var Qi=vt('<svg class="w-4 h-4 mr-2 animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> Importing...',1),Zi=u("<!> <!>",1),el=u('<div class="flex items-center justify-center py-8"><div class="flex items-center gap-3 text-text-muted"><svg class="w-5 h-5 animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span>Loading bookmark folders...</span></div></div>'),tl=u('<div class="bg-status-error/10 border border-status-error/30 rounded-lg p-4 text-sm text-status-error"> </div>'),al=u('<div class="text-center py-8 text-text-muted"><svg class="w-12 h-12 mx-auto mb-4 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"></path></svg> <p class="mb-2">No Mnemonic bookmarks found</p> <p class="text-xs">Export a workspace to bookmarks first, then import it here.</p></div>'),sl=u('<span class="text-phosphor-dark">|</span> <span> </span>',1),rl=u('<button><svg class="w-5 h-5 text-phosphor flex-shrink-0" fill="currentColor" viewBox="0 0 20 20"><path d="M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"></path></svg> <div class="flex-1 min-w-0"><div class="font-medium truncate"> </div> <div class="text-xs text-text-muted flex items-center gap-2"><span> </span> <!></div></div> <span> </span></button>'),ol=u('<div class="flex items-center gap-2 ml-6"><svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg> <span> </span> <span class="text-text-muted"> </span></div>'),nl=u('<div class="flex items-center gap-2"><svg class="w-4 h-4 text-phosphor" fill="currentColor" viewBox="0 0 20 20"><path d="M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"></path></svg> <span class="font-medium"> </span> <span class="text-text-muted">(Parent)</span></div> <!>',1),il=u('<div class="flex items-center gap-2"><svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM4.332 8.027a6.012 6.012 0 011.912-2.706C6.512 5.73 6.974 6 7.5 6A1.5 1.5 0 019 7.5V8a2 2 0 004 0 2 2 0 011.523-1.943A5.977 5.977 0 0116 10c0 .34-.028.675-.083 1H15a2 2 0 00-2 2v2.197A5.973 5.973 0 0110 16v-2a2 2 0 00-2-2 2 2 0 01-2-2 2 2 0 00-1.668-1.973z" clip-rule="evenodd"></path></svg> <span class="font-medium"> </span> <span> </span></div>'),ll=u("<option> </option>"),cl=u('<div class="space-y-2"><label class="text-sm font-medium flex items-center gap-2"><span>Add to existing context</span> <span class="text-xs text-text-muted">(optional)</span></label> <select class="w-full px-3 py-2 rounded bg-mnemonic-bg border border-phosphor-dark/30 text-sm focus:border-phosphor focus:outline-none"><option>Create as standalone</option><!></select></div>'),dl=u('<div class="border-t border-phosphor-dark/20 pt-4 space-y-4"><div class="bg-mnemonic-bg-dark/50 rounded-lg p-3"><div class="text-sm font-medium mb-2">Structure Preview</div> <div class="text-xs text-text-muted space-y-1"><!></div></div> <div class="space-y-2"><label class="text-sm font-medium">Import as:</label> <div class="grid grid-cols-3 gap-2"><button><div class="font-medium">Auto</div> <div class="text-xs text-text-muted"> </div></button> <button><div class="font-medium">Standalone</div> <div class="text-xs text-text-muted">Single workspace</div></button> <button><div class="font-medium">Context</div> <div class="text-xs text-text-muted">Parent + children</div></button></div></div> <!></div>'),vl=u('<div class="space-y-2"><p class="text-sm text-text-muted">Select a folder from your Mnemonic bookmarks:</p> <div class="max-h-48 overflow-y-auto border border-phosphor-dark/20 rounded-lg divide-y divide-phosphor-dark/10"></div></div> <!>',1),ul=u('<div class="space-y-4"><!></div>');function pl(O,s){Ft(s,!0);let c=qt(s,"open",15),p=b(!1),d=b(null),f=b(dt([])),g=b(null),w=b("auto"),M=b(""),j=b(!1);Kt(()=>{c()?H():(a(d,null),a(g,null),a(w,"auto"),a(M,""))});async function H(){a(p,!0),a(d,null);try{const P=await C.runtime.sendMessage({type:"GET_BOOKMARK_FOLDERS"});P.success?a(f,P.folders,!0):a(d,P.error||"Failed to load bookmark folders",!0)}catch(P){a(d,P instanceof Error?P.message:"Failed to load bookmarks",!0)}finally{a(p,!1)}}function se(P){a(g,P,!0),a(w,"auto"),a(M,"")}function Y(){var P;return e(w)==="auto"?((P=e(g))==null?void 0:P.recommendedMode)==="context"?"context":"standalone":e(w)}async function re(){if(e(g)){a(j,!0),a(d,null);try{const P=JSON.parse(JSON.stringify(e(g))),q=await C.runtime.sendMessage({type:"IMPORT_FROM_BOOKMARKS",payload:{folderId:e(g).id,folderData:P,mode:e(w),parentId:e(M)||void 0}});q.success?(s.onImported(),s.onclose()):a(d,q.error||"Failed to import bookmarks",!0)}catch(P){a(d,P instanceof Error?P.message:"Failed to import bookmarks",!0)}finally{a(j,!1)}}}function Z(P){return`${P} bookmark${P!==1?"s":""}`}sa(O,{title:"Import from Bookmarks",size:"lg",get open(){return c()},set open(q){c(q)},footer:q=>{var te=Zi(),G=ee(te);Pe(G,{variant:"ghost",get onclick(){return s.onclose},get disabled(){return e(j)},children:(ce,F)=>{var W=Me("Cancel");n(ce,W)},$$slots:{default:!0}});var de=i(G,2);{let ce=me(()=>!e(g)||e(j)||e(p));Pe(de,{variant:"primary",onclick:re,get disabled(){return e(ce)},children:(F,W)=>{var R=Fe(),U=ee(R);{var ie=V=>{var A=Qi();n(V,A)},B=V=>{var A=Me("Import");n(V,A)};x(U,V=>{e(j)?V(ie):V(B,!1)})}n(F,R)},$$slots:{default:!0}})}n(q,te)},children:(q,te)=>{var G=ul(),de=o(G);{var ce=W=>{var R=el();n(W,R)},F=W=>{var R=Fe(),U=ee(R);{var ie=V=>{var A=tl(),S=o(A);L(()=>E(S,e(d))),n(V,A)},B=V=>{var A=Fe(),S=ee(A);{var $=K=>{var X=al();n(K,X)},D=K=>{var X=vl(),ve=ee(X),We=i(o(ve),2);wt(We,21,()=>e(f),N=>N.id,(N,Q)=>{var he=rl();he.__click=()=>se(e(Q));var we=i(o(he),2),ke=o(we),Ee=o(ke),be=i(ke,2),De=o(be),xe=o(De),Ce=i(De,2);{var Ne=fe=>{var pe=sl(),je=i(ee(pe),2),Ie=o(je);L(()=>E(Ie,`${e(Q).structure.subfolderCount??""} subfolder${e(Q).structure.subfolderCount!==1?"s":""}`)),n(fe,pe)};x(Ce,fe=>{e(Q).structure.subfolderCount>0&&fe(Ne)})}var ue=i(we,2),ze=o(ue);L(fe=>{var pe;Oe(he,1,`w-full p-3 text-left hover:bg-phosphor/10 transition-colors flex items-center gap-3 ${((pe=e(g))==null?void 0:pe.id)===e(Q).id?"bg-phosphor/20":""}`),E(Ee,e(Q).title),E(xe,fe),Oe(ue,1,`px-2 py-0.5 text-xs rounded-full ${e(Q).structure.type==="nested"?"bg-phosphor/20 text-phosphor":"bg-surface-raised text-text-muted"}`),E(ze,e(Q).structure.type==="nested"?"Context":"Flat")},[()=>Z(e(Q).structure.bookmarkCount)]),n(N,he)});var oe=i(ve,2);{var _=N=>{var Q=dl(),he=o(Q),we=i(o(he),2),ke=o(we);{var Ee=Ie=>{var _e=nl(),Ae=ee(_e),He=i(o(Ae),2),Ue=o(He),Xe=i(Ae,2);wt(Xe,17,()=>e(g).structure.subfolders,ea,(_t,ne)=>{var ge=ol(),Le=i(o(ge),2),ut=o(Le),Ve=i(Le,2),qe=o(Ve);L(()=>{E(ut,e(ne).name),E(qe,`(${e(ne).bookmarkCount??""} tabs)`)}),n(_t,ge)}),L(()=>E(Ue,e(g).title)),n(Ie,_e)},be=Ie=>{var _e=il(),Ae=i(o(_e),2),He=o(Ae),Ue=i(Ae,2),Xe=o(Ue);L(()=>{E(He,e(g).title),E(Xe,`(${e(g).structure.bookmarkCount??""} tabs)`)}),n(Ie,_e)};x(ke,Ie=>{e(g).structure.type==="nested"?Ie(Ee):Ie(be,!1)})}var De=i(he,2),xe=i(o(De),2),Ce=o(xe);Ce.__click=()=>a(w,"auto");var Ne=i(o(Ce),2),ue=o(Ne),ze=i(Ce,2);ze.__click=()=>a(w,"standalone");var fe=i(ze,2);fe.__click=()=>a(w,"context");var pe=i(De,2);{var je=Ie=>{var _e=cl(),Ae=i(o(_e),2),He=o(Ae);He.value=He.__value="";var Ue=i(He);wt(Ue,17,()=>s.parentWorkspaces,Xe=>Xe.id,(Xe,_t)=>{var ne=ll(),ge=o(ne),Le={};L(()=>{E(ge,`Add to "${e(_t).name??""}"`),Le!==(Le=e(_t).id)&&(ne.value=(ne.__value=e(_t).id)??"")}),n(Xe,ne)}),is(Ae,()=>e(M),Xe=>a(M,Xe)),n(Ie,_e)};x(pe,Ie=>{Y()==="standalone"&&s.parentWorkspaces.length>0&&Ie(je)})}L(()=>{Oe(Ce,1,`p-2 rounded border text-sm transition-colors text-center ${e(w)==="auto"?"border-phosphor bg-phosphor/10":"border-phosphor-dark/30"}`),E(ue,e(g).recommendedMode==="context"?"Context":"Standalone"),Oe(ze,1,`p-2 rounded border text-sm transition-colors text-center ${e(w)==="standalone"?"border-phosphor bg-phosphor/10":"border-phosphor-dark/30"}`),Oe(fe,1,`p-2 rounded border text-sm transition-colors text-center ${e(w)==="context"?"border-phosphor bg-phosphor/10":"border-phosphor-dark/30"}`)}),n(N,Q)};x(oe,N=>{e(g)&&N(_)})}n(K,X)};x(S,K=>{e(f).length===0?K($):K(D,!1)},!0)}n(V,A)};x(U,V=>{e(d)?V(ie):V(B,!1)},!0)}n(W,R)};x(de,W=>{e(p)?W(ce):W(F,!1)})}n(q,G)},$$slots:{footer:!0,default:!0}}),jt()}oa(["click"]);var hl=u('<div class="search-spinner svelte-uxd1ku"></div>'),fl=u('<button class="search-clear svelte-uxd1ku" type="button" title="Clear search"><svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg></button>'),gl=u('<div class="no-results svelte-uxd1ku"><p> </p> <p class="hint svelte-uxd1ku">Try different keywords or check spelling</p></div>'),ml=vt('<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path d="M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"></path></svg>'),kl=vt('<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z" clip-rule="evenodd"></path></svg>'),wl=vt('<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM4.332 8.027a6.012 6.012 0 011.912-2.706C6.512 5.73 6.974 6 7.5 6A1.5 1.5 0 019 7.5V8a2 2 0 004 0 2 2 0 011.523-1.943A5.977 5.977 0 0116 10c0 .34-.028.675-.083 1H15a2 2 0 00-2 2v2.197A5.973 5.973 0 0110 16v-2a2 2 0 00-2-2 2 2 0 01-2-2 2 2 0 00-1.668-1.973z" clip-rule="evenodd"></path></svg>'),_l=u('<span class="result-item-type-badge is-tab svelte-uxd1ku">Tab</span>'),bl=u('<span class="result-item-type-badge is-resource svelte-uxd1ku">Resource</span>'),yl=u('<span class="result-domain svelte-uxd1ku"> </span>'),xl=u('<span class="result-workspace"> </span>'),Cl=u('<span class="result-workspace"> </span>'),Sl=u('<span class="result-workspace"> </span>'),Tl=u('<span class="result-type-badge svelte-uxd1ku"> </span>'),Ml=u('<li><button type="button"><span><!></span> <div class="result-content svelte-uxd1ku"><span class="result-title svelte-uxd1ku"> </span> <span class="result-meta svelte-uxd1ku"><!> <!> <!></span></div> <span class="result-score svelte-uxd1ku" title="Relevance score"> </span></button></li>'),Il=u('<div class="results-header svelte-uxd1ku"><span class="results-count"> </span> <span class="results-time"> </span></div> <ul class="results-list svelte-uxd1ku"></ul>',1),Al=u('<div class="search-results svelte-uxd1ku"><!></div>'),El=u('<div class="search-container svelte-uxd1ku"><div class="search-input-wrapper svelte-uxd1ku"><svg class="search-icon svelte-uxd1ku" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg> <input type="text" class="search-input svelte-uxd1ku"/> <!></div> <!></div>');function Pl(O,s){Ft(s,!0);let c=qt(s,"placeholder",3,"Search workspaces and tabs..."),p=qt(s,"results",3,null),d=qt(s,"loading",3,!1),f=b(""),g=b(!1),w=b(-1);const M=me(()=>p()&&p().results.length>0);function j(R){var ie;const U=R.target;a(f,U.value,!0),a(w,-1),e(f).length>=2?((ie=s.onSearch)==null||ie.call(s,e(f)),a(g,!0)):a(g,!1)}function H(R){var U,ie;if(e(M))if(R.key==="ArrowDown")R.preventDefault(),a(w,Math.min(e(w)+1,(((U=p())==null?void 0:U.results.length)||0)-1),!0);else if(R.key==="ArrowUp")R.preventDefault(),a(w,Math.max(e(w)-1,-1),!0);else if(R.key==="Enter"&&e(w)>=0){R.preventDefault();const B=(ie=p())==null?void 0:ie.results[e(w)];B&&se(B.document)}else R.key==="Escape"&&(a(g,!1),a(w,-1))}function se(R){var U;(U=s.onResultSelect)==null||U.call(s,R),a(g,!1),a(f,""),a(w,-1)}function Y(){setTimeout(()=>{a(g,!1)},200)}function re(){e(f).length>=2&&e(M)&&a(g,!0)}function Z(){a(f,""),a(g,!1),a(w,-1)}var P=El(),q=o(P),te=i(o(q),2);te.__input=j,te.__keydown=H;var G=i(te,2);{var de=R=>{var U=hl();n(R,U)},ce=R=>{var U=Fe(),ie=ee(U);{var B=V=>{var A=fl();A.__click=Z,n(V,A)};x(ie,V=>{e(f)&&V(B)},!0)}n(R,U)};x(G,R=>{d()?R(de):R(ce,!1)})}var F=i(q,2);{var W=R=>{var U=Al(),ie=o(U);{var B=A=>{var S=gl(),$=o(S),D=o($);L(()=>E(D,`No results found for "${e(f)??""}"`)),n(A,S)},V=A=>{var S=Il(),$=ee(S),D=o($),K=o(D),X=i(D,2),ve=o(X),We=i($,2);wt(We,23,()=>p().results,oe=>oe.document.id,(oe,_,N)=>{var Q=Ml(),he=o(Q);let we;he.__click=()=>se(e(_).document);var ke=o(he);let Ee;var be=o(ke);{var De=ne=>{var ge=ml();n(ne,ge)},xe=ne=>{var ge=Fe(),Le=ee(ge);{var ut=qe=>{var Re=kl();n(qe,Re)},Ve=qe=>{var Re=wl();n(qe,Re)};x(Le,qe=>{e(_).document.type==="resource"?qe(ut):qe(Ve,!1)},!0)}n(ne,ge)};x(be,ne=>{e(_).document.type==="workspace"?ne(De):ne(xe,!1)})}var Ce=i(ke,2),Ne=o(Ce),ue=o(Ne),ze=i(Ne,2),fe=o(ze);{var pe=ne=>{var ge=_l();n(ne,ge)},je=ne=>{var ge=Fe(),Le=ee(ge);{var ut=Ve=>{var qe=bl();n(Ve,qe)};x(Le,Ve=>{e(_).document.type==="resource"&&Ve(ut)},!0)}n(ne,ge)};x(fe,ne=>{e(_).document.type==="tab"?ne(pe):ne(je,!1)})}var Ie=i(fe,2);{var _e=ne=>{var ge=Fe(),Le=ee(ge);{var ut=Ve=>{var qe=yl(),Re=o(qe);L(()=>E(Re,e(_).document.domain)),n(Ve,qe)};x(Le,Ve=>{e(_).document.domain&&Ve(ut)})}n(ne,ge)};x(Ie,ne=>{(e(_).document.type==="tab"||e(_).document.type==="resource")&&ne(_e)})}var Ae=i(Ie,2);{var He=ne=>{var ge=xl(),Le=o(ge);L(()=>E(Le,`${e(_).document.parentName??""} โ€บ ${e(_).document.workspaceName??""}`)),n(ne,ge)},Ue=ne=>{var ge=Fe(),Le=ee(ge);{var ut=qe=>{var Re=Cl(),pt=o(Re);L(()=>E(pt,`in ${e(_).document.workspaceName??""}`)),n(qe,Re)},Ve=qe=>{var Re=Fe(),pt=ee(Re);{var ot=ye=>{var J=Sl(),at=o(J);L(()=>E(at,`Child of ${e(_).document.parentName??""}`)),n(ye,J)},Ze=ye=>{var J=Fe(),at=ee(J);{var nt=ht=>{var tt=Tl(),Mt=o(tt);L(()=>E(Mt,e(_).document.workspaceType)),n(ht,tt)};x(at,ht=>{e(_).document.workspaceType&&ht(nt)},!0)}n(ye,J)};x(pt,ye=>{e(_).document.workspaceType==="child"&&e(_).document.parentName?ye(ot):ye(Ze,!1)},!0)}n(qe,Re)};x(Le,qe=>{e(_).document.workspaceName&&(e(_).document.type==="tab"||e(_).document.type==="resource")?qe(ut):qe(Ve,!1)},!0)}n(ne,ge)};x(Ae,ne=>{e(_).document.parentName&&e(_).document.workspaceName?ne(He):ne(Ue,!1)})}var Xe=i(Ce,2),_t=o(Xe);L(ne=>{we=Oe(he,1,"result-item svelte-uxd1ku",null,we,{selected:e(N)===e(w)}),Ee=Oe(ke,1,"result-type svelte-uxd1ku",null,Ee,{"is-workspace":e(_).document.type==="workspace","is-resource":e(_).document.type==="resource"}),E(ue,e(_).document.title),E(_t,`${ne??""}%`)},[()=>Math.round(e(_).score*100)]),n(oe,Q)}),L(oe=>{E(K,`${p().totalMatches??""} result${p().totalMatches===1?"":"s"}`),E(ve,`${oe??""}ms`)},[()=>p().duration.toFixed(1)]),n(A,S)};x(ie,A=>{p().results.length===0?A(B):A(V,!1)})}n(R,U)};x(F,R=>{e(g)&&p()&&R(W)})}L(()=>{Ct(te,"placeholder",c()),Ii(te,e(f))}),Zt("blur",te,Y),Zt("focus",te,re),n(O,P),jt()}oa(["input","keydown","click"]);var zl=u('<div class="error-banner svelte-1qgo3fj"><svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd"></path></svg> <span> </span> <button class="ml-auto text-xs hover:underline">Dismiss</button></div>'),Ll=u('<div class="loading-state svelte-1qgo3fj"><svg class="animate-spin w-6 h-6 text-phosphor" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span class="text-text-muted">Loading shared workspaces...</span></div>'),Rl=vt('<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg>'),Wl=vt('<svg class="animate-spin w-4 h-4" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>'),Bl=u('<div class="workspace-item svelte-1qgo3fj"><label class="workspace-checkbox svelte-1qgo3fj"><input type="checkbox" class="svelte-1qgo3fj"/> <div class="workspace-info svelte-1qgo3fj"><span class="workspace-name svelte-1qgo3fj"> </span> <span class="workspace-meta svelte-1qgo3fj"> </span></div></label> <!></div>'),Dl=u('<div class="empty-state svelte-1qgo3fj">No shared workspaces</div>'),Nl=u('<div class="section-actions svelte-1qgo3fj"><!></div>'),ql=u('<div class="workspace-list svelte-1qgo3fj"></div> <!>',1),Ol=u('<section class="workspace-section svelte-1qgo3fj"><button class="section-header svelte-1qgo3fj"><div class="section-header-left svelte-1qgo3fj"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg> <h3 class="section-title svelte-1qgo3fj"> </h3> <span class="section-count svelte-1qgo3fj"> </span></div> <span class="section-meta svelte-1qgo3fj"> </span></button> <!></section>'),Fl=u('<section class="workspace-section svelte-1qgo3fj"><div class="empty-state svelte-1qgo3fj"><p>No workspaces from other browsers yet.</p> <p class="text-sm mt-1">Workspaces will appear here automatically when other browsers sync.</p></div></section>'),jl=u('<section class="sync-status svelte-1qgo3fj"><div class="sync-status-icon svelte-1qgo3fj"><svg class="w-5 h-5 text-status-success" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg></div> <div class="sync-status-text svelte-1qgo3fj"><span class="sync-status-title svelte-1qgo3fj"> </span> <span class="sync-status-detail svelte-1qgo3fj"> </span></div> <!></section> <hr class="section-divider svelte-1qgo3fj"/> <!> <div class="status-footer svelte-1qgo3fj"><svg class="w-4 h-4 text-status-success" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg> <span>Connected to workspaces-bridge</span></div>',1),Ul=u('<div class="cross-browser-content svelte-1qgo3fj"><!> <!></div>');function Hl(O,s){Ft(s,!0);let c=qt(s,"open",15),p=b(!1),d=b(null),f=b(null),g=b("unknown"),w=b(dt(new Map)),M=b(dt(new Set)),j=b(dt(new Map));function H(F){const W=new Map(e(j));W.set(F,!W.get(F)),a(j,W,!0)}function se(){const F=navigator.userAgent;return F.includes("Firefox")?"firefox":F.includes("Chrome")?"chrome":"unknown"}Kt(()=>{c()?(a(g,se(),!0),Y()):(a(w,new Map,!0),a(d,null))});async function Y(){var F;a(p,!0),a(d,null);try{const W=await C.runtime.sendMessage({type:"GET_SHARED_WORKSPACES"});if(W.success){a(f,W.data,!0);const R=new Map;for(const[U,ie]of Object.entries(((F=e(f))==null?void 0:F.browsers)||{}))U!==e(g)&&ie&&ie.workspaces.length>0&&R.set(U,!0);a(j,R,!0)}else a(d,W.error||"Failed to load shared workspaces",!0)}catch(W){a(d,W instanceof Error?W.message:"Failed to connect to bridge",!0)}finally{a(p,!1)}}function re(){var F;return(F=e(f))!=null&&F.browsers?Object.entries(e(f).browsers).filter(([W])=>W!==e(g)).filter(([,W])=>W&&W.workspaces&&W.workspaces.length>0).map(([W,R])=>({browser:W,data:R})):[]}function Z(){var F,W;return(W=(F=e(f))==null?void 0:F.browsers)!=null&&W[e(g)]?e(f).browsers[e(g)].workspaces.filter(R=>R.type!=="child").length:0}function P(F,W){const R=new Map(e(w));R.has(F)||R.set(F,new Set);const U=R.get(F);U.has(W)?U.delete(W):U.add(W),a(w,R,!0)}async function q(F,W){a(M,new Set([...e(M),W]),!0);try{const R=await C.runtime.sendMessage({type:"PULL_WORKSPACES",payload:{sourceBrowser:F,workspaceIds:[W]}});R.success?s.onWorkspacesImported():a(d,R.error||"Failed to pull workspace",!0)}catch(R){a(d,R instanceof Error?R.message:"Failed to pull workspace",!0)}finally{a(M,new Set([...e(M)].filter(R=>R!==W)),!0)}}async function te(F){const W=e(w).get(F);if(!W||W.size===0)return;const R=[...W];a(M,new Set([...e(M),...R]),!0);try{const U=await C.runtime.sendMessage({type:"PULL_WORKSPACES",payload:{sourceBrowser:F,workspaceIds:R}});if(U.success){const ie=new Map(e(w));ie.delete(F),a(w,ie,!0),s.onWorkspacesImported()}else a(d,U.error||"Failed to pull workspaces",!0)}catch(U){a(d,U instanceof Error?U.message:"Failed to pull workspaces",!0)}finally{a(M,new Set([...e(M)].filter(U=>!R.includes(U))),!0)}}function G(F){const W=new Date(F),U=new Date().getTime()-W.getTime(),ie=Math.floor(U/6e4),B=Math.floor(U/36e5),V=Math.floor(U/864e5);return ie<1?"Just now":ie<60?`${ie} min ago`:B<24?`${B} hour${B>1?"s":""} ago`:`${V} day${V>1?"s":""} ago`}function de(F){var R,U;if(F.type==="parent")return`parent, ${"children"in F&&((R=F.children)==null?void 0:R.length)||0} children`;const W="tabs"in F&&((U=F.tabs)==null?void 0:U.length)||0;return`${F.type}, ${W} tabs`}function ce(F){switch(F){case"chrome":return"Chrome";case"firefox":return"Firefox";default:return"Unknown Browser"}}sa(O,{title:"Cross-Browser Workspaces",get onclose(){return s.onclose},get open(){return c()},set open(F){c(F)},children:(F,W)=>{var R=Ul(),U=o(R);{var ie=S=>{var $=zl(),D=i(o($),2),K=o(D),X=i(D,2);X.__click=()=>a(d,null),L(()=>E(K,e(d))),n(S,$)};x(U,S=>{e(d)&&S(ie)})}var B=i(U,2);{var V=S=>{var $=Ll();n(S,$)},A=S=>{var $=jl(),D=ee($),K=i(o(D),2),X=o(K),ve=o(X),We=i(X,2),oe=o(We),_=i(K,2);Pe(_,{variant:"ghost",size:"sm",onclick:Y,children:(Q,he)=>{var we=Rl();n(Q,we)},$$slots:{default:!0}});var N=i(D,4);wt(N,17,re,ea,(Q,he)=>{let we=()=>e(he).browser,ke=()=>e(he).data;var Ee=Ol(),be=o(Ee);be.__click=()=>H(we());var De=o(be),xe=o(De);let Ce;var Ne=i(xe,2),ue=o(Ne),ze=i(Ne,2),fe=o(ze),pe=i(De,2),je=o(pe),Ie=i(be,2);{var _e=Ae=>{var He=ql(),Ue=ee(He);wt(Ue,21,()=>ke().workspaces.filter(ne=>ne.type!=="child"),ne=>ne.id,(ne,ge)=>{var Le=Bl(),ut=o(Le),Ve=o(ut);Ve.__change=()=>P(we(),e(ge).id);var qe=i(Ve,2),Re=o(qe),pt=o(Re),ot=i(Re,2),Ze=o(ot),ye=i(ut,2);{let J=me(()=>e(M).has(e(ge).id));Pe(ye,{variant:"ghost",size:"sm",onclick:()=>q(we(),e(ge).id),get disabled(){return e(J)},children:(at,nt)=>{var ht=Fe(),tt=ee(ht);{var Mt=St=>{var gt=Wl();n(St,gt)},ft=St=>{var gt=Me("Pull");n(St,gt)};x(tt,St=>{e(M).has(e(ge).id)?St(Mt):St(ft,!1)})}n(at,ht)},$$slots:{default:!0}})}L((J,at)=>{Fa(Ve,J),E(pt,e(ge).name),E(Ze,at)},[()=>{var J;return((J=e(w).get(we()))==null?void 0:J.has(e(ge).id))||!1},()=>de(e(ge))]),n(ne,Le)},ne=>{var ge=Dl();n(ne,ge)});var Xe=i(Ue,2);{var _t=ne=>{var ge=Nl(),Le=o(ge);Pe(Le,{variant:"primary",size:"sm",onclick:()=>te(we()),children:(ut,Ve)=>{var qe=Me();L(Re=>E(qe,`Pull Selected (${Re??""})`),[()=>{var Re;return(Re=e(w).get(we()))==null?void 0:Re.size}]),n(ut,qe)},$$slots:{default:!0}}),n(ne,ge)};x(Xe,ne=>{var ge;(((ge=e(w).get(we()))==null?void 0:ge.size)||0)>0&&ne(_t)})}n(Ae,He)};x(Ie,Ae=>{e(j).get(we())&&Ae(_e)})}L((Ae,He,Ue,Xe)=>{Ce=Oe(xe,0,"chevron-icon svelte-1qgo3fj",null,Ce,Ae),E(ue,`${He??""} Workspaces`),E(fe,Ue),E(je,Xe)},[()=>({expanded:e(j).get(we())}),()=>ce(we()),()=>ke().workspaces.filter(Ae=>Ae.type!=="child").length,()=>G(ke().lastUpdated)]),n(Q,Ee)},Q=>{var he=Fl();n(Q,he)}),L((Q,he)=>{E(ve,`Your ${Q??""} workspaces are syncing`),E(oe,`${he??""} workspaces available to other browsers`)},[()=>ce(e(g)),Z]),n(S,$)};x(B,S=>{e(p)?S(V):S(A,!1)})}n(F,R)},$$slots:{default:!0}}),jt()}oa(["click","change"]);var Vl=vt('<svg class="animate-spin search-spinner svelte-ythzsf" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>'),$l=u('<div class="success-banner svelte-ythzsf"><svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg> <span> </span> <button class="ml-auto text-xs hover:underline">Dismiss</button></div>'),Gl=u('<div class="error-banner svelte-ythzsf"><svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clip-rule="evenodd"></path></svg> <span> </span> <button class="ml-auto text-xs hover:underline">Dismiss</button></div>'),Kl=u('<div class="empty-state svelte-ythzsf"><p class="text-text-muted text-sm"> </p></div>'),Yl=u('<tr><td class="search-time svelte-ythzsf"> </td><td class="search-browser svelte-ythzsf"> </td><td class="search-name svelte-ythzsf"> </td><td> </td></tr>'),Jl=u('<p class="confirm-text-inline svelte-ythzsf"> </p> <div class="confirm-actions-inline svelte-ythzsf"><!> <!></div>',1),Xl=u('<span class="search-selection-info svelte-ythzsf"> </span> <!>',1),Ql=u('<div class="search-restore-bar svelte-ythzsf"><!></div>'),Zl=u('<table class="search-table svelte-ythzsf"><thead><tr><th class="svelte-ythzsf">Date/Time</th><th class="svelte-ythzsf">Browser</th><th class="svelte-ythzsf">Workspace</th><th class="svelte-ythzsf">Tabs</th></tr></thead><tbody></tbody></table> <!>',1),ec=u('<div class="search-results svelte-ythzsf"><!></div>'),tc=u('<div class="loading-state svelte-ythzsf"><svg class="animate-spin w-6 h-6 text-phosphor" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span class="text-text-muted">Loading backups...</span></div>'),ac=u('<div class="empty-state svelte-ythzsf"><svg class="w-12 h-12 text-text-muted mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"></path></svg> <p class="text-text-muted">No backups available yet.</p> <p class="text-sm text-text-muted mt-1">Backups are created automatically when you sync workspaces.</p></div>'),sc=vt('<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg>'),rc=vt('<svg class="w-4 h-4 text-phosphor" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg>'),oc=u('<button><div class="backup-item-main svelte-ythzsf"><span class="backup-time svelte-ythzsf"> </span> <span class="backup-meta svelte-ythzsf"> </span></div> <!></button>'),nc=u('<div class="backup-group svelte-ythzsf"><div class="group-label svelte-ythzsf"> </div> <!></div>'),ic=u('<div class="preview-placeholder svelte-ythzsf"><svg class="w-8 h-8 text-text-muted mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path></svg> <p class="text-text-muted text-sm">Select a backup to preview</p></div>'),lc=u('<div class="preview-loading svelte-ythzsf"><svg class="animate-spin w-5 h-5 text-phosphor" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <span class="text-text-muted text-sm">Loading preview...</span></div>'),cc=u('<span class="selected-count svelte-ythzsf"> </span>'),dc=u('<li class="workspace-item svelte-ythzsf"><label class="workspace-checkbox-label svelte-ythzsf"><input type="checkbox" class="workspace-checkbox svelte-ythzsf"/> <span class="workspace-name svelte-ythzsf"> </span></label> <span class="workspace-type svelte-ythzsf"> </span></li>'),vc=u('<div class="browser-section svelte-ythzsf"><div class="browser-header svelte-ythzsf"><span class="browser-name svelte-ythzsf"> </span> <span class="workspace-count svelte-ythzsf"> </span></div> <ul class="workspace-list svelte-ythzsf"></ul></div>'),uc=u('<div class="restore-confirm svelte-ythzsf"><p class="confirm-text svelte-ythzsf"> </p> <div class="confirm-actions svelte-ythzsf"><!> <!></div></div>'),pc=u(`<div class="restore-confirm svelte-ythzsf"><p class="confirm-text svelte-ythzsf">This will replace ALL your current sync data with this backup.
10                      A backup of the current state will be created first.</p> <div class="confirm-actions svelte-ythzsf"><!> <!></div></div>`),hc=u('<div class="restore-actions svelte-ythzsf"><!> <!></div>'),fc=u('<div class="preview-content svelte-ythzsf"><div class="preview-header svelte-ythzsf"><h4 class="preview-title svelte-ythzsf">Preview</h4> <span class="preview-date svelte-ythzsf"> </span></div> <div class="selection-controls svelte-ythzsf"><button class="select-link svelte-ythzsf">Select All</button> <span class="select-divider svelte-ythzsf">|</span> <button class="select-link svelte-ythzsf">Deselect All</button> <!></div> <div class="preview-workspaces svelte-ythzsf"></div> <!></div>'),gc=u('<div class="backup-layout svelte-ythzsf"><div class="backup-list svelte-ythzsf"><div class="list-header svelte-ythzsf"><span class="text-sm font-medium">Backup History</span> <!></div> <div class="backup-groups svelte-ythzsf"></div></div> <div class="preview-panel svelte-ythzsf"><!></div></div>'),mc=u('<div class="backup-browser svelte-ythzsf"><div class="search-bar svelte-ythzsf"><svg class="search-icon svelte-ythzsf" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg> <input type="text" class="search-input svelte-ythzsf" placeholder="Search workspace across backups..."/> <!></div> <!> <!> <!></div>');function kc(O,s){Ft(s,!0);let c=qt(s,"open",15),p=b(!1),d=b(null),f=b(dt([])),g=b(null),w=b(null),M=b(!1),j=b(!1),H=b(!1),se=b(""),Y=b(dt([])),re=b(!1),Z=null,P=b(dt(new Set)),q=b(!1),te=b(!1),G=b(null),de=b(!1),ce=b(!1),F=b(null);Kt(()=>{c()?(W(),a(g,null),a(w,null),a(H,!1),a(se,""),a(Y,[],!0),a(G,null),a(de,!1),a(P,new Set,!0),a(q,!1)):(a(d,null),a(F,null))}),Kt(()=>{const _=e(se);Z&&clearTimeout(Z),_.trim().length>0?Z=setTimeout(()=>R(_),300):(a(Y,[],!0),a(G,null),a(de,!1))});async function W(){a(p,!0),a(d,null);try{const _=await C.runtime.sendMessage({type:"GET_BACKUPS"});_.success?a(f,_.backups,!0):a(d,_.error||"Failed to load backups",!0)}catch(_){a(d,_ instanceof Error?_.message:"Failed to connect to backup service",!0)}finally{a(p,!1)}}async function R(_){a(re,!0);try{const N=await C.runtime.sendMessage({type:"SEARCH_BACKUPS",payload:{query:_}});N.success&&a(Y,N.results,!0)}catch{}finally{a(re,!1)}}async function U(_){a(g,_,!0),a(M,!0),a(w,null),a(H,!1),a(q,!1),a(P,new Set,!0);try{const N=await C.runtime.sendMessage({type:"PREVIEW_BACKUP",payload:{filename:_.filename}});N.success?a(w,N.data,!0):a(d,N.error||"Failed to load backup preview",!0)}catch(N){a(d,N instanceof Error?N.message:"Failed to load backup preview",!0)}finally{a(M,!1)}}async function ie(){if(e(g)){a(j,!0),a(d,null);try{const _=await C.runtime.sendMessage({type:"RESTORE_VERSIONED_BACKUP",payload:{filename:e(g).filename}});_.success?(a(H,!1),s.onRestoreComplete(),c(!1)):a(d,_.error||"Failed to restore backup",!0)}catch(_){a(d,_ instanceof Error?_.message:"Failed to restore backup",!0)}finally{a(j,!1)}}}async function B(){if(!(!e(g)||e(P).size===0)){a(te,!0),a(d,null);try{const _=await C.runtime.sendMessage({type:"RESTORE_SELECTIVE_BACKUP",payload:{filename:e(g).filename,workspaceIds:Array.from(e(P))}});_.success?(a(q,!1),s.onRestoreComplete(),c(!1)):a(d,_.error||"Failed to restore selected workspaces",!0)}catch(_){a(d,_ instanceof Error?_.message:"Failed to restore selected workspaces",!0)}finally{a(te,!1)}}}async function V(){if(e(G)){a(ce,!0),a(d,null);try{const _=await C.runtime.sendMessage({type:"RESTORE_SELECTIVE_BACKUP",payload:{filename:e(G).filename,workspaceIds:[e(G).workspace_id]}});if(_.success){const N=e(G).workspace_name;a(de,!1),a(G,null),s.onRestoreComplete(),a(F,`"${N}" imported successfully`),setTimeout(()=>a(F,null),4e3)}else a(d,_.error||"Failed to import workspace",!0)}catch(_){a(d,_ instanceof Error?_.message:"Failed to import workspace",!0)}finally{a(ce,!1)}}}function A(_){const N=new Set(e(P));N.has(_)?N.delete(_):N.add(_),a(P,N,!0)}function S(){const _=new Set;for(const{workspaces:N}of ve())for(const Q of N)_.add(Q.id);a(P,_,!0)}function $(){a(P,new Set,!0)}function D(_){const N=[],Q=[],he=[],we=[],ke=[];for(const Ee of _)Ee.age_days<1?Q.push(Ee):Ee.age_days<2?he.push(Ee):Ee.age_days<7?we.push(Ee):ke.push(Ee);return Q.length>0&&N.push({label:`Today (${Q.length})`,backups:Q}),he.length>0&&N.push({label:`Yesterday (${he.length})`,backups:he}),we.length>0&&N.push({label:`This Week (${we.length})`,backups:we}),ke.length>0&&N.push({label:`Older (${ke.length})`,backups:ke}),N}function K(_){return new Date(_).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function X(_){return _<1024?`${_} B`:_<1024*1024?`${(_/1024).toFixed(1)} KB`:`${(_/(1024*1024)).toFixed(1)} MB`}function ve(){var _;return(_=e(w))!=null&&_.browsers?Object.entries(e(w).browsers).filter(([,N])=>N&&N.workspaces&&N.workspaces.length>0).map(([N,Q])=>({browser:N,workspaces:Q.workspaces})):[]}function We(_){switch(_){case"chrome":return"Chrome";case"firefox":return"Firefox";default:return"Unknown"}}function oe(_,N){if(_.tab_count!==0)return!1;for(let Q=N+1;Q<e(Y).length;Q++)if(e(Y)[Q].workspace_id===_.workspace_id)return e(Y)[Q].tab_count>0;return!1}sa(O,{title:"Browse Sync Backups",get onclose(){return s.onclose},size:"lg",get open(){return c()},set open(_){c(_)},children:(_,N)=>{var Q=mc(),he=o(Q),we=i(o(he),2),ke=i(we,2);{var Ee=fe=>{var pe=Vl();n(fe,pe)};x(ke,fe=>{e(re)&&fe(Ee)})}var be=i(he,2);{var De=fe=>{var pe=$l(),je=i(o(pe),2),Ie=o(je),_e=i(je,2);_e.__click=()=>a(F,null),L(()=>E(Ie,e(F))),n(fe,pe)};x(be,fe=>{e(F)&&fe(De)})}var xe=i(be,2);{var Ce=fe=>{var pe=Gl(),je=i(o(pe),2),Ie=o(je),_e=i(je,2);_e.__click=()=>a(d,null),L(()=>E(Ie,e(d))),n(fe,pe)};x(xe,fe=>{e(d)&&fe(Ce)})}var Ne=i(xe,2);{var ue=fe=>{var pe=ec(),je=o(pe);{var Ie=Ae=>{var He=Kl(),Ue=o(He),Xe=o(Ue);L(()=>E(Xe,`No results found for "${e(se)??""}"`)),n(Ae,He)},_e=Ae=>{var He=Zl(),Ue=ee(He),Xe=i(o(Ue));wt(Xe,21,()=>e(Y),ea,(ge,Le,ut)=>{var Ve=Yl();let qe;Ve.__click=()=>{a(G,e(G)===e(Le)?null:e(Le),!0),a(de,!1)};var Re=o(Ve),pt=o(Re),ot=i(Re),Ze=o(ot),ye=i(ot),J=o(ye),at=i(ye);let nt;var ht=o(at);L((tt,Mt,ft)=>{qe=Oe(Ve,1,"search-row svelte-ythzsf",null,qe,tt),E(pt,Mt),E(Ze,ft),E(J,e(Le).workspace_name),nt=Oe(at,1,"search-tabs svelte-ythzsf",null,nt,{"tab-zero":e(Le).tab_count===0}),E(ht,e(Le).tab_count>=0?e(Le).tab_count:"?")},[()=>({"zero-tab-transition":oe(e(Le),ut),"zero-tabs":e(Le).tab_count===0,selected:e(G)===e(Le)}),()=>K(e(Le).timestamp),()=>We(e(Le).browser)]),n(ge,Ve)});var _t=i(Ue,2);{var ne=ge=>{var Le=Ql(),ut=o(Le);{var Ve=Re=>{var pt=Jl(),ot=ee(pt),Ze=o(ot),ye=i(ot,2),J=o(ye);Pe(J,{variant:"ghost",size:"sm",onclick:()=>a(de,!1),get disabled(){return e(ce)},children:(nt,ht)=>{var tt=Me("Cancel");n(nt,tt)},$$slots:{default:!0}});var at=i(J,2);Pe(at,{variant:"primary",size:"sm",onclick:V,get disabled(){return e(ce)},children:(nt,ht)=>{var tt=Fe(),Mt=ee(tt);{var ft=gt=>{var Ut=Me("Importing...");n(gt,Ut)},St=gt=>{var Ut=Me("Confirm Import");n(gt,Ut)};x(Mt,gt=>{e(ce)?gt(ft):gt(St,!1)})}n(nt,tt)},$$slots:{default:!0}}),L(nt=>E(Ze,`Import "${e(G).workspace_name??""}" (${e(G).tab_count??""} tabs) from ${nt??""}?`),[()=>K(e(G).timestamp)]),n(Re,pt)},qe=Re=>{var pt=Xl(),ot=ee(pt),Ze=o(ot),ye=i(ot,2);Pe(ye,{variant:"primary",size:"sm",onclick:()=>a(de,!0),children:(J,at)=>{var nt=Me("Import Workspace");n(J,nt)},$$slots:{default:!0}}),L(J=>E(Ze,`"${e(G).workspace_name??""}" โ€” ${e(G).tab_count??""} tabs from ${J??""}`),[()=>K(e(G).timestamp)]),n(Re,pt)};x(ut,Re=>{e(de)?Re(Ve):Re(qe,!1)})}n(ge,Le)};x(_t,ge=>{e(G)&&ge(ne)})}n(Ae,He)};x(je,Ae=>{e(Y).length===0&&!e(re)?Ae(Ie):Ae(_e,!1)})}n(fe,pe)},ze=fe=>{var pe=Fe(),je=ee(pe);{var Ie=Ae=>{var He=tc();n(Ae,He)},_e=Ae=>{var He=Fe(),Ue=ee(He);{var Xe=ne=>{var ge=ac();n(ne,ge)},_t=ne=>{var ge=gc(),Le=o(ge),ut=o(Le),Ve=i(o(ut),2);Pe(Ve,{variant:"ghost",size:"sm",onclick:W,title:"Refresh",children:(ye,J)=>{var at=sc();n(ye,at)},$$slots:{default:!0}});var qe=i(ut,2);wt(qe,21,()=>D(e(f)),ea,(ye,J)=>{var at=nc(),nt=o(at),ht=o(nt),tt=i(nt,2);wt(tt,17,()=>e(J).backups,ea,(Mt,ft)=>{var St=oc();let gt;St.__click=()=>U(e(ft));var Ut=o(St),Aa=o(Ut),ja=o(Aa),Ua=i(Aa,2),Ra=o(Ua),y=i(Ut,2);{var Wa=na=>{var _a=rc();n(na,_a)};x(y,na=>{var _a;((_a=e(g))==null?void 0:_a.filename)===e(ft).filename&&na(Wa)})}L((na,_a)=>{var Ea;gt=Oe(St,1,"backup-item svelte-ythzsf",null,gt,{selected:((Ea=e(g))==null?void 0:Ea.filename)===e(ft).filename}),E(ja,na),E(Ra,`${e(ft).workspace_count??"?"??""} ws, ${_a??""}`)},[()=>K(e(ft).timestamp),()=>X(e(ft).size)]),n(Mt,St)}),L(()=>E(ht,e(J).label)),n(ye,at)});var Re=i(Le,2),pt=o(Re);{var ot=ye=>{var J=ic();n(ye,J)},Ze=ye=>{var J=Fe(),at=ee(J);{var nt=tt=>{var Mt=lc();n(tt,Mt)},ht=tt=>{var Mt=Fe(),ft=ee(Mt);{var St=gt=>{var Ut=fc(),Aa=o(Ut),ja=i(o(Aa),2),Ua=o(ja),Ra=i(Aa,2),y=o(Ra);y.__click=S;var Wa=i(y,4);Wa.__click=$;var na=i(Wa,2);{var _a=yt=>{var Ht=cc(),va=o(Ht);L(()=>E(va,`${e(P).size??""} selected`)),n(yt,Ht)};x(na,yt=>{e(P).size>0&&yt(_a)})}var Ea=i(Ra,2);wt(Ea,21,ve,ea,(yt,Ht)=>{let va=()=>e(Ht).browser,ba=()=>e(Ht).workspaces;var ya=vc(),Vt=o(ya),ta=o(Vt),aa=o(ta),ia=i(ta,2),la=o(ia),$t=i(Vt,2);wt($t,21,ba,ea,(ca,le)=>{var Ot=dc(),ua=o(Ot),Pa=o(ua);Pa.__change=()=>A(e(le).id);var pa=i(Pa,2),za=o(pa),da=i(ua,2),I=o(da);L(Ba=>{var Za,es;Fa(Pa,Ba),E(za,e(le).name),E(I,e(le).type==="parent"?`${((Za=e(le).children)==null?void 0:Za.length)||0} children`:`${((es=e(le).tabs)==null?void 0:es.length)||0} tabs`)},[()=>e(P).has(e(le).id)]),n(ca,Ot)}),L(ca=>{E(aa,ca),E(la,`${ba().length??""} workspaces`)},[()=>We(va())]),n(yt,ya)});var cs=i(Ea,2);{var Ha=yt=>{var Ht=uc(),va=o(Ht),ba=o(va),ya=i(va,2),Vt=o(ya);Pe(Vt,{variant:"ghost",size:"sm",onclick:()=>a(q,!1),get disabled(){return e(te)},children:(aa,ia)=>{var la=Me("Cancel");n(aa,la)},$$slots:{default:!0}});var ta=i(Vt,2);Pe(ta,{variant:"primary",size:"sm",onclick:B,get disabled(){return e(te)},children:(aa,ia)=>{var la=Fe(),$t=ee(la);{var ca=Ot=>{var ua=Me("Restoring...");n(Ot,ua)},le=Ot=>{var ua=Me();L(()=>E(ua,`Confirm Restore (${e(P).size??""})`)),n(Ot,ua)};x($t,Ot=>{e(te)?Ot(ca):Ot(le,!1)})}n(aa,la)},$$slots:{default:!0}}),L(()=>E(ba,`Restore ${e(P).size??""} selected workspace${e(P).size===1?"":"s"} from this backup?
11                      Other workspaces will remain unchanged. A backup of the current state will be created first.`)),n(yt,Ht)},Va=yt=>{var Ht=Fe(),va=ee(Ht);{var ba=Vt=>{var ta=pc(),aa=i(o(ta),2),ia=o(aa);Pe(ia,{variant:"ghost",size:"sm",onclick:()=>a(H,!1),get disabled(){return e(j)},children:($t,ca)=>{var le=Me("Cancel");n($t,le)},$$slots:{default:!0}});var la=i(ia,2);Pe(la,{variant:"danger",size:"sm",onclick:ie,get disabled(){return e(j)},children:($t,ca)=>{var le=Fe(),Ot=ee(le);{var ua=pa=>{var za=Me("Restoring...");n(pa,za)},Pa=pa=>{var za=Me("Confirm Full Restore");n(pa,za)};x(Ot,pa=>{e(j)?pa(ua):pa(Pa,!1)})}n($t,le)},$$slots:{default:!0}}),n(Vt,ta)},ya=Vt=>{var ta=hc(),aa=o(ta);{var ia=$t=>{Pe($t,{variant:"primary",size:"sm",onclick:()=>a(q,!0),children:(ca,le)=>{var Ot=Me();L(()=>E(Ot,`Restore Selected (${e(P).size??""})`)),n(ca,Ot)},$$slots:{default:!0}})};x(aa,$t=>{e(P).size>0&&$t(ia)})}var la=i(aa,2);Pe(la,{variant:"danger",size:"sm",onclick:()=>a(H,!0),children:($t,ca)=>{var le=Me("Restore Entire Backup");n($t,le)},$$slots:{default:!0}}),n(Vt,ta)};x(va,Vt=>{e(H)?Vt(ba):Vt(ya,!1)},!0)}n(yt,Ht)};x(cs,yt=>{e(q)?yt(Ha):yt(Va,!1)})}L(yt=>E(Ua,yt),[()=>K(e(g).timestamp)]),n(gt,Ut)};x(ft,gt=>{e(w)&&gt(St)},!0)}n(tt,Mt)};x(at,tt=>{e(M)?tt(nt):tt(ht,!1)},!0)}n(ye,J)};x(pt,ye=>{e(g)?ye(Ze,!1):ye(ot)})}n(ne,ge)};x(Ue,ne=>{e(f).length===0?ne(Xe):ne(_t,!1)},!0)}n(Ae,He)};x(je,Ae=>{e(p)?Ae(Ie):Ae(_e,!1)},!0)}n(fe,pe)};x(Ne,fe=>{e(se).trim().length>0?fe(ue):fe(ze,!1)})}wa(we,()=>e(se),fe=>a(se,fe)),n(_,Q)},$$slots:{default:!0,footer:(_,N)=>{Pe(_,{variant:"ghost",get onclick(){return s.onclose},children:(Q,he)=>{var we=Me("Close");n(Q,we)},$$slots:{default:!0}})}}}),jt()}oa(["click","change"]);var wc=u("<option> </option>"),_c=vt('<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg>'),bc=u('<div class="loading-state svelte-1iwfs3g">Loading...</div>'),yc=u('<div class="empty-state svelte-1iwfs3g"><p class="text-text-muted text-sm"> </p></div>'),xc=u('<div class="entry-data svelte-1iwfs3g"> </div>'),Cc=u('<div><div class="entry-header svelte-1iwfs3g"><span class="entry-time svelte-1iwfs3g"> </span> <span class="entry-event svelte-1iwfs3g"> </span></div> <!></div>'),Sc=u('<div class="log-entries svelte-1iwfs3g"></div>'),Tc=u('<div class="debug-log-viewer svelte-1iwfs3g"><div class="toolbar svelte-1iwfs3g"><select class="filter-select svelte-1iwfs3g"></select> <span class="entry-count svelte-1iwfs3g"> </span> <div class="toolbar-actions svelte-1iwfs3g"><!> <!> <!></div></div> <!></div>');function Mc(O,s){Ft(s,!0);let c=qt(s,"open",15),p=b(dt([])),d=b(!1),f=b("all");const g=["all","auto_save_triggered","auto_save_completed","auto_save_skipped","auto_save_cancelled","capture_tabs","update_tabs","zero_tab_blocked","window_removed","tab_detached","tab_removed","sync_merge"];Kt(()=>{c()&&w()});async function w(){a(d,!0);try{const P=await C.runtime.sendMessage({type:"GET_DEBUG_LOGS"});P.success&&a(p,P.entries,!0)}catch{}finally{a(d,!1)}}async function M(){try{await C.runtime.sendMessage({type:"CLEAR_DEBUG_LOGS"}),a(p,[],!0)}catch{}}async function j(){try{const P=await C.runtime.sendMessage({type:"EXPORT_DEBUG_LOGS"});if(P.success){const q=new Blob([P.data],{type:"application/json"}),te=URL.createObjectURL(q),G=document.createElement("a");G.href=te,G.download=`mnemonic-debug-${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.json`,G.click(),URL.revokeObjectURL(te)}}catch{}}function H(P){return new Date(P).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function se(P){return new Date(P).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Y(P){const q=[];for(const[te,G]of Object.entries(P))q.push(`${te}=${JSON.stringify(G)}`);return q.join(", ")}function re(P){switch(P){case"zero_tab_blocked":return"var(--status-error)";case"auto_save_cancelled":case"auto_save_skipped":return"var(--status-warning)";case"auto_save_completed":case"update_tabs":return"var(--status-success)";default:return"var(--text-muted)"}}let Z=me(()=>e(f)==="all"?e(p):e(p).filter(P=>P.event===e(f)));sa(O,{title:"Debug Logs",get onclose(){return s.onclose},size:"lg",get open(){return c()},set open(P){c(P)},children:(P,q)=>{var te=Tc(),G=o(te),de=o(G);wt(de,21,()=>g,ea,(S,$)=>{var D=wc(),K=o(D),X={};L(()=>{E(K,e($)==="all"?"All Events":e($)),X!==(X=e($))&&(D.value=(D.__value=e($))??"")}),n(S,D)});var ce=i(de,2),F=o(ce),W=i(ce,2),R=o(W);Pe(R,{variant:"ghost",size:"sm",onclick:w,title:"Refresh",children:(S,$)=>{var D=_c();n(S,D)},$$slots:{default:!0}});var U=i(R,2);Pe(U,{variant:"ghost",size:"sm",onclick:j,title:"Export JSON",children:(S,$)=>{var D=Me("Export");n(S,D)},$$slots:{default:!0}});var ie=i(U,2);Pe(ie,{variant:"ghost",size:"sm",onclick:M,title:"Clear all logs",children:(S,$)=>{var D=Me("Clear");n(S,D)},$$slots:{default:!0}});var B=i(G,2);{var V=S=>{var $=bc();n(S,$)},A=S=>{var $=Fe(),D=ee($);{var K=ve=>{var We=yc(),oe=o(We),_=o(oe);L(()=>E(_,`No debug log entries${e(f)!=="all"?` for "${e(f)}"`:""}.`)),n(ve,We)},X=ve=>{var We=Sc();wt(We,21,()=>e(Z),ea,(oe,_)=>{var N=Cc();let Q;var he=o(N),we=o(he),ke=o(we),Ee=i(we,2),be=o(Ee),De=i(he,2);{var xe=Ce=>{var Ne=xc(),ue=o(Ne);L(ze=>E(ue,ze),[()=>Y(e(_).data)]),n(Ce,Ne)};x(De,Ce=>{Object.keys(e(_).data).length>0&&Ce(xe)})}L((Ce,Ne,ue)=>{Q=Oe(N,1,"log-entry svelte-1iwfs3g",null,Q,{highlight:e(_).event==="zero_tab_blocked"}),E(ke,`${Ce??""} ${Ne??""}`),Ia(Ee,`color: ${ue??""}`),E(be,e(_).event)},[()=>se(e(_).timestamp),()=>H(e(_).timestamp),()=>re(e(_).event)]),n(oe,N)}),n(ve,We)};x(D,ve=>{e(Z).length===0?ve(K):ve(X,!1)},!0)}n(S,$)};x(B,S=>{e(d)?S(V):S(A,!1)})}L(()=>E(F,`${e(Z).length??""} entries`)),is(de,()=>e(f),S=>a(f,S)),n(P,te)},$$slots:{default:!0,footer:(P,q)=>{Pe(P,{variant:"ghost",get onclick(){return s.onclose},children:(te,G)=>{var de=Me("Close");n(te,de)},$$slots:{default:!0}})}}}),jt()}var Ic=u('<div class="spinner svelte-x81nvl"></div>'),Ac=vt('<svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path></svg>'),Ec=u("<!> Get Suggestions",1),Pc=u('<div class="not-configured svelte-x81nvl"><svg class="config-icon svelte-x81nvl" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"></path></svg> <p class="config-text svelte-x81nvl">Configure your Claude API key to get intelligent workspace suggestions.</p> <!></div>'),zc=u('<div class="loading-state svelte-x81nvl"><div class="spinner large svelte-x81nvl"></div> <p>Analyzing your workspaces...</p></div>'),Lc=u('<div class="empty-state svelte-x81nvl"><svg class="empty-icon svelte-x81nvl" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> <p class="svelte-x81nvl">Your workspaces are well organized!</p> <p class="empty-hint svelte-x81nvl">Click "Get Suggestions" to analyze your workspace structure.</p></div>'),Rc=u("<span> </span>"),Wc=u('<li class="suggestion-item svelte-x81nvl"><div class="suggestion-header svelte-x81nvl"><div class="suggestion-type svelte-x81nvl"><svg class="type-icon svelte-x81nvl" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"></path></svg> <span class="type-label svelte-x81nvl"> </span></div> <!></div> <p class="suggestion-description svelte-x81nvl"> </p> <div class="suggestion-actions svelte-x81nvl"><!> <!></div></li>'),Bc=u('<ul class="suggestion-list svelte-x81nvl"></ul>'),Dc=u('<div class="suggestion-panel svelte-x81nvl"><div class="panel-header svelte-x81nvl"><div class="header-left svelte-x81nvl"><svg class="header-icon svelte-x81nvl" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"></path></svg> <h3 class="header-title svelte-x81nvl">Claude Suggestions</h3></div> <!></div> <div class="panel-content svelte-x81nvl"><!></div></div>');function Nc(O,s){Ft(s,!0);let c=qt(s,"suggestions",19,()=>[]),p=qt(s,"isLoading",3,!1),d=qt(s,"isConfigured",3,!1);const f={organize:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z",merge:"M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2",split:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z",rename:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z",transcendent:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"};function g(q){return{organize:"Organize",merge:"Merge",split:"Split",rename:"Rename",transcendent:"Mark Transcendent"}[q]||q}function w(q){return q===void 0?"text-text-muted":q>=.8?"text-status-success":q>=.5?"text-phosphor":"text-status-warning"}var M=Dc(),j=o(M),H=i(o(j),2);{var se=q=>{Pe(q,{variant:"ghost",size:"sm",get disabled(){return p()},get onclick(){return s.onGetSuggestions},children:(te,G)=>{var de=Ec(),ce=ee(de);{var F=R=>{var U=Ic();n(R,U)},W=R=>{var U=Ac();n(R,U)};x(ce,R=>{p()?R(F):R(W,!1)})}n(te,de)},$$slots:{default:!0}})};x(H,q=>{d()&&q(se)})}var Y=i(j,2),re=o(Y);{var Z=q=>{var te=Pc(),G=i(o(te),4);Pe(G,{variant:"primary",size:"sm",get onclick(){return s.onConfigure},children:(de,ce)=>{var F=Me("Configure API Key");n(de,F)},$$slots:{default:!0}}),n(q,te)},P=q=>{var te=Fe(),G=ee(te);{var de=F=>{var W=zc();n(F,W)},ce=F=>{var W=Fe(),R=ee(W);{var U=B=>{var V=Lc();n(B,V)},ie=B=>{var V=Bc();wt(V,21,c,A=>A.description,(A,S)=>{var $=Wc(),D=o($),K=o(D),X=o(K),ve=o(X),We=i(X,2),oe=o(We),_=i(K,2);{var N=be=>{var De=Rc(),xe=o(De);L((Ce,Ne)=>{Oe(De,1,`confidence ${Ce??""}`,"svelte-x81nvl"),E(xe,`${Ne??""}%`)},[()=>w(e(S).confidence),()=>Math.round(e(S).confidence*100)]),n(be,De)};x(_,be=>{e(S).confidence!==void 0&&be(N)})}var Q=i(D,2),he=o(Q),we=i(Q,2),ke=o(we);Pe(ke,{variant:"primary",size:"sm",onclick:()=>{var be;return(be=s.onApplySuggestion)==null?void 0:be.call(s,e(S))},children:(be,De)=>{var xe=Me("Apply");n(be,xe)},$$slots:{default:!0}});var Ee=i(ke,2);Pe(Ee,{variant:"ghost",size:"sm",onclick:()=>{var be;return(be=s.onDismissSuggestion)==null?void 0:be.call(s,e(S))},children:(be,De)=>{var xe=Me("Dismiss");n(be,xe)},$$slots:{default:!0}}),L(be=>{Ct(ve,"d",f[e(S).type]||f.organize),E(oe,be),E(he,e(S).description)},[()=>g(e(S).type)]),n(A,$)}),n(B,V)};x(R,B=>{c().length===0?B(U):B(ie,!1)},!0)}n(F,W)};x(G,F=>{p()?F(de):F(ce,!1)},!0)}n(q,te)};x(re,q=>{d()?q(P,!1):q(Z)})}n(O,M),jt()}var qc=u('<span class="connection-badge connected svelte-mzal0a">Logseq</span>'),Oc=u('<span class="save-status saving svelte-mzal0a">Saving...</span>'),Fc=u('<span class="save-status unsaved svelte-mzal0a">Unsaved</span>'),jc=u('<span class="save-status saved svelte-mzal0a">Saved</span>'),Uc=u('<span class="modified-time svelte-mzal0a"> </span>'),Hc=vt('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-mzal0a"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>'),Vc=vt('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="svelte-mzal0a"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>'),$c=u("<!> <!> <button><!></button>",1),Gc=u('<div class="connection-prompt svelte-mzal0a"><svg class="prompt-icon svelte-mzal0a" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg> <h4 class="svelte-mzal0a">Logseq Not Connected</h4> <p class="svelte-mzal0a"><!></p> <div class="prompt-actions svelte-mzal0a"><button class="btn-primary svelte-mzal0a">Configure Logseq</button> <button class="btn-secondary svelte-mzal0a">Retry Connection</button></div> <p class="prompt-hint svelte-mzal0a">Make sure Logseq is running with HTTP API enabled (port 12315).</p></div>'),Kc=u('<div class="loading svelte-mzal0a"><div class="spinner svelte-mzal0a"></div> <span>Loading notes...</span></div>'),Yc=u('<div class="error svelte-mzal0a"><p> </p> <button class="btn-secondary svelte-mzal0a">Retry</button></div>'),Jc=u(`<textarea class="note-editor svelte-mzal0a" placeholder="Write your notes here...
12  
13  Use Markdown:
14  - **bold** or __bold__
15  - *italic* or _italic_
16  - \`code\`
17  - [links](url)
18  - Lists with -"></textarea>`),Xc=u('<div class="note-preview svelte-mzal0a" role="button" tabindex="0"><!></div>'),Qc=u('<div class="notes-panel svelte-mzal0a"><div class="notes-header svelte-mzal0a"><div class="notes-title svelte-mzal0a"><svg class="icon svelte-mzal0a" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg> <span>Notes</span> <!></div> <div class="notes-actions svelte-mzal0a"><!></div></div> <div class="notes-content svelte-mzal0a"><!></div></div>');function Zc(O,s){Ft(s,!0);const c=Fi(),p=Qa();let d=b(dt({available:!1,graphName:null,graphPath:null,lastChecked:""})),f=b(""),g=b(""),w=b(null),M=b(!1),j=b(!1),H=b(!1),se=b(null),Y=b(!1),re=null;const Z=2e3;let P=null;Kt(()=>{a(Y,e(f)!==e(g))}),Kt(()=>{s.workspace&&e(d).available&&te()}),Ps(async()=>{try{const N=await C.storage.local.get("logseqSettings");N.logseqSettings&&p.setSettings(N.logseqSettings)}catch(N){console.error("[Notes] Failed to load Logseq settings:",N)}await q();const _=()=>{document.visibilityState==="visible"&&!e(d).available&&q()};return document.addEventListener("visibilitychange",_),P=setInterval(()=>{e(d).available||q()},3e5),()=>{document.removeEventListener("visibilitychange",_),re&&clearTimeout(re),P&&clearInterval(P)}});async function q(){a(d,await c.checkConnection(),!0)}async function te(){var _;if(s.workspace){a(j,!0),a(se,null);try{const N=(_=s.parentWorkspace)==null?void 0:_.name,Q=await c.getWorkspaceNoteWithMetadata(s.workspace,N);a(f,Q.content,!0),a(g,Q.content,!0),a(w,Q.modifiedUtc,!0)}catch(N){a(se,N instanceof Error?N.message:"Failed to load notes",!0)}finally{a(j,!1)}}}async function G(){var _;if(!(!s.workspace||!e(Y))){a(H,!0),a(se,null);try{const N=(_=s.parentWorkspace)==null?void 0:_.name;await c.setWorkspaceNoteContent(s.workspace,e(f),N),a(g,e(f),!0),a(w,new Date().toISOString(),!0)}catch(N){a(se,N instanceof Error?N.message:"Failed to save notes",!0)}finally{a(H,!1)}}}function de(){re&&clearTimeout(re),re=setTimeout(()=>{e(Y)&&e(d).available&&G()},Z)}function ce(){e(Y)&&e(d).available&&(re&&clearTimeout(re),G())}async function F(){C.runtime.openOptionsPage()}async function W(){await q(),e(d).available&&s.workspace&&await te()}function R(){a(M,!e(M))}function U(_){return _?_.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/^### (.*)$/gm,"<h4>$1</h4>").replace(/^## (.*)$/gm,"<h3>$1</h3>").replace(/^# (.*)$/gm,"<h2>$1</h2>").replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/___(.+?)___/g,"<strong><em>$1</em></strong>").replace(/__(.+?)__/g,"<strong>$1</strong>").replace(/_(.+?)_/g,"<em>$1</em>").replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener">$1</a>').replace(/^- (.*)$/gm,"<li>$1</li>").replace(/(<li>.*<\/li>\n?)+/g,"<ul>$&</ul>").replace(/\n\n/g,"</p><p>").replace(/\n/g,"<br>").replace(/^/,"<p>").replace(/$/,"</p>").replace(/<p><\/p>/g,"").replace(/<p>(<h[234]>)/g,"$1").replace(/(<\/h[234]>)<\/p>/g,"$1"):'<p class="empty-note">No notes yet. Click to add some.</p>'}var ie=Qc(),B=o(ie),V=o(B),A=i(o(V),4);{var S=_=>{var N=qc();L(()=>Ct(N,"title",`Connected to ${e(d).graphName??""}`)),n(_,N)};x(A,_=>{e(d).available&&_(S)})}var $=i(V,2),D=o($);{var K=_=>{var N=$c(),Q=ee(N);{var he=ue=>{var ze=Oc();n(ue,ze)},we=ue=>{var ze=Fe(),fe=ee(ze);{var pe=Ie=>{var _e=Fc();n(Ie,_e)},je=Ie=>{var _e=Fe(),Ae=ee(_e);{var He=Ue=>{var Xe=jc();n(Ue,Xe)};x(Ae,Ue=>{e(g)&&Ue(He)},!0)}n(Ie,_e)};x(fe,Ie=>{e(Y)?Ie(pe):Ie(je,!1)},!0)}n(ue,ze)};x(Q,ue=>{e(H)?ue(he):ue(we,!1)})}var ke=i(Q,2);{var Ee=ue=>{var ze=Uc(),fe=o(ze);L((pe,je)=>{Ct(ze,"title",`Last modified: ${pe??""}`),E(fe,je)},[()=>Zr(e(w),{includeDate:!0,includeTime:!0}),()=>Zr(e(w),{relative:!0})]),n(ue,ze)};x(ke,ue=>{e(w)&&!e(Y)&&!e(H)&&ue(Ee)})}var be=i(ke,2);let De;be.__click=R;var xe=o(be);{var Ce=ue=>{var ze=Hc();n(ue,ze)},Ne=ue=>{var ze=Vc();n(ue,ze)};x(xe,ue=>{e(M)?ue(Ce):ue(Ne,!1)})}L(()=>{De=Oe(be,1,"toggle-btn svelte-mzal0a",null,De,{active:e(M)}),Ct(be,"title",e(M)?"View":"Edit")}),n(_,N)};x(D,_=>{e(d).available&&_(K)})}var X=i(B,2),ve=o(X);{var We=_=>{var N=Gc(),Q=i(o(N),4),he=o(Q);{var we=xe=>{var Ce=Me();L(()=>E(Ce,e(d).error)),n(xe,Ce)},ke=xe=>{var Ce=Me("Connect to Logseq to sync your workspace notes.");n(xe,Ce)};x(he,xe=>{e(d).error?xe(we):xe(ke,!1)})}var Ee=i(Q,2),be=o(Ee);be.__click=F;var De=i(be,2);De.__click=W,n(_,N)},oe=_=>{var N=Fe(),Q=ee(N);{var he=ke=>{var Ee=Kc();n(ke,Ee)},we=ke=>{var Ee=Fe(),be=ee(Ee);{var De=Ce=>{var Ne=Yc(),ue=o(Ne),ze=o(ue),fe=i(ue,2);fe.__click=W,L(()=>E(ze,e(se))),n(Ce,Ne)},xe=Ce=>{var Ne=Fe(),ue=ee(Ne);{var ze=pe=>{var je=Jc();je.__input=de,Zt("blur",je,ce),wa(je,()=>e(f),Ie=>a(f,Ie)),n(pe,je)},fe=pe=>{var je=Xc();je.__click=()=>a(M,!0),je.__keydown=_e=>_e.key==="Enter"&&a(M,!0);var Ie=o(je);Pi(Ie,()=>U(e(f))),n(pe,je)};x(ue,pe=>{e(M)?pe(ze):pe(fe,!1)},!0)}n(Ce,Ne)};x(be,Ce=>{e(se)?Ce(De):Ce(xe,!1)},!0)}n(ke,Ee)};x(Q,ke=>{e(j)?ke(he):ke(we,!1)},!0)}n(_,N)};x(ve,_=>{e(d).available?_(oe,!1):_(We)})}n(O,ie),jt()}oa(["click","input","keydown"]);const so=25*1024*1024,Oa="mnemonic_pending_attachments";function ed(O){if(O.size>so)return{valid:!1,error:`File size exceeds maximum of 25MB. File is ${zs(O.size)}.`};const s=td(O.name);return{valid:!0,metadata:{name:O.name,size:O.size,mimeType:O.type||"application/octet-stream",extension:s}}}function td(O){if(!O)return"";const s=O.lastIndexOf(".");return s<=0?s===0&&O.length>1?O.slice(1).toLowerCase():"":O.slice(s+1).toLowerCase()}function zs(O){if(O===0)return"0 B";const s=["B","KB","MB","GB"],c=1024,p=Math.floor(Math.log(O)/Math.log(c));return`${parseFloat((O/Math.pow(c,p)).toFixed(1))} ${s[p]}`}class ad{constructor(){Ja(this,"filesystemService",Bi())}canStoreInLogseq(){return this.filesystemService.getState().hasAccess}isFilesystemSupported(){return this.filesystemService.isSupported()}async addAttachment(s,c){const p=ed(s);if(!p.valid)throw new Error(p.error);const{metadata:d}=p,f=new Date().toISOString();if(this.canStoreInLogseq())try{const w=await s.arrayBuffer(),M=await this.filesystemService.writeAsset(c,s.name,w),j={originalName:d.name,size:d.size,mimeType:d.mimeType,extension:d.extension,attachedAt:f,storageType:"logseq",logseqAssetPath:M};return Ms(s.name,M,j)}catch(w){console.error("[Attachments] Failed to write to Logseq, falling back to path-only:",w);const M={originalName:d.name,size:d.size,mimeType:d.mimeType,extension:d.extension,attachedAt:f,storageType:"path-only",pendingSync:!0},j=Ms(s.name,"",M);try{await this.queueAttachment(s,c,j.id)}catch(H){console.error("[Attachments] Failed to queue attachment:",H)}return j}else{const w={originalName:d.name,size:d.size,mimeType:d.mimeType,extension:d.extension,attachedAt:f,storageType:"path-only",pendingSync:!0},M=Ms(s.name,"",w);try{await this.queueAttachment(s,c,M.id)}catch(j){console.error("[Attachments] Failed to queue attachment:",j)}return M}}async openAttachment(s){if(s.type!=="attachment"||!s.attachment)return null;const{attachment:c}=s;return c.storageType==="logseq"&&c.logseqAssetPath?await this.filesystemService.getFileUrl(c.logseqAssetPath):null}async verifyAttachment(s){if(s.type!=="attachment"||!s.attachment)return s;const{attachment:c}=s;if(c.storageType==="path-only")return s;if(c.storageType==="logseq"&&c.logseqAssetPath)if(await this.filesystemService.fileExists(c.logseqAssetPath)){const{error:d,...f}=c;return{...s,attachment:f}}else return{...s,attachment:{...c,error:"File not found at expected location"}};return s}async deleteAttachment(s){if(s.type!=="attachment"||!s.attachment)return!1;const{attachment:c}=s;return c.storageType==="logseq"&&c.logseqAssetPath?await this.filesystemService.deleteFile(c.logseqAssetPath):!1}async queueAttachment(s,c,p){try{const d=await s.arrayBuffer(),f=btoa(new Uint8Array(d).reduce((M,j)=>M+String.fromCharCode(j),"")),g={id:p,workspaceId:c,fileName:s.name,mimeType:s.type||"application/octet-stream",size:s.size,base64Data:f,createdAt:new Date().toISOString(),retryCount:0},w=await this.getPendingAttachments();w.push(g),await C.storage.local.set({[Oa]:w}),console.log("[Attachments] Queued attachment for later sync:",s.name)}catch(d){throw console.error("[Attachments] Failed to queue attachment:",d),d}}async getPendingAttachments(){try{return(await C.storage.local.get(Oa))[Oa]||[]}catch(s){return console.error("[Attachments] Failed to get pending queue:",s),[]}}async getPendingCount(){return(await this.getPendingAttachments()).length}async removePendingAttachment(s){const p=(await this.getPendingAttachments()).filter(d=>d.id!==s);await C.storage.local.set({[Oa]:p})}async processPendingQueue(){if(!this.canStoreInLogseq())return console.log("[Attachments] Cannot process queue - no Logseq access"),{processed:0,failed:0,remaining:await this.getPendingCount()};const s=await this.getPendingAttachments();if(s.length===0)return{processed:0,failed:0,remaining:0};console.log(`[Attachments] Processing ${s.length} pending attachments`);let c=0,p=0;const d=[];for(const f of s)try{const g=atob(f.base64Data),w=new Uint8Array(g.length);for(let M=0;M<g.length;M++)w[M]=g.charCodeAt(M);await this.filesystemService.writeAsset(f.workspaceId,f.fileName,w.buffer),console.log("[Attachments] Synced pending attachment:",f.fileName),c++}catch(g){console.error("[Attachments] Failed to sync pending attachment:",f.fileName,g),d.push({...f,retryCount:f.retryCount+1,lastError:g instanceof Error?g.message:"Unknown error"}),p++}return await C.storage.local.set({[Oa]:d}),{processed:c,failed:p,remaining:d.length}}async migratePathOnlyAttachments(s,c){if(!this.canStoreInLogseq())return{migrated:[],failed:[]};const p=[],d=[],f=s.filter(M=>{var j,H;return M.type==="attachment"&&((j=M.attachment)==null?void 0:j.storageType)==="path-only"&&((H=M.attachment)==null?void 0:H.pendingSync)});if(f.length===0)return{migrated:p,failed:d};console.log(`[Attachments] Migrating ${f.length} path-only attachments`);const g=await this.getPendingAttachments(),w=new Map(g.map(M=>[M.id,M]));for(const M of f){const j=w.get(M.id);if(!j){console.warn("[Attachments] No queued data for path-only attachment:",M.title),d.push(M.id);continue}try{const H=atob(j.base64Data),se=new Uint8Array(H.length);for(let Z=0;Z<H.length;Z++)se[Z]=H.charCodeAt(Z);const Y=await this.filesystemService.writeAsset(c,j.fileName,se.buffer),re={...M,value:Y,attachment:{...M.attachment,storageType:"logseq",logseqAssetPath:Y,pendingSync:void 0}};p.push(re),await this.removePendingAttachment(M.id),console.log("[Attachments] Migrated attachment:",M.title)}catch(H){console.error("[Attachments] Failed to migrate attachment:",M.title,H),d.push(M.id)}}return{migrated:p,failed:d}}async clearPendingQueue(){await C.storage.local.remove(Oa),console.log("[Attachments] Cleared pending queue")}}let Is=null;function ro(){return Is||(Is=new ad),Is}const sd={pdf:"document-pdf",doc:"document-word",docx:"document-word",odt:"document-word",rtf:"document-word",xls:"document-excel",xlsx:"document-excel",ods:"document-excel",csv:"document-excel",ppt:"document-powerpoint",pptx:"document-powerpoint",odp:"document-powerpoint",txt:"document-text",md:"document-text",markdown:"document-text",log:"document-text",png:"image",jpg:"image",jpeg:"image",gif:"image",webp:"image",svg:"image",bmp:"image",ico:"image",tiff:"image",tif:"image",mp3:"audio",wav:"audio",ogg:"audio",flac:"audio",m4a:"audio",aac:"audio",wma:"audio",mp4:"video",webm:"video",mov:"video",avi:"video",mkv:"video",wmv:"video",m4v:"video",zip:"archive",rar:"archive","7z":"archive",tar:"archive",gz:"archive",bz2:"archive",xz:"archive",js:"code",ts:"code",jsx:"code",tsx:"code",py:"code",java:"code",c:"code",cpp:"code",h:"code",cs:"code",go:"code",rs:"code",rb:"code",php:"code",html:"code",css:"code",scss:"code",json:"code",xml:"code",yaml:"code",yml:"code",sh:"code",bat:"code",sql:"code"};function rd(O){const s=O.toLowerCase();return sd[s]||"document-generic"}function od(O){return{"document-pdf":"๐Ÿ“„","document-word":"๐Ÿ“","document-excel":"๐Ÿ“Š","document-powerpoint":"๐Ÿ“Š","document-text":"๐Ÿ“ƒ",image:"๐Ÿ–ผ",audio:"๐ŸŽต",video:"๐ŸŽฌ",archive:"๐Ÿ“ฆ",code:"๐Ÿ’ป","document-generic":"๐Ÿ“"}[O]||"๐Ÿ“"}function nd(O){const s=rd(O),c=od(s);return{type:s,emoji:c}}var id=u('<img alt="" class="w-4 h-4 flex-shrink-0 svelte-vyfhib"/>'),ld=u("<span> </span>"),cd=u('<span class="text-xs text-status-error bg-surface px-1.5 py-0.5 rounded flex-shrink-0 svelte-vyfhib">Error</span>'),dd=u('<span class="text-xs text-status-warning bg-surface px-1.5 py-0.5 rounded flex-shrink-0 svelte-vyfhib">Pending</span>'),vd=u('<span class="text-xs text-text-muted bg-surface px-1.5 py-0.5 rounded flex-shrink-0 svelte-vyfhib"> </span>'),ud=u('<div role="button" tabindex="0"><div class="flex items-center gap-2 flex-1 min-w-0 svelte-vyfhib"><!> <span> </span> <!></div> <div class="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0 svelte-vyfhib"><button class="p-1 hover:bg-surface rounded text-text-muted hover:text-phosphor transition-colors svelte-vyfhib" title="Remove resource"><svg class="w-4 h-4 svelte-vyfhib" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" class="svelte-vyfhib"></path></svg></button></div></div>');function pd(O,s){Ft(s,!0);let c=qt(s,"highlight",3,!1);const p=ro();let d=b(!1);async function f(){if(s.resource.type==="logseq"){if(!s.graphName){alert("Logseq graph not configured. Please configure Logseq in settings.");return}if(!s.logseqConnected){alert("Logseq is not connected. Please ensure Logseq is running.");return}const B=Ui(s.graphName,s.resource.value);window.open(B,"_blank")}else s.resource.type==="attachment"?await g():window.open(s.resource.value,"_blank")}async function g(){if(s.resource.attachment){if(s.resource.attachment.error){alert(`Cannot open file: ${s.resource.attachment.error}`);return}if(s.resource.attachment.storageType==="path-only"&&!s.resource.attachment.logseqAssetPath){alert("This attachment is stored as a reference only. Grant graph access in settings to enable file storage.");return}a(d,!0);try{const B=await p.openAttachment(s.resource);B?window.open(B,"_blank"):alert("Could not open attachment. The file may have been moved or deleted.")}catch(B){console.error("[ResourceItem] Failed to open attachment:",B),alert("Failed to open attachment.")}finally{a(d,!1)}}}function w(B){B.stopPropagation(),s.onRemove(s.resource.id)}const M=me(()=>s.resource.type==="logseq"?"๐Ÿ“":s.resource.type==="attachment"&&s.resource.attachment?nd(s.resource.attachment.extension).emoji:"๐Ÿ”—"),j=me(()=>s.resource.type==="logseq"?"Logseq":s.resource.type==="attachment"&&s.resource.attachment?zs(s.resource.attachment.size):"URL"),H=me(()=>{var B;return s.resource.type==="attachment"&&((B=s.resource.attachment)==null?void 0:B.error)}),se=me(()=>{var B;return s.resource.type==="attachment"&&((B=s.resource.attachment)==null?void 0:B.pendingSync)});var Y=ud();let re;Y.__click=f,Y.__keydown=B=>B.key==="Enter"&&f();var Z=o(Y),P=o(Z);{var q=B=>{var V=id();L(()=>Ct(V,"src",s.resource.favIconUrl)),Zt("error",V,A=>A.currentTarget.style.display="none"),n(B,V)},te=B=>{var V=ld();let A;var S=o(V);L(()=>{A=Oe(V,1,"text-sm flex-shrink-0 svelte-vyfhib",null,A,{"error-icon":e(H)}),E(S,e(M))}),n(B,V)};x(P,B=>{s.resource.type==="url"&&s.resource.favIconUrl?B(q):B(te,!1)})}var G=i(P,2);let de;var ce=o(G),F=i(G,2);{var W=B=>{var V=cd();L(()=>{var A;return Ct(V,"title",(A=s.resource.attachment)==null?void 0:A.error)}),n(B,V)},R=B=>{var V=Fe(),A=ee(V);{var S=D=>{var K=dd();n(D,K)},$=D=>{var K=vd(),X=o(K);L(()=>E(X,e(j))),n(D,K)};x(A,D=>{e(se)?D(S):D($,!1)},!0)}n(B,V)};x(F,B=>{e(H)?B(W):B(R,!1)})}var U=i(Z,2),ie=o(U);ie.__click=w,L(()=>{re=Oe(Y,1,"resource-item group svelte-vyfhib",null,re,{"has-error":e(H),"is-pending":e(se),"is-opening":e(d),"flash-highlight":c()}),Ct(Y,"data-resource-id",s.resource.id),de=Oe(G,1,"text-text truncate svelte-vyfhib",null,de,{"error-text":e(H)}),Ct(G,"title",s.resource.title),E(ce,s.resource.title)}),n(O,Y),jt()}oa(["click","keydown"]);var hd=u('<div class="text-center py-4 text-red-400 text-sm"> <button class="ml-2 text-phosphor underline">Retry</button></div>'),fd=u('<div class="text-center py-4 text-text-muted"><span class="animate-pulse">Loading pages from Logseq...</span></div>'),gd=vt('<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path></svg>'),md=u('<button><span><!></span> <span class="page-name svelte-9k0e5m"> </span></button>'),kd=u('<button class="btn-primary w-full svelte-9k0e5m"> </button>'),wd=u('<div class="search-results svelte-9k0e5m"></div> <!>',1),_d=u('<div class="text-center py-4 text-text-muted text-sm"> </div>'),bd=u('<div class="text-center py-4 text-text-muted text-sm"> </div>'),yd=u('<div class="text-center py-4 text-text-muted text-sm">Enter at least 2 characters to search</div>'),xd=u('<div class="space-y-4"><div><label class="block text-sm font-medium text-text mb-1.5" for="logseq-search">Search for pages</label> <input id="logseq-search" type="text" class="input-field svelte-9k0e5m" placeholder="Type to search pages..."/> <label class="flex items-center gap-2 mt-2 text-sm text-text-muted cursor-pointer"><input type="checkbox" class="checkbox-input svelte-9k0e5m"/> <span>Include workspace notes (Mnemonic/...)</span></label></div> <!></div>'),Cd=u('<p class="mt-1 text-sm text-red-400"> </p>'),Sd=u('<div class="space-y-4"><div><label class="block text-sm font-medium text-text mb-1.5" for="url-input">URL</label> <input id="url-input" type="url" class="input-field svelte-9k0e5m" placeholder="https://example.com"/> <!></div> <div><label class="block text-sm font-medium text-text mb-1.5" for="url-title">Title (optional)</label> <input id="url-title" type="text" class="input-field svelte-9k0e5m" placeholder="Enter a title or leave empty to use hostname"/></div> <button class="btn-primary w-full svelte-9k0e5m">Add URL</button></div>'),Td=u('<div class="modal-overlay svelte-9k0e5m" role="dialog" aria-modal="true"><div class="modal-backdrop svelte-9k0e5m" role="presentation"></div> <div class="modal-content svelte-9k0e5m"><div class="modal-header svelte-9k0e5m"><h2 class="text-lg font-semibold text-phosphor">Add Resource</h2> <button class="text-text-muted hover:text-phosphor transition-colors p-1" aria-label="Close"><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg></button></div> <div class="tabs svelte-9k0e5m"><button>Search Logseq</button> <button>Add URL</button></div> <div class="modal-body svelte-9k0e5m"><!></div></div></div>');function Md(O,s){Ft(s,!0);let c=qt(s,"open",15),p=b("url"),d=b(""),f=b(dt([])),g=b(dt(new Set)),w=b(dt([])),M=b(!1),j=b(!1),H=b(null),se=b(!1),Y=b(""),re=b(""),Z=b(null);const P=Qa();Kt(()=>{c()&&s.logseqConnected&&e(p)==="logseq"&&!e(j)&&!e(M)&&de()});let q=b(!1);Kt(()=>{c()&&!e(q)&&s.logseqConnected&&a(p,"logseq"),a(q,c(),!0)}),Kt(()=>{c()&&(a(d,""),a(f,[],!0),a(g,new Set,!0),a(Y,""),a(re,""),a(Z,null),s.logseqConnected||a(p,"url"))});let te=b(0);Kt(()=>{if(e(d).trim().length>=2&&e(j)){const D=e(d).toLowerCase(),K=e(w).filter(X=>!e(se)&&X.name.startsWith("mnemonic/")?!1:X.name.includes(D)||X.displayName.toLowerCase().includes(D)).slice(0,50);a(f,K,!0),a(te,K.reduce((X,ve)=>Math.max(X,ve.displayName.length),0),!0)}else a(f,[],!0),a(te,0)});const G=me(()=>()=>{const ve=Math.max(400,e(te)*8+150),We=typeof window<"u"?window.innerWidth*.66:900;return Math.min(ve,We)});async function de(){if(!(e(j)||e(M))){a(M,!0),a(H,null);try{console.log("[AddResourceModal] Loading page cache...");const D=await P.getAllPageNames();D&&D.length>0?(a(w,D,!0),a(j,!0),console.log(`[AddResourceModal] Cached ${D.length} pages`)):(console.warn("[AddResourceModal] No pages returned from getAllPageNames"),a(H,"No pages found in Logseq graph"))}catch(D){console.error("[AddResourceModal] Failed to load page cache:",D),a(H,"Failed to load pages from Logseq")}finally{a(M,!1)}}}function ce(D){const K=new Set(e(g));K.has(D.name)?K.delete(D.name):K.add(D.name),a(g,K,!0)}function F(D){return e(g).has(D)}function W(){if(e(g).size===0)return;const D=[];for(const K of e(g)){const X=e(w).find(ve=>ve.name===K);X&&D.push(Xa("logseq",X.displayName,X.name))}D.length>0&&s.onAdd(D),U()}function R(){if(console.log("[AddResourceModal] addUrl called, urlInput:",e(Y)),a(Z,null),!e(Y).trim()){a(Z,"Please enter a URL"),console.log("[AddResourceModal] Error: empty URL");return}if(!ao(e(Y))){a(Z,"Please enter a valid HTTP or HTTPS URL"),console.log("[AddResourceModal] Error: invalid URL");return}const D=e(re).trim()||new URL(e(Y)).hostname,K=Xa("url",D,e(Y));console.log("[AddResourceModal] Adding URL resource:",K),s.onAdd([K]),U()}function U(){c(!1),s.onClose()}function ie(D){D.key==="Enter"&&R()}function B(D){D.key==="Escape"&&U()}function V(D){D.target===D.currentTarget&&U()}var A=Fe();Zt("keydown",Ai,B);var S=ee(A);{var $=D=>{var K=Td(),X=o(K);X.__click=V;var ve=i(X,2),We=o(ve),oe=i(o(We),2);oe.__click=U;var _=i(We,2),N=o(_);let Q;N.__click=()=>s.logseqConnected&&a(p,"logseq");var he=i(N,2);let we;he.__click=()=>a(p,"url");var ke=i(_,2),Ee=o(ke);{var be=xe=>{var Ce=xd(),Ne=o(Ce),ue=i(o(Ne),2),ze=i(ue,2),fe=o(ze),pe=i(Ne,2);{var je=_e=>{var Ae=hd(),He=o(Ae),Ue=i(He);Ue.__click=de,L(()=>E(He,`${e(H)??""} `)),n(_e,Ae)},Ie=_e=>{var Ae=Fe(),He=ee(Ae);{var Ue=_t=>{var ne=fd();n(_t,ne)},Xe=_t=>{var ne=Fe(),ge=ee(ne);{var Le=Ve=>{var qe=wd(),Re=ee(qe);wt(Re,21,()=>e(f),Ze=>Ze.name,(Ze,ye)=>{var J=md();let at;J.__click=()=>ce(e(ye));var nt=o(J);let ht;var tt=o(nt);{var Mt=gt=>{var Ut=gd();n(gt,Ut)};x(tt,gt=>{F(e(ye).name)&&gt(Mt)})}var ft=i(nt,2),St=o(ft);L((gt,Ut)=>{at=Oe(J,1,"search-result svelte-9k0e5m",null,at,gt),Ct(J,"title",e(ye).displayName),ht=Oe(nt,1,"checkbox svelte-9k0e5m",null,ht,Ut),E(St,e(ye).displayName)},[()=>({selected:F(e(ye).name)}),()=>({checked:F(e(ye).name)})]),n(Ze,J)});var pt=i(Re,2);{var ot=Ze=>{var ye=kd();ye.__click=W;var J=o(ye);L(()=>E(J,`Add ${e(g).size??""} Page${e(g).size>1?"s":""}`)),n(Ze,ye)};x(pt,Ze=>{e(g).size>0&&Ze(ot)})}n(Ve,qe)},ut=Ve=>{var qe=Fe(),Re=ee(qe);{var pt=Ze=>{var ye=_d(),J=o(ye);L(()=>E(J,`No pages found matching "${e(d)??""}"`)),n(Ze,ye)},ot=Ze=>{var ye=Fe(),J=ee(ye);{var at=ht=>{var tt=bd(),Mt=o(tt);L(()=>E(Mt,`Enter at least 2 characters to search (${e(w).length??""} pages available)`)),n(ht,tt)},nt=ht=>{var tt=yd();n(ht,tt)};x(J,ht=>{e(j)?ht(at):ht(nt,!1)},!0)}n(Ze,ye)};x(Re,Ze=>{e(d).length>=2?Ze(pt):Ze(ot,!1)},!0)}n(Ve,qe)};x(ge,Ve=>{e(f).length>0?Ve(Le):Ve(ut,!1)},!0)}n(_t,ne)};x(He,_t=>{e(M)?_t(Ue):_t(Xe,!1)},!0)}n(_e,Ae)};x(pe,_e=>{e(H)?_e(je):_e(Ie,!1)})}wa(ue,()=>e(d),_e=>a(d,_e)),rs(fe,()=>e(se),_e=>a(se,_e)),n(xe,Ce)},De=xe=>{var Ce=Sd(),Ne=o(Ce),ue=i(o(Ne),2);ue.__keydown=ie;var ze=i(ue,2);{var fe=_e=>{var Ae=Cd(),He=o(Ae);L(()=>E(He,e(Z))),n(_e,Ae)};x(ze,_e=>{e(Z)&&_e(fe)})}var pe=i(Ne,2),je=i(o(pe),2),Ie=i(pe,2);Ie.__click=R,wa(ue,()=>e(Y),_e=>a(Y,_e)),wa(je,()=>e(re),_e=>a(re,_e)),n(xe,Ce)};x(Ee,xe=>{e(p)==="logseq"?xe(be):xe(De,!1)})}L(xe=>{Ia(ve,`width: ${xe??""}px;`),Q=Oe(N,1,"tab svelte-9k0e5m",null,Q,{active:e(p)==="logseq",disabled:!s.logseqConnected}),N.disabled=!s.logseqConnected,Ct(N,"title",s.logseqConnected?"":"Logseq is not connected"),we=Oe(he,1,"tab svelte-9k0e5m",null,we,{active:e(p)==="url"})},[()=>e(G)()]),n(D,K)};x(S,D=>{c()&&D($)})}n(O,A),jt()}oa(["click","keydown"]);var Id=u('<div class="resources-list svelte-q3v3l5"></div>'),Ad=u('<div class="empty-state svelte-q3v3l5"><p class="text-text-muted text-sm">No resources yet</p> <p class="text-text-muted text-xs mt-1">Drag URLs, files, or markdown here, or click "Add" to search</p></div>'),Ed=u('<div class="drop-overlay svelte-q3v3l5"><div class="drop-message svelte-q3v3l5"><svg class="w-8 h-8 text-phosphor mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path></svg> <span class="text-phosphor font-medium">Drop to add resource</span></div></div>'),Pd=u('<div><div class="flex items-center justify-between mb-4"><h3 class="text-lg text-phosphor"> </h3> <button class="btn-secondary text-sm px-3 py-1 svelte-q3v3l5">+ Add</button></div> <div role="region" aria-label="Drop files or URLs here to add as resources"><!> <!></div></div> <!>',1);function zd(O,s){Ft(s,!0);let c=qt(s,"highlightResourceId",3,null);const p=ro();let d=b(!1),f=b(!1);const g=Qa();function w(A){var $,D;A.preventDefault();const S=(D=($=A.dataTransfer)==null?void 0:$.types)==null?void 0:D.includes("application/json");A.dataTransfer.dropEffect=S?"move":"copy",a(f,!0)}function M(A){const S=A.currentTarget.getBoundingClientRect();(A.clientX<S.left||A.clientX>=S.right||A.clientY<S.top||A.clientY>=S.bottom)&&a(f,!1)}async function j(A){var D,K,X,ve,We;A.preventDefault(),a(f,!1);const S=(D=A.dataTransfer)==null?void 0:D.getData("application/json");if(S)try{const oe=JSON.parse(S);if(oe.type==="tab"&&oe.tab&&s.onTabDrop){s.onTabDrop({tab:oe.tab,tabIndex:oe.tabIndex,sourceWorkspaceId:oe.sourceWorkspaceId});return}}catch{}if((X=(K=A.dataTransfer)==null?void 0:K.files)!=null&&X.length){for(const oe of A.dataTransfer.files)oe.name.endsWith(".md")||oe.name.endsWith(".markdown")?await se(oe):await H(oe);return}const $=((ve=A.dataTransfer)==null?void 0:ve.getData("text/uri-list"))||((We=A.dataTransfer)==null?void 0:We.getData("text/plain"));$&&ao($.trim())&&await Y($.trim())}async function H(A){if(A.size>so){alert(`File too large. Maximum size is 25MB. Your file is ${zs(A.size)}.`);return}try{const S=await p.addAttachment(A,s.workspaceId);s.onAddResources([S]),console.log("[Resources] Added file attachment:",A.name)}catch(S){console.error("[Resources] Failed to add file attachment:",S),alert(S instanceof Error?S.message:"Failed to add file attachment.")}}async function se(A){if(!s.logseqConnected||!s.graphName){alert("Logseq must be connected to upload markdown files.");return}try{const S=await A.text(),$=Hi(S)||A.name.replace(/\.md$|\.markdown$/i,"");await g.getOrCreatePage($),await g.appendBlockToPage($,S);const D=Xa("logseq",$,$);s.onAddResources([D]),console.log("[Resources] Created Logseq page from markdown:",$)}catch(S){console.error("[Resources] Failed to create Logseq page:",S),alert("Failed to create Logseq page from markdown file.")}}async function Y(A){try{let S;try{const D=new URL(A);S=D.hostname+D.pathname,S.length>50&&(S=D.hostname)}catch{S=A}const $=Xa("url",S,A);s.onAddResources([$]),console.log("[Resources] Added URL resource:",A)}catch(S){console.error("[Resources] Failed to add URL:",S)}}var re=Pd(),Z=ee(re);let P;var q=o(Z),te=o(q),G=o(te),de=i(te,2);de.__click=()=>a(d,!0);var ce=i(q,2);let F;var W=o(ce);{var R=A=>{var S=Id();wt(S,21,()=>s.resources,$=>$.id,($,D)=>{{let K=me(()=>c()===e(D).id);pd($,{get resource(){return e(D)},get graphName(){return s.graphName},get logseqConnected(){return s.logseqConnected},get onRemove(){return s.onRemoveResource},get highlight(){return e(K)}})}}),n(A,S)},U=A=>{var S=Ad();n(A,S)};x(W,A=>{s.resources.length>0?A(R):A(U,!1)})}var ie=i(W,2);{var B=A=>{var S=Ed();n(A,S)};x(ie,A=>{e(f)&&A(B)})}var V=i(Z,2);Md(V,{get open(){return e(d)},get logseqConnected(){return s.logseqConnected},onClose:()=>a(d,!1),get onAdd(){return s.onAddResources}}),L(()=>{P=Oe(Z,1,"panel resources-panel svelte-q3v3l5",null,P,{"drag-over":e(f)}),E(G,`Resources (${s.resources.length??""})`),F=Oe(ce,1,"drop-zone svelte-q3v3l5",null,F,{active:e(f)})}),Zt("dragover",ce,w),Zt("dragleave",ce,M),Zt("drop",ce,j),n(O,re),jt()}oa(["click"]);var Ld=u('<button type="button"> </button>'),Rd=u('<div class="task-editor svelte-c5fw8b"><input type="text" class="task-input svelte-c5fw8b" placeholder="Task name"/> <textarea class="description-input svelte-c5fw8b" placeholder="Description (optional)" rows="2"></textarea> <div class="editor-row svelte-c5fw8b"><div class="field svelte-c5fw8b"><label for="due-input" class="svelte-c5fw8b">Due</label> <input id="due-input" type="text" class="due-input svelte-c5fw8b" placeholder="e.g., tomorrow, next Monday"/></div> <div class="field svelte-c5fw8b"><label class="svelte-c5fw8b">Priority</label> <div class="priority-buttons svelte-c5fw8b"></div></div></div> <div class="editor-actions svelte-c5fw8b"><button type="button" class="btn-cancel svelte-c5fw8b">Cancel</button> <button type="button" class="btn-save svelte-c5fw8b"> </button></div> <div class="hint svelte-c5fw8b"><kbd class="svelte-c5fw8b">Ctrl</kbd>+<kbd class="svelte-c5fw8b">Enter</kbd> to save, <kbd class="svelte-c5fw8b">Esc</kbd> to cancel</div></div>');function oo(O,s){var U,ie,B,V,A;Ft(s,!0);let c=qt(s,"task",3,null),p=b(dt(((U=c())==null?void 0:U.content)||"")),d=b(dt(((ie=c())==null?void 0:ie.description)||"")),f=b(dt(((V=(B=c())==null?void 0:B.due)==null?void 0:V.string)||"")),g=b(dt(((A=c())==null?void 0:A.priority)||1)),w=b(!1);const M=me(()=>e(p).trim().length>0),j=me(()=>c()!==null);async function H(){if(e(M)){a(w,!0);try{if(e(j)&&c()){const S={taskId:c().id,content:e(p),description:e(d)||void 0,dueString:e(f)||void 0,priority:e(g)};await ka.updateTask(S),s.onSave(S)}else{const S={content:e(p),description:e(d)||void 0,dueString:e(f)||void 0,priority:e(g)};s.onSave(S)}}finally{a(w,!1)}}}function se(S){S.key==="Enter"&&(S.metaKey||S.ctrlKey)&&H(),S.key==="Escape"&&s.onCancel()}var Y=Rd();Y.__keydown=se;var re=o(Y),Z=i(re,2),P=i(Z,2),q=o(P),te=i(o(q),2),G=i(q,2),de=i(o(G),2);wt(de,20,()=>[4,3,2,1],ea,(S,$)=>{const D=me(()=>Es[$]);var K=Ld();let X;K.__click=()=>a(g,$,!0);var ve=o(K);L(()=>{X=Oe(K,1,"priority-btn svelte-c5fw8b",null,X,{selected:e(g)===$}),Ia(K,`--priority-color: ${e(D).color??""}`),E(ve,e(D).label)}),n(S,K)});var ce=i(P,2),F=o(ce);F.__click=function(...S){var $;($=s.onCancel)==null||$.apply(this,S)};var W=i(F,2);W.__click=H;var R=o(W);L(()=>{W.disabled=!e(M)||e(w),E(R,e(w)?"Saving...":e(j)?"Save":"Add Task")}),wa(re,()=>e(p),S=>a(p,S)),wa(Z,()=>e(d),S=>a(d,S)),wa(te,()=>e(f),S=>a(f,S)),n(O,Y),jt()}oa(["keydown","click"]);var Wd=u('<span class="task-description svelte-1qhbjux"> </span>'),Bd=u("<span> </span>"),Dd=u('<span class="label svelte-1qhbjux"> </span>'),Nd=u('<span class="labels svelte-1qhbjux"></span>'),qd=u("<span></span>"),Od=u('<div><button><!></button> <div class="task-content svelte-1qhbjux"><span class="task-text svelte-1qhbjux"> </span> <!> <div class="task-meta svelte-1qhbjux"><!> <!></div></div> <div class="priority-indicator svelte-1qhbjux"></div> <div class="task-actions svelte-1qhbjux"><button class="btn-action svelte-1qhbjux" title="Edit">&#9998;</button> <button class="btn-action btn-delete svelte-1qhbjux" title="Delete">&#128465;</button></div></div>');function Fd(O,s){Ft(s,!0);let c=b(!1),p=b(!1);const d=me(()=>Es[s.task.priority]||Es[1]),f=me(()=>w(s.task.due)),g=me(()=>{var P;return((P=s.task.due)==null?void 0:P.date)&&new Date(s.task.due.date)<new Date&&!s.task.isCompleted});function w(P){if(!(P!=null&&P.date))return"";const q=new Date(P.date),te=new Date,G=new Date(te);return G.setDate(G.getDate()+1),q.toDateString()===te.toDateString()?"Today":q.toDateString()===G.toDateString()?"Tomorrow":q.toLocaleDateString("en-US",{month:"short",day:"numeric"})}async function M(){a(p,!0),await ka.toggleComplete(s.task.id),a(p,!1)}async function j(){confirm("Delete this task?")&&await ka.deleteTask(s.task.id)}function H(){a(c,!1)}var se=Fe(),Y=ee(se);{var re=P=>{oo(P,{get task(){return s.task},onSave:H,onCancel:()=>a(c,!1)})},Z=P=>{var q=Od();let te;var G=o(q);let de;G.__click=M;var ce=o(G);{var F=oe=>{var _=Me("โœ“");n(oe,_)};x(ce,oe=>{s.task.isCompleted&&oe(F)})}var W=i(G,2);W.__dblclick=()=>a(c,!0);var R=o(W),U=o(R),ie=i(R,2);{var B=oe=>{var _=Wd(),N=o(_);L(()=>E(N,s.task.description)),n(oe,_)};x(ie,oe=>{s.task.description&&oe(B)})}var V=i(ie,2),A=o(V);{var S=oe=>{var _=Bd();let N;var Q=o(_);L(()=>{N=Oe(_,1,"due-date svelte-1qhbjux",null,N,{overdue:e(g)}),E(Q,`๐Ÿ“… ${e(f)??""}`)}),n(oe,_)};x(A,oe=>{e(f)&&oe(S)})}var $=i(A,2);{var D=oe=>{var _=Nd();wt(_,21,()=>s.task.labels,ea,(N,Q)=>{var he=Dd(),we=o(he);L(()=>E(we,`@${e(Q)??""}`)),n(N,he)}),n(oe,_)};x($,oe=>{var _;(_=s.task.labels)!=null&&_.length&&oe(D)})}var K=i(W,2);wt(K,20,()=>Array(4),ea,(oe,_,N)=>{var Q=qd();let he;L(()=>{he=Oe(Q,1,"dot svelte-1qhbjux",null,he,{filled:N<e(d).dots}),Ia(Q,`--dot-color: ${e(d).color??""}`)}),n(oe,Q)});var X=i(K,2),ve=o(X);ve.__click=()=>a(c,!0);var We=i(ve,2);We.__click=j,L(()=>{te=Oe(q,1,"task-item svelte-1qhbjux",null,te,{completed:s.task.isCompleted,overdue:e(g)}),de=Oe(G,1,"checkbox svelte-1qhbjux",null,de,{checked:s.task.isCompleted,completing:e(p)}),Ia(G,`--priority-color: ${e(d).color??""}`),G.disabled=e(p),Ct(G,"aria-label",s.task.isCompleted?"Mark as incomplete":"Mark as complete"),E(U,s.task.content),Ct(K,"title",e(d).label)}),n(P,q)};x(Y,P=>{e(c)?P(re):P(Z,!1)})}n(O,se),jt()}oa(["click","dblclick"]);var jd=u('<div class="auth-tabs svelte-h4d7cq"><button>OAuth Login</button> <button>API Token</button></div>'),Ud=u('<span class="spinner svelte-h4d7cq"></span> Connecting...',1),Hd=u('<div class="oauth-section svelte-h4d7cq"><p class="description svelte-h4d7cq">Sign in with your Todoist account to grant access.</p> <button class="btn-primary oauth-button svelte-h4d7cq"><!></button></div>'),Vd=u('<div class="token-section svelte-h4d7cq"><div class="field svelte-h4d7cq"><label for="api-token" class="svelte-h4d7cq">API Token</label> <input id="api-token" type="password" placeholder="Enter your Todoist API token" class="svelte-h4d7cq"/> <p class="hint svelte-h4d7cq">Find your token at <a href="https://todoist.com/app/settings/integrations/developer" target="_blank" rel="noopener noreferrer" class="svelte-h4d7cq">Todoist Settings > Integrations > Developer</a></p></div></div>'),$d=u('<div class="error-message svelte-h4d7cq"> </div>'),Gd=u('<p class="sync-time svelte-h4d7cq"> </p>'),Kd=u('<div class="connection-status success svelte-h4d7cq"><span class="status-icon svelte-h4d7cq">&#10003;</span> <div><strong class="svelte-h4d7cq">Connected</strong> <p class="svelte-h4d7cq"> </p> <!></div></div>'),Yd=u('<div class="todoist-settings svelte-h4d7cq"><!> <!> <!> <!> <div class="info-box svelte-h4d7cq"><h4 class="svelte-h4d7cq">How it works</h4> <ul class="svelte-h4d7cq"><li class="svelte-h4d7cq">A "Mnemonic" project will be created in your Todoist</li> <li class="svelte-h4d7cq">Each workspace gets a sub-project under Mnemonic</li> <li class="svelte-h4d7cq">Child workspaces become sub-projects of their parent</li> <li class="svelte-h4d7cq">Tasks sync with Todoist</li></ul></div></div>'),Jd=u('<button class="btn-danger svelte-h4d7cq">Disconnect</button>'),Xd=u('<button class="btn-secondary svelte-h4d7cq"> </button> <button class="btn-primary svelte-h4d7cq"> </button>',1),Qd=u('<div class="modal-footer svelte-h4d7cq" slot="footer"><!> <div class="footer-right svelte-h4d7cq"><!></div></div>');function Zd(O,s){Ft(s,!0);let c=b("api_token"),p=b(""),d=b(null),f=b(!1),g=b(!1),w=b(null),M=b(!1);Kt(()=>{s.open&&(j(),a(M,Cs.isOAuthConfigured(),!0))});async function j(){const Z=await Cs.loadSettings();Z.accessToken&&(a(p,Z.accessToken.substring(0,8)+"..."),a(c,Z.authMethod||"api_token",!0),a(f,!0),a(d,await ra.initializeFromStorage(),!0),a(f,!1))}async function H(){if(!e(p).trim()||e(p).includes("...")){a(w,"Please enter your API token");return}a(f,!0),a(w,null);try{a(d,await ra.initialize(e(p)),!0),e(d).connected||a(w,e(d).error||"Connection failed",!0)}catch(Z){a(w,Z instanceof Error?Z.message:"Connection failed",!0)}finally{a(f,!1)}}async function se(){var Z;if(!e(M)){a(w,"OAuth is not configured. Please use API token authentication.");return}a(f,!0),a(w,null);try{const P=await Cs.launchOAuthFlow();P.success?(a(d,await ra.initializeFromStorage(),!0),e(d).connected?(await Wt.loadMappings(),(Z=s.onConnected)==null||Z.call(s)):a(w,e(d).error||"Connection failed after OAuth",!0)):a(w,P.error||"OAuth failed",!0)}catch(P){a(w,P instanceof Error?P.message:"OAuth failed",!0)}finally{a(f,!1)}}async function Y(){var Z,P,q;if(!(!((Z=e(d))!=null&&Z.connected)&&(await H(),!((P=e(d))!=null&&P.connected)))){a(g,!0);try{await Wt.loadMappings(),(q=s.onConnected)==null||q.call(s),s.onClose()}catch(te){a(w,te instanceof Error?te.message:"Failed to save settings",!0)}finally{a(g,!1)}}}async function re(){await ra.disconnect(),await Wt.clearAllMappings(),a(p,""),a(d,null),s.onClose()}sa(O,{get open(){return s.open},get onClose(){return s.onClose},title:"Todoist Integration",children:(Z,P)=>{var q=Yd(),te=o(q);{var G=B=>{var V=jd(),A=o(V);let S;A.__click=()=>a(c,"oauth");var $=i(A,2);let D;$.__click=()=>a(c,"api_token"),L(()=>{S=Oe(A,1,"auth-tab svelte-h4d7cq",null,S,{active:e(c)==="oauth"}),D=Oe($,1,"auth-tab svelte-h4d7cq",null,D,{active:e(c)==="api_token"})}),n(B,V)};x(te,B=>{e(M)&&B(G)})}var de=i(te,2);{var ce=B=>{var V=Hd(),A=i(o(V),2);A.__click=se;var S=o(A);{var $=K=>{var X=Ud();n(K,X)},D=K=>{var X=Me("Sign in with Todoist");n(K,X)};x(S,K=>{e(f)?K($):K(D,!1)})}L(()=>A.disabled=e(f)),n(B,V)},F=B=>{var V=Vd(),A=o(V),S=i(o(A),2);L(()=>{var $;return S.disabled=($=e(d))==null?void 0:$.connected}),wa(S,()=>e(p),$=>a(p,$)),n(B,V)};x(de,B=>{e(c)==="oauth"&&e(M)?B(ce):B(F,!1)})}var W=i(de,2);{var R=B=>{var V=$d(),A=o(V);L(()=>E(A,e(w))),n(B,V)};x(W,B=>{e(w)&&B(R)})}var U=i(W,2);{var ie=B=>{var V=Kd(),A=i(o(V),2),S=i(o(A),2),$=o(S),D=i(S,2);{var K=X=>{var ve=Gd(),We=o(ve);L(oe=>E(We,`Last sync: ${oe??""}`),[()=>new Date(e(d).lastSync).toLocaleString()]),n(X,ve)};x(D,X=>{e(d).lastSync&&X(K)})}L(()=>E($,`Master project: ${e(d).masterProjectName??""}`)),n(B,V)};x(U,B=>{var V;(V=e(d))!=null&&V.connected&&B(ie)})}n(Z,q)},$$slots:{default:!0,footer:(Z,P)=>{var q=Qd(),te=o(q);{var G=W=>{var R=Jd();R.__click=re,n(W,R)};x(te,W=>{var R;(R=e(d))!=null&&R.connected&&W(G)})}var de=i(te,2),ce=o(de);{var F=W=>{var R=Xd(),U=ee(R);U.__click=H;var ie=o(U),B=i(U,2);B.__click=Y;var V=o(B);L(()=>{var A;U.disabled=e(f)||((A=e(d))==null?void 0:A.connected),E(ie,e(f)?"Testing...":"Test Connection"),B.disabled=e(g)||e(f),E(V,e(g)?"Saving...":"Save")}),n(W,R)};x(ce,W=>{(e(c)==="api_token"||!e(M))&&W(F)})}n(Z,q)}}}),jt()}oa(["click"]);var ev=u('<button class="btn-icon svelte-ggenkx" title="Add task" aria-label="Add task">+</button> <button title="Sync with Todoist" aria-label="Sync with Todoist">&#8635;</button>',1),tv=u('<div class="not-connected svelte-ggenkx"><p>Connect to Todoist to manage tasks</p> <button class="btn-primary svelte-ggenkx">Connect</button></div>'),av=u('<div class="loading svelte-ggenkx"><span class="spinner svelte-ggenkx"></span> Loading tasks...</div>'),sv=u('<div class="error svelte-ggenkx"><p class="svelte-ggenkx"> </p> <button class="btn-text svelte-ggenkx">Dismiss</button></div>'),rv=u('<div class="not-synced svelte-ggenkx"><p>Todoist project not created yet</p> <button class="btn-primary svelte-ggenkx"> </button> <p class="hint svelte-ggenkx">This creates a project in Todoist for this workspace</p></div>'),ov=u('<div class="empty-state svelte-ggenkx"><p>No tasks yet</p> <button type="button" class="add-task-btn svelte-ggenkx">+ Add your first task</button></div>'),nv=u('<!> <div class="task-list svelte-ggenkx"></div> <footer class="card-footer svelte-ggenkx"><button type="button" class="btn-text svelte-ggenkx"> </button> <span class="task-count svelte-ggenkx"> </span></footer>',1),iv=u('<div class="panel todoist-card svelte-ggenkx"><header class="card-header svelte-ggenkx"><div class="header-left svelte-ggenkx"><span class="card-icon svelte-ggenkx">&#128203;</span> <h3 class="svelte-ggenkx"> </h3></div> <div class="header-actions svelte-ggenkx"><!> <button class="btn-icon svelte-ggenkx" title="Settings" aria-label="Todoist settings">&#9881;</button></div></header> <!></div> <!>',1);function lv(O,s){Ft(s,!0);let c=b(!1),p=b(!1),d=b(!1),f=b(!1),g=b(void 0),w=b(dt([])),M=b(!1),j=b(null),H=b(!1),se=null;Ps(()=>(re(),se=ka.subscribe(()=>{Y()}),()=>{se&&se()}));function Y(){const X=ka.getState();a(w,ka.getWorkspaceTasks(s.workspace.id),!0),a(M,X.loading,!0),a(j,X.error,!0),a(H,X.filter.showCompleted,!0)}async function re(){const X=await ra.initializeFromStorage();a(f,X.connected,!0),console.log("[Mnemonic/Todoist] TodoistCard checkConnection: isConnected =",e(f)),e(f)&&(await Wt.loadMappings(),a(g,await Wt.getProjectId(s.workspace.id),!0),console.log("[Mnemonic/Todoist] TodoistCard checkConnection: projectId for workspace",s.workspace.name,"=",e(g)),e(g)||(console.log("[Mnemonic/Todoist] TodoistCard checkConnection: No mapping found, attempting to detect existing project..."),(await Wt.detectAndLinkExistingProjects([s.workspace])).size>0?(a(g,await Wt.getProjectId(s.workspace.id),!0),console.log("[Mnemonic/Todoist] TodoistCard checkConnection: Auto-linked to project:",e(g))):console.log("[Mnemonic/Todoist] TodoistCard checkConnection: No matching project found for workspace:",s.workspace.name)),e(g)&&(await ka.loadWorkspaceTasks(s.workspace.id),Y()))}async function Z(){if(e(f)){a(d,!0);try{if(console.log("[Mnemonic/Todoist] handleSync: Starting sync for workspace:",s.workspace.name),e(g)){console.log("[Mnemonic/Todoist] handleSync: Verifying existing mapping, projectId:",e(g));try{await ra.getProject(e(g)),console.log("[Mnemonic/Todoist] handleSync: Project still exists in Todoist")}catch{console.log("[Mnemonic/Todoist] handleSync: Project not found in Todoist, clearing mapping and rescanning..."),await Wt.removeMapping(s.workspace.id,!1),a(g,void 0),(await Wt.detectAndLinkExistingProjects([s.workspace])).size>0&&(a(g,await Wt.getProjectId(s.workspace.id),!0),console.log("[Mnemonic/Todoist] handleSync: Re-linked to existing project:",e(g)))}}e(g)||(console.log("[Mnemonic/Todoist] handleSync: No mapping, attempting detection..."),(await Wt.detectAndLinkExistingProjects([s.workspace])).size>0&&(a(g,await Wt.getProjectId(s.workspace.id),!0),console.log("[Mnemonic/Todoist] handleSync: Detected and linked to project:",e(g)))),await Wt.syncWorkspace(s.workspace),a(g,await Wt.getProjectId(s.workspace.id),!0),console.log("[Mnemonic/Todoist] handleSync: After sync, projectId:",e(g)),e(g)&&(await ka.loadWorkspaceTasks(s.workspace.id),Y())}finally{a(d,!1)}}}async function P(X){await ka.createTask(s.workspace.id,X)&&(a(c,!1),Y())}function q(){ka.toggleShowCompleted(),Y()}function te(){re()}const G=me(()=>e(w).filter(X=>!X.isCompleted));var de=iv(),ce=ee(de),F=o(ce),W=o(F),R=i(o(W),2),U=o(R),ie=i(W,2),B=o(ie);{var V=X=>{var ve=ev(),We=ee(ve);We.__click=()=>a(c,!0);var oe=i(We,2);let _;oe.__click=Z,L(()=>_=Oe(oe,1,"btn-icon svelte-ggenkx",null,_,{syncing:e(d)})),n(X,ve)};x(B,X=>{e(f)&&X(V)})}var A=i(B,2);A.__click=()=>a(p,!0);var S=i(F,2);{var $=X=>{var ve=tv(),We=i(o(ve),2);We.__click=()=>a(p,!0),n(X,ve)},D=X=>{var ve=Fe(),We=ee(ve);{var oe=N=>{var Q=av();n(N,Q)},_=N=>{var Q=Fe(),he=ee(Q);{var we=Ee=>{var be=sv(),De=o(be),xe=o(De),Ce=i(De,2);Ce.__click=()=>ka.clearError(),L(()=>E(xe,e(j))),n(Ee,be)},ke=Ee=>{var be=Fe(),De=ee(be);{var xe=Ne=>{var ue=rv(),ze=i(o(ue),2);ze.__click=Z;var fe=o(ze);L(()=>{ze.disabled=e(d),E(fe,e(d)?"Creating...":"Create Project in Todoist")}),n(Ne,ue)},Ce=Ne=>{var ue=nv(),ze=ee(ue);{var fe=Ue=>{oo(Ue,{get workspaceId(){return s.workspace.id},onSave:P,onCancel:()=>a(c,!1)})};x(ze,Ue=>{e(c)&&Ue(fe)})}var pe=i(ze,2);wt(pe,21,()=>e(w),Ue=>Ue.id,(Ue,Xe)=>{Fd(Ue,{get task(){return e(Xe)}})},Ue=>{var Xe=ov(),_t=i(o(Xe),2);_t.__click=()=>{a(c,!0)},n(Ue,Xe)});var je=i(pe,2),Ie=o(je);Ie.__click=q;var _e=o(Ie),Ae=i(Ie,2),He=o(Ae);L(()=>{E(_e,`${e(H)?"Hide":"Show"} completed`),E(He,`${e(G).length??""} active`)}),n(Ne,ue)};x(De,Ne=>{e(g)?Ne(Ce,!1):Ne(xe)},!0)}n(Ee,be)};x(he,Ee=>{e(j)?Ee(we):Ee(ke,!1)},!0)}n(N,Q)};x(We,N=>{e(M)?N(oe):N(_,!1)},!0)}n(X,ve)};x(S,X=>{e(f)?X(D,!1):X($)})}var K=i(ce,2);Zd(K,{get open(){return e(p)},onClose:()=>a(p,!1),onConnected:te}),L(()=>E(U,`${s.workspace.name??""} Tasks`)),n(O,de),jt()}oa(["click"]);const As={isDragging:!1,draggedId:null,draggedType:null,selectedIds:[],dropTargetId:null,dropPosition:null,sourceParentId:null};function to(O,s,c,p){if(O.id===s)return{allowed:!1,reason:"Cannot drop on self"};const d=p.find(g=>g.id===O.id),f=p.find(g=>g.id===s);return!d||!f?{allowed:!1,reason:"Workspace not found"}:c==="inside"&&f.type!=="parent"?{allowed:!1,reason:"Can only drop inside parent workspaces"}:d.type==="parent"&&c==="inside"&&no(f.id,d.id,p)?{allowed:!1,reason:"Cannot create circular hierarchy"}:{allowed:!0}}function no(O,s,c){const p=c.find(f=>f.id===s);if(!p||p.type!=="parent")return!1;const d=c.filter(f=>f.type==="child"&&f.parentId===s);for(const f of d)if(f.id===O||no(O,f.id,c))return!0;return!1}function cv(O,s,c,p){const d=p.find(H=>H.id===O.id),f=p.find(H=>H.id===s);if(!d||!f)return null;if(c==="inside")return f.type!=="parent"?null:{newParentId:f.id,newIndex:0};const g=f.parentId,M=p.filter(H=>g===null&&H.type==="parent"||H.parentId===g&&H.type!=="parent").findIndex(H=>H.id===s);if(M===-1)return null;const j=c==="before"?M:M+1;return{newParentId:g,newIndex:j}}var dv=u('<span class="text-text-muted ml-1 svelte-1k2s006">in</span> <button class="text-phosphor-dark ml-1 hover:text-phosphor hover:underline transition-colors svelte-1k2s006" title="Click to select parent workspace"> </button>',1),vv=u('<div class="flex items-center gap-2 svelte-1k2s006"><svg class="w-4 h-4 text-phosphor svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2" class="svelte-1k2s006"></path></svg> <div class="text-sm svelte-1k2s006"><span class="text-text-muted svelte-1k2s006">Window assigned to:</span> <button class="text-text font-medium ml-1 hover:text-phosphor hover:underline transition-colors svelte-1k2s006" title="Click to select this workspace"> </button> <!></div></div> <button class="p-1.5 rounded hover:bg-surface text-text-muted hover:text-phosphor transition-colors svelte-1k2s006" title="Reassign window to different workspace"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" class="svelte-1k2s006"></path></svg></button>',1),uv=u('<button class="text-phosphor hover:text-phosphor-light underline svelte-1k2s006">Create workspace and assign</button>'),pv=u('<button class="text-phosphor hover:text-phosphor-light underline svelte-1k2s006">Assign now</button>'),hv=u('<div class="flex items-center gap-2 text-sm text-text-muted svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Window not assigned</span> <!></div>'),fv=u('<div class="flex items-center gap-2 pl-6 border-l border-phosphor-dark/30 svelte-1k2s006"><div class="flex items-center gap-2 px-3 py-1.5 rounded-full bg-phosphor/20 border border-phosphor/40 svelte-1k2s006"><svg class="w-4 h-4 text-phosphor svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" class="svelte-1k2s006"></path></svg> <span class="text-sm text-phosphor font-medium svelte-1k2s006"> </span> <span class="text-xs text-phosphor-dark svelte-1k2s006"> </span></div></div>'),gv=vt('<svg class="w-4 h-4 mr-1.5 text-status-success animate-pulse svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0A9.972 9.972 0 0119 10a9.972 9.972 0 01-2.929 7.071 1 1 0 01-1.414-1.414A7.971 7.971 0 0017 10c0-2.21-.894-4.208-2.343-5.657a1 1 0 010-1.414zm-2.829 2.828a1 1 0 011.415 0A5.983 5.983 0 0115 10a5.984 5.984 0 01-1.757 4.243 1 1 0 01-1.415-1.415A3.984 3.984 0 0013 10a3.983 3.983 0 00-1.172-2.828 1 1 0 010-1.415z" clip-rule="evenodd" class="svelte-1k2s006"></path></svg> Go to Playing',1),mv=vt('<svg class="w-4 h-4 mr-1.5 text-status-success svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" class="svelte-1k2s006"></path></svg> Pause All',1),kv=u("<!> <!>",1),wv=vt('<svg class="w-4 h-4 mr-1.5 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4" class="svelte-1k2s006"></path></svg> Create Workspace from Window',1),_v=u('<button class="actions-menu-item svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Cross-Browser Sync</span></button> <button class="actions-menu-item svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Browse Backups</span></button>',1),bv=u('<button class="fixed inset-0 z-40 svelte-1k2s006" aria-label="Close menu"></button> <div class="absolute right-0 top-full mt-1 w-64 bg-surface-raised border border-phosphor-dark/30 rounded-lg shadow-xl z-50 py-1 overflow-hidden svelte-1k2s006"><button class="actions-menu-item svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Refresh Workspaces</span></button> <button class="actions-menu-item svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Rescan Window Mappings</span></button> <div class="border-t border-phosphor-dark/20 my-1 svelte-1k2s006"></div> <button class="actions-menu-item svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Archived Workspaces</span></button> <button class="actions-menu-item svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Import Bookmarks</span></button> <!> <div class="border-t border-phosphor-dark/20 my-1 svelte-1k2s006"></div> <button class="actions-menu-item text-status-warning svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Unlock All Window Mappings</span></button> <div class="border-t border-phosphor-dark/20 my-1 svelte-1k2s006"></div> <button class="actions-menu-item svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Debug Logs</span></button></div>',1),yv=u('<div class="flex items-center justify-center py-12 svelte-1k2s006"><div class="w-8 h-8 border-2 border-phosphor-dark border-t-phosphor rounded-full animate-spin svelte-1k2s006"></div></div>'),xv=u('<div class="text-center py-8 svelte-1k2s006"><p class="text-status-error text-sm mb-2 svelte-1k2s006"> </p> <!></div>'),Cv=u('<span class="status-badge status-badge-success flex-shrink-0 svelte-1k2s006"><span class="status-dot status-dot-success svelte-1k2s006"></span> Open<!></span>'),Sv=u('<span class="status-badge status-badge-muted flex-shrink-0 svelte-1k2s006">Closed</span>'),Tv=u('<button class="action-btn action-btn-primary svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Switch Context</span></button> <button class="action-btn svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Open All</span></button>',1),Mv=u('<button class="action-btn action-btn-primary svelte-1k2s006" title="Open in New Window"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Open Window</span></button>'),Iv=u('<button class="action-btn svelte-1k2s006" title="Convert to Parent"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 14v6m-3-3h6M6 10h2a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Convert</span></button>'),Av=u('<div class="space-y-2 svelte-1k2s006"><textarea class="w-full h-20 px-3 py-2 text-sm bg-mnemonic-bg-dark border border-phosphor-dark/30 rounded-lg text-text-primary placeholder-text-muted focus:border-phosphor focus:ring-1 focus:ring-phosphor resize-none svelte-1k2s006" placeholder="Write a brief description of this workspace..."></textarea> <div class="flex items-center gap-2 svelte-1k2s006"><button class="px-3 py-1.5 text-xs rounded bg-phosphor text-mnemonic-bg hover:bg-phosphor-light transition-colors svelte-1k2s006">Save</button> <button class="px-3 py-1.5 text-xs rounded border border-phosphor-dark/30 text-text-secondary hover:border-phosphor-dark hover:text-text-primary transition-colors svelte-1k2s006">Cancel</button></div></div>'),Ev=u('<span class="inline-flex items-center mt-1 text-xs text-text-muted svelte-1k2s006"><svg class="w-3 h-3 mr-1 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" class="svelte-1k2s006"></path></svg> User written</span>'),Pv=u('<span class="inline-flex items-center mt-1 text-xs text-text-muted svelte-1k2s006"><svg class="w-3 h-3 mr-1 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" class="svelte-1k2s006"></path></svg> AI generated</span>'),zv=u('<p class="text-sm text-text-secondary leading-relaxed svelte-1k2s006"> </p> <!>',1),Lv=u('<p class="text-sm text-text-muted italic svelte-1k2s006">No summary yet. <!></p>'),Rv=vt('<svg class="w-4 h-4 animate-spin svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" class="svelte-1k2s006"></path></svg>'),Wv=vt('<svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" class="svelte-1k2s006"></path></svg>'),Bv=u('<button class="p-1.5 rounded text-text-muted hover:text-phosphor hover:bg-surface transition-colors disabled:opacity-50 disabled:cursor-not-allowed svelte-1k2s006" title="Regenerate summary with AI"><!></button>'),Dv=u('<button class="p-1.5 rounded text-text-muted hover:text-phosphor hover:bg-surface transition-colors svelte-1k2s006" title="Edit summary"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" class="svelte-1k2s006"></path></svg></button> <!>',1),Nv=vt('<svg class="w-3.5 h-3.5 animate-spin svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" class="svelte-1k2s006"></path></svg> Generating...',1),qv=vt('<svg class="w-3.5 h-3.5 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" class="svelte-1k2s006"></path></svg> Generate',1),Ov=u('<button class="inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded bg-phosphor/20 text-phosphor hover:bg-phosphor hover:text-mnemonic-bg transition-colors disabled:opacity-50 disabled:cursor-not-allowed svelte-1k2s006" title="Generate summary with AI"><!></button>'),Fv=u('<button class="p-1.5 rounded text-text-muted hover:text-phosphor hover:bg-surface transition-colors svelte-1k2s006" title="Write a summary"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" class="svelte-1k2s006"></path></svg></button> <!>',1),jv=u('<div class="flex items-center gap-1 flex-shrink-0 svelte-1k2s006"><!></div>'),Uv=u('<span class="w-2 h-2 rounded-full bg-status-success animate-pulse svelte-1k2s006" title="Window open"></span>'),Hv=u('<span class="w-2 h-2 rounded-full bg-text-muted/30 svelte-1k2s006" title="Window closed"></span>'),Vv=u('<span class="text-xs px-1.5 py-0.5 rounded bg-status-success/20 text-status-success svelte-1k2s006">Open</span>'),$v=u('<button class="opacity-0 group-hover:opacity-100 px-2 py-1 text-xs rounded bg-phosphor/20 text-phosphor hover:bg-phosphor hover:text-mnemonic-bg transition-all svelte-1k2s006" title="Open in New Window"><svg class="w-3.5 h-3.5 inline-block svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" class="svelte-1k2s006"></path></svg></button>'),Gv=u('<div class="flex items-center justify-between p-3 rounded bg-mnemonic-bg-dark/50 hover:bg-mnemonic-bg-dark cursor-pointer transition-colors group svelte-1k2s006" role="button" tabindex="0"><div class="flex items-center gap-3 svelte-1k2s006"><!> <svg class="w-5 h-5 text-text-muted svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM4.332 8.027a6.012 6.012 0 011.912-2.706C6.512 5.73 6.974 6 7.5 6A1.5 1.5 0 019 7.5V8a2 2 0 004 0 2 2 0 011.523-1.943A5.977 5.977 0 0116 10c0 .34-.028.675-.083 1H15a2 2 0 00-2 2v2.197A5.973 5.973 0 0110 16v-2a2 2 0 00-2-2 2 2 0 01-2-2 2 2 0 00-1.668-1.973z" clip-rule="evenodd" class="svelte-1k2s006"></path></svg> <span class="text-text-primary svelte-1k2s006"> </span></div> <div class="flex items-center gap-3 svelte-1k2s006"><span class="text-sm text-text-muted svelte-1k2s006"> </span> <!></div></div>'),Kv=u('<div class="space-y-2 svelte-1k2s006"></div>'),Yv=u('<div class="text-center py-8 text-text-muted svelte-1k2s006"><p class="svelte-1k2s006">No child workspaces yet</p> <p class="text-sm mt-1 svelte-1k2s006">Click "Add Child" to create one</p></div>'),Jv=u('<div class="panel svelte-1k2s006"><div class="flex items-center justify-between mb-4 svelte-1k2s006"><h3 class="text-lg text-phosphor svelte-1k2s006"> </h3> <!></div> <!></div>'),Xv=vt('<svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" class="svelte-1k2s006"></path></svg> Dedupe',1),Qv=u('<span class="refocus-indicator svelte-1k2s006" title="Refocus Tab - This tab will be activated when the window gains focus"><svg class="w-3.5 h-3.5 text-amber-400 svelte-1k2s006" fill="currentColor" viewBox="0 0 24 24"><path d="M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z" class="svelte-1k2s006"></path></svg></span>'),Zv=vt('<svg class="w-4 h-4 svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd" class="svelte-1k2s006"></path></svg>'),eu=vt('<svg class="w-4 h-4 svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path d="M10 2a5 5 0 00-5 5v2a2 2 0 00-2 2v5a2 2 0 002 2h10a2 2 0 002-2v-5a2 2 0 00-2-2H7V7a3 3 0 015.905-.75 1 1 0 001.937-.5A5.002 5.002 0 0010 2z" class="svelte-1k2s006"></path></svg>'),tu=u('<div draggable="true"><button type="button" class="tab-link svelte-1k2s006" title="Switch to tab (or open if not in window)"><img alt="" class="w-4 h-4 rounded flex-shrink-0 svelte-1k2s006"/> <span class="flex-1 truncate text-sm text-text-primary group-hover:text-phosphor text-left svelte-1k2s006"> </span> <!></button> <div class="tab-actions svelte-1k2s006"><button class="tab-action-btn svelte-1k2s006" title="Open new tab in background"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" class="svelte-1k2s006"></path></svg></button> <button><!></button> <button><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" class="svelte-1k2s006"></path></svg></button></div></div>'),au=u('<div class="space-y-1 saved-tabs-list svelte-1k2s006"></div>'),su=u('<div class="text-center py-8 text-text-muted svelte-1k2s006"><p class="svelte-1k2s006">No tabs saved yet</p> <p class="text-sm mt-1 svelte-1k2s006">Click "Save Current Tabs" to capture your current browser tabs</p></div>'),ru=u('<div class="panel svelte-1k2s006"><div class="flex items-center justify-between mb-4 svelte-1k2s006"><h3 class="text-lg text-phosphor svelte-1k2s006"> </h3> <div class="flex items-center gap-2 svelte-1k2s006"><!> <!></div></div> <!></div>'),ou=u('<label class="flex items-center gap-3 cursor-pointer select-none mb-4 svelte-1k2s006"><input type="checkbox" class="w-4 h-4 rounded border-phosphor-dark/50 bg-mnemonic-bg text-phosphor focus:ring-phosphor focus:ring-offset-0 cursor-pointer svelte-1k2s006"/> <div class="svelte-1k2s006"><span class="text-sm text-text svelte-1k2s006">Open in Context Switch</span> <p class="text-xs text-text-muted svelte-1k2s006">When enabled, this workspace opens automatically when switching to its parent context</p></div></label>'),nu=u('<label class="flex items-center gap-3 cursor-pointer select-none ml-6 svelte-1k2s006"><input type="checkbox" class="w-4 h-4 rounded border-phosphor-dark/50 bg-mnemonic-bg text-phosphor focus:ring-phosphor focus:ring-offset-0 cursor-pointer svelte-1k2s006"/> <div class="svelte-1k2s006"><span class="text-sm text-text svelte-1k2s006">Refocus Tab Takes Priority</span> <p class="text-xs text-text-muted svelte-1k2s006">When enabled, the designated refocus tab takes priority over any playing tab</p></div></label>'),iu=u('<label class="flex items-center gap-3 cursor-pointer select-none svelte-1k2s006"><input type="checkbox" class="w-4 h-4 rounded border-phosphor-dark/50 bg-mnemonic-bg text-phosphor focus:ring-phosphor focus:ring-offset-0 cursor-pointer svelte-1k2s006"/> <div class="svelte-1k2s006"><span class="text-sm text-text svelte-1k2s006">Auto-Focus Playing Tab</span> <p class="text-xs text-text-muted svelte-1k2s006">Automatically focus any tab playing audio when this window gains focus</p></div></label> <!>',1),lu=u(`<div class="flex gap-6 svelte-1k2s006"><div class="flex-1 max-w-4xl svelte-1k2s006"><div class="flex items-start justify-between mb-6 svelte-1k2s006"><div class="flex-1 svelte-1k2s006"><div class="flex items-center gap-3 mb-1 svelte-1k2s006"><!> <h2 class="text-2xl font-semibold text-phosphor svelte-1k2s006"> </h2></div> <p class="text-sm text-text-muted svelte-1k2s006"> </p></div> <div class="action-toolbar svelte-1k2s006"><div class="action-group svelte-1k2s006"><!></div> <span class="action-divider svelte-1k2s006"></span> <div class="action-group svelte-1k2s006"><!> <button class="action-btn svelte-1k2s006" title="Rename"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006">Rename</span></button> <button><svg class="w-4 h-4 svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path d="M10 2a1 1 0 011 1v1.323l3.954 1.582 1.599-.8a1 1 0 01.894 1.79l-1.233.616 1.738 5.42a1 1 0 01-.285 1.05A3.989 3.989 0 0115 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.715-5.349L11 6.477V16h2a1 1 0 110 2H7a1 1 0 110-2h2V6.477L6.237 7.582l1.715 5.349a1 1 0 01-.285 1.05A3.989 3.989 0 015 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.738-5.42-1.233-.617a1 1 0 01.894-1.788l1.599.799L9 4.323V3a1 1 0 011-1z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006"> </span></button></div> <span class="action-divider svelte-1k2s006"></span> <div class="action-group svelte-1k2s006"><button class="action-btn action-btn-danger svelte-1k2s006" title="Delete"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" class="svelte-1k2s006"></path></svg></button></div></div></div> <div class="summary-panel mb-6 svelte-1k2s006"><div class="flex items-start justify-between gap-3 svelte-1k2s006"><div class="flex-1 min-w-0 svelte-1k2s006"><!></div> <!></div></div> <!> <div class="mt-6 p-4 rounded bg-mnemonic-bg-dark/30 svelte-1k2s006"><h4 class="text-sm font-medium text-text-secondary mb-3 svelte-1k2s006">Settings</h4> <!> <label class="flex items-center gap-3 cursor-pointer select-none svelte-1k2s006"><input type="checkbox" class="w-4 h-4 rounded border-phosphor-dark/50 bg-mnemonic-bg text-phosphor focus:ring-phosphor focus:ring-offset-0 cursor-pointer svelte-1k2s006"/> <div class="svelte-1k2s006"><span class="text-sm text-text svelte-1k2s006">Sync Enabled</span> <p class="text-xs text-text-muted svelte-1k2s006">When disabled, external changes from other devices won't overwrite this workspace</p></div></label> <!></div> <div class="mt-6 p-4 rounded bg-mnemonic-bg-dark/30 text-sm svelte-1k2s006"><div class="grid grid-cols-2 gap-4 text-text-muted svelte-1k2s006"><div class="svelte-1k2s006"><span class="text-text-secondary svelte-1k2s006">Last Modified:</span> <span class="ml-2 svelte-1k2s006"> </span></div> <div class="svelte-1k2s006"><span class="text-text-secondary svelte-1k2s006">Last Accessed:</span> <span class="ml-2 svelte-1k2s006"> </span></div> <div class="svelte-1k2s006"><span class="text-text-secondary svelte-1k2s006">Switch Count:</span> <span class="ml-2 svelte-1k2s006"> </span></div> <div class="svelte-1k2s006"><span class="text-text-secondary svelte-1k2s006">ID:</span> <span class="ml-2 font-mono text-xs svelte-1k2s006"> </span></div></div></div> <div class="mt-6 svelte-1k2s006"><!></div></div> <div class="w-[600px] flex-shrink-0 svelte-1k2s006"><div class="sticky top-0 space-y-4 svelte-1k2s006"><!> <!></div></div></div>`),cu=u(`<div class="flex flex-col items-center justify-center h-full text-center svelte-1k2s006"><div class="w-20 h-20 flex items-center justify-center bg-phosphor text-mnemonic-bg text-4xl font-bold rounded-2xl mb-6 svelte-1k2s006">M</div> <h2 class="text-2xl font-semibold text-phosphor mb-2 svelte-1k2s006">Welcome to Mnemonic</h2> <p class="text-text-secondary max-w-md mb-6 svelte-1k2s006">Organize your browser windows into hierarchical workspaces.
19              Select a workspace from the sidebar or create a new one to get started.</p> <div class="flex gap-3 svelte-1k2s006"><!> <!></div></div>`),du=u('<div class="notes-resize-handle svelte-1k2s006" role="separator" aria-orientation="vertical" aria-label="Resize notes sidebar" tabindex="0"></div>'),vu=u('<span class="notes-vertical-title svelte-1k2s006">Logseq Notes</span>'),uu=u('<div class="flex-1 overflow-hidden svelte-1k2s006"><!></div>'),pu=u('<aside class="notes-sidebar border-l border-phosphor-dark/30 bg-mnemonic-bg-dark/30 relative flex svelte-1k2s006"><!> <button class="notes-toggle-btn svelte-1k2s006"><!> <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" class="svelte-1k2s006"></path></svg></button> <!></aside>'),hu=u("<!> <!>",1),fu=u("<!> <!>",1),gu=u('<p class="text-sm text-text-muted mb-4 svelte-1k2s006"> </p> <!>',1),mu=u("<!> <!>",1),ku=u('<span class="w-3 h-3 rounded-full flex-shrink-0 svelte-1k2s006"></span>'),wu=vt('<svg class="w-4 h-4 text-text-muted flex-shrink-0 svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path d="M2 6a2 2 0 012-2h5l2 2h5a2 2 0 012 2v6a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" class="svelte-1k2s006"></path></svg>'),_u=vt('<svg class="w-4 h-4 text-phosphor svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" class="svelte-1k2s006"></path></svg>'),bu=u('<button><!> <span class="flex-1 text-text svelte-1k2s006"> </span> <!></button>'),yu=u('<p class="text-text-muted text-sm italic p-3 svelte-1k2s006">No groups defined in this context.</p>'),xu=u('<p class="text-sm text-text-muted mb-4 svelte-1k2s006"> </p> <div class="space-y-2 max-h-60 overflow-y-auto svelte-1k2s006"><!></div>',1),Cu=u("<!> <!>",1),Su=vt('<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" class="svelte-1k2s006"></path>'),Tu=vt('<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9" class="svelte-1k2s006"></path>'),Mu=u('<div class="text-xs text-text-muted truncate svelte-1k2s006"> </div>'),Iu=u('<div class="text-xs text-text-muted svelte-1k2s006">Standalone</div>'),Au=u('<span class="text-xs text-phosphor font-medium svelte-1k2s006">Current</span>'),Eu=u('<span class="text-xs text-text-muted svelte-1k2s006">Has window</span>'),Pu=u('<button><svg class="w-4 h-4 text-text-muted flex-shrink-0 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><!></svg> <div class="flex-1 min-w-0 svelte-1k2s006"><div class="font-medium text-text truncate svelte-1k2s006"> </div> <!></div> <!></button>'),zu=u('<p class="text-sm text-text-muted py-4 text-center svelte-1k2s006">No child or standalone workspaces available.</p>'),Lu=u(`<div class="space-y-4 svelte-1k2s006"><p class="text-sm text-text-muted svelte-1k2s006">Select a workspace to assign this window to. This will update the dashboard tab to track the selected workspace.</p> <label class="flex items-center gap-3 p-3 rounded bg-mnemonic-bg-dark/30 cursor-pointer select-none svelte-1k2s006"><input type="checkbox" class="w-4 h-4 rounded border-phosphor-dark/50 bg-mnemonic-bg text-phosphor focus:ring-phosphor focus:ring-offset-0 cursor-pointer svelte-1k2s006"/> <div class="svelte-1k2s006"><span class="text-sm text-text svelte-1k2s006">Sync current tabs to workspace</span> <p class="text-xs text-text-muted svelte-1k2s006">Overwrites the workspace's saved tabs with this window's current tabs</p></div></label> <div class="max-h-56 overflow-y-auto space-y-1 border border-phosphor-dark/20 rounded-lg p-2 svelte-1k2s006"></div></div>`),Ru=u("<!> <!>",1),Wu=u('<span class="inline-flex items-center gap-1.5 text-xs font-normal text-phosphor svelte-1k2s006"><span class="w-3 h-3 border-2 border-phosphor/30 border-t-phosphor rounded-full animate-spin svelte-1k2s006"></span> suggesting...</span>'),Bu=u('<option class="svelte-1k2s006"> </option>'),Du=u('<li class="text-xs text-text-secondary truncate flex items-center gap-2 svelte-1k2s006"><img alt="" class="w-3 h-3 svelte-1k2s006"/> </li>'),Nu=u('<li class="text-xs text-text-muted svelte-1k2s006"> </li>'),qu=u('<label class="flex flex-wrap items-center gap-2 cursor-pointer py-1 svelte-1k2s006"><input type="checkbox" class="w-4 h-4 accent-phosphor cursor-pointer svelte-1k2s006"/> <span class="text-sm text-text svelte-1k2s006">Open in Context Switch</span> <span class="text-xs text-text-muted w-full pl-6 svelte-1k2s006">Include when switching to parent context</span></label>'),Ou=u('<div class="space-y-4 svelte-1k2s006"><p class="text-sm text-text-muted svelte-1k2s006"> </p> <div class="svelte-1k2s006"><label for="window-workspace-name" class="flex items-center gap-2 text-sm font-medium text-text-secondary mb-2 svelte-1k2s006">Workspace Name <!></label> <input id="window-workspace-name" type="text" placeholder="Enter workspace name"/></div> <div class="svelte-1k2s006"><label for="create-from-window-parent" class="block text-sm font-medium text-text-secondary mb-2 svelte-1k2s006">Parent (optional)</label> <select id="create-from-window-parent" class="w-full px-3 py-2 bg-mnemonic-bg-dark border border-phosphor-dark/30 rounded-lg text-text focus:border-phosphor focus:outline-none svelte-1k2s006"><option class="svelte-1k2s006">Standalone (no parent)</option><!></select></div> <div class="bg-mnemonic-bg-dark/50 rounded-lg p-3 max-h-40 overflow-y-auto svelte-1k2s006"><p class="text-xs text-text-muted mb-2 svelte-1k2s006"> </p> <ul class="space-y-1 svelte-1k2s006"><!> <!></ul></div> <div class="pt-2 border-t border-phosphor-dark/20 space-y-2 svelte-1k2s006"><p class="text-xs font-medium text-text-muted uppercase tracking-wide svelte-1k2s006">Workspace Options</p> <!> <label class="flex flex-wrap items-center gap-2 cursor-pointer py-1 svelte-1k2s006"><input type="checkbox" class="w-4 h-4 accent-phosphor cursor-pointer svelte-1k2s006"/> <span class="text-sm text-text svelte-1k2s006">Sync Enabled</span> <span class="text-xs text-text-muted w-full pl-6 svelte-1k2s006">Sync with external storage</span></label></div></div>'),Fu=u("<!> <!>",1),ju=u('<div class="flex items-center gap-2 text-status-error svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006"> </span></div>'),Uu=u('<div class="flex items-center gap-2 text-phosphor svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="currentColor" viewBox="0 0 20 20"><path d="M14.5 10c0 1.38-1.12 2.5-2.5 2.5-.83 0-1.57-.41-2.02-1.03L8.5 10l1.48-1.47A2.49 2.49 0 0112 7.5c1.38 0 2.5 1.12 2.5 2.5z" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006"> </span></div>'),Hu=u('<div class="space-y-4 svelte-1k2s006"><div class="flex items-start gap-3 svelte-1k2s006"><div class="flex-shrink-0 text-status-warning svelte-1k2s006"><svg class="w-6 h-6 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" class="svelte-1k2s006"></path></svg></div> <div class="text-sm text-text-secondary svelte-1k2s006"><p class="font-medium text-text mb-2 svelte-1k2s006"> </p> <p class="svelte-1k2s006">This action will:</p></div></div> <div class="bg-mnemonic-bg-dark/50 rounded-lg p-4 space-y-2 text-sm svelte-1k2s006"><!> <!> <div class="flex items-center gap-2 text-status-success svelte-1k2s006"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" class="svelte-1k2s006"></path></svg> <span class="svelte-1k2s006"> </span></div></div> <p class="text-xs text-text-muted svelte-1k2s006">Unsaved work in closing windows may be lost. Make sure to save your work before switching.</p></div>'),Vu=u('<div class="dashboard h-screen flex flex-col bg-mnemonic-bg svelte-1k2s006"><header class="flex items-center justify-between px-6 py-4 border-b border-phosphor-dark/30 bg-surface-raised svelte-1k2s006"><div class="flex items-center gap-6 svelte-1k2s006"><div class="flex items-center gap-4 svelte-1k2s006"><div class="flex items-center justify-center w-10 h-10 bg-phosphor text-mnemonic-bg font-bold text-xl rounded-lg svelte-1k2s006">M</div> <div class="svelte-1k2s006"><h1 class="text-xl font-semibold text-phosphor svelte-1k2s006">Mnemonic</h1> <div class="flex items-center gap-3 text-xs text-text-muted svelte-1k2s006"><span class="svelte-1k2s006"><span class="text-text-secondary font-medium svelte-1k2s006"> </span> Contexts</span> <span class="text-phosphor-dark/50 svelte-1k2s006">|</span> <span class="svelte-1k2s006"><span class="text-text-secondary font-medium svelte-1k2s006"> </span> Workspaces</span> <span class="text-phosphor-dark/50 svelte-1k2s006">|</span> <span><span> </span> Transcendent</span> <span class="text-phosphor-dark/50 svelte-1k2s006">|</span> <span><span> </span> Open</span></div></div></div> <div class="flex items-center gap-3 pl-6 border-l border-phosphor-dark/30 svelte-1k2s006"><!></div> <!></div> <div class="flex-1 max-w-md mx-8 svelte-1k2s006"><!></div> <div class="flex items-center gap-2 svelte-1k2s006"><!> <!> <div class="relative svelte-1k2s006"><button class="p-2 rounded-lg hover:bg-surface-raised text-text-muted hover:text-phosphor transition-colors svelte-1k2s006" title="Actions menu"><svg class="w-5 h-5 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" class="svelte-1k2s006"></path></svg></button> <!></div></div></header> <div class="flex flex-1 overflow-hidden svelte-1k2s006"><aside class="relative border-r border-phosphor-dark/30 bg-mnemonic-bg-dark/50 overflow-y-auto flex-shrink-0 svelte-1k2s006"><div class="resize-handle svelte-1k2s006" role="separator" aria-orientation="vertical" aria-label="Resize sidebar" tabindex="0"></div> <div class="p-4 svelte-1k2s006"><div class="sidebar-header flex items-center justify-between mb-4 svelte-1k2s006"><h2 class="text-sm font-mono uppercase tracking-wider text-text-muted svelte-1k2s006">Workspaces</h2> <div class="flex gap-1 svelte-1k2s006"><button class="p-1.5 rounded hover:bg-surface-raised text-text-muted hover:text-phosphor transition-colors svelte-1k2s006" title="Create parent workspace"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z" class="svelte-1k2s006"></path></svg></button> <button class="p-1.5 rounded hover:bg-surface-raised text-text-muted hover:text-phosphor transition-colors svelte-1k2s006" title="Create standalone workspace"><svg class="w-4 h-4 svelte-1k2s006" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" class="svelte-1k2s006"></path></svg></button></div></div> <!></div></aside> <main class="flex-1 overflow-y-auto p-6 svelte-1k2s006"><!></main> <!></div></div> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>',1);function $u(O,s){Ft(s,!0);let c=b(dt([])),p=b(!0),d=b(null),f=b(null);Kt(()=>{s.workspaceId!==null&&a(d,s.workspaceId,!0)});let g=b(!1),w=b("standalone"),M=b(!1),j=b(null),H=b(!1),se=b(""),Y=b(!1),re=b(null),Z=b(""),P=b(!1),q=b(null),te=b(!1),G=b(null),de=b(null),ce=b(""),F=b(!1),W=b(null),R=b(null),U=b(null),ie=b(!1),B=b(null),V=b(dt({windowsToClose:0,transcendentToKeep:0})),A=b(null),S=b(null),$=b(!1),D=b(dt([])),K=b(!1),X=b(!0),ve=b(!1),We=b(dt([])),oe=b(""),_=b(""),N=b(!1),Q=b(!1),he=b(!0),we=b(!0),ke=b(dt(new Set)),Ee=b(null),be=b(dt(new Set)),De=b(dt([])),xe=b(0),Ce=b(!1),Ne=b(!1),ue=b(!1),ze=b(null),fe=b(dt({})),pe=b(!1),je=b(!1),Ie=b(!1),_e=b(!1),Ae=b(dt({available:!1,graphName:null,graphPath:null,lastChecked:""}));const He=Qa();let Ue=b(""),Xe=b("info"),_t=b(!1),ne=b(null),ge=b(!1),Le=b(null),ut=null,Ve=b(dt([])),qe=b(!1),Re=b(!1);const pt=zi();let ot=b(!1),Ze=b(!1),ye=b(""),J=b(dt({...As})),at=b(240),nt=b(!1),ht=b(!1);const tt=200,Mt=600;let ft=b(!1),St=b(320),gt=b(!1);const Ut=250,Aa=1500,ja=36;function Ua(t){if(t.length===0)return tt;const m=t.reduce((T,z)=>z.name.length>T.length?z.name:T,"").length*8+35+90,k=Math.ceil(m*1.1);return Math.max(tt,Math.min(Mt,k))}function Ra(t){if(!e(ht)&&t.length>0){const r=Ua(t);e(at)!==r&&a(at,r,!0)}}Kt(()=>{if(e(d)){const t=e(c).find(r=>r.id===e(d));t&&(a(ft,t.notesSidebarExpanded??!1,!0),a(St,t.notesSidebarWidth??320,!0))}});const y=me(()=>e(c).find(t=>t.id===e(d))||null),Wa=me(()=>{if(!e(y)||e(y).type!=="child")return null;const t=e(y);return e(c).find(r=>r.id===t.parentId)||null}),na=me(()=>e(c).filter(t=>t.type==="parent")),_a=me(()=>e(c).filter(t=>t.type==="parent").length),Ea=me(()=>e(c).filter(t=>t.type==="child").length),cs=me(()=>e(c).filter(t=>t.type==="standalone").length),Ha=me(()=>e(c).filter(t=>t.isTranscendent).length),Va=me(()=>e(ke).size),yt=me(()=>s.workspaceId?e(c).find(t=>t.id===s.workspaceId):null),Ht=me(()=>{if(!e(yt))return null;if(e(yt).type==="child"){const t=e(yt);return e(c).find(r=>r.id===t.parentId)||null}return null}),va=me(()=>e(c).filter(t=>t.type==="child"||t.type==="standalone").sort((t,r)=>{const l=e(ke).has(t.id),v=e(ke).has(r.id);return l!==v?l?1:-1:t.name.localeCompare(r.name)})),ba=me(()=>e(Ee)?e(c).find(t=>t.id===e(Ee)):null);function ya(t){return t.type==="parent"?e(c).some(r=>r.type==="child"&&r.parentId===t.id&&e(ke).has(r.id)):e(ke).has(t.id)}function Vt(t){return t.type!=="parent"?0:e(c).filter(r=>r.type==="child"&&r.parentId===t.id&&e(ke).has(r.id)).length}function ta(t){if(t.type!=="parent")return!1;const r=e(c).filter(l=>l.type==="child"&&l.parentId===t.id&&l.openInContextSwitch!==!1);return r.length===0?!0:r.every(l=>e(ke).has(l.id))}function aa(t){t.type==="TABS_UPDATED"?le():t.type==="WORKSPACE_STATUS_CHANGED"||t.type==="WORKSPACES_UPDATED_EXTERNALLY"?(da(),le()):t.type==="AUDIBLE_STATE_CHANGED"&&Ba()}function ia(){C.runtime.sendMessage({type:"WORKSPACE_STATUS_CHANGED"}).catch(()=>{})}async function la(){try{const t=await C.runtime.sendMessage({type:"CHECK_BRIDGE_STATUS"});a(ue,t.connected===!0),a(ze,t.browserKey||null,!0),console.log("[Dashboard] Bridge status:",e(ue),"browserKey:",e(ze)),e(ue)&&await $t()}catch(t){console.error("[Dashboard] Bridge check failed:",t),a(ue,!1)}}async function $t(){var t,r;try{const l=await C.runtime.sendMessage({type:"GET_SHARED_WORKSPACES"});if(console.log("[Dashboard] GET_SHARED_WORKSPACES response:",l==null?void 0:l.success,"browsers:",(t=l==null?void 0:l.data)!=null&&t.browsers?Object.keys(l.data.browsers):"none"),!l.success||!((r=l.data)!=null&&r.browsers)){a(fe,{},!0);return}const v={};for(const[h,m]of Object.entries(l.data.browsers)){if(console.log("[Dashboard] Processing browser:",h,"myBrowserKey:",e(ze),"skip:",h===e(ze)),h===e(ze))continue;const k=m;if(!k.workspaces)continue;const T=new Map;for(const ae of k.workspaces)ae.type==="parent"&&T.set(ae.id,ae.name);const z=k.workspaces.filter(ae=>(ae.type==="child"||ae.type==="standalone")&&!ae.archivedAt).map(ae=>({id:ae.id,name:ae.name,type:ae.type,parentId:ae.parentId,parentName:ae.parentId?T.get(ae.parentId):void 0}));console.log("[Dashboard] Browser",h,"has",k.workspaces.length,"total workspaces,",z.length,"valid targets"),z.length>0&&(v[h]=z)}a(fe,v,!0),console.log("[Dashboard] Remote workspaces loaded:",Object.keys(v),"total browsers with targets:",Object.keys(v).length)}catch(l){console.error("[Dashboard] Failed to load remote workspaces:",l),a(fe,{},!0)}}function ca(){le(),I("Workspaces imported successfully","success")}Ps(async()=>{await le(),await da(),await cn(),await Ba(),await la(),await Pa();const t=setInterval(Ba,3e5);try{const T=await C.storage.local.get("activeContextId");T.activeContextId&&a(Ee,T.activeContextId,!0)}catch(T){console.error("Failed to load active context:",T)}if(e(y)){const T=e(y).isTranscendent?"!":e(y).type==="parent"?"[+]":"[-]";document.title=`${T} ${e(y).name} - Mnemonic`}else document.title="Mnemonic Dashboard";C.windows.onCreated.addListener(da),C.windows.onRemoved.addListener(da),C.runtime.onMessage.addListener(aa);const l=(await C.windows.getCurrent()).id,v=(T,z)=>{z.windowId===l&&!z.isWindowClosing&&setTimeout(()=>le(),500)},h=T=>{T.windowId===l&&setTimeout(()=>le(),500)},m=(T,z)=>{z.windowId===l&&setTimeout(()=>le(),500)};C.tabs.onRemoved.addListener(v),C.tabs.onCreated.addListener(h),C.tabs.onMoved.addListener(m);const k=()=>{document.visibilityState==="visible"&&s.workspaceId&&a(d,s.workspaceId,!0)};return document.addEventListener("visibilitychange",k),()=>{C.windows.onCreated.removeListener(da),C.windows.onRemoved.removeListener(da),C.runtime.onMessage.removeListener(aa),C.tabs.onRemoved.removeListener(v),C.tabs.onCreated.removeListener(h),C.tabs.onMoved.removeListener(m),document.removeEventListener("visibilitychange",k),clearInterval(t)}});async function le(){a(p,!0),a(f,null);try{const t=await C.runtime.sendMessage({type:"GET_WORKSPACES"});a(c,t||[],!0),Ra(e(c))}catch(t){a(f,t instanceof Error?t.message:"Failed to load workspaces",!0)}finally{a(p,!1)}}async function Ot(){a(pe,!1),I("Rescanning window mappings...","info");try{const t=await C.runtime.sendMessage({type:"RESCAN_WINDOW_MAPPINGS"});t.success?(await le(),await da(),I("Window mappings updated","success")):I(t.error||"Failed to rescan","error")}catch(t){I(t instanceof Error?t.message:"Failed to rescan","error")}}async function ua(){a(pe,!1);try{const t=await C.runtime.sendMessage({type:"CLEAR_MANUAL_MAPPINGS"});t.success?(await le(),I("Manual mappings cleared - workspaces can now auto-match","success")):I(t.error||"Failed to clear mappings","error")}catch(t){I(t instanceof Error?t.message:"Failed to clear mappings","error")}}async function Pa(){try{const t=await C.storage.local.get("logseqSettings");t.logseqSettings&&He.setSettings(t.logseqSettings),a(Ae,await He.checkConnection(),!0)}catch(t){console.error("[Dashboard] Failed to check Logseq connection:",t)}}async function pa(t){if(e(y))try{const l=[...e(y).resources||[],t];await C.runtime.sendMessage({type:"UPDATE_WORKSPACE",payload:{id:e(y).id,updates:{resources:l}}}),e(y).resources=l,a(c,e(c).map(v=>v.id===e(y).id?{...v,resources:l}:v),!0),I("Resource added","success")}catch(r){console.error("[Dashboard] Failed to add resource:",r),I("Failed to add resource","error")}}async function za(t){if(e(y))try{const l=(e(y).resources||[]).filter(v=>v.id!==t);await C.runtime.sendMessage({type:"UPDATE_WORKSPACE",payload:{id:e(y).id,updates:{resources:l}}}),e(y).resources=l,a(c,e(c).map(v=>v.id===e(y).id?{...v,resources:l}:v),!0),I("Resource removed","success")}catch(r){console.error("[Dashboard] Failed to remove resource:",r),I("Failed to remove resource","error")}}async function da(){var t;try{const r=await C.windows.getAll({populate:!0}),l=C.runtime.getURL("workspace-dashboard.html"),v=new Set,h=new Set;for(const k of r)if(k.tabs){for(const T of k.tabs)if((t=T.url)!=null&&t.startsWith(l)){const z=new URL(T.url),ae=z.searchParams.get("workspaceId"),Se=z.searchParams.get("parentId");ae&&(v.add(ae),Se&&h.add(Se))}}let m=null;h.size===1&&(m=[...h][0]),a(ke,v,!0),a(Ee,m,!0)}catch(r){console.error("Failed to scan open windows:",r)}}function I(t,r="info"){a(Ue,t,!0),a(Xe,r,!0),a(_t,!0)}async function Ba(){try{const t=await C.runtime.sendMessage({type:"GET_AUDIBLE_TABS"});if(t!=null&&t.success){const r=new Set([...t.audibleWorkspaceIds,...t.parentWithAudibleChildren]);a(be,r,!0),a(De,t.audibleTabs||[],!0),e(De).length===0?a(xe,0):e(xe)>=e(De).length&&a(xe,0)}}catch{}}async function Za(){try{const t=await C.runtime.sendMessage({type:"PAUSE_ALL_MEDIA"});t!=null&&t.success?(I("Media paused","success"),setTimeout(Ba,500)):I((t==null?void 0:t.error)||"Failed to pause media","error")}catch{I("Failed to pause media","error")}}async function es(){if(e(De).length===0){I("No tabs playing audio","info");return}const t=e(De)[e(xe)];try{await C.runtime.sendMessage({type:"FOCUS_TAB",payload:{tabId:t.tabId,windowId:t.windowId}});const r=e(xe)+1,l=e(De).length;l>1&&I(`Playing tab ${r}/${l}: ${t.title}`,"info"),a(xe,(e(xe)+1)%e(De).length)}catch{I("Failed to navigate to playing tab","error")}}async function io(t,r=!0){if(t.type==="parent"){I("Cannot assign window to a parent workspace. Choose a child or standalone workspace.","error");return}if(r)try{const v=await C.windows.getCurrent();if(v.id){const h=await C.tabs.query({windowId:v.id}),m=C.runtime.getURL("workspace-dashboard.html"),k=h.filter(T=>T.url&&!T.url.startsWith("chrome-extension://")&&!T.url.startsWith("moz-extension://")&&!T.url.startsWith(m)).map(T=>({url:T.url,title:T.title||T.url,pinned:T.pinned||!1}));await C.runtime.sendMessage({type:"UPDATE_TABS",payload:{id:t.id,tabs:k}}),I(`Synced ${k.length} tabs to "${t.name}"`,"success")}}catch(v){console.error("Failed to sync tabs:",v)}const l=new URL(window.location.href);if(l.searchParams.set("workspaceId",t.id),l.searchParams.set("type",t.type),l.searchParams.set("transcendent",t.isTranscendent.toString()),t.type==="child"){const v=t;l.searchParams.set("parentId",v.parentId)}else l.searchParams.delete("parentId");try{const v=await C.windows.getCurrent();v.id&&await C.runtime.sendMessage({type:"SET_MANUAL_MAPPING",payload:{workspaceId:t.id,windowId:v.id}})}catch(v){console.warn("Failed to set manual mapping:",v)}window.location.href=l.toString()}function lo(t){a(d,t.id,!0)}function $a(t){a(w,t,!0),a(g,!0)}async function Ls(){var t;try{const r=await C.windows.getCurrent();if(!r.id){I("Could not get current window","error");return}const l=await C.tabs.query({windowId:r.id}),v=C.runtime.getURL("workspace-dashboard.html"),h=l.filter(k=>k.url&&!k.url.startsWith("chrome-extension://")&&!k.url.startsWith("moz-extension://")&&!k.url.startsWith(v)).map(k=>({url:k.url,title:k.title||k.url,pinned:k.pinned||!1}));if(h.length===0){I("No tabs to save in this window","error");return}const m=((t=h[0].title)==null?void 0:t.split(" - ")[0].slice(0,30))||"New Workspace";a(We,h,!0),a(oe,m,!0),a(_,""),a(Q,!1),a(he,!0),a(we,!0),a(ve,!0),co(h)}catch(r){I(r instanceof Error?r.message:"Failed to capture window tabs","error")}}async function co(t){if(!(e(N)||t.length===0)){a(N,!0);try{const l=(await C.storage.local.get("claudeSettings")).claudeSettings;if(console.log("[Dashboard] Claude settings:",{enabled:l==null?void 0:l.enabled,hasKey:!!(l!=null&&l.apiKey)}),!(l!=null&&l.enabled)||!(l!=null&&l.apiKey)){console.log("[Dashboard] Claude not configured");return}const v=xs();v.setApiKey(l.apiKey),l.model&&v.setModel(l.model),console.log("[Dashboard] API key format:",v.getApiKeyMasked()),console.log("[Dashboard] Requesting workspace name suggestion...");const h=await pt.suggestWorkspaceNameAndParent(t,e(na).map(m=>({id:m.id,name:m.name})));console.log("[Dashboard] Suggestion result:",h),h.success&&h.name?(a(oe,h.name,!0),h.parentId&&a(_,h.parentId,!0),a(Q,!0)):h.error&&console.error("[Dashboard] Suggestion error:",h.error)}catch(r){console.error("[Dashboard] Failed to get suggestion:",r)}finally{a(N,!1)}}}function vo(){e(Q)&&(a(oe,""),a(Q,!1))}async function uo(t,r,l){try{const v=JSON.parse(JSON.stringify(e(We)));let h;if(r?h=await C.runtime.sendMessage({type:"CREATE_CHILD",payload:{parentId:r,name:t,tabs:v,openInContextSwitch:l.openInContextSwitch,syncEnabled:l.syncEnabled}}):h=await C.runtime.sendMessage({type:"CREATE_STANDALONE",payload:{name:t,tabs:v,openInContextSwitch:l.openInContextSwitch,syncEnabled:l.syncEnabled}}),h.success){const m=h.workspace,k=new URL(window.location.href);k.searchParams.set("workspaceId",m.id),k.searchParams.set("type",m.type),k.searchParams.set("transcendent","false"),r?k.searchParams.set("parentId",r):k.searchParams.delete("parentId"),C.runtime.sendMessage({type:"GENERATE_WORKSPACE_SUMMARY",payload:{workspaceId:m.id}}).catch(()=>{}),window.location.href=k.toString()}else throw new Error(h.error||"Failed to create workspace")}catch(v){I(v instanceof Error?v.message:"Failed to create workspace","error")}finally{a(ve,!1),a(We,[],!0),a(oe,""),a(_,""),a(he,!0),a(we,!0)}}async function po(t){try{const r=t.name.trim();if(e(c).some(k=>{if(k.name.toLowerCase()===r.toLowerCase()){if(t.type==="child"&&k.type==="child")return k.parentId===t.parentId;if(t.type!=="child"&&k.type!=="child")return!0}return!1})){I(`A workspace named "${r}" already exists in this scope`,"error");return}let v="",h={name:r};t.type==="parent"?v="CREATE_PARENT":t.type==="child"?(v="CREATE_CHILD",h.parentId=t.parentId):v="CREATE_STANDALONE";const m=await C.runtime.sendMessage({type:v,payload:h});if(m.success)await le(),a(d,m.workspace.id,!0),I(`Created "${r}"`,"success");else throw new Error(m.error||"Failed to create workspace")}catch(r){I(r instanceof Error?r.message:"Failed to create workspace","error")}}function Rs(t){if(t.type==="parent"){const r=e(c).filter(l=>l.type==="child"&&l.parentId===t.id&&l.isTranscendent);if(r.length>0){I(`Cannot delete: "${t.name}" has ${r.length} transcendent child workspace(s). Remove transcendent status first.`,"error");return}}a(j,t,!0),a(M,!0)}async function ho(){if(e(j))try{await C.runtime.sendMessage({type:"DELETE_WORKSPACE",payload:{id:e(j).id,keepChildren:!0}}),e(d)===e(j).id&&a(d,null),await le(),I(`Deleted "${e(j).name}"`,"success")}catch(t){I(t instanceof Error?t.message:"Failed to delete workspace","error")}}function fo(){e(y)&&(a(se,e(y).name,!0),a(H,!0))}async function go(){if(!e(y)||!e(se).trim())return;const t=e(se).trim();if(t.toLowerCase()===e(y).name.toLowerCase()){a(H,!1);return}if(e(c).some(l=>{if(l.id===e(y).id)return!1;if(l.name.toLowerCase()===t.toLowerCase()){if(e(y).type==="child"&&l.type==="child")return l.parentId===e(y).parentId;if(e(y).type!=="child"&&l.type!=="child")return!0}return!1})){I(`A workspace named "${t}" already exists in this scope`,"error");return}try{await C.runtime.sendMessage({type:"RENAME_WORKSPACE",payload:{id:e(y).id,name:t}}),await le(),a(H,!1),I("Workspace renamed","success")}catch(l){I(l instanceof Error?l.message:"Failed to rename workspace","error")}}async function Ws(){if(e(y))try{await C.runtime.sendMessage({type:"SET_TRANSCENDENT",payload:{id:e(y).id,isTranscendent:!e(y).isTranscendent}}),await le(),I(e(y).isTranscendent?"Removed transcendent status":"Marked as transcendent","success")}catch(t){I(t instanceof Error?t.message:"Failed to update workspace","error")}}async function mo(){if(!e(y))return;const r=!(e(y).openInContextSwitch!==!1);try{await C.runtime.sendMessage({type:"SET_OPEN_IN_CONTEXT_SWITCH",payload:{id:e(y).id,openInContextSwitch:r}}),await le(),I(r?"Will open on context switch":"Will not open on context switch","success")}catch(l){I(l instanceof Error?l.message:"Failed to update workspace","error")}}async function ko(){if(!e(y))return;const r=!(e(y).syncEnabled!==!1);try{await C.runtime.sendMessage({type:"SET_SYNC_ENABLED",payload:{id:e(y).id,syncEnabled:r}}),await le(),I(r?"Sync enabled for this workspace":"Sync disabled - external changes will be ignored","success")}catch(l){I(l instanceof Error?l.message:"Failed to update workspace","error")}}async function wo(){if(!e(y)||!Xr(e(y)))return;const r=!(e(y).autoFocusPlayingTab===!0);try{await C.runtime.sendMessage({type:"SET_AUTO_FOCUS_PLAYING_TAB",payload:{workspaceId:e(y).id,enabled:r}}),await le(),I(r?"Auto-focus playing tab enabled":"Auto-focus playing tab disabled","success")}catch(l){I(l instanceof Error?l.message:"Failed to update workspace","error")}}async function _o(){if(!e(y)||!Xr(e(y)))return;const r=!(e(y).refocusTabOverridesPlaying===!0);try{await C.runtime.sendMessage({type:"SET_REFOCUS_TAB_OVERRIDES_PLAYING",payload:{workspaceId:e(y).id,enabled:r}}),await le(),I(r?"Refocus tab now takes priority over playing tabs":"Playing tabs will take priority over refocus tab","success")}catch(l){I(l instanceof Error?l.message:"Failed to update workspace","error")}}async function Bs(){if(!(!e(y)||e(y).type!=="standalone"))try{await C.runtime.sendMessage({type:"CONVERT_TO_PARENT",payload:{id:e(y).id}}),await le(),I(`Converted "${e(y).name}" to parent workspace`,"success")}catch(t){I(t instanceof Error?t.message:"Failed to convert workspace","error")}}async function bo(t){if(t.type==="child")try{await C.runtime.sendMessage({type:"MOVE_WORKSPACE",payload:{id:t.id,newParentId:null}}),await le(),I(`Converted "${t.name}" to standalone workspace`,"success")}catch(r){I(r instanceof Error?r.message:"Failed to convert workspace","error")}}async function yo(){if(!(!e(re)||!e(Z).trim()))try{const t=await C.runtime.sendMessage({type:"CREATE_GROUP",payload:{parentId:e(re).id,name:e(Z).trim()}});if(!t.success)throw new Error(t.error||"Failed to create group");await le(),I(`Created group "${e(Z).trim()}"`,"success"),a(Y,!1),a(Z,""),a(re,null)}catch(t){I(t instanceof Error?t.message:"Failed to create group","error")}}async function Ds(t){if(e(q))try{const r=await C.runtime.sendMessage({type:"SET_CHILD_GROUP",payload:{childId:e(q).id,groupId:t}});if(!r.success)throw new Error(r.error||"Failed to move to group");await le(),I(t===null?`Removed "${e(q).name}" from group`:`Moved "${e(q).name}" to group`,"success"),a(P,!1),a(q,null)}catch(r){I(r instanceof Error?r.message:"Failed to move to group","error")}}async function xo(t){try{const r=await C.runtime.sendMessage({type:"SET_CHILD_GROUP",payload:{childId:t.id,groupId:null}});if(!r.success)throw new Error(r.error||"Failed to remove from group");await le(),I(`Removed "${t.name}" from group`,"success")}catch(r){I(r instanceof Error?r.message:"Failed to remove from group","error")}}async function Ns(t,r){try{const l=await C.runtime.sendMessage({type:"TOGGLE_GROUP_COLLAPSED",payload:{parentId:r.id,groupId:t.id}});if(!l.success)throw new Error(l.error||"Failed to toggle group");await le()}catch(l){I(l instanceof Error?l.message:"Failed to toggle group","error")}}function Co(t,r,l){t.preventDefault(),t.stopPropagation(),a(U,{group:r,parent:l,x:t.clientX,y:t.clientY},!0)}async function So(){if(!(!e(G)||!e(de)||!e(ce).trim()))try{const t=await C.runtime.sendMessage({type:"RENAME_GROUP",payload:{parentId:e(G).id,groupId:e(de),name:e(ce).trim()}});if(!t.success)throw new Error(t.error||"Failed to rename group");await le(),I(`Renamed group to "${e(ce).trim()}"`,"success"),a(te,!1),a(G,null),a(de,null),a(ce,"")}catch(t){I(t instanceof Error?t.message:"Failed to rename group","error")}}async function To(){if(!(!e(W)||!e(R)))try{const t=await C.runtime.sendMessage({type:"DELETE_GROUP",payload:{parentId:e(W).id,groupId:e(R)}});if(!t.success)throw new Error(t.error||"Failed to delete group");await le(),I("Group deleted","success"),a(F,!1),a(W,null),a(R,null)}catch(t){I(t instanceof Error?t.message:"Failed to delete group","error")}}async function Mo(t,r,l){var v;try{const h=await C.runtime.sendMessage({type:"SET_CHILD_GROUP",payload:{childId:t,groupId:r}});if(!h.success)throw new Error(h.error||"Failed to move to group");a(J,{...As},!0),await le();const m=e(c).find(z=>z.id===t),k=e(c).find(z=>z.type==="parent"),T=(v=k==null?void 0:k.groups)==null?void 0:v.find(z=>z.id===r);m&&T&&I(`Moved "${m.name}" to "${T.name}"`,"success")}catch(h){I(h instanceof Error?h.message:"Failed to move to group","error")}}async function qs(){const t=await C.windows.getAll({populate:!0}),r=C.runtime.getURL("workspace-dashboard.html"),l=new Set(e(c).filter(k=>k.isTranscendent).map(k=>k.id));let v=0,h=0;const m=[];for(const k of t){if(!k.tabs||!k.id)continue;const T=k.tabs.find(z=>{var ae;return(ae=z.url)==null?void 0:ae.startsWith(r)});if(T){const ae=new URL(T.url).searchParams.get("workspaceId");if(ae&&l.has(ae)){h++;continue}}v++,m.push(k.id)}return{windowsToClose:v,transcendentToKeep:h,windowIds:m}}async function Os(t){if(t.type!=="parent"){I("Context switch is only available for parent workspaces","error");return}if(e(c).filter(v=>v.type==="child"&&v.parentId===t.id).length===0){I("This parent context has no child workspaces","error");return}const l=await qs();a(V,{windowsToClose:l.windowsToClose,transcendentToKeep:l.transcendentToKeep},!0),a(B,t,!0),a(ie,!0)}async function Io(){var t;if(!(!e(B)||e(B).type!=="parent"))try{const r=e(c).filter(m=>m.type==="child"&&m.parentId===e(B).id&&m.openInContextSwitch!==!1),l=await qs(),v=await C.windows.getCurrent();for(const m of l.windowIds)if(m!==v.id)try{await C.windows.remove(m)}catch(k){console.warn("Failed to close window:",m,k)}let h=0;for(const m of r){const k=m.tabs||[];if(k.length>0){const T=new URL(C.runtime.getURL("workspace-dashboard.html"));T.searchParams.set("workspaceId",m.id),T.searchParams.set("type","child"),T.searchParams.set("transcendent",m.isTranscendent.toString()),T.searchParams.set("parentId",m.parentId);const z=await C.windows.create({url:T.toString(),focused:!1});if(z.id){const ae=await C.tabs.query({windowId:z.id});(t=ae[0])!=null&&t.id&&await C.tabs.update(ae[0].id,{pinned:!0});for(const Se of k)await C.tabs.create({windowId:z.id,url:Se.url,pinned:Se.pinned||!1,active:!1});h++}}}a(Ee,e(B).id,!0),await C.storage.local.set({activeContextId:e(B).id}),v.id&&l.windowIds.includes(v.id)&&await C.windows.remove(v.id),I(`Switched to "${e(B).name}" context (${h} windows opened)`,"success")}catch(r){I(r instanceof Error?r.message:"Failed to switch context","error")}finally{a(ie,!1),a(B,null)}}function Ao(){a(ie,!1),a(B,null)}async function Eo(t){await Os(t)}async function ds(t){var l;if(t.type==="parent")return;if(e(ke).has(t.id)){await Po(t.id);return}const r=t.tabs||[];try{const v=new URL(C.runtime.getURL("workspace-dashboard.html"));v.searchParams.set("workspaceId",t.id),v.searchParams.set("type",t.type),v.searchParams.set("transcendent",t.isTranscendent.toString()),t.type==="child"&&v.searchParams.set("parentId",t.parentId);const h=await C.windows.create({url:v.toString(),focused:!0});if(h.id){const m=await C.tabs.query({windowId:h.id});(l=m[0])!=null&&l.id&&await C.tabs.update(m[0].id,{pinned:!0});for(const k of r)await C.tabs.create({windowId:h.id,url:k.url,pinned:k.pinned||!1,active:!1})}I(r.length>0?`Opened ${r.length} tabs in new window`:"Opened workspace in new window","success"),await da(),ia()}catch(v){I(v instanceof Error?v.message:"Failed to open in new window","error")}}async function Po(t){var r;try{const l=await C.windows.getAll({populate:!0}),v=C.runtime.getURL("workspace-dashboard.html");for(const h of l)if(!(!h.tabs||!h.id)){for(const m of h.tabs)if((r=m.url)!=null&&r.startsWith(v)&&new URL(m.url).searchParams.get("workspaceId")===t){await C.windows.update(h.id,{focused:!0}),I("Brought window to front","success");return}}I("Window not found","error")}catch(l){I(l instanceof Error?l.message:"Failed to bring window to front","error")}}async function Fs(t){var l;if(t.type!=="parent")return;const r=e(c).filter(v=>v.type==="child"&&v.parentId===t.id);if(r.length===0){I("This parent has no child workspaces","error");return}try{let v=0;for(const h of r){const m=h.tabs||[],k=new URL(C.runtime.getURL("workspace-dashboard.html"));k.searchParams.set("workspaceId",h.id),k.searchParams.set("type","child"),k.searchParams.set("transcendent",h.isTranscendent.toString()),k.searchParams.set("parentId",h.parentId);const T=await C.windows.create({url:k.toString(),focused:!1});if(T.id){const z=await C.tabs.query({windowId:T.id});(l=z[0])!=null&&l.id&&await C.tabs.update(z[0].id,{pinned:!0});for(const ae of m)await C.tabs.create({windowId:T.id,url:ae.url,pinned:ae.pinned||!1,active:!1});v++}}I(`Opened ${v} windows for "${t.name}"`,"success"),await da(),ia()}catch(v){I(v instanceof Error?v.message:"Failed to open windows","error")}}async function zo(t){if(t.type!=="parent")return;const r=e(c).filter(l=>l.type==="child"&&l.parentId===t.id);if(r.length===0){I("This parent has no child workspaces","error");return}try{let l=0;for(const v of r)e(ke).has(v.id)&&(await C.runtime.sendMessage({type:"CLOSE_WORKSPACE_WINDOWS",payload:{workspaceId:v.id}})).success&&l++;l>0?(I(`Closed ${l} window${l>1?"s":""} for "${t.name}"`,"success"),await da(),ia()):I("No windows were open for this context","info")}catch(l){I(l instanceof Error?l.message:"Failed to close windows","error")}}function Lo(t,r){t.preventDefault(),a(d,r.id,!0),a(A,{workspace:r,x:t.clientX,y:t.clientY},!0)}const Ro=me(()=>{if(!e(A))return[];const t=e(A).workspace,r=[];if(t.type==="parent"){const l=e(c).filter(k=>k.type==="child"&&k.parentId===t.id).length,v=ta(t);r.push({id:"switch-context",label:v?"All Windows Open":"Switch to Context",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>',disabled:l===0||v}),r.push({id:"open-all-windows",label:"Open All in New Windows",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6z"/></svg>',disabled:l===0||v});const m=e(c).filter(k=>k.type==="child"&&k.parentId===t.id).some(k=>e(ke).has(k.id));r.push({id:"close-context",label:"Close Context",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>',disabled:!m}),r.push({id:"sep0",label:"",separator:!0}),r.push({id:"create-subgroup",label:"Create Subgroup",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"/></svg>'}),r.push({id:"sep0a",label:"",separator:!0})}if(t.type!=="parent"){const l=e(ke).has(t.id);r.push({id:"open-new-window",label:l?"Bring to Front":"Open in New Window",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/></svg>'}),r.push({id:"sep0",label:"",separator:!0})}if(t.type==="child"){const l=t,v=e(c).find(m=>m.id===l.parentId),h=(v==null?void 0:v.groups)&&v.groups.length>0;r.push({id:"move-to-group",label:l.groupId?"Change Group":"Move to Group",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"/></svg>',disabled:!h}),l.groupId&&r.push({id:"remove-from-group",label:"Remove from Group",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>'}),r.push({id:"convert-to-standalone",label:"Convert to Standalone",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 18a8 8 0 100-16 8 8 0 000 16zM4.332 8.027a6.012 6.012 0 011.912-2.706C6.512 5.73 6.974 6 7.5 6A1.5 1.5 0 019 7.5V8a2 2 0 004 0 2 2 0 011.523-1.943A5.977 5.977 0 0116 10c0 .34-.028.675-.083 1H15a2 2 0 00-2 2v2.197A5.973 5.973 0 0110 16v-2a2 2 0 00-2-2 2 2 0 01-2-2 2 2 0 00-1.668-1.973z"/></svg>'})}return r.push({id:"rename",label:"Rename",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>'}),t.type==="standalone"&&r.push({id:"convert-to-parent",label:"Convert to Parent",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 14v6m-3-3h6M6 10h2a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2z"/></svg>'}),r.push({id:"toggle-transcendent",label:t.isTranscendent?"Remove Transcendent":"Make Transcendent",icon:'<svg fill="currentColor" viewBox="0 0 20 20"><path d="M14.5 10c0 1.38-1.12 2.5-2.5 2.5-.83 0-1.57-.41-2.02-1.03L8.5 10l1.48-1.47A2.49 2.49 0 0112 7.5c1.38 0 2.5 1.12 2.5 2.5z"/></svg>'}),r.push({id:"export-bookmarks",label:t.type==="parent"?"Export Context to Bookmarks":"Export to Bookmarks",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"/></svg>'}),r.push({id:"sep1",label:"",separator:!0}),r.push({id:"archive",label:t.type==="parent"?"Archive Context":"Archive",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"/></svg>'}),r.push({id:"delete",label:"Delete",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>',danger:!0}),r});function Wo(t){if(!e(A))return;const r=e(A).workspace;switch(t){case"switch-context":Os(r);break;case"open-all-windows":Fs(r);break;case"close-context":zo(r);break;case"open-new-window":ds(r);break;case"rename":a(se,r.name,!0),a(H,!0);break;case"convert-to-parent":Bs();break;case"convert-to-standalone":bo(r);break;case"toggle-transcendent":Ws();break;case"export-bookmarks":r.type==="parent"?Ho(r.id):Uo(r.id);break;case"archive":r.type==="parent"?jo(r.id):Fo(r.id);break;case"delete":Rs(r);break;case"create-subgroup":r.type==="parent"&&(a(re,r,!0),a(Z,""),a(Y,!0));break;case"move-to-group":r.type==="child"&&(a(q,r,!0),a(P,!0));break;case"remove-from-group":r.type==="child"&&xo(r);break}a(A,null)}const Bo=me(()=>{if(!e(U))return[];const{group:t}=e(U),r=[];return r.push({id:"rename-group",label:"Rename Group",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>'}),r.push({id:"toggle-group-collapsed",label:t.collapsed?"Expand Group":"Collapse Group",icon:t.collapsed?'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>':'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"/></svg>'}),r.push({id:"sep-group",label:"",separator:!0}),r.push({id:"delete-group",label:"Delete Group",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>',danger:!0}),r});function Do(t){if(!e(U))return;const{group:r,parent:l}=e(U);switch(t){case"rename-group":a(G,l,!0),a(de,r.id,!0),a(ce,r.name,!0),a(te,!0);break;case"toggle-group-collapsed":Ns(r,l);break;case"delete-group":a(W,l,!0),a(R,r.id,!0),a(F,!0);break}a(U,null)}const No=me(()=>{var k,T;if(!e(S)||!e(y))return[];const t=[];t.push({id:"open-background",label:"Open in Background",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/></svg>'}),t.push({id:"save-to-resources",label:"Convert to Resource",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"/></svg>'}),t.push({id:"sep-refocus",label:"",separator:!0});const r=e(y);((k=r.refocusTab)==null?void 0:k.url)===e(S).tab.url&&((T=r.refocusTab)==null?void 0:T.index)===e(S).tabIndex?t.push({id:"clear-refocus",label:"Clear Refocus Tab",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>'}):t.push({id:"set-refocus",label:"Set as Refocus Tab",icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"/></svg>'}),t.push({id:"sep-move",label:"",separator:!0});const v=e(c).filter(z=>(z.type==="child"||z.type==="standalone")&&z.id!==e(y).id&&!z.archivedAt),h=e(c).filter(z=>z.type==="parent"&&!z.archivedAt);for(const z of h){const ae=v.filter(Se=>Se.type==="child"&&Se.parentId===z.id);if(ae.length>0){t.push({id:`header-${z.id}`,label:`๐Ÿ“ ${z.name}`,disabled:!0});for(const Se of ae)t.push({id:`move-${Se.id}`,label:`    ${Se.name}`,icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6"/></svg>'})}}const m=v.filter(z=>z.type==="standalone");if(m.length>0){t.push({id:"header-standalone",label:"๐ŸŒ Standalone",disabled:!0});for(const z of m)t.push({id:`move-${z.id}`,label:`    ${z.name}`,icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6"/></svg>'})}if(e(ue)&&Object.keys(e(fe)).length>0){t.push({id:"sep-send",label:"",separator:!0});const z={chrome:"๐Ÿ”ต",firefox:"๐ŸฆŠ",edge:"๐Ÿ”ท"};for(const[ae,Se]of Object.entries(e(fe))){const $e=z[ae]||"๐ŸŒ",st=ae.charAt(0).toUpperCase()+ae.slice(1);t.push({id:`send-header-${ae}`,label:`${$e} Send to ${st}`,disabled:!0});const zt=new Map,Gt=[];for(const Ke of Se)Ke.parentName&&Ke.parentId?(zt.has(Ke.parentId)||zt.set(Ke.parentId,[]),zt.get(Ke.parentId).push(Ke)):Gt.push(Ke);for(const[Ke,Ge]of zt){const Lt=Ge[0].parentName;t.push({id:`send-parent-${ae}-${Ke}`,label:`    ๐Ÿ“ ${Lt}`,disabled:!0});for(const Dt of Ge)t.push({id:`send-${ae}::${Dt.id}::${Dt.name}`,label:`        ${Dt.name}`,icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>'})}for(const Ke of Gt)t.push({id:`send-${ae}::${Ke.id}::${Ke.name}`,label:`    ${Ke.name}`,icon:'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>'})}}return t});function qo(t,r,l){t.preventDefault(),a(S,{tab:r,tabIndex:l,x:t.clientX,y:t.clientY},!0)}async function Oo(t){if(!(!e(S)||!e(y))){if(t==="open-background")Js(e(S).tab);else if(t==="save-to-resources")await js(e(S).tab,e(S).tabIndex);else if(t==="set-refocus")try{await C.runtime.sendMessage({type:"SET_REFOCUS_TAB",payload:{workspaceId:e(y).id,url:e(S).tab.url,index:e(S).tabIndex}}),await le()}catch(r){console.error("Failed to set refocus tab:",r)}else if(t==="clear-refocus")try{await C.runtime.sendMessage({type:"CLEAR_REFOCUS_TAB",payload:{workspaceId:e(y).id}}),await le()}catch(r){console.error("Failed to clear refocus tab:",r)}else if(t.startsWith("move-")){const r=t.replace("move-","");await Us(e(S).tab,e(S).tabIndex,r)}else if(t.startsWith("send-")&&!t.startsWith("send-header-")&&!t.startsWith("send-parent-")){const r=t.replace("send-",""),[l,v,...h]=r.split("::"),m=h.join("::");try{const k=await C.runtime.sendMessage({type:"SEND_TAB_TRANSFER",payload:{target_browser:l,target_workspace_id:v,target_workspace_name:m,tab:{url:e(S).tab.url,title:e(S).tab.title,pinned:e(S).tab.pinned}}});if(k.success){const T=l.charAt(0).toUpperCase()+l.slice(1);I(`Sent to ${T} โ†’ ${m}`,"success")}else I(k.error||"Transfer failed","error")}catch(k){I(k instanceof Error?k.message:"Transfer failed","error")}}a(S,null)}}async function js(t,r){if(e(y))try{const l=Xa("url",t.title||new URL(t.url).hostname,t.url,t.favIconUrl);if(await pa(l),s.workspaceId===e(y).id)try{const k=await C.windows.getCurrent();if(k.id){const z=(await C.tabs.query({windowId:k.id})).find(ae=>ae.url===t.url);z!=null&&z.id&&await C.tabs.remove(z.id)}}catch(k){console.warn("Could not close browser tab:",k)}const h=(e(y).tabs||[]).filter((k,T)=>T!==r),m=JSON.parse(JSON.stringify(h));await C.runtime.sendMessage({type:"UPDATE_TABS",payload:{id:e(y).id,tabs:m}}),await le(),I("Tab converted to resource","success")}catch(l){console.error("[Dashboard] Failed to convert tab to resource:",l),I("Failed to convert tab to resource","error")}}async function Us(t,r,l){if(e(y))try{const v=JSON.parse(JSON.stringify(t)),h=await C.runtime.sendMessage({type:"MOVE_TAB",payload:{sourceWorkspaceId:e(y).id,targetWorkspaceId:l,tab:v,tabIndex:r}});if(h.success){const m=e(c).find(k=>k.id===l);I(`Moved tab to "${(m==null?void 0:m.name)||"workspace"}"`,"success"),await le()}else I(h.error||"Failed to move tab","error")}catch(v){console.error("Failed to move tab:",v),I("Failed to move tab","error")}}async function Fo(t){try{await C.runtime.sendMessage({type:"ARCHIVE_WORKSPACE",payload:{workspaceId:t}}),I("Workspace archived","success"),await le()}catch(r){console.error("Failed to archive workspace:",r),I("Failed to archive workspace","error")}}async function jo(t){try{const r=await C.runtime.sendMessage({type:"ARCHIVE_CONTEXT",payload:{parentId:t}});I(`Archived context (${r.archivedCount} workspaces)`,"success"),await le()}catch(r){console.error("Failed to archive context:",r),I("Failed to archive context","error")}}async function Uo(t){try{const r=await C.runtime.sendMessage({type:"EXPORT_TO_BOOKMARKS",payload:{workspaceId:t}});r.success?I(`Exported ${r.bookmarkCount} bookmarks`,"success"):I(r.error||"Failed to export","error")}catch(r){console.error("Failed to export to bookmarks:",r),I("Failed to export to bookmarks","error")}}async function Ho(t){try{const r=await C.runtime.sendMessage({type:"EXPORT_CONTEXT_TO_BOOKMARKS",payload:{parentId:t}});r.success?I(`Exported context with ${r.bookmarkCount} bookmarks`,"success"):I(r.error||"Failed to export context","error")}catch(r){console.error("Failed to export context to bookmarks:",r),I("Failed to export context to bookmarks","error")}}async function Vo(t){if(!t||t.length<2){a(ne,null);return}a(ge,!0);try{const r=await C.runtime.sendMessage({type:"SEARCH",payload:{query:t,generateMissingSummaries:e(Re)}});a(ne,r,!0)}catch(r){console.error("Search error:",r),a(ne,null)}finally{a(ge,!1)}}function $o(t){t.type==="workspace"?a(d,t.id,!0):t.workspaceId&&a(d,t.workspaceId,!0),a(ne,null),(t.type==="tab"||t.type==="resource")&&(ut&&clearTimeout(ut),a(Le,null),requestAnimationFrame(()=>{if(t.type==="resource"){const r=e(c).find(l=>l.id===t.workspaceId);if(r!=null&&r.resources){const l=parseInt(t.id.split(":resource:")[1],10),v=r.resources[l];v&&(a(Le,v.id,!0),setTimeout(()=>{const h=document.querySelector(`[data-resource-id="${v.id}"]`);h==null||h.scrollIntoView({behavior:"smooth",block:"center"})},50))}}else t.type==="tab"&&t.url&&(a(Le,t.url,!0),setTimeout(()=>{const r=document.querySelector(`[data-tab-url="${CSS.escape(t.url)}"]`);r==null||r.scrollIntoView({behavior:"smooth",block:"center"})},50));ut=setTimeout(()=>{a(Le,null)},1800)}))}function Go(t){const r=t.type==="child"?t.parentId:null;a(J,{isDragging:!0,draggedId:t.id,draggedType:"workspace",selectedIds:[t.id],dropTargetId:null,dropPosition:null,sourceParentId:r},!0)}function Ko(t,r){if(!e(J).isDragging||!e(J).draggedId)return;if(e(J).draggedType==="tab"){(t.type==="child"||t.type==="standalone")&&t.id!==e(J).sourceParentId?a(J,{...e(J),dropTargetId:t.id,dropPosition:"inside"},!0):a(J,{...e(J),dropTargetId:null,dropPosition:null},!0);return}const l={id:e(J).draggedId,type:e(J).draggedType,parentId:e(J).sourceParentId};to(l,t.id,r,e(c)).allowed?a(J,{...e(J),dropTargetId:t.id,dropPosition:r},!0):a(J,{...e(J),dropTargetId:null,dropPosition:null},!0)}function Yo(){e(J).isDragging&&a(J,{...e(J),dropTargetId:null,dropPosition:null},!0)}async function Jo(t){if(!e(J).isDragging||!e(J).draggedId||!e(J).dropTargetId){ha();return}if(e(J).draggedType==="tab"){await Xo(t);return}const r={id:e(J).draggedId,type:e(J).draggedType,parentId:e(J).sourceParentId},l=to(r,t.id,e(J).dropPosition,e(c));if(!l.allowed){I(l.reason||"Cannot drop here","error"),ha();return}if(!cv(r,t.id,e(J).dropPosition,e(c))){ha();return}try{const h=e(c).find(m=>m.id===e(J).draggedId);if(!h){ha();return}e(J).dropPosition==="inside"&&t.type==="parent"&&(await C.runtime.sendMessage({type:"MOVE_WORKSPACE",payload:{id:e(J).draggedId,newParentId:t.id}}),I(`Moved "${h.name}" into "${t.name}"`,"success")),await le()}catch(h){I(h instanceof Error?h.message:"Failed to move workspace","error")}finally{ha()}}async function Xo(t){var T;const r=(T=e(J).draggedId)==null?void 0:T.match(/^tab-(\d+)$/);if(!r){I("Invalid tab drag data","error"),ha();return}const l=parseInt(r[1],10),v=e(J).sourceParentId;if(!v){I("Cannot determine source workspace","error"),ha();return}const h=e(c).find(z=>z.id===v);if(!h||h.type!=="child"&&h.type!=="standalone"){I("Source workspace not found","error"),ha();return}const m=h.tabs;if(l<0||l>=m.length){I("Invalid tab index","error"),ha();return}const k=m[l];try{await Us(k,l,t.id)}finally{ha()}}function ha(){a(J,{...As},!0)}function Qo(t,r,l){var h,m;if(!e(y))return;const v={type:"tab",sourceWorkspaceId:e(y).id,tabIndex:l,tab:r};(h=t.dataTransfer)==null||h.setData("application/json",JSON.stringify(v)),(m=t.dataTransfer)==null||m.setData("text/plain",r.url),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"),a(J,{isDragging:!0,draggedId:`tab-${l}`,draggedType:"tab",selectedIds:[`tab-${l}`],dropTargetId:null,dropPosition:null,sourceParentId:e(y).id},!0)}function Zo(){ha()}function en(t){t.preventDefault(),a(nt,!0),document.addEventListener("mousemove",Hs),document.addEventListener("mouseup",Vs),document.body.style.cursor="ew-resize",document.body.style.userSelect="none"}function Hs(t){if(!e(nt))return;const r=Math.min(Mt,Math.max(tt,t.clientX));a(at,r,!0),a(ht,!0)}function Vs(){a(nt,!1),document.removeEventListener("mousemove",Hs),document.removeEventListener("mouseup",Vs),document.body.style.cursor="",document.body.style.userSelect=""}function tn(t){t.preventDefault(),a(gt,!0),document.addEventListener("mousemove",$s),document.addEventListener("mouseup",Gs),document.body.style.cursor="ew-resize",document.body.style.userSelect="none"}function $s(t){if(!e(gt))return;const r=window.innerWidth,l=Math.min(Aa,Math.max(Ut,r-t.clientX));a(St,l,!0)}function Gs(){a(gt,!1),document.removeEventListener("mousemove",$s),document.removeEventListener("mouseup",Gs),document.body.style.cursor="",document.body.style.userSelect="",Ks()}async function an(){a(ft,!e(ft)),await Ks()}async function Ks(){if(!(!e(y)||e(y).type==="parent"))try{await C.runtime.sendMessage({type:"UPDATE_WORKSPACE",payload:{id:e(y).id,updates:{notesSidebarExpanded:e(ft),notesSidebarWidth:e(St)}}})}catch(t){console.error("Failed to save notes sidebar state:",t)}}async function sn(t){if(!e(y)||e(y).type==="parent")return;const r=e(y).tabs||[],l=r[t];if(l.pinned){I("Cannot remove locked tab. Unlock it first.","error");return}const v=r.filter((h,m)=>m!==t);try{const h=JSON.parse(JSON.stringify(v));await C.runtime.sendMessage({type:"UPDATE_TABS",payload:{id:e(y).id,tabs:h}});let m=!1;if(s.workspaceId===e(y).id)try{const k=await C.windows.getCurrent();if(k.id){const z=(await C.tabs.query({windowId:k.id})).find(ae=>ae.url===l.url);z!=null&&z.id&&(await C.tabs.remove(z.id),m=!0)}}catch(k){console.warn("Could not close browser tab:",k)}await le(),I(m?"Tab removed and closed":"Tab removed","success")}catch(h){I(h instanceof Error?h.message:"Failed to remove tab","error")}}async function rn(t){if(!e(y)||e(y).type==="parent")return;const r=e(y).tabs||[],l=r[t],v=!l.pinned,h=r.map((m,k)=>k===t?{...m,pinned:v}:m);try{const m=JSON.parse(JSON.stringify(h));if(await C.runtime.sendMessage({type:"UPDATE_TABS",payload:{id:e(y).id,tabs:m}}),s.workspaceId===e(y).id)try{const k=await C.windows.getCurrent();if(k.id){const z=(await C.tabs.query({windowId:k.id})).find(ae=>ae.url===l.url);z!=null&&z.id&&await C.tabs.update(z.id,{pinned:v})}}catch(k){console.warn("Could not pin/unpin browser tab:",k)}await le(),I(v?"Tab locked and pinned":"Tab unlocked and unpinned","success")}catch(m){I(m instanceof Error?m.message:"Failed to update tab","error")}}async function on(){if(!(!e(y)||e(y).type==="parent"))try{const t=await C.windows.getCurrent(),r=await C.tabs.query({windowId:t.id}),l=C.runtime.getURL("workspace-dashboard.html"),v=r.filter(h=>h.url&&!h.url.startsWith(l)).map(h=>({url:h.url,title:h.title||h.url,pinned:h.pinned}));a(D,v,!0),e(yt)&&e(yt).id!==e(y).id?a($,!0):await Ys()}catch(t){I(t instanceof Error?t.message:"Failed to capture tabs","error")}}async function Ys(){if(!(!e(y)||e(D).length===0))try{const t=e(D).map(r=>({...r}));await C.runtime.sendMessage({type:"UPDATE_TABS",payload:{id:e(y).id,tabs:t}}),await le(),I(`Saved ${e(D).length} tabs to "${e(y).name}"`,"success"),a($,!1),a(D,[],!0)}catch(t){I(t instanceof Error?t.message:"Failed to save tabs","error")}}async function nn(){if(!e(y)||e(y).type==="parent")return;const t=e(y).tabs||[];if(t.length===0){I("No tabs to deduplicate","info");return}const r=new Set,l=[],v=[];for(const h of t)r.has(h.url)?v.push(h.url):(r.add(h.url),l.push(h));if(v.length===0){I("No duplicate tabs found","info");return}try{const h=JSON.parse(JSON.stringify(l));await C.runtime.sendMessage({type:"UPDATE_TABS",payload:{id:e(y).id,tabs:h}});let m=0;if(s.workspaceId===e(y).id)try{const T=await C.windows.getCurrent();if(T.id){const z=await C.tabs.query({windowId:T.id}),ae=C.runtime.getURL("workspace-dashboard.html"),Se=new Set,$e=[];for(const st of z)!st.url||st.url.startsWith(ae)||(Se.has(st.url)?st.id&&$e.push(st.id):Se.add(st.url));$e.length>0&&(await C.tabs.remove($e),m=$e.length)}}catch(T){console.warn("Could not close duplicate browser tabs:",T)}await le();const k=m>0?`Removed ${v.length} duplicate(s) and closed ${m} tab(s)`:`Removed ${v.length} duplicate(s) from saved tabs`;I(k,"success")}catch(h){I(h instanceof Error?h.message:"Failed to deduplicate tabs","error")}}async function ln(t){try{const r=await C.windows.getCurrent(),v=(await C.tabs.query({windowId:r.id})).find(h=>h.url===t.url);v&&v.id?await C.tabs.update(v.id,{active:!0}):await C.tabs.create({url:t.url,active:!0})}catch(r){console.error("Failed to activate/open tab:",r),window.open(t.url,"_blank")}}async function Js(t){try{await C.tabs.create({url:t.url,active:!1})}catch(r){console.error("Failed to open tab in background:",r),window.open(t.url,"_blank")}}async function cn(){try{const r=(await C.storage.local.get("claudeSettings")).claudeSettings;a(Re,(r==null?void 0:r.enabled)&&!!(r!=null&&r.apiKey),!0)}catch(t){console.error("Failed to check Claude configuration:",t),a(Re,!1)}}async function dn(){if(!(!e(Re)||e(qe))){a(qe,!0);try{const t=await pt.getSuggestions(e(c));t.success?(a(Ve,t.suggestions,!0),t.suggestions.length===0?I("Your workspaces are well organized!","success"):I(`Found ${t.suggestions.length} suggestions`,"info")):I(t.error||"Failed to get suggestions","error")}catch(t){I(t instanceof Error?t.message:"Failed to get suggestions","error")}finally{a(qe,!1)}}}async function vn(t){const r=t.suggestedAction;try{switch(r.type){case"createParent":{const l=r.params.name||"New Parent",v=r.params.childIds||t.affectedWorkspaces,h=await C.runtime.sendMessage({type:"CREATE_PARENT",payload:{name:l}});if(h.success&&v.length>0)for(const m of v)await C.runtime.sendMessage({type:"MOVE_WORKSPACE",payload:{id:m,newParentId:h.workspace.id}});break}case"mergeWorkspaces":{const l=r.params.targetId||t.affectedWorkspaces[0],v=r.params.sourceIds||t.affectedWorkspaces.filter(h=>h!==l);for(const h of v){const m=e(c).find(T=>T.id===h),k=e(c).find(T=>T.id===l);if(m&&k&&"tabs"in m&&"tabs"in k){const T=[...k.tabs,...m.tabs].map(z=>({...z}));await C.runtime.sendMessage({type:"UPDATE_TABS",payload:{id:l,tabs:T}}),await C.runtime.sendMessage({type:"DELETE_WORKSPACE",payload:{id:h,keepChildren:!1}})}}break}case"renameWorkspace":{const l=t.affectedWorkspaces[0],v=r.params.newName;l&&v&&await C.runtime.sendMessage({type:"RENAME_WORKSPACE",payload:{id:l,name:v}});break}case"setTranscendent":{for(const l of t.affectedWorkspaces)await C.runtime.sendMessage({type:"SET_TRANSCENDENT",payload:{id:l,isTranscendent:!0}});break}case"splitWorkspace":{I("Split workspace requires manual action","info"),vs(t);return}}await le(),vs(t),I("Suggestion applied successfully","success")}catch(l){I(l instanceof Error?l.message:"Failed to apply suggestion","error")}}function vs(t){a(Ve,e(Ve).filter(r=>r.description!==t.description),!0)}function un(){C.runtime.openOptionsPage()}async function us(t){var r;try{const l=t.map(h=>({url:h.url,title:h.title})),v=await C.runtime.sendMessage({type:"ENRICH_TABS",payload:{tabs:l,maxTabs:15}});if(v.success&&((r=v.result)!=null&&r.tabs))return v.result.tabs}catch(l){console.warn("[Dashboard] Failed to enrich tabs:",l)}return t}async function pn(){var t;if(!(!e(y)||e(ot)||!e(Re))){if((t=e(y).summary)!=null&&t.isUserGenerated){I("Cannot overwrite user-generated summary. Edit it instead.","info");return}a(ot,!0);try{const l=(await C.storage.local.get("claudeSettings")).claudeSettings;if(!(l!=null&&l.enabled)||!(l!=null&&l.apiKey)){I("Claude API not configured","error");return}const v=xs();v.setApiKey(l.apiKey),l.model&&v.setModel(l.model);let h;if(e(y).type==="parent"){const m=e(c).filter(T=>T.type==="child"&&T.parentId===e(y).id);for(const T of m)if(!T.summary){const z=await us(T.tabs.map(Se=>({url:Se.url,title:Se.title}))),ae=await pt.generateSummaryFromTabs(T.name,z);ae.success&&ae.summary&&await C.runtime.sendMessage({type:"UPDATE_SUMMARY",payload:{id:T.id,text:ae.summary,isUserGenerated:!1}})}await le();const k=e(c).filter(T=>T.type==="child"&&T.parentId===e(y).id);h=await pt.generateSummaryFromChildren(e(y).name,k.map(T=>{var z;return{name:T.name,summary:(z=T.summary)==null?void 0:z.text}}))}else{const m=e(y).tabs||[],k=await us(m);h=await pt.generateSummaryFromTabs(e(y).name,k)}h.success&&h.summary?(await C.runtime.sendMessage({type:"UPDATE_SUMMARY",payload:{id:e(y).id,text:h.summary,isUserGenerated:!1}}),await le(),I("Summary generated","success")):I(h.error||"Failed to generate summary","error")}catch(r){I(r instanceof Error?r.message:"Failed to generate summary","error")}finally{a(ot,!1)}}}async function hn(){if(!(!e(y)||e(ot)||!e(Re))){a(ot,!0);try{const r=(await C.storage.local.get("claudeSettings")).claudeSettings;if(!(r!=null&&r.enabled)||!(r!=null&&r.apiKey)){I("Claude API not configured","error");return}const l=xs();l.setApiKey(r.apiKey),r.model&&l.setModel(r.model);let v;if(e(y).type==="parent"){const h=e(c).filter(m=>m.type==="child"&&m.parentId===e(y).id);v=await pt.generateSummaryFromChildren(e(y).name,h.map(m=>{var k;return{name:m.name,summary:(k=m.summary)==null?void 0:k.text}}))}else{const h=e(y).tabs||[],m=await us(h);v=await pt.generateSummaryFromTabs(e(y).name,m)}v.success&&v.summary?(await C.runtime.sendMessage({type:"UPDATE_SUMMARY",payload:{id:e(y).id,text:v.summary,isUserGenerated:!1}}),await le(),I("Summary regenerated","success")):I(v.error||"Failed to regenerate summary","error")}catch(t){I(t instanceof Error?t.message:"Failed to regenerate summary","error")}finally{a(ot,!1)}}}function Xs(){var t;e(y)&&(a(ye,((t=e(y).summary)==null?void 0:t.text)||"",!0),a(Ze,!0))}function fn(){a(Ze,!1),a(ye,"")}async function gn(){if(!(!e(y)||!e(ye).trim()))try{await C.runtime.sendMessage({type:"UPDATE_SUMMARY",payload:{id:e(y).id,text:e(ye).trim(),isUserGenerated:!0}}),await le(),a(Ze,!1),a(ye,""),I("Summary saved","success")}catch(t){I(t instanceof Error?t.message:"Failed to save summary","error")}}var Qs=Vu(),Zs=ee(Qs),er=o(Zs),tr=o(er),ar=o(tr),mn=i(o(ar),2),kn=i(o(mn),2),sr=o(kn),wn=o(sr),_n=o(wn),rr=i(sr,4),bn=o(rr),yn=o(bn),ps=i(rr,4);let or;var nr=o(ps);let ir;var xn=o(nr),lr=i(ps,4);let cr;var dr=o(lr);let vr;var Cn=o(dr),ur=i(ar,2),Sn=o(ur);{var Tn=t=>{var r=vv(),l=ee(r),v=i(o(l),2),h=i(o(v),2);h.__click=()=>a(d,e(yt).id,!0);var m=o(h),k=i(h,2);{var T=ae=>{var Se=dv(),$e=i(ee(Se),2);$e.__click=()=>a(d,e(Ht).id,!0);var st=o($e);L(()=>E(st,e(Ht).name)),n(ae,Se)};x(k,ae=>{e(Ht)&&ae(T)})}var z=i(l,2);z.__click=()=>a(K,!0),L(()=>E(m,e(yt).name)),n(t,r)},Mn=t=>{var r=hv(),l=i(o(r),4);{var v=m=>{var k=uv();k.__click=Ls,n(m,k)},h=m=>{var k=pv();k.__click=()=>a(K,!0),n(m,k)};x(l,m=>{e(va).length===0?m(v):m(h,!1)})}n(t,r)};x(Sn,t=>{e(yt)?t(Tn):t(Mn,!1)})}var In=i(ur,2);{var An=t=>{var r=fv(),l=o(r),v=i(o(l),2),h=o(v),m=i(v,2),k=o(m);L(T=>{E(h,`Context: ${e(ba).name??""}`),E(k,`(${T??""} open)`)},[()=>Vt(e(ba))]),n(t,r)};x(In,t=>{e(ba)&&t(An)})}var pr=i(tr,2),En=o(pr);Pl(En,{placeholder:"Search workspaces and tabs... (Ctrl+K)",onSearch:Vo,onResultSelect:$o,get results(){return e(ne)},get loading(){return e(ge)}});var Pn=i(pr,2),hr=o(Pn);{var zn=t=>{var r=kv(),l=ee(r);{let h=me(()=>e(De).length>1?` (${e(De).length} tabs playing)`:"");Pe(l,{variant:"ghost",onclick:es,get title(){return`Navigate to playing tab${e(h)??""}`},children:(m,k)=>{var T=gv();n(m,T)},$$slots:{default:!0}})}var v=i(l,2);Pe(v,{variant:"ghost",onclick:Za,title:"Pause all playing media",children:(h,m)=>{var k=mv();n(h,k)},$$slots:{default:!0}}),n(t,r)};x(hr,t=>{e(be).size>0&&t(zn)})}var fr=i(hr,2);{var Ln=t=>{Pe(t,{variant:"primary",onclick:Ls,children:(r,l)=>{var v=wv();n(r,v)},$$slots:{default:!0}})};x(fr,t=>{e(yt)||t(Ln)})}var Rn=i(fr,2),gr=o(Rn);gr.__click=()=>a(pe,!e(pe));var Wn=i(gr,2);{var Bn=t=>{var r=bv(),l=ee(r);l.__click=()=>a(pe,!1);var v=i(l,2),h=o(v);h.__click=()=>{le(),a(pe,!1)};var m=i(h,2);m.__click=Ot;var k=i(m,4);k.__click=()=>{a(Ie,!0),a(pe,!1)};var T=i(k,2);T.__click=()=>{a(_e,!0),a(pe,!1)};var z=i(T,2);{var ae=st=>{var zt=_v(),Gt=ee(zt);Gt.__click=()=>{a(Ce,!0),a(pe,!1)};var Ke=i(Gt,2);Ke.__click=()=>{a(Ne,!0),a(pe,!1)},n(st,zt)};x(z,st=>{e(ue)&&st(ae)})}var Se=i(z,4);Se.__click=ua;var $e=i(Se,4);$e.__click=()=>{a(je,!0),a(pe,!1)},n(t,r)};x(Wn,t=>{e(pe)&&t(Bn)})}var Dn=i(er,2),hs=o(Dn),mr=o(hs);mr.__mousedown=en;var Nn=i(mr,2),kr=o(Nn),qn=i(o(kr),2),wr=o(qn);wr.__click=()=>$a("parent");var On=i(wr,2);On.__click=()=>$a("standalone");var Fn=i(kr,2);{var jn=t=>{var r=yv();n(t,r)},Un=t=>{var r=Fe(),l=ee(r);{var v=m=>{var k=xv(),T=o(k),z=o(T),ae=i(T,2);Pe(ae,{variant:"ghost",size:"sm",onclick:()=>le(),children:(Se,$e)=>{var st=Me("Try Again");n(Se,st)},$$slots:{default:!0}}),L(()=>E(z,e(f))),n(m,k)},h=m=>{Wi(m,{get workspaces(){return e(c)},get selectedId(){return e(d)},enableDragDrop:!0,get dragState(){return e(J)},get audibleWorkspaceIds(){return e(be)},get openWorkspaceIds(){return e(ke)},onselect:lo,oncontextmenu:Lo,ongroupcontextmenu:Co,ongrouptoggle:Ns,ongroupdrop:Mo,ondragstart:Go,ondragover:Ko,ondragleave:Yo,ondrop:Jo})};x(l,m=>{e(f)?m(v):m(h,!1)},!0)}n(t,r)};x(Fn,t=>{e(p)?t(jn):t(Un,!1)})}var _r=i(hs,2),Hn=o(_r);{var Vn=t=>{const r=me(()=>e(y).resources||[]);var l=lu(),v=o(l),h=o(v),m=o(h),k=o(m),T=o(k);{var z=Te=>{var Be=Cv(),mt=i(o(Be),2);{var It=xt=>{var ct=Me();L(Ye=>E(ct,`(${Ye??""})`),[()=>Vt(e(y))]),n(xt,ct)};x(mt,xt=>{e(y).type==="parent"&&xt(It)})}n(Te,Be)},ae=Te=>{var Be=Sv();n(Te,Be)};x(T,Te=>{ya(e(y))?Te(z):Te(ae,!1)})}var Se=i(T,2),$e=o(Se),st=i(k,2),zt=o(st),Gt=i(m,2),Ke=o(Gt),Ge=o(Ke);{var Lt=Te=>{const Be=me(()=>e(c).filter(Ye=>{var At;return Ye.type==="child"&&Ye.parentId===((At=e(y))==null?void 0:At.id)}).length),mt=me(()=>ta(e(y)));var It=Tv(),xt=ee(It);xt.__click=()=>Eo(e(y));var ct=i(xt,2);ct.__click=()=>Fs(e(y)),L(()=>{xt.disabled=e(Be)===0||e(mt),Ct(xt,"title",e(mt)?"All windows are already open":"Switch to this context"),ct.disabled=e(Be)===0||e(mt),Ct(ct,"title",e(mt)?"All windows are already open":"Open all children in new windows")}),n(Te,It)},Dt=Te=>{var Be=Mv();Be.__click=()=>ds(e(y)),n(Te,Be)};x(Ge,Te=>{e(y).type==="parent"?Te(Lt):Te(Dt,!1)})}var Bt=i(Ke,4),fa=o(Bt);{var Ca=Te=>{var Be=Iv();Be.__click=Bs,n(Te,Be)};x(fa,Te=>{e(y).type==="standalone"&&Te(Ca)})}var Sa=i(fa,2);Sa.__click=fo;var ga=i(Sa,2);ga.__click=Ws;var Ta=i(o(ga),2),it=o(Ta);it.nodeValue="Transcendent";var Pt=i(Bt,4),Qe=o(Pt);Qe.__click=()=>Rs(e(y));var et=i(h,2),lt=o(et),Yt=o(lt),Da=o(Yt);{var fs=Te=>{var Be=Av(),mt=o(Be),It=i(mt,2),xt=o(It);xt.__click=gn;var ct=i(xt,2);ct.__click=fn,L(Ye=>xt.disabled=Ye,[()=>!e(ye).trim()]),wa(mt,()=>e(ye),Ye=>a(ye,Ye)),n(Te,Be)},Zn=Te=>{var Be=Fe(),mt=ee(Be);{var It=ct=>{var Ye=zv(),At=ee(Ye),Jt=o(At),ma=i(At,2);{var rt=kt=>{var Tt=Ev();n(kt,Tt)},bt=kt=>{var Tt=Pv();n(kt,Tt)};x(ma,kt=>{e(y).summary.isUserGenerated?kt(rt):kt(bt,!1)})}L(()=>E(Jt,e(y).summary.text)),n(ct,Ye)},xt=ct=>{var Ye=Lv(),At=i(o(Ye));{var Jt=rt=>{var bt=Me('Click "Generate" to create one with AI.');n(rt,bt)},ma=rt=>{var bt=Me("Configure Claude in settings to enable AI summaries.");n(rt,bt)};x(At,rt=>{e(Re)?rt(Jt):rt(ma,!1)})}n(ct,Ye)};x(mt,ct=>{var Ye;(Ye=e(y).summary)!=null&&Ye.text?ct(It):ct(xt,!1)},!0)}n(Te,Be)};x(Da,Te=>{e(Ze)?Te(fs):Te(Zn,!1)})}var ei=i(Yt,2);{var ti=Te=>{var Be=jv(),mt=o(Be);{var It=ct=>{var Ye=Dv(),At=ee(Ye);At.__click=Xs;var Jt=i(At,2);{var ma=rt=>{var bt=Bv();bt.__click=hn;var kt=o(bt);{var Tt=Je=>{var Nt=Rv();n(Je,Nt)},Xt=Je=>{var Nt=Wv();n(Je,Nt)};x(kt,Je=>{e(ot)?Je(Tt):Je(Xt,!1)})}L(()=>bt.disabled=e(ot)),n(rt,bt)};x(Jt,rt=>{e(Re)&&rt(ma)})}n(ct,Ye)},xt=ct=>{var Ye=Fv(),At=ee(Ye);At.__click=Xs;var Jt=i(At,2);{var ma=rt=>{var bt=Ov();bt.__click=pn;var kt=o(bt);{var Tt=Je=>{var Nt=Nv();n(Je,Nt)},Xt=Je=>{var Nt=qv();n(Je,Nt)};x(kt,Je=>{e(ot)?Je(Tt):Je(Xt,!1)})}L(()=>bt.disabled=e(ot)),n(rt,bt)};x(Jt,rt=>{e(Re)&&rt(ma)})}n(ct,Ye)};x(mt,ct=>{var Ye;(Ye=e(y).summary)!=null&&Ye.text?ct(It):ct(xt,!1)})}n(Te,Be)};x(ei,Te=>{e(Ze)||Te(ti)})}var Or=i(et,2);{var ai=Te=>{const Be=me(()=>e(c).filter(rt=>{var bt;return rt.type==="child"&&rt.parentId===((bt=e(y))==null?void 0:bt.id)}));var mt=Jv(),It=o(mt),xt=o(It),ct=o(xt),Ye=i(xt,2);Pe(Ye,{variant:"secondary",size:"sm",onclick:()=>$a("child"),children:(rt,bt)=>{var kt=Me("+ Add Child");n(rt,kt)},$$slots:{default:!0}});var At=i(It,2);{var Jt=rt=>{var bt=Kv();wt(bt,21,()=>e(Be),kt=>kt.id,(kt,Tt)=>{var Xt=Gv();Xt.__click=()=>a(d,e(Tt).id,!0),Xt.__keydown=Et=>Et.key==="Enter"&&a(d,e(Tt).id,!0);var Je=o(Xt),Nt=o(Je);{var gs=Et=>{var Qt=Uv();n(Et,Qt)},xa=Et=>{var Qt=Hv();n(Et,Qt)};x(Nt,Et=>{ya(e(Tt))?Et(gs):Et(xa,!1)})}var ts=i(Nt,4),Ga=o(ts),Ka=i(Je,2),Ya=o(Ka),ms=o(Ya),ks=i(Ya,2);{var ws=Et=>{var Qt=Vv();n(Et,Qt)},_s=Et=>{var Qt=$v();Qt.__click=as=>{as.stopPropagation(),ds(e(Tt))},n(Et,Qt)};x(ks,Et=>{ya(e(Tt))?Et(ws):Et(_s,!1)})}L(()=>{var Et;E(Ga,e(Tt).name),E(ms,`${(((Et=e(Tt).tabs)==null?void 0:Et.length)||0)??""} tabs`)}),n(kt,Xt)}),n(rt,bt)},ma=rt=>{var bt=Yv();n(rt,bt)};x(At,rt=>{e(Be).length>0?rt(Jt):rt(ma,!1)})}L(()=>E(ct,`Child Workspaces (${e(Be).length??""})`)),n(Te,mt)},si=Te=>{const Be=me(()=>e(y).tabs||[]);var mt=ru(),It=o(mt),xt=o(It),ct=o(xt),Ye=i(xt,2),At=o(Ye);Pe(At,{variant:"ghost",size:"sm",onclick:nn,title:"Remove duplicate tabs",children:(kt,Tt)=>{var Xt=Xv();n(kt,Xt)},$$slots:{default:!0}});var Jt=i(At,2);Pe(Jt,{variant:"secondary",size:"sm",onclick:on,children:(kt,Tt)=>{var Xt=Me("Save Current Tabs");n(kt,Xt)},$$slots:{default:!0}});var ma=i(It,2);{var rt=kt=>{var Tt=au();wt(Tt,21,()=>e(Be),ea,(Xt,Je,Nt)=>{const gs=me(()=>{var Rt,Ma;return((Rt=e(y).refocusTab)==null?void 0:Rt.url)===e(Je).url&&((Ma=e(y).refocusTab)==null?void 0:Ma.index)===Nt});var xa=tu();let ts;xa.__contextmenu=Rt=>qo(Rt,e(Je),Nt);var Ga=o(xa);Ga.__click=()=>ln(e(Je));var Ka=o(Ga),Ya=i(Ka,2),ms=o(Ya),ks=i(Ya,2);{var ws=Rt=>{var Ma=Qv();n(Rt,Ma)};x(ks,Rt=>{e(gs)&&Rt(ws)})}var _s=i(Ga,2),Et=o(_s);Et.__click=()=>Js(e(Je));var Qt=i(Et,2);let as;Qt.__click=()=>rn(Nt);var xi=o(Qt);{var Ci=Rt=>{var Ma=Zv();n(Rt,Ma)},Si=Rt=>{var Ma=eu();n(Rt,Ma)};x(xi,Rt=>{e(Je).pinned?Rt(Ci):Rt(Si,!1)})}var ss=i(Qt,2);let Jr;ss.__click=()=>sn(Nt),L(()=>{ts=Oe(xa,1,"tab-item group svelte-1k2s006",null,ts,{locked:e(Je).pinned,dragging:e(J).isDragging&&e(J).draggedType==="tab"&&e(J).draggedId===`tab-${Nt}`,"flash-highlight":e(Le)===e(Je).url}),Ct(xa,"data-tab-url",e(Je).url),Ct(Ka,"src",`https://www.google.com/s2/favicons?domain=${new URL(e(Je).url).hostname??""}&sz=32`),E(ms,e(Je).title||e(Je).url),as=Oe(Qt,1,"tab-action-btn svelte-1k2s006",null,as,{active:e(Je).pinned}),Ct(Qt,"title",e(Je).pinned?"Unlock tab":"Lock tab (prevent removal)"),Jr=Oe(ss,1,"tab-action-btn danger svelte-1k2s006",null,Jr,{disabled:e(Je).pinned}),Ct(ss,"title",e(Je).pinned?"Unlock to remove":"Remove tab"),ss.disabled=e(Je).pinned}),Zt("dragstart",xa,Rt=>Qo(Rt,e(Je),Nt)),Zt("dragend",xa,Zo),Zt("error",Ka,Rt=>Rt.currentTarget.style.display="none"),n(Xt,xa)}),n(kt,Tt)},bt=kt=>{var Tt=su();n(kt,Tt)};x(ma,kt=>{e(Be).length>0?kt(rt):kt(bt,!1)})}L(()=>E(ct,`Saved Tabs (${e(Be).length??""})`)),n(Te,mt)};x(Or,Te=>{e(y).type==="parent"?Te(ai):Te(si,!1)})}var Fr=i(Or,2),jr=i(o(Fr),2);{var ri=Te=>{var Be=ou(),mt=o(Be);mt.__change=mo,L(()=>Fa(mt,e(y).openInContextSwitch!==!1)),n(Te,Be)};x(jr,Te=>{e(y).type==="child"&&Te(ri)})}var Ur=i(jr,2),Hr=o(Ur);Hr.__change=ko;var oi=i(Ur,2);{var ni=Te=>{var Be=iu(),mt=ee(Be),It=o(mt);It.__change=wo;var xt=i(mt,2);{var ct=Ye=>{var At=nu(),Jt=o(At);Jt.__change=_o,L(()=>Fa(Jt,e(y).refocusTabOverridesPlaying===!0)),n(Ye,At)};x(xt,Ye=>{e(y).autoFocusPlayingTab&&e(y).refocusTab&&Ye(ct)})}L(()=>Fa(It,e(y).autoFocusPlayingTab===!0)),n(Te,Be)};x(oi,Te=>{e(y).type!=="parent"&&Te(ni)})}var Vr=i(Fr,2),ii=o(Vr),$r=o(ii),li=i(o($r),2),ci=o(li),Gr=i($r,2),di=i(o(Gr),2),vi=o(di),Kr=i(Gr,2),ui=i(o(Kr),2),pi=o(ui),hi=i(Kr,2),fi=i(o(hi),2),gi=o(fi),mi=i(Vr,2),ki=o(mi);Nc(ki,{get suggestions(){return e(Ve)},get isLoading(){return e(qe)},get isConfigured(){return e(Re)},onGetSuggestions:dn,onApplySuggestion:vn,onDismissSuggestion:vs,onConfigure:un});var wi=i(v,2),_i=o(wi),Yr=o(_i);{let Te=me(()=>{var Be;return((Be=e(y))==null?void 0:Be.id)||""});zd(Yr,{get resources(){return e(r)},get workspaceId(){return e(Te)},get graphName(){return e(Ae).graphName},get logseqConnected(){return e(Ae).available},onAddResources:Be=>Be.forEach(pa),onRemoveResource:za,onTabDrop:Be=>js(Be.tab,Be.tabIndex),get highlightResourceId(){return e(Le)}})}var bi=i(Yr,2);{var yi=Te=>{lv(Te,{get workspace(){return e(y)}})};x(bi,Te=>{e(y)&&e(y).type!=="parent"&&Te(yi)})}L((Te,Be,mt,It)=>{E($e,e(y).name),E(zt,`${e(y).type==="parent"?"Parent Workspace":e(y).type==="child"?"Child Workspace":"Standalone Workspace"}
20                   ยท 
21                  Created ${Te??""}`),Oe(ga,1,`action-btn ${e(y).isTranscendent?"action-btn-transcendent-active":""}`,"svelte-1k2s006"),Ct(ga,"title",e(y).isTranscendent?"Remove Transcendent":"Make Transcendent"),Fa(Hr,e(y).syncEnabled!==!1),E(ci,Be),E(vi,mt),E(pi,e(y).metadata.switchCount),E(gi,`${It??""}...`)},[()=>new Date(e(y).metadata.created).toLocaleDateString(),()=>new Date(e(y).metadata.lastModified).toLocaleString(),()=>new Date(e(y).metadata.lastAccessed).toLocaleString(),()=>e(y).id.slice(0,8)]),n(t,l)},$n=t=>{var r=cu(),l=i(o(r),6),v=o(l);Pe(v,{variant:"primary",onclick:()=>$a("parent"),children:(m,k)=>{var T=Me("Create Parent Workspace");n(m,T)},$$slots:{default:!0}});var h=i(v,2);Pe(h,{variant:"secondary",onclick:()=>$a("standalone"),children:(m,k)=>{var T=Me("Create Standalone");n(m,T)},$$slots:{default:!0}}),n(t,r)};x(Hn,t=>{e(y)?t(Vn):t($n,!1)})}var Gn=i(_r,2);{var Kn=t=>{var r=pu(),l=o(r);{var v=Se=>{var $e=du();$e.__mousedown=tn,n(Se,$e)};x(l,Se=>{e(ft)&&Se(v)})}var h=i(l,2);h.__click=an;var m=o(h);{var k=Se=>{var $e=vu();n(Se,$e)};x(m,Se=>{e(ft)||Se(k)})}var T=i(m,2),z=i(h,2);{var ae=Se=>{var $e=uu(),st=o($e);Zc(st,{get workspace(){return e(y)},get parentWorkspace(){return e(Wa)}}),n(Se,$e)};x(z,Se=>{e(ft)&&Se(ae)})}L(()=>{Ia(r,`width: ${(e(ft)?e(St):ja)??""}px`),Ct(h,"title",e(ft)?"Collapse notes":"Expand notes"),Oe(T,0,`w-4 h-4 transition-transform duration-200 ${e(ft)?"":"rotate-180"}`,"svelte-1k2s006")}),n(t,r)};x(Gn,t=>{e(y)&&e(y).type!=="parent"&&t(Kn)})}var br=i(Zs,2);{let t=me(()=>{var r;return((r=e(y))==null?void 0:r.type)==="parent"?e(y).id:void 0});Xi(br,{get type(){return e(w)},get parentWorkspaces(){return e(na)},get selectedParentId(){return e(t)},oncreate:po,get open(){return e(g)},set open(r){a(g,r,!0)}})}var yr=i(br,2);Hl(yr,{get localWorkspaces(){return e(c)},onclose:()=>a(Ce,!1),onWorkspacesImported:ca,get open(){return e(Ce)},set open(t){a(Ce,t,!0)}});var xr=i(yr,2);kc(xr,{onclose:()=>a(Ne,!1),onRestoreComplete:le,get open(){return e(Ne)},set open(t){a(Ne,t,!0)}});var Cr=i(xr,2);Mc(Cr,{onclose:()=>a(je,!1),get open(){return e(je)},set open(t){a(je,t,!0)}});var Sr=i(Cr,2);Li(Sr,{onclose:()=>a(Ie,!1),onRestored:le,get open(){return e(Ie)},set open(t){a(Ie,t,!0)}});var Tr=i(Sr,2);pl(Tr,{get parentWorkspaces(){return e(na)},onclose:()=>a(_e,!1),onImported:le,get open(){return e(_e)},set open(t){a(_e,t,!0)}});var Mr=i(Tr,2);sa(Mr,{title:"Rename Workspace",get open(){return e(H)},set open(r){a(H,r,!0)},footer:r=>{var l=hu(),v=ee(l);Pe(v,{variant:"ghost",onclick:()=>a(H,!1),children:(m,k)=>{var T=Me("Cancel");n(m,T)},$$slots:{default:!0}});var h=i(v,2);{let m=me(()=>!e(se).trim());Pe(h,{variant:"primary",onclick:go,get disabled(){return e(m)},children:(k,T)=>{var z=Me("Rename");n(k,z)},$$slots:{default:!0}})}n(r,l)},children:(r,l)=>{os(r,{label:"New Name",placeholder:"Enter new name",get value(){return e(se)},set value(v){a(se,v,!0)}})},$$slots:{footer:!0,default:!0}});var Ir=i(Mr,2);sa(Ir,{title:"Create Subgroup",get open(){return e(Y)},set open(r){a(Y,r,!0)},footer:r=>{var l=fu(),v=ee(l);Pe(v,{variant:"ghost",onclick:()=>{a(Y,!1),a(Z,"")},children:(m,k)=>{var T=Me("Cancel");n(m,T)},$$slots:{default:!0}});var h=i(v,2);{let m=me(()=>!e(Z).trim());Pe(h,{variant:"primary",onclick:yo,get disabled(){return e(m)},children:(k,T)=>{var z=Me("Create Group");n(k,z)},$$slots:{default:!0}})}n(r,l)},children:(r,l)=>{var v=gu(),h=ee(v),m=o(h),k=i(h,2);os(k,{label:"Group Name",placeholder:"Enter group name",get value(){return e(Z)},set value(T){a(Z,T,!0)}}),L(()=>{var T;return E(m,`Create a new subgroup within "${((T=e(re))==null?void 0:T.name)??""}" to organize child workspaces.`)}),n(r,v)},$$slots:{footer:!0,default:!0}});var Ar=i(Ir,2);sa(Ar,{title:"Move to Group",get open(){return e(P)},set open(r){a(P,r,!0)},footer:r=>{var l=mu(),v=ee(l);Pe(v,{variant:"ghost",onclick:()=>{a(P,!1),a(q,null)},children:(k,T)=>{var z=Me("Cancel");n(k,z)},$$slots:{default:!0}});var h=i(v,2);{var m=k=>{Pe(k,{variant:"ghost",onclick:()=>Ds(null),children:(T,z)=>{var ae=Me("Remove from Group");n(T,ae)},$$slots:{default:!0}})};x(h,k=>{var T;(T=e(q))!=null&&T.groupId&&k(m)})}n(r,l)},children:(r,l)=>{var v=Fe(),h=ee(v);{var m=k=>{const T=me(()=>e(c).find(Ke=>{var Ge;return Ke.id===((Ge=e(q))==null?void 0:Ge.parentId)}));var z=xu(),ae=ee(z),Se=o(ae),$e=i(ae,2),st=o($e);{var zt=Ke=>{var Ge=Fe(),Lt=ee(Ge);wt(Lt,17,()=>e(T).groups,Dt=>Dt.id,(Dt,Bt)=>{var fa=bu();fa.__click=()=>Ds(e(Bt).id);var Ca=o(fa);{var Sa=et=>{var lt=ku();L(()=>Ia(lt,`background-color: ${e(Bt).color??""}`)),n(et,lt)},ga=et=>{var lt=wu();n(et,lt)};x(Ca,et=>{e(Bt).color?et(Sa):et(ga,!1)})}var Ta=i(Ca,2),it=o(Ta),Pt=i(Ta,2);{var Qe=et=>{var lt=_u();n(et,lt)};x(Pt,et=>{e(q).groupId===e(Bt).id&&et(Qe)})}L(()=>{Oe(fa,1,`w-full flex items-center gap-3 p-3 rounded-lg transition-colors text-left
22                ${e(q).groupId===e(Bt).id?"bg-phosphor/20 border border-phosphor":"bg-mnemonic-bg-dark hover:bg-phosphor/10 border border-transparent"}`,"svelte-1k2s006"),E(it,e(Bt).name)}),n(Dt,fa)}),n(Ke,Ge)},Gt=Ke=>{var Ge=yu();n(Ke,Ge)};x(st,Ke=>{var Ge;(Ge=e(T))!=null&&Ge.groups&&e(T).groups.length>0?Ke(zt):Ke(Gt,!1)})}L(()=>E(Se,`Select a group for "${e(q).name??""}":`)),n(k,z)};x(h,k=>{e(q)&&k(m)})}n(r,v)},$$slots:{footer:!0,default:!0}});var Er=i(Ar,2);sa(Er,{title:"Rename Group",get open(){return e(te)},set open(r){a(te,r,!0)},footer:r=>{var l=Cu(),v=ee(l);Pe(v,{variant:"ghost",onclick:()=>{a(te,!1),a(ce,"")},children:(m,k)=>{var T=Me("Cancel");n(m,T)},$$slots:{default:!0}});var h=i(v,2);{let m=me(()=>!e(ce).trim());Pe(h,{variant:"primary",onclick:So,get disabled(){return e(m)},children:(k,T)=>{var z=Me("Rename");n(k,z)},$$slots:{default:!0}})}n(r,l)},children:(r,l)=>{os(r,{label:"New Name",placeholder:"Enter new group name",get value(){return e(ce)},set value(v){a(ce,v,!0)}})},$$slots:{footer:!0,default:!0}});var Pr=i(Er,2);bs(Pr,{title:"Delete Group",message:"Are you sure you want to delete this group? Workspaces in this group will become ungrouped.",variant:"danger",confirmText:"Delete",onconfirm:To,get open(){return e(F)},set open(t){a(F,t,!0)}});var zr=i(Pr,2);{var Yn=t=>{ys(t,{get items(){return e(Bo)},get x(){return e(U).x},get y(){return e(U).y},onSelect:Do,onClose:()=>a(U,null)})};x(zr,t=>{e(U)&&t(Yn)})}var Lr=i(zr,2);sa(Lr,{title:"Reassign Window",get open(){return e(K)},set open(r){a(K,r,!0)},footer:r=>{Pe(r,{variant:"ghost",onclick:()=>a(K,!1),children:(l,v)=>{var h=Me("Cancel");n(l,h)},$$slots:{default:!0}})},children:(r,l)=>{var v=Lu(),h=i(o(v),2),m=o(h),k=i(h,2);wt(k,21,()=>e(va),T=>T.id,(T,z)=>{const ae=me(()=>e(z).type==="child"?e(c).find(it=>it.id===e(z).parentId):null),Se=me(()=>e(ke).has(e(z).id));var $e=Pu();$e.__click=()=>{io(e(z),e(X)),a(K,!1)};var st=o($e),zt=o(st);{var Gt=it=>{var Pt=Su();n(it,Pt)},Ke=it=>{var Pt=Tu();n(it,Pt)};x(zt,it=>{e(z).type==="child"?it(Gt):it(Ke,!1)})}var Ge=i(st,2),Lt=o(Ge),Dt=o(Lt),Bt=i(Lt,2);{var fa=it=>{var Pt=Mu(),Qe=o(Pt);L(()=>E(Qe,`in ${e(ae).name??""}`)),n(it,Pt)},Ca=it=>{var Pt=Fe(),Qe=ee(Pt);{var et=lt=>{var Yt=Iu();n(lt,Yt)};x(Qe,lt=>{e(z).type==="standalone"&&lt(et)},!0)}n(it,Pt)};x(Bt,it=>{e(ae)?it(fa):it(Ca,!1)})}var Sa=i(Ge,2);{var ga=it=>{var Pt=Au();n(it,Pt)},Ta=it=>{var Pt=Fe(),Qe=ee(Pt);{var et=lt=>{var Yt=Eu();n(lt,Yt)};x(Qe,lt=>{e(Se)&&lt(et)},!0)}n(it,Pt)};x(Sa,it=>{e(z).id===s.workspaceId?it(ga):it(Ta,!1)})}L(()=>{Oe($e,1,`w-full flex items-center gap-3 px-3 py-2 rounded hover:bg-surface-raised transition-colors text-left ${e(z).id===s.workspaceId?"bg-phosphor/20 border border-phosphor/40":""}`,"svelte-1k2s006"),E(Dt,e(z).name)}),n(T,$e)},T=>{var z=zu();n(T,z)}),rs(m,()=>e(X),T=>a(X,T)),n(r,v)},$$slots:{footer:!0,default:!0}});var Rr=i(Lr,2);{let t=me(()=>{var l;return(l=e(j))==null?void 0:l.name}),r=me(()=>{var l;return((l=e(j))==null?void 0:l.type)==="parent"?"Child workspaces will become standalone.":""});bs(Rr,{title:"Delete Workspace",get message(){return`Are you sure you want to delete '${e(t)??""}'? ${e(r)??""}`},variant:"danger",confirmText:"Delete",onconfirm:ho,get open(){return e(M)},set open(l){a(M,l,!0)}})}var Wr=i(Rr,2);{var Jn=t=>{ys(t,{get items(){return e(Ro)},get x(){return e(A).x},get y(){return e(A).y},onSelect:Wo,onClose:()=>a(A,null)})};x(Wr,t=>{e(A)&&t(Jn)})}var Br=i(Wr,2);{var Xn=t=>{ys(t,{get items(){return e(No)},get x(){return e(S).x},get y(){return e(S).y},onSelect:Oo,onClose:()=>a(S,null)})};x(Br,t=>{e(S)&&t(Xn)})}var Dr=i(Br,2);{let t=me(()=>{var v;return(v=e(yt))==null?void 0:v.name}),r=me(()=>{var v;return(v=e(y))==null?void 0:v.name}),l=me(()=>{var v;return(v=e(y))==null?void 0:v.name});bs(Dr,{title:"Overwrite Workspace Tabs",get message(){return`This window is assigned to '${e(t)??""}' but you're saving tabs to '${e(r)??""}'. This will overwrite the saved tabs in '${e(l)??""}' with the tabs from this window. Are you sure?`},variant:"warning",confirmText:"Overwrite",onconfirm:Ys,get open(){return e($)},set open(v){a($,v,!0)}})}var Nr=i(Dr,2);sa(Nr,{title:"Create Workspace from Window",get open(){return e(ve)},set open(r){a(ve,r,!0)},footer:r=>{var l=Ru(),v=ee(l);Pe(v,{variant:"ghost",onclick:()=>a(ve,!1),children:(m,k)=>{var T=Me("Cancel");n(m,T)},$$slots:{default:!0}});var h=i(v,2);{let m=me(()=>!e(oe).trim());Pe(h,{variant:"primary",onclick:()=>uo(e(oe),e(_)||null,{openInContextSwitch:e(he),syncEnabled:e(we)}),get disabled(){return e(m)},children:(k,T)=>{var z=Me("Create & Assign Window");n(k,z)},$$slots:{default:!0}})}n(r,l)},children:(r,l)=>{var v=Ou(),h=o(v),m=o(h),k=i(h,2),T=o(k),z=i(o(T));{var ae=Qe=>{var et=Wu();n(Qe,et)};x(z,Qe=>{e(N)&&Qe(ae)})}var Se=i(T,2),$e=i(k,2),st=i(o($e),2),zt=o(st);zt.value=zt.__value="";var Gt=i(zt);wt(Gt,17,()=>e(na),Qe=>Qe.id,(Qe,et)=>{var lt=Bu(),Yt=o(lt),Da={};L(()=>{E(Yt,e(et).name),Da!==(Da=e(et).id)&&(lt.value=(lt.__value=e(et).id)??"")}),n(Qe,lt)});var Ke=i($e,2),Ge=o(Ke),Lt=o(Ge),Dt=i(Ge,2),Bt=o(Dt);wt(Bt,17,()=>e(We).slice(0,5),ea,(Qe,et)=>{var lt=Du(),Yt=o(lt),Da=i(Yt);L(()=>{Ct(Yt,"src",`https://www.google.com/s2/favicons?domain=${new URL(e(et).url).hostname??""}&sz=16`),E(Da,` ${e(et).title??""}`)}),Zt("error",Yt,fs=>fs.currentTarget.style.display="none"),n(Qe,lt)});var fa=i(Bt,2);{var Ca=Qe=>{var et=Nu(),lt=o(et);L(()=>E(lt,`...and ${e(We).length-5} more`)),n(Qe,et)};x(fa,Qe=>{e(We).length>5&&Qe(Ca)})}var Sa=i(Ke,2),ga=i(o(Sa),2);{var Ta=Qe=>{var et=qu(),lt=o(et);rs(lt,()=>e(he),Yt=>a(he,Yt)),n(Qe,et)};x(ga,Qe=>{e(_)&&Qe(Ta)})}var it=i(ga,2),Pt=o(it);L(()=>{E(m,`Create a new workspace from the ${e(We).length??""} tabs in this window.
23        This window will be automatically assigned to the new workspace.`),Oe(Se,1,`w-full px-3 py-2 bg-mnemonic-bg-dark border rounded-lg focus:outline-none focus:border-phosphor transition-colors ${e(Q)?"border-phosphor/50 bg-phosphor/5 text-phosphor":"border-phosphor-dark/30 text-text"}`,"svelte-1k2s006"),E(Lt,`${e(We).length??""} tabs to save:`)}),Zt("focus",Se,vo),wa(Se,()=>e(oe),Qe=>a(oe,Qe)),is(st,()=>e(_),Qe=>a(_,Qe)),rs(Pt,()=>e(we),Qe=>a(we,Qe)),n(r,v)},$$slots:{footer:!0,default:!0}});var qr=i(Nr,2);sa(qr,{title:"Switch Context",get open(){return e(ie)},set open(r){a(ie,r,!0)},footer:r=>{var l=Fu(),v=ee(l);Pe(v,{variant:"ghost",onclick:Ao,children:(m,k)=>{var T=Me("Cancel");n(m,T)},$$slots:{default:!0}});var h=i(v,2);Pe(h,{variant:"primary",onclick:Io,children:(m,k)=>{var T=Me("Switch Context");n(m,T)},$$slots:{default:!0}}),n(r,l)},children:(r,l)=>{var v=Hu(),h=o(v),m=i(o(h),2),k=o(m),T=o(k),z=i(h,2),ae=o(z);{var Se=Ge=>{var Lt=ju(),Dt=i(o(Lt),2),Bt=o(Dt);L(()=>E(Bt,`Close ${e(V).windowsToClose??""} window${e(V).windowsToClose!==1?"s":""}`)),n(Ge,Lt)};x(ae,Ge=>{e(V).windowsToClose>0&&Ge(Se)})}var $e=i(ae,2);{var st=Ge=>{var Lt=Uu(),Dt=i(o(Lt),2),Bt=o(Dt);L(()=>E(Bt,`Keep ${e(V).transcendentToKeep??""} transcendent window${e(V).transcendentToKeep!==1?"s":""}`)),n(Ge,Lt)};x($e,Ge=>{e(V).transcendentToKeep>0&&Ge(st)})}var zt=i($e,2),Gt=i(o(zt),2),Ke=o(Gt);L(Ge=>{var Lt;E(T,`Switch to "${((Lt=e(B))==null?void 0:Lt.name)??""}" context?`),E(Ke,`Open ${Ge??""} child workspace(s) in new windows`)},[()=>e(B)?e(c).filter(Ge=>Ge.type==="child"&&Ge.parentId===e(B).id&&Ge.openInContextSwitch!==!1).length:0]),n(r,v)},$$slots:{footer:!0,default:!0}});var Qn=i(qr,2);Ri(Qn,{get message(){return e(Ue)},get type(){return e(Xe)},get visible(){return e(_t)},set visible(t){a(_t,t,!0)}}),L(()=>{E(_n,e(_a)),E(yn,e(Ea)+e(cs)),or=Oe(ps,1,"svelte-1k2s006",null,or,{"text-phosphor":e(Ha)>0}),ir=Oe(nr,1,"font-medium svelte-1k2s006",null,ir,{"text-phosphor":e(Ha)>0}),E(xn,e(Ha)),cr=Oe(lr,1,"svelte-1k2s006",null,cr,{"text-status-success":e(Va)>0}),vr=Oe(dr,1,"font-medium svelte-1k2s006",null,vr,{"text-status-success":e(Va)>0}),E(Cn,e(Va)),Ia(hs,`width: ${e(at)??""}px`)}),n(O,Qs),jt()}oa(["click","mousedown","keydown","contextmenu","change"]);const ls=new URLSearchParams(window.location.search),Gu=ls.get("workspaceId"),Ku=ls.get("type"),Yu=ls.get("transcendent")==="true",Ju=ls.get("parentId");Ei($u,{target:document.getElementById("app"),props:{workspaceId:Gu,workspaceType:Ku,isTranscendent:Yu,parentId:Ju}});