@magicx-eng/ai-autocomplete-react 0.5.0 → 0.5.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.
package/dist/index.d.mts CHANGED
@@ -168,8 +168,6 @@ interface AIAutocompleteDropdownProps {
168
168
  activeSelected?: boolean;
169
169
  /** True while a fetch for the latest query is in flight. Replaces options/pills with a skeleton. */
170
170
  isLoading?: boolean;
171
- /** Once the user has tabbed to highlight an option, the footer hint switches from "tab to select" to "→ to skip". Provided by `dropdownProps` from the hook. */
172
- hasTabbedToHighlight?: boolean;
173
171
  /** When the input has no typed text, the footer hint reads "tab to select". Provided by `dropdownProps` from the hook. */
174
172
  isInputEmpty?: boolean;
175
173
  /**
@@ -195,7 +193,7 @@ interface AIAutocompleteDropdownProps {
195
193
 
196
194
  declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
197
195
 
198
- declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, activeSelected, isLoading, hasTabbedToHighlight, isInputEmpty, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
196
+ declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, activeSelected, isLoading, isInputEmpty, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
199
197
 
200
198
  declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
201
199
 
package/dist/index.d.ts CHANGED
@@ -168,8 +168,6 @@ interface AIAutocompleteDropdownProps {
168
168
  activeSelected?: boolean;
169
169
  /** True while a fetch for the latest query is in flight. Replaces options/pills with a skeleton. */
170
170
  isLoading?: boolean;
171
- /** Once the user has tabbed to highlight an option, the footer hint switches from "tab to select" to "→ to skip". Provided by `dropdownProps` from the hook. */
172
- hasTabbedToHighlight?: boolean;
173
171
  /** When the input has no typed text, the footer hint reads "tab to select". Provided by `dropdownProps` from the hook. */
174
172
  isInputEmpty?: boolean;
175
173
  /**
@@ -195,7 +193,7 @@ interface AIAutocompleteDropdownProps {
195
193
 
196
194
  declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProps & react.RefAttributes<AIAutocompleteHandle>>;
197
195
 
198
- declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, activeSelected, isLoading, hasTabbedToHighlight, isInputEmpty, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
196
+ declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, activeSelected, isLoading, isInputEmpty, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
199
197
 
200
198
  declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
201
199
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Re=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var mt=(e,o)=>{for(var a in o)Re(e,a,{get:o[a],enumerable:!0})},gt=(e,o,a,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of pt(o))!ut.call(e,t)&&t!==a&&Re(e,t,{get:()=>o[t],enumerable:!(l=ct(o,t))||l.enumerable});return e};var ft=e=>gt(Re({},"__esModule",{value:!0}),e);var _t={};mt(_t,{AIAutocomplete:()=>tt,AIAutocompleteDropdown:()=>Ie,useAIAutocomplete:()=>Ae});module.exports=ft(_t);var S=require("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
+ "use strict";var Re=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var mt=(e,t)=>{for(var o in t)Re(e,o,{get:t[o],enumerable:!0})},gt=(e,t,o,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of pt(t))!ut.call(e,a)&&a!==o&&Re(e,a,{get:()=>t[a],enumerable:!(l=ct(t,a))||l.enumerable});return e};var ft=e=>gt(Re({},"__esModule",{value:!0}),e);var _t={};mt(_t,{AIAutocomplete:()=>tt,AIAutocompleteDropdown:()=>Ie,useAIAutocomplete:()=>Ae});module.exports=ft(_t);var S=require("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
@@ -8,7 +8,7 @@
8
8
  }
9
9
 
10
10
  .AIAutocomplete-module_inputWrapper_FLq1b {
11
- padding: 12px 10px;
11
+ padding: 12px 16px;
12
12
  border: 1px solid var(--aia-border, #b0b0b0);
13
13
  border-radius: 20px;
14
14
  background: var(--aia-surface, #ffffff);
@@ -414,7 +414,7 @@
414
414
  justify-content: space-around;
415
415
  }
416
416
  }
417
- `,document.head.appendChild(e)}var Te=require("react/jsx-runtime");function fe({gap:e,align:o="center",justify:a="start",noWrap:l=!1,inline:t=!1,className:n,children:d,...c}){let g=e?{"--aia-cluster-gap":e}:void 0,x={className:n?`aia-cluster ${n}`:"aia-cluster","data-align":o,"data-justify":a,"data-nowrap":l||void 0,"data-inline":t||void 0,style:g,...c};return t?(0,Te.jsx)("span",{...x,children:d}):(0,Te.jsx)("div",{...x,children:d})}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
417
+ `,document.head.appendChild(e)}var Le=require("react/jsx-runtime");function fe({gap:e,align:t="center",justify:o="start",noWrap:l=!1,inline:a=!1,className:n,children:d,...c}){let h=e?{"--aia-cluster-gap":e}:void 0,v={className:n?`aia-cluster ${n}`:"aia-cluster","data-align":t,"data-justify":o,"data-nowrap":l||void 0,"data-inline":a||void 0,style:h,...c};return a?(0,Le.jsx)("span",{...v,children:d}):(0,Le.jsx)("div",{...v,children:d})}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
418
  section gap above and its own 8px gap provide the vertical rhythm), so the
419
419
  divider spans the full footer width yet still stays clear of the dropdown's
420
420
  rounded edges. */
@@ -487,11 +487,11 @@
487
487
  line-height: 18px;
488
488
  color: var(--aia-footer-brand-color, #b0b0b0);
489
489
  }
490
- `,document.head.appendChild(e)}var te={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"};var j=require("react/jsx-runtime");function We({hasTabbedToHighlight:e=!1,isOptionHighlighted:o=!1,isInputEmpty:a=!1}){let{key:l,hint:t}=(0,Ke.getFooterHint)(e,o,a);return(0,j.jsxs)("footer",{className:te.footer,"data-aia-footer":"",children:[(0,j.jsx)("div",{className:te.divider}),(0,j.jsxs)(fe,{justify:"between",noWrap:!0,children:[(0,j.jsxs)(fe,{gap:"5px",className:te.hintGroup,children:[(0,j.jsx)("kbd",{className:te.key,children:l}),(0,j.jsx)("span",{className:te.hint,children:t})]}),(0,j.jsxs)("a",{className:te.brandLink,href:"https://ai-autocomplete.com",target:"_blank",rel:"noopener noreferrer",children:[(0,j.jsx)("span",{className:te.brand,children:"AI"}),(0,j.jsx)("span",{className:te.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- {
490
+ `,document.head.appendChild(e)}var Y={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"};var G=require("react/jsx-runtime");function We({isOptionHighlighted:e=!1,isInputEmpty:t=!1}){let{key:o,hint:l}=(0,Ke.getFooterHint)(e,t);return(0,G.jsxs)("footer",{className:Y.footer,"data-aia-footer":"",children:[(0,G.jsx)("div",{className:Y.divider}),(0,G.jsxs)(fe,{justify:"between",noWrap:!0,children:[(0,G.jsxs)(fe,{gap:"5px",className:Y.hintGroup,children:[(0,G.jsx)("kbd",{className:Y.key,children:o}),(0,G.jsx)("span",{className:Y.hint,children:l})]}),(0,G.jsxs)("a",{className:Y.brandLink,href:"https://ai-autocomplete.com",target:"_blank",rel:"noopener noreferrer",children:[(0,G.jsx)("span",{className:Y.brand,children:"AI"}),(0,G.jsx)("span",{className:Y.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
491
  display: inline-flex;
492
492
  align-items: center;
493
493
  justify-content: center;
494
- padding: 7px 8px;
494
+ padding: 7px 10px;
495
495
  border: none;
496
496
  border-radius: 999px;
497
497
  background: rgba(49, 50, 85, 0.25);
@@ -539,7 +539,7 @@
539
539
  opacity: 0;
540
540
  }
