@threadlabs/looma 0.2.0 → 0.2.1

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 (76) hide show
  1. package/dist/{chunk-JXSHRMYW.js → chunk-WW7Y67EW.js} +32 -32
  2. package/dist/{chunk-M7FPK6GN.js → chunk-Z4W5W53T.js} +19 -1
  3. package/dist/cjs/{positioning-D5q9DM-0.js → positioning-BiPpyC-_.js} +26 -0
  4. package/dist/cjs/ui-affordance-scope.cjs.entry.js +1 -1
  5. package/dist/cjs/ui-chip_2.cjs.entry.js +1 -1
  6. package/dist/cjs/ui-combobox.cjs.entry.js +1 -1
  7. package/dist/cjs/ui-context-menu.cjs.entry.js +1 -1
  8. package/dist/cjs/ui-menu.cjs.entry.js +1 -1
  9. package/dist/cjs/ui-popover.cjs.entry.js +1 -1
  10. package/dist/cjs/ui-toast-region.cjs.entry.js +1 -1
  11. package/dist/collection/overlay/positioning.js +26 -0
  12. package/dist/components/p-BOC_l2hE.js +1 -0
  13. package/dist/components/{p-DWN2m6ta.js → p-Btk_75st.js} +1 -1
  14. package/dist/components/{p-DYiNETk6.js → p-biKnomFl.js} +1 -1
  15. package/dist/components/ui-affordance-scope.js +1 -1
  16. package/dist/components/ui-combobox.js +1 -1
  17. package/dist/components/ui-context-menu.js +1 -1
  18. package/dist/components/ui-menu.js +1 -1
  19. package/dist/components/ui-popover.js +1 -1
  20. package/dist/components/ui-toast-region.js +1 -1
  21. package/dist/components/ui-tooltip.js +1 -1
  22. package/dist/esm/{positioning-Drmwg-C1.js → positioning-Ig1jYhE1.js} +26 -0
  23. package/dist/esm/ui-affordance-scope.entry.js +1 -1
  24. package/dist/esm/ui-chip_2.entry.js +1 -1
  25. package/dist/esm/ui-combobox.entry.js +1 -1
  26. package/dist/esm/ui-context-menu.entry.js +1 -1
  27. package/dist/esm/ui-menu.entry.js +1 -1
  28. package/dist/esm/ui-popover.entry.js +1 -1
  29. package/dist/esm/ui-toast-region.entry.js +1 -1
  30. package/dist/index.cjs +45 -10
  31. package/dist/index.js +18 -1
  32. package/dist/looma/looma.esm.js +1 -1
  33. package/dist/looma/{p-32c85198.entry.js → p-08c9e253.entry.js} +1 -1
  34. package/dist/looma/{p-37ec2b4b.entry.js → p-0fa7062f.entry.js} +1 -1
  35. package/dist/looma/{p-d46317e0.entry.js → p-172d67ff.entry.js} +1 -1
  36. package/dist/looma/{p-5cbbf7a0.entry.js → p-3fba3edd.entry.js} +1 -1
  37. package/dist/looma/p-4354f48f.entry.js +1 -0
  38. package/dist/looma/{p-55e06e2e.entry.js → p-7ebbe74e.entry.js} +1 -1
  39. package/dist/looma/p-Ig1jYhE1.js +1 -0
  40. package/dist/looma/{p-b6fb6ba3.entry.js → p-ec1c02e5.entry.js} +1 -1
  41. package/dist/{ui-affordance-scope.entry-VR7FLAWG.js → ui-affordance-scope.entry-FENYADN3.js} +2 -2
  42. package/dist/{ui-avatar-group.entry-L3UKOY3U.js → ui-avatar-group.entry-K7D6QKDP.js} +1 -1
  43. package/dist/{ui-avatar.entry-VM5OHEFQ.js → ui-avatar.entry-WCYFUQZT.js} +1 -1
  44. package/dist/{ui-badge.entry-ZTM4OPUD.js → ui-badge.entry-VZC4LONR.js} +1 -1
  45. package/dist/{ui-button.entry-CIPUSV5B.js → ui-button.entry-7E2KMPRF.js} +1 -1
  46. package/dist/{ui-callout.entry-OBFCI2O7.js → ui-callout.entry-7WXQ47S6.js} +1 -1
  47. package/dist/{ui-checkbox.entry-XT6ET56H.js → ui-checkbox.entry-GTSEB7ZS.js} +1 -1
  48. package/dist/{ui-chip_2.entry-32SHCLV6.js → ui-chip_2.entry-PG24H67I.js} +2 -2
  49. package/dist/{ui-combobox.entry-ONBBPQ2C.js → ui-combobox.entry-NTCOCZOH.js} +2 -2
  50. package/dist/{ui-context-menu.entry-RXNUOK24.js → ui-context-menu.entry-7GSDWHTP.js} +2 -2
  51. package/dist/{ui-dialog.entry-IJXNUARC.js → ui-dialog.entry-F53O6FBQ.js} +1 -1
  52. package/dist/{ui-disclosure.entry-5QS7UDRH.js → ui-disclosure.entry-YWJA42GQ.js} +1 -1
  53. package/dist/{ui-editable.entry-D7LOQN2H.js → ui-editable.entry-3QPCWDPM.js} +1 -1
  54. package/dist/{ui-floating-action-button.entry-XQZCTZQT.js → ui-floating-action-button.entry-L4UC6RFM.js} +1 -1
  55. package/dist/{ui-form-field.entry-A654LJZE.js → ui-form-field.entry-2VCITLQA.js} +1 -1
  56. package/dist/{ui-icon-button.entry-MJ7F7ZIH.js → ui-icon-button.entry-MRRA6NVP.js} +1 -1
  57. package/dist/{ui-input.entry-B2XM7JQU.js → ui-input.entry-7LYLUJNT.js} +1 -1
  58. package/dist/{ui-menu-item.entry-JULYSFVW.js → ui-menu-item.entry-YHSIKO5W.js} +1 -1
  59. package/dist/{ui-menu.entry-ORRWW7HD.js → ui-menu.entry-ZQBF7B4T.js} +2 -2
  60. package/dist/{ui-popover.entry-W67V4UPA.js → ui-popover.entry-2HG5ZWQX.js} +2 -2
  61. package/dist/{ui-radio-group.entry-KCFOR27M.js → ui-radio-group.entry-A6LI3KHW.js} +1 -1
  62. package/dist/{ui-radio.entry-I2P4V5E3.js → ui-radio.entry-WBCZZG5D.js} +1 -1
  63. package/dist/{ui-search-result-row.entry-GHODLSLR.js → ui-search-result-row.entry-P25POOYP.js} +1 -1
  64. package/dist/{ui-search-shell.entry-PDB5UN4B.js → ui-search-shell.entry-R6IVRPSW.js} +1 -1
  65. package/dist/{ui-select.entry-D3CZHCKB.js → ui-select.entry-CAAGCELJ.js} +1 -1
  66. package/dist/{ui-switch.entry-WUDRL4H5.js → ui-switch.entry-SKU445KH.js} +1 -1
  67. package/dist/{ui-tabs.entry-MW64GKIJ.js → ui-tabs.entry-7BQPZEH3.js} +1 -1
  68. package/dist/{ui-textarea.entry-VHRBYY6G.js → ui-textarea.entry-OFC4YUU7.js} +1 -1
  69. package/dist/{ui-toast-region.entry-ET75RWYP.js → ui-toast-region.entry-7VNTFVDO.js} +2 -2
  70. package/dist/{ui-top-bar.entry-QIYA3LD3.js → ui-top-bar.entry-2N3EKMVF.js} +1 -1
  71. package/dist/{ui-tree-item.entry-BDB7VEUS.js → ui-tree-item.entry-SLHAE42A.js} +1 -1
  72. package/dist/{ui-tree.entry-GSC7BPRN.js → ui-tree.entry-LF45JUC4.js} +1 -1
  73. package/package.json +1 -1
  74. package/dist/components/p-Drw41pSY.js +0 -1
  75. package/dist/looma/p-56dac38a.entry.js +0 -1
  76. package/dist/looma/p-Drmwg-C1.js +0 -1
