Nothing matches these filters.
`; return (s.q&&s.tab!=='dups'?`No missing images or attachments were found in the imported chats.
`; return `No duplicates found.
`;const s=AS(),sq=nzs(s.q); return `No files imported yet.
`; return `Import the backups you exported from ChatGPT, Gemini, Copilot and Venice. Every original file is kept; chats are listed once, duplicates are found automatically, and any chat can become a page when you want it.
Opening the archive…
';arcLoad().then(()=>{arcDedupe();if(ui.view==='archive')render()});return} const s=AS();if(!ARC.stats)ARC.stats=arcStats(); if(!ARC.chats.length&&!ARC.files.length){sc.innerHTML='Choose a chat to preview it as a page.
Nothing added yet. Paste a whole conversation, or paste your questions and the AI’s replies one at a time.
'; return d.segs.map((m,i)=>`Paste as many times as you need. A whole conversation (with lines like “You said” / “Copilot said”) is split automatically; a single question or reply is added as one message. Then save it to the archive, or save it and make a page.
Add some text first.
';return} const title=d.title||firstLine((d.segs.find(m=>m.r==='u')||d.segs[0]).x,90),now=Date.now(); const c=mkChat(d.src,title,title,d.segs.map((m,i)=>({r:m.r,t:now+i,x:m.x,att:[]})),'pasted text');c.layout='paste';c.pasted=true; const ex=ARC.chats.find(x=>x.id===c.id);let target,msg; if(ex){const f=pasteMerge(ex,c);target=ex;msg=f>0?'Filled '+f+' missing repl'+(f>1?'ies':'y')+' in “'+esc(ex.title)+'”.':f<0?'Replaced “'+esc(ex.title)+'” with the fuller pasted version.':'“'+esc(ex.title)+'” is already complete — nothing changed.'} else{ARC.chats.push(c);target=c;msg='Added “'+esc(c.title)+'” ('+c.msgs.length+' messages).'} if(t&&t.dataset.mk==='1'){arcCreate(target,{reuse:1});msg+=' Page created in AI archive / '+SRC[target.src].n+'.'} await arcPut([target]);arcDedupe();await arcPut(ARC.chats);const s=AS();s.sel=target.id;s.tab='all';ARC.draft=null;ARD();const ti=$('#apti');if(ti)ti.value='';arcDraftUI();out.innerHTML=''+msg+'
';arcRefresh()}}); document.addEventListener('paste',e=>{const t=e.target;if(t&&t.id==='apx'){const x=e.clipboardData&&e.clipboardData.getData('text/plain');if(x){e.preventDefault();arcDraftKeep();arcAddText(x)}}}); document.addEventListener('change',e=>{const t=e.target;if(t&&(t.id==='apsrc'||t.id==='apti'))arcDraftKeep()}); /* paste anywhere in the archive -> opens the paste list; paste AI text into a note -> clean blocks */ document.addEventListener('paste',e=>{if(ui.view!=='archive')return;const t=e.target;if(t&&(t.closest('input,textarea,[contenteditable="true"]')||t.id==='apx'))return;if(!$('#modal').hidden)return; const x=e.clipboardData&&e.clipboardData.getData('text/plain');if(!x||!x.trim())return;e.preventDefault();arcPasteUI();arcAddText(x);toast('Pasted — add more, then save')}); function pasteMd(e){const h=e.clipboardData.getData('text/html'),tx=e.clipboardData.getData('text/plain')||'';let md=''; if(h&&/<(h[1-6]|ul|ol|table|pre|strong|b|blockquote)[\s>]/i.test(h))md=htmlMd(h.replace(//g,'')); else if(/\n/.test(tx)&&/(^|\n)(#{1,6} |\s*[-*] |\s*\d+\. |\|.*\||```)/.test(tx))md=tx; return md} document.addEventListener('paste',e=>{const t=e.target&&e.target.closest&&e.target.closest('.ed[data-id]');if(!t||t.dataset.y||ui.view!=='page'||ui.mode==='read'||!e.clipboardData)return; let md;try{md=pasteMd(e)}catch(x){return}if(!md||md.split('\n').length<2)return;e.preventDefault(); let inF=false;md=md.split('\n').map(l=>{if(/^\s*```/.test(l))inF=!inF;if(inF)return l;const h=/^(#{4,6})\s+(.*)/.exec(l);return h?'**'+h[2].replace(/\*\*/g,'')+'**':l}).join('\n'); const nb=fromMD(md),p=hostPage(),i=idxB(t.dataset.id);if(i<0||!nb.length)return;const cur=p.blocks[i],empty=cur&&cur.t==='p'&&!plain(cur.x||'').trim(); p.blocks.splice(empty?i:i+1,empty?1:0,...nb);touch();rerenderBlocks(nb[nb.length-1].id,true);announce('Pasted '+nb.length+' blocks');toast('Pasted as '+nb.length+' blocks')}); /* ================= Sync: offline work on each device, reviewed and added when you sync ================= */ function syncMeta(){const m=S.meta=S.meta||{};if(!m.devId){m.devId=uid()+uid();const ua=navigator.userAgent;m.devName=/iPhone/.test(ua)?'iPhone':/iPad/.test(ua)?'iPad':/Android/.test(ua)?'Android phone':/Mac/.test(ua)?'Mac':/Windows/.test(ua)?'Windows PC':'This device';save()}return m} function syncPending(){const m=syncMeta(),since=m.lastSync||0;const pg=Object.values(S.pages).filter(p=>(p.updated||0)>since&&!p.trash);const ch=ARC.chats.filter(c=>Math.max(c.added||0,c.mod||0)>since);return{pages:pg,chats:ch,since}} function syncBadge(){return syncBadge0()+(synOn()?'':'')} function syncBadge0(){try{const y=SY();if(!y.remind)return'';const p=syncPending(),n=p.pages.length+(y.archive?p.chats.length:0);return n?''+n+'':''}catch(e){return''}} function syncWhen(t){return t?arcWhen(t):'never'} async function syncPackage(all){const m=syncMeta(),pend=syncPending(),use=all||!m.lastSync;await arcLoad(); const pages=use?Object.values(S.pages):pend.pages,have=new Set(pages.map(p=>p.id)); Object.values(S.pages).forEach(p=>{let x=p;while(x&&x.parent&&!have.has(x.parent)&&S.pages[x.parent]){x=S.pages[x.parent];if(!have.has(x.id)){have.add(x.id);pages.push(x)}}}); const comps={};pages.forEach(p=>p.blocks&&p.blocks.forEach(b=>{if(b.comp&&S.comps[b.comp])comps[b.comp]=S.comps[b.comp]})); let chats=use?ARC.chats:pend.chats;if(!SY().archive)chats=[]; const media=await medCollect(pages,comps); return{app:'mosaic-sync',v:1,device:{id:m.devId,name:m.devName},at:Date.now(),full:!!use,pages,comps,media,chats:chats.map(c=>{const o=Object.assign({},c);delete o._p;delete o._n;return o}),files:SY().archive?ARC.files:[]}} async function dlBlob(name,blob){try{const d=window.claude&&await claude.use('downloads');if(d){await d.save({filename:name,data:new Uint8Array(await blob.arrayBuffer())});return true}}catch(e){if(e&&e.code==='declined')return false} const a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download=name;document.body.appendChild(a);a.click();setTimeout(()=>{a.remove();URL.revokeObjectURL(a.href)},3000);return true} async function syncSave(all){const pk=await syncPackage(all),m=syncMeta(),nm='mosaic-sync-'+m.devName.replace(/[^\w-]+/g,'-')+'-'+new Date().toISOString().slice(0,10)+'.json'; const ok=await dlBlob(nm,new Blob([JSON.stringify(pk)],{type:'application/json'}));if(ok){m.lastSync=Date.now();save();toast('Sync file saved: '+pk.pages.length+' pages, '+pk.chats.length+' chats');syncUI()}} async function syncRead(f){let buf=new Uint8Array(await f.arrayBuffer());if(buf[0]===0x1f&&buf[1]===0x8b){buf=new Uint8Array(await new Response(new Blob([buf]).stream().pipeThrough(new DecompressionStream('gzip'))).arrayBuffer())} const j=JSON.parse(new TextDecoder().decode(buf));if(j.app!=='mosaic-sync')throw new Error('This is not a Mosaic sync file');return j} function syncDiff(pk){const m=syncMeta(),since=m.lastSync||0,items=[]; pk.pages.forEach(p=>{const l=S.pages[p.id];if(!l)items.push({k:'new',p});else if((p.updated||0)>(l.updated||0)+1000){items.push({k:(l.updated||0)>since?'both':'newer',p,l})}}); const ex=new Set(ARC.chats.map(c=>c.id));const nc=pk.chats.filter(c=>!ex.has(c.id)),uc=pk.chats.filter(c=>{const o=ARC.chats.find(x=>x.id===c.id);return o&&(c.msgs.reduce((s,x)=>s+(x.x||'').length,0)>o.msgs.reduce((s,x)=>s+(x.x||'').length,0)||(c.status==='page'&&o.status!=='page'&&!o.pageId))}); return{items,nc,uc}} var SYNC=null; function syncReview(pk){const d=syncDiff(pk);SYNC={pk,d,pick:{}};d.items.forEach((it,i)=>{SYNC.pick[i]=it.k!=='both'}); const lab={new:'New',newer:'Updated',both:'Changed on both devices — will be added as a copy'}; const rows=d.items.map((it,i)=>``).join(''); return `${d.items.length} page${d.items.length===1?'':'s'} to review · ${d.nc.length} new AI chat${d.nc.length===1?'':'s'} · ${d.uc.length} fuller AI chat${d.uc.length===1?'':'s'}
No pages to add.
'}${SYW[y.where][1]}
Also works without the server, for example to hand a copy to someone or keep a backup.
`:`${esc(SYW[y.where][1])}
`; modal(`Added '+np+' new, '+up+' updated, '+cp+' copies and '+ch.length+' AI chats.
';render()}}); document.addEventListener('change',e=>{const t=e.target;if(t.id==='syf'&&t.files&&t.files[0]){const o=$('#symsg');o.innerHTML='Reading…
';syncRead(t.files[0]).then(pk=>{o.innerHTML=syncReview(pk)}).catch(x=>{o.innerHTML=''+esc(x.message||'Could not read this file')+'
'});t.value=''} if(t.dataset&&t.dataset.sk!==undefined&&SYNC)SYNC.pick[+t.dataset.sk]=t.checked; if(t.id==='sydn'){syncMeta().devName=t.value.trim()||'This device';save()} if(t.dataset&&t.dataset.ss){const y=SY();const k=t.dataset.ss;y[k]=t.type==='checkbox'?t.checked:t.value;save();if(k==='method'||k==='where'){const h=$('#sywh');if(h)h.textContent=SYW[y.where][1];if(k==='method')syncUI('set')}if(k==='remind')renderSide()}}); document.addEventListener('input',e=>{if(e.target.id==='sydn'){syncMeta().devName=e.target.value.trim()||'This device';save()}}); /* ================= Tabs block ================= */ function tabsHTML(c,id,ro){const a=c.tabs.find(t=>t.id===c.act)||c.tabs[0];c.act=a.id; return `Empty tab. Press Write to add content.
'}This tab's page was removed. ${ed?``:''}
`}`} (function(){const _nc=newComp;newComp=function(type){if(type==='ptabs'){const id='c-'+uid(),h=hostPage(),mk=n=>({id:uid(),pid:newPage({title:'Tab '+n,parent:h?h.id:null,icon:'📄',btab:true})});const t=[mk(1),mk(2)];if(h)h.open=true;S.comps[id]={type:'ptabs',tabs:t,act:t[0].id};save();return id}return _nc(type)}})(); Object.assign(H,{ptsel(t){const c=S.comps[t.dataset.cid];if(!c)return;c.act=t.dataset.t;c._del=null;save();refreshComp(t.dataset.cid);setTimeout(()=>{const b=$(`#pt-${t.dataset.cid}-${t.dataset.t}`);b&&b.focus({preventScroll:true})},20)}, ptnew(t){const c=S.comps[t.dataset.cid],h=hostPage();if(!c)return;const id=uid();c.tabs.push({id,pid:newPage({title:'Tab '+(c.tabs.length+1),parent:h?h.id:null,icon:'📄',btab:true})});c.act=id;c._del=null;save();refreshComp(t.dataset.cid);announce('Tab added');setTimeout(()=>{const e=$(`.tpanel .tpt`);if(e){e.focus();const r=document.createRange();r.selectNodeContents(e);const g=getSelection();g.removeAllRanges();g.addRange(r)}},40)}, ptdel(t){const c=S.comps[t.dataset.cid];if(!c||c.tabs.length<2)return;const tb=c.tabs.find(x=>x.id===t.dataset.t),pg=tb&&P(tb.pid);const has=pg&&(pg.blocks.length>1||plain(pg.blocks[0].x||'').trim());if(has&&c._del!==tb.id){c._del=tb.id;refreshComp(t.dataset.cid);return} const i=c.tabs.findIndex(x=>x.id===t.dataset.t);c.tabs.splice(i,1);c.act=(c.tabs[Math.max(0,i-1)]||c.tabs[0]).id;c._del=null;if(pg)trashPage(pg.id);save();refreshComp(t.dataset.cid);announce('Tab removed (its page is in the trash)')}, ptfix(t){const c=S.comps[t.dataset.cid],tb=c&&c.tabs.find(x=>x.id===t.dataset.t),h=hostPage();if(!tb)return;tb.pid=newPage({title:'Tab',parent:h?h.id:null,icon:'📄',btab:true});save();refreshComp(t.dataset.cid)}, tpend(t){const p=P(t.dataset.pid);if(!p)return;ui.ectx=p.id;const l=p.blocks[p.blocks.length-1];if(l&&l.t==='p'&&!plain(l.x||'').trim())focusBlock(l.id);else insertAfter(l.id,'p')}}); document.addEventListener('input',e=>{const t=e.target;if(t.dataset&&t.dataset.tptitle){const p=P(t.dataset.tptitle);if(p){p.title=t.textContent.replace(/\n/g,' ');p.updated=Date.now();save();$$(`[data-act="ptsel"][data-pid="${p.id}"]`).forEach(b=>b.textContent=(p.icon||'📄')+' '+(p.title||'Untitled'));try{renderSideSoft()}catch(x){}}}}); document.addEventListener('keydown',e=>{const t=e.target;if(t.dataset&&t.dataset.tptitle&&e.key==='Enter'){e.preventDefault();const p=P(t.dataset.tptitle);p&&p.blocks[0]&&focusBlock(p.blocks[0].id,false);return} if(!(t.matches&&t.matches('[role="tab"][data-act="ptsel"]')))return;const k=e.key,rtl=getComputedStyle(t).direction==='rtl',bs=$$('[role="tab"]',t.parentElement);let i=bs.indexOf(t); if(k==='ArrowRight')i+=rtl?-1:1;else if(k==='ArrowLeft')i+=rtl?1:-1;else if(k==='Home')i=0;else if(k==='End')i=bs.length-1;else return;e.preventDefault();i=(i+bs.length)%bs.length;H.ptsel(bs[i])}); /* editing context: blocks inside a tab panel belong to that tab's page */ ['pointerdown','mousedown','touchstart','focusin','keydown','beforeinput','input','paste','click'].forEach(ev=>document.addEventListener(ev,e=>{const t=e.target;if(!t||!t.closest)return;if(t.closest('#pop'))return;const pn=t.closest('.tpanel[data-pid]');ui.ectx=pn?pn.dataset.pid:null},true)); /* Markdown export of tab blocks */ function compMD(b,d){d=d||0;const c=S.comps[b.comp]||{}; if(c.type==='ptabs'&&d<4)return c.tabs.map(t=>{const pg=P(t.pid);if(!pg||pg.trash)return'';return '### 🗂 '+(pg.title||'Untitled')+'\n\n'+toMD(Object.assign({},pg,{fm:[]}))}).filter(Boolean).join('\n\n'); if(c.type==='tabs')return c.tabs.map(t=>'### 🗂 '+(t.title||'Untitled')+'\n\n'+(t.x||'')).join('\n\n'); if(c.type==='svg')return '```svg\n'+(c.src||'')+'\n```'; if(c.type==='diagram')return '```mermaid\n'+(c.src||'')+'\n```'; return ''} function markBtabs(){let ch=0;Object.values(S.comps||{}).forEach(c=>{if(c&&c.type==='ptabs')(c.tabs||[]).forEach(t=>{const p=P(t.pid);if(p&&!p.btab){p.btab=true;ch=1}})});if(ch)save()} /* ================= Diagram (Mermaid) block: styles, line shapes, templates, export ================= */ const DGS={ clean:{n:'Clean',bg:'#FFFFFF',v:{primaryColor:'#EAF2FF',primaryTextColor:'#1C1C1E',primaryBorderColor:'#0071E3',lineColor:'#6E6E73',secondaryColor:'#F2F2F7',tertiaryColor:'#FFFFFF',noteBkgColor:'#FFF8E1',noteTextColor:'#1C1C1E'},r:12,w:1.5,sh:1,sw:2}, pastel:{n:'Pastel',bg:'#FFFDF8',v:{primaryColor:'#FFE3E8',primaryTextColor:'#3B2F3A',primaryBorderColor:'#F2A5B5',lineColor:'#B79BB6',secondaryColor:'#E3F1FF',tertiaryColor:'#E8F7E4',noteBkgColor:'#FFF3C4',noteTextColor:'#3B2F3A'},r:16,w:1.5,sh:1,sw:2.2}, candy:{n:'Candy',bg:'#FFFFFF',v:{primaryColor:'#FFD166',primaryTextColor:'#1B1B1F',primaryBorderColor:'#1B1B1F',lineColor:'#1B1B1F',secondaryColor:'#8ECAE6',tertiaryColor:'#FFB5A7',noteBkgColor:'#CDEAC0',noteTextColor:'#1B1B1F'},r:14,w:2.5,sh:0,sw:2.5,solid:1}, blueprint:{n:'Blueprint',bg:'#0B2A4A',v:{primaryColor:'#0F3B66',primaryTextColor:'#EAF4FF',primaryBorderColor:'#8CC8FF',lineColor:'#8CC8FF',secondaryColor:'#124A7D',tertiaryColor:'#0B2A4A',noteBkgColor:'#124A7D',noteTextColor:'#EAF4FF',textColor:'#EAF4FF',mainBkg:'#0F3B66'},r:3,w:1.2,sh:0,sw:1.4,dash:1}, mono:{n:'Mono',bg:'#FFFFFF',v:{primaryColor:'#FFFFFF',primaryTextColor:'#000000',primaryBorderColor:'#000000',lineColor:'#000000',secondaryColor:'#F0F0F0',tertiaryColor:'#FFFFFF',noteBkgColor:'#F0F0F0',noteTextColor:'#000000'},r:2,w:1.5,sh:0,sw:1.5}, paper:{n:'Sketch',bg:'#FBF6E9',v:{primaryColor:'#FFF1C9',primaryTextColor:'#3A2E1F',primaryBorderColor:'#7A5C2E',lineColor:'#7A5C2E',secondaryColor:'#E9F0D8',tertiaryColor:'#FBF6E9',noteBkgColor:'#FFE9A8',noteTextColor:'#3A2E1F'},r:8,w:2,sh:0,sw:2,font:'hand'}, forest:{n:'Forest',bg:'#F4F8F4',v:{primaryColor:'#DDEFD9',primaryTextColor:'#17331F',primaryBorderColor:'#2F7D4F',lineColor:'#4F7D5C',secondaryColor:'#EAF3E3',tertiaryColor:'#F4F8F4',noteBkgColor:'#FFF4CC',noteTextColor:'#17331F'},r:10,w:1.5,sh:1,sw:2}, sunset:{n:'Sunset',bg:'#FFF7F0',v:{primaryColor:'#FFD9C2',primaryTextColor:'#4A1D0E',primaryBorderColor:'#E4572E',lineColor:'#B5452A',secondaryColor:'#FFE9A8',tertiaryColor:'#FFF7F0',noteBkgColor:'#FFE9A8',noteTextColor:'#4A1D0E'},r:12,w:1.8,sh:1,sw:2}, corp:{n:'Corporate',bg:'#F7F8FA',v:{primaryColor:'#1F3A5F',primaryTextColor:'#FFFFFF',primaryBorderColor:'#1F3A5F',lineColor:'#5B6B7F',secondaryColor:'#DCE4EE',tertiaryColor:'#F7F8FA',noteBkgColor:'#E8EDF4',noteTextColor:'#1F3A5F'},r:4,w:1,sh:1,sw:1.8}, neon:{n:'Neon',bg:'#0D0F1A',v:{primaryColor:'#1A1D33',primaryTextColor:'#E8F0FF',primaryBorderColor:'#00E5FF',lineColor:'#FF3DCB',secondaryColor:'#241A3D',tertiaryColor:'#0D0F1A',noteBkgColor:'#241A3D',noteTextColor:'#E8F0FF',textColor:'#E8F0FF',mainBkg:'#1A1D33'},r:10,w:1.8,sh:0,sw:2,glow:1}, auto:{n:'Match app',bg:'',v:null,r:10,w:1.5,sh:0,sw:2} }; const DGF={sys:['System','-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",Inter,system-ui,"Segoe UI",Roboto,Vazirmatn,sans-serif'],round:['Rounded','"SF Pro Rounded","Nunito","Varela Round",ui-rounded,-apple-system,system-ui,Vazirmatn,sans-serif'],serif:['Serif','"New York",Georgia,"Times New Roman",serif'],mono:['Mono','ui-monospace,"SF Mono",Menlo,Consolas,monospace'],hand:['Handwritten','"Bradley Hand","Segoe Print","Comic Sans MS","Marker Felt",cursive']}; const DGCURVE={basis:'Curved (smooth)',bumpX:'S-curve (horizontal)',bumpY:'S-curve (vertical)',natural:'Natural curve',monotoneX:'Flowing (horizontal)',monotoneY:'Flowing (vertical)',cardinal:'Cardinal (tight)',catmullRom:'Catmull-Rom (loose)',linear:'Straight',step:'Steps (middle turn)',stepBefore:'Steps (turn early)',stepAfter:'Steps (turn late)'}; const DGT=[ ['Flowchart','flowchart TD\n A([Start]) --> B{Is it ready?}\n B -- Yes --> C[Ship it]\n B -- No --> D[Fix issues]\n D --> B\n C --> E([Done])'], ['Left-to-right process','flowchart LR\n A[Idea] --> B[Plan] --> C[Build] --> D[Test] --> E[Launch]'], ['Org chart','flowchart TD\n CEO[CEO] --> CTO[CTO]\n CEO --> CFO[CFO]\n CEO --> COO[COO]\n CTO --> E1[Engineering]\n CTO --> E2[Design]\n COO --> O1[Support]\n COO --> O2[Logistics]'], ['Sequence','sequenceDiagram\n participant U as User\n participant A as App\n participant S as Server\n U->>A: Open note\n A->>S: Request sync\n S-->>A: Changes\n A-->>U: Updated'], ['Mind map','mindmap\n root((My topic))\n Ideas\n First\n Second\n Tasks\n Today\n Later\n Notes'], ['State machine','stateDiagram-v2\n [*] --> Draft\n Draft --> Review\n Review --> Draft: Changes\n Review --> Published\n Published --> [*]'], ['Entity relationship','erDiagram\n CLIENT ||--o{ PROJECT : has\n PROJECT ||--|{ TASK : contains\n CLIENT { string name\n string email }\n TASK { string title\n date due }'], ['Class diagram','classDiagram\n class Page {\n +String title\n +addBlock()\n }\n class Database\n Page <|-- Database'], ['Gantt plan','gantt\n title Launch plan\n dateFormat YYYY-MM-DD\n section Build\n Design :a1, 2026-12-01, 7d\n Develop :after a1, 14d\n section Release\n Test :7d\n Launch :milestone, 0d'], ['Timeline','timeline\n title History\n 2023 : Started\n 2024 : Prototype : First users\n 2025 : Launch\n 2026 : Growth'], ['User journey','journey\n title My day\n section Morning\n Wake up: 3: Me\n Coffee: 5: Me\n section Work\n Write notes: 4: Me\n Meetings: 2: Me'], ['Pie chart','pie title Time spent\n "Writing" : 40\n "Meetings" : 25\n "Research" : 35'], ['Git graph','gitGraph\n commit\n branch feature\n commit\n checkout main\n merge feature\n commit'] ]; let dgN=0,dgQ=Promise.resolve(); const dgDark=()=>document.documentElement.dataset.theme==='dark'||(!document.documentElement.dataset.theme&&matchMedia('(prefers-color-scheme:dark)').matches); function mmLoad(){if(window.mermaid)return Promise.resolve();if(window._mmP)return window._mmP; return window._mmP=new Promise((res,rej)=>{const s=document.createElement('script'),em=document.getElementById('mmsrc');s.src=em?URL.createObjectURL(new Blob([em.textContent.split('<\\/script').join('window.mermaid?res():(window._mmP=null,rej());s.onerror=()=>{window._mmP=null;rej()};document.head.appendChild(s)})} function dgCfg(c){const st=DGS[c.style]||DGS.clean,dk=dgDark(),auto=c.style==='auto',fk=c.font||st.font||'sys',ff=(DGF[fk]||DGF.sys)[1],fs=({s:13,m:16,l:20})[c.size||'m']; let v=st.v?Object.assign({},st.v):null,bg=st.bg; if(auto){bg=dk?'#1C1C1E':'#FFFFFF';v=dk?{primaryColor:'#2C2C2E',primaryTextColor:'#F5F5F7',primaryBorderColor:'#0A84FF',lineColor:'#A1A1A6',secondaryColor:'#3A3A3C',tertiaryColor:'#1C1C1E',noteBkgColor:'#3A3A3C',noteTextColor:'#F5F5F7',textColor:'#F5F5F7',mainBkg:'#2C2C2E'}:{primaryColor:'#EAF2FF',primaryTextColor:'#1C1C1E',primaryBorderColor:'#0071E3',lineColor:'#6E6E73',secondaryColor:'#F2F2F7',tertiaryColor:'#FFFFFF',noteBkgColor:'#FFF8E1',noteTextColor:'#1C1C1E'}} if(c.bg==='clear')bg='transparent'; const R=c.rad==null||c.rad===''?st.r:+c.rad,tx=v.primaryTextColor,dsh=c.dash==='dash'?'8 5':c.dash==='dot'?'2 5':st.dash?'6 4':'',sw=st.sw*(c.thick==='b'?1.6:c.thick==='t'?.7:1); const css=`.node rect,.node polygon,.node circle,.node ellipse,.node path,.actor,.classBox rect,.statediagram-state rect{stroke-width:${st.w}px!important}.node rect,.cluster rect,.label-container,.actor{rx:${R}px;ry:${R}px}`+ `.edgePath path,.flowchart-link,.messageLine0,.messageLine1,.relationshipLine,.transition{stroke-width:${sw}px!important${dsh?';stroke-dasharray:'+dsh:''}}`+ (st.sh?`.node rect,.node polygon,.node circle,.node path,.actor{filter:drop-shadow(0 2px 5px rgba(0,0,0,.14))}`:'')+ (st.solid?`.node rect,.node polygon,.node circle,.node path{filter:drop-shadow(3px 3px 0 ${v.primaryBorderColor})}`:'')+ (st.glow?`.node rect,.node polygon,.node circle,.node path{filter:drop-shadow(0 0 6px ${v.primaryBorderColor})}.edgePath path{filter:drop-shadow(0 0 4px ${v.lineColor})}`:'')+ `.edgeLabel,.edgeLabel p,.labelBkg{background-color:${bg==='transparent'?'transparent':bg}!important}.edgeLabel rect{fill:${bg==='transparent'?'transparent':bg}!important;opacity:.95}.nodeLabel,.label,.edgeLabel,text{fill:${tx}}.cluster span{color:${tx}}`; return {startOnLoad:false,securityLevel:'strict',theme:'base',themeVariables:Object.assign({fontFamily:ff,fontSize:fs+'px',background:bg},v),themeCSS:css,fontFamily:ff,flowchart:{curve:c.curve||'basis',htmlLabels:true,padding:14,nodeSpacing:+(c.sp||44),rankSpacing:+(c.rk||52)},sequence:{mirrorActors:false,useMaxWidth:true},bg}} function dgDraw(id){const c=S.comps[id];if(!c)return Promise.resolve();const els=$$(`.dgv[data-cid="${id}"]`);if(!els.length)return Promise.resolve(); return dgQ=dgQ.then(async()=>{try{await mmLoad()}catch(e){els.forEach(el=>{el.innerHTML='