1try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0be25ad8-9f79-402f-b1f3-38e75ab3019a",e._sentryDebugIdIdentifier="sentry-dbid-0be25ad8-9f79-402f-b1f3-38e75ab3019a")}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5270],{7250:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/widget/sample/ai-agent",function(){return n(75849)}])},75849:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return eD}});var o=n(52322),s=n(2784),a=n(97729),r=n.n(a),i=n(5632),l=n(93948),c=n(12929),d=n(22836),u=n(64067);n(21633),n(26114);var h={horizontal:"_1lk0ebg1 _1lk0ebg0",vertical:"_1lk0ebg2 _1lk0ebg0"},p=function(e){let{orientation:t="horizontal",...n}=e;return(0,o.jsx)(l.Z,{as:"hr",flexShrink:0,className:h[t],...n,"aria-orientation":"vertical"===t?"vertical":void 0})},f=n(68390),g=n(25237),b=n.n(g),x=n(48933),m=function(e){let{alignY:t="center",...n}=e;return(0,o.jsx)(x.Z,{align:"between",alignY:t,...n})},v=n(95028),w=n(33619),y=n(85478),j=n(49842);n(93438),n(57960),n(53071);var C={default:"_1vsndtn1 _1vsndtn0",danger:"_1vsndtn2 _1vsndtn0"};let _=(0,s.forwardRef)(function(e,t){let{as:n="button",size:s="md",tone:a="default",underline:r=!0,disabled:i=!1,leadingIcon:c,trailingIcon:d,loading:u=!1,children:h,...p}=e;return(0,o.jsxs)(l.Z,{as:n,ref:t,className:(0,v.W)(y.aD,y.zC[s],C[a],r&&"_1vsndtn3"),"aria-busy":u||void 0,...p,...(0,j.T)(n,i||u),children:[u&&(0,o.jsx)("span",{className:y.V_,children:(0,o.jsx)(w.Z,{size:"sm"})}),(0,o.jsxs)("span",{className:(0,v.W)(y.iB[u?"hidden":"visible"]),children:[c&&(0,o.jsx)("span",{className:y.EA[s],children:c}),h,d&&(0,o.jsx)("span",{className:y.EA[s],children:d})]})]})});_.displayName="TextLink";var Z=n(25433),k=function(e){let{title:t,description:n,children:s}=e;return(0,o.jsxs)(c.Z,{space:4,children:[(0,o.jsx)(Z.Z,{as:"h2",size:"large",children:t}),(0,o.jsxs)(c.Z,{space:3,children:[(0,o.jsx)(u.Z,{size:"small",children:n}),s]})]})};let N={eventId:"",language:"",label:"",color:"",iconColor:"",surfaceColor:"",position:"",offset:{bottom:"",side:""},autoOpen:!1},I={label:"AI agent",color:"#eae6fa",iconColor:"#7033bd",surfaceColor:"#ffffff",position:"end",offset:{bottom:20,side:20}},E=/^#[0-9a-f]{6}$/i;function T(e,t){return E.test(e)?e:t}function S(e,t){let n=Number(e);return""===e||Number.isNaN(n)?t:n}function P(e){let t={};e.eventId&&(t.eventId=e.eventId),e.language&&(t.language=e.language),e.label&&(t.label=e.label),e.color&&(t.color=e.color),e.iconColor&&(t.iconColor=e.iconColor),e.surfaceColor&&(t.surfaceColor=e.surfaceColor),e.position&&(t.position=e.position);let n={};return e.offset.bottom&&(n.bottom=Number(e.offset.bottom)),e.offset.side&&(n.side=Number(e.offset.side)),(void 0!==n.bottom||void 0!==n.side)&&(t.offset=n),e.autoOpen&&(t.autoOpen=!0),t}let A=b()(()=>Promise.all([n.e(8476),n.e(8487)]).then(n.bind(n,28487)),{loadableGenerated:{webpack:()=>[28487]},ssr:!1});var F=function(e){let{options:t,onReset:n}=e;return(0,o.jsxs)(k,{title:"Installation",description:"Add this script tag to the page. The widget creates its own button. The chat is created the first time a visitor opens it.",children:[(0,o.jsx)(A,{options:P(t)}),(0,o.jsxs)(m,{space:4,children:[(0,o.jsx)(u.Z,{size:"small",children:"Set an option and this snippet follows, along with the widget running on this page."}),Object.keys(P(t)).length>0&&(0,o.jsx)(l.Z,{as:"div",flexShrink:0,children:(0,o.jsx)(_,{size:"sm",onClick:n,children:"Reset"})})]})]})};n(59005),n(40115);var R={neutral:"zfc87v0 _1fw27xn9",error:"zfc87v1 _1fw27xn9"};let B=(0,s.forwardRef)(function(e,t){let{tone:n="neutral",...s}=e;return(0,o.jsx)(l.Z,{as:"span",ref:t,className:R[n],...s})});function z(e){let{children:t}=e;return(0,o.jsx)(l.Z,{as:"code",className:"mxledq0",children:t})}function D(e){let{type:t,defaultValue:n}=e;return t?(0,o.jsx)(B,{children:n?"".concat(t," \xb7 default ").concat(n):t}):null}n(51183);var L=function(e){let{items:t}=e;return(0,o.jsx)(l.Z,{as:"div",children:t.map(e=>(0,o.jsx)(l.Z,{as:"div",paddingBlock:3,className:"mxledq3",children:(0,o.jsxs)(x.Z,{space:4,alignY:"top",collapseBelow:"sm",children:[(0,o.jsx)(l.Z,{as:"div",flexShrink:0,className:"mxledq1",children:(0,o.jsxs)(c.Z,{space:1,align:"start",children:[(0,o.jsx)(z,{children:e.name}),(0,o.jsx)(D,{type:e.type,defaultValue:e.defaultValue})]})}),(0,o.jsx)(l.Z,{as:"div",flexGrow:1,className:"mxledq2",children:(0,o.jsxs)(c.Z,{space:3,children:[(0,o.jsx)(u.Z,{size:"small",children:e.body}),e.control]})})]})},e.name))})};n(62687);var G="g1y6hd1",W="g1y6hd2",O="g1y6hd0";n(3728);var V="_1hb4cpi2";let $=(0,s.forwardRef)(function(e,t){let{startNode:n,endNode:s,...a}=e;return(0,o.jsxs)(l.Z,{as:"div",display:"flex",alignItems:"center",gap:2,paddingInline:4,className:"_1hb4cpi0",children:[n&&(0,o.jsx)(l.Z,{as:"span",display:"contents",className:V,children:n}),(0,o.jsx)(l.Z,{as:"input",ref:t,paddingBlock:3,className:"_1hb4cpi1 _1fw27xnb",...a}),s&&(0,o.jsx)(l.Z,{as:"span",display:"contents",className:V,children:s})]})});var H=n(89069);n(58823);var U=function(e){let{url:t,type:n="monochromatic",...s}=e;return"monochromatic"===n?(0,o.jsx)("span",{...s,className:"gnpyrr1",style:(0,H.Lf)({"var(--gnpyrr0)":'url
1("'.concat(t,'")')})}):(0,o.jsx)("img",{...s,alt:"",className:"gnpyrr2",src:t})},M=function(e){return(0,o.jsx)(U,{...e,url:"https://static.swapcard.com/public/images/1bb63733cbcb4618a927128aff0f0292.svg"})},q=function(e){return(0,o.jsx)(U,{...e,url:"https://static.swapcard.com/public/images/ca5a84af1ced430a93437f830a17511a.svg"})};function Y(e){let{className:t,children:n}=e;return(0,o.jsx)(l.Z,{as:"span",position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",className:t,children:n})}n(25706);let Q=(0,s.forwardRef)(function(e,t){return(0,o.jsxs)(l.Z,{as:"span",position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,className:"_1drunt2",children:[(0,o.jsx)(l.Z,{as:"input",ref:t,type:"radio",position:"absolute",inset:0,width:"100%",height:"100%",className:"_1drunt5",...e}),(0,o.jsxs)("span",{"aria-hidden":"true",children:[(0,o.jsx)(Y,{className:"_1drunt7 _1drunt6",children:(0,o.jsx)(M,{})}),(0,o.jsx)(Y,{className:"_1drunt8 _1drunt6",children:(0,o.jsx)(q,{})})]})]})});function X(e){return(0,o.jsx)(l.Z,{as:"label",display:"flex",alignItems:"flex-start",gap:2,paddingBlock:2,paddingInline:4,className:"_1drunt1 _1drunt0 _1fw27xn8",...e})}n(66264);var K=function(e){return(0,o.jsx)(l.Z,{as:"div",display:"flex",flexDirection:"column",className:"it007e0",...e})},J=n(12866),ee=n(31383),et=n(13329),en=n(28021);function eo(e){return new Promise(t=>{setTimeout(t,e)})}function es(e){return ei.test(e.replace("#",""))}let ea={dirty:!1,focused:!1,loading:!1,success:!1,valid:!0,value:"",changeEffect:!1};function er(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ea,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"CHANGE":return{...e,dirty:!0,valid:t.valid,value:t.value};case"SELECT":return{...e,dirty:!0,valid:!0,value:t.value,focused:!1};case"BLUR":return{...e,focused:!1};case"FOCUS":return{...e,focused:!0};case"START_SUBMIT":return{...e,loading:!0};case"END_SUBMIT":return{...e,dirty:!1,loading:!1,success:!0};case"RESET_SUCCESS":return{...e,success:!1};case"SET_STATE":return{...e,...t.state};case"RESET":return ea;case"TRIGGER_CHANGE_EFFECT_START":return{...e,changeEffect:!0};case"TRIGGER_CHANGE_EFFECT_END":return{...e,changeEffect:!1};default:return e}}let ei=/^[0-9A-F]{6}$/i;var el=n(56366);J.ZP.div.withConfig({displayName:"loader__Wrapper",componentId:"sc-1322ec0d-0"})(["display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border:solid 1px ",";border-radius:",";background-color:",";"],e=>{let{theme:{colors:t}}=e;return t.outline.base},e=>{let{theme:t}=e;return t.radius.md},e=>{let{theme:{colors:t}}=e;return t.surface.base}),J.ZP.div.withConfig({displayName:"loader__Hash",componentId:"sc-1322ec0d-1"})(['height:15px;line-height:10px;margin-right:8px;&:before{content:"#";color:',";font-size:14px;}"],e=>{let{theme:{colors:t}}=e;return t.surface.onPlaceholder}),(0,J.ZP)(el.Z).attrs({size:14}).withConfig({displayName:"loader__Line",componentId:"sc-1322ec0d-2"})(["max-width:60px;"]),J.ZP.div.withConfig({displayName:"loader__Filler",componentId:"sc-1322ec0d-3"})(["flex-grow:1;"]),(0,J.ZP)(el.Z).attrs({size:16}).withConfig({displayName:"loader__Color",componentId:"sc-1322ec0d-4"})(["width:16px;"]);var ec=["#b71c1c","#f44336","#E91E63","#9C27B0","#673AB7","#3F51B5","#262f3d","#2196F3","#26ADE4","#00BCD4","#009688","#00cc88","#8BC34A","#CDDC39","#FFEB3B","#FFD54F","#F9A70C","#FF5722","#795548","#4E342E","#9E9E9E","#607D8B","#424242","#000000","#FFFFFF"];let ed=J.ZP.div.withConfig({displayName:"input-color__Wrapper",componentId:"sc-20ecc3a8-0"})(["position:relative;"]),eu=J.ZP.div.withConfig({displayName:"input-color__Right",componentId:"sc-20ecc3a8-1"})(["display:flex;align-items:center;"]),eh=J.ZP.div.withConfig({displayName:"input-color__ColorPreview",componentId:"sc-20ecc3a8-2"})(["width:16px;height:16px;border-radius:",";box-sizing:border-box;"," "," ",""],e=>{let{theme:t}=e;return t.radius.sm},e=>{let{disabled:t}=e;
1return!t&&(0,ee.iv)(["cursor:pointer;"])},e=>{let{color:t}=e;return t&&/^[0-9A-F]{6}$/i.test(t)&&(0,ee.iv)(["background-color:#",";"],t)},e=>{let{theme:t,color:n}=e;return"#".concat(n).toLowerCase()===t.colors.surface.base.toLowerCase()&&(0,ee.iv)(["border:1px solid ",";"],e=>{let{theme:t}=e;return t.colors.outline.base})}),ep=J.ZP.div.withConfig({displayName:"input-color__ColorPicker",componentId:"sc-20ecc3a8-3"})(["background:",";border-radius:",";position:absolute;box-sizing:border-box;margin-top:-1px;",":0;"," max-width:186px;padding:16px;z-index:10;box-shadow:",";grid-template-columns:repeat(auto-fill,24px);grid-gap:8px;justify-content:center;visibility:",";display:",";transition:200ms;"],e=>{let{theme:t}=e;return t.colors.surface.base},e=>{let{theme:t}=e;return t.radius.md},e=>{let{theme:t}=e;return"rtl"===t.dir?"left":"right"},e=>{let{$overflow:t}=e;return!t&&"width: 100%;"},e=>{let{theme:t}=e;return t.shadow.md},e=>{let{active:t}=e;return t?"visible":"hidden"},e=>{let{active:t}=e;return t?"grid":"none"}),ef=J.ZP.div.withConfig({displayName:"input-color__Color",componentId:"sc-20ecc3a8-4"})(["background-color:",";width:100%;height:24px;border-radius:",";cursor:pointer;box-sizing:border-box;",""],e=>{let{color:t}=e;return t},e=>{let{theme:t}=e;return t.radius.sm},e=>{let{theme:t,color:n}=e;return n.toLowerCase()===t.colors.surface.base.toLowerCase()&&(0,ee.iv)(["border:1px solid ",";"],e=>{let{theme:t}=e;return t.colors.outline.base})});function eg(e){let{value:t,focused:n,disabled:a,onFocus:r,onBlur:i,onClickOutside:l,onSelectColor:c,pickerOverflow:d=!1,right:u,...h}=e,p=(0,s.useRef)(null),[f,g]=(0,s.useState)(!!n);(0,et.Z)(p,()=>{l&&l(),g(!1)});let b="string"==typeof t?t.replace("#",""):"";return(0,o.jsxs)(ed,{ref:p,children:[(0,o.jsx)(en.ZP,{...h,value:b,focused:n,disabled:a,onFocus:()=>{r&&r(),g(!0)},onBlur:i,left:"#",right:(0,o.jsxs)(eu,{children:[u,(0,o.jsx)(eh,{color:b,disabled:a,"data-testid":"color-preview",onClick:()=>{a||(r&&r(),g(!0))}})]})}),!a&&(0,o.jsx)(ep,{active:f,$overflow:d,"data-testid":"color-pickers",children:ec.map((e,t)=>(0,o.jsx)(ef,{color:e,"data-testid":"color-picker-".concat(t),onClick:()=>{c&&c(e.replace("#","")),g(!1)}},t))})]})}var eb=n(50467),ex=n(24471);function em(e){let{name:t,value:n,placeholder:s,onChange:a}=e;return(0,o.jsx)($,{"aria-label":t,value:n,placeholder:s,spellCheck:!1,onChange:e=>{let{target:t}=e;return a(t.value)}})}function ev(e){let{name:t,value:n,placeholder:a,onChange:r}=e,i=function(){let{initialState:e,autoSave:t,resetDuration:n=3e3}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[{value:o,focused:a,dirty:r,loading:i,success:l,valid:c,changeEffect:d},u]=(0,s.useReducer)(er,{...ea,...e}),h=async e=>{t&&(u({type:"START_SUBMIT"}),await t({value:e}),u({type:"END_SUBMIT"}),await eo(n),u({type:"RESET_SUCCESS"}))},p=(0,s.useCallback)(e=>{let{target:{value:t}}=e;return u({type:"CHANGE",valid:es(t),value:t.replace("#","")})},[u]),f=(0,s.useCallback)(e=>{u({type:"SELECT",value:e}),h(e)},[u]),g=(0,s.useCallback)(()=>u({type:"FOCUS"}),[u]),b=(0,s.useCallback)(()=>{u({type:"BLUR"}),r&&c&&h(o)},[u,o,r,c]),x=(0,s.useCallback)(()=>{a&&u({type:"BLUR"})},[u,a]);return{dirty:r,focused:a,loading:i,onBlur:b,onClickOutside:x,onChange:p,onSelectColor:f,onFocus:g,success:l,valid:c,value:o,setState:(0,s.useCallback)(e=>{u({type:"SET_STATE",state:e})},[u]),reset:(0,s.useCallback)(()=>{u({type:"RESET"})},[u]),triggerChangeEffect:(0,s.useCallback)(async()=>{u({type:"TRIGGER_CHANGE_EFFECT_START"}),await eo(n),u({type:"TRIGGER_CHANGE_EFFECT_END"})},[u]),changeEffect:d,isValid:es}}();return(0,o.jsx)(eg,{...i,"aria-label":t,placeholder:a,value:n,onChange:e=>{let{target:t}=e;return r(t.value&&"#".concat(t.value.replace("#","")))},onSelectColor:e=>{i.onSelectColor(e),r("#".concat(e))}})}function ew(e){let{name:t,value:n,emptyLabel:s,choices:a,onChange:r}=e;return(0,o.jsxs)(eb.ZP,{"aria-label":t,value:n,onChange:e=>{let{target:t}=e;return r(t.value)},children:[(0,o.jsx)(eb.Wx,{value:"",children:s}),a.map(e=>(0,o.jsx)(eb.Wx,{value:e.value,children:e.label},e.value))]})}function ey(e){let{name:t,prefix:n,value:a,placeholder:r,onChange:i}=e,c=(0,s.useId)();return(0,o.jsx)($,{id:c,"aria-label":t,type:"number",min:0,value:a,placeholder:r,startNode:(0,o.jsx)(l.Z,{as:"label",htmlFor:c,children:n}),onChange:e=>{let{target:t}=e;return i(t.value)}})}function ej(e){let{name:t,value:n,choices:s,onChange:a}=e;return(0,o.jsx)(K,{role:"radiogroup","aria-label":t,flexDirection:"row",children:s.map(e=>(0,o.jsxs)(X,{flexGrow:1,justifyContent:"center",children:[(0,o.jsx)(Q,{name:t,value:e,checked:e===n,onChange:()=>a(e)}),e]},e))})}function eC(e){let{name:t,value:n,onChange:s}=e;return(0,o.jsx)(ex.ZP,{"aria-label":t,checked:n,onChange:e=>{let{target:t}=e;return s(t.checked)}})}var e_=n(36933);let eZ=new Intl.DisplayNames(["en"],{type:"language"}),ek=["end","start"];var eN=function(e){let{options:t,onChange:n}=e,a=function(){let{i18n:e}=(0,e_.$)(),{supportedLngs:t}=e.options;return(0,s.useMemo)(()=>(t||[]).filter(e=>"cimode"!==e).map(e=>({value:e,label:"".concat(e," \xb7 ").concat(eZ.of(e))})).sort((e,t)=>
1e.label.localeCompare(t.label)),[t])}();function r(e){n({offset:{...t.offset,...e}})}let i=[{name:"eventId",type:"string",body:"Limits the agent to one event. It answers about that event only, and the panel uses the event branding. Without it, the agent opens with no context.",control:(0,o.jsx)(l.Z,{as:"div",className:O,children:(0,o.jsx)(em,{name:"eventId",value:t.eventId,placeholder:"No event",onChange:e=>n({eventId:e})})})},{name:"language",type:"string",defaultValue:"browser language",body:"Language of the chat. This option is part of the panel address, so changing it reloads the panel.",control:(0,o.jsx)(l.Z,{as:"div",className:O,children:(0,o.jsx)(ew,{name:"language",value:t.language,emptyLabel:"Browser language",choices:a,onChange:e=>n({language:e})})})},{name:"label",type:"string",defaultValue:'"'.concat(I.label,'"'),body:"Accessible name of the button. The button is an icon with no text, so this is what a screen reader announces. Pass your own for a site in another language.",control:(0,o.jsx)(l.Z,{as:"div",className:O,children:(0,o.jsx)(em,{name:"label",value:t.label,placeholder:I.label,onChange:e=>n({label:e})})})},{name:"color",type:"string",defaultValue:'"'.concat(I.color,'"'),body:"Background color of the button. The default is the same lavender as the event app. An event theme does not change it.",control:(0,o.jsx)(l.Z,{as:"div",className:G,children:(0,o.jsx)(ev,{name:"color",value:t.color,placeholder:I.color.replace("#",""),onChange:e=>n({color:e})})})},{name:"iconColor",type:"string",defaultValue:'"'.concat(I.iconColor,'"'),body:"Color of the icon on the button, and of the ring shown while the chat loads.",control:(0,o.jsx)(l.Z,{as:"div",className:G,children:(0,o.jsx)(ev,{name:"iconColor",value:t.iconColor,placeholder:I.iconColor.replace("#",""),onChange:e=>n({iconColor:e})})})},{name:"surfaceColor",type:"string",defaultValue:'"'.concat(I.surfaceColor,'"'),body:"Background color of the panel while the chat loads. Pass the surface color of the event for a dark theme.",control:(0,o.jsx)(l.Z,{as:"div",className:G,children:(0,o.jsx)(ev,{name:"surfaceColor",value:t.surfaceColor,placeholder:I.surfaceColor.replace("#",""),onChange:e=>n({surfaceColor:e})})})},{name:"position",type:'"end" | "start"',defaultValue:'"'.concat(I.position,'"'),body:"Follows the direction of the page, so the button stays on the correct side in a right to left page.",control:(0,o.jsx)(l.Z,{as:"div",className:G,children:(0,o.jsx)(ej,{name:"position",value:t.position,choices:ek,onChange:e=>n({position:e})})})},{name:"offset",type:"{ bottom, side }",defaultValue:"{ bottom: ".concat(I.offset.bottom,", side: ").concat(I.offset.side," }"),body:"Distance from the edges of the page, in pixels. One of the two can be passed on its own.",control:(0,o.jsxs)(x.Z,{space:2,alignY:"center",children:[(0,o.jsx)(l.Z,{as:"div",className:W,children:(0,o.jsx)(ey,{name:"offset bottom",prefix:"bottom",value:t.offset.bottom,placeholder:String(I.offset.bottom),onChange:e=>r({bottom:e})})}),(0,o.jsx)(l.Z,{as:"div",className:W,children:(0,o.jsx)(ey,{name:"offset side",prefix:"side",value:t.offset.side,placeholder:String(I.offset.side),onChange:e=>r({side:e})})})]})},{name:"autoOpen",type:"boolean",defaultValue:"false",body:"Opens the panel when init runs, without waiting for a click. The widget on this page started long ago, so this one only writes itself into the snippet.",control:(0,o.jsx)(eC,{name:"autoOpen",value:t.autoOpen,onChange:e=>n({autoOpen:e})})}];return(0,o.jsx)(k,{title:"Options",description:(0,o.jsxs)(o.Fragment,{children:["All options are optional. Pass them to ",(0,o.jsx)(z,{children:"init"}),", and change them later with ",(0,o.jsx)(z,{children:"update"}),"."]}),children:(0,o.jsx)(L,{items:i})})};let eI={start:"flex-start",center:"center",end:"flex-end",between:"space-between"},eE={top:"flex-start",center:"center",bottom:"flex-end"};var eT=function(e){let{as:t="div",space:n=0,align:s="start",alignY:a="center",children:r,...i}=e;return(0,o.jsx)(l.Z,{as:t,display:"flex",flexWrap:"wrap",gap:n,justifyContent:eI[s],alignItems:eE[a],...i,children:r})},eS=n(15287);function eP(e){let{names:t}=e;return(0,o.jsx)(eT,{space:2,children:t.map(e=>(0,o.jsxs)(eS.Z,{variant:"outlined",size:"sm",onClick:()=>{var t;return null===(t=window.scAiAgent)||void 0===t?void 0:t[e]()},children:[e,"()"]},e))})}let eA=[{name:"init(options)",body:"Creates the button and starts listening. Calling it again replaces the current widget. If the script itself is loaded twice, the second copy does nothing."},{name:"update(options)",body:"Changes some of the options without recreating the widget. eventId, color, iconColor, position and offset change in place. language reloads the panel. The options above call it."}
1,{name:"open() / close() / toggle()",body:"Opens and closes the panel. The panel is created on the first open and kept after that, so a conversation is not lost when it closes.",control:(0,o.jsx)(eP,{names:["open","close","toggle"]})},{name:"show() / hide()",body:"Shows or removes the button. Hiding the button also closes the panel.",control:(0,o.jsx)(eP,{names:["show","hide"]})},{name:"destroy()",body:"Removes the button, the panel and all listeners. There is no button for it here, because nothing on this page would bring the widget back."}];var eF=function(){return(0,o.jsx)(k,{title:"Methods",description:(0,o.jsxs)(o.Fragment,{children:["Call them on ",(0,o.jsx)(z,{children:"scAiAgent"}),". The buttons call the widget running on this page, the way a website would call it from its own code."]}),children:(0,o.jsx)(L,{items:eA})})};let eR=[{name:'"open"',body:"The panel opened, from the button or from code."},{name:'"close"',body:"The panel closed."},{name:'"ready"',body:"The chat inside the panel finished loading."}];var eB=function(){return(0,o.jsx)(k,{title:"Events",description:(0,o.jsxs)(o.Fragment,{children:["Add a handler with ",(0,o.jsx)(z,{children:"scAiAgent.on(name, handler)"}),". Remove it with ",(0,o.jsx)(z,{children:"off"}),"."]}),children:(0,o.jsx)(L,{items:eR})})};n(76375),n(39499);var ez=function(){var e;let t=(0,i.useRouter)(),n=(0,f.Eh)(),a=null!==(e=t.query.eventId)&&void 0!==e?e:"",[h,g]=(0,s.useState)(()=>({...N,eventId:a})),b=(0,s.useRef)(!1),x=(0,s.useRef)(h);function m(e){g(t=>({...t,...e}))}return(0,s.useEffect)(()=>{if(b.current)return;b.current=!0;let e=document.createElement("script");e.src="/ai-agent-widget.js",e.onload=()=>{var e;null===(e=window.scAiAgent)||void 0===e||e.init(P(x.current))},document.body.appendChild(e)},[]),(0,s.useEffect)(()=>{x.current=h;let e=window.setTimeout(()=>{var e;h.eventId!==a&&n({eventId:h.eventId||null}),null===(e=window.scAiAgent)||void 0===e||e.update({eventId:h.eventId||void 0,language:h.language||void 0,label:h.label||I.label,color:T(h.color,I.color),iconColor:T(h.iconColor,I.iconColor),surfaceColor:T(h.surfaceColor,I.surfaceColor),position:h.position||I.position,offset:{bottom:S(h.offset.bottom,I.offset.bottom),side:S(h.offset.side,I.offset.side)}})},400);return()=>window.clearTimeout(e)},[h,a,n]),(0,o.jsxs)(l.Z,{as:"div",paddingInline:4,className:"ikdoll0",children:[(0,o.jsx)(r(),{children:(0,o.jsx)("title",{children:"AI agent widget"})}),(0,o.jsx)(l.Z,{as:"div",paddingBlock:8,children:(0,o.jsxs)(c.Z,{space:8,children:[(0,o.jsxs)(c.Z,{space:3,children:[(0,o.jsx)(d.Z,{as:"h1",size:"large",children:"AI agent widget"}),(0,o.jsx)(u.Z,{size:"large",children:"This script adds the AI agent to any website. It shows a floating button that opens a chat panel. The widget is running on this page. The button in the bottom corner is the real one, and the options below drive it."})]}),(0,o.jsx)(p,{}),(0,o.jsxs)(l.Z,{as:"div",display:"flex",flexDirection:{base:"column",lg:"row"},alignItems:{base:"stretch",lg:"flex-start"},gap:{base:8,lg:10},children:[(0,o.jsx)(l.Z,{as:"aside",className:"ikdoll2",children:(0,o.jsx)(F,{options:h,onReset:()=>m(N)})}),(0,o.jsx)(l.Z,{as:"div",flexGrow:1,className:"ikdoll1 _19zym5d1",children:(0,o.jsxs)(c.Z,{space:8,children:[(0,o.jsx)(eN,{options:h,onChange:m}),(0,o.jsx)(p,{}),(0,o.jsx)(eF,{}),(0,o.jsx)(p,{}),(0,o.jsx)(eB,{})]})})]})]})})]})};function eD(){return(0,o.jsx)(ez,{})}},42979:function(e,t,n){"use strict";n.d(t,{Z:function(){return a},a:function(){return r}});var o=n(52322),s=n(87553);function a(e){let{checked:t,onChange:n,disabled:a,loading:r,...i}=e;return(0,o.jsxs)(s.iV,{children:[(0,o.jsx)(s.II,{type:"checkbox",role:"switch",checked:t,onChange:n,disabled:a,"aria-busy":r,...i}),(0,o.jsx)(s.S0,{"aria-hidden":"true",children:(0,o.jsx)(s.lH,{children:(0,o.jsxs)(s.xL,{children:[(0,o.jsx)(s.Y_,{}),(0,o.jsx)(s.x8,{}),(0,o.jsx)(s.aN,{variant:"LOADER"})]})})})]})}function r(e){return(0,o.jsx)(s.Vm,{...e,size:parseInt(s.n3),maxWidth:s.Qs})}},87553:function(e,t,n){"use strict";n.d(t,{II:function(){return f},Qs:function(){return c},S0:function(){return g},Vm:function(){return j},Y_:function(){return m},aN:function(){return w},iV:function(){return y},lH:function(){return b},n3:function(){return d},sb:function(){return C},x8:function(){return v},xL:function(){return x}});var o=n(12866),s=n(70231),a=n(40335),r=n(96413),i=n(32636),l=n(83106);let c="48px",d="24px",u="16px",h="0.5s ease",p="32px",f=o.ZP.input.withConfig({displayName:"styles__Input",componentId:"sc-608965f-0"})(["position:absolute;top:0;left:0;width:100%;height:100%;opacity:0;z-index:10;margin:0;cursor:pointer;"]),g=o.ZP.span.withConfig({displayName:"styles__Rail",componentId:"sc-608965f-1"})(["box-sizing:border-box;display:block;position:relative;height:100%;width:100%;border-radius:inherit;background-color:",";border:",";transition:background-color ",",border-color ",";"],e=>{let{theme:t}=e;return t.colors.surface.base},e=>{let{theme:{colors:t}}=e;return"".concat("2px"," solid ").concat(t.outline.base)},h,h),b=o.ZP.span.withConfig({displayName:"styles__Knob",componentId:"sc-608965f-2"})(["display:block;position:relative;top:",";inset-inline-start:",";width:",";aspect-ratio:1;border-radius:50%;background-color:",";transition:left ",",right ",",background-color ",';font-size:10px;&::after{content:"";position:absolute;top:50%;left:50%;width:0;height:0;border-radius:50%;transform:translate(-50%,-50%);transition:width ',",height ",";}&:hover::after{width:",";height:",";}"],"2px","2px",u,e=>{let{theme:t}=e;return t.colors.neutral.base},h,h,h,h,h,p,p),x=o.ZP.span.withConfig({displayName:"styles__StyledIcon",componentId:"sc-608965f-3"})(["position:relative;top:",";inset-inline-start:",";color:",";transition:color ",";"],"3px","3px",e=>{let{theme:t}=e;return t.colors.surface.base},h),m=(0,o.ZP)(s.Z).withConfig({displayName:"styles__CheckMark",componentId:"sc-608965f-4"})(["display:none;"]),v=(0,o.ZP)(a.Z).withConfig({displayName:"styles__Close",componentId:"sc-608965f-5"})(["display:none;"]),w=(0,o.ZP)(r.Z).withConfig({displayName:"styles__Loader",componentId:"sc-608965f-6"})(["display:none;"]),y=o.ZP.div.withConfig({displayName:"styles__SwitchWrapper",componentId:"sc-608965f-7"})(["position:relative;display:block;width:",";min-width:",";height:",";min-height:",";border-radius:",';overflow:hidden;cursor:pointer;&:has(input:disabled),&:has(input[aria-busy="true"]){cursor:default;pointer-events:none;}&:has(input:focus-visible){outline:',";outline-offset:",";}&:has(input:checked:disabled) ","{background-color:",";border:"," solid transparent;}&:has(input:checked) ","{background-color:",";border:"," solid transparent;}&:has(input:disabled) ","{background-color:",";border:"," solid transparent;}&:has(input:checked) ","{inset-inline-start:calc( "," - "," - "," - 2 * "," );}&:has(input:checked:disabled) ","{background-color:",";}&:has(input:disabled) ","{background-color:",";}&:has(input:checked) ","{background-color:",";}&:has(input:checked) ",":hover::after{background-color:",";}&:has(input:not(:checked)) ",":hover::after{background-color:",";}&:has(input:checked:disabled) ","{color:",";}&:has(input:checked) ","{color:",";}&:has(input:disabled) ","{color:",";}&:has(input:checked) ","{display:block;}&:has(input:checked) ",",&:has(input:checked) ","{display:none;}&:not(:has(input:checked)) ",",&:not(:has(input:checked)) ","{display:none;}&:not(:has(input:checked)) ",'{display:block;}&:has(input[aria-busy="true"]) ','{display:block;}&:has(input[aria-busy="true"]) ',',&:has(input[aria-busy="true"]) ',"{display:none;}"],c,c,d,d,e=>{let{theme:t}=e;return t.radius.lg},e=>{let{theme:{colors:t}}=e;return"".concat("2px"," solid ").concat(t.outline.focus)},"2px",g,e=>{let{theme:t}=e;return t.colors.surface.onDisabled},"2px",g,e=>{let{theme:t}=e;return t.colors.success.base},"2px",g,e=>{let{theme:t}=e;return t.colors.surface.disabled},"2px",b,c,u,"2px","2px",b,e=>{let{theme:{colors:t}}=e;return t.surface.disabled},b,e=>{let{theme:t}=e;return t.colors.surface.onDisabled},b,e=>{let{theme:t}=e;return t.colors.surface.base},b,e=>{let{theme:{mode:t,palette:n}}=e;return"dark"===t?(0,l.Z)(n.white,.08):(0,l.Z)(n.black,.04)},b,e=>{let{theme:{mode:t,palette:n}}=e;return"dark"===t?(0,l.Z)(n.white,.08):(0,l.Z)(n.black,.04)},x,e=>{let{theme:t}=e;return t.colors.surface.onDisabled},x,e=>{let{theme:t}=e;return t.colors.success.base},x,e=>{let{theme:t}=e;return t.colors.surface.disabled},m,v,w,m,w,v,w,m,v),j=(0,o.ZP)(i.Z).withConfig({displayName:"styles__Placeholder",componentId:"sc-608965f-8"})(["border-radius:",";"],e=>{let{theme:t}=e;return t.radius.lg}),C=o.ZP.div.withConfig({displayName:"styles__LoaderWrapper",componentId:"sc-608965f-9"})(["display:flex;align-items:center;justify-content:space-between;gap:",";"],e=>{let{theme:t}=e;return t.spacing[8]})},24471:function(e,t,n){"use strict";n.d(t,{I5:function(){return s.I5},m$:function(){return s.ZP}});var o=n(42979);n(55800);var s=n(14090);t.ZP=o.Z},55800:function(e,t,n){"use strict";n.d(t,{M3:function(){return g},Pc:function(){return p},ZP:function(){return x},e:function(){return f},nB:function(){return m},px:function(){return h}});var o=n(52322),s=n(2784),a=n(12866),r=n(31383),i=n(5045),l=n(42979),c=n(27358),d=n(3864),u=n(4497);let h=a.ZP.div.withConfig({displayName:"switch-box__SwitchBoxContent",componentId:"sc-207f3f22-0"})(["display:flex;flex-direction:column;gap:",";",""],e=>{let{theme:t}=e;return t.spacing[1]},u.F),p=(0,a.ZP)(i.Z).withConfig({displayName:"switch-box__SwitchBoxBody",componentId:"sc-207f3f22-1"})([""]),f=a.ZP.div.withConfig({displayName:"switch-box__SwitchBoxHeader",componentId:"sc-207f3f22-2"})(["display:flex;align-items:center;justify-content:space-between;gap:",";&:has(input:disabled) ","{color:",";cursor:default;}",""],e=>{let{theme:t}=e;return t.spacing[2]},d.$,e=>{let{theme:{colors:t}}=e;return t.surface.onDisabled},u.F),g=a.ZP.div.withConfig({displayName:"switch-box__SwitchBoxWrapper",componentId:"sc-207f3f22-3"})(["display:flex;flex-direction:column;gap:",";"," ",""],e=>{let{theme:t}=e;return t.spacing[2]},e=>{let{disabled:t,theme:n}=e;return t&&(0,r.iv)(["",",",",",",","{color:",";}"],d.$,p,f,h,n.colors.surface.onDisabled)},u.F),b=a.ZP.div.withConfig({displayName:"switch-box__ActionWrapper",componentId:"sc-207f3f22-4"})(["display:flex;gap:",";align-items:center;"],e=>{let{theme:t}=e;return t.spacing[4]});function x(e){let{switchProps:t,title:n,description:a,action:r,...i}=e,c=(0,s.useId)(),{id:u,...x}=t,m=null!=u?u:c;return(0,o.jsxs)(g,{disabled:null==t?void 0:t.disabled,...i,children:[(0,o.jsxs)(f,{children:[(0,o.jsx)(d.$,{htmlFor:m,variant:"bold",children:n}),r?(0,o.jsxs)(b,{children:[r,(0,o.jsx)(l.Z,{...x,id:m})]}):(0,o.jsx)(l.Z,{...x,id:m})]}),(0,o.jsx)(h,{children:(0,o.jsx)(p,{children:a})})]})}function m(e){return(0,o.jsxs)(g,{...e,children:[(0,o.jsxs)(f,{children:[(0,o.jsx)(c.h,{size:"small",maxWidth:"80%"}),(0,o.jsx)(l.a,{})]}),(0,o.jsx)(i.T,{lines:2})]})}},14090:function(e,t,n){"use strict";n.d(t,{$A:function(){return l.$},I5:function(){return d},ZP:function(){return c}});var o=n(52322),s=n(2784),a=n(5045),r=n(42979),i=n(87553),l=n(3864);function c(e){let{switchProps:t,label:n,...a}=e,i=(0,s.useId)(),{id:c,...d}=t,u=null!=c?c:i;return(0,o.jsxs)(l.w,{...a,children:[(0,o.jsx)(l.$,{htmlFor:u,children:n}),(0,o.jsx)(r.Z,{...d,id:u})]})}function d(e){return(0,o.jsxs)(i.sb,{...e,children:[(0,o.jsx)(a.T,{lines:1,style:{width:"100%"}}),(0,o.jsx)(r.a,{})]})}},3864:function(e,t,n){"use strict";n.d(t,{$:function(){return r},w:function(){return i}});var o=n(12866),s=n(4497),a=n(56140);let r=o.ZP.label.withConfig({displayName:"styles__SwitchLabel",componentId:"sc-b256ebe2-0"})(["cursor:pointer;display:block;line-height:150%;font-size:0.875rem;color:",";font-weight:",";"," ",""],e=>{let{theme:t,variant:n}=e;return"bold"===n?t.colors.surface.onVariant:t.colors.surface.on},e=>{let{variant:t}=e;
1return"bold"===t?600:400},s.F,a.n),i=o.ZP.div.withConfig({displayName:"styles__SwitchWithLabelWrapper",componentId:"sc-b256ebe2-1"})(["display:flex;align-items:center;gap:",";justify-content:space-between;&:has(input:disabled) ","{color:",";cursor:default;}",""],e=>{let{theme:t}=e;return t.spacing[4]},r,e=>{let{theme:{colors:t}}=e;return t.surface.onDisabled},s.F)},48933:function(e,t,n){"use strict";var o=n(52322),s=n(93948);let a={start:"flex-start",center:"center",end:"flex-end",between:"space-between"},r={top:"flex-start",center:"center",bottom:"flex-end",stretch:"stretch"};t.Z=function(e){let{as:t="div",space:n=0,align:i="start",alignY:l="top",collapseBelow:c,flexGrow:d,children:u,...h}=e,p=r[l];return(0,o.jsx)(s.Z,{as:t,display:"flex",flexDirection:c?{base:"column",[c]:"row"}:"row",flexWrap:"nowrap",gap:n,justifyContent:a[i],alignItems:c?{base:"stretch",[c]:p}:p,flexGrow:d,...h,children:u})}},40115:function(){},74410:function(){},66264:function(){},26114:function(){},3728:function(){},32147:function(){},25706:function(){},53071:function(){},81088:function(){},57960:function(){},58823:function(){},51183:function(){},39499:function(){},62687:function(){}},function(e){e.O(0,[5287,2888,9774,179],function(){return e(e.s=7250)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.