541
541
  }
542
- `,document.head.appendChild(e)}var oe={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"};var je=require("react/jsx-runtime"),Le={selected:1,first:.7,next:.4,last:.2};function Ge({label:e,state:o,selected:a,rounded:l,loading:t,onClick:n}){let d=[oe.pill,l?oe.rounded:"",a&&!t?oe.active:"",t?oe.skeleton:""].filter(Boolean).join(" ");return(0,je.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":t?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:d,style:{opacity:Le[o]},onMouseDown:c=>c.preventDefault(),onClick:t?void 0:n,disabled:t,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 {
542
+ `,document.head.appendChild(e)}var ee={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"};var je=require("react/jsx-runtime"),Te={selected:1,first:.7,next:.4,last:.2};function Ge({label:e,state:t,selected:o,rounded:l,loading:a,onClick:n}){let d=[ee.pill,l?ee.rounded:"",o&&!a?ee.active:"",a?ee.skeleton:""].filter(Boolean).join(" ");return(0,je.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:d,style:{opacity:Te[t]},onMouseDown:c=>c.preventDefault(),onClick:a?void 0:n,disabled:a,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
543
  position: relative;
544
544
  z-index: 1;
545
545
  pointer-events: auto;
@@ -549,7 +549,7 @@
549
549
  align-items: center;
550
550
  vertical-align: middle;
551
551
  }
552
- `,document.head.appendChild(e)}var Be={list:"PillList-module_list_qvLqO"};var he=require("react/jsx-runtime"),ht=[125,69];function Ve(e){return e===0?"first":e===1?"next":"last"}function ke({pills:e,activePillIndex:o,onSelectPill:a,activeSelected:l,rounded:t,loading:n}){return n&&e.length===0?(0,he.jsx)("span",{className:Be.list,"data-aia-pill-list-loading":"",children:ht.map((d,c)=>(0,he.jsx)("span",{"data-aia-pill-skeleton":"",className:`${oe.pill} ${t?oe.rounded:""} ${oe.skeleton}`,style:{width:d,opacity:Le[Ve(c)]}},`skel-${d}`))}):(0,he.jsx)("span",{className:Be.list,"data-aia-pill-list-loading":n?"":void 0,children:e.map((d,c)=>{let g=!!l&&c===o;return(0,he.jsx)(Ge,{label:d.text,state:g?"selected":Ve(c),selected:g,rounded:t,loading:n,onClick:()=>a(c)},`${d.type}-${d.text}`)})})}var ie=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
552
+ `,document.head.appendChild(e)}var Be={list:"PillList-module_list_qvLqO"};var he=require("react/jsx-runtime"),ht=[125,69];function Ve(e){return e===0?"first":e===1?"next":"last"}function ke({pills:e,activePillIndex:t,onSelectPill:o,activeSelected:l,rounded:a,loading:n}){return n&&e.length===0?(0,he.jsx)("span",{className:Be.list,"data-aia-pill-list-loading":"",children:ht.map((d,c)=>(0,he.jsx)("span",{"data-aia-pill-skeleton":"",className:`${ee.pill} ${a?ee.rounded:""} ${ee.skeleton}`,style:{width:d,opacity:Te[Ve(c)]}},`skel-${d}`))}):(0,he.jsx)("span",{className:Be.list,"data-aia-pill-list-loading":n?"":void 0,children:e.map((d,c)=>{let h=!!l&&c===t;return(0,he.jsx)(Ge,{label:d.text,state:h?"selected":Ve(c),selected:h,rounded:a,loading:n,onClick:()=>o(c)},`${d.type}-${d.text}`)})})}var ne=require("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
553
  .aia-grid {
554
554
  display: grid;
555
555
  grid-template-columns: repeat(
@@ -603,7 +603,7 @@
603
603
  opacity: 1;
604
604
  }
605
605
  }
606
- `,document.head.appendChild(e)}var ze=require("react/jsx-runtime");function qe({min:e="16rem",max:o,gap:a,scroll:l=!1,maxHeight:t,fade:n=!1,className:d,children:c,...g}){let x=(0,ie.useRef)(null),[B,P]=(0,ie.useState)(!1);(0,ie.useEffect)(()=>{if(!n)return;let w=x.current;if(!w)return;let z=()=>{P(w.scrollHeight-w.scrollTop-w.clientHeight>1)};w.addEventListener("scroll",z,{passive:!0});let H=new ResizeObserver(z);return H.observe(w),()=>{w.removeEventListener("scroll",z),H.disconnect()}},[n]),(0,ie.useLayoutEffect)(()=>{let w=x.current;!n||!w||P(w.scrollHeight-w.scrollTop-w.clientHeight>1)},[n,c]);let A={"--aia-grid-min":e};o&&(A["--aia-grid-max"]=o),a&&(A["--aia-grid-gap"]=a),t&&(A["--aia-grid-max-height"]=t);let C=(0,ze.jsx)("div",{ref:x,className:!n&&d?`aia-grid ${d}`:"aia-grid","data-scroll":l||void 0,style:A,...n?{}:g,children:c});return n?(0,ze.jsx)("div",{className:d?`aia-grid-fade ${d}`:"aia-grid-fade","data-fade":B?"":void 0,...g,children:C}):C}var pe=require("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 {
606
+ `,document.head.appendChild(e)}var ze=require("react/jsx-runtime");function qe({min:e="16rem",max:t,gap:o,scroll:l=!1,maxHeight:a,fade:n=!1,className:d,children:c,...h}){let v=(0,ne.useRef)(null),[B,P]=(0,ne.useState)(!1);(0,ne.useEffect)(()=>{if(!n)return;let w=v.current;if(!w)return;let R=()=>{P(w.scrollHeight-w.scrollTop-w.clientHeight>1)};w.addEventListener("scroll",R,{passive:!0});let H=new ResizeObserver(R);return H.observe(w),()=>{w.removeEventListener("scroll",R),H.disconnect()}},[n]),(0,ne.useLayoutEffect)(()=>{let w=v.current;!n||!w||P(w.scrollHeight-w.scrollTop-w.clientHeight>1)},[n,c]);let A={"--aia-grid-min":e};t&&(A["--aia-grid-max"]=t),o&&(A["--aia-grid-gap"]=o),a&&(A["--aia-grid-max-height"]=a);let C=(0,ze.jsx)("div",{ref:v,className:!n&&d?`aia-grid ${d}`:"aia-grid","data-scroll":l||void 0,style:A,...n?{}:h,children:c});return n?(0,ze.jsx)("div",{className:d?`aia-grid-fade ${d}`:"aia-grid-fade","data-fade":B?"":void 0,...h,children:C}):C}var pe=require("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
607
  position: relative;
608
608
  overflow: visible;
609
609
  display: flex;
@@ -650,7 +650,7 @@
650
650
  .SuggestionItem-module_highlighted_Hb0SU {
651
651
  color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
652
652
  background: var(--aia-option-bg, transparent);
653
- font-weight: 700;
653
+ font-weight: 500;
654
654
  }
655
655
 
656
656
  .SuggestionItem-module_tag_e3Fwe {
@@ -953,7 +953,7 @@
953
953
  filter: brightness(0.55);
954
954
  }
955
955
  }
