@magicx-eng/ai-autocomplete-react 0.6.4 → 0.6.6

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.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Re=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var mt=(e,t)=>{for(var a in t)Re(e,a,{get:t[a],enumerable:!0})},gt=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ct(t))!ut.call(e,n)&&n!==a&&Re(e,n,{get:()=>t[n],enumerable:!(s=pt(t,n))||s.enumerable});return e};var ft=e=>gt(Re({},"__esModule",{value:!0}),e);var _t={};mt(_t,{AIAutocomplete:()=>tt,AIAutocompleteDropdown:()=>Ie,useAIAutocomplete:()=>Se});module.exports=ft(_t);var P=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 Le=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var gt=(e,t)=>{for(var a in t)Le(e,a,{get:t[a],enumerable:!0})},ft=(e,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ut(t))!mt.call(e,n)&&n!==a&&Le(e,n,{get:()=>t[n],enumerable:!(s=ct(t,n))||s.enumerable});return e};var ht=e=>ft(Le({},"__esModule",{value:!0}),e);var kt={};gt(kt,{AIAutocomplete:()=>at,AIAutocompleteDropdown:()=>Se,useAIAutocomplete:()=>Ce});module.exports=ht(kt);var P=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
@@ -158,7 +158,7 @@
158
158
  opacity: 0;
159
159
  }
160
160
  }
161
- `,document.head.appendChild(e)}var le={container:"AIAutocomplete-module_container_KKjFU",inputWrapper:"AIAutocomplete-module_inputWrapper_FLq1b",editorArea:"AIAutocomplete-module_editorArea_7rBWq",input:"AIAutocomplete-module_input_IW-P-",pillListContainer:"AIAutocomplete-module_pillListContainer_h92IA",submitSlot:"AIAutocomplete-module_submitSlot_GhuCM",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};var ue=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
161
+ `,document.head.appendChild(e)}var le={container:"AIAutocomplete-module_container_KKjFU",inputWrapper:"AIAutocomplete-module_inputWrapper_FLq1b",editorArea:"AIAutocomplete-module_editorArea_7rBWq",input:"AIAutocomplete-module_input_IW-P-",pillListContainer:"AIAutocomplete-module_pillListContainer_h92IA",submitSlot:"AIAutocomplete-module_submitSlot_GhuCM",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};var me=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
162
162
  * Built-in appearance defaults \u2014 zero specificity via :where().
163
163
  * Consumer CSS always wins without !important.
164
164
  *
@@ -430,7 +430,7 @@
430
430
  opacity: 0.25;
431
431
  }
432
432
  }
433
- `,document.head.appendChild(e)}var pe={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};var Ke=require("@magicx-eng/ai-autocomplete-vanilla");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
433
+ `,document.head.appendChild(e)}var pe={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};var ce=require("@magicx-eng/ai-autocomplete-vanilla"),Ie=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
434
434
  .aia-cluster {
435
435
  display: flex;
436
436
  flex-wrap: wrap;
@@ -472,7 +472,7 @@
472
472
  justify-content: space-around;
473
473
  }
474
474
  }
475
- `,document.head.appendChild(e)}var Te=require("react/jsx-runtime");function fe({gap:e,align:t="center",justify:a="start",noWrap:s=!1,inline:n=!1,className:i,children:d,...c}){let x=e?{"--aia-cluster-gap":e}:void 0,v={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":t,"data-justify":a,"data-nowrap":s||void 0,"data-inline":n||void 0,style:x,...c};return n?(0,Te.jsx)("span",{...v,children:d}):(0,Te.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 so it stays clear of the
475
+ `,document.head.appendChild(e)}var Be=require("react/jsx-runtime");function he({gap:e,align:t="center",justify:a="start",noWrap:s=!1,inline:n=!1,className:o,children:d,...c}){let x=e?{"--aia-cluster-gap":e}:void 0,v={className:o?`aia-cluster ${o}`:"aia-cluster","data-align":t,"data-justify":a,"data-nowrap":s||void 0,"data-inline":n||void 0,style:x,...c};return n?(0,Be.jsx)("span",{...v,children:d}):(0,Be.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 so it stays clear of the
476
476
  dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
477
477
  room above the hint/branding row so the footer doesn't butt against the last
478
478
  option row \u2014 additive to the dropdown's 8px section gap. */
@@ -553,7 +553,7 @@
553
553
  justify-content: flex-end;
554
554
  }
555
555
  }
556
- `,document.head.appendChild(e)}var Y={footer:"DropdownFooter-module_footer_qQQ7x",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"};var q=require("react/jsx-runtime");function We({isOptionHighlighted:e=!1,isInputEmpty:t=!1}){let{key:a,hint:s}=(0,Ke.getFooterHint)(e,t);return(0,q.jsx)("footer",{className:Y.footer,"data-aia-footer":"",children:(0,q.jsxs)(fe,{justify:"between",noWrap:!0,className:Y.row,children:[(0,q.jsxs)(fe,{gap:"5px",className:Y.hintGroup,children:[(0,q.jsx)("kbd",{className:Y.key,children:a}),(0,q.jsx)("span",{className:Y.hint,children:s})]}),(0,q.jsxs)("a",{className:Y.brandLink,href:"https://ai-autocomplete.com",target:"_blank",rel:"noopener noreferrer",children:[(0,q.jsx)("span",{className:Y.brand,children:"AI"}),(0,q.jsx)("span",{className:Y.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill
556
+ `,document.head.appendChild(e)}var Y={footer:"DropdownFooter-module_footer_qQQ7x",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"};var q=require("react/jsx-runtime");function Ge({isOptionHighlighted:e=!1,isInputEmpty:t=!1}){let{key:a,hint:s}=(0,ce.getFooterHint)(e,t),[n,o]=(0,Ie.useState)(ce.ATTRIBUTION_URL);return(0,Ie.useEffect)(()=>{o((0,ce.buildAttributionUrl)())},[]),(0,q.jsx)("footer",{className:Y.footer,"data-aia-footer":"",children:(0,q.jsxs)(he,{justify:"between",noWrap:!0,className:Y.row,children:[(0,q.jsxs)(he,{gap:"5px",className:Y.hintGroup,children:[(0,q.jsx)("kbd",{className:Y.key,children:a}),(0,q.jsx)("span",{className:Y.hint,children:s})]}),(0,q.jsxs)("a",{className:Y.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,q.jsx)("span",{className:Y.brand,children:"AI"}),(0,q.jsx)("span",{className:Y.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill
557
557
  with a dashed border. ~28px via 6px padding + 14px text + the 1px border
558
558
  (border-box). */
559
559
  .ParamPill-module_pill_6Ga7S {
@@ -605,7 +605,7 @@
605
605
  opacity: 0;
606
606
  }
607
607
  }
