@magicx-eng/ai-autocomplete-react 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as Ft,useLayoutEffect as Ot,useRef as ce}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.AIAutocomplete-module_container_KKjFU {
1
+ import{forwardRef as zt,useCallback as Te,useEffect as ot,useImperativeHandle as Ft,useLayoutEffect as Ot,useRef as pe}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.AIAutocomplete-module_container_KKjFU {
2
2
  position: relative;
3
3
  /* Inherits the host page's font by default. Consumers can pin a specific
4
4
  font on the library via \`--aia-font-family: 'Custom Font'\` without
@@ -167,75 +167,99 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
167
167
  box-sizing: border-box;
168
168
  }
169
169
 
170
- /* Light mode defaults (base) */
170
+ /*
171
+ * Primitive color ramp \u2014 single source of truth, mirroring the Figma
172
+ * "Primitives" collection. INTERNAL: theme via the public --aia-* vars below,
173
+ * not these. Mode-independent (raw values; the same in light and dark).
174
+ */
175
+ :where(.magicx-aia) {
176
+ --aia-primitive-neutral-0: #000000;
177
+ --aia-primitive-neutral-250: #323232;
178
+ --aia-primitive-neutral-300: #333539;
179
+ --aia-primitive-neutral-400: #4a4a4a;
180
+ --aia-primitive-neutral-500: #505050;
181
+ --aia-primitive-neutral-700: #b0b0b0;
182
+ --aia-primitive-neutral-750: #bdbdbd;
183
+ --aia-primitive-neutral-900: #e7e7e7;
184
+ --aia-primitive-neutral-1000: #ffffff;
185
+ --aia-primitive-blue-50: #eef2ff;
186
+ --aia-primitive-neutral-750-a50: rgba(189, 189, 189, 0.51);
187
+ --aia-primitive-neutral-700-a40: rgba(176, 176, 176, 0.4);
188
+ }
189
+
190
+ /* Light mode defaults (base) \u2014 public --aia-* vars resolve to primitives */
171
191
  :where(.magicx-aia),
172
192
  :where(.magicx-aia[data-mode="light"]) {
173
- --aia-surface: #ffffff;
174
- --aia-border: #b0b0b0;
175
- --aia-dropdown-border: #e5e7eb;
193
+ --aia-surface: var(--aia-primitive-neutral-1000);
194
+ --aia-border: var(--aia-primitive-neutral-700);
195
+ --aia-dropdown-border: var(
196
+ --aia-primitive-neutral-900
197
+ ); /* was #e5e7eb \u2014 snapped to palette (\u03942) */
176
198
  --aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
177
- --aia-pill-bg: #bdbdbd;
178
- --aia-pill-color: #333539;
199
+ --aia-pill-bg: var(--aia-primitive-neutral-750); /* solid; per-pill opacity via getPillOpacity */
200
+ --aia-pill-color: var(--aia-primitive-neutral-300);
179
201
  --aia-pill-font-size: 14px;
180
202
 
181
- --aia-option-bg: #eef2ff;
182
- --aia-option-color: #505050;
183
- --aia-option-color-selected: #000000;
203
+ --aia-option-bg: var(--aia-primitive-blue-50);
204
+ --aia-option-color: var(--aia-primitive-neutral-500);
205
+ --aia-option-color-selected: var(--aia-primitive-neutral-0);
184
206
  --aia-option-font-size: 14px;
185
207
 
186
- --aia-written-text-color: #000000;
208
+ --aia-written-text-color: var(--aia-primitive-neutral-0);
187
209
  --aia-written-text-font-size: 14px;
188
210
  --aia-caret-color: var(--aia-written-text-color, #000000);
189
211
 
190
- --aia-submit-bg: #000000;
191
- --aia-submit-color: #ffffff;
212
+ --aia-submit-bg: var(--aia-primitive-neutral-0);
213
+ --aia-submit-color: var(--aia-primitive-neutral-1000);
192
214
 
193
- --aia-color-text-muted: #6b7280;
215
+ --aia-color-text-muted: #6b7280; /* off shared palette (slate) */
194
216
 
195
- --aia-skeleton-bg: rgba(189, 189, 189, 0.51);
217
+ --aia-skeleton-bg: var(--aia-primitive-neutral-750-a50);
196
218
 
197
- --aia-streak-rgb: 99, 102, 241;
219
+ --aia-streak-rgb: 99, 102, 241; /* off shared palette (indigo effect) */
198
220
  --aia-streak-glass-bg: rgba(99, 102, 241, 0.1);
199
221
 
200
- --aia-footer-divider: rgba(176, 176, 176, 0.4);
201
- --aia-footer-hint-color: #505050;
202
- --aia-footer-brand-color: #b0b0b0;
203
- --aia-footer-badge-border: rgba(189, 189, 189, 0.51);
222
+ --aia-footer-divider: var(--aia-primitive-neutral-700-a40);
223
+ --aia-footer-hint-color: var(--aia-primitive-neutral-500);
224
+ --aia-footer-brand-color: var(--aia-primitive-neutral-700);
225
+ --aia-footer-badge-border: var(--aia-primitive-neutral-750-a50);
204
226
  }
205
227
 
206
228
  /* Dark mode defaults */
207
229
  :where(.magicx-aia[data-mode="dark"]) {
208
- --aia-surface: #000000;
209
- --aia-border: #505050;
210
- --aia-dropdown-border: #484848;
230
+ --aia-surface: var(--aia-primitive-neutral-0);
231
+ --aia-border: var(--aia-primitive-neutral-500);
232
+ --aia-dropdown-border: var(
233
+ --aia-primitive-neutral-400
234
+ ); /* was #484848 \u2014 snapped to palette (\u03942) */
211
235
  --aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
212
- --aia-pill-bg: #bdbdbd;
213
- --aia-pill-color: #b0b0b0;
236
+ --aia-pill-bg: var(--aia-primitive-neutral-750);
237
+ --aia-pill-color: var(--aia-primitive-neutral-700);
214
238
  --aia-pill-font-size: 14px;
215
239
 
216
- --aia-option-bg: #323232;
217
- --aia-option-color: #b0b0b0;
218
- --aia-option-color-selected: #ffffff;
240
+ --aia-option-bg: var(--aia-primitive-neutral-250);
241
+ --aia-option-color: var(--aia-primitive-neutral-700);
242
+ --aia-option-color-selected: var(--aia-primitive-neutral-1000);
219
243
  --aia-option-font-size: 14px;
220
244
 
221
- --aia-written-text-color: #ffffff;
245
+ --aia-written-text-color: var(--aia-primitive-neutral-1000);
222
246
  --aia-written-text-font-size: 14px;
223
247
  --aia-caret-color: var(--aia-written-text-color, #ffffff);
224
248
 
225
- --aia-submit-bg: #ffffff;
226
- --aia-submit-color: #000000;
249
+ --aia-submit-bg: var(--aia-primitive-neutral-1000);
250
+ --aia-submit-color: var(--aia-primitive-neutral-0);
227
251
 
228
- --aia-color-text-muted: #c1c4cb;
252
+ --aia-color-text-muted: #c1c4cb; /* off shared palette (slate) */
229
253
 
230
- --aia-skeleton-bg: #333539;
254
+ --aia-skeleton-bg: var(--aia-primitive-neutral-300);
231
255
 
232
256
  --aia-streak-rgb: 255, 255, 255;
233
257
  --aia-streak-glass-bg: rgba(255, 255, 255, 0.1);
234
258
 
235
- --aia-footer-divider: rgba(255, 255, 255, 0.15);
236
- --aia-footer-hint-color: #b0b0b0;
237
- --aia-footer-brand-color: #505050;
238
- --aia-footer-badge-border: #505050;
259
+ --aia-footer-divider: rgba(255, 255, 255, 0.15); /* off shared palette (no .15 step) */
260
+ --aia-footer-hint-color: var(--aia-primitive-neutral-700);
261
+ --aia-footer-brand-color: var(--aia-primitive-neutral-500);
262
+ --aia-footer-badge-border: var(--aia-primitive-neutral-500);
239
263
  }
240
264
 
241
265
  /* optionsPosition: dropdown above the input. The sections live inside the
@@ -414,7 +438,7 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
414
438
  justify-content: space-around;
415
439
  }
416
440
  }
417
- `,document.head.appendChild(e)}import{jsx as He}from"react/jsx-runtime";function le({gap:e,align:d="center",justify:n="start",noWrap:p=!1,inline:i=!1,className:t,children:s,...l}){let f=e?{"--aia-cluster-gap":e}:void 0,x={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":d,"data-justify":n,"data-nowrap":p||void 0,"data-inline":i||void 0,style:f,...l};return i?He("span",{...x,children:s}):He("div",{...x,children:s})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset (no vertical padding \u2014 the 8px
441
+ `,document.head.appendChild(e)}import{jsx as He}from"react/jsx-runtime";function le({gap:e,align:d="center",justify:n="start",noWrap:c=!1,inline:i=!1,className:t,children:s,...l}){let f=e?{"--aia-cluster-gap":e}:void 0,x={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":d,"data-justify":n,"data-nowrap":c||void 0,"data-inline":i||void 0,style:f,...l};return i?He("span",{...x,children:s}):He("div",{...x,children:s})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset (no vertical padding \u2014 the 8px
418
442
  section gap above and its own 8px gap provide the vertical rhythm), so the
419
443
  divider spans the full footer width yet still stays clear of the dropdown's
420
444
  rounded edges. */
@@ -487,7 +511,20 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
487
511
  line-height: 18px;
488
512
  color: var(--aia-footer-brand-color, #b0b0b0);
489
513
  }
490
- `,document.head.appendChild(e)}var U={footer:"DropdownFooter-module_footer_qQQ7x",divider:"DropdownFooter-module_divider_FlX4C",hintGroup:"DropdownFooter-module_hintGroup_ZzbPf",brandLink:"DropdownFooter-module_brandLink_r4f3R",key:"DropdownFooter-module_key_Bz1H-",hint:"DropdownFooter-module_hint_GKEOH",brand:"DropdownFooter-module_brand_Al-lR",badge:"DropdownFooter-module_badge_Fk9vg"};import{jsx as de,jsxs as be}from"react/jsx-runtime";function Ne({isOptionHighlighted:e=!1,isInputEmpty:d=!1}){let{key:n,hint:p}=ut(e,d);return be("footer",{className:U.footer,"data-aia-footer":"",children:[de("div",{className:U.divider}),be(le,{justify:"between",noWrap:!0,children:[be(le,{gap:"5px",className:U.hintGroup,children:[de("kbd",{className:U.key,children:n}),de("span",{className:U.hint,children:p})]}),be("a",{className:U.brandLink,href:"https://ai-autocomplete.com",target:"_blank",rel:"noopener noreferrer",children:[de("span",{className:U.brand,children:"AI"}),de("span",{className:U.badge,children:"Autocomplete"})]})]})]})}if(typeof document<"u"&&!document.getElementById("ac-style-04fef8d6")){let e=document.createElement("style");e.id="ac-style-04fef8d6",e.textContent=`.Pill-module_pill_3Rkw- {
514
+
515
+ /* Mobile footer variant (Figma "Mobile"): on phone-width viewports drop the
516
+ keyboard hint ("tab to select" is meaningless on touch) and its divider,
517
+ leaving only the AI-Autocomplete brand pinned to the right. */
518
+ @media (max-width: 768px) {
519
+ .DropdownFooter-module_divider_FlX4C,
520
+ .DropdownFooter-module_hintGroup_ZzbPf {
521
+ display: none;
522
+ }
523
+ .DropdownFooter-module_row_BgZ6Q {
524
+ justify-content: flex-end;
525
+ }
526
+ }
527
+ `,document.head.appendChild(e)}var V={footer:"DropdownFooter-module_footer_qQQ7x",divider:"DropdownFooter-module_divider_FlX4C",hintGroup:"DropdownFooter-module_hintGroup_ZzbPf",brandLink:"DropdownFooter-module_brandLink_r4f3R",key:"DropdownFooter-module_key_Bz1H-",hint:"DropdownFooter-module_hint_GKEOH",brand:"DropdownFooter-module_brand_Al-lR",badge:"DropdownFooter-module_badge_Fk9vg",row:"DropdownFooter-module_row_BgZ6Q"};import{jsx as de,jsxs as be}from"react/jsx-runtime";function Ne({isOptionHighlighted:e=!1,isInputEmpty:d=!1}){let{key:n,hint:c}=ut(e,d);return be("footer",{className:V.footer,"data-aia-footer":"",children:[de("div",{className:V.divider}),be(le,{justify:"between",noWrap:!0,className:V.row,children:[be(le,{gap:"5px",className:V.hintGroup,children:[de("kbd",{className:V.key,children:n}),de("span",{className:V.hint,children:c})]}),be("a",{className:V.brandLink,href:"https://ai-autocomplete.com",target:"_blank",rel:"noopener noreferrer",children:[de("span",{className:V.brand,children:"AI"}),de("span",{className:V.badge,children:"Autocomplete"})]})]})]})}if(typeof document<"u"&&!document.getElementById("ac-style-04fef8d6")){let e=document.createElement("style");e.id="ac-style-04fef8d6",e.textContent=`.Pill-module_pill_3Rkw- {
491
528
  display: inline-flex;
492
529
  align-items: center;
493
530
  justify-content: center;
@@ -539,7 +576,7 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
539
576
  opacity: 0;
540
577
  }
541
578
  }
542
- `,document.head.appendChild(e)}var Q={pill:"Pill-module_pill_3Rkw-",fadeIn:"Pill-module_fadeIn_Bbqtz",rounded:"Pill-module_rounded_6WMps",skeleton:"Pill-module_skeleton_-u9-j",skeletonPulse:"Pill-module_skeletonPulse_xHh-7"};import{jsx as mt}from"react/jsx-runtime";var Ae={selected:1,first:.7,next:.4,last:.2};function Ke({label:e,state:d,selected:n,rounded:p,loading:i,onClick:t}){let s=[Q.pill,p?Q.rounded:"",n&&!i?Q.active:"",i?Q.skeleton:""].filter(Boolean).join(" ");return mt("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:s,style:{opacity:Ae[d]},onMouseDown:l=>l.preventDefault(),onClick:i?void 0:t,disabled:i,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.PillList-module_list_qvLqO {
579
+ `,document.head.appendChild(e)}var Q={pill:"Pill-module_pill_3Rkw-",fadeIn:"Pill-module_fadeIn_Bbqtz",rounded:"Pill-module_rounded_6WMps",skeleton:"Pill-module_skeleton_-u9-j",skeletonPulse:"Pill-module_skeletonPulse_xHh-7"};import{jsx as mt}from"react/jsx-runtime";var Ae={selected:1,first:.7,next:.4,last:.2};function Ke({label:e,state:d,selected:n,rounded:c,loading:i,onClick:t}){let s=[Q.pill,c?Q.rounded:"",n&&!i?Q.active:"",i?Q.skeleton:""].filter(Boolean).join(" ");return mt("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:s,style:{opacity:Ae[d]},onMouseDown:l=>l.preventDefault(),onClick:i?void 0:t,disabled:i,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.PillList-module_list_qvLqO {
543
580
  position: relative;
544
581
  z-index: 1;
545
582
  pointer-events: auto;
@@ -549,7 +586,7 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
549
586
  align-items: center;
550
587
  vertical-align: middle;
551
588
  }
552
- `,document.head.appendChild(e)}var Pe={list:"PillList-module_list_qvLqO"};import{jsx as xe}from"react/jsx-runtime";var gt=[125,69];function We(e){return e===0?"first":e===1?"next":"last"}function ve({pills:e,activePillIndex:d,onSelectPill:n,activeSelected:p,rounded:i,loading:t}){return t&&e.length===0?xe("span",{className:Pe.list,"data-aia-pill-list-loading":"",children:gt.map((s,l)=>xe("span",{"data-aia-pill-skeleton":"",className:`${Q.pill} ${i?Q.rounded:""} ${Q.skeleton}`,style:{width:s,opacity:Ae[We(l)]}},`skel-${s}`))}):xe("span",{className:Pe.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((s,l)=>{let f=!!p&&l===d;return xe(Ke,{label:s.text,state:f?"selected":We(l),selected:f,rounded:i,loading:t,onClick:()=>n(l)},`${s.type}-${s.text}`)})})}import{useEffect as ft,useLayoutEffect as ht,useRef as bt,useState as xt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
589
+ `,document.head.appendChild(e)}var Pe={list:"PillList-module_list_qvLqO"};import{jsx as xe}from"react/jsx-runtime";var gt=[125,69];function We(e){return e===0?"first":e===1?"next":"last"}function ve({pills:e,activePillIndex:d,onSelectPill:n,activeSelected:c,rounded:i,loading:t}){return t&&e.length===0?xe("span",{className:Pe.list,"data-aia-pill-list-loading":"",children:gt.map((s,l)=>xe("span",{"data-aia-pill-skeleton":"",className:`${Q.pill} ${i?Q.rounded:""} ${Q.skeleton}`,style:{width:s,opacity:Ae[We(l)]}},`skel-${s}`))}):xe("span",{className:Pe.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((s,l)=>{let f=!!c&&l===d;return xe(Ke,{label:s.text,state:f?"selected":We(l),selected:f,rounded:i,loading:t,onClick:()=>n(l)},`${s.type}-${s.text}`)})})}import{useEffect as ft,useLayoutEffect as ht,useRef as bt,useState as xt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
553
590
  .aia-grid {
554
591
  display: grid;
555
592
  grid-template-columns: repeat(
@@ -582,7 +619,8 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
582
619
  border-radius: 3px;
583
620
  }
584
621
 
585
- /* Fade wrapper \u2014 bottom blur overlay shown while the grid overflows below. */
622
+ /* Fade wrapper \u2014 bottom gradient overlay shown while the grid overflows
623
+ below: overflowing options fade into the dropdown surface color. */
586
624
  .aia-grid-fade {
587
625
  position: relative;
588
626
  }
@@ -596,14 +634,18 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
596
634
  pointer-events: none;
597
635
  opacity: 0;
598
636
  transition: opacity 150ms ease-out;
599
- backdrop-filter: blur(12px);
600
- mask-image: linear-gradient(to bottom, transparent, white);
637
+ background: linear-gradient(to bottom, transparent, var(--aia-surface, #ffffff));
601
638
  }
602
639
  .aia-grid-fade[data-fade]::after {
603
640
  opacity: 1;
604
641
  }
642
+
643
+ /* Glass surface has no solid color to fade into, so skip the fade entirely. */
644
+ [data-aia-surface="glass"] .aia-grid-fade::after {
645
+ display: none;
646
+ }
605
647
  }
606
- `,document.head.appendChild(e)}import{jsx as Ge}from"react/jsx-runtime";function je({min:e="16rem",max:d,gap:n,scroll:p=!1,maxHeight:i,fade:t=!1,className:s,children:l,...f}){let x=bt(null),[R,I]=xt(!1);ft(()=>{if(!t)return;let v=x.current;if(!v)return;let C=()=>{I(v.scrollHeight-v.scrollTop-v.clientHeight>1)};v.addEventListener("scroll",C,{passive:!0});let z=new ResizeObserver(C);return z.observe(v),()=>{v.removeEventListener("scroll",C),z.disconnect()}},[t]),ht(()=>{let v=x.current;!t||!v||I(v.scrollHeight-v.scrollTop-v.clientHeight>1)},[t,l]);let k={"--aia-grid-min":e};d&&(k["--aia-grid-max"]=d),n&&(k["--aia-grid-gap"]=n),i&&(k["--aia-grid-max-height"]=i);let S=Ge("div",{ref:x,className:!t&&s?`aia-grid ${s}`:"aia-grid","data-scroll":p||void 0,style:k,...t?{}:f,children:l});return t?Ge("div",{className:s?`aia-grid-fade ${s}`:"aia-grid-fade","data-fade":R?"":void 0,...f,children:S}):S}import{useEffect as vt,useRef as wt,useState as yt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.SuggestionItem-module_item_d4vpD {
648
+ `,document.head.appendChild(e)}import{jsx as Ge}from"react/jsx-runtime";function je({min:e="16rem",max:d,gap:n,scroll:c=!1,maxHeight:i,fade:t=!1,className:s,children:l,...f}){let x=bt(null),[R,I]=xt(!1);ft(()=>{if(!t)return;let v=x.current;if(!v)return;let C=()=>{I(v.scrollHeight-v.scrollTop-v.clientHeight>1)};v.addEventListener("scroll",C,{passive:!0});let z=new ResizeObserver(C);return z.observe(v),()=>{v.removeEventListener("scroll",C),z.disconnect()}},[t]),ht(()=>{let v=x.current;!t||!v||I(v.scrollHeight-v.scrollTop-v.clientHeight>1)},[t,l]);let k={"--aia-grid-min":e};d&&(k["--aia-grid-max"]=d),n&&(k["--aia-grid-gap"]=n),i&&(k["--aia-grid-max-height"]=i);let S=Ge("div",{ref:x,className:!t&&s?`aia-grid ${s}`:"aia-grid","data-scroll":c||void 0,style:k,...t?{}:f,children:l});return t?Ge("div",{className:s?`aia-grid-fade ${s}`:"aia-grid-fade","data-fade":R?"":void 0,...f,children:S}):S}import{useEffect as vt,useRef as wt,useState as yt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.SuggestionItem-module_item_d4vpD {
607
649
  position: relative;
608
650
  overflow: visible;
609
651
  display: flex;
@@ -953,7 +995,7 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
953
995
  filter: brightness(0.55);
954
996
  }
955
997
  }
956
- `,document.head.appendChild(e)}var H={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",content:"SuggestionItem-module_content_T-Qba",tappable:"SuggestionItem-module_tappable_70KcX",nonTappable:"SuggestionItem-module_nonTappable_xSZM-",highlighted:"SuggestionItem-module_highlighted_Hb0SU",tag:"SuggestionItem-module_tag_e3Fwe",pressed:"SuggestionItem-module_pressed_98o-r",glassFade:"SuggestionItem-module_glassFade_oyiSj",tapDown:"SuggestionItem-module_tapDown_G3WGz",streaks:"SuggestionItem-module_streaks_d9PEB",streaksVert:"SuggestionItem-module_streaksVert_ERlV1",streakHorizRight:"SuggestionItem-module_streakHorizRight_aboGz",streakHorizLeft:"SuggestionItem-module_streakHorizLeft_BreWJ",streakVertUp:"SuggestionItem-module_streakVertUp_to1GD",streakVertDown:"SuggestionItem-module_streakVertDown_OrcLh",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};import{jsx as we,jsxs as Ve}from"react/jsx-runtime";function qe({option:e,isHighlighted:d,onSelect:n,onHighlight:p,id:i,loading:t}){let[s,l]=yt(!1),f=wt(void 0);vt(()=>()=>clearTimeout(f.current),[]);let x=()=>{t||!e.is_tappable||s||(l(!0),n(e),clearTimeout(f.current),f.current=setTimeout(()=>l(!1),500))},R=[H.item,d&&!t?H.highlighted:"",e.is_tappable?H.tappable:H.nonTappable,s?H.pressed:""].filter(Boolean).join(" ");return Ve("div",{id:i,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"aria-selected":d,className:R,tabIndex:t||!e.is_tappable?-1:0,onClick:x,onKeyDown:I=>{!t&&e.is_tappable&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),x())},onMouseEnter:!t&&e.is_tappable?p:void 0,children:[we("div",{className:H.streaks}),we("div",{className:H.streaksVert}),Ve("span",{className:H.content,children:[we("span",{className:H.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&we("span",{className:H.tag,children:e.tag})]})]})}import{jsx as $e}from"react/jsx-runtime";function Ue({options:e,activeIndex:d,onSelect:n,onHighlight:p,listboxId:i,loading:t}){return $e(je,{min:"250px",max:"250px",gap:"0",scroll:!0,fade:!0,children:e.map((s,l)=>$e(qe,{option:s,isHighlighted:l===d,onSelect:n,onHighlight:()=>p(l),id:`${i}-option-${l}`,loading:t},s.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
998
+ `,document.head.appendChild(e)}var H={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",content:"SuggestionItem-module_content_T-Qba",tappable:"SuggestionItem-module_tappable_70KcX",nonTappable:"SuggestionItem-module_nonTappable_xSZM-",highlighted:"SuggestionItem-module_highlighted_Hb0SU",tag:"SuggestionItem-module_tag_e3Fwe",pressed:"SuggestionItem-module_pressed_98o-r",glassFade:"SuggestionItem-module_glassFade_oyiSj",tapDown:"SuggestionItem-module_tapDown_G3WGz",streaks:"SuggestionItem-module_streaks_d9PEB",streaksVert:"SuggestionItem-module_streaksVert_ERlV1",streakHorizRight:"SuggestionItem-module_streakHorizRight_aboGz",streakHorizLeft:"SuggestionItem-module_streakHorizLeft_BreWJ",streakVertUp:"SuggestionItem-module_streakVertUp_to1GD",streakVertDown:"SuggestionItem-module_streakVertDown_OrcLh",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};import{jsx as we,jsxs as Ve}from"react/jsx-runtime";function qe({option:e,isHighlighted:d,onSelect:n,onHighlight:c,id:i,loading:t}){let[s,l]=yt(!1),f=wt(void 0);vt(()=>()=>clearTimeout(f.current),[]);let x=()=>{t||!e.is_tappable||s||(l(!0),n(e),clearTimeout(f.current),f.current=setTimeout(()=>l(!1),500))},R=[H.item,d&&!t?H.highlighted:"",e.is_tappable?H.tappable:H.nonTappable,s?H.pressed:""].filter(Boolean).join(" ");return Ve("div",{id:i,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"aria-selected":d,className:R,tabIndex:t||!e.is_tappable?-1:0,onClick:x,onKeyDown:I=>{!t&&e.is_tappable&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),x())},onMouseEnter:!t&&e.is_tappable?c:void 0,children:[we("div",{className:H.streaks}),we("div",{className:H.streaksVert}),Ve("span",{className:H.content,children:[we("span",{className:H.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&we("span",{className:H.tag,children:e.tag})]})]})}import{jsx as $e}from"react/jsx-runtime";function Ue({options:e,activeIndex:d,onSelect:n,onHighlight:c,listboxId:i,loading:t}){return $e(je,{min:"250px",max:"250px",gap:"0",scroll:!0,fade:!0,children:e.map((s,l)=>$e(qe,{option:s,isHighlighted:l===d,onSelect:n,onHighlight:()=>c(l),id:`${i}-option-${l}`,loading:t},s.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
957
999
  .aia-stack {
958
1000
  display: flex;
959
1001
  flex-direction: column;
@@ -970,7 +1012,7 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
970
1012
  }
971
1013
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
972
1014
  }
973
- `,document.head.appendChild(e)}import{jsx as _t}from"react/jsx-runtime";function Qe({space:e,align:d="stretch",className:n,children:p,...i}){let t=e?{"--aia-stack-space":e}:void 0;return _t("div",{className:n?`aia-stack ${n}`:"aia-stack","data-align":d,style:t,...i,children:p})}import{jsx as oe,jsxs as Ct}from"react/jsx-runtime";var At=[159,119,164];function Pt(e){let d=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[n,p]=St(d);if(kt(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>p(i.matches);return i.addEventListener("change",t),()=>i.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?n?"dark":"light":e}function Ce({suggestions:e,activeIndex:d,onSelect:n,onHighlight:p,isOpen:i,id:t,className:s,pills:l,onPillClick:f,showPills:x=!0,activeSelected:R=!1,isLoading:I=!1,isInputEmpty:k=!1,optionsPosition:S="below",mode:v}){let C=Pt(v),z=C!==void 0,V=e[0]?.options??[],r=!!(l&&l.length>0&&f),w=i&&(V.length>0||x&&r||I),T={suggestions:e,activeIndex:d,pills:l,showPills:x,activeSelected:R,isLoading:I,isInputEmpty:k},W=It(T);w&&(W.current=T);let m=w?T:W.current,B=m.suggestions[0]?.options??[],E=m.activeIndex>=0&&!!B[m.activeIndex]?.is_tappable,G=!!(m.pills&&m.pills.length>0&&f),L=m.showPills&&G,J=m.showPills&&!G&&m.isLoading,q=L||J,F=B.length>0,O=m.isLoading&&!F;return oe("div",{id:t,role:"listbox","data-aia-dropdown":"","data-options-position":S,"data-mode":C,"data-aia-loading":m.isLoading?"":void 0,className:`${z?"magicx-aia ":""}${ne.dropdown} ${w?ne.visible:""} ${s??""}`,onMouseDown:g=>g.preventDefault(),children:Ct(Qe,{space:"8px",children:[q&&oe(le,{noWrap:!0,className:ne.pillBar,"data-aia-pillbar":"",children:oe(ve,{pills:m.pills??[],activePillIndex:0,activeSelected:m.activeSelected,onSelectPill:f??(()=>{}),rounded:!0,loading:m.isLoading})}),F&&oe(Ue,{options:B,activeIndex:m.activeIndex,onSelect:n,onHighlight:p,listboxId:t,loading:m.isLoading}),O&&oe("div",{className:ne.skeletonBars,"data-aia-skeleton-bars":"",children:At.map(g=>oe("span",{className:ne.skeletonBar,style:{width:g}},`bar-${g}`))}),oe(Ne,{isOptionHighlighted:E,isInputEmpty:m.isInputEmpty})]})})}import{buildQuery as Mt,ModeController as Ht,setCursorOffset as Nt}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.SubmitButton-module_submitButton_otz7H {
1015
+ `,document.head.appendChild(e)}import{jsx as _t}from"react/jsx-runtime";function Qe({space:e,align:d="stretch",className:n,children:c,...i}){let t=e?{"--aia-stack-space":e}:void 0;return _t("div",{className:n?`aia-stack ${n}`:"aia-stack","data-align":d,style:t,...i,children:c})}import{jsx as ae,jsxs as Ct}from"react/jsx-runtime";var At=[159,119,164];function Pt(e){let d=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[n,c]=St(d);if(kt(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>c(i.matches);return i.addEventListener("change",t),()=>i.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?n?"dark":"light":e}function Ce({suggestions:e,activeIndex:d,onSelect:n,onHighlight:c,isOpen:i,id:t,className:s,pills:l,onPillClick:f,showPills:x=!0,activeSelected:R=!1,isLoading:I=!1,isInputEmpty:k=!1,optionsPosition:S="below",mode:v}){let C=Pt(v),z=C!==void 0,q=e[0]?.options??[],r=!!(l&&l.length>0&&f),w=i&&(q.length>0||x&&r||I),T={suggestions:e,activeIndex:d,pills:l,showPills:x,activeSelected:R,isLoading:I,isInputEmpty:k},W=It(T);w&&(W.current=T);let m=w?T:W.current,B=m.suggestions[0]?.options??[],E=m.activeIndex>=0&&!!B[m.activeIndex]?.is_tappable,G=!!(m.pills&&m.pills.length>0&&f),L=m.showPills&&G,Z=m.showPills&&!G&&m.isLoading,$=L||Z,F=B.length>0,O=m.isLoading&&!F;return ae("div",{id:t,role:"listbox","data-aia-dropdown":"","data-options-position":S,"data-mode":C,"data-aia-loading":m.isLoading?"":void 0,className:`${z?"magicx-aia ":""}${ne.dropdown} ${w?ne.visible:""} ${s??""}`,onMouseDown:g=>g.preventDefault(),children:Ct(Qe,{space:"8px",children:[$&&ae(le,{noWrap:!0,className:ne.pillBar,"data-aia-pillbar":"",children:ae(ve,{pills:m.pills??[],activePillIndex:0,activeSelected:m.activeSelected,onSelectPill:f??(()=>{}),rounded:!0,loading:m.isLoading})}),F&&ae(Ue,{options:B,activeIndex:m.activeIndex,onSelect:n,onHighlight:c,listboxId:t,loading:m.isLoading}),O&&ae("div",{className:ne.skeletonBars,"data-aia-skeleton-bars":"",children:At.map(g=>ae("span",{className:ne.skeletonBar,style:{width:g}},`bar-${g}`))}),ae(Ne,{isOptionHighlighted:E,isInputEmpty:m.isInputEmpty})]})})}import{buildQuery as Mt,ModeController as Ht,setCursorOffset as Nt}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.SubmitButton-module_submitButton_otz7H {
974
1016
  flex-shrink: 0;
975
1017
  width: 32px;
976
1018
  height: 32px;
@@ -994,5 +1036,5 @@ import{forwardRef as zt,useCallback as Te,useEffect as at,useImperativeHandle as
994
1036
  opacity: 0.4;
995
1037
  cursor: default;
996
1038
  }
997
- `,document.head.appendChild(e)}var Xe={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ee}from"react/jsx-runtime";function Je({disabled:e,onClick:d}){return Ee("button",{type:"button","data-aia-submit":"",className:Xe.submitButton,disabled:e,onClick:n=>{n.stopPropagation(),d()},"aria-label":"Submit",children:Ee("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ee("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Et}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Ze,useEffect as ye,useRef as N,useState as Dt}from"react";var Rt={text:"",completedParams:[],suggestions:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1};function De({onSubmit:e,onError:d,optionOverrides:n,maskCompletedText:p,apiConfig:i,columns:t=2,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:f,showNonTappableOptions:x,onFocus:R,onBlur:I,value:k,completedParams:S,onChange:v,onParamsChange:C,source:z,setCursor:V}){let r=N(null),[w,T]=Dt(null),W=N(e);W.current=e;let m=N(d);m.current=d;let X=N(v);X.current=v;let B=N(C);B.current=C;let E=N(R);E.current=R;let G=N(I);G.current=I;let L=N(V);L.current=V,ye(()=>{if(typeof document>"u")return;let a=new Et(document.createElement("div"),{renderMode:"headless",apiConfig:i,optionOverrides:n,maskCompletedText:p,columns:t,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:f,showNonTappableOptions:x,source:z,value:k,completedParams:S,onSubmit:(...A)=>W.current?.(...A),onError:(...A)=>m.current?.(...A),onChange:(...A)=>X.current?.(...A),onParamsChange:(...A)=>B.current?.(...A),onFocus:()=>E.current?.(),onBlur:()=>G.current?.(),setCursor:A=>L.current?.(A)});r.current=a,T(a.getState());let P=a.subscribe(A=>T(A));return()=>{P(),a.destroy(),r.current===a&&(r.current=null)}},[]),ye(()=>{k!==void 0&&r.current?.setValue(k)},[k]),ye(()=>{S!==void 0&&r.current?.setCompletedParams(S)},[S]);let J=JSON.stringify(i??null),q=N(n),F=N(0);if(n!==q.current){let a=q.current,P=n,A=Object.keys(a??{}),ae=Object.keys(P??{});(A.length!==ae.length||ae.some(se=>!a?.[se]||P[se]!==a[se]))&&F.current++,q.current=n}ye(()=>{r.current?.update({apiConfig:i,optionOverrides:n,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:f,showNonTappableOptions:x})},[J,F.current,s,l,f,x]);let O=N(null);O.current===null&&(O.current={handleTextChange:a=>r.current?.handleTextChange(a),handleKeyDown:a=>{let P="nativeEvent"in a?a.nativeEvent:a;r.current?.handleKeyDown(P)},setFocused:a=>r.current?.setFocused(a),startEditingParam:a=>r.current?.startEditingParam(a),exitEditMode:()=>r.current?.exitEditMode(),handleCaretAfterInput:a=>r.current?.handleCaretAfterInput(a),handleCaretMove:a=>r.current?.handleCaretMove(a),replaceEditingRange:a=>r.current?.replaceEditingRange(a)??!1,setActivePill:a=>r.current?.setActivePill(a),removeLastParam:()=>r.current?.removeLastParam(),clearNewParamId:()=>r.current?.clearNewParamId(),reset:()=>r.current?.reset(),selectOption:a=>r.current?.selectOption(a),setActiveDropdownIndex:a=>r.current?.setActiveDropdownIndex(a),handleFocus:()=>r.current?.setFocused(!0),handleBlur:()=>r.current?.setFocused(!1)});let g=O.current,Y=Ze(a=>{let P=a.target.value,ae=P.length>0&&!a.nativeEvent?.isComposing&&P[0]!==P[0].toUpperCase()?P[0].toUpperCase()+P.slice(1):P;r.current?.handleTextChange(ae)},[]),ee=Ze(a=>{r.current?.handleKeyDown(a.nativeEvent)},[]),Z=r.current,c=w??Rt,o=k!==void 0?k:c.text,u=S!==void 0?S:c.completedParams,h=c.actionableSuggestions,_=h[0],b=Z?.listboxId??"",D=c.activeDropdownIndex>=0&&Z?`${b}-option-${c.activeDropdownIndex}`:void 0,M=c.editingParam,$=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:null,pe=$??_,ke=$?[$]:h,ue=!Z||c.isLoading&&!c.editingParam&&!c.inSelectionAnimation;return{completedParams:u,suggestionPills:h,setActivePill:g.setActivePill,removeLastParam:g.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:g.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:ue,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:b,error:c.error,handleTextChange:g.handleTextChange,handleKeyDown:g.handleKeyDown,setFocused:g.setFocused,editingParam:M,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:g.startEditingParam,exitEditMode:g.exitEditMode,handleCaretAfterInput:g.handleCaretAfterInput,handleCaretMove:g.handleCaretMove,replaceEditingRange:g.replaceEditingRange,inputProps:{value:o,placeholder:c.placeholderText||void 0,onChange:Y,onKeyDown:ee,onFocus:g.handleFocus,onBlur:g.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":D,"aria-autocomplete":"list","aria-controls":b},reset:g.reset,dropdownProps:{suggestions:pe?[{...pe,options:c.filteredOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:g.selectOption,onHighlight:g.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:b,pills:ke,activeSelected:c.isActivePillSelected,onPillClick:g.setActivePill,isLoading:ue,isInputEmpty:o.trim().length===0,optionsPosition:l??"below"}}}import{extractPlainText as Ye,getCursorOffset as et,plainTextLength as Lt,renderEditableContent as Tt,setCursorOffset as tt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as K,useEffect as Re,useLayoutEffect as Le,useRef as ie}from"react";var _e;function Bt(){if(_e!==void 0)return _e;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),_e=e.contentEditable==="plaintext-only",_e}function ot(e){let{segments:d,newParamId:n,editingParam:p,editingAnchor:i,caretOffset:t,placeholderText:s,isFocused:l,isDropdownOpen:f,listboxId:x,activeDescendantId:R,autoFocus:I,handleTextChange:k,handleKeyDown:S,handleCaretAfterInput:v,handleCaretMove:C,startEditingParam:z,replaceEditingRange:V,setFocused:r}=e,w=ie(null),T=ie(!1),W=ie(""),m=ie(""),X=ie(null),B=ie(0);X.current=t,Re(()=>{if(!I)return;let o=w.current;o&&(document.activeElement===o?r(!0):o.focus())},[I,r]),Re(()=>{let o=w.current;if(!o)return;let u=o.ownerDocument??document,h=()=>{let _=u.getSelection();if(!_||_.rangeCount===0||!_.anchorNode||!o.contains(_.anchorNode))return;let b=_.anchorNode,$=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if($&&$!==p?.id){z($);return}performance.now()-B.current<50||C(et(o))};return u.addEventListener("selectionchange",h),()=>u.removeEventListener("selectionchange",h)},[p,z,C]),Le(()=>{let o=w.current;o&&Tt({input:o,segments:d,newParamId:n,editingParamId:p?.id??null,placeholderText:s??"",isFocused:l})},[d,n,p,s,l]),Le(()=>{let o=W.current,u=n??"";if(W.current=u,!u||u===o)return;let h=w.current;if(!h)return;h.focus();let _=X.current??Lt(h);tt(h,_)},[n]),Le(()=>{let o=m.current,u=p?.id??"";if(m.current=u,!u||u===o||i==null)return;let h=w.current;h&&tt(h,i)},[p,i]);let E=K(()=>{if(T.current)return;let o=w.current;if(!o)return;let u=Ye(o),_=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;k(_)},[k]),G=K(()=>{B.current=performance.now(),E();let o=w.current;o&&v(et(o))},[E,v]);Re(()=>{let o=w.current;if(!o)return;let u=h=>{let _=h,b=_.inputType;if(b==="insertParagraph"||b==="insertLineBreak"||b==="insertFromDrop"){h.preventDefault();return}if(b.startsWith("insert")||b.startsWith("delete")){let D=b.startsWith("delete")?"":_.data??"";V(D)&&h.preventDefault()}};return o.addEventListener("beforeinput",u),()=>o.removeEventListener("beforeinput",u)},[V]);let L=K(()=>{T.current=!0},[]),J=K(()=>{T.current=!1,E()},[E]),q=K(o=>{o.preventDefault();let u=w.current;if(!u)return;let h=(o.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let _=u.ownerDocument??document,b=_.getSelection();if(!b||b.rangeCount===0)return;let D=b.getRangeAt(0);if(!u.contains(D.startContainer))return;D.deleteContents();let M=_.createTextNode(h);D.insertNode(M),D.setStartAfter(M),D.collapse(!0),b.removeAllRanges(),b.addRange(D),E()},[E]),F=K(o=>S(o),[S]),O=K(()=>r(!0),[r]),g=K(()=>r(!1),[r]),Y=K(()=>w.current?.focus(),[]),ee=K(()=>w.current?.blur(),[]),Z=K(()=>{let o=w.current;return o?Ye(o):""},[]),c=Bt()?"plaintext-only":"true";return{inputRef:w,editorProps:{ref:w,contentEditable:c,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":x,"aria-expanded":f,"aria-activedescendant":R,spellCheck:!0,enterKeyHint:"send",onInput:G,onKeyDown:F,onCompositionStart:L,onCompositionEnd:J,onPaste:q,onFocus:O,onBlur:g},getPlainText:Z,focus:Y,blur:ee}}import{jsx as re,jsxs as Be}from"react/jsx-runtime";function Kt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Wt=zt(function({onSubmit:d,onError:n,optionOverrides:p,maskCompletedText:i,className:t,apiConfig:s,columns:l,pillPlacement:f="dropdown",mode:x="auto",optionsPosition:R="below",animations:I=!0,dropdownTrigger:k,closeDropdownOnBlur:S,showNonTappableOptions:v,autoFocus:C=!0,onFocus:z,onBlur:V,value:r,completedParams:w,onChange:T,onParamsChange:W,submitButton:m},X){let B=ce(null),E=ce(null),G=ce(()=>{}),L=ce(null),J=ce(null);at(()=>{let y=B.current;if(y)return L.current?L.current.setMode(x):L.current=new Ht(y,x),()=>{L.current?.destroy(),L.current=null}},[x]);let q=Te(y=>{let j=J.current?.current;j&&(j.focus(),Nt(j,y))},[]),{completedParams:F,suggestionPills:O,setActivePill:g,segments:Y,newParamId:ee,clearNewParamId:Z,placeholderText:c,isFocused:o,isDropdownOpen:u,isActivePillSelected:h,isLoading:_,activeIndex:b,listboxId:D,handleTextChange:M,handleKeyDown:$,setFocused:pe,editingParam:ke,editingAnchor:ue,caretOffset:a,startEditingParam:P,handleCaretAfterInput:A,handleCaretMove:ae,replaceEditingRange:se,dropdownProps:nt,reset:me}=De({onSubmit:y=>G.current(y),onError:n,optionOverrides:p,maskCompletedText:i,apiConfig:s,columns:l,dropdownTrigger:k,optionsPosition:R,closeDropdownOnBlur:S,showNonTappableOptions:v,onFocus:z,onBlur:V,value:r,completedParams:w,onChange:T,onParamsChange:W,source:"full-sdk",setCursor:q});at(()=>{if(!ee)return;let y=window.setTimeout(()=>Z(),650);return()=>window.clearTimeout(y)},[ee,Z]);let it=b>=0?`${D}-option-${b}`:void 0,{inputRef:Ie,editorProps:rt,focus:ge,blur:ze,getPlainText:Fe}=ot({segments:Y,newParamId:ee,editingParam:ke,editingAnchor:ue,caretOffset:a,placeholderText:c,isFocused:o,isDropdownOpen:u,listboxId:D,activeDescendantId:it,autoFocus:C,handleTextChange:M,handleKeyDown:$,handleCaretAfterInput:A,handleCaretMove:ae,startEditingParam:P,replaceEditingRange:se,setFocused:pe});J.current=Ie,Ot(()=>{let y=E.current,j=Ie.current;if(!y||!j)return;let he=()=>{let Me=y.firstElementChild;if(!Me)return;let ct=Me.getBoundingClientRect(),pt=j.getBoundingClientRect();ct.top>=pt.bottom-2?y.setAttribute("data-aia-pill-wrapped",""):y.removeAttribute("data-aia-pill-wrapped")};he();let Oe=new ResizeObserver(he);return Oe.observe(j),()=>Oe.disconnect()},[Y,O.length,_,Ie]),Ft(X,()=>({focus:ge,blur:ze,reset:me,setMode:y=>L.current?.setMode(y)}),[ge,ze,me]);let fe=!!Y.length||F.length>0,Se=Te(()=>{if(!fe)return;let y=Fe(),{rawQuery:j,completedParams:he}=Mt(y,F);d({query:y.trim(),raw_query:j,completed_params:he}),me()},[fe,F,d,me,Fe]);G.current=Se;let st=Te(y=>{y.target?.closest("[data-aia-pill]")||ge()},[ge]),lt=f==="inline",dt=f==="dropdown";return Be("div",{ref:B,className:`magicx-aia ${te.container} ${t??""}`,"data-pill-placement":f,"data-options-position":R,"data-animations":I?"on":"off","data-mode":Kt(x),children:[re(Ce,{...nt,showPills:dt}),Be("div",{className:te.inputWrapper,onClick:st,children:[Be("div",{className:te.editorArea,"data-aia-editor":"",children:[re("div",{...rt,className:te.input,"data-aia-input":""}),lt&&(_||O.length>0)&&re("span",{ref:E,className:te.pillListContainer,"data-aia-pill-list-container":"",children:re(ve,{pills:O,activePillIndex:0,activeSelected:h,onSelectPill:g,loading:_})})]}),m===null?null:m===void 0?re(Je,{disabled:!fe,onClick:Se}):re("span",{"data-aia-submit":"",className:te.submitSlot,onClick:y=>{fe&&(y.stopPropagation(),Se())},children:m})]})]})});export{Wt as AIAutocomplete,Ce as AIAutocompleteDropdown,De as useAIAutocomplete};
1039
+ `,document.head.appendChild(e)}var Xe={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ee}from"react/jsx-runtime";function Ze({disabled:e,onClick:d}){return Ee("button",{type:"button","data-aia-submit":"",className:Xe.submitButton,disabled:e,onClick:n=>{n.stopPropagation(),d()},"aria-label":"Submit",children:Ee("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ee("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Et}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Je,useEffect as ye,useRef as N,useState as Dt}from"react";var Rt={text:"",completedParams:[],suggestions:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1};function De({onSubmit:e,onError:d,optionOverrides:n,maskCompletedText:c,apiConfig:i,columns:t=2,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:f,showNonTappableOptions:x,onFocus:R,onBlur:I,value:k,completedParams:S,onChange:v,onParamsChange:C,source:z,setCursor:q}){let r=N(null),[w,T]=Dt(null),W=N(e);W.current=e;let m=N(d);m.current=d;let X=N(v);X.current=v;let B=N(C);B.current=C;let E=N(R);E.current=R;let G=N(I);G.current=I;let L=N(q);L.current=q,ye(()=>{if(typeof document>"u")return;let o=new Et(document.createElement("div"),{renderMode:"headless",apiConfig:i,optionOverrides:n,maskCompletedText:c,columns:t,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:f,showNonTappableOptions:x,source:z,value:k,completedParams:S,onSubmit:(...A)=>W.current?.(...A),onError:(...A)=>m.current?.(...A),onChange:(...A)=>X.current?.(...A),onParamsChange:(...A)=>B.current?.(...A),onFocus:()=>E.current?.(),onBlur:()=>G.current?.(),setCursor:A=>L.current?.(A)});r.current=o,T(o.getState());let P=o.subscribe(A=>T(A));return()=>{P(),o.destroy(),r.current===o&&(r.current=null)}},[]),ye(()=>{k!==void 0&&r.current?.setValue(k)},[k]),ye(()=>{S!==void 0&&r.current?.setCompletedParams(S)},[S]);let Z=JSON.stringify(i??null),$=N(n),F=N(0);if(n!==$.current){let o=$.current,P=n,A=Object.keys(o??{}),oe=Object.keys(P??{});(A.length!==oe.length||oe.some(se=>!o?.[se]||P[se]!==o[se]))&&F.current++,$.current=n}ye(()=>{r.current?.update({apiConfig:i,optionOverrides:n,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:f,showNonTappableOptions:x})},[Z,F.current,s,l,f,x]);let O=N(null);O.current===null&&(O.current={handleTextChange:o=>r.current?.handleTextChange(o),handleKeyDown:o=>{let P="nativeEvent"in o?o.nativeEvent:o;r.current?.handleKeyDown(P)},setFocused:o=>r.current?.setFocused(o),startEditingParam:o=>r.current?.startEditingParam(o),exitEditMode:()=>r.current?.exitEditMode(),handleCaretAfterInput:o=>r.current?.handleCaretAfterInput(o),handleCaretMove:o=>r.current?.handleCaretMove(o),replaceEditingRange:o=>r.current?.replaceEditingRange(o)??!1,setActivePill:o=>r.current?.setActivePill(o),removeLastParam:()=>r.current?.removeLastParam(),clearNewParamId:()=>r.current?.clearNewParamId(),reset:()=>r.current?.reset(),selectOption:o=>r.current?.selectOption(o),setActiveDropdownIndex:o=>r.current?.setActiveDropdownIndex(o),handleFocus:()=>r.current?.setFocused(!0),handleBlur:()=>r.current?.setFocused(!1)});let g=O.current,Y=Je(o=>{let P=o.target.value,oe=P.length>0&&!o.nativeEvent?.isComposing&&P[0]!==P[0].toUpperCase()?P[0].toUpperCase()+P.slice(1):P;r.current?.handleTextChange(oe)},[]),ee=Je(o=>{r.current?.handleKeyDown(o.nativeEvent)},[]),J=r.current,p=w??Rt,a=k!==void 0?k:p.text,u=S!==void 0?S:p.completedParams,h=p.actionableSuggestions,_=h[0],b=J?.listboxId??"",D=p.activeDropdownIndex>=0&&J?`${b}-option-${p.activeDropdownIndex}`:void 0,M=p.editingParam,U=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:null,ce=U??_,ke=U?[U]:h,ue=!J||p.isLoading&&!p.editingParam&&!p.inSelectionAnimation;return{completedParams:u,suggestionPills:h,setActivePill:g.setActivePill,removeLastParam:g.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:g.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:ue,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:b,error:p.error,handleTextChange:g.handleTextChange,handleKeyDown:g.handleKeyDown,setFocused:g.setFocused,editingParam:M,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:g.startEditingParam,exitEditMode:g.exitEditMode,handleCaretAfterInput:g.handleCaretAfterInput,handleCaretMove:g.handleCaretMove,replaceEditingRange:g.replaceEditingRange,inputProps:{value:a,placeholder:p.placeholderText||void 0,onChange:Y,onKeyDown:ee,onFocus:g.handleFocus,onBlur:g.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":D,"aria-autocomplete":"list","aria-controls":b},reset:g.reset,dropdownProps:{suggestions:ce?[{...ce,options:p.filteredOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:g.selectOption,onHighlight:g.setActiveDropdownIndex,isOpen:p.isDropdownOpen,id:b,pills:ke,activeSelected:p.isActivePillSelected,onPillClick:g.setActivePill,isLoading:ue,isInputEmpty:a.trim().length===0,optionsPosition:l??"below"}}}import{extractPlainText as Ye,getCursorOffset as et,plainTextLength as Lt,renderEditableContent as Tt,setCursorOffset as tt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as K,useEffect as Re,useLayoutEffect as Le,useRef as ie}from"react";var _e;function Bt(){if(_e!==void 0)return _e;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),_e=e.contentEditable==="plaintext-only",_e}function at(e){let{segments:d,newParamId:n,editingParam:c,editingAnchor:i,caretOffset:t,placeholderText:s,isFocused:l,isDropdownOpen:f,listboxId:x,activeDescendantId:R,autoFocus:I,handleTextChange:k,handleKeyDown:S,handleCaretAfterInput:v,handleCaretMove:C,startEditingParam:z,replaceEditingRange:q,setFocused:r}=e,w=ie(null),T=ie(!1),W=ie(""),m=ie(""),X=ie(null),B=ie(0);X.current=t,Re(()=>{if(!I)return;let a=w.current;a&&(document.activeElement===a?r(!0):a.focus())},[I,r]),Re(()=>{let a=w.current;if(!a)return;let u=a.ownerDocument??document,h=()=>{let _=u.getSelection();if(!_||_.rangeCount===0||!_.anchorNode||!a.contains(_.anchorNode))return;let b=_.anchorNode,U=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(U&&U!==c?.id){z(U);return}performance.now()-B.current<50||C(et(a))};return u.addEventListener("selectionchange",h),()=>u.removeEventListener("selectionchange",h)},[c,z,C]),Le(()=>{let a=w.current;a&&Tt({input:a,segments:d,newParamId:n,editingParamId:c?.id??null,placeholderText:s??"",isFocused:l})},[d,n,c,s,l]),Le(()=>{let a=W.current,u=n??"";if(W.current=u,!u||u===a)return;let h=w.current;if(!h)return;h.focus();let _=X.current??Lt(h);tt(h,_)},[n]),Le(()=>{let a=m.current,u=c?.id??"";if(m.current=u,!u||u===a||i==null)return;let h=w.current;h&&tt(h,i)},[c,i]);let E=K(()=>{if(T.current)return;let a=w.current;if(!a)return;let u=Ye(a),_=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;k(_)},[k]),G=K(()=>{B.current=performance.now(),E();let a=w.current;a&&v(et(a))},[E,v]);Re(()=>{let a=w.current;if(!a)return;let u=h=>{let _=h,b=_.inputType;if(b==="insertParagraph"||b==="insertLineBreak"||b==="insertFromDrop"){h.preventDefault();return}if(b.startsWith("insert")||b.startsWith("delete")){let D=b.startsWith("delete")?"":_.data??"";q(D)&&h.preventDefault()}};return a.addEventListener("beforeinput",u),()=>a.removeEventListener("beforeinput",u)},[q]);let L=K(()=>{T.current=!0},[]),Z=K(()=>{T.current=!1,E()},[E]),$=K(a=>{a.preventDefault();let u=w.current;if(!u)return;let h=(a.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let _=u.ownerDocument??document,b=_.getSelection();if(!b||b.rangeCount===0)return;let D=b.getRangeAt(0);if(!u.contains(D.startContainer))return;D.deleteContents();let M=_.createTextNode(h);D.insertNode(M),D.setStartAfter(M),D.collapse(!0),b.removeAllRanges(),b.addRange(D),E()},[E]),F=K(a=>S(a),[S]),O=K(()=>r(!0),[r]),g=K(()=>r(!1),[r]),Y=K(()=>w.current?.focus(),[]),ee=K(()=>w.current?.blur(),[]),J=K(()=>{let a=w.current;return a?Ye(a):""},[]),p=Bt()?"plaintext-only":"true";return{inputRef:w,editorProps:{ref:w,contentEditable:p,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":x,"aria-expanded":f,"aria-activedescendant":R,spellCheck:!0,enterKeyHint:"send",onInput:G,onKeyDown:F,onCompositionStart:L,onCompositionEnd:Z,onPaste:$,onFocus:O,onBlur:g},getPlainText:J,focus:Y,blur:ee}}import{jsx as re,jsxs as Be}from"react/jsx-runtime";function Kt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Wt=zt(function({onSubmit:d,onError:n,optionOverrides:c,maskCompletedText:i,className:t,apiConfig:s,columns:l,pillPlacement:f="dropdown",mode:x="auto",optionsPosition:R="below",animations:I=!0,dropdownTrigger:k,closeDropdownOnBlur:S,showNonTappableOptions:v,autoFocus:C=!0,onFocus:z,onBlur:q,value:r,completedParams:w,onChange:T,onParamsChange:W,submitButton:m},X){let B=pe(null),E=pe(null),G=pe(()=>{}),L=pe(null),Z=pe(null);ot(()=>{let y=B.current;if(y)return L.current?L.current.setMode(x):L.current=new Ht(y,x),()=>{L.current?.destroy(),L.current=null}},[x]);let $=Te(y=>{let j=Z.current?.current;j&&(j.focus(),Nt(j,y))},[]),{completedParams:F,suggestionPills:O,setActivePill:g,segments:Y,newParamId:ee,clearNewParamId:J,placeholderText:p,isFocused:a,isDropdownOpen:u,isActivePillSelected:h,isLoading:_,activeIndex:b,listboxId:D,handleTextChange:M,handleKeyDown:U,setFocused:ce,editingParam:ke,editingAnchor:ue,caretOffset:o,startEditingParam:P,handleCaretAfterInput:A,handleCaretMove:oe,replaceEditingRange:se,dropdownProps:nt,reset:me}=De({onSubmit:y=>G.current(y),onError:n,optionOverrides:c,maskCompletedText:i,apiConfig:s,columns:l,dropdownTrigger:k,optionsPosition:R,closeDropdownOnBlur:S,showNonTappableOptions:v,onFocus:z,onBlur:q,value:r,completedParams:w,onChange:T,onParamsChange:W,source:"full-sdk",setCursor:$});ot(()=>{if(!ee)return;let y=window.setTimeout(()=>J(),650);return()=>window.clearTimeout(y)},[ee,J]);let it=b>=0?`${D}-option-${b}`:void 0,{inputRef:Ie,editorProps:rt,focus:ge,blur:ze,getPlainText:Fe}=at({segments:Y,newParamId:ee,editingParam:ke,editingAnchor:ue,caretOffset:o,placeholderText:p,isFocused:a,isDropdownOpen:u,listboxId:D,activeDescendantId:it,autoFocus:C,handleTextChange:M,handleKeyDown:U,handleCaretAfterInput:A,handleCaretMove:oe,startEditingParam:P,replaceEditingRange:se,setFocused:ce});Z.current=Ie,Ot(()=>{let y=E.current,j=Ie.current;if(!y||!j)return;let he=()=>{let Me=y.firstElementChild;if(!Me)return;let pt=Me.getBoundingClientRect(),ct=j.getBoundingClientRect();pt.top>=ct.bottom-2?y.setAttribute("data-aia-pill-wrapped",""):y.removeAttribute("data-aia-pill-wrapped")};he();let Oe=new ResizeObserver(he);return Oe.observe(j),()=>Oe.disconnect()},[Y,O.length,_,Ie]),Ft(X,()=>({focus:ge,blur:ze,reset:me,setMode:y=>L.current?.setMode(y)}),[ge,ze,me]);let fe=!!Y.length||F.length>0,Se=Te(()=>{if(!fe)return;let y=Fe(),{rawQuery:j,completedParams:he}=Mt(y,F);d({query:y.trim(),raw_query:j,completed_params:he}),me()},[fe,F,d,me,Fe]);G.current=Se;let st=Te(y=>{y.target?.closest("[data-aia-pill]")||ge()},[ge]),lt=f==="inline",dt=f==="dropdown";return Be("div",{ref:B,className:`magicx-aia ${te.container} ${t??""}`,"data-pill-placement":f,"data-options-position":R,"data-animations":I?"on":"off","data-mode":Kt(x),children:[re(Ce,{...nt,showPills:dt}),Be("div",{className:te.inputWrapper,onClick:st,children:[Be("div",{className:te.editorArea,"data-aia-editor":"",children:[re("div",{...rt,className:te.input,"data-aia-input":""}),lt&&(_||O.length>0)&&re("span",{ref:E,className:te.pillListContainer,"data-aia-pill-list-container":"",children:re(ve,{pills:O,activePillIndex:0,activeSelected:h,onSelectPill:g,loading:_})})]}),m===null?null:m===void 0?re(Ze,{disabled:!fe,onClick:Se}):re("span",{"data-aia-submit":"",className:te.submitSlot,onClick:y=>{fe&&(y.stopPropagation(),Se())},children:m})]})]})});export{Wt as AIAutocomplete,Ce as AIAutocompleteDropdown,De as useAIAutocomplete};
998
1040
  //# sourceMappingURL=index.mjs.map