956
- `,document.head.appendChild(e)}var V={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"};var re=require("react/jsx-runtime");function $e({option:e,isHighlighted:o,onSelect:a,onHighlight:l,id:t,loading:n}){let[d,c]=(0,pe.useState)(!1),g=(0,pe.useRef)(void 0);(0,pe.useEffect)(()=>()=>clearTimeout(g.current),[]);let x=()=>{n||!e.is_tappable||d||(c(!0),a(e),clearTimeout(g.current),g.current=setTimeout(()=>c(!1),500))},B=[V.item,o&&!n?V.highlighted:"",e.is_tappable?V.tappable:V.nonTappable,d?V.pressed:""].filter(Boolean).join(" ");return(0,re.jsxs)("div",{id:t,role:"option","data-aia-option":"","data-aia-loading":n?"":void 0,"aria-selected":o,className:B,tabIndex:n||!e.is_tappable?-1:0,onClick:x,onKeyDown:P=>{!n&&e.is_tappable&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),x())},onMouseEnter:!n&&e.is_tappable?l:void 0,children:[(0,re.jsx)("div",{className:V.streaks}),(0,re.jsx)("div",{className:V.streaksVert}),(0,re.jsxs)("span",{className:V.content,children:[(0,re.jsx)("span",{className:V.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,re.jsx)("span",{className:V.tag,children:e.tag})]})]})}var Fe=require("react/jsx-runtime");function Ue({options:e,activeIndex:o,onSelect:a,onHighlight:l,listboxId:t,loading:n}){return(0,Fe.jsx)(qe,{min:"250px",max:"250px",gap:"0",scroll:!0,fade:!0,children:e.map((d,c)=>(0,Fe.jsx)($e,{option:d,isHighlighted:c===o,onSelect:a,onHighlight:()=>l(c),id:`${t}-option-${c}`,loading:n},d.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
956
+ `,document.head.appendChild(e)}var j={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"};var ie=require("react/jsx-runtime");function $e({option:e,isHighlighted:t,onSelect:o,onHighlight:l,id:a,loading:n}){let[d,c]=(0,pe.useState)(!1),h=(0,pe.useRef)(void 0);(0,pe.useEffect)(()=>()=>clearTimeout(h.current),[]);let v=()=>{n||!e.is_tappable||d||(c(!0),o(e),clearTimeout(h.current),h.current=setTimeout(()=>c(!1),500))},B=[j.item,t&&!n?j.highlighted:"",e.is_tappable?j.tappable:j.nonTappable,d?j.pressed:""].filter(Boolean).join(" ");return(0,ie.jsxs)("div",{id:a,role:"option","data-aia-option":"","data-aia-loading":n?"":void 0,"aria-selected":t,className:B,tabIndex:n||!e.is_tappable?-1:0,onClick:v,onKeyDown:P=>{!n&&e.is_tappable&&(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),v())},onMouseEnter:!n&&e.is_tappable?l:void 0,children:[(0,ie.jsx)("div",{className:j.streaks}),(0,ie.jsx)("div",{className:j.streaksVert}),(0,ie.jsxs)("span",{className:j.content,children:[(0,ie.jsx)("span",{className:j.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,ie.jsx)("span",{className:j.tag,children:e.tag})]})]})}var Fe=require("react/jsx-runtime");function Ue({options:e,activeIndex:t,onSelect:o,onHighlight:l,listboxId:a,loading:n}){return(0,Fe.jsx)(qe,{min:"250px",max:"250px",gap:"0",scroll:!0,fade:!0,children:e.map((d,c)=>(0,Fe.jsx)($e,{option:d,isHighlighted:c===t,onSelect:o,onHighlight:()=>l(c),id:`${a}-option-${c}`,loading:n},d.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
957
  .aia-stack {
958
958
  display: flex;
959
959
  flex-direction: column;
@@ -970,7 +970,7 @@
970
970
  }
971
971
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
972
972
  }