@@ -10,7 +10,7 @@ import {
10
10
  getElement,
11
11
  h,
12
12
  registerInstance
13
- } from "./chunk-JXSHRMYW.js";
13
+ } from "./chunk-WW7Y67EW.js";
14
14
 
15
15
  // dist/esm/ui-tree-item.entry.js
16
16
  var uiTreeItemCss = () => `:host{--ui-tree-indent:16px;--ui-tree-row-min-height:32px;--ui-tree-drop-color:var(--ui-accent-solid);position:relative;display:block;min-inline-size:0;margin-inline-start:calc(var(--ui-tree-item-depth, 0) * var(--ui-tree-indent))}.row{position:relative;display:grid;grid-template-columns:20px auto minmax(0, 1fr) auto;align-items:center;min-block-size:var(--ui-tree-row-min-height);min-inline-size:0;font-size:var(--ui-tree-font-size, var(--ui-font-size-ui, 0.9375rem));border-radius:var(--ui-radius-md);color:var(--ui-text-secondary);transition:background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease), opacity var(--ui-motion-fast) var(--ui-motion-ease), box-shadow var(--ui-motion-fast) var(--ui-motion-ease), min-block-size var(--ui-motion-base) var(--ui-motion-ease)}.row:hover,:host([data-selected]) .row,.row:focus-within{color:var(--ui-text-primary);background:var(--ui-surface-muted)}:host([data-disabled]) .row{opacity:0.55}:host([data-dragging]) .row{opacity:0.42}:host(:focus){outline:none}:host(:focus-visible) .row{box-shadow:0 0 0 2px var(--ui-focus-ring)}:host([data-drop-position='inside']) .row{background:var(--ui-accent-subtle);box-shadow:inset 0 0 0 1px var(--ui-tree-drop-color)}.disclosure,.disclosure-spacer{grid-column:1;grid-row:1;inline-size:20px;block-size:28px}.disclosure{display:grid;place-items:center;padding:0;color:var(--ui-text-muted);background:transparent;border:0;border-radius:var(--ui-radius-sm);cursor:pointer}.disclosure:hover{color:var(--ui-text-primary);background:var(--ui-surface-elevated)}.disclosure-icon{display:block;inline-size:14px;block-size:14px;transform:rotate(-90deg);transition:transform var(--ui-motion-fast) var(--ui-motion-ease)}.disclosure-icon--expanded{transform:rotate(0deg)}.disclosure-icon :is(svg),.drag-handle :is(svg){display:block;inline-size:100%;block-size:100%}.leading{display:none}.leading:has(*){display:inline-grid;place-items:center;grid-column:2;grid-row:1;inline-size:16px;block-size:16px;margin-inline-start:var(--ui-space-1)}.label{grid-column:3;grid-row:1;min-inline-size:0;padding:var(--ui-space-1) var(--ui-space-2)}.actions{grid-column:4;grid-row:1;display:inline-flex;align-items:center;min-inline-size:0}.drag-handle{position:absolute;z-index:2;inset-block-start:50%;inset-inline-start:-22px;inline-size:20px;block-size:32px;display:grid;place-items:center;padding:7px 3px;color:var(--ui-text-muted);background:var(--ui-surface-elevated);border:1px solid transparent;border-radius:var(--ui-radius-sm);cursor:grab;opacity:0;pointer-events:none;transform:translateY(-50%);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease)}.row:hover .drag-handle,.drag-handle:focus-visible,:host([data-dragging]) .drag-handle{opacity:1;pointer-events:auto}.drag-handle:active{cursor:grabbing}.drop-indicator{position:absolute;z-index:3;inset-inline:1px;display:none;block-size:2px;border-radius:999px;background:var(--ui-tree-drop-color);pointer-events:none}.drop-indicator::before,.drop-indicator::after{content:'';position:absolute;inset-block-start:50%;inline-size:7px;block-size:7px;border:2px solid var(--ui-tree-drop-color);border-radius:999px;background:var(--ui-surface-elevated);transform:translateY(-50%)}.drop-indicator::before{inset-inline-start:-1px}.drop-indicator::after{inset-inline-end:-1px}:host([data-drop-position='before']) .row-drop-indicator{display:block;inset-block-start:-1px}:host([data-drop-position='after']) .subtree-drop-indicator{display:block;inset-block-end:-1px}.children[hidden]{display:none}:host-context(html[data-ui-input-modality='touch']){--ui-tree-row-min-height:44px}:host-context(html[data-ui-input-modality='touch']) .drag-handle{display:none}@media (prefers-reduced-motion: reduce){.row,.disclosure-icon,.drag-handle{transition:none}}`;
