@inkeep/cxkit-primitives 0.5.101 → 0.5.102

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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("openai"),t=require("react"),J=require("react-hook-form"),W=require("../../utils/form.cjs"),X=require("./actions/qa-model-response.cjs"),z=require("./actions/context-model-response.cjs"),Y=require("../../providers/config-provider.cjs"),Z=require("../../providers/conversation-provider.cjs"),ee=require("../../providers/chat-events-provider.cjs"),se=require("./actions/qa-model-messages.cjs"),re=require("../embedded-chat/use-captcha.cjs"),te="root.serverError",R=async(u,s)=>{if(s)return;const o=await re.fetchAndSolveChallenge(`${u}/v1/challenge`);if(o)return{"X-INKEEP-CHALLENGE-SOLUTION":btoa(JSON.stringify(o))}},oe=u=>{const{formSettings:s}=u,{baseSettings:o}=Y.useInkeepConfig(),{conversation:m}=Z.useInkeepConversation(),{logEvent:a}=ee.useChatEvents(),{aiApiBaseUrl:c,shouldBypassCaptcha:S}=o,v=t.useMemo(()=>new $({baseURL:`${c}/v1`,apiKey:o.apiKey,dangerouslyAllowBrowser:!0}),[o.apiKey,c]),[q,w]=t.useState(!1),[M,V]=t.useState(!1),[A,f]=t.useState(!1),[F,h]=t.useState({}),d=t.useMemo(()=>{const{primary:n,secondary:i}=s;return W.getFormDefaultValues([...n.fields,...i.fields])},[s]),{control:b,handleSubmit:I,formState:{errors:C,isSubmitting:N,isSubmitSuccessful:P},reset:_,trigger:O,setValue:k,setError:H}=J.useForm({defaultValues:d});t.useEffect(()=>{d&&_(d)},[_,d]);const L=async n=>{try{await s.buttons.submit.onSubmit({values:n,conversation:m}),a({eventName:"intelligent_form_submitted",properties:{conversation:m,values:n}}),a({eventName:"user_escalation_indicated",properties:{escalationType:"intelligent_support_form",conversation:m}})}catch(i){H(te,{message:i instanceof Error?i.message:"Something went wrong."})}},x=async()=>{const n=s.primary.fields.map(e=>e.name);if(!await O(n))return;V(!0),w(!0);const B=b._formValues,E=s.primary.fields.reduce((e,l)=>(e[l.name]=B[l.name],e),{}),U=s.secondary.fields.filter(e=>e.shouldPrefillWithAI!==!1),g=se.getQAModelMessages(E);a({eventName:"intelligent_form_primary_section_submitted",properties:{}},g);try{const e=await R(c,S),l=await R(c,S),[r,p]=await Promise.all([X.generateQAModelResponse(g,v,e),z.generateContextModelResponse({primaryFieldValues:E,fieldsToGenerate:U},v,l)]);if(p.suggestedValues)for(const[G,Q]of Object.entries(p.suggestedValues))k(G,Q);const y=r.aiAnnotations?.answerConfidence,j=y&&["very_confident","somewhat_confident"].includes(y),D=r.recordsConsidered&&r.recordsConsidered.length>0;j&&D&&r.answer?(h({answer:r.answer,answerConfidence:y,recordsConsidered:r.recordsConsidered}),a({eventName:"intelligent_form_ai_response_provided",properties:{recordsConsidered:r.recordsConsidered}},[...g,{id:Date.now().toString(),role:"assistant",content:r.answer,links:[]}])):(f(!0),h({answer:null,recordsConsidered:r.recordsConsidered,suggestedValues:p.suggestedValues}))}catch(e){console.error(e),f(!0)}finally{w(!1)}},K=I(L),T=C?.root?.serverError;return{formSettings:s,control:b,errors:C,isSubmitSuccessful:P,isSubmitting:N,handleSubmit:K,loading:q,formError:T,submittedPrimaryForm:M,handleSubmitPrimaryForm:x,aiResponse:F,showSecondaryFields:A,setShowSecondaryFields:f}};exports.useInkeepIntelligentForm=oe;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("openai"),t=require("react"),J=require("react-hook-form"),W=require("../../utils/form.cjs"),X=require("./actions/qa-model-response.cjs"),z=require("./actions/context-model-response.cjs"),Y=require("../../providers/config-provider.cjs"),Z=require("../../providers/conversation-provider.cjs"),ee=require("../../providers/chat-events-provider.cjs"),se=require("./actions/qa-model-messages.cjs"),re=require("../embedded-chat/use-captcha.cjs"),te="root.serverError",q=async(u,s)=>{if(s)return;const o=await re.fetchAndSolveChallenge(`${u}/v1/challenge`);if(o)return{"X-INKEEP-CHALLENGE-SOLUTION":btoa(JSON.stringify(o))}},oe=u=>{const{formSettings:s}=u,{baseSettings:o}=Y.useInkeepConfig(),{conversation:m}=Z.useInkeepConversation(),{logEvent:a}=ee.useChatEvents(),{aiApiBaseUrl:c,shouldBypassCaptcha:S}=o,v=t.useMemo(()=>new $({baseURL:`${c}/v1`,apiKey:o.apiKey,dangerouslyAllowBrowser:!0}),[o.apiKey,c]),[M,w]=t.useState(!1),[V,A]=t.useState(!1),[F,f]=t.useState(!1),[I,h]=t.useState({}),d=t.useMemo(()=>{const{primary:n,secondary:i}=s;return W.getFormDefaultValues([...n.fields,...i.fields])},[s]),{control:b,handleSubmit:N,formState:{errors:C,isSubmitting:_,isSubmitSuccessful:P},reset:E,trigger:O,setValue:k,setError:H}=J.useForm({defaultValues:d});t.useEffect(()=>{d&&E(d)},[E,d]);const L=async n=>{if(!_)try{await s.buttons.submit.onSubmit({values:n,conversation:m}),a({eventName:"intelligent_form_submitted",properties:{conversation:m,values:n}}),a({eventName:"user_escalation_indicated",properties:{escalationType:"intelligent_support_form",conversation:m}})}catch(i){H(te,{message:i instanceof Error?i.message:"Something went wrong."})}},x=async()=>{const n=s.primary.fields.map(e=>e.name);if(!await O(n))return;A(!0),w(!0);const B=b._formValues,R=s.primary.fields.reduce((e,l)=>(e[l.name]=B[l.name],e),{}),U=s.secondary.fields.filter(e=>e.shouldPrefillWithAI!==!1),g=se.getQAModelMessages(R);a({eventName:"intelligent_form_primary_section_submitted",properties:{}},g);try{const e=await q(c,S),l=await q(c,S),[r,p]=await Promise.all([X.generateQAModelResponse(g,v,e),z.generateContextModelResponse({primaryFieldValues:R,fieldsToGenerate:U},v,l)]);if(p.suggestedValues)for(const[G,Q]of Object.entries(p.suggestedValues))k(G,Q);const y=r.aiAnnotations?.answerConfidence,j=y&&["very_confident","somewhat_confident"].includes(y),D=r.recordsConsidered&&r.recordsConsidered.length>0;j&&D&&r.answer?(h({answer:r.answer,answerConfidence:y,recordsConsidered:r.recordsConsidered}),a({eventName:"intelligent_form_ai_response_provided",properties:{recordsConsidered:r.recordsConsidered}},[...g,{id:Date.now().toString(),role:"assistant",content:r.answer,links:[]}])):(f(!0),h({answer:null,recordsConsidered:r.recordsConsidered,suggestedValues:p.suggestedValues}))}catch(e){console.error(e),f(!0)}finally{w(!1)}},K=N(L),T=C?.root?.serverError;return{formSettings:s,control:b,errors:C,isSubmitSuccessful:P,isSubmitting:_,handleSubmit:K,loading:M,formError:T,submittedPrimaryForm:V,handleSubmitPrimaryForm:x,aiResponse:I,showSecondaryFields:F,setShowSecondaryFields:f}};exports.useInkeepIntelligentForm=oe;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import J from "openai";
3
- import { useMemo as R, useState as c, useEffect as W } from "react";
3
+ import { useMemo as V, useState as c, useEffect as W } from "react";
4
4
  import { useForm as X } from "react-hook-form";