973
- `,document.head.appendChild(e)}var Xe=require("react/jsx-runtime");function Qe({space:e,align:o="stretch",className:a,children:l,...t}){let n=e?{"--aia-stack-space":e}:void 0;return(0,Xe.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":o,style:n,...t,children:l})}var Q=require("react/jsx-runtime"),bt=[159,119,164];function xt(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,l]=(0,ue.useState)(o);if((0,ue.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>l(t.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Ie({suggestions:e,activeIndex:o,onSelect:a,onHighlight:l,isOpen:t,id:n,className:d,pills:c,onPillClick:g,showPills:x=!0,activeSelected:B=!1,isLoading:P=!1,hasTabbedToHighlight:A=!1,isInputEmpty:C=!1,optionsPosition:w="below",mode:z}){let H=xt(z),X=H!==void 0,s=e[0]?.options??[],I=!!(c&&c.length>0&&g),O=t&&(s.length>0||x&&I||P),W={suggestions:e,activeIndex:o,pills:c,showPills:x,activeSelected:B,isLoading:P,hasTabbedToHighlight:A,isInputEmpty:C},M=(0,ue.useRef)(W);O&&(M.current=W);let f=O?W:M.current,E=f.suggestions[0]?.options??[],Z=f.activeIndex>=0&&!!E[f.activeIndex]?.is_tappable,T=!!(f.pills&&f.pills.length>0&&g),ae=f.showPills&&T,Y=f.showPills&&!T&&f.isLoading,$=ae||Y,N=E.length>0,v=f.isLoading&&!N;return(0,Q.jsx)("div",{id:n,role:"listbox","data-aia-dropdown":"","data-options-position":w,"data-mode":H,"data-aia-loading":f.isLoading?"":void 0,className:`${X?"magicx-aia ":""}${ce.dropdown} ${O?ce.visible:""} ${d??""}`,onMouseDown:K=>K.preventDefault(),children:(0,Q.jsxs)(Qe,{space:"8px",children:[$&&(0,Q.jsx)(fe,{noWrap:!0,className:ce.pillBar,"data-aia-pillbar":"",children:(0,Q.jsx)(ke,{pills:f.pills??[],activePillIndex:0,activeSelected:f.activeSelected,onSelectPill:g??(()=>{}),rounded:!0,loading:f.isLoading})}),N&&(0,Q.jsx)(Ue,{options:E,activeIndex:f.activeIndex,onSelect:a,onHighlight:l,listboxId:n,loading:f.isLoading}),v&&(0,Q.jsx)("div",{className:ce.skeletonBars,"data-aia-skeleton-bars":"",children:bt.map(K=>(0,Q.jsx)("span",{className:ce.skeletonBar,style:{width:K}},`bar-${K}`))}),(0,Q.jsx)(We,{hasTabbedToHighlight:f.hasTabbedToHighlight,isOptionHighlighted:Z,isInputEmpty:f.isInputEmpty})]})})}var me=require("@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 {
973
+ `,document.head.appendChild(e)}var Xe=require("react/jsx-runtime");function Qe({space:e,align:t="stretch",className:o,children:l,...a}){let n=e?{"--aia-stack-space":e}:void 0;return(0,Xe.jsx)("div",{className:o?`aia-stack ${o}`:"aia-stack","data-align":t,style:n,...a,children:l})}var Q=require("react/jsx-runtime"),bt=[159,119,164];function xt(e){let t=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[o,l]=(0,ue.useState)(t);if((0,ue.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let a=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>l(a.matches);return a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[e]),e!==void 0)return e==="auto"?o?"dark":"light":e}function Ie({suggestions:e,activeIndex:t,onSelect:o,onHighlight:l,isOpen:a,id:n,className:d,pills:c,onPillClick:h,showPills:v=!0,activeSelected:B=!1,isLoading:P=!1,isInputEmpty:A=!1,optionsPosition:C="below",mode:w}){let R=xt(w),H=R!==void 0,X=e[0]?.options??[],s=!!(c&&c.length>0&&h),y=a&&(X.length>0||v&&s||P),O={suggestions:e,activeIndex:t,pills:c,showPills:v,activeSelected:B,isLoading:P,isInputEmpty:A},q=(0,ue.useRef)(O);y&&(q.current=O);let g=y?O:q.current,M=g.suggestions[0]?.options??[],L=g.activeIndex>=0&&!!M[g.activeIndex]?.is_tappable,$=!!(g.pills&&g.pills.length>0&&h),z=g.showPills&&$,oe=g.showPills&&!$&&g.isLoading,J=z||oe,N=M.length>0,K=g.isLoading&&!N;return(0,Q.jsx)("div",{id:n,role:"listbox","data-aia-dropdown":"","data-options-position":C,"data-mode":R,"data-aia-loading":g.isLoading?"":void 0,className:`${H?"magicx-aia ":""}${ce.dropdown} ${y?ce.visible:""} ${d??""}`,onMouseDown:f=>f.preventDefault(),children:(0,Q.jsxs)(Qe,{space:"8px",children:[J&&(0,Q.jsx)(fe,{noWrap:!0,className:ce.pillBar,"data-aia-pillbar":"",children:(0,Q.jsx)(ke,{pills:g.pills??[],activePillIndex:0,activeSelected:g.activeSelected,onSelectPill:h??(()=>{}),rounded:!0,loading:g.isLoading})}),N&&(0,Q.jsx)(Ue,{options:M,activeIndex:g.activeIndex,onSelect:o,onHighlight:l,listboxId:n,loading:g.isLoading}),K&&(0,Q.jsx)("div",{className:ce.skeletonBars,"data-aia-skeleton-bars":"",children:bt.map(f=>(0,Q.jsx)("span",{className:ce.skeletonBar,style:{width:f}},`bar-${f}`))}),(0,Q.jsx)(We,{isOptionHighlighted:L,isInputEmpty:g.isInputEmpty})]})})}var me=require("@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
974
  flex-shrink: 0;
975
975
  width: 32px;
976
976
  height: 32px;
@@ -994,5 +994,5 @@
994
994
  opacity: 0.4;
995
995
  cursor: default;
996
996
  }