608
- `,document.head.appendChild(e)}var oe={pill:"ParamPill-module_pill_6Ga7S",fadeIn:"ParamPill-module_fadeIn_Ux4eQ",rounded:"ParamPill-module_rounded_y7xA9",skeleton:"ParamPill-module_skeleton_57P0T",skeletonPulse:"ParamPill-module_skeletonPulse_xGcUy"};var Ue=require("react/jsx-runtime"),Le={selected:1,first:.7,next:.4,last:.2};function Ge({label:e,state:t,rounded:a,loading:s,onClick:n}){let i=[oe.pill,a?oe.rounded:"",s?oe.skeleton:""].filter(Boolean).join(" ");return(0,Ue.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":s?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:Le[t]},onMouseDown:d=>d.preventDefault(),onClick:s?void 0:n,disabled:s,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 {
608
+ `,document.head.appendChild(e)}var oe={pill:"ParamPill-module_pill_6Ga7S",fadeIn:"ParamPill-module_fadeIn_Ux4eQ",rounded:"ParamPill-module_rounded_y7xA9",skeleton:"ParamPill-module_skeleton_57P0T",skeletonPulse:"ParamPill-module_skeletonPulse_xGcUy"};var je=require("react/jsx-runtime"),ze={selected:1,first:.7,next:.4,last:.2};function Ue({label:e,state:t,rounded:a,loading:s,onClick:n}){let o=[oe.pill,a?oe.rounded:"",s?oe.skeleton:""].filter(Boolean).join(" ");return(0,je.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":s?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:o,style:{opacity:ze[t]},onMouseDown:d=>d.preventDefault(),onClick:s?void 0:n,disabled:s,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 {
609
609
  position: relative;
610
610
  z-index: 1;
611
611
  pointer-events: auto;
@@ -615,7 +615,7 @@
615
615
  align-items: center;
616
616
  vertical-align: middle;
617
617
  }
618
- `,document.head.appendChild(e)}var ze={list:"PillList-module_list_qvLqO"};var he=require("react/jsx-runtime"),ht=[125,69];function je(e){return e===0?"first":e===1?"next":"last"}function ke({pills:e,activePillIndex:t,onSelectPill:a,activeSelected:s,rounded:n,loading:i}){return i&&e.length===0?(0,he.jsx)("span",{className:ze.list,"data-aia-pill-list-loading":"",children:ht.map((d,c)=>(0,he.jsx)("span",{"data-aia-pill-skeleton":"",className:`${oe.pill} ${n?oe.rounded:""} ${oe.skeleton}`,style:{width:d,opacity:Le[je(c)]}},`skel-${d}`))}):(0,he.jsx)("span",{className:ze.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((d,c)=>{let x=!!s&&c===t;return(0,he.jsx)(Ge,{label:d.text,state:x?"selected":je(c),selected:x,rounded:n,loading:i,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 {
618
+ `,document.head.appendChild(e)}var Fe={list:"PillList-module_list_qvLqO"};var be=require("react/jsx-runtime"),bt=[125,69];function Ve(e){return e===0?"first":e===1?"next":"last"}function Pe({pills:e,activePillIndex:t,onSelectPill:a,activeSelected:s,rounded:n,loading:o}){return o&&e.length===0?(0,be.jsx)("span",{className:Fe.list,"data-aia-pill-list-loading":"",children:bt.map((d,c)=>(0,be.jsx)("span",{"data-aia-pill-skeleton":"",className:`${oe.pill} ${n?oe.rounded:""} ${oe.skeleton}`,style:{width:d,opacity:ze[Ve(c)]}},`skel-${d}`))}):(0,be.jsx)("span",{className:Fe.list,"data-aia-pill-list-loading":o?"":void 0,children:e.map((d,c)=>{let x=!!s&&c===t;return(0,be.jsx)(Ue,{label:d.text,state:x?"selected":Ve(c),selected:x,rounded:n,loading:o,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 {
619
619
  .aia-grid {
620
620
  display: grid;
621
621
  grid-template-columns: repeat(
@@ -674,7 +674,7 @@
674
674
  display: none;
675
675
  }
676
676
  }
677
- `,document.head.appendChild(e)}var Fe=require("react/jsx-runtime");function Ve({min:e="16rem",max:t,gap:a,scroll:s=!1,maxHeight:n,fade:i=!1,className:d,children:c,...x}){let v=(0,ie.useRef)(null),[z,A]=(0,ie.useState)(!1);(0,ie.useEffect)(()=>{if(!i)return;let y=v.current;if(!y)return;let R=()=>{A(y.scrollHeight-y.scrollTop-y.clientHeight>1)};y.addEventListener("scroll",R,{passive:!0});let H=new ResizeObserver(R);return H.observe(y),()=>{y.removeEventListener("scroll",R),H.disconnect()}},[i]),(0,ie.useLayoutEffect)(()=>{let y=v.current;!i||!y||A(y.scrollHeight-y.scrollTop-y.clientHeight>1)},[i,c]);let S={"--aia-grid-min":e};t&&(S["--aia-grid-max"]=t),a&&(S["--aia-grid-gap"]=a),n&&(S["--aia-grid-max-height"]=n);let C=(0,Fe.jsx)("div",{ref:v,className:!i&&d?`aia-grid ${d}`:"aia-grid","data-scroll":s||void 0,style:S,...i?{}:x,children:c});return i?(0,Fe.jsx)("div",{className:d?`aia-grid-fade ${d}`:"aia-grid-fade","data-fade":z?"":void 0,...x,children:C}):C}var ce=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 {
677
+ `,document.head.appendChild(e)}var Oe=require("react/jsx-runtime");function $e({min:e="16rem",max:t,gap:a,scroll:s=!1,maxHeight:n,fade:o=!1,className:d,children:c,...x}){let v=(0,ie.useRef)(null),[B,A]=(0,ie.useState)(!1);(0,ie.useEffect)(()=>{if(!o)return;let y=v.current;if(!y)return;let D=()=>{A(y.scrollHeight-y.scrollTop-y.clientHeight>1)};y.addEventListener("scroll",D,{passive:!0});let H=new ResizeObserver(D);return H.observe(y),()=>{y.removeEventListener("scroll",D),H.disconnect()}},[o]),(0,ie.useLayoutEffect)(()=>{let y=v.current;!o||!y||A(y.scrollHeight-y.scrollTop-y.clientHeight>1)},[o,c]);let S={"--aia-grid-min":e};t&&(S["--aia-grid-max"]=t),a&&(S["--aia-grid-gap"]=a),n&&(S["--aia-grid-max-height"]=n);let C=(0,Oe.jsx)("div",{ref:v,className:!o&&d?`aia-grid ${d}`:"aia-grid","data-scroll":s||void 0,style:S,...o?{}:x,children:c});return o?(0,Oe.jsx)("div",{className:d?`aia-grid-fade ${d}`:"aia-grid-fade","data-fade":B?"":void 0,...x,children:C}):C}var ue=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 {
678
678
  position: relative;
679
679
  overflow: visible;
680
680
  display: flex;
@@ -1024,7 +1024,7 @@
1024
1024
  filter: brightness(0.55);
1025
1025
  }
1026
1026
  }
1027
- `,document.head.appendChild(e)}var G={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 ne=require("react/jsx-runtime");function $e({option:e,isHighlighted:t,onSelect:a,onHighlight:s,id:n,loading:i}){let[d,c]=(0,ce.useState)(!1),x=(0,ce.useRef)(void 0);(0,ce.useEffect)(()=>()=>clearTimeout(x.current),[]);let v=()=>{i||!e.is_tappable||d||(c(!0),a(e),clearTimeout(x.current),x.current=setTimeout(()=>c(!1),500))},z=[G.item,t&&!i?G.highlighted:"",e.is_tappable?G.tappable:G.nonTappable,d?G.pressed:""].filter(Boolean).join(" ");return(0,ne.jsxs)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"aria-selected":t,className:z,tabIndex:i||!e.is_tappable?-1:0,onClick:v,onKeyDown:A=>{!i&&e.is_tappable&&(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),v())},onMouseEnter:!i&&e.is_tappable?s:void 0,children:[(0,ne.jsx)("div",{className:G.streaks}),(0,ne.jsx)("div",{className:G.streaksVert}),(0,ne.jsxs)("span",{className:G.content,children:[(0,ne.jsx)("span",{className:G.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,ne.jsx)("span",{className:G.tag,children:e.tag})]})]})}var Be=require("react/jsx-runtime");function qe({options:e,activeIndex:t,onSelect:a,onHighlight:s,listboxId:n,loading:i}){return(0,Be.jsx)(Ve,{min:"250px",max:"250px",gap:"0",scroll:!0,fade:!0,children:e.map((d,c)=>(0,Be.jsx)($e,{option:d,isHighlighted:c===t,onSelect:a,onHighlight:()=>s(c),id:`${n}-option-${c}`,loading:i},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 {
1027
+ `,document.head.appendChild(e)}var G={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 ne=require("react/jsx-runtime");function qe({option:e,isHighlighted:t,onSelect:a,onHighlight:s,id:n,loading:o}){let[d,c]=(0,ue.useState)(!1),x=(0,ue.useRef)(void 0);(0,ue.useEffect)(()=>()=>clearTimeout(x.current),[]);let v=()=>{o||!e.is_tappable||d||(c(!0),a(e),clearTimeout(x.current),x.current=setTimeout(()=>c(!1),500))},B=[G.item,t&&!o?G.highlighted:"",e.is_tappable?G.tappable:G.nonTappable,d?G.pressed:""].filter(Boolean).join(" ");return(0,ne.jsxs)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"aria-selected":t,className:B,tabIndex:o||!e.is_tappable?-1:0,onClick:v,onKeyDown:A=>{!o&&e.is_tappable&&(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),v())},onMouseEnter:!o&&e.is_tappable?s:void 0,children:[(0,ne.jsx)("div",{className:G.streaks}),(0,ne.jsx)("div",{className:G.streaksVert}),(0,ne.jsxs)("span",{className:G.content,children:[(0,ne.jsx)("span",{className:G.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,ne.jsx)("span",{className:G.tag,children:e.tag})]})]})}var Me=require("react/jsx-runtime");function Qe({options:e,activeIndex:t,onSelect:a,onHighlight:s,listboxId:n,loading:o}){return(0,Me.jsx)($e,{min:"250px",max:"250px",gap:"0",scroll:!0,fade:!0,children:e.map((d,c)=>(0,Me.jsx)(qe,{option:d,isHighlighted:c===t,onSelect:a,onHighlight:()=>s(c),id:`${n}-option-${c}`,loading:o},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 {
1028
1028
  .aia-stack {
1029
1029
  display: flex;
1030
1030
  flex-direction: column;
@@ -1041,7 +1041,7 @@
1041
1041
  }
1042
1042
  /* data-align="stretch" is the flex default \u2014 no rule needed. */
1043
1043
  }
1044
- `,document.head.appendChild(e)}var Xe=require("react/jsx-runtime");function Qe({space:e,align:t="stretch",className:a,children:s,...n}){let i=e?{"--aia-stack-space":e}:void 0;return(0,Xe.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":t,style:i,...n,children:s})}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,[a,s]=(0,ue.useState)(t);if((0,ue.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>s(n.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Ie({suggestions:e,activeIndex:t,onSelect:a,onHighlight:s,isOpen:n,id:i,className:d,pills:c,onPillClick:x,showPills:v=!0,activeSelected:z=!1,isLoading:A=!1,isInputEmpty:S=!1,optionsPosition:C="below",mode:y}){let R=xt(y),H=R!==void 0,X=e[0]?.options??[],l=!!(c&&c.length>0&&x),_=n&&(X.length>0||v&&l||A),O={suggestions:e,activeIndex:t,pills:c,showPills:v,activeSelected:z,isLoading:A,isInputEmpty:S},j=(0,ue.useRef)(O);_&&(j.current=O);let h=_?O:j.current,M=h.suggestions[0]?.options??[],T=h.activeIndex>=0&&!!M[h.activeIndex]?.is_tappable,V=!!(h.pills&&h.pills.length>0&&x),F=h.showPills&&V,te=h.showPills&&!V&&h.isLoading,Z=F||te,N=M.length>0,K=h.isLoading&&!N;return(0,Q.jsx)("div",{id:i,role:"listbox","data-aia-dropdown":"","data-options-position":C,"data-mode":R,"data-aia-loading":h.isLoading?"":void 0,className:`${H?"magicx-aia ":""}${pe.dropdown} ${_?pe.visible:""} ${d??""}`,onMouseDown:b=>b.preventDefault(),children:(0,Q.jsxs)(Qe,{space:"8px",children:[Z&&(0,Q.jsx)(fe,{noWrap:!0,className:pe.pillBar,"data-aia-pillbar":"",children:(0,Q.jsx)(ke,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:h.isLoading})}),N&&(0,Q.jsx)(qe,{options:M,activeIndex:h.activeIndex,onSelect:a,onHighlight:s,listboxId:i,loading:h.isLoading}),K&&(0,Q.jsx)("div",{className:pe.skeletonBars,"data-aia-skeleton-bars":"",children:bt.map(b=>(0,Q.jsx)("span",{className:pe.skeletonBar,style:{width:b}},`bar-${b}`))}),(0,Q.jsx)(We,{isOptionHighlighted:T,isInputEmpty:h.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 {
1044
+ `,document.head.appendChild(e)}var Ze=require("react/jsx-runtime");function Xe({space:e,align:t="stretch",className:a,children:s,...n}){let o=e?{"--aia-stack-space":e}:void 0;return(0,Ze.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":t,style:o,...n,children:s})}var Q=require("react/jsx-runtime"),xt=[159,119,164];function vt(e){let t=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,s]=(0,me.useState)(t);if((0,me.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>s(n.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Se({suggestions:e,activeIndex:t,onSelect:a,onHighlight:s,isOpen:n,id:o,className:d,pills:c,onPillClick:x,showPills:v=!0,activeSelected:B=!1,isLoading:A=!1,isInputEmpty:S=!1,optionsPosition:C="below",mode:y}){let D=vt(y),H=D!==void 0,X=e[0]?.options??[],l=!!(c&&c.length>0&&x),_=n&&(X.length>0||v&&l||A),O={suggestions:e,activeIndex:t,pills:c,showPills:v,activeSelected:B,isLoading:A,isInputEmpty:S},j=(0,me.useRef)(O);_&&(j.current=O);let h=_?O:j.current,M=h.suggestions[0]?.options??[],T=h.activeIndex>=0&&!!M[h.activeIndex]?.is_tappable,V=!!(h.pills&&h.pills.length>0&&x),z=h.showPills&&V,te=h.showPills&&!V&&h.isLoading,Z=z||te,N=M.length>0,K=h.isLoading&&!N;return(0,Q.jsx)("div",{id:o,role:"listbox","data-aia-dropdown":"","data-options-position":C,"data-mode":D,"data-aia-loading":h.isLoading?"":void 0,className:`${H?"magicx-aia ":""}${pe.dropdown} ${_?pe.visible:""} ${d??""}`,onMouseDown:b=>b.preventDefault(),children:(0,Q.jsxs)(Xe,{space:"8px",children:[Z&&(0,Q.jsx)(he,{noWrap:!0,className:pe.pillBar,"data-aia-pillbar":"",children:(0,Q.jsx)(Pe,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:h.isLoading})}),N&&(0,Q.jsx)(Qe,{options:M,activeIndex:h.activeIndex,onSelect:a,onHighlight:s,listboxId:o,loading:h.isLoading}),K&&(0,Q.jsx)("div",{className:pe.skeletonBars,"data-aia-skeleton-bars":"",children:xt.map(b=>(0,Q.jsx)("span",{className:pe.skeletonBar,style:{width:b}},`bar-${b}`))}),(0,Q.jsx)(Ge,{isOptionHighlighted:T,isInputEmpty:h.isInputEmpty})]})})}var ge=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 {
1045
1045
  flex-shrink: 0;
1046
1046
  width: 32px;
1047
1047
  height: 32px;
@@ -1076,5 +1076,5 @@
1076
1076
  );
1077
1077
  cursor: default;
1078
1078
  }
1079
- `,document.head.appendChild(e)}var Ze={submitButton:"SubmitButton-module_submitButton_otz7H"};var Pe=require("react/jsx-runtime");function Je({disabled:e,onClick:t}){return(0,Pe.jsx)("button",{type:"button","data-aia-submit":"",className:Ze.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),t()},"aria-label":"Submit",children:(0,Pe.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Pe.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"),I=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 Se({onSubmit:e,onError:t,optionOverrides:a,maskCompletedText:s,apiConfig:n,columns:i=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:x,showNonTappableOptions:v,onFocus:z,onBlur:A,value:S,completedParams:C,onChange:y,onParamsChange:R,source:H,setCursor:X}){let l=(0,I.useRef)(null),[_,O]=(0,I.useState)(null),j=(0,I.useRef)(e);j.current=e;let h=(0,I.useRef)(t);h.current=t;let ee=(0,I.useRef)(y);ee.current=y;let M=(0,I.useRef)(R);M.current=R;let T=(0,I.useRef)(z);T.current=z;let V=(0,I.useRef)(A);V.current=A;let F=(0,I.useRef)(X);F.current=X,(0,I.useEffect)(()=>{if(typeof document>"u")return;let r=new Ye.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:n,optionOverrides:a,maskCompletedText:s,columns:i,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:x,showNonTappableOptions:v,source:H,value:S,completedParams:C,onSubmit:(...E)=>j.current?.(...E),onError:(...E)=>h.current?.(...E),onChange:(...E)=>ee.current?.(...E),onParamsChange:(...E)=>M.current?.(...E),onFocus:()=>T.current?.(),onBlur:()=>V.current?.(),setCursor:E=>F.current?.(E)});l.current=r,O(r.getState());let D=r.subscribe(E=>O(E));return()=>{D(),r.destroy(),l.current===r&&(l.current=null)}},[]),(0,I.useEffect)(()=>{S!==void 0&&l.current?.setValue(S)},[S]),(0,I.useEffect)(()=>{C!==void 0&&l.current?.setCompletedParams(C)},[C]);let te=JSON.stringify(n??null),Z=(0,I.useRef)(a),N=(0,I.useRef)(0);if(a!==Z.current){let r=Z.current,D=a,E=Object.keys(r??{}),de=Object.keys(D??{});(E.length!==de.length||de.some(ge=>!r?.[ge]||D[ge]!==r[ge]))&&N.current++,Z.current=a}(0,I.useEffect)(()=>{l.current?.update({apiConfig:n,optionOverrides:a,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:x,showNonTappableOptions:v})},[te,N.current,d,c,x,v]);let K=(0,I.useRef)(null);K.current===null&&(K.current={handleTextChange:r=>l.current?.handleTextChange(r),handleKeyDown:r=>{let D="nativeEvent"in r?r.nativeEvent:r;l.current?.handleKeyDown(D)},setFocused:r=>l.current?.setFocused(r),startEditingParam:r=>l.current?.startEditingParam(r),exitEditMode:()=>l.current?.exitEditMode(),handleCaretAfterInput:r=>l.current?.handleCaretAfterInput(r),handleCaretMove:r=>l.current?.handleCaretMove(r),replaceEditingRange:r=>l.current?.replaceEditingRange(r)??!1,setActivePill:r=>l.current?.setActivePill(r),removeLastParam:()=>l.current?.removeLastParam(),clearNewParamId:()=>l.current?.clearNewParamId(),reset:()=>l.current?.reset(),selectOption:r=>l.current?.selectOption(r),setActiveDropdownIndex:r=>l.current?.setActiveDropdownIndex(r),handleFocus:()=>l.current?.setFocused(!0),handleBlur:()=>l.current?.setFocused(!1)});let b=K.current,re=(0,I.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;l.current?.handleTextChange(de)},[]),se=(0,I.useCallback)(r=>{l.current?.handleKeyDown(r.nativeEvent)},[]),ae=l.current,u=_??vt,o=S!==void 0?S:u.text,p=C!==void 0?C:u.completedParams,m=u.actionableSuggestions,w=m[0],g=ae?.listboxId??"",L=u.activeDropdownIndex>=0&&ae?`${g}-option-${u.activeDropdownIndex}`:void 0,W=u.editingParam,J=W?{type:W.suggestionType,text:W.suggestionPlaceholder,required:!0,options:W.options}:null,be=J??w,Ce=J?[J]:m,xe=!ae||u.isLoading&&!u.editingParam&&!u.inSelectionAnimation;return{completedParams:p,suggestionPills:m,setActivePill:b.setActivePill,removeLastParam:b.removeLastParam,segments:u.segments,newParamId:u.newParamId,clearNewParamId:b.clearNewParamId,suggestions:u.suggestions,activeIndex:u.activeDropdownIndex,isReady:u.isReady,isLoading:xe,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:g,error:u.error,handleTextChange:b.handleTextChange,handleKeyDown:b.handleKeyDown,setFocused:b.setFocused,editingParam:W,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:b.startEditingParam,exitEditMode:b.exitEditMode,handleCaretAfterInput:b.handleCaretAfterInput,handleCaretMove:b.handleCaretMove,replaceEditingRange:b.replaceEditingRange,inputProps:{value:o,placeholder:u.placeholderText||void 0,onChange:re,onKeyDown:se,onFocus:b.handleFocus,onBlur:b.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":L,"aria-autocomplete":"list","aria-controls":g},reset:b.reset,dropdownProps:{suggestions:be?[{...be,options:u.filteredOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:b.selectOption,onHighlight:b.setActiveDropdownIndex,isOpen:u.isDropdownOpen,id:g,pills:Ce,activeSelected:u.isActivePillSelected,onPillClick:b.setActivePill,isLoading:xe,isInputEmpty:o.trim().length===0,optionsPosition:c??"below"}}}var B=require("@magicx-eng/ai-autocomplete-vanilla"),f=require("react"),Ae;function wt(){if(Ae!==void 0)return Ae;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ae=e.contentEditable==="plaintext-only",Ae}function et(e){let{segments:t,newParamId:a,editingParam:s,editingAnchor:n,caretOffset:i,placeholderText:d,isFocused:c,isDropdownOpen:x,listboxId:v,activeDescendantId:z,autoFocus:A,handleTextChange:S,handleKeyDown:C,handleCaretAfterInput:y,handleCaretMove:R,startEditingParam:H,replaceEditingRange:X,setFocused:l}=e,_=(0,f.useRef)(null),O=(0,f.useRef)(!1),j=(0,f.useRef)(""),h=(0,f.useRef)(""),ee=(0,f.useRef)(null),M=(0,f.useRef)(0);ee.current=i,(0,f.useEffect)(()=>{if(!A)return;let o=_.current;if(!o)return;document.activeElement===o?l(!0):o.focus();let p=o.ownerDocument??document,m=p.getSelection(),w=m&&m.rangeCount>0&&o.contains(m.anchorNode);if(m&&!w){let g=p.createRange();g.selectNodeContents(o),g.collapse(!0),m.removeAllRanges(),m.addRange(g)}},[A,l]),(0,f.useEffect)(()=>{let o=_.current;if(!o)return;let p=o.ownerDocument??document,m=()=>{let w=p.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!o.contains(w.anchorNode))return;let g=w.anchorNode,J=(g.nodeType===Node.ELEMENT_NODE?g:g.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(J&&J!==s?.id){H(J);return}performance.now()-M.current<50||R((0,B.getCursorOffset)(o))};return p.addEventListener("selectionchange",m),()=>p.removeEventListener("selectionchange",m)},[s,H,R]),(0,f.useLayoutEffect)(()=>{let o=_.current;o&&(0,B.renderEditableContent)({input:o,segments:t,newParamId:a,editingParamId:s?.id??null,placeholderText:d??"",isFocused:c})},[t,a,s,d,c]),(0,f.useLayoutEffect)(()=>{let o=j.current,p=a??"";if(j.current=p,!p||p===o)return;let m=_.current;if(!m)return;m.focus();let w=ee.current??(0,B.plainTextLength)(m);(0,B.setCursorOffset)(m,w)},[a]),(0,f.useLayoutEffect)(()=>{let o=h.current,p=s?.id??"";if(h.current=p,!p||p===o||n==null)return;let m=_.current;m&&(0,B.setCursorOffset)(m,n)},[s,n]);let T=(0,f.useCallback)(()=>{if(O.current)return;let o=_.current;if(!o)return;let p=(0,B.extractPlainText)(o),w=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;S(w)},[S]),V=(0,f.useCallback)(()=>{M.current=performance.now(),T();let o=_.current;o&&y((0,B.getCursorOffset)(o))},[T,y]);(0,f.useEffect)(()=>{let o=_.current;if(!o)return;let p=m=>{let w=m,g=w.inputType;if(g==="insertParagraph"||g==="insertLineBreak"||g==="insertFromDrop"){m.preventDefault();return}if(g.startsWith("insert")||g.startsWith("delete")){let L=g.startsWith("delete")?"":w.data??"";X(L)&&m.preventDefault()}};return o.addEventListener("beforeinput",p),()=>o.removeEventListener("beforeinput",p)},[X]);let F=(0,f.useCallback)(()=>{O.current=!0},[]),te=(0,f.useCallback)(()=>{O.current=!1,T()},[T]),Z=(0,f.useCallback)(o=>{o.preventDefault();let p=_.current;if(!p)return;let m=(o.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!m)return;let w=p.ownerDocument??document,g=w.getSelection();if(!g||g.rangeCount===0)return;let L=g.getRangeAt(0);if(!p.contains(L.startContainer))return;L.deleteContents();let W=w.createTextNode(m);L.insertNode(W),L.setStartAfter(W),L.collapse(!0),g.removeAllRanges(),g.addRange(L),T()},[T]),N=(0,f.useCallback)(o=>C(o),[C]),K=(0,f.useCallback)(()=>l(!0),[l]),b=(0,f.useCallback)(()=>l(!1),[l]),re=(0,f.useCallback)(()=>_.current?.focus(),[]),se=(0,f.useCallback)(()=>_.current?.blur(),[]),ae=(0,f.useCallback)(()=>{let o=_.current;return o?(0,B.extractPlainText)(o):""},[]),u=wt()?"plaintext-only":"true";return{inputRef:_,editorProps:{ref:_,contentEditable:u,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":v,"aria-expanded":x,"aria-activedescendant":z,spellCheck:!0,enterKeyHint:"send",onInput:V,onKeyDown:N,onCompositionStart:F,onCompositionEnd:te,onPaste:Z,onFocus:K,onBlur:b},getPlainText:ae,focus:re,blur:se}}var U=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,P.forwardRef)(function({onSubmit:t,onError:a,optionOverrides:s,maskCompletedText:n,className:i,apiConfig:d,columns:c,pillPlacement:x="dropdown",mode:v="auto",optionsPosition:z="below",animations:A=!0,dropdownTrigger:S,closeDropdownOnBlur:C,showNonTappableOptions:y,autoFocus:R=!0,onFocus:H,onBlur:X,value:l,completedParams:_,onChange:O,onParamsChange:j,submitButton:h},ee){let M=(0,P.useRef)(null),T=(0,P.useRef)(null),V=(0,P.useRef)(()=>{}),F=(0,P.useRef)(null),te=(0,P.useRef)(null);(0,P.useEffect)(()=>{let k=M.current;if(k)return F.current?F.current.setMode(v):F.current=new me.ModeController(k,v),()=>{F.current?.destroy(),F.current=null}},[v]);let Z=(0,P.useCallback)(k=>{let $=te.current?.current;$&&($.focus(),(0,me.setCursorOffset)($,k))},[]),{completedParams:N,suggestionPills:K,setActivePill:b,segments:re,newParamId:se,clearNewParamId:ae,placeholderText:u,isFocused:o,isDropdownOpen:p,isActivePillSelected:m,isLoading:w,activeIndex:g,listboxId:L,handleTextChange:W,handleKeyDown:J,setFocused:be,editingParam:Ce,editingAnchor:xe,caretOffset:r,startEditingParam:D,handleCaretAfterInput:E,handleCaretMove:de,replaceEditingRange:ge,dropdownProps:at,reset:ve}=Se({onSubmit:k=>V.current(k),onError:a,optionOverrides:s,maskCompletedText:n,apiConfig:d,columns:c,dropdownTrigger:S,optionsPosition:z,closeDropdownOnBlur:C,showNonTappableOptions:y,onFocus:H,onBlur:X,value:l,completedParams:_,onChange:O,onParamsChange:j,source:"full-sdk",setCursor:Z});(0,P.useEffect)(()=>{if(!se)return;let k=window.setTimeout(()=>ae(),650);return()=>window.clearTimeout(k)},[se,ae]);let ot=g>=0?`${L}-option-${g}`:void 0,{inputRef:Ee,editorProps:it,focus:we,blur:Oe,getPlainText:Me}=et({segments:re,newParamId:se,editingParam:Ce,editingAnchor:xe,caretOffset:r,placeholderText:u,isFocused:o,isDropdownOpen:p,listboxId:L,activeDescendantId:ot,autoFocus:R,handleTextChange:W,handleKeyDown:J,handleCaretAfterInput:E,handleCaretMove:de,startEditingParam:D,replaceEditingRange:ge,setFocused:be});te.current=Ee,(0,P.useLayoutEffect)(()=>{let k=T.current,$=Ee.current;if(!k||!$)return;let _e=()=>{let Ne=k.firstElementChild;if(!Ne)return;let lt=Ne.getBoundingClientRect(),dt=$.getBoundingClientRect();lt.top>=dt.bottom-2?k.setAttribute("data-aia-pill-wrapped",""):k.removeAttribute("data-aia-pill-wrapped")};_e();let He=new ResizeObserver(_e);return He.observe($),()=>He.disconnect()},[re,K.length,w,Ee]),(0,P.useImperativeHandle)(ee,()=>({focus:we,blur:Oe,reset:ve,setMode:k=>F.current?.setMode(k)}),[we,Oe,ve]);let ye=!!re.length||N.length>0,De=(0,P.useCallback)(()=>{if(!ye)return;let k=Me(),{rawQuery:$,completedParams:_e}=(0,me.buildQuery)(k,N);t({query:k.trim(),raw_query:$,completed_params:_e}),ve()},[ye,N,t,ve,Me]);V.current=De;let nt=(0,P.useCallback)(k=>{k.target?.closest("[data-aia-pill]")||we()},[we]),rt=x==="inline",st=x==="dropdown";return(0,U.jsxs)("div",{ref:M,className:`magicx-aia ${le.container} ${i??""}`,"data-pill-placement":x,"data-options-position":z,"data-animations":A?"on":"off","data-mode":yt(v),children:[(0,U.jsx)(Ie,{...at,showPills:st}),(0,U.jsxs)("div",{className:le.inputWrapper,onClick:nt,children:[(0,U.jsxs)("div",{className:le.editorArea,"data-aia-editor":"",children:[(0,U.jsx)("div",{...it,className:le.input,"data-aia-input":""}),rt&&(w||K.length>0)&&(0,U.jsx)("span",{ref:T,className:le.pillListContainer,"data-aia-pill-list-container":"",children:(0,U.jsx)(ke,{pills:K,activePillIndex:0,activeSelected:m,onSelectPill:b,loading:w})})]}),h===null?null:h===void 0?(0,U.jsx)(Je,{disabled:!ye,onClick:De}):(0,U.jsx)("span",{"data-aia-submit":"",className:le.submitSlot,onClick:k=>{ye&&(k.stopPropagation(),De())},children:h})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,useAIAutocomplete});
1079
+ `,document.head.appendChild(e)}var Je={submitButton:"SubmitButton-module_submitButton_otz7H"};var Ae=require("react/jsx-runtime");function Ye({disabled:e,onClick:t}){return(0,Ae.jsx)("button",{type:"button","data-aia-submit":"",className:Je.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),t()},"aria-label":"Submit",children:(0,Ae.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Ae.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var et=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react"),wt={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 Ce({onSubmit:e,onError:t,optionOverrides:a,maskCompletedText:s,apiConfig:n,columns:o=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:x,showNonTappableOptions:v,onFocus:B,onBlur:A,value:S,completedParams:C,onChange:y,onParamsChange:D,source:H,setCursor:X}){let l=(0,I.useRef)(null),[_,O]=(0,I.useState)(null),j=(0,I.useRef)(e);j.current=e;let h=(0,I.useRef)(t);h.current=t;let ee=(0,I.useRef)(y);ee.current=y;let M=(0,I.useRef)(D);M.current=D;let T=(0,I.useRef)(B);T.current=B;let V=(0,I.useRef)(A);V.current=A;let z=(0,I.useRef)(X);z.current=X,(0,I.useEffect)(()=>{if(typeof document>"u")return;let r=new et.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:n,optionOverrides:a,maskCompletedText:s,columns:o,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:x,showNonTappableOptions:v,source:H,value:S,completedParams:C,onSubmit:(...E)=>j.current?.(...E),onError:(...E)=>h.current?.(...E),onChange:(...E)=>ee.current?.(...E),onParamsChange:(...E)=>M.current?.(...E),onFocus:()=>T.current?.(),onBlur:()=>V.current?.(),setCursor:E=>z.current?.(E)});l.current=r,O(r.getState());let R=r.subscribe(E=>O(E));return()=>{R(),r.destroy(),l.current===r&&(l.current=null)}},[]),(0,I.useEffect)(()=>{S!==void 0&&l.current?.setValue(S)},[S]),(0,I.useEffect)(()=>{C!==void 0&&l.current?.setCompletedParams(C)},[C]);let te=JSON.stringify(n??null),Z=(0,I.useRef)(a),N=(0,I.useRef)(0);if(a!==Z.current){let r=Z.current,R=a,E=Object.keys(r??{}),de=Object.keys(R??{});(E.length!==de.length||de.some(fe=>!r?.[fe]||R[fe]!==r[fe]))&&N.current++,Z.current=a}(0,I.useEffect)(()=>{l.current?.update({apiConfig:n,optionOverrides:a,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:x,showNonTappableOptions:v})},[te,N.current,d,c,x,v]);let K=(0,I.useRef)(null);K.current===null&&(K.current={handleTextChange:r=>l.current?.handleTextChange(r),handleKeyDown:r=>{let R="nativeEvent"in r?r.nativeEvent:r;l.current?.handleKeyDown(R)},setFocused:r=>l.current?.setFocused(r),startEditingParam:r=>l.current?.startEditingParam(r),exitEditMode:()=>l.current?.exitEditMode(),handleCaretAfterInput:r=>l.current?.handleCaretAfterInput(r),handleCaretMove:r=>l.current?.handleCaretMove(r),replaceEditingRange:r=>l.current?.replaceEditingRange(r)??!1,setActivePill:r=>l.current?.setActivePill(r),removeLastParam:()=>l.current?.removeLastParam(),clearNewParamId:()=>l.current?.clearNewParamId(),reset:()=>l.current?.reset(),selectOption:r=>l.current?.selectOption(r),setActiveDropdownIndex:r=>l.current?.setActiveDropdownIndex(r),handleFocus:()=>l.current?.setFocused(!0),handleBlur:()=>l.current?.setFocused(!1)});let b=K.current,re=(0,I.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;l.current?.handleTextChange(de)},[]),se=(0,I.useCallback)(r=>{l.current?.handleKeyDown(r.nativeEvent)},[]),ae=l.current,u=_??wt,i=S!==void 0?S:u.text,p=C!==void 0?C:u.completedParams,m=u.actionableSuggestions,w=m[0],g=ae?.listboxId??"",L=u.activeDropdownIndex>=0&&ae?`${g}-option-${u.activeDropdownIndex}`:void 0,W=u.editingParam,J=W?{type:W.suggestionType,text:W.suggestionPlaceholder,required:!0,options:W.options}:null,xe=J??w,Re=J?[J]:m,ve=!ae||u.isLoading&&!u.editingParam&&!u.inSelectionAnimation;return{completedParams:p,suggestionPills:m,setActivePill:b.setActivePill,removeLastParam:b.removeLastParam,segments:u.segments,newParamId:u.newParamId,clearNewParamId:b.clearNewParamId,suggestions:u.suggestions,activeIndex:u.activeDropdownIndex,isReady:u.isReady,isLoading:ve,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:g,error:u.error,handleTextChange:b.handleTextChange,handleKeyDown:b.handleKeyDown,setFocused:b.setFocused,editingParam:W,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:b.startEditingParam,exitEditMode:b.exitEditMode,handleCaretAfterInput:b.handleCaretAfterInput,handleCaretMove:b.handleCaretMove,replaceEditingRange:b.replaceEditingRange,inputProps:{value:i,placeholder:u.placeholderText||void 0,onChange:re,onKeyDown:se,onFocus:b.handleFocus,onBlur:b.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":L,"aria-autocomplete":"list","aria-controls":g},reset:b.reset,dropdownProps:{suggestions:xe?[{...xe,options:u.filteredOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:b.selectOption,onHighlight:b.setActiveDropdownIndex,isOpen:u.isDropdownOpen,id:g,pills:Re,activeSelected:u.isActivePillSelected,onPillClick:b.setActivePill,isLoading:ve,isInputEmpty:i.trim().length===0,optionsPosition:c??"below"}}}var F=require("@magicx-eng/ai-autocomplete-vanilla"),f=require("react"),Ee;function yt(){if(Ee!==void 0)return Ee;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ee=e.contentEditable==="plaintext-only",Ee}function tt(e){let{segments:t,newParamId:a,editingParam:s,editingAnchor:n,caretOffset:o,placeholderText:d,isFocused:c,isDropdownOpen:x,listboxId:v,activeDescendantId:B,autoFocus:A,handleTextChange:S,handleKeyDown:C,handleCaretAfterInput:y,handleCaretMove:D,startEditingParam:H,replaceEditingRange:X,setFocused:l}=e,_=(0,f.useRef)(null),O=(0,f.useRef)(!1),j=(0,f.useRef)(""),h=(0,f.useRef)(""),ee=(0,f.useRef)(null),M=(0,f.useRef)(0);ee.current=o,(0,f.useEffect)(()=>{if(!A)return;let i=_.current;if(!i)return;document.activeElement===i?l(!0):i.focus();let p=i.ownerDocument??document,m=p.getSelection(),w=m&&m.rangeCount>0&&i.contains(m.anchorNode);if(m&&!w){let g=p.createRange();g.selectNodeContents(i),g.collapse(!0),m.removeAllRanges(),m.addRange(g)}},[A,l]),(0,f.useEffect)(()=>{let i=_.current;if(!i)return;let p=i.ownerDocument??document,m=()=>{let w=p.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!i.contains(w.anchorNode))return;let g=w.anchorNode,J=(g.nodeType===Node.ELEMENT_NODE?g:g.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(J&&J!==s?.id){H(J);return}performance.now()-M.current<50||D((0,F.getCursorOffset)(i))};return p.addEventListener("selectionchange",m),()=>p.removeEventListener("selectionchange",m)},[s,H,D]),(0,f.useLayoutEffect)(()=>{let i=_.current;i&&(0,F.renderEditableContent)({input:i,segments:t,newParamId:a,editingParamId:s?.id??null,placeholderText:d??"",isFocused:c})},[t,a,s,d,c]),(0,f.useLayoutEffect)(()=>{let i=j.current,p=a??"";if(j.current=p,!p||p===i)return;let m=_.current;if(!m)return;m.focus();let w=ee.current??(0,F.plainTextLength)(m);(0,F.setCursorOffset)(m,w)},[a]),(0,f.useLayoutEffect)(()=>{let i=h.current,p=s?.id??"";if(h.current=p,!p||p===i||n==null)return;let m=_.current;m&&(0,F.setCursorOffset)(m,n)},[s,n]);let T=(0,f.useCallback)(()=>{if(O.current)return;let i=_.current;if(!i)return;let p=(0,F.extractPlainText)(i),w=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;S(w)},[S]),V=(0,f.useCallback)(()=>{M.current=performance.now(),T();let i=_.current;i&&y((0,F.getCursorOffset)(i))},[T,y]);(0,f.useEffect)(()=>{let i=_.current;if(!i)return;let p=m=>{let w=m,g=w.inputType;if(g==="insertParagraph"||g==="insertLineBreak"||g==="insertFromDrop"){m.preventDefault();return}if(g.startsWith("insert")||g.startsWith("delete")){let L=g.startsWith("delete")?"":w.data??"";X(L)&&m.preventDefault()}};return i.addEventListener("beforeinput",p),()=>i.removeEventListener("beforeinput",p)},[X]);let z=(0,f.useCallback)(()=>{O.current=!0},[]),te=(0,f.useCallback)(()=>{O.current=!1,T()},[T]),Z=(0,f.useCallback)(i=>{i.preventDefault();let p=_.current;if(!p)return;let m=(i.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!m)return;let w=p.ownerDocument??document,g=w.getSelection();if(!g||g.rangeCount===0)return;let L=g.getRangeAt(0);if(!p.contains(L.startContainer))return;L.deleteContents();let W=w.createTextNode(m);L.insertNode(W),L.setStartAfter(W),L.collapse(!0),g.removeAllRanges(),g.addRange(L),T()},[T]),N=(0,f.useCallback)(i=>C(i),[C]),K=(0,f.useCallback)(()=>l(!0),[l]),b=(0,f.useCallback)(()=>l(!1),[l]),re=(0,f.useCallback)(()=>_.current?.focus(),[]),se=(0,f.useCallback)(()=>_.current?.blur(),[]),ae=(0,f.useCallback)(()=>{let i=_.current;return i?(0,F.extractPlainText)(i):""},[]),u=yt()?"plaintext-only":"true";return{inputRef:_,editorProps:{ref:_,contentEditable:u,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":v,"aria-expanded":x,"aria-activedescendant":B,spellCheck:!0,enterKeyHint:"send",onInput:V,onKeyDown:N,onCompositionStart:z,onCompositionEnd:te,onPaste:Z,onFocus:K,onBlur:b},getPlainText:ae,focus:re,blur:se}}var U=require("react/jsx-runtime");function _t(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var at=(0,P.forwardRef)(function({onSubmit:t,onError:a,optionOverrides:s,maskCompletedText:n,className:o,apiConfig:d,columns:c,pillPlacement:x="dropdown",mode:v="auto",optionsPosition:B="below",animations:A=!0,dropdownTrigger:S,closeDropdownOnBlur:C,showNonTappableOptions:y,autoFocus:D=!0,onFocus:H,onBlur:X,value:l,completedParams:_,onChange:O,onParamsChange:j,submitButton:h},ee){let M=(0,P.useRef)(null),T=(0,P.useRef)(null),V=(0,P.useRef)(()=>{}),z=(0,P.useRef)(null),te=(0,P.useRef)(null);(0,P.useEffect)(()=>{let k=M.current;if(k)return z.current?z.current.setMode(v):z.current=new ge.ModeController(k,v),()=>{z.current?.destroy(),z.current=null}},[v]);let Z=(0,P.useCallback)(k=>{let $=te.current?.current;$&&($.focus(),(0,ge.setCursorOffset)($,k))},[]),{completedParams:N,suggestionPills:K,setActivePill:b,segments:re,newParamId:se,clearNewParamId:ae,placeholderText:u,isFocused:i,isDropdownOpen:p,isActivePillSelected:m,isLoading:w,activeIndex:g,listboxId:L,handleTextChange:W,handleKeyDown:J,setFocused:xe,editingParam:Re,editingAnchor:ve,caretOffset:r,startEditingParam:R,handleCaretAfterInput:E,handleCaretMove:de,replaceEditingRange:fe,dropdownProps:ot,reset:we}=Ce({onSubmit:k=>V.current(k),onError:a,optionOverrides:s,maskCompletedText:n,apiConfig:d,columns:c,dropdownTrigger:S,optionsPosition:B,closeDropdownOnBlur:C,showNonTappableOptions:y,onFocus:H,onBlur:X,value:l,completedParams:_,onChange:O,onParamsChange:j,source:"full-sdk",setCursor:Z});(0,P.useEffect)(()=>{if(!se)return;let k=window.setTimeout(()=>ae(),650);return()=>window.clearTimeout(k)},[se,ae]);let it=g>=0?`${L}-option-${g}`:void 0,{inputRef:De,editorProps:nt,focus:ye,blur:He,getPlainText:Ne}=tt({segments:re,newParamId:se,editingParam:Re,editingAnchor:ve,caretOffset:r,placeholderText:u,isFocused:i,isDropdownOpen:p,listboxId:L,activeDescendantId:it,autoFocus:D,handleTextChange:W,handleKeyDown:J,handleCaretAfterInput:E,handleCaretMove:de,startEditingParam:R,replaceEditingRange:fe,setFocused:xe});te.current=De,(0,P.useLayoutEffect)(()=>{let k=T.current,$=De.current;if(!k||!$)return;let ke=()=>{let We=k.firstElementChild;if(!We)return;let dt=We.getBoundingClientRect(),pt=$.getBoundingClientRect();dt.top>=pt.bottom-2?k.setAttribute("data-aia-pill-wrapped",""):k.removeAttribute("data-aia-pill-wrapped")};ke();let Ke=new ResizeObserver(ke);return Ke.observe($),()=>Ke.disconnect()},[re,K.length,w,De]),(0,P.useImperativeHandle)(ee,()=>({focus:ye,blur:He,reset:we,setMode:k=>z.current?.setMode(k)}),[ye,He,we]);let _e=!!re.length||N.length>0,Te=(0,P.useCallback)(()=>{if(!_e)return;let k=Ne(),{rawQuery:$,completedParams:ke}=(0,ge.buildQuery)(k,N);t({query:k.trim(),raw_query:$,completed_params:ke}),we()},[_e,N,t,we,Ne]);V.current=Te;let rt=(0,P.useCallback)(k=>{k.target?.closest("[data-aia-pill]")||ye()},[ye]),st=x==="inline",lt=x==="dropdown";return(0,U.jsxs)("div",{ref:M,className:`magicx-aia ${le.container} ${o??""}`,"data-pill-placement":x,"data-options-position":B,"data-animations":A?"on":"off","data-mode":_t(v),children:[(0,U.jsx)(Se,{...ot,showPills:lt}),(0,U.jsxs)("div",{className:le.inputWrapper,onClick:rt,children:[(0,U.jsxs)("div",{className:le.editorArea,"data-aia-editor":"",children:[(0,U.jsx)("div",{...nt,className:le.input,"data-aia-input":""}),st&&(w||K.length>0)&&(0,U.jsx)("span",{ref:T,className:le.pillListContainer,"data-aia-pill-list-container":"",children:(0,U.jsx)(Pe,{pills:K,activePillIndex:0,activeSelected:m,onSelectPill:b,loading:w})})]}),h===null?null:h===void 0?(0,U.jsx)(Ye,{disabled:!_e,onClick:Te}):(0,U.jsx)("span",{"data-aia-submit":"",className:le.submitSlot,onClick:k=>{_e&&(k.stopPropagation(),Te())},children:h})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,useAIAutocomplete});
1080
1080
  //# sourceMappingURL=index.js.map