@@ -6,7 +6,7 @@ import {
6
6
  getElement,
7
7
  h,
8
8
  registerInstance
9
- } from "./chunk-JXSHRMYW.js";
9
+ } from "./chunk-WW7Y67EW.js";
10
10
 
11
11
  // dist/esm/ui-tree.entry.js
12
12
  function classifyDropPosition(rect, clientY, acceptsChildren) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "Looma web components, responsive layout primitives, a complete editor, and supported Vue adapters.",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- const t=16;let n=0;const o=new WeakMap;function a(t){try{return t.matches(":popover-open")}catch{return!t.hidden}}function i(t){if(t.setAttribute("popover","manual"),t.hidden=!1,"function"==typeof t.showPopover&&!a(t))try{t.showPopover()}catch{}}function e(t){if("function"==typeof t.hidePopover&&a(t))try{t.hidePopover()}catch{}t.hidden=!0}function r(t){return t.setAttribute("popover","manual"),t.dataset.uiPositioning="viewport",{show(){i(t)},hide(){e(t)},destroy(){e(t)}}}function l(t,n,o,a,i,e=t.getBoundingClientRect()){const r=c(t.ownerDocument.defaultView??window),l=o.startsWith("top"),u=o.endsWith("end"),h=r.bottom-n.bottom-i,p=n.top-r.top-i,f=(l?!(p<e.height+a&&h>p):h<e.height+a&&p>h)?n.top-e.height-a:n.bottom+a,d=u?n.right-e.width:n.left,m=s({left:d,top:f,width:e.width,height:e.height},r,i);t.style.left=`${Math.round(d+m.x)}px`,t.style.top=`${Math.round(f+m.y)}px`,t.style.right="auto",t.style.bottom="auto"}function u(t,a={}){const r=t.ownerDocument.defaultView??window,u=a.placement??"bottom-start",h=Math.max(0,a.gap??4),p=Math.max(0,a.viewportGap??8),f=function(t){const n=t.CSS;return"function"==typeof n?.supports&&n.supports("anchor-name: --ui-anchor-test")&&n.supports("position-anchor: --ui-anchor-test")&&n.supports("top: anchor(bottom)")}(r),d="--ui-anchor-"+ ++n;let m=a.anchor??null,g=null,y=!1,v=null,w=null;t.setAttribute("popover","manual"),t.dataset.uiPositioning=f?"anchor":"fallback",t.style.position="fixed",t.style.margin="0";const b=n=>{m&&function(t,n){const a=o.get(t);if(a)if(a.names.delete(n),a.names.size){const n=[a.original,...a.names].filter(Boolean);t.style.setProperty("anchor-name",n.join(", "))}else a.original?t.style.setProperty("anchor-name",a.original):t.style.removeProperty("anchor-name"),o.delete(t)}(m,d),m=n,m?(function(t,n){const a=o.get(t)??{original:t.style.getPropertyValue("anchor-name"),names:new Set};a.names.add(n),o.set(t,a);const i=[a.original,...a.names].filter(Boolean);t.style.setProperty("anchor-name",i.join(", "))}(m,d),t.style.setProperty("position-anchor",d)):t.style.removeProperty("position-anchor")},M=()=>{if(v=null,!y)return;if(g)return void l(t,{left:g.x,right:g.x,top:g.y,bottom:g.y},"bottom-start",h,p);if(!m)return;let n;if(f){(()=>{const n=u.startsWith("bottom"),o=u.endsWith("end");t.style.top=n?`calc(anchor(bottom) + ${h}px)`:"auto",t.style.bottom=n?"auto":`calc(anchor(top) + ${h}px)`,t.style.left=o?"auto":"anchor(left)",t.style.right=o?"anchor(right)":"auto",t.style.setProperty("position-try-fallbacks","flip-block, flip-inline")})();const o=c(r);n=t.getBoundingClientRect();const a=s(n,o,p);if(0===a.x&&0===a.y)return}l(t,m.getBoundingClientRect(),u,h,p,n)},x=()=>{y&&null===v&&(v=r.requestAnimationFrame(M))},A=()=>{if(!y||null===g&&null===m)return w?.abort(),void(w=null);if(w)return;w=new AbortController;const t=w.signal;r.addEventListener("resize",x,{passive:!0,signal:t}),r.addEventListener("scroll",x,{passive:!0,capture:!0,signal:t}),r.visualViewport?.addEventListener("resize",x,{passive:!0,signal:t}),r.visualViewport?.addEventListener("scroll",x,{passive:!0,signal:t})};return b(m),{setAnchor(t){g=null,b(t),A(),x()},show(){g=null,y=!0,A(),i(t),M()},showAtPoint(n){g=n,y=!0,A(),i(t),M()},hide(){y=!1,g=null,A(),null!==v&&r.cancelAnimationFrame(v),v=null,e(t)},refresh:x,destroy(){y=!1,w?.abort(),w=null,null!==v&&r.cancelAnimationFrame(v),v=null,e(t),b(null)}}}function c(t=window){const n=t.visualViewport,o=n?.offsetLeft??0,a=n?.offsetTop??0,i=n?.width??t.innerWidth,e=n?.height??t.innerHeight;return{left:o,top:a,right:o+i,bottom:a+e,width:i,height:e}}function s(t,n=c(),o=0){const a=Math.max(0,n.width-2*o),i=Math.max(0,n.height-2*o),e=t.width>a?n.left+o:Math.min(Math.max(t.left,n.left+o),n.right-o-t.width),r=t.height>i?n.top+o:Math.min(Math.max(t.top,n.top+o),n.bottom-o-t.height);return{x:e-t.left,y:r-t.top}}function h(t,n){const o=Math.max(n.left-t.x,0,t.x-n.right),a=Math.max(n.top-t.y,0,t.y-n.bottom);return Math.hypot(o,a)}function p(t,n={}){const o=t.ownerDocument.defaultView??window,a=n.pointerTarget??t,i=n.anchorSelector??"[data-ui-affordance]",e=n.nearRadius??16,r=Number.isFinite(e)?Math.max(0,e):16,l=new AbortController;let u=[],c=null,s=null,p=!1;const f=()=>{for(const{element:t}of u)t.hasAttribute("data-ui-proximity")&&t.removeAttribute("data-ui-proximity");t.hasAttribute("data-ui-interaction")&&t.removeAttribute("data-ui-interaction")},d=()=>{u=Array.from(t.querySelectorAll(i)).filter((t=>!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled"))).map((t=>({element:t,rect:t.getBoundingClientRect()}))),p=!1},m=()=>{if(c=null,p&&d(),!s)return void f();let n=!1;for(const t of u){const o=h(s,t.rect)<=r;o&&"near"!==t.element.getAttribute("data-ui-proximity")?t.element.setAttribute("data-ui-proximity","near"):!o&&t.element.hasAttribute("data-ui-proximity")&&t.element.removeAttribute("data-ui-proximity"),n||=o}n&&"engaged"!==t.getAttribute("data-ui-interaction")?t.setAttribute("data-ui-interaction","engaged"):!n&&t.hasAttribute("data-ui-interaction")&&t.removeAttribute("data-ui-interaction")},g=()=>{null===c&&(c=o.requestAnimationFrame(m))},y=()=>{p=!0,g()};return a.addEventListener("pointermove",(t=>{s="touch"===t.pointerType?null:{x:t.clientX,y:t.clientY},g()}),{passive:!0,signal:l.signal}),o.addEventListener("resize",y,{passive:!0,signal:l.signal}),o.addEventListener("scroll",y,{passive:!0,capture:!0,signal:l.signal}),o.visualViewport?.addEventListener("resize",y,{passive:!0,signal:l.signal}),o.visualViewport?.addEventListener("scroll",y,{passive:!0,signal:l.signal}),d(),{refresh:y,destroy(){l.abort(),null!==c&&o.cancelAnimationFrame(c),c=null,s=null,f(),u=[]}}}export{t as D,p as a,r as b,u as c}
@@ -1 +0,0 @@
1
- import{r as t,g as s,h as i,H as a}from"./p-8BGiMGQ0.js";import{d as r,e}from"./p-JwSoedEO.js";import{b as o}from"./p-Drmwg-C1.js";const n=class{constructor(s){t(this,s)}get host(){return s(this)}open=!0;internalOpen=!1;surface=null;contentObserver=null;pendingDismiss=null;syncFromProp(){this.syncContents()}syncSurface(){this.internalOpen?this.surface?.show():this.surface?.hide()}componentDidLoad(){this.surface=o(this.host),this.contentObserver=new MutationObserver(this.syncContents),this.contentObserver.observe(this.host,{childList:!0,subtree:!0}),this.syncContents(),this.syncSurface(),this.host.addEventListener("click",this.onClick)}disconnectedCallback(){this.host.removeEventListener("click",this.onClick),this.contentObserver?.disconnect(),this.contentObserver=null,this.surface?.destroy(),this.surface=null}getToasts(){return Array.from(this.host.querySelectorAll("[data-ui-toast]"))}syncContents=()=>{const t=this.open&&this.getToasts().length>0,s=this.internalOpen,i=this.pendingDismiss&&!this.host.contains(this.pendingDismiss.toast)?this.pendingDismiss:null;this.internalOpen=t,s&&!t&&i&&r(this.host,"close",{open:!1,reason:"action",trigger:i.trigger}),!i&&this.open||(this.pendingDismiss=null)};onClick=t=>{const s=t.target.closest?.("[data-ui-toast-dismiss]");if(!s)return;const i=s.closest?.("[data-ui-toast]");if(!i)return;const a=i.id??"",o=e(t);this.pendingDismiss={toast:i,trigger:o},r(this.host,"dismiss",{id:a,reason:"action",trigger:o})};render(){return i(a,{key:"9f9c2e14150c631c0f7cb427c693dcd52c20897d",role:"region","aria-label":"Notifications","aria-live":"polite","data-open":this.internalOpen?"":void 0},i("slot",{key:"9e1d9ebb6b587afab2c4302241cecb03a321cee1"}))}static get watchers(){return{open:[{syncFromProp:0}],internalOpen:[{syncSurface:0}]}}};n.style=":host{position:fixed;top:calc(var(--ui-space-4) + env(safe-area-inset-top));left:50%;transform:translateX(-50%);z-index:9999;display:grid;gap:var(--ui-space-2);inline-size:min(24rem, calc(100vw - (var(--ui-space-4) * 2)));max-inline-size:100%;pointer-events:none}:host([popover]){right:auto;bottom:auto;margin:0}:host>*{pointer-events:auto}::slotted([data-ui-toast]){display:grid;grid-template-columns:1fr auto;gap:var(--ui-space-2);align-items:start;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);padding:var(--ui-space-3) var(--ui-space-4);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-lg);animation:ui-toast-enter 0.25s var(--ui-motion-ease) forwards}@keyframes ui-toast-enter{from{opacity:0;transform:translateY(-0.5rem)}to{opacity:1;transform:translateY(0)}}::slotted([data-ui-toast][aria-hidden='true']){display:none}::slotted([data-ui-toast-dismiss]){border:0;background:transparent;color:var(--ui-text-secondary);cursor:pointer;font:inherit}";export{n as ui_toast_region}
@@ -1 +0,0 @@
1
- const t=16;let n=0;const o=new WeakMap;function a(t){try{return t.matches(":popover-open")}catch{return!t.hidden}}function i(t){if(t.setAttribute("popover","manual"),t.hidden=!1,"function"==typeof t.showPopover&&!a(t))try{t.showPopover()}catch{}}function e(t){if("function"==typeof t.hidePopover&&a(t))try{t.hidePopover()}catch{}t.hidden=!0}function r(t){return t.setAttribute("popover","manual"),t.dataset.uiPositioning="viewport",{show(){i(t)},hide(){e(t)},destroy(){e(t)}}}function l(t,n,o,a,i,e=t.getBoundingClientRect()){const r=c(t.ownerDocument.defaultView??window),l=o.startsWith("top"),u=o.endsWith("end"),h=r.bottom-n.bottom-i,p=n.top-r.top-i,f=(l?!(p<e.height+a&&h>p):h<e.height+a&&p>h)?n.top-e.height-a:n.bottom+a,d=u?n.right-e.width:n.left,m=s({left:d,top:f,width:e.width,height:e.height},r,i);t.style.left=`${Math.round(d+m.x)}px`,t.style.top=`${Math.round(f+m.y)}px`,t.style.right="auto",t.style.bottom="auto"}function u(t,a={}){const r=t.ownerDocument.defaultView??window,u=a.placement??"bottom-start",h=Math.max(0,a.gap??4),p=Math.max(0,a.viewportGap??8),f=function(t){const n=t.CSS;return"function"==typeof n?.supports&&n.supports("anchor-name: --ui-anchor-test")&&n.supports("position-anchor: --ui-anchor-test")&&n.supports("top: anchor(bottom)")}(r),d="--ui-anchor-"+ ++n;let m=a.anchor??null,g=null,y=!1,v=null,w=null;t.setAttribute("popover","manual"),t.dataset.uiPositioning=f?"anchor":"fallback",t.style.position="fixed",t.style.margin="0";const b=n=>{m&&function(t,n){const a=o.get(t);if(a)if(a.names.delete(n),a.names.size){const n=[a.original,...a.names].filter(Boolean);t.style.setProperty("anchor-name",n.join(", "))}else a.original?t.style.setProperty("anchor-name",a.original):t.style.removeProperty("anchor-name"),o.delete(t)}(m,d),m=n,m?(function(t,n){const a=o.get(t)??{original:t.style.getPropertyValue("anchor-name"),names:new Set};a.names.add(n),o.set(t,a);const i=[a.original,...a.names].filter(Boolean);t.style.setProperty("anchor-name",i.join(", "))}(m,d),t.style.setProperty("position-anchor",d)):t.style.removeProperty("position-anchor")},M=()=>{if(v=null,!y)return;if(g)return void l(t,{left:g.x,right:g.x,top:g.y,bottom:g.y},"bottom-start",h,p);if(!m)return;let n;if(f){(()=>{const n=u.startsWith("bottom"),o=u.endsWith("end");t.style.top=n?`calc(anchor(bottom) + ${h}px)`:"auto",t.style.bottom=n?"auto":`calc(anchor(top) + ${h}px)`,t.style.left=o?"auto":"anchor(left)",t.style.right=o?"anchor(right)":"auto",t.style.setProperty("position-try-fallbacks","flip-block, flip-inline")})();const o=c(r);n=t.getBoundingClientRect();const a=s(n,o,p);if(0===a.x&&0===a.y)return}l(t,m.getBoundingClientRect(),u,h,p,n)},x=()=>{y&&null===v&&(v=r.requestAnimationFrame(M))},A=()=>{if(!y||null===g&&null===m)return w?.abort(),void(w=null);if(w)return;w=new AbortController;const t=w.signal;r.addEventListener("resize",x,{passive:!0,signal:t}),r.addEventListener("scroll",x,{passive:!0,capture:!0,signal:t}),r.visualViewport?.addEventListener("resize",x,{passive:!0,signal:t}),r.visualViewport?.addEventListener("scroll",x,{passive:!0,signal:t})};return b(m),{setAnchor(t){g=null,b(t),A(),x()},show(){g=null,y=!0,A(),i(t),M()},showAtPoint(n){g=n,y=!0,A(),i(t),M()},hide(){y=!1,g=null,A(),null!==v&&r.cancelAnimationFrame(v),v=null,e(t)},refresh:x,destroy(){y=!1,w?.abort(),w=null,null!==v&&r.cancelAnimationFrame(v),v=null,e(t),b(null)}}}function c(t=window){const n=t.visualViewport,o=n?.offsetLeft??0,a=n?.offsetTop??0,i=n?.width??t.innerWidth,e=n?.height??t.innerHeight;return{left:o,top:a,right:o+i,bottom:a+e,width:i,height:e}}function s(t,n=c(),o=0){const a=Math.max(0,n.width-2*o),i=Math.max(0,n.height-2*o),e=t.width>a?n.left+o:Math.min(Math.max(t.left,n.left+o),n.right-o-t.width),r=t.height>i?n.top+o:Math.min(Math.max(t.top,n.top+o),n.bottom-o-t.height);return{x:e-t.left,y:r-t.top}}function h(t,n){const o=Math.max(n.left-t.x,0,t.x-n.right),a=Math.max(n.top-t.y,0,t.y-n.bottom);return Math.hypot(o,a)}function p(t,n={}){const o=t.ownerDocument.defaultView??window,a=n.pointerTarget??t,i=n.anchorSelector??"[data-ui-affordance]",e=n.nearRadius??16,r=Number.isFinite(e)?Math.max(0,e):16,l=new AbortController;let u=[],c=null,s=null,p=!1;const f=()=>{for(const{element:t}of u)t.hasAttribute("data-ui-proximity")&&t.removeAttribute("data-ui-proximity");t.hasAttribute("data-ui-interaction")&&t.removeAttribute("data-ui-interaction")},d=()=>{u=Array.from(t.querySelectorAll(i)).filter((t=>!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled"))).map((t=>({element:t,rect:t.getBoundingClientRect()}))),p=!1},m=()=>{if(c=null,p&&d(),!s)return void f();let n=!1;for(const t of u){const o=h(s,t.rect)<=r;o&&"near"!==t.element.getAttribute("data-ui-proximity")?t.element.setAttribute("data-ui-proximity","near"):!o&&t.element.hasAttribute("data-ui-proximity")&&t.element.removeAttribute("data-ui-proximity"),n||=o}n&&"engaged"!==t.getAttribute("data-ui-interaction")?t.setAttribute("data-ui-interaction","engaged"):!n&&t.hasAttribute("data-ui-interaction")&&t.removeAttribute("data-ui-interaction")},g=()=>{null===c&&(c=o.requestAnimationFrame(m))},y=()=>{p=!0,g()};return a.addEventListener("pointermove",(t=>{s="touch"===t.pointerType?null:{x:t.clientX,y:t.clientY},g()}),{passive:!0,signal:l.signal}),o.addEventListener("resize",y,{passive:!0,signal:l.signal}),o.addEventListener("scroll",y,{passive:!0,capture:!0,signal:l.signal}),o.visualViewport?.addEventListener("resize",y,{passive:!0,signal:l.signal}),o.visualViewport?.addEventListener("scroll",y,{passive:!0,signal:l.signal}),d(),{refresh:y,destroy(){l.abort(),null!==c&&o.cancelAnimationFrame(c),c=null,s=null,f(),u=[]}}}export{t as D,u as a,r as b,p as c}