997
- `,document.head.appendChild(e)}var Je={submitButton:"SubmitButton-module_submitButton_otz7H"};var Se=require("react/jsx-runtime");function Ze({disabled:e,onClick:o}){return(0,Se.jsx)("button",{type:"button","data-aia-submit":"",className:Je.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":"Submit",children:(0,Se.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Se.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ye=require("@magicx-eng/ai-autocomplete-vanilla"),_=require("react"),vt={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,hasTabbedToHighlight:!1};function Ae({onSubmit:e,onError:o,optionOverrides:a,maskCompletedText:l,apiConfig:t,columns:n=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:g,showNonTappableOptions:x,onFocus:B,onBlur:P,value:A,completedParams:C,onChange:w,onParamsChange:z,source:H,setCursor:X}){let s=(0,_.useRef)(null),[I,O]=(0,_.useState)(null),W=(0,_.useRef)(e);W.current=e;let M=(0,_.useRef)(o);M.current=o;let f=(0,_.useRef)(w);f.current=w;let J=(0,_.useRef)(z);J.current=z;let E=(0,_.useRef)(B);E.current=B;let Z=(0,_.useRef)(P);Z.current=P;let T=(0,_.useRef)(X);T.current=X,(0,_.useEffect)(()=>{if(typeof document>"u")return;let r=new Ye.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:t,optionOverrides:a,maskCompletedText:l,columns:n,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:g,showNonTappableOptions:x,source:H,value:A,completedParams:C,onSubmit:(...D)=>W.current?.(...D),onError:(...D)=>M.current?.(...D),onChange:(...D)=>f.current?.(...D),onParamsChange:(...D)=>J.current?.(...D),onFocus:()=>E.current?.(),onBlur:()=>Z.current?.(),setCursor:D=>T.current?.(D)});s.current=r,O(r.getState());let R=r.subscribe(D=>O(D));return()=>{R(),r.destroy(),s.current===r&&(s.current=null)}},[]),(0,_.useEffect)(()=>{A!==void 0&&s.current?.setValue(A)},[A]),(0,_.useEffect)(()=>{C!==void 0&&s.current?.setCompletedParams(C)},[C]);let ae=JSON.stringify(t??null),Y=(0,_.useRef)(a),$=(0,_.useRef)(0);if(a!==Y.current){let r=Y.current,R=a,D=Object.keys(r??{}),de=Object.keys(R??{});(D.length!==de.length||de.some(ge=>!r?.[ge]||R[ge]!==r[ge]))&&$.current++,Y.current=a}(0,_.useEffect)(()=>{s.current?.update({apiConfig:t,optionOverrides:a,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:g,showNonTappableOptions:x})},[ae,$.current,d,c,g,x]);let N=(0,_.useRef)(null);N.current===null&&(N.current={handleTextChange:r=>s.current?.handleTextChange(r),handleKeyDown:r=>{let R="nativeEvent"in r?r.nativeEvent:r;s.current?.handleKeyDown(R)},setFocused:r=>s.current?.setFocused(r),startEditingParam:r=>s.current?.startEditingParam(r),exitEditMode:()=>s.current?.exitEditMode(),handleCaretAfterInput:r=>s.current?.handleCaretAfterInput(r),handleCaretMove:r=>s.current?.handleCaretMove(r),replaceEditingRange:r=>s.current?.replaceEditingRange(r)??!1,setActivePill:r=>s.current?.setActivePill(r),removeLastParam:()=>s.current?.removeLastParam(),clearNewParamId:()=>s.current?.clearNewParamId(),reset:()=>s.current?.reset(),selectOption:r=>s.current?.selectOption(r),setActiveDropdownIndex:r=>s.current?.setActiveDropdownIndex(r),handleFocus:()=>s.current?.setFocused(!0),handleBlur:()=>s.current?.setFocused(!1)});let v=N.current,K=(0,_.useCallback)(r=>{let R=r.target.value,de=R.length>0&&!r.nativeEvent?.isComposing&&R[0]!==R[0].toUpperCase()?R[0].toUpperCase()+R.slice(1):R;s.current?.handleTextChange(de)},[]),se=(0,_.useCallback)(r=>{s.current?.handleKeyDown(r.nativeEvent)},[]),ne=s.current,p=I??vt,i=A!==void 0?A:p.text,u=C!==void 0?C:p.completedParams,h=p.actionableSuggestions,k=h[0],b=ne?.listboxId??"",L=p.activeDropdownIndex>=0&&ne?`${b}-option-${p.activeDropdownIndex}`:void 0,G=p.editingParam,ee=G?{type:G.suggestionType,text:G.suggestionPlaceholder,required:!0,options:G.options}:null,be=ee??k,Ce=ee?[ee]:h,xe=!ne||p.isLoading&&!p.editingParam&&!p.inSelectionAnimation;return{completedParams:u,suggestionPills:h,setActivePill:v.setActivePill,removeLastParam:v.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:v.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:xe,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:b,error:p.error,handleTextChange:v.handleTextChange,handleKeyDown:v.handleKeyDown,setFocused:v.setFocused,editingParam:G,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:v.startEditingParam,exitEditMode:v.exitEditMode,handleCaretAfterInput:v.handleCaretAfterInput,handleCaretMove:v.handleCaretMove,replaceEditingRange:v.replaceEditingRange,inputProps:{value:i,placeholder:p.placeholderText||void 0,onChange:K,onKeyDown:se,onFocus:v.handleFocus,onBlur:v.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":L,"aria-autocomplete":"list","aria-controls":b},reset:v.reset,dropdownProps:{suggestions:be?[{...be,options:p.filteredOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:v.selectOption,onHighlight:v.setActiveDropdownIndex,isOpen:p.isDropdownOpen,id:b,pills:Ce,activeSelected:p.isActivePillSelected,onPillClick:v.setActivePill,isLoading:xe,hasTabbedToHighlight:p.hasTabbedToHighlight,isInputEmpty:i.trim().length===0,optionsPosition:c??"below"}}}var F=require("@magicx-eng/ai-autocomplete-vanilla"),m=require("react"),Pe;function wt(){if(Pe!==void 0)return Pe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Pe=e.contentEditable==="plaintext-only",Pe}function et(e){let{segments:o,newParamId:a,editingParam:l,editingAnchor:t,caretOffset:n,placeholderText:d,isFocused:c,isDropdownOpen:g,listboxId:x,activeDescendantId:B,autoFocus:P,handleTextChange:A,handleKeyDown:C,handleCaretAfterInput:w,handleCaretMove:z,startEditingParam:H,replaceEditingRange:X,setFocused:s}=e,I=(0,m.useRef)(null),O=(0,m.useRef)(!1),W=(0,m.useRef)(""),M=(0,m.useRef)(""),f=(0,m.useRef)(null),J=(0,m.useRef)(0);f.current=n,(0,m.useEffect)(()=>{if(!P)return;let i=I.current;i&&(document.activeElement===i?s(!0):i.focus())},[P,s]),(0,m.useEffect)(()=>{let i=I.current;if(!i)return;let u=i.ownerDocument??document,h=()=>{let k=u.getSelection();if(!k||k.rangeCount===0||!k.anchorNode||!i.contains(k.anchorNode))return;let b=k.anchorNode,ee=(b.nodeType===Node.ELEMENT_NODE?b:b.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(ee&&ee!==l?.id){H(ee);return}performance.now()-J.current<50||z((0,F.getCursorOffset)(i))};return u.addEventListener("selectionchange",h),()=>u.removeEventListener("selectionchange",h)},[l,H,z]),(0,m.useLayoutEffect)(()=>{let i=I.current;i&&(0,F.renderEditableContent)({input:i,segments:o,newParamId:a,editingParamId:l?.id??null,placeholderText:d??"",isFocused:c})},[o,a,l,d,c]),(0,m.useLayoutEffect)(()=>{let i=W.current,u=a??"";if(W.current=u,!u||u===i)return;let h=I.current;if(!h)return;h.focus();let k=f.current??(0,F.plainTextLength)(h);(0,F.setCursorOffset)(h,k)},[a]),(0,m.useLayoutEffect)(()=>{let i=M.current,u=l?.id??"";if(M.current=u,!u||u===i||t==null)return;let h=I.current;h&&(0,F.setCursorOffset)(h,t)},[l,t]);let E=(0,m.useCallback)(()=>{if(O.current)return;let i=I.current;if(!i)return;let u=(0,F.extractPlainText)(i),k=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;A(k)},[A]),Z=(0,m.useCallback)(()=>{J.current=performance.now(),E();let i=I.current;i&&w((0,F.getCursorOffset)(i))},[E,w]);(0,m.useEffect)(()=>{let i=I.current;if(!i)return;let u=h=>{let k=h,b=k.inputType;if(b==="insertParagraph"||b==="insertLineBreak"||b==="insertFromDrop"){h.preventDefault();return}if(b.startsWith("insert")||b.startsWith("delete")){let L=b.startsWith("delete")?"":k.data??"";X(L)&&h.preventDefault()}};return i.addEventListener("beforeinput",u),()=>i.removeEventListener("beforeinput",u)},[X]);let T=(0,m.useCallback)(()=>{O.current=!0},[]),ae=(0,m.useCallback)(()=>{O.current=!1,E()},[E]),Y=(0,m.useCallback)(i=>{i.preventDefault();let u=I.current;if(!u)return;let h=(i.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let k=u.ownerDocument??document,b=k.getSelection();if(!b||b.rangeCount===0)return;let L=b.getRangeAt(0);if(!u.contains(L.startContainer))return;L.deleteContents();let G=k.createTextNode(h);L.insertNode(G),L.setStartAfter(G),L.collapse(!0),b.removeAllRanges(),b.addRange(L),E()},[E]),$=(0,m.useCallback)(i=>C(i),[C]),N=(0,m.useCallback)(()=>s(!0),[s]),v=(0,m.useCallback)(()=>s(!1),[s]),K=(0,m.useCallback)(()=>I.current?.focus(),[]),se=(0,m.useCallback)(()=>I.current?.blur(),[]),ne=(0,m.useCallback)(()=>{let i=I.current;return i?(0,F.extractPlainText)(i):""},[]),p=wt()?"plaintext-only":"true";return{inputRef:I,editorProps:{ref:I,contentEditable:p,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":x,"aria-expanded":g,"aria-activedescendant":B,spellCheck:!0,enterKeyHint:"send",onInput:Z,onKeyDown:$,onCompositionStart:T,onCompositionEnd:ae,onPaste:Y,onFocus:N,onBlur:v},getPlainText:ne,focus:K,blur:se}}var q=require("react/jsx-runtime");function yt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var tt=(0,S.forwardRef)(function({onSubmit:o,onError:a,optionOverrides:l,maskCompletedText:t,className:n,apiConfig:d,columns:c,pillPlacement:g="inline",mode:x="auto",optionsPosition:B="below",animations:P=!0,dropdownTrigger:A,closeDropdownOnBlur:C,showNonTappableOptions:w,autoFocus:z=!0,onFocus:H,onBlur:X,value:s,completedParams:I,onChange:O,onParamsChange:W,submitButton:M},f){let J=(0,S.useRef)(null),E=(0,S.useRef)(null),Z=(0,S.useRef)(()=>{}),T=(0,S.useRef)(null),ae=(0,S.useRef)(null);(0,S.useEffect)(()=>{let y=J.current;if(y)return T.current?T.current.setMode(x):T.current=new me.ModeController(y,x),()=>{T.current?.destroy(),T.current=null}},[x]);let Y=(0,S.useCallback)(y=>{let U=ae.current?.current;U&&(U.focus(),(0,me.setCursorOffset)(U,y))},[]),{completedParams:$,suggestionPills:N,setActivePill:v,segments:K,newParamId:se,clearNewParamId:ne,placeholderText:p,isFocused:i,isDropdownOpen:u,isActivePillSelected:h,isLoading:k,activeIndex:b,listboxId:L,handleTextChange:G,handleKeyDown:ee,setFocused:be,editingParam:Ce,editingAnchor:xe,caretOffset:r,startEditingParam:R,handleCaretAfterInput:D,handleCaretMove:de,replaceEditingRange:ge,dropdownProps:ot,reset:ve}=Ae({onSubmit:y=>Z.current(y),onError:a,optionOverrides:l,maskCompletedText:t,apiConfig:d,columns:c,dropdownTrigger:A,optionsPosition:B,closeDropdownOnBlur:C,showNonTappableOptions:w,onFocus:H,onBlur:X,value:s,completedParams:I,onChange:O,onParamsChange:W,source:"full-sdk",setCursor:Y});(0,S.useEffect)(()=>{if(!se)return;let y=window.setTimeout(()=>ne(),650);return()=>window.clearTimeout(y)},[se,ne]);let at=b>=0?`${L}-option-${b}`:void 0,{inputRef:Ee,editorProps:nt,focus:we,blur:He,getPlainText:Oe}=et({segments:K,newParamId:se,editingParam:Ce,editingAnchor:xe,caretOffset:r,placeholderText:p,isFocused:i,isDropdownOpen:u,listboxId:L,activeDescendantId:at,autoFocus:z,handleTextChange:G,handleKeyDown:ee,handleCaretAfterInput:D,handleCaretMove:de,startEditingParam:R,replaceEditingRange:ge,setFocused:be});ae.current=Ee,(0,S.useLayoutEffect)(()=>{let y=E.current,U=Ee.current;if(!y||!U)return;let _e=()=>{let Ne=y.firstElementChild;if(!Ne)return;let lt=Ne.getBoundingClientRect(),dt=U.getBoundingClientRect();lt.top>=dt.bottom-2?y.setAttribute("data-aia-pill-wrapped",""):y.removeAttribute("data-aia-pill-wrapped")};_e();let Me=new ResizeObserver(_e);return Me.observe(U),()=>Me.disconnect()},[K,N.length,k,Ee]),(0,S.useImperativeHandle)(f,()=>({focus:we,blur:He,reset:ve,setMode:y=>T.current?.setMode(y)}),[we,He,ve]);let ye=!!K.length||$.length>0,De=(0,S.useCallback)(()=>{if(!ye)return;let y=Oe(),{rawQuery:U,completedParams:_e}=(0,me.buildQuery)(y,$);o({query:y.trim(),raw_query:U,completed_params:_e}),ve()},[ye,$,o,ve,Oe]);Z.current=De;let it=(0,S.useCallback)(y=>{y.target?.closest("[data-aia-pill]")||we()},[we]),rt=g==="inline",st=g==="dropdown";return(0,q.jsxs)("div",{ref:J,className:`magicx-aia ${le.container} ${n??""}`,"data-pill-placement":g,"data-options-position":B,"data-animations":P?"on":"off","data-mode":yt(x),children:[(0,q.jsx)(Ie,{...ot,showPills:st}),(0,q.jsxs)("div",{className:le.inputWrapper,onClick:it,children:[(0,q.jsxs)("div",{className:le.editorArea,"data-aia-editor":"",children:[(0,q.jsx)("div",{...nt,className:le.input,"data-aia-input":""}),rt&&(k||N.length>0)&&(0,q.jsx)("span",{ref:E,className:le.pillListContainer,"data-aia-pill-list-container":"",children:(0,q.jsx)(ke,{pills:N,activePillIndex:0,activeSelected:h,onSelectPill:v,loading:k})})]}),M===null?null:M===void 0?(0,q.jsx)(Ze,{disabled:!ye,onClick:De}):(0,q.jsx)("span",{"data-aia-submit":"",className:le.submitSlot,onClick:y=>{ye&&(y.stopPropagation(),De())},children:M})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,useAIAutocomplete});
997
+ `,document.head.appendChild(e)}var Je={submitButton:"SubmitButton-module_submitButton_otz7H"};var Se=require("react/jsx-runtime");function Ze({disabled:e,onClick:t}){return(0,Se.jsx)("button",{type:"button","data-aia-submit":"",className:Je.submitButton,disabled:e,onClick:o=>{o.stopPropagation(),t()},"aria-label":"Submit",children:(0,Se.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Se.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ye=require("@magicx-eng/ai-autocomplete-vanilla"),k=require("react"),vt={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 Ae({onSubmit:e,onError:t,optionOverrides:o,maskCompletedText:l,apiConfig:a,columns:n=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:h,showNonTappableOptions:v,onFocus:B,onBlur:P,value:A,completedParams:C,onChange:w,onParamsChange:R,source:H,setCursor:X}){let s=(0,k.useRef)(null),[y,O]=(0,k.useState)(null),q=(0,k.useRef)(e);q.current=e;let g=(0,k.useRef)(t);g.current=t;let te=(0,k.useRef)(w);te.current=w;let M=(0,k.useRef)(R);M.current=R;let L=(0,k.useRef)(B);L.current=B;let $=(0,k.useRef)(P);$.current=P;let z=(0,k.useRef)(X);z.current=X,(0,k.useEffect)(()=>{if(typeof document>"u")return;let r=new Ye.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:a,optionOverrides:o,maskCompletedText:l,columns:n,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:h,showNonTappableOptions:v,source:H,value:A,completedParams:C,onSubmit:(...E)=>q.current?.(...E),onError:(...E)=>g.current?.(...E),onChange:(...E)=>te.current?.(...E),onParamsChange:(...E)=>M.current?.(...E),onFocus:()=>L.current?.(),onBlur:()=>$.current?.(),setCursor:E=>z.current?.(E)});s.current=r,O(r.getState());let D=r.subscribe(E=>O(E));return()=>{D(),r.destroy(),s.current===r&&(s.current=null)}},[]),(0,k.useEffect)(()=>{A!==void 0&&s.current?.setValue(A)},[A]),(0,k.useEffect)(()=>{C!==void 0&&s.current?.setCompletedParams(C)},[C]);let oe=JSON.stringify(a??null),J=(0,k.useRef)(o),N=(0,k.useRef)(0);if(o!==J.current){let r=J.current,D=o,E=Object.keys(r??{}),de=Object.keys(D??{});(E.length!==de.length||de.some(ge=>!r?.[ge]||D[ge]!==r[ge]))&&N.current++,J.current=o}(0,k.useEffect)(()=>{s.current?.update({apiConfig:a,optionOverrides:o,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:h,showNonTappableOptions:v})},[oe,N.current,d,c,h,v]);let K=(0,k.useRef)(null);K.current===null&&(K.current={handleTextChange:r=>s.current?.handleTextChange(r),handleKeyDown:r=>{let D="nativeEvent"in r?r.nativeEvent:r;s.current?.handleKeyDown(D)},setFocused:r=>s.current?.setFocused(r),startEditingParam:r=>s.current?.startEditingParam(r),exitEditMode:()=>s.current?.exitEditMode(),handleCaretAfterInput:r=>s.current?.handleCaretAfterInput(r),handleCaretMove:r=>s.current?.handleCaretMove(r),replaceEditingRange:r=>s.current?.replaceEditingRange(r)??!1,setActivePill:r=>s.current?.setActivePill(r),removeLastParam:()=>s.current?.removeLastParam(),clearNewParamId:()=>s.current?.clearNewParamId(),reset:()=>s.current?.reset(),selectOption:r=>s.current?.selectOption(r),setActiveDropdownIndex:r=>s.current?.setActiveDropdownIndex(r),handleFocus:()=>s.current?.setFocused(!0),handleBlur:()=>s.current?.setFocused(!1)});let f=K.current,re=(0,k.useCallback)(r=>{let D=r.target.value,de=D.length>0&&!r.nativeEvent?.isComposing&&D[0]!==D[0].toUpperCase()?D[0].toUpperCase()+D.slice(1):D;s.current?.handleTextChange(de)},[]),se=(0,k.useCallback)(r=>{s.current?.handleKeyDown(r.nativeEvent)},[]),ae=s.current,p=y??vt,i=A!==void 0?A:p.text,u=C!==void 0?C:p.completedParams,b=p.actionableSuggestions,I=b[0],x=ae?.listboxId??"",T=p.activeDropdownIndex>=0&&ae?`${x}-option-${p.activeDropdownIndex}`:void 0,W=p.editingParam,Z=W?{type:W.suggestionType,text:W.suggestionPlaceholder,required:!0,options:W.options}:null,be=Z??I,Ce=Z?[Z]:b,xe=!ae||p.isLoading&&!p.editingParam&&!p.inSelectionAnimation;return{completedParams:u,suggestionPills:b,setActivePill:f.setActivePill,removeLastParam:f.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:f.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:xe,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:x,error:p.error,handleTextChange:f.handleTextChange,handleKeyDown:f.handleKeyDown,setFocused:f.setFocused,editingParam:W,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:f.startEditingParam,exitEditMode:f.exitEditMode,handleCaretAfterInput:f.handleCaretAfterInput,handleCaretMove:f.handleCaretMove,replaceEditingRange:f.replaceEditingRange,inputProps:{value:i,placeholder:p.placeholderText||void 0,onChange:re,onKeyDown:se,onFocus:f.handleFocus,onBlur:f.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":T,"aria-autocomplete":"list","aria-controls":x},reset:f.reset,dropdownProps:{suggestions:be?[{...be,options:p.filteredOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:f.selectOption,onHighlight:f.setActiveDropdownIndex,isOpen:p.isDropdownOpen,id:x,pills:Ce,activeSelected:p.isActivePillSelected,onPillClick:f.setActivePill,isLoading:xe,isInputEmpty:i.trim().length===0,optionsPosition:c??"below"}}}var F=require("@magicx-eng/ai-autocomplete-vanilla"),m=require("react"),Pe;function wt(){if(Pe!==void 0)return Pe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Pe=e.contentEditable==="plaintext-only",Pe}function et(e){let{segments:t,newParamId:o,editingParam:l,editingAnchor:a,caretOffset:n,placeholderText:d,isFocused:c,isDropdownOpen:h,listboxId:v,activeDescendantId:B,autoFocus:P,handleTextChange:A,handleKeyDown:C,handleCaretAfterInput:w,handleCaretMove:R,startEditingParam:H,replaceEditingRange:X,setFocused:s}=e,y=(0,m.useRef)(null),O=(0,m.useRef)(!1),q=(0,m.useRef)(""),g=(0,m.useRef)(""),te=(0,m.useRef)(null),M=(0,m.useRef)(0);te.current=n,(0,m.useEffect)(()=>{if(!P)return;let i=y.current;i&&(document.activeElement===i?s(!0):i.focus())},[P,s]),(0,m.useEffect)(()=>{let i=y.current;if(!i)return;let u=i.ownerDocument??document,b=()=>{let I=u.getSelection();if(!I||I.rangeCount===0||!I.anchorNode||!i.contains(I.anchorNode))return;let x=I.anchorNode,Z=(x.nodeType===Node.ELEMENT_NODE?x:x.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(Z&&Z!==l?.id){H(Z);return}performance.now()-M.current<50||R((0,F.getCursorOffset)(i))};return u.addEventListener("selectionchange",b),()=>u.removeEventListener("selectionchange",b)},[l,H,R]),(0,m.useLayoutEffect)(()=>{let i=y.current;i&&(0,F.renderEditableContent)({input:i,segments:t,newParamId:o,editingParamId:l?.id??null,placeholderText:d??"",isFocused:c})},[t,o,l,d,c]),(0,m.useLayoutEffect)(()=>{let i=q.current,u=o??"";if(q.current=u,!u||u===i)return;let b=y.current;if(!b)return;b.focus();let I=te.current??(0,F.plainTextLength)(b);(0,F.setCursorOffset)(b,I)},[o]),(0,m.useLayoutEffect)(()=>{let i=g.current,u=l?.id??"";if(g.current=u,!u||u===i||a==null)return;let b=y.current;b&&(0,F.setCursorOffset)(b,a)},[l,a]);let L=(0,m.useCallback)(()=>{if(O.current)return;let i=y.current;if(!i)return;let u=(0,F.extractPlainText)(i),I=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;A(I)},[A]),$=(0,m.useCallback)(()=>{M.current=performance.now(),L();let i=y.current;i&&w((0,F.getCursorOffset)(i))},[L,w]);(0,m.useEffect)(()=>{let i=y.current;if(!i)return;let u=b=>{let I=b,x=I.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){b.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let T=x.startsWith("delete")?"":I.data??"";X(T)&&b.preventDefault()}};return i.addEventListener("beforeinput",u),()=>i.removeEventListener("beforeinput",u)},[X]);let z=(0,m.useCallback)(()=>{O.current=!0},[]),oe=(0,m.useCallback)(()=>{O.current=!1,L()},[L]),J=(0,m.useCallback)(i=>{i.preventDefault();let u=y.current;if(!u)return;let b=(i.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let I=u.ownerDocument??document,x=I.getSelection();if(!x||x.rangeCount===0)return;let T=x.getRangeAt(0);if(!u.contains(T.startContainer))return;T.deleteContents();let W=I.createTextNode(b);T.insertNode(W),T.setStartAfter(W),T.collapse(!0),x.removeAllRanges(),x.addRange(T),L()},[L]),N=(0,m.useCallback)(i=>C(i),[C]),K=(0,m.useCallback)(()=>s(!0),[s]),f=(0,m.useCallback)(()=>s(!1),[s]),re=(0,m.useCallback)(()=>y.current?.focus(),[]),se=(0,m.useCallback)(()=>y.current?.blur(),[]),ae=(0,m.useCallback)(()=>{let i=y.current;return i?(0,F.extractPlainText)(i):""},[]),p=wt()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:p,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":v,"aria-expanded":h,"aria-activedescendant":B,spellCheck:!0,enterKeyHint:"send",onInput:$,onKeyDown:N,onCompositionStart:z,onCompositionEnd:oe,onPaste:J,onFocus:K,onBlur:f},getPlainText:ae,focus:re,blur:se}}var V=require("react/jsx-runtime");function yt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var tt=(0,S.forwardRef)(function({onSubmit:t,onError:o,optionOverrides:l,maskCompletedText:a,className:n,apiConfig:d,columns:c,pillPlacement:h="inline",mode:v="auto",optionsPosition:B="below",animations:P=!0,dropdownTrigger:A,closeDropdownOnBlur:C,showNonTappableOptions:w,autoFocus:R=!0,onFocus:H,onBlur:X,value:s,completedParams:y,onChange:O,onParamsChange:q,submitButton:g},te){let M=(0,S.useRef)(null),L=(0,S.useRef)(null),$=(0,S.useRef)(()=>{}),z=(0,S.useRef)(null),oe=(0,S.useRef)(null);(0,S.useEffect)(()=>{let _=M.current;if(_)return z.current?z.current.setMode(v):z.current=new me.ModeController(_,v),()=>{z.current?.destroy(),z.current=null}},[v]);let J=(0,S.useCallback)(_=>{let U=oe.current?.current;U&&(U.focus(),(0,me.setCursorOffset)(U,_))},[]),{completedParams:N,suggestionPills:K,setActivePill:f,segments:re,newParamId:se,clearNewParamId:ae,placeholderText:p,isFocused:i,isDropdownOpen:u,isActivePillSelected:b,isLoading:I,activeIndex:x,listboxId:T,handleTextChange:W,handleKeyDown:Z,setFocused:be,editingParam:Ce,editingAnchor:xe,caretOffset:r,startEditingParam:D,handleCaretAfterInput:E,handleCaretMove:de,replaceEditingRange:ge,dropdownProps:ot,reset:ve}=Ae({onSubmit:_=>$.current(_),onError:o,optionOverrides:l,maskCompletedText:a,apiConfig:d,columns:c,dropdownTrigger:A,optionsPosition:B,closeDropdownOnBlur:C,showNonTappableOptions:w,onFocus:H,onBlur:X,value:s,completedParams:y,onChange:O,onParamsChange:q,source:"full-sdk",setCursor:J});(0,S.useEffect)(()=>{if(!se)return;let _=window.setTimeout(()=>ae(),650);return()=>window.clearTimeout(_)},[se,ae]);let at=x>=0?`${T}-option-${x}`:void 0,{inputRef:Ee,editorProps:nt,focus:we,blur:Oe,getPlainText:Me}=et({segments:re,newParamId:se,editingParam:Ce,editingAnchor:xe,caretOffset:r,placeholderText:p,isFocused:i,isDropdownOpen:u,listboxId:T,activeDescendantId:at,autoFocus:R,handleTextChange:W,handleKeyDown:Z,handleCaretAfterInput:E,handleCaretMove:de,startEditingParam:D,replaceEditingRange:ge,setFocused:be});oe.current=Ee,(0,S.useLayoutEffect)(()=>{let _=L.current,U=Ee.current;if(!_||!U)return;let _e=()=>{let Ne=_.firstElementChild;if(!Ne)return;let lt=Ne.getBoundingClientRect(),dt=U.getBoundingClientRect();lt.top>=dt.bottom-2?_.setAttribute("data-aia-pill-wrapped",""):_.removeAttribute("data-aia-pill-wrapped")};_e();let He=new ResizeObserver(_e);return He.observe(U),()=>He.disconnect()},[re,K.length,I,Ee]),(0,S.useImperativeHandle)(te,()=>({focus:we,blur:Oe,reset:ve,setMode:_=>z.current?.setMode(_)}),[we,Oe,ve]);let ye=!!re.length||N.length>0,De=(0,S.useCallback)(()=>{if(!ye)return;let _=Me(),{rawQuery:U,completedParams:_e}=(0,me.buildQuery)(_,N);t({query:_.trim(),raw_query:U,completed_params:_e}),ve()},[ye,N,t,ve,Me]);$.current=De;let it=(0,S.useCallback)(_=>{_.target?.closest("[data-aia-pill]")||we()},[we]),rt=h==="inline",st=h==="dropdown";return(0,V.jsxs)("div",{ref:M,className:`magicx-aia ${le.container} ${n??""}`,"data-pill-placement":h,"data-options-position":B,"data-animations":P?"on":"off","data-mode":yt(v),children:[(0,V.jsx)(Ie,{...ot,showPills:st}),(0,V.jsxs)("div",{className:le.inputWrapper,onClick:it,children:[(0,V.jsxs)("div",{className:le.editorArea,"data-aia-editor":"",children:[(0,V.jsx)("div",{...nt,className:le.input,"data-aia-input":""}),rt&&(I||K.length>0)&&(0,V.jsx)("span",{ref:L,className:le.pillListContainer,"data-aia-pill-list-container":"",children:(0,V.jsx)(ke,{pills:K,activePillIndex:0,activeSelected:b,onSelectPill:f,loading:I})})]}),g===null?null:g===void 0?(0,V.jsx)(Ze,{disabled:!ye,onClick:De}):(0,V.jsx)("span",{"data-aia-submit":"",className:le.submitSlot,onClick:_=>{ye&&(_.stopPropagation(),De())},children:g})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,useAIAutocomplete});
998
998
  //# sourceMappingURL=index.js.map