anniedrawing 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/dist/agent/index.js +1 -1
  4. package/dist/agent/index.js.map +1 -1
  5. package/dist/core/catalog.d.ts +1 -1
  6. package/dist/core/index.js +1 -1
  7. package/dist/core/textFit.d.ts +13 -0
  8. package/dist/docs/agents-repository.md +1 -1
  9. package/dist/docs/agents.md +2 -2
  10. package/dist/docs/api.md +3 -3
  11. package/dist/docs/board-js.md +16 -16
  12. package/dist/docs/decisions.md +15 -1
  13. package/dist/docs/format.md +2 -2
  14. package/dist/docs/index.html +15 -7
  15. package/dist/docs/llms-full.txt +16 -16
  16. package/dist/docs/llms.txt +10 -10
  17. package/dist/docs/mcp.md +1 -1
  18. package/dist/fellow.js +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/shared/board-OPwsZ2_V.js +2 -0
  21. package/dist/shared/board-OPwsZ2_V.js.map +1 -0
  22. package/dist/shared/{cards-DF0uI4-I.js → cards-D_9Lly1d.js} +2 -2
  23. package/dist/shared/{cards-DF0uI4-I.js.map → cards-D_9Lly1d.js.map} +1 -1
  24. package/dist/shared/defaults-DZEoAeRz.js +2 -0
  25. package/dist/shared/defaults-DZEoAeRz.js.map +1 -0
  26. package/dist/shared/describe-o3vER0cL.js +3 -0
  27. package/dist/shared/{describe-DaWyf3qV.js.map → describe-o3vER0cL.js.map} +1 -1
  28. package/dist/shared/{paste-B8nZA2Gh.js → paste-B4b0C9Jh.js} +2 -2
  29. package/dist/shared/{paste-B8nZA2Gh.js.map → paste-B4b0C9Jh.js.map} +1 -1
  30. package/dist/shared/picker-ciuPQvRn.js +2 -0
  31. package/dist/shared/picker-ciuPQvRn.js.map +1 -0
  32. package/dist/shared/textFit-BrGz6lhQ.js +2 -0
  33. package/dist/shared/textFit-BrGz6lhQ.js.map +1 -0
  34. package/dist/shared/ui-c98N8xEV.js +2 -0
  35. package/dist/shared/ui-c98N8xEV.js.map +1 -0
  36. package/dist/shared/{urlPaste-Oc4kZ0P7.js → urlPaste-BqcpeQ-c.js} +2 -2
  37. package/dist/shared/{urlPaste-Oc4kZ0P7.js.map → urlPaste-BqcpeQ-c.js.map} +1 -1
  38. package/dist/style.css +1 -1
  39. package/dist/ui/index.js +1 -1
  40. package/dist/ui/version.d.ts +1 -1
  41. package/llms-full.txt +16 -16
  42. package/llms.txt +10 -10
  43. package/package.json +1 -1
  44. package/dist/shared/board-p60lv7As.js +0 -2
  45. package/dist/shared/board-p60lv7As.js.map +0 -1
  46. package/dist/shared/defaults-C-aC_B4z.js +0 -2
  47. package/dist/shared/defaults-C-aC_B4z.js.map +0 -1
  48. package/dist/shared/describe-DaWyf3qV.js +0 -3
  49. package/dist/shared/picker-DZpEpkED.js +0 -2
  50. package/dist/shared/picker-DZpEpkED.js.map +0 -1
  51. package/dist/shared/ui-DWQtW0zJ.js +0 -2
  52. package/dist/shared/ui-DWQtW0zJ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"cards-DF0uI4-I.js","names":[],"sources":["../../src/stage/cards.ts"],"sourcesContent":["import { normalizeHref, videoEmbed } from '../core/links';\nimport { displayUrl, prettyTitle } from '../core/paste';\nimport type { AnnieDoc, Item } from '../core/types';\n\n/** Injected once from this async chunk so video/link rules stay out of the 100 KiB editor CSS. */\nfunction ensureCss() {\n if (document.getElementById('ad-card-css')) return;\n const style = document.createElement('style');\n style.id = 'ad-card-css';\n style.textContent = `.ad-video{display:block;width:100%;height:100%;border:0;pointer-events:none;background:#103639}.ad-item[data-ad-interactive=true] .ad-video{pointer-events:auto}.ad-link{display:flex;flex-direction:column;height:100%;min-width:0;min-height:0;overflow:hidden;container-type:size;background:var(--ad-paper,#fff);color:var(--ad-ink,#103639)}.ad-link-media{position:relative;flex:1 1 46%;min-height:0;background:#8f93f914}.ad-link-media img{width:100%;height:100%;object-fit:cover}.ad-link-mark{position:absolute;inset:0;display:grid;place-items:center;color:#8f93f9;font-size:36px;font-weight:800}.ad-link-body{display:flex;flex:0 0 auto;flex-direction:column;gap:4px;min-width:0;padding:10px 12px 12px}.ad-link-title,.ad-link-url{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.ad-link-title{font-size:15px;font-weight:800}.ad-link-url{color:#606062;font-size:12px}.ad-root[data-theme=dark] .ad-link-url{color:#b6c5c1}.ad-link-open{flex:0 0 auto;align-self:start;margin-top:2px;padding:5px 10px;border-radius:999px;background:#05d9ab;color:#103639;font-size:11px;font-weight:800;text-decoration:none;pointer-events:auto}@container (max-height:160px){.ad-link-media{flex-basis:34%}.ad-link-body{padding:8px 10px 10px}.ad-link-title{font-size:13px}.ad-link-url{font-size:11px}}@container (max-height:118px){.ad-link-media{display:none}.ad-link-open{padding:4px 8px}}@container (max-width:150px){.ad-link-title{font-size:12px}.ad-link-url{font-size:10px}.ad-link-open{padding:4px 8px;font-size:10px}}`;\n document.head.append(style);\n}\n\nfunction el<K extends keyof HTMLElementTagNameMap>(tag: K, cls: string, text?: string) {\n const node = document.createElement(tag);\n if (cls) node.className = cls;\n if (text) node.textContent = text;\n return node;\n}\n\nexport function paintCard(root: HTMLElement, item: Item, doc: AnnieDoc) {\n ensureCss();\n if (item.kind === 'video') {\n const src = videoEmbed(item.href);\n if (!src) {\n root.innerHTML =\n '<div class=\"ad-placeholder\"><span aria-hidden=\"true\">◇</span><span>Video unavailable</span></div>';\n return;\n }\n const frame = document.createElement('iframe');\n frame.className = 'ad-video';\n frame.src = src;\n frame.title = item.name ?? item.text?.value ?? 'Video';\n frame.allow = 'autoplay; fullscreen; picture-in-picture';\n frame.referrerPolicy = 'strict-origin-when-cross-origin';\n frame.setAttribute(\n 'sandbox',\n 'allow-scripts allow-same-origin allow-presentation allow-popups',\n );\n root.append(frame);\n return;\n }\n const href = normalizeHref(item.href);\n const title = item.text?.value || (href ? prettyTitle(href) : item.name || 'Link');\n const card = el('div', 'ad-link');\n const media = el('div', 'ad-link-media');\n const record = item.media ? doc.media[item.media] : undefined;\n if (record) {\n const img = el('img', '');\n img.draggable = false;\n img.alt = '';\n img.src = record.src;\n media.append(img);\n } else media.append(el('span', 'ad-link-mark', title.trim().slice(0, 1).toUpperCase() || '•'));\n const open = el('a', 'ad-link-open', 'Open');\n if (href) {\n open.href = href;\n open.target = '_blank';\n open.rel = 'noopener noreferrer';\n } else open.setAttribute('aria-disabled', 'true');\n const url = el('div', 'ad-link-url', href ? displayUrl(href) : '');\n url.hidden = !href;\n const body = el('div', 'ad-link-body');\n body.append(el('div', 'ad-link-title', title), url, open);\n card.append(media, body);\n root.append(card);\n}\n"],"mappings":"+FAaA,SAAS,EAA0C,EAAQ,EAAa,GACtE,MAAM,EAAO,SAAS,cAAc,GAGpC,OAFI,IAAK,EAAK,UAAY,GACtB,IAAM,EAAK,YAAc,GACtB,CACT,CAEA,SAAgB,EAAU,EAAmB,EAAY,GAEvD,GAjBF,WACE,GAAI,SAAS,eAAe,eAAgB,OAC5C,MAAM,EAAQ,SAAS,cAAc,SACrC,EAAM,GAAK,cACX,EAAM,YAAc,g/CACpB,SAAS,KAAK,OAAO,EACvB,CAUE,GACkB,UAAd,EAAK,KAAkB,CACzB,MAAM,EAAM,EAAW,EAAK,MAC5B,IAAK,EAGH,YAFA,EAAK,UACH,qGAGJ,MAAM,EAAQ,SAAS,cAAc,UAWrC,OAVA,EAAM,UAAY,WAClB,EAAM,IAAM,EACZ,EAAM,MAAQ,EAAK,MAAQ,EAAK,MAAM,OAAS,QAC/C,EAAM,MAAQ,2CACd,EAAM,eAAiB,kCACvB,EAAM,aACJ,UACA,wEAEF,EAAK,OAAO,EAEd,CACA,MAAM,EAAO,EAAc,EAAK,MAC1B,EAAQ,EAAK,MAAM,QAAU,EAAO,EAAY,GAAQ,EAAK,MAAQ,QACrE,EAAO,EAAG,MAAO,WACjB,EAAQ,EAAG,MAAO,iBAClB,EAAS,EAAK,MAAQ,EAAI,MAAM,EAAK,YAAS,EACpD,GAAI,EAAQ,CACV,MAAM,EAAM,EAAG,MAAO,IACtB,EAAI,WAAY,EAChB,EAAI,IAAM,GACV,EAAI,IAAM,EAAO,IACjB,EAAM,OAAO,EACf,MAAO,EAAM,OAAO,EAAG,OAAQ,eAAgB,EAAM,OAAO,MAAM,EAAG,GAAG,eAAiB,MACzF,MAAM,EAAO,EAAG,IAAK,eAAgB,QACjC,GACF,EAAK,KAAO,EACZ,EAAK,OAAS,SACd,EAAK,IAAM,uBACN,EAAK,aAAa,gBAAiB,QAC1C,MAAM,EAAM,EAAG,MAAO,cAAe,EAAO,EAAW,GAAQ,IAC/D,EAAI,QAAU,EACd,MAAM,EAAO,EAAG,MAAO,gBACvB,EAAK,OAAO,EAAG,MAAO,gBAAiB,GAAQ,EAAK,GACpD,EAAK,OAAO,EAAO,GACnB,EAAK,OAAO,EACd"}