5
5
  import { getFormDefaultValues as z } from "../../utils/form.js";
6
6
  import { generateQAModelResponse as Y } from "./actions/qa-model-response.js";
@@ -10,7 +10,7 @@ import { useInkeepConversation as se } from "../../providers/conversation-provid
10
10
  import { useChatEvents as re } from "../../providers/chat-events-provider.js";
11
11
  import { getQAModelMessages as te } from "./actions/qa-model-messages.js";
12
12
  import { fetchAndSolveChallenge as oe } from "../embedded-chat/use-captcha.js";
13
- const ne = "root.serverError", V = async (m, s) => {
13
+ const ne = "root.serverError", A = async (m, s) => {
14
14
  if (s) return;
15
15
  const t = await oe(`${m}/v1/challenge`);
16
16
  if (t)
@@ -18,21 +18,21 @@ const ne = "root.serverError", V = async (m, s) => {
18
18
  "X-INKEEP-CHALLENGE-SOLUTION": btoa(JSON.stringify(t))
19
19
  };
20
20
  }, we = (m) => {
21
- const { formSettings: s } = m, { baseSettings: t } = ee(), { conversation: u } = se(), { logEvent: i } = re(), { aiApiBaseUrl: a, shouldBypassCaptcha: w } = t, S = R(
21
+ const { formSettings: s } = m, { baseSettings: t } = ee(), { conversation: u } = se(), { logEvent: i } = re(), { aiApiBaseUrl: a, shouldBypassCaptcha: w } = t, S = V(
22
22
  () => new J({
23
23
  baseURL: `${a}/v1`,
24
24
  apiKey: t.apiKey,
25
25
  dangerouslyAllowBrowser: !0
26
26
  }),
27
27
  [t.apiKey, a]
28
- ), [A, h] = c(!1), [F, N] = c(!1), [I, f] = c(!1), [M, _] = c({}), d = R(() => {
28
+ ), [F, h] = c(!1), [N, I] = c(!1), [M, f] = c(!1), [O, _] = c({}), d = V(() => {
29
29
  const { primary: o, secondary: n } = s;
30
30
  return z([...o.fields, ...n.fields]);
31
31
  }, [s]), {
32
32
  control: C,
33
- handleSubmit: O,
34
- formState: { errors: b, isSubmitting: P, isSubmitSuccessful: L },
35
- reset: v,
33
+ handleSubmit: P,
34
+ formState: { errors: b, isSubmitting: v, isSubmitSuccessful: L },
35
+ reset: E,
36
36
  trigger: k,
37
37
  setValue: x,
38
38
  setError: H
@@ -40,41 +40,42 @@ const ne = "root.serverError", V = async (m, s) => {
40
40
  defaultValues: d
41
41
  });
42
42
  W(() => {
43
- d && v(d);
44
- }, [v, d]);
43
+ d && E(d);
44
+ }, [E, d]);
45
45
  const K = async (o) => {
46
- try {
47
- await s.buttons.submit.onSubmit({
48
- values: o,
49
- conversation: u
50
- }), i({
51
- eventName: "intelligent_form_submitted",
52
- properties: {
53
- conversation: u,
54
- values: o
55
- }
56
- }), i({
57
- eventName: "user_escalation_indicated",
58
- properties: {
59
- escalationType: "intelligent_support_form",
46
+ if (!v)
47
+ try {
48
+ await s.buttons.submit.onSubmit({
49
+ values: o,
60
50
  conversation: u
61
- }
62
- });
63
- } catch (n) {
64
- H(ne, {
65
- message: n instanceof Error ? n.message : "Something went wrong."
66
- });
67
- }
51
+ }), i({
52
+ eventName: "intelligent_form_submitted",
53
+ properties: {
54
+ conversation: u,
55
+ values: o
56
+ }
57
+ }), i({
58
+ eventName: "user_escalation_indicated",
59
+ properties: {
60
+ escalationType: "intelligent_support_form",
61
+ conversation: u
62
+ }
63
+ });
64
+ } catch (n) {
65
+ H(ne, {
66
+ message: n instanceof Error ? n.message : "Something went wrong."
67
+ });
68
+ }
68
69
  }, B = async () => {
69
70
  const o = s.primary.fields.map((e) => e.name);
70
71
  if (!await k(o)) return;
71
- N(!0), h(!0);
72
- const q = C._formValues, E = s.primary.fields.reduce(
72
+ I(!0), h(!0);
73
+ const q = C._formValues, R = s.primary.fields.reduce(
73
74
  (e, l) => (e[l.name] = q[l.name], e),
74
75
  {}
75
76
  ), D = s.secondary.fields.filter(
76
77
  (e) => e.shouldPrefillWithAI !== !1
77
- ), p = te(E);
78
+ ), p = te(R);
78
79
  i(
79
80
  {
80
81
  eventName: "intelligent_form_primary_section_submitted",
@@ -83,10 +84,10 @@ const ne = "root.serverError", V = async (m, s) => {
83
84
  p
84
85
  );
85
86
  try {
86
- const e = await V(a, w), l = await V(a, w), [r, g] = await Promise.all([
87
+ const e = await A(a, w), l = await A(a, w), [r, g] = await Promise.all([
87
88
  Y(p, S, e),
88
89
  Z(
89
- { primaryFieldValues: E, fieldsToGenerate: D },
90
+ { primaryFieldValues: R, fieldsToGenerate: D },
90
91
  S,
91
92
  l
92
93
  )
@@ -120,20 +121,20 @@ const ne = "root.serverError", V = async (m, s) => {
120
121
  } finally {
121
122
  h(!1);
122
123
  }
123
- }, T = O(K), U = b?.root?.serverError;
124
+ }, T = P(K), U = b?.root?.serverError;
124
125
  return {
125
126
  formSettings: s,
126
127
  control: C,
127
128
  errors: b,
128
129
  isSubmitSuccessful: L,
129
- isSubmitting: P,
130
+ isSubmitting: v,
130
131
  handleSubmit: T,
131
- loading: A,
132
+ loading: F,
132
133
  formError: U,
133
- submittedPrimaryForm: F,
134
+ submittedPrimaryForm: N,
134
135
  handleSubmitPrimaryForm: B,
135
- aiResponse: M,
136
- showSecondaryFields: I,
136
+ aiResponse: O,
137
+ showSecondaryFields: M,
137
138
  setShowSecondaryFields: f
138
139
  };
139
140
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("./factory.cjs"),F=require("react"),k=require("react-textarea-autosize"),g=require("../atoms/select.cjs"),je=require("@radix-ui/react-checkbox"),m=require("./intelligent-form/intelligent-form-provider.cjs"),Ae=require("@radix-ui/react-scroll-area"),p=require("../atoms/icons/built-in-icon-renderer.cjs"),c=require("../utils/misc.cjs"),Te=require("react-hook-form"),I=require("../providers/intelligent-form-field-provider.cjs"),Be=require("../atoms/icons/checkbox-icon.cjs"),y=require("../providers/config-provider.cjs"),h=require("../providers/source-item-provider.cjs"),He=require("../atoms/link.cjs"),Ee=require("../atoms/markdown/index.cjs"),P=require("../utils/compose-refs.cjs"),u=require("../utils/compose-event-handlers.cjs"),Le=require("../utils/transform-source/index.cjs");function x(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const R=x(je),S=x(Ae),qe=n.ikp("form",{_id:"intelligentForm__Root"}),w=i=>{const{onSubmit:e,...t}=i,{handleSubmit:r}=m.useIntelligentForm();return o.jsx(qe,{onSubmit:u.composeEventHandlers(e,r),...t})},j=n.ikp("h2",{_id:"intelligentForm__Heading",children:"Contact Support"}),A=n.ikp("div",{_id:"intelligentForm__Content"}),T=n.ikp(S.Root,{_id:"intelligentForm__Content__ScrollArea"}),Ve=n.ikp(S.Viewport,{_id:"intelligentForm__Content__ScrollAreaViewport"}),B=i=>{const{children:e,...t}=i;return o.jsx(Ve,{children:o.jsx("div",{"data-part":"grid",style:{display:"grid"},children:e}),...t})},H=n.ikp(S.ScrollAreaScrollbar,{_id:"intelligentForm__Content__ScrollAreaScrollbar"}),E=n.ikp(S.ScrollAreaThumb,{_id:"intelligentForm__Content__ScrollAreaThumb"}),L=n.ikp(S.Corner,{_id:"intelligentForm__Content__ScrollAreaCorner"}),De=n.ikp("div",{_id:"intelligentForm__Success"}),q=i=>{const{children:e,...t}=i,{isSubmitSuccessful:r}=m.useIntelligentForm();return r?o.jsx(De,{...t,children:e}):null},Ne=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SuccessIcon"}),V=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Ne,{iconSettings:e.icon??{builtIn:"LuCircleCheck"},...i})},Oe=n.ikp("h2",{_id:"intelligentForm__SuccessHeading"}),D=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Oe,{children:e.heading,...i})},Me=n.ikp("p",{_id:"intelligentForm__SuccessMessage"}),N=i=>{const{formSettings:{successView:e}}=m.useIntelligentForm();return o.jsx(Me,{children:e.message,...i})},O=n.ikp("div",{_id:"intelligentForm__PrimaryForm"}),ze=n.ikp("div",{_id:"intelligentForm__PrimaryFormFields"}),Ue=n.ikp("p",{_id:"intelligentForm__PrimaryForm__Description"}),M=i=>{const{formSettings:{primary:e}}=m.useIntelligentForm();return e.description?o.jsx(Ue,{children:e.description,...i}):null},z=i=>{const{children:e,...t}=i,{formSettings:{primary:r}}=m.useIntelligentForm();return o.jsx(ze,{children:c.maybeRender(e,r.fields),...t})},$e=n.ikp("button",{_id:"intelligentForm__PrimaryFormSubmit",type:"button",children:"Next"}),U=i=>{const{onClick:e,...t}=i,{submittedPrimaryForm:r,handleSubmitPrimaryForm:l}=m.useIntelligentForm();return o.jsx($e,{"data-submitted":c.dataAttr(r),onClick:u.composeEventHandlers(e,l),...t})},Qe=n.ikp("div",{_id:"intelligentForm__Field"}),$=i=>{const{field:e,autoFocus:t,...r}=i,{control:l,errors:s}=m.useIntelligentForm();return o.jsx(Te.Controller,{name:e.name,control:l,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const a=d.value!==void 0||e.inputType==="file";return o.jsx(I.IntelligentFormFieldProvider,{"data-invalid":c.dataAttr(!!s[e.name]),field:e,fieldProps:d,autoFocus:t,children:a&&o.jsx(Qe,{"data-input-type":e.inputType,"data-hidden":c.dataAttr(e.isHidden),...r})})}})},We=n.ikp("label",{_id:"intelligentForm__FieldLabel"}),Q=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx(We,{"data-required":c.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...i})},Ge=n.ikp("input",{_id:"intelligentForm__FieldText",type:"text"}),f=F.forwardRef((i,e)=>{const{field:t,error:r,fieldProps:{onChange:l,onBlur:s,ref:d,...a},autoFocus:v}=I.useIntelligentFormField(),_=P.useComposedRefs(e,d);return o.jsx(Ge,{asChild:t.inputType==="textarea",ref:_,id:t.name,autoFocus:v,placeholder:"placeholder"in t?t.placeholder:void 0,"data-invalid":c.dataAttr(!!r),onChange:u.composeEventHandlers(i.onChange,l),onBlur:u.composeEventHandlers(i.onBlur,s),...a,...i,children:t.inputType==="textarea"?o.jsx(k,{minRows:3,maxRows:10}):null})}),W=n.ikp(f,{_id:"intelligentForm__FieldEmail",type:"email"}),Je=n.ikp("input",{_id:"intelligentForm__FieldFile",type:"file",multiple:!0}),G=i=>{const{field:e,error:t,fieldProps:{value:r,onChange:l,onBlur:s,...d},autoFocus:a}=I.useIntelligentFormField(),{onChange:v,onBlur:_,...b}=i,C=Re=>{const we=Re.target.files;l(we)};return o.jsx(Je,{id:e.name,autoFocus:a,"data-value":r,"data-invalid":c.dataAttr(!!t),...b,...d,onChange:u.composeEventHandlers(v,C),onBlur:u.composeEventHandlers(_,s)})},J=n.ikp(f,{_id:"intelligentForm__FieldTextArea",type:"textarea",asChild:!0,children:o.jsx(k,{rows:1,maxRows:8})}),Ke=n.ikp(R.Root,{_id:"intelligentForm__FieldCheckbox"}),K=i=>{const{field:e,error:t,fieldProps:r,autoFocus:l}=I.useIntelligentFormField(),{onCheckedChange:s,...d}=i;return o.jsx(Ke,{id:e.name,name:e.name,autoFocus:l,"data-invalid":c.dataAttr(!!t),checked:r.value,onCheckedChange:u.composeEventHandlers(s,r.onChange),...d})},X=n.ikp(R.Indicator,{_id:"intelligentForm__FieldCheckboxIndicator",children:o.jsx(Be.CheckboxIcon,{})}),Xe=n.ikp(g.Root,{_id:"intelligentForm__FieldSelect"}),Y=i=>{const{field:e,error:t,fieldProps:r}=I.useIntelligentFormField(),{onValueChange:l,...s}=i;return o.jsx(Xe,{name:e.name,"data-invalid":c.dataAttr(!!t),value:r.value,onValueChange:u.composeEventHandlers(l,r.onChange),...s})},Z=n.ikp(g.Trigger,{_id:"intelligentForm__FieldSelect__Trigger"}),Ye=n.ikp(g.Value,{_id:"intelligentForm__FieldSelect__Value"}),ee=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx(Ye,{placeholder:"placeholder"in e?e.placeholder:void 0,...i})},ie=n.ikp(g.Icon,{_id:"intelligentForm__FieldSelect__Icon",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),te=n.ikp(g.Content,{_id:"intelligentForm__FieldSelect__Content",position:"popper"}),ne=n.ikp(g.Viewport,{_id:"intelligentForm__FieldSelect__Viewport"}),re=n.ikp(g.Item,{_id:"intelligentForm__FieldSelect__Item"}),oe=n.ikp(g.ItemText,{_id:"intelligentForm__FieldSelect__ItemText"}),le=n.ikp(g.ItemIndicator,{_id:"intelligentForm__FieldSelect__ItemIndicator",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),Ze=n.ikp("span",{_id:"intelligentForm__FieldError"}),me=i=>{const{error:e}=I.useIntelligentFormField();return e?o.jsx(Ze,{children:e.message?.toString(),...i}):null},se=n.ikp("div",{_id:"intelligentForm__BotHeading"}),ce=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__BotHeading__Icon",iconSettings:{builtIn:"LuSparkles"}}),ei=n.ikp("div",{_id:"intelligentForm__BotHeading__Name"}),de=i=>{const{baseSettings:e}=y.useInkeepConfig(),{organizationDisplayName:t}=e??{},{formSettings:{aiAssistantName:r}}=m.useIntelligentForm();return o.jsx(ei,{children:r??t,...i})},ii=n.ikp("div",{_id:"intelligentForm__Loading"}),Fe=F.forwardRef(({...i},e)=>{const{loading:t}=m.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(ii,{ref:l,...i}):null}),ti=n.ikp("div",{_id:"intelligentForm__ConfidentResponse"}),ae=F.forwardRef(({...i},e)=>{const{aiResponse:t,loading:r}=m.useIntelligentForm(),l=F.useRef(null),s=P.useComposedRefs(e,l);return F.useEffect(()=>{!r&&t.answerConfidence&&l.current&&l.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[r,t.answerConfidence]),t.answerConfidence?o.jsx(ti,{ref:s,...i}):null}),ni=n.ikp(Ee.Markdown,{_id:"intelligentForm__ConfidentAnswer"}),ue=i=>{const{aiResponse:e}=m.useIntelligentForm();return o.jsx(ni,{shouldOpenLinksInNewTab:!0,children:e.answer,...i})},ri=n.ikp("button",{_id:"intelligentForm__ConfidentResponseButton",type:"button"}),ge=i=>{const{onClick:e,...t}=i,{showSecondaryFields:r,setShowSecondaryFields:l}=m.useIntelligentForm(),s=()=>{l(!0)};return o.jsx(ri,{"data-escalated":c.dataAttr(r),onClick:u.composeEventHandlers(e,s),...t})},Ie=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__ConfidentResponseButton__Icon",iconSettings:{builtIn:"LuUser"}}),_e=n.ikp("span",{_id:"intelligentForm__ConfidentResponseButton__Label",children:"Escalate to human"}),oi=n.ikp("div",{_id:"intelligentForm__SecondaryForm"}),pe=F.forwardRef(({...i},e)=>{const{showSecondaryFields:t}=m.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(oi,{ref:l,...i}):null}),li=n.ikp("p",{_id:"intelligentForm__SecondaryForm__Description"}),ve=i=>{const{formSettings:{secondary:e},aiResponse:{answerConfidence:t}}=m.useIntelligentForm();if(!e.description)return null;const r=typeof e.description=="string"?e.description:t?e.description.confident:e.description.default;return o.jsx(li,{children:r,...i})},mi=n.ikp("div",{_id:"intelligentForm__SecondaryFormFields"}),Se=i=>{const{children:e,...t}=i,{formSettings:{secondary:r}}=m.useIntelligentForm();return o.jsx(mi,{children:c.maybeRender(e,r.fields),...t})},si=n.ikp("button",{_id:"intelligentForm__SecondaryFormSubmit",type:"submit",children:"Submit"}),Pe=i=>{const{formSettings:e}=m.useIntelligentForm(),{label:t}=e.buttons.submit;return o.jsx(si,{children:t??"Submit",...i})},ci=n.ikp("span",{_id:"intelligentForm__Error"}),fe=i=>{const{formError:e}=m.useIntelligentForm();return e?o.jsx(ci,{children:e.message,...i}):null},Ce=n.ikp("div",{_id:"intelligentForm__Sources"}),he=n.ikp("p",{_id:"intelligentForm__SourcesCaption",children:"Here are the sources I considered:"}),di=n.ikp("div",{_id:"intelligentForm__SourcesList"}),be=i=>{const{children:e,...t}=i,{baseSettings:{transformSource:r,organizationDisplayName:l}}=y.useInkeepConfig(),{aiResponse:{recordsConsidered:s}}=m.useIntelligentForm();if(!s)return null;const d=s.reduce((a,v)=>{const _=Le.transformInkeepSource(v,"intelligentFormSource",{organizationDisplayName:l,transformSource:r});return a.some(C=>C.url===_.url)||a.push(_),a},[]);return o.jsx(di,{children:c.maybeRender(e,d),...t})},Fi=n.ikp(He.LinkWithQueryParams,{_id:"intelligentForm__Source"}),ke=i=>{const{source:e,...t}=i;return o.jsx(h.SourceItemProvider,{source:{...e,isExternal:!!e.shouldOpenInNewTab},children:o.jsx(Fi,{"data-type":e.type,appendToUrl:e.appendToUrl,href:e.url,isExternal:e.shouldOpenInNewTab!==!1,...t})})},ai=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SourceIcon"}),ye=i=>{const{source:e}=h.useSourceItem();return o.jsx(ai,{iconSettings:e.icon,"data-type":e.type,...i})},ui=n.ikp("span",{_id:"intelligentForm__SourceTitle"}),xe=i=>{const{source:e}=h.useSourceItem();return o.jsx(ui,{"data-type":e.type,children:e.title,...i})};exports.Provider=m.IntelligentFormProvider;exports.BotHeading=se;exports.BotHeadingIcon=ce;exports.BotHeadingName=de;exports.ConfidentAnswer=ue;exports.ConfidentResponse=ae;exports.ConfidentResponseButton=ge;exports.ConfidentResponseButtonIcon=Ie;exports.ConfidentResponseButtonLabel=_e;exports.Content=A;exports.ContentScrollArea=T;exports.ContentScrollAreaCorner=L;exports.ContentScrollAreaScrollbar=H;exports.ContentScrollAreaThumb=E;exports.ContentScrollAreaViewport=B;exports.Error=fe;exports.FormField=$;exports.FormFieldCheckbox=K;exports.FormFieldCheckboxIndicator=X;exports.FormFieldEmail=W;exports.FormFieldError=me;exports.FormFieldFile=G;exports.FormFieldLabel=Q;exports.FormFieldSelect=Y;exports.FormFieldSelectContent=te;exports.FormFieldSelectIcon=ie;exports.FormFieldSelectItem=re;exports.FormFieldSelectItemIndicator=le;exports.FormFieldSelectItemText=oe;exports.FormFieldSelectTrigger=Z;exports.FormFieldSelectValue=ee;exports.FormFieldSelectViewport=ne;exports.FormFieldText=f;exports.FormFieldTextArea=J;exports.Heading=j;exports.IntelligentFormPrimitiveBotHeading=se;exports.IntelligentFormPrimitiveBotHeadingIcon=ce;exports.IntelligentFormPrimitiveBotHeadingName=de;exports.IntelligentFormPrimitiveConfidentAnswer=ue;exports.IntelligentFormPrimitiveConfidentResponse=ae;exports.IntelligentFormPrimitiveConfidentResponseButton=ge;exports.IntelligentFormPrimitiveConfidentResponseButtonIcon=Ie;exports.IntelligentFormPrimitiveConfidentResponseButtonLabel=_e;exports.IntelligentFormPrimitiveContent=A;exports.IntelligentFormPrimitiveContentScrollArea=T;exports.IntelligentFormPrimitiveContentScrollAreaCorner=L;exports.IntelligentFormPrimitiveContentScrollAreaScrollbar=H;exports.IntelligentFormPrimitiveContentScrollAreaThumb=E;exports.IntelligentFormPrimitiveContentScrollAreaViewport=B;exports.IntelligentFormPrimitiveFormError=fe;exports.IntelligentFormPrimitiveFormField=$;exports.IntelligentFormPrimitiveFormFieldCheckbox=K;exports.IntelligentFormPrimitiveFormFieldCheckboxIndicator=X;exports.IntelligentFormPrimitiveFormFieldEmail=W;exports.IntelligentFormPrimitiveFormFieldError=me;exports.IntelligentFormPrimitiveFormFieldFile=G;exports.IntelligentFormPrimitiveFormFieldLabel=Q;exports.IntelligentFormPrimitiveFormFieldSelect=Y;exports.IntelligentFormPrimitiveFormFieldSelectContent=te;exports.IntelligentFormPrimitiveFormFieldSelectIcon=ie;exports.IntelligentFormPrimitiveFormFieldSelectItem=re;exports.IntelligentFormPrimitiveFormFieldSelectItemIndicator=le;exports.IntelligentFormPrimitiveFormFieldSelectItemText=oe;exports.IntelligentFormPrimitiveFormFieldSelectTrigger=Z;exports.IntelligentFormPrimitiveFormFieldSelectValue=ee;exports.IntelligentFormPrimitiveFormFieldSelectViewport=ne;exports.IntelligentFormPrimitiveFormFieldText=f;exports.IntelligentFormPrimitiveFormFieldTextArea=J;exports.IntelligentFormPrimitiveHeading=j;exports.IntelligentFormPrimitiveLoading=Fe;exports.IntelligentFormPrimitivePrimaryForm=O;exports.IntelligentFormPrimitivePrimaryFormDescription=M;exports.IntelligentFormPrimitivePrimaryFormFields=z;exports.IntelligentFormPrimitivePrimaryFormSubmit=U;exports.IntelligentFormPrimitiveRoot=w;exports.IntelligentFormPrimitiveSecondaryForm=pe;exports.IntelligentFormPrimitiveSecondaryFormDescription=ve;exports.IntelligentFormPrimitiveSecondaryFormFields=Se;exports.IntelligentFormPrimitiveSecondaryFormSubmit=Pe;exports.IntelligentFormPrimitiveSource=ke;exports.IntelligentFormPrimitiveSourceIcon=ye;exports.IntelligentFormPrimitiveSourceTitle=xe;exports.IntelligentFormPrimitiveSources=Ce;exports.IntelligentFormPrimitiveSourcesCaption=he;exports.IntelligentFormPrimitiveSourcesList=be;exports.IntelligentFormPrimitiveSuccess=q;exports.IntelligentFormPrimitiveSuccessHeading=D;exports.IntelligentFormPrimitiveSuccessIcon=V;exports.IntelligentFormPrimitiveSuccessMessage=N;exports.Loading=Fe;exports.PrimaryForm=O;exports.PrimaryFormDescription=M;exports.PrimaryFormFields=z;exports.PrimaryFormSubmit=U;exports.Root=w;exports.SecondaryForm=pe;exports.SecondaryFormDescription=ve;exports.SecondaryFormFields=Se;exports.SecondaryFormSubmit=Pe;exports.Source=ke;exports.SourceIcon=ye;exports.SourceTitle=xe;exports.Sources=Ce;exports.SourcesCaption=he;exports.SourcesList=be;exports.Success=q;exports.SuccessHeading=D;exports.SuccessIcon=V;exports.SuccessMessage=N;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("./factory.cjs"),F=require("react"),k=require("react-textarea-autosize"),g=require("../atoms/select.cjs"),je=require("@radix-ui/react-checkbox"),s=require("./intelligent-form/intelligent-form-provider.cjs"),Ae=require("@radix-ui/react-scroll-area"),p=require("../atoms/icons/built-in-icon-renderer.cjs"),c=require("../utils/misc.cjs"),Te=require("react-hook-form"),I=require("../providers/intelligent-form-field-provider.cjs"),Be=require("../atoms/icons/checkbox-icon.cjs"),y=require("../providers/config-provider.cjs"),h=require("../providers/source-item-provider.cjs"),He=require("../atoms/link.cjs"),Ee=require("../atoms/markdown/index.cjs"),P=require("../utils/compose-refs.cjs"),u=require("../utils/compose-event-handlers.cjs"),Le=require("../utils/transform-source/index.cjs");function x(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const R=x(je),S=x(Ae),qe=n.ikp("form",{_id:"intelligentForm__Root"}),w=i=>{const{onSubmit:e,...t}=i,{handleSubmit:r}=s.useIntelligentForm();return o.jsx(qe,{onSubmit:u.composeEventHandlers(e,r),...t})},j=n.ikp("h2",{_id:"intelligentForm__Heading",children:"Contact Support"}),A=n.ikp("div",{_id:"intelligentForm__Content"}),T=n.ikp(S.Root,{_id:"intelligentForm__Content__ScrollArea"}),Ve=n.ikp(S.Viewport,{_id:"intelligentForm__Content__ScrollAreaViewport"}),B=i=>{const{children:e,...t}=i;return o.jsx(Ve,{children:o.jsx("div",{"data-part":"grid",style:{display:"grid"},children:e}),...t})},H=n.ikp(S.ScrollAreaScrollbar,{_id:"intelligentForm__Content__ScrollAreaScrollbar"}),E=n.ikp(S.ScrollAreaThumb,{_id:"intelligentForm__Content__ScrollAreaThumb"}),L=n.ikp(S.Corner,{_id:"intelligentForm__Content__ScrollAreaCorner"}),De=n.ikp("div",{_id:"intelligentForm__Success"}),q=i=>{const{children:e,...t}=i,{isSubmitSuccessful:r}=s.useIntelligentForm();return r?o.jsx(De,{...t,children:e}):null},Ne=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SuccessIcon"}),V=i=>{const{formSettings:{successView:e}}=s.useIntelligentForm();return o.jsx(Ne,{iconSettings:e.icon??{builtIn:"LuCircleCheck"},...i})},Oe=n.ikp("h2",{_id:"intelligentForm__SuccessHeading"}),D=i=>{const{formSettings:{successView:e}}=s.useIntelligentForm();return o.jsx(Oe,{children:e.heading,...i})},Me=n.ikp("p",{_id:"intelligentForm__SuccessMessage"}),N=i=>{const{formSettings:{successView:e}}=s.useIntelligentForm();return o.jsx(Me,{children:e.message,...i})},O=n.ikp("div",{_id:"intelligentForm__PrimaryForm"}),ze=n.ikp("div",{_id:"intelligentForm__PrimaryFormFields"}),Ue=n.ikp("p",{_id:"intelligentForm__PrimaryForm__Description"}),M=i=>{const{formSettings:{primary:e}}=s.useIntelligentForm();return e.description?o.jsx(Ue,{children:e.description,...i}):null},z=i=>{const{children:e,...t}=i,{formSettings:{primary:r}}=s.useIntelligentForm();return o.jsx(ze,{children:c.maybeRender(e,r.fields),...t})},$e=n.ikp("button",{_id:"intelligentForm__PrimaryFormSubmit",type:"button",children:"Next"}),U=i=>{const{onClick:e,...t}=i,{submittedPrimaryForm:r,handleSubmitPrimaryForm:l}=s.useIntelligentForm();return o.jsx($e,{"data-submitted":c.dataAttr(r),onClick:u.composeEventHandlers(e,l),...t})},Qe=n.ikp("div",{_id:"intelligentForm__Field"}),$=i=>{const{field:e,autoFocus:t,...r}=i,{control:l,errors:m}=s.useIntelligentForm();return o.jsx(Te.Controller,{name:e.name,control:l,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const a=d.value!==void 0||e.inputType==="file";return o.jsx(I.IntelligentFormFieldProvider,{"data-invalid":c.dataAttr(!!m[e.name]),field:e,fieldProps:d,autoFocus:t,children:a&&o.jsx(Qe,{"data-input-type":e.inputType,"data-hidden":c.dataAttr(e.isHidden),...r})})}})},We=n.ikp("label",{_id:"intelligentForm__FieldLabel"}),Q=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx(We,{"data-required":c.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...i})},Ge=n.ikp("input",{_id:"intelligentForm__FieldText",type:"text"}),f=F.forwardRef((i,e)=>{const{field:t,error:r,fieldProps:{onChange:l,onBlur:m,ref:d,...a},autoFocus:v}=I.useIntelligentFormField(),_=P.useComposedRefs(e,d);return o.jsx(Ge,{asChild:t.inputType==="textarea",ref:_,id:t.name,autoFocus:v,placeholder:"placeholder"in t?t.placeholder:void 0,"data-invalid":c.dataAttr(!!r),onChange:u.composeEventHandlers(i.onChange,l),onBlur:u.composeEventHandlers(i.onBlur,m),...a,...i,children:t.inputType==="textarea"?o.jsx(k,{minRows:3,maxRows:10}):null})}),W=n.ikp(f,{_id:"intelligentForm__FieldEmail",type:"email"}),Je=n.ikp("input",{_id:"intelligentForm__FieldFile",type:"file",multiple:!0}),G=i=>{const{field:e,error:t,fieldProps:{value:r,onChange:l,onBlur:m,...d},autoFocus:a}=I.useIntelligentFormField(),{onChange:v,onBlur:_,...b}=i,C=Re=>{const we=Re.target.files;l(we)};return o.jsx(Je,{id:e.name,autoFocus:a,"data-value":r,"data-invalid":c.dataAttr(!!t),...b,...d,onChange:u.composeEventHandlers(v,C),onBlur:u.composeEventHandlers(_,m)})},J=n.ikp(f,{_id:"intelligentForm__FieldTextArea",type:"textarea",asChild:!0,children:o.jsx(k,{rows:1,maxRows:8})}),Ke=n.ikp(R.Root,{_id:"intelligentForm__FieldCheckbox"}),K=i=>{const{field:e,error:t,fieldProps:r,autoFocus:l}=I.useIntelligentFormField(),{onCheckedChange:m,...d}=i;return o.jsx(Ke,{id:e.name,name:e.name,autoFocus:l,"data-invalid":c.dataAttr(!!t),checked:r.value,onCheckedChange:u.composeEventHandlers(m,r.onChange),...d})},X=n.ikp(R.Indicator,{_id:"intelligentForm__FieldCheckboxIndicator",children:o.jsx(Be.CheckboxIcon,{})}),Xe=n.ikp(g.Root,{_id:"intelligentForm__FieldSelect"}),Y=i=>{const{field:e,error:t,fieldProps:r}=I.useIntelligentFormField(),{onValueChange:l,...m}=i;return o.jsx(Xe,{name:e.name,"data-invalid":c.dataAttr(!!t),value:r.value,onValueChange:u.composeEventHandlers(l,r.onChange),...m})},Z=n.ikp(g.Trigger,{_id:"intelligentForm__FieldSelect__Trigger"}),Ye=n.ikp(g.Value,{_id:"intelligentForm__FieldSelect__Value"}),ee=i=>{const{field:e}=I.useIntelligentFormField();return o.jsx(Ye,{placeholder:"placeholder"in e?e.placeholder:void 0,...i})},ie=n.ikp(g.Icon,{_id:"intelligentForm__FieldSelect__Icon",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),te=n.ikp(g.Content,{_id:"intelligentForm__FieldSelect__Content",position:"popper"}),ne=n.ikp(g.Viewport,{_id:"intelligentForm__FieldSelect__Viewport"}),re=n.ikp(g.Item,{_id:"intelligentForm__FieldSelect__Item"}),oe=n.ikp(g.ItemText,{_id:"intelligentForm__FieldSelect__ItemText"}),le=n.ikp(g.ItemIndicator,{_id:"intelligentForm__FieldSelect__ItemIndicator",asChild:!0,children:o.jsx(p.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),Ze=n.ikp("span",{_id:"intelligentForm__FieldError"}),se=i=>{const{error:e}=I.useIntelligentFormField();return e?o.jsx(Ze,{children:e.message?.toString(),...i}):null},me=n.ikp("div",{_id:"intelligentForm__BotHeading"}),ce=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__BotHeading__Icon",iconSettings:{builtIn:"LuSparkles"}}),ei=n.ikp("div",{_id:"intelligentForm__BotHeading__Name"}),de=i=>{const{baseSettings:e}=y.useInkeepConfig(),{organizationDisplayName:t}=e??{},{formSettings:{aiAssistantName:r}}=s.useIntelligentForm();return o.jsx(ei,{children:r??t,...i})},ii=n.ikp("div",{_id:"intelligentForm__Loading"}),Fe=F.forwardRef(({...i},e)=>{const{loading:t}=s.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(ii,{ref:l,...i}):null}),ti=n.ikp("div",{_id:"intelligentForm__ConfidentResponse"}),ae=F.forwardRef(({...i},e)=>{const{aiResponse:t,loading:r}=s.useIntelligentForm(),l=F.useRef(null),m=P.useComposedRefs(e,l);return F.useEffect(()=>{!r&&t.answerConfidence&&l.current&&l.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[r,t.answerConfidence]),t.answerConfidence?o.jsx(ti,{ref:m,...i}):null}),ni=n.ikp(Ee.Markdown,{_id:"intelligentForm__ConfidentAnswer"}),ue=i=>{const{aiResponse:e}=s.useIntelligentForm();return o.jsx(ni,{shouldOpenLinksInNewTab:!0,children:e.answer,...i})},ri=n.ikp("button",{_id:"intelligentForm__ConfidentResponseButton",type:"button"}),ge=i=>{const{onClick:e,...t}=i,{showSecondaryFields:r,setShowSecondaryFields:l}=s.useIntelligentForm(),m=()=>{l(!0)};return o.jsx(ri,{"data-escalated":c.dataAttr(r),onClick:u.composeEventHandlers(e,m),...t})},Ie=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__ConfidentResponseButton__Icon",iconSettings:{builtIn:"LuUser"}}),_e=n.ikp("span",{_id:"intelligentForm__ConfidentResponseButton__Label",children:"Escalate to human"}),oi=n.ikp("div",{_id:"intelligentForm__SecondaryForm"}),pe=F.forwardRef(({...i},e)=>{const{showSecondaryFields:t}=s.useIntelligentForm(),r=F.useRef(null),l=P.useComposedRefs(e,r);return F.useEffect(()=>{t&&r.current&&r.current.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},[t]),t?o.jsx(oi,{ref:l,...i}):null}),li=n.ikp("p",{_id:"intelligentForm__SecondaryForm__Description"}),ve=i=>{const{formSettings:{secondary:e},aiResponse:{answerConfidence:t}}=s.useIntelligentForm();if(!e.description)return null;const r=typeof e.description=="string"?e.description:t?e.description.confident:e.description.default;return o.jsx(li,{children:r,...i})},si=n.ikp("div",{_id:"intelligentForm__SecondaryFormFields"}),Se=i=>{const{children:e,...t}=i,{formSettings:{secondary:r}}=s.useIntelligentForm();return o.jsx(si,{children:c.maybeRender(e,r.fields),...t})},mi=n.ikp("button",{_id:"intelligentForm__SecondaryFormSubmit",type:"submit",children:"Submit"}),Pe=i=>{const{formSettings:e,isSubmitting:t}=s.useIntelligentForm(),{label:r}=e.buttons.submit;return o.jsx(mi,{disabled:t,children:r??"Submit",...i})},ci=n.ikp("span",{_id:"intelligentForm__Error"}),fe=i=>{const{formError:e}=s.useIntelligentForm();return e?o.jsx(ci,{children:e.message,...i}):null},Ce=n.ikp("div",{_id:"intelligentForm__Sources"}),he=n.ikp("p",{_id:"intelligentForm__SourcesCaption",children:"Here are the sources I considered:"}),di=n.ikp("div",{_id:"intelligentForm__SourcesList"}),be=i=>{const{children:e,...t}=i,{baseSettings:{transformSource:r,organizationDisplayName:l}}=y.useInkeepConfig(),{aiResponse:{recordsConsidered:m}}=s.useIntelligentForm();if(!m)return null;const d=m.reduce((a,v)=>{const _=Le.transformInkeepSource(v,"intelligentFormSource",{organizationDisplayName:l,transformSource:r});return a.some(C=>C.url===_.url)||a.push(_),a},[]);return o.jsx(di,{children:c.maybeRender(e,d),...t})},Fi=n.ikp(He.LinkWithQueryParams,{_id:"intelligentForm__Source"}),ke=i=>{const{source:e,...t}=i;return o.jsx(h.SourceItemProvider,{source:{...e,isExternal:!!e.shouldOpenInNewTab},children:o.jsx(Fi,{"data-type":e.type,appendToUrl:e.appendToUrl,href:e.url,isExternal:e.shouldOpenInNewTab!==!1,...t})})},ai=n.ikp(p.BuiltInIconRenderer,{_id:"intelligentForm__SourceIcon"}),ye=i=>{const{source:e}=h.useSourceItem();return o.jsx(ai,{iconSettings:e.icon,"data-type":e.type,...i})},ui=n.ikp("span",{_id:"intelligentForm__SourceTitle"}),xe=i=>{const{source:e}=h.useSourceItem();return o.jsx(ui,{"data-type":e.type,children:e.title,...i})};exports.Provider=s.IntelligentFormProvider;exports.BotHeading=me;exports.BotHeadingIcon=ce;exports.BotHeadingName=de;exports.ConfidentAnswer=ue;exports.ConfidentResponse=ae;exports.ConfidentResponseButton=ge;exports.ConfidentResponseButtonIcon=Ie;exports.ConfidentResponseButtonLabel=_e;exports.Content=A;exports.ContentScrollArea=T;exports.ContentScrollAreaCorner=L;exports.ContentScrollAreaScrollbar=H;exports.ContentScrollAreaThumb=E;exports.ContentScrollAreaViewport=B;exports.Error=fe;exports.FormField=$;exports.FormFieldCheckbox=K;exports.FormFieldCheckboxIndicator=X;exports.FormFieldEmail=W;exports.FormFieldError=se;exports.FormFieldFile=G;exports.FormFieldLabel=Q;exports.FormFieldSelect=Y;exports.FormFieldSelectContent=te;exports.FormFieldSelectIcon=ie;exports.FormFieldSelectItem=re;exports.FormFieldSelectItemIndicator=le;exports.FormFieldSelectItemText=oe;exports.FormFieldSelectTrigger=Z;exports.FormFieldSelectValue=ee;exports.FormFieldSelectViewport=ne;exports.FormFieldText=f;exports.FormFieldTextArea=J;exports.Heading=j;exports.IntelligentFormPrimitiveBotHeading=me;exports.IntelligentFormPrimitiveBotHeadingIcon=ce;exports.IntelligentFormPrimitiveBotHeadingName=de;exports.IntelligentFormPrimitiveConfidentAnswer=ue;exports.IntelligentFormPrimitiveConfidentResponse=ae;exports.IntelligentFormPrimitiveConfidentResponseButton=ge;exports.IntelligentFormPrimitiveConfidentResponseButtonIcon=Ie;exports.IntelligentFormPrimitiveConfidentResponseButtonLabel=_e;exports.IntelligentFormPrimitiveContent=A;exports.IntelligentFormPrimitiveContentScrollArea=T;exports.IntelligentFormPrimitiveContentScrollAreaCorner=L;exports.IntelligentFormPrimitiveContentScrollAreaScrollbar=H;exports.IntelligentFormPrimitiveContentScrollAreaThumb=E;exports.IntelligentFormPrimitiveContentScrollAreaViewport=B;exports.IntelligentFormPrimitiveFormError=fe;exports.IntelligentFormPrimitiveFormField=$;exports.IntelligentFormPrimitiveFormFieldCheckbox=K;exports.IntelligentFormPrimitiveFormFieldCheckboxIndicator=X;exports.IntelligentFormPrimitiveFormFieldEmail=W;exports.IntelligentFormPrimitiveFormFieldError=se;exports.IntelligentFormPrimitiveFormFieldFile=G;exports.IntelligentFormPrimitiveFormFieldLabel=Q;exports.IntelligentFormPrimitiveFormFieldSelect=Y;exports.IntelligentFormPrimitiveFormFieldSelectContent=te;exports.IntelligentFormPrimitiveFormFieldSelectIcon=ie;exports.IntelligentFormPrimitiveFormFieldSelectItem=re;exports.IntelligentFormPrimitiveFormFieldSelectItemIndicator=le;exports.IntelligentFormPrimitiveFormFieldSelectItemText=oe;exports.IntelligentFormPrimitiveFormFieldSelectTrigger=Z;exports.IntelligentFormPrimitiveFormFieldSelectValue=ee;exports.IntelligentFormPrimitiveFormFieldSelectViewport=ne;exports.IntelligentFormPrimitiveFormFieldText=f;exports.IntelligentFormPrimitiveFormFieldTextArea=J;exports.IntelligentFormPrimitiveHeading=j;exports.IntelligentFormPrimitiveLoading=Fe;exports.IntelligentFormPrimitivePrimaryForm=O;exports.IntelligentFormPrimitivePrimaryFormDescription=M;exports.IntelligentFormPrimitivePrimaryFormFields=z;exports.IntelligentFormPrimitivePrimaryFormSubmit=U;exports.IntelligentFormPrimitiveRoot=w;exports.IntelligentFormPrimitiveSecondaryForm=pe;exports.IntelligentFormPrimitiveSecondaryFormDescription=ve;exports.IntelligentFormPrimitiveSecondaryFormFields=Se;exports.IntelligentFormPrimitiveSecondaryFormSubmit=Pe;exports.IntelligentFormPrimitiveSource=ke;exports.IntelligentFormPrimitiveSourceIcon=ye;exports.IntelligentFormPrimitiveSourceTitle=xe;exports.IntelligentFormPrimitiveSources=Ce;exports.IntelligentFormPrimitiveSourcesCaption=he;exports.IntelligentFormPrimitiveSourcesList=be;exports.IntelligentFormPrimitiveSuccess=q;exports.IntelligentFormPrimitiveSuccessHeading=D;exports.IntelligentFormPrimitiveSuccessIcon=V;exports.IntelligentFormPrimitiveSuccessMessage=N;exports.Loading=Fe;exports.PrimaryForm=O;exports.PrimaryFormDescription=M;exports.PrimaryFormFields=z;exports.PrimaryFormSubmit=U;exports.Root=w;exports.SecondaryForm=pe;exports.SecondaryFormDescription=ve;exports.SecondaryFormFields=Se;exports.SecondaryFormSubmit=Pe;exports.Source=ke;exports.SourceIcon=ye;exports.SourceTitle=xe;exports.Sources=Ce;exports.SourcesCaption=he;exports.SourcesList=be;exports.Success=q;exports.SuccessHeading=D;exports.SuccessIcon=V;exports.SuccessMessage=N;
@@ -406,8 +406,8 @@ const G = t("form", {
406
406
  type: "submit",
407
407
  children: "Submit"
408
408
  }), Vi = (i) => {
409
- const { formSettings: e } = s(), { label: n } = e.buttons.submit;
410
- return /* @__PURE__ */ o(Ie, { children: n ?? "Submit", ...i });
409
+ const { formSettings: e, isSubmitting: n } = s(), { label: r } = e.buttons.submit;
410
+ return /* @__PURE__ */ o(Ie, { disabled: n, children: r ?? "Submit", ...i });
411
411
  }, Pe = t("span", {
412
412
  _id: "intelligentForm__Error"
413
413
  }), Hi = (i) => {
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.101",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.102",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
7
7
  const u = B(void 0), $ = ({ children: e }) => {
8
8
  const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
9
9
  () => ({
10
- widgetLibraryVersion: "0.5.101",
10
+ widgetLibraryVersion: "0.5.102",
11
11
  componentType: s,
12
12
  tags: a
13
13
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/cxkit-primitives",
3
- "version": "0.5.101",
3
+ "version": "0.5.102",
4
4
  "description": "",
5
5
  "license": "Inkeep, Inc. Customer License (IICL) v1.1",
6
6
  "homepage": "",
@@ -67,9 +67,9 @@
67
67
  "remark-gfm": "^4.0.1",
68
68
  "unist-util-visit": "^5.0.0",
69
69
  "use-sync-external-store": "^1.4.0",
70
- "@inkeep/cxkit-color-mode": "^0.5.101",
71
- "@inkeep/cxkit-theme": "0.5.101",
72
- "@inkeep/cxkit-types": "0.5.101"
70
+ "@inkeep/cxkit-color-mode": "^0.5.102",
71
+ "@inkeep/cxkit-theme": "0.5.102",
72
+ "@inkeep/cxkit-types": "0.5.102"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@biomejs/biome": "1.9.4",