1
+ {"version":3,"file":"cards-D_9Lly1d.js","names":[],"sources":["../../src/stage/cards.ts"],"sourcesContent":["import { normalizeHref, videoEmbed } from '../core/links';\nimport { displayUrl, prettyTitle } from '../core/paste';\nimport type { AnnieDoc, Item } from '../core/types';\n\n/** Injected once from this async chunk so video/link rules stay out of the 100 KiB editor CSS. */\nfunction ensureCss() {\n if (document.getElementById('ad-card-css')) return;\n const style = document.createElement('style');\n style.id = 'ad-card-css';\n style.textContent = `.ad-video{display:block;width:100%;height:100%;border:0;pointer-events:none;background:#103639}.ad-item[data-ad-interactive=true] .ad-video{pointer-events:auto}.ad-link{display:flex;flex-direction:column;height:100%;min-width:0;min-height:0;overflow:hidden;container-type:size;background:var(--ad-paper,#fff);color:var(--ad-ink,#103639)}.ad-link-media{position:relative;flex:1 1 46%;min-height:0;background:#8f93f914}.ad-link-media img{width:100%;height:100%;object-fit:cover}.ad-link-mark{position:absolute;inset:0;display:grid;place-items:center;color:#8f93f9;font-size:36px;font-weight:800}.ad-link-body{display:flex;flex:0 0 auto;flex-direction:column;gap:4px;min-width:0;padding:10px 12px 12px}.ad-link-title,.ad-link-url{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.ad-link-title{font-size:15px;font-weight:800}.ad-link-url{color:#606062;font-size:12px}.ad-root[data-theme=dark] .ad-link-url{color:#b6c5c1}.ad-link-open{flex:0 0 auto;align-self:start;margin-top:2px;padding:5px 10px;border-radius:999px;background:#05d9ab;color:#103639;font-size:11px;font-weight:800;text-decoration:none;pointer-events:auto}@container (max-height:160px){.ad-link-media{flex-basis:34%}.ad-link-body{padding:8px 10px 10px}.ad-link-title{font-size:13px}.ad-link-url{font-size:11px}}@container (max-height:118px){.ad-link-media{display:none}.ad-link-open{padding:4px 8px}}@container (max-width:150px){.ad-link-title{font-size:12px}.ad-link-url{font-size:10px}.ad-link-open{padding:4px 8px;font-size:10px}}`;\n document.head.append(style);\n}\n\nfunction el<K extends keyof HTMLElementTagNameMap>(tag: K, cls: string, text?: string) {\n const node = document.createElement(tag);\n if (cls) node.className = cls;\n if (text) node.textContent = text;\n return node;\n}\n\nexport function paintCard(root: HTMLElement, item: Item, doc: AnnieDoc) {\n ensureCss();\n if (item.kind === 'video') {\n const src = videoEmbed(item.href);\n if (!src) {\n root.innerHTML =\n '<div class=\"ad-placeholder\"><span aria-hidden=\"true\">◇</span><span>Video unavailable</span></div>';\n return;\n }\n const frame = document.createElement('iframe');\n frame.className = 'ad-video';\n frame.src = src;\n frame.title = item.name ?? item.text?.value ?? 'Video';\n frame.allow = 'autoplay; fullscreen; picture-in-picture';\n frame.referrerPolicy = 'strict-origin-when-cross-origin';\n frame.setAttribute(\n 'sandbox',\n 'allow-scripts allow-same-origin allow-presentation allow-popups',\n );\n root.append(frame);\n return;\n }\n const href = normalizeHref(item.href);\n const title = item.text?.value || (href ? prettyTitle(href) : item.name || 'Link');\n const card = el('div', 'ad-link');\n const media = el('div', 'ad-link-media');\n const record = item.media ? doc.media[item.media] : undefined;\n if (record) {\n const img = el('img', '');\n img.draggable = false;\n img.alt = '';\n img.src = record.src;\n media.append(img);\n } else media.append(el('span', 'ad-link-mark', title.trim().slice(0, 1).toUpperCase() || '•'));\n const open = el('a', 'ad-link-open', 'Open');\n if (href) {\n open.href = href;\n open.target = '_blank';\n open.rel = 'noopener noreferrer';\n } else open.setAttribute('aria-disabled', 'true');\n const url = el('div', 'ad-link-url', href ? displayUrl(href) : '');\n url.hidden = !href;\n const body = el('div', 'ad-link-body');\n body.append(el('div', 'ad-link-title', title), url, open);\n card.append(media, body);\n root.append(card);\n}\n"],"mappings":"+FAaA,SAAS,EAA0C,EAAQ,EAAa,GACtE,MAAM,EAAO,SAAS,cAAc,GAGpC,OAFI,IAAK,EAAK,UAAY,GACtB,IAAM,EAAK,YAAc,GACtB,CACT,CAEA,SAAgB,EAAU,EAAmB,EAAY,GAEvD,GAjBF,WACE,GAAI,SAAS,eAAe,eAAgB,OAC5C,MAAM,EAAQ,SAAS,cAAc,SACrC,EAAM,GAAK,cACX,EAAM,YAAc,g/CACpB,SAAS,KAAK,OAAO,EACvB,CAUE,GACkB,UAAd,EAAK,KAAkB,CACzB,MAAM,EAAM,EAAW,EAAK,MAC5B,IAAK,EAGH,YAFA,EAAK,UACH,qGAGJ,MAAM,EAAQ,SAAS,cAAc,UAWrC,OAVA,EAAM,UAAY,WAClB,EAAM,IAAM,EACZ,EAAM,MAAQ,EAAK,MAAQ,EAAK,MAAM,OAAS,QAC/C,EAAM,MAAQ,2CACd,EAAM,eAAiB,kCACvB,EAAM,aACJ,UACA,wEAEF,EAAK,OAAO,EAEd,CACA,MAAM,EAAO,EAAc,EAAK,MAC1B,EAAQ,EAAK,MAAM,QAAU,EAAO,EAAY,GAAQ,EAAK,MAAQ,QACrE,EAAO,EAAG,MAAO,WACjB,EAAQ,EAAG,MAAO,iBAClB,EAAS,EAAK,MAAQ,EAAI,MAAM,EAAK,YAAS,EACpD,GAAI,EAAQ,CACV,MAAM,EAAM,EAAG,MAAO,IACtB,EAAI,WAAY,EAChB,EAAI,IAAM,GACV,EAAI,IAAM,EAAO,IACjB,EAAM,OAAO,EACf,MAAO,EAAM,OAAO,EAAG,OAAQ,eAAgB,EAAM,OAAO,MAAM,EAAG,GAAG,eAAiB,MACzF,MAAM,EAAO,EAAG,IAAK,eAAgB,QACjC,GACF,EAAK,KAAO,EACZ,EAAK,OAAS,SACd,EAAK,IAAM,uBACN,EAAK,aAAa,gBAAiB,QAC1C,MAAM,EAAM,EAAG,MAAO,cAAe,EAAO,EAAW,GAAQ,IAC/D,EAAI,QAAU,EACd,MAAM,EAAO,EAAG,MAAO,gBACvB,EAAK,OAAO,EAAG,MAAO,gBAAiB,GAAQ,EAAK,GACpD,EAAK,OAAO,EAAO,GACnB,EAAK,OAAO,EACd"}
@@ -0,0 +1,2 @@
1
+ var e=2,t=[{kind:"rect",since:2,w:180,h:110,note:"Rounded rectangle. Nodes, cards, boxes. Agent creates grow so text fits."},{kind:"ellipse",since:2,w:180,h:110,note:"Ellipse or circle. Agent creates grow so text fits."},{kind:"diamond",since:2,w:160,h:140,note:"Diamond. Decisions or highlights. Agent creates grow so text fits."},{kind:"line",since:1,w:180,h:0,note:"Straight segment. Optional points are relative to x/y."},{kind:"connector",since:2,w:0,h:0,note:"Bound or free link. Requires from and to. Agent creates that omit route store elbow. Compact JSON omits x/y/w/h."},{kind:"path",since:1,w:0,h:0,note:"Freehand or polyline. points relative to x/y; closed optional."},{kind:"text",since:2,w:600,h:48,note:"Plain text. Default width 600. Agent creates grow so a title fits. Browser autoWidth measures."},{kind:"note",since:2,w:200,h:180,note:"Sticky note. Default moss fill and 12px corner. Agent creates grow so text fits."},{kind:"image",since:1,w:240,h:180,note:"References a media table key. Raster or SVG; remote URLs need allowed origins."},{kind:"video",since:1,w:480,h:270,note:"YouTube or Vimeo href. Stores the watch URL, not iframe markup."},{kind:"link",since:1,w:220,h:200,note:"Website card. href plus optional title, description, and preview media."},{kind:"group",since:1,w:0,h:0,note:"Only kind that contains children. Child positions stay in page coordinates."},{kind:"html",since:1,w:240,h:160,note:"Markup. Renders only when the host passed a sanitizer."}];function n(e=0){const n=e||0;return{version:2,since:n,kinds:t.filter(e=>e.since>n).map(e=>({...e}))}}var i=e=>crypto.getRandomValues(new Uint8Array(e)),r=((e,t=21)=>((e,t,n)=>{let i=256-256%e.length;if(256===i){let i=e.length-1;return(r=t)=>{if(!r)return"";let o="";for(;;){let t=n(r),s=r;for(;s--;)if(o+=e[t[s]&i],o.length>=r)return o}}}let r=Math.ceil(409.6*t/i);return(o=t)=>{if(!o)return"";let s="";for(;;){let t=n(r),l=r;for(;l--;)if(t[l]<i&&(s+=e[t[l]%e.length],s.length>=o))return s}}})(e,0|t,i))("346789abcdefghjkmnpqrtwxyz",6),o=()=>`i_${r()}`,s=()=>`p_${r()}`,l=()=>`m_${r()}`;function a(e,t){if(e&&!t.has(e)&&e.length<=160)return e;const n=(e.replace(/_\d+$/,"")||e||"i").slice(0,158);for(let i=1;i<1e7;i++){const e=`_${i}`,r=`${n.slice(0,160-e.length)}${e}`;if(!t.has(r))return r}return o()}var d={rectangle:"rect",arrow:"connector"},c={black:"ink",grey:"slate",gray:"slate",blue:"sky","light-blue":"sky",green:"teal","light-green":"moss",red:"rose","light-red":"rose",orange:"coral",yellow:"amber",violet:"violet","light-violet":"violet"};function h(e){return d[e]??e}function f(e){if(void 0!==e)return c[e]??e}function u(e){if(void 0!==e)return"string"==typeof e?{item:e,side:"auto"}:e}function g(e){if(!e)return e;const t=f(e.stroke),n=f(e.fill);return t===e.stroke&&n===e.fill?e:{...e,...void 0!==t?{stroke:t}:{},...void 0!==n?{fill:n}:{}}}var k=12,m={stroke:"ink",strokeWidth:2,dash:"solid",fill:"none",fillMode:"solid",corner:12,opacity:1},y=Object.fromEntries(t.map(e=>[e.kind,[e.w,e.h]]));function w(e){return structuredClone(e)}function p(e){return y[e]??[180,110]}function v(e){return Object.fromEntries((e??[]).filter(e=>e.defaults).map(e=>[e.kind,e.defaults]))}function b(){return{format:"anniedrawing",version:2,meta:{title:"Untitled board"},pages:[{id:"p_main",name:"Page 1",background:"paper",items:[]}],media:{}}}function x(e,t={}){const n=e.kind,i=h(n),r=t[i]??t[n];e={...e,kind:i},r&&(e={...w(r),...e,...r.style?{style:{...w(r.style),...e.style}}:{}});const s=p(i),l={...w(e),id:e.id??o(),kind:i,x:e.x??0,y:e.y??0,w:e.w??s[0],h:e.h??s[1]},a=u(e.from),d=u(e.to),c=g(e.style);return a?l.from=a:delete l.from,d?l.to=d:delete l.to,c?l.style=c:delete l.style,"arrow"===n&&(void 0===l.heads?.end&&(l.heads={...l.heads,end:"arrow"}),void 0===l.route&&(l.route="elbow")),e.children&&(l.children=e.children.map(e=>x(e,t))),l}function R(e,t={}){const n={...m,..."note"===e.kind?{fill:"moss",strokeWidth:0,corner:12}:{},...t[e.kind]?.style},i=w(e);if(0===i.rotation&&delete i.rotation,!1===i.locked&&delete i.locked,!1===i.hidden&&delete i.hidden,i.style){for(const e of Object.keys(i.style))i.style[e]===n[e]&&delete i.style[e];Object.keys(i.style).length||delete i.style}return i.children&&(i.children=i.children.map(e=>R(e,t)),i.children.length||delete i.children),"connector"===i.kind&&(delete i.x,delete i.y,delete i.w,delete i.h),i}export{a as _,w as a,n as b,R as c,f as d,u as f,s as g,l as h,g as i,x as l,o as m,y as n,b as o,h as p,m as r,v as s,k as t,p as u,e as v,t as y};
2
+ //# sourceMappingURL=defaults-DZEoAeRz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults-DZEoAeRz.js","names":["random"],"sources":["../../src/core/catalog.ts","../../node_modules/nanoid/index.browser.js","../../src/core/ids.ts","../../src/core/defaults.ts"],"sourcesContent":["/** Bump when a built-in kind is added or its create/read contract changes. */\nexport const CATALOG_VERSION = 2;\n\nexport interface KindCatalogEntry {\n kind: string;\n /** Catalog version that added this kind or last changed its create/read fields. */\n since: number;\n w: number;\n h: number;\n note: string;\n}\n\nexport interface KindCatalogSnapshot {\n version: number;\n since: number;\n kinds: KindCatalogEntry[];\n}\n\n/** Built-in kinds. `since` is the catalog version that introduced or last changed the kind. */\nexport const KIND_CATALOG: readonly KindCatalogEntry[] = [\n {\n kind: 'rect',\n since: 2,\n w: 180,\n h: 110,\n note: 'Rounded rectangle. Nodes, cards, boxes. Agent creates grow so text fits.',\n },\n {\n kind: 'ellipse',\n since: 2,\n w: 180,\n h: 110,\n note: 'Ellipse or circle. Agent creates grow so text fits.',\n },\n {\n kind: 'diamond',\n since: 2,\n w: 160,\n h: 140,\n note: 'Diamond. Decisions or highlights. Agent creates grow so text fits.',\n },\n {\n kind: 'line',\n since: 1,\n w: 180,\n h: 0,\n note: 'Straight segment. Optional points are relative to x/y.',\n },\n {\n kind: 'connector',\n since: 2,\n w: 0,\n h: 0,\n note: 'Bound or free link. Requires from and to. Agent creates that omit route store elbow. Compact JSON omits x/y/w/h.',\n },\n {\n kind: 'path',\n since: 1,\n w: 0,\n h: 0,\n note: 'Freehand or polyline. points relative to x/y; closed optional.',\n },\n {\n kind: 'text',\n since: 2,\n w: 600,\n h: 48,\n note: 'Plain text. Default width 600. Agent creates grow so a title fits. Browser autoWidth measures.',\n },\n {\n kind: 'note',\n since: 2,\n w: 200,\n h: 180,\n note: 'Sticky note. Default moss fill and 12px corner. Agent creates grow so text fits.',\n },\n {\n kind: 'image',\n since: 1,\n w: 240,\n h: 180,\n note: 'References a media table key. Raster or SVG; remote URLs need allowed origins.',\n },\n {\n kind: 'video',\n since: 1,\n w: 480,\n h: 270,\n note: 'YouTube or Vimeo href. Stores the watch URL, not iframe markup.',\n },\n {\n kind: 'link',\n since: 1,\n w: 220,\n h: 200,\n note: 'Website card. href plus optional title, description, and preview media.',\n },\n {\n kind: 'group',\n since: 1,\n w: 0,\n h: 0,\n note: 'Only kind that contains children. Child positions stay in page coordinates.',\n },\n {\n kind: 'html',\n since: 1,\n w: 240,\n h: 160,\n note: 'Markup. Renders only when the host passed a sanitizer.',\n },\n];\n\n/**\n * Built-in kinds added or last changed after `since`.\n * Omit `since` or pass 0 to list every built-in kind.\n */\nexport function kindsSince(since = 0): KindCatalogSnapshot {\n const from = since || 0;\n return {\n version: CATALOG_VERSION,\n since: from,\n kinds: KIND_CATALOG.filter((entry) => entry.since > from).map((entry) => ({ ...entry })),\n };\n}\n","\n\nimport { urlAlphabet } from './url-alphabet/index.js'\n\nexport { urlAlphabet }\n\nexport let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\n\nexport let customRandom = (alphabet, defaultSize, getRandom) => {\n let safeByteCutoff = 256 - (256 % alphabet.length)\n\n if (safeByteCutoff === 256) {\n let mask = alphabet.length - 1\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(size)\n let j = size\n while (j--) {\n id += alphabet[bytes[j] & mask]\n if (id.length >= size) return id\n }\n }\n }\n }\n\n let step = Math.ceil((1.6 * 256 * defaultSize) / safeByteCutoff)\n\n return (size = defaultSize) => {\n if (!size) return ''\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n if (bytes[j] < safeByteCutoff) {\n id += alphabet[bytes[j] % alphabet.length]\n if (id.length >= size) return id\n }\n }\n }\n }\n}\n\nexport let customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size | 0, random)\n\nexport let nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))\n while (size--) {\n id += urlAlphabet[bytes[size] & 63]\n }\n return id\n}\n","import { customAlphabet } from 'nanoid';\nconst random = customAlphabet('346789abcdefghjkmnpqrtwxyz', 6);\n/** Matches the item-id schema maximum. */\nconst ID_MAX = 160;\nexport const itemId = () => `i_${random()}`;\nexport const pageId = () => `p_${random()}`;\nexport const mediaId = () => `m_${random()}`;\n\n/** Next free id: keep `requested` when unused, otherwise `stem_1`, `stem_2`, … */\nexport function uniqueItemId(requested: string, taken: Set<string>): string {\n if (requested && !taken.has(requested) && requested.length <= ID_MAX) return requested;\n const stem = (requested.replace(/_\\d+$/, '') || requested || 'i').slice(0, ID_MAX - 2);\n for (let n = 1; n < 1e7; n++) {\n const suffix = `_${n}`;\n const id = `${stem.slice(0, ID_MAX - suffix.length)}${suffix}`;\n if (!taken.has(id)) return id;\n }\n return itemId();\n}\n","import type { AnnieDoc, Endpoint, EndpointInput, Item, NewItem, Style } from './types';\nimport { KIND_CATALOG } from './catalog';\nimport { itemId } from './ids';\nexport const KIND_ALIASES: Record<string, string> = {\n rectangle: 'rect',\n arrow: 'connector',\n};\nexport const COLOR_ALIASES: Record<string, string> = {\n black: 'ink',\n grey: 'slate',\n gray: 'slate',\n blue: 'sky',\n 'light-blue': 'sky',\n green: 'teal',\n 'light-green': 'moss',\n red: 'rose',\n 'light-red': 'rose',\n orange: 'coral',\n yellow: 'amber',\n violet: 'violet',\n 'light-violet': 'violet',\n};\nexport function storedKind(kind: string): string {\n return KIND_ALIASES[kind] ?? kind;\n}\nexport function storedColor(value?: string): string | undefined {\n if (value === undefined) return undefined;\n return COLOR_ALIASES[value] ?? value;\n}\nexport function storedEndpoint(value?: EndpointInput): Endpoint | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'string') return { item: value, side: 'auto' };\n return value;\n}\nexport function aliasStyle(style?: Style): Style | undefined {\n if (!style) return style;\n const stroke = storedColor(style.stroke),\n fill = storedColor(style.fill);\n if (stroke === style.stroke && fill === style.fill) return style;\n return {\n ...style,\n ...(stroke !== undefined ? { stroke } : {}),\n ...(fill !== undefined ? { fill } : {}),\n };\n}\nexport const CARD_CORNER = 12;\nexport const DEFAULT_STYLE: Required<Style> = {\n stroke: 'ink',\n strokeWidth: 2,\n dash: 'solid',\n fill: 'none',\n fillMode: 'solid',\n corner: CARD_CORNER,\n opacity: 1,\n};\nexport const DEFAULT_SIZES: Record<string, [number, number]> = Object.fromEntries(\n KIND_CATALOG.map((entry) => [entry.kind, [entry.w, entry.h]]),\n);\nexport function clone<T>(value: T): T {\n return structuredClone(value);\n}\nexport function sizeOf(kind: string): [number, number] {\n return DEFAULT_SIZES[kind] ?? [180, 110];\n}\nexport function kindDefaultsFrom(\n kinds?: { kind: string; defaults?: Partial<Item> }[],\n): Record<string, Partial<Item>> {\n return Object.fromEntries(\n (kinds ?? []).filter((kind) => kind.defaults).map((kind) => [kind.kind, kind.defaults!]),\n );\n}\nexport function defaultDoc(): AnnieDoc {\n return {\n format: 'anniedrawing',\n version: 2,\n meta: { title: 'Untitled board' },\n pages: [{ id: 'p_main', name: 'Page 1', background: 'paper', items: [] }],\n media: {},\n };\n}\nexport function normalizeItem(\n input: NewItem,\n kindDefaults: Record<string, Partial<Item>> = {},\n): Item {\n const originalKind = input.kind,\n kind = storedKind(originalKind);\n const custom = kindDefaults[kind] ?? kindDefaults[originalKind];\n input = { ...input, kind };\n if (custom)\n input = {\n ...clone(custom),\n ...input,\n ...(custom.style ? { style: { ...clone(custom.style), ...input.style } } : {}),\n };\n const size = sizeOf(kind);\n const result = {\n ...clone(input),\n id: input.id ?? itemId(),\n kind,\n x: input.x ?? 0,\n y: input.y ?? 0,\n w: input.w ?? size[0],\n h: input.h ?? size[1],\n } as Item;\n const from = storedEndpoint(input.from),\n to = storedEndpoint(input.to),\n style = aliasStyle(input.style);\n if (from) result.from = from;\n else delete result.from;\n if (to) result.to = to;\n else delete result.to;\n if (style) result.style = style;\n else delete result.style;\n if (originalKind === 'arrow') {\n if (result.heads?.end === undefined) result.heads = { ...result.heads, end: 'arrow' };\n if (result.route === undefined) result.route = 'elbow';\n }\n if (input.children)\n result.children = input.children.map((child) => normalizeItem(child, kindDefaults));\n return result;\n}\nexport function minimalItem(item: Item, kindDefaults: Record<string, Partial<Item>> = {}): Item {\n const defaults = {\n ...DEFAULT_STYLE,\n ...(item.kind === 'note' ? { fill: 'moss', strokeWidth: 0, corner: CARD_CORNER } : {}),\n ...kindDefaults[item.kind]?.style,\n };\n const next = clone(item);\n if (next.rotation === 0) delete next.rotation;\n if (next.locked === false) delete next.locked;\n if (next.hidden === false) delete next.hidden;\n if (next.style) {\n for (const key of Object.keys(next.style) as (keyof Style)[])\n if (next.style[key] === defaults[key]) delete next.style[key];\n if (!Object.keys(next.style).length) delete next.style;\n }\n if (next.children) {\n next.children = next.children.map((child) => minimalItem(child, kindDefaults));\n if (!next.children.length) delete next.children;\n }\n if (next.kind === 'connector') {\n delete (next as Partial<Item>).x;\n delete (next as Partial<Item>).y;\n delete (next as Partial<Item>).w;\n delete (next as Partial<Item>).h;\n }\n return next;\n}\n"],"x_google_ignoreList":[1],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ import{_ as e,a as t,m as n,p as i}from"./defaults-DZEoAeRz.js";var s={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function r(e){return e?{lang:e?.lang??void 0,message:e?.message,abortEarly:e?.abortEarly??void 0,abortPipeEarly:e?.abortPipeEarly??void 0}:s}function o(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function a(e,t,n,i,s){const r=s&&"input"in s?s.input:n.value,a=s?.expected??e.expects??null,u=s?.received??/* @__PURE__ */o(r),c={kind:e.kind,type:e.type,input:r,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},l="schema"===e.kind,p=s?.message??e.message??(/* @__PURE__ */e.reference,void c.lang)??(l?/* @__PURE__ */void c.lang:null)??i.message??/* @__PURE__ */void c.lang;void 0!==p&&(c.message="function"==typeof p?p(c):p),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function u(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function c(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&"__proto__"!==t&&"prototype"!==t&&"constructor"!==t}function l(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}function p(e){return e["~standard"]={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},/* @__PURE__ */r())},e}function y(e){return{kind:"validation",type:"finite",reference:y,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&a(this,"finite",e,t),e}}}function f(e){return{kind:"validation",type:"integer",reference:f,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&a(this,"integer",e,t),e}}}function d(e,t){return{kind:"validation",type:"max_length",reference:d,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&a(this,"length",e,t,{received:`${e.value.length}`}),e}}}function h(e,t){return{kind:"validation",type:"max_value",reference:h,async:!1,expects:`<=${e instanceof Date?e.toJSON():/* @__PURE__ */o(e)}`,requirement:e,message:t,"~run"(e,t){return!e.typed||e.value<=this.requirement||a(this,"value",e,t,{received:e.value instanceof Date?e.value.toJSON():/* @__PURE__ */o(e.value)}),e}}}function m(e,t){return{kind:"validation",type:"min_length",reference:m,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length<this.requirement&&a(this,"length",e,t,{received:`${e.value.length}`}),e}}}function x(e,t){return{kind:"validation",type:"min_value",reference:x,async:!1,expects:`>=${e instanceof Date?e.toJSON():/* @__PURE__ */o(e)}`,requirement:e,message:t,"~run"(e,t){return!e.typed||e.value>=this.requirement||a(this,"value",e,t,{received:e.value instanceof Date?e.value.toJSON():/* @__PURE__ */o(e.value)}),e}}}var g={abortEarly:!0};function v(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function b(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function w(e,t){return p({kind:"schema",type:"array",reference:w,expects:"Array",async:!1,item:e,message:t,"~run"(e,t){const n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let i=0;i<n.length;i++){const s=n[i],r=this.item["~run"]({value:s},t);if(r.issues){const o={type:"array",origin:"value",input:n,key:i,value:s};for(const t of r.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=r.issues),t.abortEarly){e.typed=!1;break}}r.typed||(e.typed=!1),e.value.push(r.value)}}else a(this,"type",e,t);return e}})}function k(e){return p({kind:"schema",type:"boolean",reference:k,expects:"boolean",async:!1,message:e,"~run"(e,t){return"boolean"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}})}function $(e,t){return p({kind:"schema",type:"literal",reference:$,expects:/* @__PURE__ */o(e),async:!1,literal:e,message:t,"~run"(e,t){/* @__PURE__ */
2
+ return u(e.value,this.literal)?e.typed=!0:a(this,"type",e,t),e}})}function M(e,t){return p({kind:"schema",type:"loose_object",reference:M,expects:"Object",async:!1,entries:e,message:t,"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const i in this.entries){const s=this.entries[i];if(i in n||("exact_optional"===s.type||"optional"===s.type||"nullish"===s.type)&&void 0!==s.default){const r=i in n?n[i]:/* @__PURE__ */b(s),o=s["~run"]({value:r},t);if(o.issues){const s={type:"object",origin:"value",input:n,key:i,value:r};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[i]=o.value}else if(void 0!==s.fallback)e.value[i]=/* @__PURE__ */v(s);else if("exact_optional"!==s.type&&"optional"!==s.type&&"nullish"!==s.type&&(a(this,"key",e,t,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:n,key:i,value:n[i]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly)for(const t in n)/* @__PURE__ */c(n,t)&&!Object.prototype.hasOwnProperty.call(this.entries,t)&&(e.value[t]=n[t])}else a(this,"type",e,t);return e}})}function j(e){return p({kind:"schema",type:"number",reference:j,expects:"number",async:!1,message:e,"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?a(this,"type",e,t):e.typed=!0,e}})}function E(e,t){return p({kind:"schema",type:"object",reference:E,expects:"Object",async:!1,entries:e,message:t,"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const i in this.entries){const s=this.entries[i];if(i in n||("exact_optional"===s.type||"optional"===s.type||"nullish"===s.type)&&void 0!==s.default){const r=i in n?n[i]:/* @__PURE__ */b(s),o=s["~run"]({value:r},t);if(o.issues){const s={type:"object",origin:"value",input:n,key:i,value:r};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[i]=o.value}else if(void 0!==s.fallback)e.value[i]=/* @__PURE__ */v(s);else if("exact_optional"!==s.type&&"optional"!==s.type&&"nullish"!==s.type&&(a(this,"key",e,t,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:n,key:i,value:n[i]}]}),t.abortEarly))break}}else a(this,"type",e,t);return e}})}function O(e,t){return p({kind:"schema",type:"optional",reference:O,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=/* @__PURE__ */b(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}})}function A(e,t){return p({kind:"schema",type:"picklist",reference:A,expects:/* @__PURE__ */l(e.map(o),"|"),async:!1,options:e,message:t,"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:a(this,"type",e,t),e}})}function S(e,t,n){return p({kind:"schema",type:"record",reference:S,expects:"Object",async:!1,key:e,value:t,message:n,"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const i in n)if(/* @__PURE__ */c(n,i)){const s=n[i],r=this.key["~run"]({value:i},t);if(r.issues){const o={type:"object",origin:"key",input:n,key:i,value:s};for(const t of r.issues)t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=r.issues),t.abortEarly){e.typed=!1;break}}const o=this.value["~run"]({value:s},t);if(o.issues){const r={type:"object",origin:"value",input:n,key:i,value:s};for(const t of o.issues)t.path?t.path.unshift(r):t.path=[r],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}r.typed&&o.typed||(e.typed=!1),r.typed&&(e.value[r.value]=o.value)}}else a(this,"type",e,t);return e}})}function N(e){return p({kind:"schema",type:"string",reference:N,expects:"string",async:!1,message:e,"~run"(e,t){return"string"==typeof e.value?e.typed=!0:a(this,"type",e,t),e}})}function q(e,t){return p({kind:"schema",type:"tuple",reference:q,expects:"Array",async:!1,items:e,message:t,"~run"(e,t){const n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let i=0;i<this.items.length;i++){const s=n[i],r=this.items[i]["~run"]({value:s},t);if(r.issues){const o={type:"array",origin:"value",input:n,key:i,value:s};for(const t of r.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=r.issues),t.abortEarly){e.typed=!1;break}}r.typed||(e.typed=!1),e.value.push(r.value)}}else a(this,"type",e,t);return e}})}function _(e,t,n){return p({kind:"schema",type:"tuple_with_rest",reference:_,expects:"Array",async:!1,items:e,rest:t,message:n,"~run"(e,t){const n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let i=0;i<this.items.length;i++){const s=n[i],r=this.items[i]["~run"]({value:s},t);if(r.issues){const o={type:"array",origin:"value",input:n,key:i,value:s};for(const t of r.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=r.issues),t.abortEarly){e.typed=!1;break}}r.typed||(e.typed=!1),e.value.push(r.value)}if(!e.issues||!t.abortEarly)for(let i=this.items.length;i<n.length;i++){const s=n[i],r=this.rest["~run"]({value:s},t);if(r.issues){const o={type:"array",origin:"value",input:n,key:i,value:s};for(const t of r.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=r.issues),t.abortEarly){e.typed=!1;break}}r.typed||(e.typed=!1),e.value.push(r.value)}}else a(this,"type",e,t);return e}})}function P(e){let t;if(e)for(const n of e)if(t)for(const e of n.issues)t.push(e);else t=n.issues;return t}function I(e,t){return p({kind:"schema",type:"union",reference:I,expects:/* @__PURE__ */l(e.map(e=>e.expects),"|"),async:!1,options:e,message:t,"~run"(e,t){let n,i,s;for(const r of this.options){const o=r["~run"]({value:e.value},t);if(o.typed){if(!o.issues){n=o;break}i?i.push(o):i=[o]}else s?s.push(o):s=[o]}if(n)return n;if(i){if(1===i.length)return i[0];a(this,"type",e,t,{issues:/* @__PURE__ */P(i)}),e.typed=!0}else{if(1===s?.length)return s[0];a(this,"type",e,t,{issues:/* @__PURE__ */P(s)})}return e}})}function J(...e){return p({...e[0],pipe:e,"~run"(t,n){for(const i of e)if("metadata"!==i.kind){if(t.issues&&("schema"===i.kind||"transformation"===i.kind)){t.typed=!1;break}t.issues&&(n.abortEarly||n.abortPipeEarly)||(t=i["~run"](t,n))}return t}})}function L(e,t,n){const i=e["~run"]({value:t},/* @__PURE__ */r(n));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}var D={maxBatch:1e3,maxItems:5e4,maxCoordinate:1e6,maxTextLength:1e5,maxDepth:32,maxPoints:1e5,maxMediaLength:2e7,maxHistory:100,maxSessionLog:500,maxJsonDepth:104},C={colors:32,maxBytes:245760},T=J(j(),y()),z=J(T,x(-D.maxCoordinate),h(D.maxCoordinate)),B=J(T,x(0),h(D.maxCoordinate)),W=J(N(),m(1),d(160)),F=J(N(),d(D.maxTextLength)),R=E({x:z,y:z}),H=E({x:z,y:z,w:B,h:B}),U=E({stroke:O(N()),strokeWidth:O(J(B,h(1e3))),dash:O(A(["solid","dashed","dotted"])),fill:O(N()),fillMode:O(A(["solid","tint","hatch"])),corner:O(B),opacity:O(J(T,x(0),h(1)))}),G=E({value:F,align:O(A(["start","center","end"])),valign:O(A(["top","middle","bottom"])),size:O(I([A(["s","m","l","xl"]),J(T,x(1),h(1e3))])),font:O(A(["sans","serif","mono","hand"]))}),K=S(N(),function e(){return p({kind:"schema",type:"unknown",reference:e,expects:"unknown",async:!1,"~run":e=>(e.typed=!0,e)})}()),Q=I([W,E({item:W,side:O(A(["auto","top","right","bottom","left"])),anchor:O(q([J(T,x(0),h(1)),J(T,x(0),h(1))]))}),R]),V=function e(t){return p({kind:"schema",type:"lazy",reference:e,expects:"unknown",async:!1,getter:t,"~run"(e,t){return this.getter(e.value)["~run"](e,t)}})}(()=>M({id:O(W),kind:J(N(),m(1),d(100)),x:O(z),y:O(z),w:O(B),h:O(B),rotation:O(z),style:O(U),text:O(G),locked:O(k()),hidden:O(k()),name:O(F),data:O(K),children:O(w(V)),points:O(J(w(_([z,z],J(T,x(0),h(1)))),d(D.maxPoints))),from:O(Q),to:O(Q),route:O(A(["straight","elbow","curve"])),heads:O(E({start:O(A(["none","arrow","dot"])),end:O(A(["none","arrow","dot"]))})),waypoints:O(w(q([z,z]))),closed:O(k()),autoWidth:O(k()),media:O(W),crop:O(H),href:O(F),description:O(F),html:O(F),mount:O(W)})),X=M({x:O(z),y:O(z),w:O(B),h:O(B),rotation:O(z),style:O(U),text:O(function(e,t){const n={};for(const i in e.entries)n[i]=!t||t.includes(i)?/* @__PURE__ */O(e.entries[i]):e.entries[i];return p({...e,entries:n})}(G)),href:O(F),description:O(F),data:O(K),from:O(Q),to:O(Q)}),Y=E({rightOf:O(W),leftOf:O(W),above:O(W),below:O(W),inside:O(W),near:O(W),gap:O(B),align:O(A(["start","middle","end"]))}),Z=E({mime:J(N(),function e(t,n){return{kind:"validation",type:"regex",reference:e,async:!1,expects:`${t}`,requirement:t,message:n,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&a(this,"format",e,t),e}}}(/^image\/(png|jpeg|gif|webp|avif|svg\+xml)$/)),w:B,h:B,src:J(N(),d(D.maxMediaLength))}),ee=E({id:W,name:F,background:O(N()),items:w(V)}),te=E({format:$("anniedrawing"),version:$(2),meta:M({title:F,modified:O(N())}),pages:J(w(ee),m(1)),media:S(N(),Z)}),ne=function e(t,n,i){return p({kind:"schema",type:"variant",reference:e,expects:"Object",async:!1,key:t,options:n,message:i,"~run"(e,t){const n=e.value;if(n&&"object"==typeof n){let i,s=0,r=this.key,o=[];const u=(e,a)=>{for(const c of e.options){if("variant"===c.type)u(c,new Set(a).add(c.key));else{let e=!0,u=0;for(const t of a){const i=c.entries[t];if(t in n?i["~run"]({typed:!1,value:n[t]},g).issues:"exact_optional"!==i.type&&"optional"!==i.type&&"nullish"!==i.type){e=!1,r!==t&&(s<u||s===u&&t in n&&!(r in n))&&(s=u,r=t,o=[]),r===t&&o.push(c.entries[t].expects);break}u++}if(e){const e=c["~run"]({value:n},t);(!i||!i.typed&&e.typed)&&(i=e)}}if(i&&!i.issues)break}};if(u(this,/* @__PURE__ */new Set([this.key])),i)return i;a(this,"type",e,t,{input:n[r],expected:/* @__PURE__ */l(o,"|"),path:[{type:"object",origin:"value",input:n,key:r,value:n[r]}]})}else a(this,"type",e,t);return e}})}("op",[E({op:$("add"),item:V,page:O(W),parent:O(W),index:O(J(j(),f(),x(0))),place:O(Y)}),E({op:$("set"),id:W,patch:X}),E({op:$("remove"),id:W}),E({op:$("order"),id:W,to:I([A(["front","back","forward","backward"]),J(j(),f(),x(0))])}),E({op:$("reparent"),id:W,parent:function e(t,n){return p({kind:"schema",type:"nullable",reference:e,expects:`(${t.expects} | null)`,async:!1,wrapped:t,default:n,"~run"(e,t){return null===e.value&&(void 0!==this.default&&(e.value=/* @__PURE__ */b(this,e,t)),null===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}})}(W),index:O(J(j(),f(),x(0)))}),E({op:$("page.add"),index:O(J(j(),f(),x(0))),page:E({id:O(W),name:F,background:O(N()),items:O(w(V))})}),E({op:$("page.set"),id:W,patch:E({name:O(F),background:O(N())})}),E({op:$("page.remove"),id:W}),E({op:$("meta.set"),patch:M({title:O(F),modified:O(N())})}),E({op:$("media.set"),id:W,media:Z}),E({op:$("media.remove"),id:W})]),ie=J(w(ne),d(D.maxBatch)),se=E({kind:O(I([N(),w(N())])),text:O(N()),within:O(H),connectedTo:O(W),direction:O(A(["in","out","both"])),inside:O(W),data:O(K),hidden:O(k()),locked:O(k()),page:O(W)}),re=E({scope:O(A(["doc","page","selection","viewport"])),detail:O(A(["brief","normal","full"])),relations:O(k()),freeSpace:O(k()),maxItems:O(J(j(),f(),x(1),h(1e4))),selection:O(w(W)),page:O(W),since:O(J(j(),y()))});function oe(e,t){const n=L(e,t);return n.success?void 0:n.issues.map(e=>`${e.path?.map(e=>e.key).join(".")??"value"}: ${e.message}`).join("; ")}var ae=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function ue(e,t,n){const i=n*Math.PI/180,s=Math.cos(i),r=Math.sin(i),o=e.x-t.x,a=e.y-t.y;return{x:t.x+o*s-a*r,y:t.y+o*r+a*s}}function ce(e,t,n){const i=n.x-t.x,s=n.y-t.y,r=i*i+s*s,o=r?Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*s)/r)):0;return Math.hypot(e.x-t.x-o*i,e.y-t.y-o*s)}function le(e,t){let n=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const r=t[i],o=t[s];r.y>e.y!=o.y>e.y&&e.x<(o.x-r.x)*(e.y-r.y)/(o.y-r.y)+r.x&&(n=!n)}return n}function pe(e,t=.5){if(e.length<3)return e.slice();const n=/* @__PURE__ */new Set([0,e.length-1]),i=[[0,e.length-1]];for(;i.length;){const[s,r]=i.pop();let o=t,a=-1;for(let t=s+1;t<r;t++){const n=ce({x:e[t][0],y:e[t][1]},{x:e[s][0],y:e[s][1]},{x:e[r][0],y:e[r][1]});n>o&&(o=n,a=t)}a>=0&&(n.add(a),i.push([s,a],[a,r]))}return[...n].sort((e,t)=>e-t).map(t=>e[t])}function ye(e,t){if(e.length<3)return e;let n=0,i=0;for(let s=1;s<e.length-1;s++){const r=ce({x:e[s][0],y:e[s][1]},{x:e[0][0],y:e[0][1]},{x:e.at(-1)[0],y:e.at(-1)[1]}),o=s/(e.length-1),a=(e[0][2]??.5)*(1-o)+(e.at(-1)[2]??.5)*o,u=Math.max(r,Math.abs((e[s][2]??.5)-a)>.08?2*t:0);u>n&&(n=u,i=s)}return n>t?[...ye(e.slice(0,i+1),t).slice(0,-1),...ye(e.slice(i),t)]:[e[0],e.at(-1)]}var fe=/* @__PURE__ */new Set(["connector","line","path","group"]);function de(e,t,n){const i=je(t,e);if("group"!==i?.kind)return i;const s=Ee(i.children??[]).filter(e=>"connector"!==e.kind&&"group"!==e.kind).map(e=>je(t,e.id)??e);return s.length?{...i,...qe(s,t,n),rotation:0}:i}function he(e,t,n){const i=n?.(e);if(!i)return;const s=Array.isArray(i)?i:[i],r=e.w/2,o=e.h/2,a=t.x**2+t.y**2;if(!a)return;const u=(e,t)=>e.x*t.y-e.y*t.x;let c=-1/0;for(const l of s){const e=l.points.length;for(let n=0;n<e-(l.closed?0:1);n++){const i=l.points[n],s=l.points[(n+1)%e],p={x:s.x-i.x,y:s.y-i.y},y={x:i.x-r,y:i.y-o},f=u(t,p);if(Math.abs(f)<1e-10){if(Math.abs(u(y,t))<1e-10)for(const e of[i,s]){const n=((e.x-r)*t.x+(e.y-o)*t.y)/a;n>=0&&(c=Math.max(c,n))}continue}const d=u(y,p)/f,h=u(y,t)/f;d>=-1e-10&&h>=-1e-10&&h<=1+1e-10&&(c=Math.max(c,Math.max(0,d)))}}return Number.isFinite(c)?{x:e.x+r+t.x*c,y:e.y+o+t.y*c}:void 0}function me(e,t,n,i){if(!e)return{x:0,y:0};if(!("item"in e))return{x:e.x,y:e.y};const s=de(e.item,n,i);if(!s)return{x:0,y:0};const r=Oe(s);let o;if(e.anchor)o={x:s.x+s.w*e.anchor[0],y:s.y+s.h*e.anchor[1]};else if(e.side&&"auto"!==e.side)o="top"===e.side?{x:r.x,y:s.y}:"bottom"===e.side?{x:r.x,y:s.y+s.h}:"left"===e.side?{x:s.x,y:r.y}:{x:s.x+s.w,y:r.y},o=he(s,{x:o.x-r.x,y:o.y-r.y},i)??o;else{const e=ue(function(e,t,n){if(!e)return{x:0,y:0};if("item"in e){const i=de(e.item,t,n);return i?Oe(i):{x:0,y:0}}return e}(t,n,i),r,-(s.rotation??0));let a=e.x-r.x,u=e.y-r.y;a||u||(a=1);const c=Math.max(s.w/2,.001),l=Math.max(s.h/2,.001),p="ellipse"===s.kind?1/Math.sqrt(a*a/(c*c)+u*u/(l*l)):"diamond"===s.kind?1/(Math.abs(a)/c+Math.abs(u)/l):Math.min(c/Math.max(Math.abs(a),1e-4),l/Math.max(Math.abs(u),1e-4));o=he(s,{x:a,y:u},i)??{x:r.x+a*p,y:r.y+u*p}}return ue(o,r,s.rotation??0)}function xe(e){if(!(e.hidden||fe.has(e.kind)||e.w<=0||e.h<=0))return{x:e.x,y:e.y,w:e.w,h:e.h}}function ge(e,t,n,i){const s=n.x-i,r=n.y-i,o=n.x+n.w+i,a=n.y+n.h+i,u=Math.min(e.x,t.x),c=Math.max(e.x,t.x),l=Math.min(e.y,t.y),p=Math.max(e.y,t.y);return!(c<s||u>o||p<r||l>a)&&(e.x===t.x?e.x>=s&&e.x<=o&&l<=a&&p>=r:e.y!==t.y||e.y>=r&&e.y<=a&&u<=o&&c>=s)}function ve(e,t,n=0){let i=0;for(let s=0;s<e.length-1;s++)for(const r of t)ge(e[s],e[s+1],r,n)&&i++;return i}function be(e){return e.slice(1).reduce((t,n,i)=>t+ae(e[i],n),0)}function we(e,t,n,i){if(n){const n=i??(e.y+t.y)/2;return[e,{x:e.x,y:n},{x:t.x,y:n},t]}const s=i??(e.x+t.x)/2;return[e,{x:s,y:e.y},{x:s,y:t.y},t]}function ke(e){return e&&"item"in e?e.item:void 0}function $e(e,t,n,i,s){const r=new Set([i.id,ke(i.from),ke(i.to)].filter(e=>!!e)),o=function(e){return e?Array.isArray(e)?Ee(e):e instanceof Map?[...e.values()]:"function"==typeof e?[]:Object.values(e):[]}(s).filter(e=>!r.has(e.id)).map(xe).filter(e=>!!e),a=we(e,t,n);if(!o.length||!ve(a,o))return a;const u=we(e,t,!n),c=o.filter(e=>ve(a,[e])||ve(u,[e])),l=[a,u];for(const p of c.slice(0,8))l.push(we(e,t,!0,p.y-16),we(e,t,!0,p.y+p.h+16),we(e,t,!1,p.x-16),we(e,t,!1,p.x+p.w+16));return l.reduce((e,t)=>{const n=ve(e,o),i=ve(t,o);return i!==n?i<n?t:e:be(t)<be(e)?t:e})}function Me(e,t,n){const i=me(e.from,e.to,t,n),s=me(e.to,e.from,t,n);let r=[i,...(e.waypoints??[]).map(([e,t])=>({x:e,y:t})),s],o="";if("elbow"===e.route&&!e.waypoints?.length){const n=e.from,o=n&&"item"in n?n.side:void 0;r=$e(i,s,"top"===o||"bottom"===o||(!o||"auto"===o)&&Math.abs(s.y-i.y)>Math.abs(s.x-i.x),e,t)}if("curve"!==e.route||e.waypoints?.length)o=r.map((e,t)=>`${t?"L":"M"} ${e.x} ${e.y}`).join(" ");else{const e=s.x-i.x,t=s.y-i.y,n={x:(i.x+s.x)/2-.22*t,y:(i.y+s.y)/2+.22*e};o=`M ${i.x} ${i.y} Q ${n.x} ${n.y} ${s.x} ${s.y}`,r=Array.from({length:25},(e,t)=>{const r=t/24,o=1-r;return{x:o*o*i.x+2*o*r*n.x+r*r*s.x,y:o*o*i.y+2*o*r*n.y+r*r*s.y}})}const a=r.slice(1).map((e,t)=>ae(r[t],e));let u=a.reduce((e,t)=>e+t,0)/2,c=i;for(let l=0;l<a.length;l++){if(u<=a[l]){const e=a[l]?u/a[l]:0;c={x:r[l].x+(r[l+1].x-r[l].x)*e,y:r[l].y+(r[l+1].y-r[l].y)*e};break}u-=a[l]}return{points:r,d:o,midpoint:c,bounds:Se(r)}}function je(e,t){return"function"==typeof e?e(t):e instanceof Map?e.get(t):Array.isArray(e)?Ee(e).find(e=>e.id===t):e?.[t]}function Ee(e){const t=[];return function e(n){for(const i of n)t.push(i),i.children&&e(i.children)}(e),t}var Oe=e=>({x:e.x+e.w/2,y:e.y+e.h/2});function Ae(e,t=0,n=Oe(e)){const i=[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}];return t?i.map(e=>ue(e,n,t)):i}function Se(e){if(!e.length)return{x:0,y:0,w:0,h:0};let t=1/0,n=1/0,i=-1/0,s=-1/0;for(const r of e)t=Math.min(t,r.x),n=Math.min(n,r.y),i=Math.max(i,r.x),s=Math.max(s,r.y);return{x:t,y:n,w:i-t,h:s-n}}function Ne(e,t,n){if("connector"===e.kind)return Me(e,t,n).bounds;if("group"===e.kind&&e.children?.length)return qe(e.children.map(e=>je(t,e.id)??e),t,n);let i={x:e.x,y:e.y,w:e.w,h:e.h};return"path"!==e.kind&&"line"!==e.kind||!e.points?.length||(i=Se(e.points.map(t=>({x:e.x+t[0],y:e.y+t[1]})))),e.rotation?Se(Ae(i,e.rotation,Oe(e))):i}function qe(e,t,n){const i=t??new Map(Ee(e).map(e=>[e.id,e]));return Se(e.flatMap(e=>{const t=Ne(e,i,n);return[{x:t.x,y:t.y},{x:t.x+t.w,y:t.y+t.h}]}))}var _e=(e,t)=>e.x<=t.x+t.w&&e.x+e.w>=t.x&&e.y<=t.y+t.h&&e.y+e.h>=t.y,Pe=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.w<=e.x+e.w&&t.y+t.h<=e.y+e.h,Ie=(e,t)=>t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h;function Je(e){return e.pages.flatMap(e=>e.items)}function Le(e){return Ee(Je(e))}function De(e,t){return t?{...e,...t,style:t.style?{...e.style,...t.style}:e.style,text:t.text?{...e.text,...t.text}:e.text,data:t.data?{...e.data,...t.data}:e.data}:e}function Ce(e,t,n){const i={x:(e.x??0)+t,y:(e.y??0)+n};if("connector"===e.kind){for(const s of["from","to"]){const r=e[s];r&&!("item"in r)&&(i[s]={x:r.x+t,y:r.y+n})}e.waypoints&&(i.waypoints=e.waypoints.map(([e,i])=>[e+t,i+n]))}return i}var Te=["rightOf","leftOf","above","below","inside","near"];function ze(n,i){const s=t(i),r=new Set(Le(n).map(e=>e.id)),o=/* @__PURE__ */new Map,a=[],u=(t,n)=>{t&&"object"==typeof t&&("string"==typeof t.id&&t.id&&(t.id=((t,n)=>{const i=e(t,r);return r.add(i),o.has(t)||o.set(t,i),i!==t&&a.push({index:n,code:"ID_REMAPPED",message:`Item id ${t} was already in use; stored as ${i}.`}),i})(t.id,n)),t.children?.forEach(e=>u(e,n)))};for(let e=0;e<s.length;e++){const t=s[e];t&&"object"==typeof t&&("add"===t.op?u(t.item,e):"page.add"===t.op?t.page.items?.forEach(t=>u(t,e)):"set"===t.op&&Array.isArray(t.patch?.children)&&t.patch.children.forEach(t=>u(t,e)))}const c=e=>e&&o.has(e)?o.get(e):e,l=e=>"string"==typeof e?c(e)??e:e&&"item"in e?{...e,item:c(e.item)??e.item}:e,p=e=>{e&&"object"==typeof e&&("from"in e&&void 0!==e.from&&(e.from=l(e.from)),"to"in e&&void 0!==e.to&&(e.to=l(e.to)),e.children?.forEach(p))};for(const e of s)if(e&&"object"==typeof e)if("add"===e.op){if(p(e.item),e.parent&&(e.parent=c(e.parent)),e.place)for(const t of Te){const n=e.place[t];n&&(e.place[t]=c(n))}}else"page.add"===e.op?e.page.items?.forEach(p):"set"===e.op?(e.id=c(e.id),void 0!==e.patch.from&&(e.patch.from=l(e.patch.from)),void 0!==e.patch.to&&(e.patch.to=l(e.patch.to)),Array.isArray(e.patch.children)&&e.patch.children.forEach(p)):"remove"===e.op||"order"===e.op?e.id=c(e.id):"reparent"===e.op&&(e.id=c(e.id),e.parent&&(e.parent=c(e.parent)));return{ops:s,warnings:a}}function Be(e,i,s=n){const r=new Map(Ee(e).map(e=>[e.id,s()])),o=e=>{const n={...t(e),id:r.get(e.id),x:(e.x??0)+i,y:(e.y??0)+i};e.children&&(n.children=e.children.map(o)),e.waypoints&&(n.waypoints=e.waypoints.map(([e,t])=>[e+i,t+i]));for(const t of["from","to"]){const s=e[t];s&&(n[t]="item"in s?{...s,item:r.get(s.item)??s.item}:{x:s.x+i,y:s.y+i})}return n};return e.map(o)}function We(e,n,i){const s=Ee([...e]),r=new Set(s.map(e=>e.id)),o=[];for(const a of s){const e={};for(const s of["from","to"]){const o=a[s];o&&"item"in o&&!r.has(o.item)&&(e[s]=t(o),a[s]=me(o,a["from"===s?"to":"from"],n,i))}Object.keys(e).length&&o.push({op:"set",id:a.id,patch:e})}return o}function Fe(e,t,n,i=n){const s=["rightOf","leftOf","above","below","inside","near"].filter(e=>t[e]);if(1!==s.length)throw new Error("Placement requires exactly one of rightOf, leftOf, above, below, inside, or near.");const r=s[0],o=je(i,t[r]);if(!o)throw new Error(`Placement reference ${t[r]} does not exist.`);const a="inside"===r?{x:o.x,y:o.y,w:o.w,h:o.h}:Ne(o,i),u=t.gap??32,c=t.align??"middle",l=(e,t)=>"start"===c?0:"end"===c?e-t:(e-t)/2;let p=a.x,y=a.y;if("rightOf"===r&&(p=a.x+a.w+u,y=a.y+l(a.h,e.h)),"leftOf"===r&&(p=a.x-e.w-u,y=a.y+l(a.h,e.h)),"above"===r&&(p=a.x+l(a.w,e.w),y=a.y-e.h-u),"below"===r&&(p=a.x+l(a.w,e.w),y=a.y+a.h+u),"inside"===r){if("group"!==o.kind)throw new Error("Inside placement requires a group.");const t=o.children??[];let n=!1;for(let s=0;s<100&&!n;s++)for(let r=0;r<100&&!n;r++){const o={x:a.x+u+r*(e.w+u),y:a.y+u+s*(e.h+u),w:e.w,h:e.h};Pe(a,o)&&!t.some(e=>_e(o,Ne(e,i)))&&(p=o.x,y=o.y,n=!0)}if(!n)throw new Error(`No free slot inside ${o.id}; enlarge the group or use a smaller item.`)}if("rightOf"===r||"leftOf"===r||"above"===r||"below"===r){const t=function(e,t,n,i,s,r){const o={...e};for(let a=0;a<64;a++){const e=s.find(e=>{return!(t=e).hidden&&"connector"!==t.kind&&"line"!==t.kind&&"path"!==t.kind&&_e(o,Ne(e,r));var t});if(!e)return o;const a=Ne(e,r);"x"===t?o.x=n>0?a.x+a.w+i:a.x-o.w-i:o.y=n>0?a.y+a.h+i:a.y-o.h-i}return o}({x:p,y:y,w:e.w,h:e.h},"above"===r||"below"===r?"y":"x","leftOf"===r||"above"===r?-1:1,u,n,i);p=t.x,y=t.y}if("near"===r){let t=!1;for(let s=1;s<=100&&!t;s++){const r=[{x:a.x+a.w+u*s,y:a.y},{x:a.x,y:a.y+a.h+u*s},{x:a.x-e.w-u*s,y:a.y},{x:a.x,y:a.y-e.h-u*s}];for(const s of r)if(!n.some(t=>_e({...s,w:e.w,h:e.h},Ne(t,i)))){p=s.x,y=s.y,t=!0;break}}if(!t)throw new Error("No free space found near the requested item.")}return{...e,x:p,y:y}}function Re(e,n={}){const s=Le(e),r=new Map(s.map(e=>[e.id,e])),o=n.page?Ee(e.pages.find(e=>e.id===n.page)?.items??[]):s,a=n.inside?new Set(Ee(r.get(n.inside)?.children??[]).map(e=>e.id)):void 0;return o.filter(e=>{if(n.kind&&!(Array.isArray(n.kind)?n.kind:[n.kind]).map(i).includes(e.kind))return!1;if(n.text){const t=[e.text?.value,e.name].filter(Boolean).join(" ");if("string"==typeof n.text?!t.toLowerCase().includes(n.text.toLowerCase()):!new RegExp(n.text.source,n.text.flags.replace(/[gy]/g,"")).test(t))return!1}if(void 0!==n.hidden&&!!e.hidden!==n.hidden||void 0!==n.locked&&!!e.locked!==n.locked)return!1;if(n.within&&!Pe(n.within,Ne(e,r)))return!1;if(a&&!a.has(e.id))return!1;if(n.data&&Object.entries(n.data).some(([t,n])=>JSON.stringify(e.data?.[t])!==JSON.stringify(n)))return!1;if(n.connectedTo){const t=e.from&&"item"in e.from&&e.from.item===n.connectedTo,i=e.to&&"item"in e.to&&e.to.item===n.connectedTo,s=n.direction??"both";if(!("out"===s?t:"in"===s?i:t||i))return!1}return!0}).map(t)}var He=e=>Math.round(10*e)/10,Ue=e=>e.name??e.text?.value,Ge=e=>JSON.stringify(e.length>160?`${e.slice(0,157)}…`:e);function Ke(e,t={},n){const i=e.pages.filter((e,n)=>t.page?e.id===t.page:"page"!==t.scope||0===n),s=t.detail??"normal",r=t.maxItems??100,o=t.since,a=new Set(t.selection??[]),u=t.ids?new Set(t.ids):void 0,c=[];let l=0;const p=/* @__PURE__ */new Set,y=Le(e),f=new Map(y.map(e=>[e.id,e])),d=void 0!==o&&n?e=>{const t=n.written.get(e);return!!t&&t.revision>o}:()=>!0,h=e=>!("selection"===t.scope&&!a.has(e.id))&&(!(u&&!u.has(e.id))&&d(e.id)),m=e=>"selection"!==t.scope&&!u&&((!t.page||e.page===t.page)&&(void 0!==o&&e.revision>o));let x=!1;for(const g of i){const e=Ee(g.items).filter(h),i=n?[...n.removed.entries()].filter(([,e])=>e.page===g.id&&m(e)).sort(([e],[t])=>e<t?-1:e>t?1:0):[];if(void 0!==o&&!e.length&&!i.length)continue;x=!0;const y=Ee(g.items).filter(e=>!("selection"===t.scope&&!a.has(e.id))&&!(u&&!u.has(e.id)));if(c.push(`Page ${Ge(g.name)} (${g.id}): ${void 0===o?y.length:e.length+i.length} item${1===(void 0===o?y.length:e.length+i.length)?"":"s"}.${a.size&&void 0===o?` Selection: ${[...a].join(", ")}.`:""}`),!e.length&&!i.length){c.push("An empty board, ready for your first idea.");continue}const d=e.filter(e=>"connector"!==e.kind).sort((e,t)=>e.y-t.y||e.x-t.x||(e.id<t.id?-1:e.id>t.id?1:0));for(const t of d){if(l>=r)continue;l++,p.add(t.id);const e=Ne(t,f),i=Ue(t);let o=`${t.id} ${t.kind}${i?` ${Ge(i)}`:""}`;"brief"!==s&&(o+=` at (${He(e.x)},${He(e.y)}) ${He(e.w)}×${He(e.h)}${t.style?.fill?`, fill ${t.style.fill}`:""}${t.hidden?", hidden":""}${t.locked?", locked":""}`),t.children?.length&&(o+=` contains ${t.children.map(e=>e.id).join(", ")}`),"full"===s&&t.data&&(o+=` [${Object.entries(t.data).sort(([e],[t])=>e<t?-1:e>t?1:0).map(([e,t])=>`data.${e}=${JSON.stringify(t)}`).join(", ")}]`),"brief"!==s&&n?.written.get(t.id)?.origin.startsWith("agent:")&&(o+=", by agent"),c.push(o)}const v=e.filter(e=>"connector"===e.kind);if(v.length){c.push("Connections:");for(const e of v){if(l>=r)continue;l++,p.add(e.id);const t=e=>e?"item"in e?e.item:`(${He(e.x)},${He(e.y)})`:"unset";let i=` ${e.id}: ${t(e.from)} → ${t(e.to)}${Ue(e)?` ${Ge(Ue(e))}`:""} (${e.route??"straight"})`;"brief"!==s&&n?.written.get(e.id)?.origin.startsWith("agent:")&&(i+=", by agent"),c.push(i)}}for(const[t,n]of i)l>=r||(l++,p.add(t),c.push("brief"===s?`removed ${t}`:`removed ${t} ${n.kind}`));if(t.relations&&"brief"!==s){const e=[];for(let t=0;t<Math.min(d.length,20);t++){const n=d[t],i=d[t+1];if(!i)continue;const s=i.x-n.x-n.w;s>=0&&Math.abs(n.y-i.y)<5&&e.push(`${n.id} is left of ${i.id}, tops aligned, gap ${He(s)}`)}e.length&&c.push(`Layout: ${e.join("; ")}.`)}if(t.freeSpace){const t=void 0===o?Ee(g.items).filter(h):e,n=t.length?t:e;if(n.length){const e=qe(n,f);c.push(`Free space: right of content from x=${He(e.x+e.w+40)}; below content from y=${He(e.y+e.h+40)}.`)}}const b=e.filter(e=>!p.has(e.id));if(b.length){const e=/* @__PURE__ */new Map;for(const t of b){const n=`near (${600*Math.floor(t.x/600)},${600*Math.floor(t.y/600)})`;e.set(n,(e.get(n)??0)+1)}c.push(`${b.length} more items: ${[...e].slice(0,8).map(([e,t])=>`${t} ${e}`).join("; ")}${e.size>8?`; ${e.size-8} more clusters`:""}. Use query() or increase maxItems for detail.`)}}return void 0===o||x?c.join("\n"):`No changes since revision ${o}.`}export{te as A,k as B,ae as C,pe as D,ce as E,Y as F,E as G,h as H,se as I,J,O as K,C as L,D as M,ne as N,ye as O,ie as P,oe as R,Me as S,ue as T,x as U,f as V,j as W,N as X,L as Y,Ee as _,De as a,je as b,Je as c,qe as d,Ae as f,Ie as g,Pe as h,Le as i,V as j,re as k,ze as l,Oe as m,Re as n,Be as o,Se as p,A as q,Fe as r,We as s,Ke as t,Ce as u,_e as v,le as w,me as x,Ne as y,w as z};
3
+ //# sourceMappingURL=describe-o3vER0cL.js.map