@constructor-io/constructorio-ui-pia 2.16.0 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,7 +54,7 @@ Error generating stack: `+i.message+`
54
54
 
55
55
  crc-32/crc32.js:
56
56
  (*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
57
- */const r1="2.16.0";function vf({apiKey:r,threadId:a,cioClient:o,testCells:l}){const[f]=Y.useState(()=>crypto.randomUUID()),h=a||f,m=Y.useMemo(()=>JSON.stringify(l??null),[l]),d=Y.useMemo(()=>o||new i1({apiKey:r,sendTrackingEvents:!0,version:`cio-ui-pia-${r1}`,...l&&{testCells:l}}),[r,o,m]);return Y.useEffect(()=>{!o||!l||Object.keys(l).length===0||console.warn("[CioPia] abTest.testCells is ignored when you supply your own cioClient. Set testCells on that client instead.")},[o,m]),{cioClient:d,threadId:h}}function a1({itemId:r,variationId:a,threadId:o,cioClient:l,parameters:f}){const[h,m]=Y.useState([]),[d,p]=Y.useState(!1),[c,g]=Y.useState(null),v=Y.useMemo(()=>JSON.stringify(f),[f]),y=Y.useRef(l);Y.useEffect(()=>{y.current=l},[l]);const _=!!l,E=Y.useCallback(()=>{const w=y.current;w&&(p(!0),g(null),w.agent.pia.getSuggestedQuestions(r,{threadId:o,variationId:a,...f}).then(x=>{m(x.questions),g(null)}).catch(x=>{g(x instanceof Error?x:new Error("Error fetching questions"))}).finally(()=>{p(!1)}))},[_,r,a,o,v]);return Y.useEffect(()=>{E()},[E]),{data:h,isLoading:d,error:c,getSuggestedQuestions:E}}const l1={guard:{camelKey:"guard",isObject:!1},num_results:{camelKey:"numResults",isObject:!1},numResults:{camelKey:"numResults",isObject:!1},pre_filter_expression:{camelKey:"preFilterExpression",isObject:!0},preFilterExpression:{camelKey:"preFilterExpression",isObject:!0},fmt_options:{camelKey:"fmtOptions",isObject:!0},fmtOptions:{camelKey:"fmtOptions",isObject:!0}};function s1(r){if(!r)return;const a={};let o=!1;for(const[l,f]of Object.entries(r)){const h=l1[l];if(h)if(o=!0,h.isObject&&typeof f=="string")try{a[h.camelKey]=JSON.parse(f)}catch{a[h.camelKey]=f}else a[h.camelKey]=f}return o?a:void 0}function o1(r){const{apiKey:a,itemId:o,variationId:l,threadId:f,cioClient:h,suggestedQuestionsParameters:m,answerParameters:d,parameters:p,formatImageUrl:c,testCells:g}=r,{cioClient:v,threadId:y}=vf({apiKey:a,threadId:f,cioClient:h,testCells:g}),_=s1(p),E=_||m?{..._,...m}:void 0,w=_||d?{..._,...d}:void 0,x=a1({itemId:o,variationId:l,threadId:y,cioClient:v,parameters:E}),S=q_({itemId:o,variationId:l,threadId:y,cioClient:v,parameters:w,formatImageUrl:c});return{cioClient:v,threadId:y,suggestedQuestions:x,answers:S}}function u1(r){if(typeof r!="object"||r===null)return!1;const{question:a,answer:o,items:l}=r;return typeof a=="string"&&typeof o=="string"&&(l==null||Array.isArray(l))}function c1(r){if(!Array.isArray(r))return console.warn("[CioPia] initialConversationHistory must be an array. It was ignored."),[];const a=r.filter(u1);return a.length<r.length&&console.warn(`[CioPia] ${r.length-a.length} initialConversationHistory entries were ignored. Each needs a string question and answer, and items must be an array.`),a.map((o,l)=>({...o,id:l+1}))}function f1({pia:r,itemId:a,isConversation:o,callbacks:l,tracking:f,initialConversationHistory:h}){var re;const{suggestedQuestions:m,answers:d,threadId:p}=r,{getAnswer:c}=d,g=Y.useMemo(()=>({itemId:a,threadId:p}),[a,p]),[v,y]=Y.useState(""),[_,E]=Y.useState([]),[w,x]=Y.useState(()=>o&&h!==void 0?c1(h):[]),S=Y.useRef(w.length),T=Y.useRef(w),k=Y.useRef(a),L=Y.useRef(d.data),H=Y.useRef(!1),N=Y.useRef(d),R=Y.useRef(l),A=Y.useRef(g),D=Y.useRef(f),M=Y.useRef(""),I=Y.useRef("user"),G=Y.useRef(!1);Y.useEffect(()=>{R.current=l},[l]),Y.useEffect(()=>{A.current=g},[g]),Y.useEffect(()=>{D.current=f},[f]),Y.useEffect(()=>{N.current=d},[d]),Y.useEffect(()=>{T.current=w},[w]);const F=Y.useCallback((ie,ee)=>{if(I.current=ee,M.current=ie,H.current=!1,y(ie),c(ie),o){S.current+=1;const fe=S.current;x(me=>[...me,{id:fe,question:ie,answer:"",source:ee}])}},[c,o]),W=Y.useCallback(ie=>{var ee,fe,me;(ee=D.current)==null||ee.trackQuestionSubmit(ie),(me=(fe=R.current)==null?void 0:fe.onQuestionSubmit)==null||me.call(fe,ie,A.current,"user"),F(ie,"user")},[F]),ue=Y.useCallback(ie=>{var ee,fe,me;(ee=D.current)==null||ee.trackQuestionClick(ie),(me=(fe=R.current)==null?void 0:fe.onQuestionSubmit)==null||me.call(fe,ie,A.current,"suggestion"),F(ie,"suggestion")},[F]),B=Y.useCallback(()=>{var ie,ee,fe;(ie=D.current)==null||ie.trackFocus(),(fe=(ee=R.current)==null?void 0:ee.onFocus)==null||fe.call(ee,A.current)},[]),Z=Y.useCallback(ie=>{var me,we,ge,qe,Ce;const ee=T.current,fe=((me=N.current.data)==null?void 0:me.qna_result_id)??((we=ee[ee.length-1])==null?void 0:we.qnaResultId);(ge=D.current)==null||ge.trackAnswerFeedback(ie,fe),(Ce=(qe=R.current)==null?void 0:qe.onFeedback)==null||Ce.call(qe,ie)},[]),le=Y.useCallback(()=>{y(""),E(m.data),x([]),L.current=null,G.current=!1},[m.data]);Y.useEffect(()=>{k.current!==a&&(k.current=a,y(""),E([]),x([]),L.current=null,G.current=!1)},[a]),Y.useEffect(()=>{G.current||E(m.data)},[m.data]),Y.useEffect(()=>{var ie;d.data&&(E(d.data.follow_up_questions??[]),G.current=!0),d.data&&M.current&&!H.current&&(H.current=!0,(ie=D.current)==null||ie.trackAnswerView(M.current,d.data,d.items))},[d.data,d.items]),Y.useEffect(()=>{var me,we,ge,qe,Ce;const ie=((me=d.data)==null?void 0:me.value)??"";if(!ie||d.data===L.current)return;L.current=d.data;const ee=(we=d.data)==null?void 0:we.thread_id,fe=(ge=d.data)==null?void 0:ge.qna_result_id;if(o)x(he=>{var ke,Ae;if(he.length===0)return he;const Re=[...he];return Re[Re.length-1]={...Re[Re.length-1],answer:ie,items:d.items,threadId:ee,qnaResultId:fe},(Ae=(ke=R.current)==null?void 0:ke.onAnswer)==null||Ae.call(ke,Re,A.current),Re});else{const he={id:S.current,question:M.current,answer:ie,source:I.current,items:d.items,threadId:ee,qnaResultId:fe};(Ce=(qe=R.current)==null?void 0:qe.onAnswer)==null||Ce.call(qe,[he],A.current)}},[o,d.data,d.items]);const ce=((re=d.data)==null?void 0:re.value)??"",ne=d.items??null,z=d.error||m.error,K=d.isLoading||m.isLoading;return{currentQuestion:v,displayedQuestions:_,conversationHistory:w,currentAnswer:ce,currentItems:ne,isLoading:K,error:z,context:g,handleSubmitQuestion:W,handleQuestionClick:ue,handleInputFocus:B,handleFeedback:Z,resetState:le}}var fr=(r=>(r.UP="up",r.DOWN="down",r))(fr||{});function Yg({cioClient:r,itemId:a,itemName:o,variationId:l,threadId:f}){const h=r==null?void 0:r.tracker,m=Y.useMemo(()=>({itemId:a,itemName:o,...l&&{variationId:l},...f&&{threadId:f}}),[a,o,l,f]),d=Y.useCallback(S=>S.map(T=>({question:T.value})),[]),p=Y.useCallback((S,T)=>{h==null||h.trackProductInsightsAgentViews({...m,questions:d(S),viewTimespans:T})},[h,m,d]),c=Y.useCallback(S=>{h==null||h.trackProductInsightsAgentView({...m,questions:d(S)})},[h,m,d]),g=Y.useCallback(()=>{h==null||h.trackProductInsightsAgentOutOfView(m)},[h,m]),v=Y.useCallback(()=>{h==null||h.trackProductInsightsAgentFocus(m)},[h,m]),y=Y.useCallback(S=>{h==null||h.trackProductInsightsAgentQuestionClick({...m,question:S})},[h,m]),_=Y.useCallback(S=>{h==null||h.trackProductInsightsAgentQuestionSubmit({...m,question:S})},[h,m]),E=Y.useCallback((S,T,k)=>{h==null||h.trackProductInsightsAgentAnswerView({...m,question:S,answerText:T.value,qnaResultId:T.qna_result_id,...k&&k.length>0&&{items:k.map(L=>({itemId:L.id,itemName:L.name}))},...T.follow_up_questions&&T.follow_up_questions.length>0&&{followUpQuestions:T.follow_up_questions.map(L=>({value:L.value}))}})},[h,m]),w=Y.useCallback((S,T)=>{const k=S===fr.UP?"thumbs_up":"thumbs_down";h==null||h.trackProductInsightsAgentAnswerFeedback({...m,feedbackLabel:k,...T&&{qnaResultId:T}})},[h,m]),x=Y.useCallback((S,T,k,L)=>{h==null||h.trackProductInsightsAgentResultClick({itemId:S.id,itemName:S.name,...S.variationId&&{variationId:S.variationId},question:k,seedItemId:a,seedItemName:o,...l&&{seedVariationId:l},...L&&{qnaResultId:L},...f&&{threadId:f},position:T})},[h,a,o,l,f]);return Y.useMemo(()=>({trackViews:p,trackView:c,trackOutOfView:g,trackFocus:v,trackQuestionClick:y,trackQuestionSubmit:_,trackAnswerView:E,trackAnswerFeedback:w,trackResultClick:x}),[p,c,g,v,y,_,E,w,x])}const d1=300*1e3,h1=.5;function Pg({tracking:r,questions:a,viewThreshold:o=h1,awaitQuestions:l=!0}){const f=Y.useRef(null),h=Y.useRef(null),m=Y.useRef(null),d=Y.useRef([]),p=Y.useRef(null),c=Y.useRef(a),g=Y.useRef(r),v=Y.useRef(l);Y.useEffect(()=>{v.current=l},[l]),Y.useEffect(()=>{const x=c.current.length===0&&a.length>0;c.current=a,v.current&&x&&p.current&&g.current.trackView(a)},[a]),Y.useEffect(()=>{g.current=r},[r]);const y=Y.useCallback(()=>{p.current&&(d.current.push({start:p.current,end:new Date().toISOString()}),p.current=null);const x=!v.current||c.current.length>0;d.current.length>0&&x&&(g.current.trackViews(c.current,[...d.current]),d.current=[])},[]),_=Y.useCallback(x=>{const S=new IntersectionObserver(([k])=>{k.isIntersecting?(p.current=new Date().toISOString(),(!v.current||c.current.length>0)&&g.current.trackView(c.current)):p.current&&(d.current.push({start:p.current,end:new Date().toISOString()}),p.current=null,g.current.trackOutOfView())},{threshold:o});S.observe(x),h.current=S,m.current=setInterval(y,d1);const T=()=>{document.visibilityState==="hidden"&&y()};return document.addEventListener("visibilitychange",T),()=>{S.disconnect(),m.current&&clearInterval(m.current),document.removeEventListener("visibilitychange",T),y()}},[y]),E=Y.useRef(null),w=Y.useCallback(x=>{E.current&&(E.current(),E.current=null),f.current=x,x&&(E.current=_(x))},[_]);return Y.useEffect(()=>()=>{E.current&&(E.current(),E.current=null)},[]),{containerRef:w}}function $g({callbacks:r,context:a}){const o=Y.useRef(r),l=Y.useRef(a),f=Y.useRef(!1),h=Y.useRef(!1),m=Y.useRef(null);return Y.useEffect(()=>{o.current=r},[r]),Y.useEffect(()=>{l.current=a},[a]),Y.useEffect(()=>()=>{var p;(p=m.current)==null||p.disconnect()},[]),{containerRef:Y.useCallback(p=>{if(m.current&&(m.current.disconnect(),m.current=null),!p)return;f.current=!1,h.current=!1;const c=new IntersectionObserver(([g])=>{var v,y,_,E;g.isIntersecting&&!f.current?(f.current=!0,(y=(v=o.current)==null?void 0:v.onView)==null||y.call(v,l.current)):!g.isIntersecting&&f.current&&!h.current&&(h.current=!0,(E=(_=o.current)==null?void 0:_.onOutOfView)==null||E.call(_,l.current),c.disconnect())},{threshold:.5});c.observe(p),m.current=c},[])}}function m1(){return O.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},O.createElement("path",{d:"M12.0004 2C6.4804 2 2.0004 6.48 2.0004 12C2.0004 17.52 6.4804 22 12.0004 22C17.5204 22 22.0004 17.52 22.0004 12C22.0004 6.48 17.5204 2 12.0004 2ZM13.0004 17H11.0004V15H13.0004V17ZM13.0004 13H11.0004V7H13.0004V13Z",fill:"#F1923A"}))}function p1(){return O.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},O.createElement("path",{d:"M11.7633 4.23329C10.7966 3.26663 9.46992 2.66663 7.99659 2.66663C5.04992 2.66663 2.66992 5.05329 2.66992 7.99996C2.66992 10.9466 5.04992 13.3333 7.99659 13.3333C10.4833 13.3333 12.5566 11.6333 13.1499 9.33329H11.7633C11.2166 10.8866 9.73659 12 7.99659 12C5.78992 12 3.99659 10.2066 3.99659 7.99996C3.99659 5.79329 5.78992 3.99996 7.99659 3.99996C9.10326 3.99996 10.0899 4.45996 10.8099 5.18663L8.66326 7.33329H13.3299V2.66663L11.7633 4.23329Z",fill:"white"}))}function Xg({message:r,onRetry:a=void 0,translations:o,announce:l=!0}){const f=r||rt("Unexpected error",o);return O.createElement("div",{className:"cio-pia-error-block-container","data-testid":"error-block"},O.createElement("div",{className:"cio-pia-error-block-warning-icon-container","data-testid":"error-block-warning-icon"},O.createElement(m1,null)),O.createElement("div",{className:"cio-pia-error-block-text-container"},O.createElement("p",{className:"cio-pia-error-block-text",role:l?"alert":void 0},f),a&&O.createElement("button",{type:"button",onClick:a,className:"cio-pia-error-block-retry-button"},O.createElement(p1,null),rt("Retry",o))))}const kp=O.createElement("div",{className:"cio-pia-loading-skeleton","data-testid":"loading-skeleton","aria-hidden":"true"},O.createElement("div",{className:"skeleton-bar"}),O.createElement("div",{className:"skeleton-bar"}),O.createElement("div",{className:"skeleton-bar skeleton-short"}));function Zg({componentOverride:r}={}){return O.createElement(Ge,{props:{skeleton:kp},override:r==null?void 0:r.reactNode},kp)}/*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */function Np(r,a){(a==null||a>r.length)&&(a=r.length);for(var o=0,l=Array(a);o<a;o++)l[o]=r[o];return l}function g1(r){if(Array.isArray(r))return r}function y1(r,a){var o=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(o!=null){var l,f,h,m,d=[],p=!0,c=!1;try{if(h=(o=o.call(r)).next,a!==0)for(;!(p=(l=h.call(o)).done)&&(d.push(l.value),d.length!==a);p=!0);}catch(g){c=!0,f=g}finally{try{if(!p&&o.return!=null&&(m=o.return(),Object(m)!==m))return}finally{if(c)throw f}}return d}}function b1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
57
+ */const r1="2.16.1";function vf({apiKey:r,threadId:a,cioClient:o,testCells:l}){const[f]=Y.useState(()=>crypto.randomUUID()),h=a||f,m=Y.useMemo(()=>JSON.stringify(l??null),[l]),d=Y.useMemo(()=>o||new i1({apiKey:r,sendTrackingEvents:!0,version:`cio-ui-pia-${r1}`,...l&&{testCells:l}}),[r,o,m]);return Y.useEffect(()=>{!o||!l||Object.keys(l).length===0||console.warn("[CioPia] abTest.testCells is ignored when you supply your own cioClient. Set testCells on that client instead.")},[o,m]),{cioClient:d,threadId:h}}function a1({itemId:r,variationId:a,threadId:o,cioClient:l,parameters:f}){const[h,m]=Y.useState([]),[d,p]=Y.useState(!1),[c,g]=Y.useState(null),v=Y.useMemo(()=>JSON.stringify(f),[f]),y=Y.useRef(l);Y.useEffect(()=>{y.current=l},[l]);const _=!!l,E=Y.useCallback(()=>{const w=y.current;w&&(p(!0),g(null),w.agent.pia.getSuggestedQuestions(r,{threadId:o,variationId:a,...f}).then(x=>{m(x.questions),g(null)}).catch(x=>{g(x instanceof Error?x:new Error("Error fetching questions"))}).finally(()=>{p(!1)}))},[_,r,a,o,v]);return Y.useEffect(()=>{E()},[E]),{data:h,isLoading:d,error:c,getSuggestedQuestions:E}}const l1={guard:{camelKey:"guard",isObject:!1},num_results:{camelKey:"numResults",isObject:!1},numResults:{camelKey:"numResults",isObject:!1},pre_filter_expression:{camelKey:"preFilterExpression",isObject:!0},preFilterExpression:{camelKey:"preFilterExpression",isObject:!0},fmt_options:{camelKey:"fmtOptions",isObject:!0},fmtOptions:{camelKey:"fmtOptions",isObject:!0}};function s1(r){if(!r)return;const a={};let o=!1;for(const[l,f]of Object.entries(r)){const h=l1[l];if(h)if(o=!0,h.isObject&&typeof f=="string")try{a[h.camelKey]=JSON.parse(f)}catch{a[h.camelKey]=f}else a[h.camelKey]=f}return o?a:void 0}function o1(r){const{apiKey:a,itemId:o,variationId:l,threadId:f,cioClient:h,suggestedQuestionsParameters:m,answerParameters:d,parameters:p,formatImageUrl:c,testCells:g}=r,{cioClient:v,threadId:y}=vf({apiKey:a,threadId:f,cioClient:h,testCells:g}),_=s1(p),E=_||m?{..._,...m}:void 0,w=_||d?{..._,...d}:void 0,x=a1({itemId:o,variationId:l,threadId:y,cioClient:v,parameters:E}),S=q_({itemId:o,variationId:l,threadId:y,cioClient:v,parameters:w,formatImageUrl:c});return{cioClient:v,threadId:y,suggestedQuestions:x,answers:S}}function u1(r){if(typeof r!="object"||r===null)return!1;const{question:a,answer:o,items:l}=r;return typeof a=="string"&&typeof o=="string"&&(l==null||Array.isArray(l))}function c1(r){if(!Array.isArray(r))return console.warn("[CioPia] initialConversationHistory must be an array. It was ignored."),[];const a=r.filter(u1);return a.length<r.length&&console.warn(`[CioPia] ${r.length-a.length} initialConversationHistory entries were ignored. Each needs a string question and answer, and items must be an array.`),a.map((o,l)=>({...o,id:l+1}))}function f1({pia:r,itemId:a,isConversation:o,callbacks:l,tracking:f,initialConversationHistory:h}){var re;const{suggestedQuestions:m,answers:d,threadId:p}=r,{getAnswer:c}=d,g=Y.useMemo(()=>({itemId:a,threadId:p}),[a,p]),[v,y]=Y.useState(""),[_,E]=Y.useState([]),[w,x]=Y.useState(()=>o&&h!==void 0?c1(h):[]),S=Y.useRef(w.length),T=Y.useRef(w),k=Y.useRef(a),L=Y.useRef(d.data),H=Y.useRef(!1),N=Y.useRef(d),R=Y.useRef(l),A=Y.useRef(g),D=Y.useRef(f),M=Y.useRef(""),I=Y.useRef("user"),G=Y.useRef(!1);Y.useEffect(()=>{R.current=l},[l]),Y.useEffect(()=>{A.current=g},[g]),Y.useEffect(()=>{D.current=f},[f]),Y.useEffect(()=>{N.current=d},[d]),Y.useEffect(()=>{T.current=w},[w]);const F=Y.useCallback((ie,ee)=>{if(I.current=ee,M.current=ie,H.current=!1,y(ie),c(ie),o){S.current+=1;const fe=S.current;x(me=>[...me,{id:fe,question:ie,answer:"",source:ee}])}},[c,o]),W=Y.useCallback(ie=>{var ee,fe,me;(ee=D.current)==null||ee.trackQuestionSubmit(ie),(me=(fe=R.current)==null?void 0:fe.onQuestionSubmit)==null||me.call(fe,ie,A.current,"user"),F(ie,"user")},[F]),ue=Y.useCallback(ie=>{var ee,fe,me;(ee=D.current)==null||ee.trackQuestionClick(ie),(me=(fe=R.current)==null?void 0:fe.onQuestionSubmit)==null||me.call(fe,ie,A.current,"suggestion"),F(ie,"suggestion")},[F]),B=Y.useCallback(()=>{var ie,ee,fe;(ie=D.current)==null||ie.trackFocus(),(fe=(ee=R.current)==null?void 0:ee.onFocus)==null||fe.call(ee,A.current)},[]),Z=Y.useCallback(ie=>{var me,we,ge,qe,Ce;const ee=T.current,fe=((me=N.current.data)==null?void 0:me.qna_result_id)??((we=ee[ee.length-1])==null?void 0:we.qnaResultId);(ge=D.current)==null||ge.trackAnswerFeedback(ie,fe),(Ce=(qe=R.current)==null?void 0:qe.onFeedback)==null||Ce.call(qe,ie)},[]),le=Y.useCallback(()=>{y(""),E(m.data),x([]),L.current=null,G.current=!1},[m.data]);Y.useEffect(()=>{k.current!==a&&(k.current=a,y(""),E([]),x([]),L.current=null,G.current=!1)},[a]),Y.useEffect(()=>{G.current||E(m.data)},[m.data]),Y.useEffect(()=>{var ie;d.data&&(E(d.data.follow_up_questions??[]),G.current=!0),d.data&&M.current&&!H.current&&(H.current=!0,(ie=D.current)==null||ie.trackAnswerView(M.current,d.data,d.items))},[d.data,d.items]),Y.useEffect(()=>{var me,we,ge,qe,Ce;const ie=((me=d.data)==null?void 0:me.value)??"";if(!ie||d.data===L.current)return;L.current=d.data;const ee=(we=d.data)==null?void 0:we.thread_id,fe=(ge=d.data)==null?void 0:ge.qna_result_id;if(o)x(he=>{var ke,Ae;if(he.length===0)return he;const Re=[...he];return Re[Re.length-1]={...Re[Re.length-1],answer:ie,items:d.items,threadId:ee,qnaResultId:fe},(Ae=(ke=R.current)==null?void 0:ke.onAnswer)==null||Ae.call(ke,Re,A.current),Re});else{const he={id:S.current,question:M.current,answer:ie,source:I.current,items:d.items,threadId:ee,qnaResultId:fe};(Ce=(qe=R.current)==null?void 0:qe.onAnswer)==null||Ce.call(qe,[he],A.current)}},[o,d.data,d.items]);const ce=((re=d.data)==null?void 0:re.value)??"",ne=d.items??null,z=d.error||m.error,K=d.isLoading||m.isLoading;return{currentQuestion:v,displayedQuestions:_,conversationHistory:w,currentAnswer:ce,currentItems:ne,isLoading:K,error:z,context:g,handleSubmitQuestion:W,handleQuestionClick:ue,handleInputFocus:B,handleFeedback:Z,resetState:le}}var fr=(r=>(r.UP="up",r.DOWN="down",r))(fr||{});function Yg({cioClient:r,itemId:a,itemName:o,variationId:l,threadId:f}){const h=r==null?void 0:r.tracker,m=Y.useMemo(()=>({itemId:a,itemName:o,...l&&{variationId:l},...f&&{threadId:f}}),[a,o,l,f]),d=Y.useCallback(S=>S.map(T=>({question:T.value})),[]),p=Y.useCallback((S,T)=>{h==null||h.trackProductInsightsAgentViews({...m,questions:d(S),viewTimespans:T})},[h,m,d]),c=Y.useCallback(S=>{h==null||h.trackProductInsightsAgentView({...m,questions:d(S)})},[h,m,d]),g=Y.useCallback(()=>{h==null||h.trackProductInsightsAgentOutOfView(m)},[h,m]),v=Y.useCallback(()=>{h==null||h.trackProductInsightsAgentFocus(m)},[h,m]),y=Y.useCallback(S=>{h==null||h.trackProductInsightsAgentQuestionClick({...m,question:S})},[h,m]),_=Y.useCallback(S=>{h==null||h.trackProductInsightsAgentQuestionSubmit({...m,question:S})},[h,m]),E=Y.useCallback((S,T,k)=>{h==null||h.trackProductInsightsAgentAnswerView({...m,question:S,answerText:T.value,qnaResultId:T.qna_result_id,...k&&k.length>0&&{items:k.map(L=>({itemId:L.id,itemName:L.name}))},...T.follow_up_questions&&T.follow_up_questions.length>0&&{followUpQuestions:T.follow_up_questions.map(L=>({value:L.value}))}})},[h,m]),w=Y.useCallback((S,T)=>{const k=S===fr.UP?"thumbs_up":"thumbs_down";h==null||h.trackProductInsightsAgentAnswerFeedback({...m,feedbackLabel:k,...T&&{qnaResultId:T}})},[h,m]),x=Y.useCallback((S,T,k,L)=>{h==null||h.trackProductInsightsAgentResultClick({itemId:S.id,itemName:S.name,...S.variationId&&{variationId:S.variationId},question:k,seedItemId:a,seedItemName:o,...l&&{seedVariationId:l},...L&&{qnaResultId:L},...f&&{threadId:f},position:T})},[h,a,o,l,f]);return Y.useMemo(()=>({trackViews:p,trackView:c,trackOutOfView:g,trackFocus:v,trackQuestionClick:y,trackQuestionSubmit:_,trackAnswerView:E,trackAnswerFeedback:w,trackResultClick:x}),[p,c,g,v,y,_,E,w,x])}const d1=300*1e3,h1=.5;function Pg({tracking:r,questions:a,viewThreshold:o=h1,awaitQuestions:l=!0}){const f=Y.useRef(null),h=Y.useRef(null),m=Y.useRef(null),d=Y.useRef([]),p=Y.useRef(null),c=Y.useRef(a),g=Y.useRef(r),v=Y.useRef(l);Y.useEffect(()=>{v.current=l},[l]),Y.useEffect(()=>{const x=c.current.length===0&&a.length>0;c.current=a,v.current&&x&&p.current&&g.current.trackView(a)},[a]),Y.useEffect(()=>{g.current=r},[r]);const y=Y.useCallback(()=>{p.current&&(d.current.push({start:p.current,end:new Date().toISOString()}),p.current=null);const x=!v.current||c.current.length>0;d.current.length>0&&x&&(g.current.trackViews(c.current,[...d.current]),d.current=[])},[]),_=Y.useCallback(x=>{const S=new IntersectionObserver(([k])=>{k.isIntersecting?(p.current=new Date().toISOString(),(!v.current||c.current.length>0)&&g.current.trackView(c.current)):p.current&&(d.current.push({start:p.current,end:new Date().toISOString()}),p.current=null,g.current.trackOutOfView())},{threshold:o});S.observe(x),h.current=S,m.current=setInterval(y,d1);const T=()=>{document.visibilityState==="hidden"&&y()};return document.addEventListener("visibilitychange",T),()=>{S.disconnect(),m.current&&clearInterval(m.current),document.removeEventListener("visibilitychange",T),y()}},[y]),E=Y.useRef(null),w=Y.useCallback(x=>{E.current&&(E.current(),E.current=null),f.current=x,x&&(E.current=_(x))},[_]);return Y.useEffect(()=>()=>{E.current&&(E.current(),E.current=null)},[]),{containerRef:w}}function $g({callbacks:r,context:a}){const o=Y.useRef(r),l=Y.useRef(a),f=Y.useRef(!1),h=Y.useRef(!1),m=Y.useRef(null);return Y.useEffect(()=>{o.current=r},[r]),Y.useEffect(()=>{l.current=a},[a]),Y.useEffect(()=>()=>{var p;(p=m.current)==null||p.disconnect()},[]),{containerRef:Y.useCallback(p=>{if(m.current&&(m.current.disconnect(),m.current=null),!p)return;f.current=!1,h.current=!1;const c=new IntersectionObserver(([g])=>{var v,y,_,E;g.isIntersecting&&!f.current?(f.current=!0,(y=(v=o.current)==null?void 0:v.onView)==null||y.call(v,l.current)):!g.isIntersecting&&f.current&&!h.current&&(h.current=!0,(E=(_=o.current)==null?void 0:_.onOutOfView)==null||E.call(_,l.current),c.disconnect())},{threshold:.5});c.observe(p),m.current=c},[])}}function m1(){return O.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},O.createElement("path",{d:"M12.0004 2C6.4804 2 2.0004 6.48 2.0004 12C2.0004 17.52 6.4804 22 12.0004 22C17.5204 22 22.0004 17.52 22.0004 12C22.0004 6.48 17.5204 2 12.0004 2ZM13.0004 17H11.0004V15H13.0004V17ZM13.0004 13H11.0004V7H13.0004V13Z",fill:"#F1923A"}))}function p1(){return O.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},O.createElement("path",{d:"M11.7633 4.23329C10.7966 3.26663 9.46992 2.66663 7.99659 2.66663C5.04992 2.66663 2.66992 5.05329 2.66992 7.99996C2.66992 10.9466 5.04992 13.3333 7.99659 13.3333C10.4833 13.3333 12.5566 11.6333 13.1499 9.33329H11.7633C11.2166 10.8866 9.73659 12 7.99659 12C5.78992 12 3.99659 10.2066 3.99659 7.99996C3.99659 5.79329 5.78992 3.99996 7.99659 3.99996C9.10326 3.99996 10.0899 4.45996 10.8099 5.18663L8.66326 7.33329H13.3299V2.66663L11.7633 4.23329Z",fill:"white"}))}function Xg({message:r,onRetry:a=void 0,translations:o,announce:l=!0}){const f=r||rt("Unexpected error",o);return O.createElement("div",{className:"cio-pia-error-block-container","data-testid":"error-block"},O.createElement("div",{className:"cio-pia-error-block-warning-icon-container","data-testid":"error-block-warning-icon"},O.createElement(m1,null)),O.createElement("div",{className:"cio-pia-error-block-text-container"},O.createElement("p",{className:"cio-pia-error-block-text",role:l?"alert":void 0},f),a&&O.createElement("button",{type:"button",onClick:a,className:"cio-pia-error-block-retry-button"},O.createElement(p1,null),rt("Retry",o))))}const kp=O.createElement("div",{className:"cio-pia-loading-skeleton","data-testid":"loading-skeleton","aria-hidden":"true"},O.createElement("div",{className:"skeleton-bar"}),O.createElement("div",{className:"skeleton-bar"}),O.createElement("div",{className:"skeleton-bar skeleton-short"}));function Zg({componentOverride:r}={}){return O.createElement(Ge,{props:{skeleton:kp},override:r==null?void 0:r.reactNode},kp)}/*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */function Np(r,a){(a==null||a>r.length)&&(a=r.length);for(var o=0,l=Array(a);o<a;o++)l[o]=r[o];return l}function g1(r){if(Array.isArray(r))return r}function y1(r,a){var o=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(o!=null){var l,f,h,m,d=[],p=!0,c=!1;try{if(h=(o=o.call(r)).next,a!==0)for(;!(p=(l=h.call(o)).done)&&(d.push(l.value),d.length!==a);p=!0);}catch(g){c=!0,f=g}finally{try{if(!p&&o.return!=null&&(m=o.return(),Object(m)!==m))return}finally{if(c)throw f}}return d}}function b1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
58
58
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v1(r,a){return g1(r)||y1(r,a)||_1(r,a)||b1()}function _1(r,a){if(r){if(typeof r=="string")return Np(r,a);var o={}.toString.call(r).slice(8,-1);return o==="Object"&&r.constructor&&(o=r.constructor.name),o==="Map"||o==="Set"?Array.from(r):o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?Np(r,a):void 0}}const Kg=Object.entries,qp=Object.setPrototypeOf,S1=Object.isFrozen,E1=Object.getPrototypeOf,w1=Object.getOwnPropertyDescriptor;let Ot=Object.freeze,Lt=Object.seal,La=Object.create,Jg=typeof Reflect<"u"&&Reflect,Fc=Jg.apply,Wc=Jg.construct;Ot||(Ot=function(a){return a});Lt||(Lt=function(a){return a});Fc||(Fc=function(a,o){for(var l=arguments.length,f=new Array(l>2?l-2:0),h=2;h<l;h++)f[h-2]=arguments[h];return a.apply(o,f)});Wc||(Wc=function(a){for(var o=arguments.length,l=new Array(o>1?o-1:0),f=1;f<o;f++)l[f-1]=arguments[f];return new a(...l)});const Ir=Nt(Array.prototype.forEach),T1=Nt(Array.prototype.lastIndexOf),zp=Nt(Array.prototype.pop),Dl=Nt(Array.prototype.push),A1=Nt(Array.prototype.splice),Ua=Array.isArray,Il=Nt(String.prototype.toLowerCase),zc=Nt(String.prototype.toString),Op=Nt(String.prototype.match),Ll=Nt(String.prototype.replace),Mp=Nt(String.prototype.indexOf),x1=Nt(String.prototype.trim),C1=Nt(Number.prototype.toString),R1=Nt(Boolean.prototype.toString),Dp=typeof BigInt>"u"?null:Nt(BigInt.prototype.toString),Lp=typeof Symbol>"u"?null:Nt(Symbol.prototype.toString),fn=Nt(Object.prototype.hasOwnProperty),Ul=Nt(Object.prototype.toString),$t=Nt(RegExp.prototype.test),jr=k1(TypeError);function Nt(r){return function(a){a instanceof RegExp&&(a.lastIndex=0);for(var o=arguments.length,l=new Array(o>1?o-1:0),f=1;f<o;f++)l[f-1]=arguments[f];return Fc(r,a,l)}}function k1(r){return function(){for(var a=arguments.length,o=new Array(a),l=0;l<a;l++)o[l]=arguments[l];return Wc(r,o)}}function Qe(r,a){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Il;if(qp&&qp(r,null),!Ua(a))return r;let l=a.length;for(;l--;){let f=a[l];if(typeof f=="string"){const h=o(f);h!==f&&(S1(a)||(a[l]=h),f=h)}r[f]=!0}return r}function N1(r){for(let a=0;a<r.length;a++)fn(r,a)||(r[a]=null);return r}function Tn(r){const a=La(null);for(const l of Kg(r)){var o=v1(l,2);const f=o[0],h=o[1];fn(r,f)&&(Ua(h)?a[f]=N1(h):h&&typeof h=="object"&&h.constructor===Object?a[f]=Tn(h):a[f]=h)}return a}function q1(r){switch(typeof r){case"string":return r;case"number":return C1(r);case"boolean":return R1(r);case"bigint":return Dp?Dp(r):"0";case"symbol":return Lp?Lp(r):"Symbol()";case"undefined":return Ul(r);case"function":case"object":{if(r===null)return Ul(r);const a=r,o=Bn(a,"toString");if(typeof o=="function"){const l=o(a);return typeof l=="string"?l:Ul(l)}return Ul(r)}default:return Ul(r)}}function Bn(r,a){for(;r!==null;){const l=w1(r,a);if(l){if(l.get)return Nt(l.get);if(typeof l.value=="function")return Nt(l.value)}r=E1(r)}function o(){return null}return o}function z1(r){try{return $t(r,""),!0}catch{return!1}}const Up=Ot(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Oc=Ot(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Mc=Ot(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),O1=Ot(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Dc=Ot(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),M1=Ot(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Bp=Ot(["#text"]),Hp=Ot(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Lc=Ot(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),jp=Ot(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),mo=Ot(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),D1=Lt(/{{[\w\W]*|^[\w\W]*}}/g),L1=Lt(/<%[\w\W]*|^[\w\W]*%>/g),U1=Lt(/\${[\w\W]*/g),B1=Lt(/^data-[\-\w.\u00B7-\uFFFF]+$/),H1=Lt(/^aria-[\-\w]+$/),Ip=Lt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),j1=Lt(/^(?:\w+script|data):/i),I1=Lt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G1=Lt(/^html$/i),V1=Lt(/^[a-z][.\w]*(-[.\w]+)+$/i),Gp=Lt(/<[/\w!]/g),Vp=Lt(/<[/\w]/g),Q1=Lt(/<\/no(script|embed|frames)/i),Y1=Lt(/\/>/i),wn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Fg=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],P1=Ot(Qe({},Fg)),$1=(function(){const r={};return Ir(Fg,a=>{r[a]=Lt(new RegExp("</"+a+"(?=[\\t\\n\\f\\r />])","i"))}),Ot(r)})(),X1=function(){return typeof window>"u"?null:window},Z1=function(a,o){if(typeof a!="object"||typeof a.createPolicy!="function")return null;let l=null;const f="data-tt-policy-suffix";o&&o.hasAttribute(f)&&(l=o.getAttribute(f));const h="dompurify"+(l?"#"+l:"");try{return a.createPolicy(h,{createHTML(m){return m},createScriptURL(m){return m}})}catch{return console.warn("TrustedTypes policy "+h+" could not be created."),null}},Qp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},cr=function(a,o,l,f){return fn(a,o)&&Ua(a[o])?Qe(f.base?Tn(f.base):{},a[o],f.transform):l},Uc=function(a,o,l){const f=fn(a,o)?a[o]:void 0;return f&&typeof f=="object"?Tn(f):l()};function Wg(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:X1();const a=de=>Wg(de);if(a.version="3.4.15",a.removed=[],!r||!r.document||r.document.nodeType!==wn.document||!r.Element)return a.isSupported=!1,a;let o=r.document;const l=o,f=l.currentScript;r.DocumentFragment;const h=r.HTMLTemplateElement,m=r.Node,d=r.Element,p=r.NodeFilter,c=r.NamedNodeMap;c===void 0&&(r.NamedNodeMap||r.MozNamedAttrMap),r.HTMLFormElement;const g=r.DOMParser,v=r.trustedTypes,y=d.prototype,_=Bn(y,"cloneNode"),E=Bn(y,"remove"),w=Bn(y,"removeAttributeNode"),x=Bn(y,"nextSibling"),S=Bn(y,"childNodes"),T=Bn(y,"parentNode"),k=Bn(y,"shadowRoot"),L=Bn(y,"attributes"),H=m&&m.prototype?Bn(m.prototype,"nodeType"):null,N=m&&m.prototype?Bn(m.prototype,"nodeName"):null,R=m&&m.prototype?Bn(m.prototype,"ownerDocument"):null,A=function(q){return H?H(q):q.nodeType},D=function(q){return N?N(q):q.nodeName};if(typeof h=="function"){const de=o.createElement("template");de.content&&de.content.ownerDocument&&(o=de.content.ownerDocument)}let M,I="",G,F=!1,W=0;const ue=function(){if(W>0)throw jr('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},B=function(q){ue(),W++;try{return M.createHTML(q)}finally{W--}},Z=function(q){ue(),W++;try{return M.createScriptURL(q)}finally{W--}},le=function(){return F||(G=Z1(v,f),F=!0),G},ce=o,ne=ce.implementation,z=ce.createNodeIterator,K=ce.createDocumentFragment,re=ce.getElementsByTagName,ie=l.importNode;let ee=Qp();a.isSupported=typeof Kg=="function"&&typeof T=="function"&&ne&&ne.createHTMLDocument!==void 0;const fe=D1,me=L1,we=U1,ge=B1,qe=H1,Ce=j1,he=I1,Re=V1;let ke=Ip,Ae=null;const yt=Qe({},[...Up,...Oc,...Mc,...Dc,...Bp]);let Me=null;const Ut=Qe({},[...Hp,...Lc,...jp,...mo]);let ft=Object.seal(La(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Bt=null,xn=null;const Ft=Object.seal(La(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Mi=!0,Et=!0,hr=!1,mr=!0,Wt=!1,en=!0,hn=!1,mn=!1,Xn=null,Zn=null,tn=!1,mt=!1,Xt=!1,wt=!1,Xr=!0,Zr=!1;const pr="user-content-";let Kn=!0,Hn=!1,nn={},Ht=null;const si=Qe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let jn=null;const gr=Qe({},["audio","video","img","source","image","track"]);let yr=null;const Kr=Qe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Jn="http://www.w3.org/1998/Math/MathML",Jr="http://www.w3.org/2000/svg",pn="http://www.w3.org/1999/xhtml";let oi=pn,Fr=!1,br=null;const Ia=Qe({},[Jn,Jr,pn],zc),Ga=Ot(["mi","mo","mn","ms","mtext"]);let Wr=Qe({},Ga);const In=Ot(["annotation-xml"]);let bt=Qe({},In);const Qt=Qe({},["title","style","font","a","script"]);let Cn=null;const Va=["application/xhtml+xml","text/html"],Co="text/html";let dt=null,ui=null;const vr=o.createElement("form"),ea=function(q){return q instanceof RegExp||q instanceof Function},Fn=function(){let q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ui&&ui===q)return;(!q||typeof q!="object")&&(q={}),q=Tn(q),Cn=Va.indexOf(q.PARSER_MEDIA_TYPE)===-1?Co:q.PARSER_MEDIA_TYPE,dt=Cn==="application/xhtml+xml"?zc:Il,Ae=cr(q,"ALLOWED_TAGS",yt,{transform:dt}),Me=cr(q,"ALLOWED_ATTR",Ut,{transform:dt}),br=cr(q,"ALLOWED_NAMESPACES",Ia,{transform:zc}),yr=cr(q,"ADD_URI_SAFE_ATTR",Kr,{transform:dt,base:Kr}),jn=cr(q,"ADD_DATA_URI_TAGS",gr,{transform:dt,base:gr}),Ht=cr(q,"FORBID_CONTENTS",si,{transform:dt}),Bt=cr(q,"FORBID_TAGS",Tn({}),{transform:dt}),xn=cr(q,"FORBID_ATTR",Tn({}),{transform:dt}),nn=fn(q,"USE_PROFILES")?q.USE_PROFILES&&typeof q.USE_PROFILES=="object"?Tn(q.USE_PROFILES):q.USE_PROFILES:!1,Mi=q.ALLOW_ARIA_ATTR!==!1,Et=q.ALLOW_DATA_ATTR!==!1,hr=q.ALLOW_UNKNOWN_PROTOCOLS||!1,mr=q.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Wt=q.SAFE_FOR_TEMPLATES||!1,en=q.SAFE_FOR_XML!==!1,hn=q.WHOLE_DOCUMENT||!1,mt=q.RETURN_DOM||!1,Xt=q.RETURN_DOM_FRAGMENT||!1,wt=q.RETURN_TRUSTED_TYPE||!1,tn=q.FORCE_BODY||!1,Xr=q.SANITIZE_DOM!==!1,Zr=q.SANITIZE_NAMED_PROPS||!1,Kn=q.KEEP_CONTENT!==!1,Hn=q.IN_PLACE||!1,ke=z1(q.ALLOWED_URI_REGEXP)?q.ALLOWED_URI_REGEXP:Ip,oi=typeof q.NAMESPACE=="string"?q.NAMESPACE:pn,Wr=Uc(q,"MATHML_TEXT_INTEGRATION_POINTS",()=>Qe({},Ga)),bt=Uc(q,"HTML_INTEGRATION_POINTS",()=>Qe({},In));const Q=Uc(q,"CUSTOM_ELEMENT_HANDLING",()=>La(null));if(ft=La(null),fn(Q,"tagNameCheck")&&ea(Q.tagNameCheck)&&(ft.tagNameCheck=Q.tagNameCheck),fn(Q,"attributeNameCheck")&&ea(Q.attributeNameCheck)&&(ft.attributeNameCheck=Q.attributeNameCheck),fn(Q,"allowCustomizedBuiltInElements")&&typeof Q.allowCustomizedBuiltInElements=="boolean"&&(ft.allowCustomizedBuiltInElements=Q.allowCustomizedBuiltInElements),Lt(ft),Wt&&(Et=!1),Xt&&(mt=!0),nn&&(Ae=Qe({},Bp),Me=La(null),nn.html===!0&&(Qe(Ae,Up),Qe(Me,Hp)),nn.svg===!0&&(Qe(Ae,Oc),Qe(Me,Lc),Qe(Me,mo)),nn.svgFilters===!0&&(Qe(Ae,Mc),Qe(Me,Lc),Qe(Me,mo)),nn.mathMl===!0&&(Qe(Ae,Dc),Qe(Me,jp),Qe(Me,mo))),Ft.tagCheck=null,Ft.attributeCheck=null,fn(q,"ADD_TAGS")&&(typeof q.ADD_TAGS=="function"?Ft.tagCheck=q.ADD_TAGS:Ua(q.ADD_TAGS)&&(Ae===yt&&(Ae=Tn(Ae)),Qe(Ae,q.ADD_TAGS,dt))),fn(q,"ADD_ATTR")&&(typeof q.ADD_ATTR=="function"?Ft.attributeCheck=q.ADD_ATTR:Ua(q.ADD_ATTR)&&(Me===Ut&&(Me=Tn(Me)),Qe(Me,q.ADD_ATTR,dt))),fn(q,"ADD_FORBID_CONTENTS")&&Ua(q.ADD_FORBID_CONTENTS)&&(Ht===si&&(Ht=Tn(Ht)),Qe(Ht,q.ADD_FORBID_CONTENTS,dt)),Kn&&(Ae["#text"]=!0),hn&&Qe(Ae,["html","head","body"]),Ae.table&&(Qe(Ae,["tbody"]),delete Bt.tbody),q.TRUSTED_TYPES_POLICY){if(typeof q.TRUSTED_TYPES_POLICY.createHTML!="function")throw jr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof q.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw jr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const oe=M;M=q.TRUSTED_TYPES_POLICY;try{I=B("")}catch(pe){throw M=oe,pe}}else q.TRUSTED_TYPES_POLICY===null?(M=void 0,I=""):(M===void 0&&(M=le()),M&&typeof I=="string"&&(I=B("")));Ot&&Ot(q),ui=q},ci=Qe({},[...Oc,...Mc,...O1]),Di=Qe({},[...Dc,...M1]),Li=function(q,Q,oe){return Q.namespaceURI===pn?q==="svg":Q.namespaceURI===Jn?q==="svg"&&(oe==="annotation-xml"||Wr[oe]):!!ci[q]},Tt=function(q,Q,oe){return Q.namespaceURI===pn?q==="math":Q.namespaceURI===Jr?q==="math"&&bt[oe]:!!Di[q]},Zl=function(q,Q,oe){return Q.namespaceURI===Jr&&!bt[oe]||Q.namespaceURI===Jn&&!Wr[oe]?!1:!Di[q]&&(Qt[q]||!ci[q])},Kl=function(q){let Q=T(q);(!Q||!Q.tagName)&&(Q={namespaceURI:oi,tagName:"template"});const oe=Il(q.tagName),pe=Il(Q.tagName);return br[q.namespaceURI]?q.namespaceURI===Jr?Li(oe,Q,pe):q.namespaceURI===Jn?Tt(oe,Q,pe):q.namespaceURI===pn?Zl(oe,Q,pe):!!(Cn==="application/xhtml+xml"&&br[q.namespaceURI]):!1},Yt=function(q){Dl(a.removed,{element:q});try{T(q).removeChild(q)}catch{if(E(q),!T(q))throw jr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},fi=function(q,Q,oe){try{w(q,Q)}catch{try{q.removeAttribute(oe)}catch{}}},ta=function(q){na(q);const Q=S(q);if(Q){const pe=[];Ir(Q,ye=>{Dl(pe,ye)}),Ir(pe,ye=>{try{E(ye)}catch{}})}const oe=L(q);if(oe)for(let pe=oe.length-1;pe>=0;--pe){const ye=oe[pe],xe=ye&&ye.name;typeof xe=="string"&&fi(q,ye,xe)}},Wn=function(q,Q,oe){if(!oe)try{oe=Q.getAttributeNode(q)}catch{oe=null}Dl(a.removed,{attribute:oe||null,from:Q});try{oe?w(Q,oe):Q.removeAttribute(q)}catch{try{Q.removeAttribute(q)}catch{}}if(q==="is")if(mt||Xt)try{Yt(Q)}catch{}else try{Q.setAttribute(q,"")}catch{}},Jl=function(q){const Q=L(q);if(Q)for(let oe=Q.length-1;oe>=0;--oe){const pe=Q[oe],ye=pe&&pe.name;typeof ye!="string"||Me[dt(ye)]||fi(q,pe,ye)}},na=function(q){const Q=[q];for(;Q.length>0;){const oe=Q.pop();A(oe)===wn.element&&Jl(oe);const ye=S(oe);if(ye)for(let xe=ye.length-1;xe>=0;--xe)Q.push(ye[xe])}},_r=function(q,Q){return en?q==="patchsrc"?!0:q==="for"&&Q!=="label"&&Q!=="output":!1},ia=function(q){if(!en)return;const Q=[q];for(;Q.length>0;){const oe=Q.pop(),pe=A(oe);if(pe===wn.processingInstruction||pe===wn.comment&&$t(Vp,oe.data)){try{E(oe)}catch{}continue}if(pe===wn.element){const xe=oe,Xe=dt(D(oe));try{xe.hasAttribute&&xe.hasAttribute("patchsrc")&&xe.removeAttribute("patchsrc"),xe.hasAttribute&&xe.hasAttribute("for")&&_r("for",Xe)&&xe.removeAttribute("for")}catch{}}const ye=S(oe);if(ye)for(let xe=ye.length-1;xe>=0;--xe)Q.push(ye[xe])}},Rn=function(q){let Q=null,oe=null;if(tn)q="<remove></remove>"+q;else{const xe=Op(q,/^[\r\n\t ]+/);oe=xe&&xe[0]}Cn==="application/xhtml+xml"&&oi===pn&&(q='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+q+"</body></html>");const pe=M?B(q):q;if(oi===pn)try{Q=new g().parseFromString(pe,Cn)}catch{}if(!Q||!Q.documentElement){Q=ne.createDocument(oi,"template",null);try{Q.documentElement.innerHTML=Fr?I:pe}catch{}}const ye=Q.body||Q.documentElement;return q&&oe&&ye.insertBefore(o.createTextNode(oe),ye.childNodes[0]||null),oi===pn?re.call(Q,hn?"html":"body")[0]:hn?Q.documentElement:ye},Zt=function(q){const Q=R?R(q):q.ownerDocument;return z.call(Q||q,q,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Sr=function(q){return q=Ll(q,fe," "),q=Ll(q,me," "),q=Ll(q,we," "),q},Qa=function(q){var Q;q.normalize();const oe=R?R(q):q.ownerDocument,pe=z.call(oe||q,q,p.SHOW_TEXT|p.SHOW_COMMENT|p.SHOW_CDATA_SECTION|p.SHOW_PROCESSING_INSTRUCTION,null);let ye=pe.nextNode();for(;ye;)ye.data=Sr(ye.data),ye=pe.nextNode();const xe=(Q=q.querySelectorAll)===null||Q===void 0?void 0:Q.call(q,"template");xe&&Ir(xe,Xe=>{di(Xe.content)&&Qa(Xe.content)})},Ui=function(q){const Q=N?N(q):null;return typeof Q!="string"||dt(Q)!=="form"?!1:typeof q.nodeName!="string"||typeof q.textContent!="string"||typeof q.removeChild!="function"||q.attributes!==L(q)||typeof q.removeAttribute!="function"||typeof q.removeAttributeNode!="function"||typeof q.getAttributeNode!="function"||typeof q.setAttribute!="function"||typeof q.namespaceURI!="string"||typeof q.insertBefore!="function"||typeof q.hasChildNodes!="function"||q.nodeType!==H(q)||q.childNodes!==S(q)},di=function(q){if(!H||typeof q!="object"||q===null)return!1;try{return H(q)===wn.documentFragment}catch{return!1}},ei=function(q){if(!H||typeof q!="object"||q===null)return!1;try{return typeof H(q)=="number"}catch{return!1}};function kn(de,q,Q){de.length!==0&&Ir(de,oe=>{oe.call(a,q,Q,ui)})}const rn=function(q,Q){return!!(en&&q.hasChildNodes()&&!ei(q.firstElementChild)&&$t(Gp,q.textContent)&&$t(Gp,q.innerHTML)||en&&q.namespaceURI===pn&&P1[Q]&&(ei(q.firstElementChild)||typeof q.textContent=="string"&&$t($1[Q],q.textContent))||q.nodeType===wn.processingInstruction||en&&q.nodeType===wn.comment&&$t(Vp,q.data))},Bi=function(q,Q){if(q instanceof RegExp)return $t(q,Q);if(q instanceof Function){for(var oe=arguments.length,pe=new Array(oe>2?oe-2:0),ye=2;ye<oe;ye++)pe[ye-2]=arguments[ye];return!!q(Q,...pe)}return!1},Fl=function(q,Q,oe){if(!Bt[Q]&&Wl(Q)&&Bi(ft.tagNameCheck,Q))return!1;if(Kn&&!Ht[Q]){const pe=T(q),ye=S(q);if(ye&&pe){const xe=ye.length;for(let Xe=xe-1;Xe>=0;--Xe){const lt=q===oe?_(ye[Xe],!0):ye[Xe];pe.insertBefore(lt,x(q))}}}return Yt(q),!0},ra=function(q,Q,oe,pe){return q.length===0?Q:Q===oe||Q===pe?Tn(Q):Q},hi=function(q,Q){return q===Q||T(q)!==null?!1:(Hn&&na(q),!0)},Ya=function(q,Q){if(kn(ee.beforeSanitizeElements,q,null),hi(q,Q))return!0;if(Ui(q))return Yt(q),!0;const oe=dt(D(q));if(Ae=ra(ee.uponSanitizeElement,Ae,yt,Xn),kn(ee.uponSanitizeElement,q,{tagName:oe,allowedTags:Ae}),hi(q,Q))return!0;if(rn(q,oe))return Yt(q),!0;if(Bt[oe]||!(Ft.tagCheck instanceof Function&&Ft.tagCheck(oe))&&!Ae[oe]){const ye=Fl(q,oe,Q);return ye===!1&&kn(ee.afterSanitizeElements,q,null),ye}if(A(q)===wn.element&&!Kl(q)||(oe==="noscript"||oe==="noembed"||oe==="noframes")&&$t(Q1,q.innerHTML))return Yt(q),!0;if(Wt&&q.nodeType===wn.text){const ye=Sr(q.textContent);q.textContent!==ye&&(Dl(a.removed,{element:q.cloneNode()}),q.textContent=ye)}return kn(ee.afterSanitizeElements,q,null),!1},Pa=function(q,Q,oe){if(xn[Q]||_r(Q,q)||Xr&&(Q==="id"||Q==="name")&&(oe in o||oe in vr))return!1;const pe=Me[Q]||Ft.attributeCheck instanceof Function&&Ft.attributeCheck(Q,q);return Et&&$t(ge,Q)||Mi&&$t(qe,Q)?!0:pe?yr[Q]||$t(ke,Ll(oe,he,""))||(Q==="src"||Q==="xlink:href"||Q==="href")&&q!=="script"&&Mp(oe,"data:")===0&&jn[q]||hr&&!$t(Ce,Ll(oe,he,""))?!0:!oe:Wl(q)&&Bi(ft.tagNameCheck,q)&&Bi(ft.attributeNameCheck,Q,q)||Q==="is"&&ft.allowCustomizedBuiltInElements&&Bi(ft.tagNameCheck,oe)},Hi=Qe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Wl=function(q){return!Hi[Il(q)]&&$t(Re,q)},es=function(q,Q,oe,pe){if(M&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!oe)switch(v.getAttributeType(q,Q)){case"TrustedHTML":return B(pe);case"TrustedScriptURL":return Z(pe)}return pe},ts=function(q,Q,oe,pe){try{return oe?q.setAttributeNS(oe,Q,pe):q.setAttribute(Q,pe),Ui(q)?(Yt(q),!1):!0}catch{return Wn(Q,q),!1}},aa=function(q){kn(ee.beforeSanitizeAttributes,q,null);const Q=q.attributes;if(!Q||Ui(q))return;Me=ra(ee.uponSanitizeAttribute,Me,Ut,Zn);const oe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Me,forceKeepAttr:void 0};let pe=Q.length;const ye=dt(q.nodeName);for(;pe--;){const xe=Q[pe],Xe=xe.name,lt=xe.namespaceURI,At=xe.value,ut=dt(Xe),Er=At;let vt=Xe==="value"?Er:x1(Er),Gn=!1;if(oe.attrName=ut,oe.attrValue=vt,oe.keepAttr=!0,oe.forceKeepAttr=void 0,kn(ee.uponSanitizeAttribute,q,oe),vt=oe.attrValue,Zr&&(ut==="id"||ut==="name")&&Mp(vt,pr)!==0&&(Wn(Xe,q,xe),vt=pr+vt,Gn=!0),en&&$t(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,vt)){Wn(Xe,q,xe);continue}if(ut==="attributename"&&Op(vt,"href")){Wn(Xe,q,xe);continue}if(!oe.forceKeepAttr){if(!oe.keepAttr){Wn(Xe,q,xe);continue}if(!mr&&$t(Y1,vt)){Wn(Xe,q,xe);continue}if(Wt&&(vt=Sr(vt)),!Pa(ye,ut,vt)){Wn(Xe,q,xe);continue}vt=es(ye,ut,lt,vt),vt!==Er&&ts(q,Xe,lt,vt)&&Gn&&zp(a.removed)}}kn(ee.afterSanitizeAttributes,q,null)},la=function(q){let Q=null;const oe=Zt(q);for(kn(ee.beforeSanitizeShadowDOM,q,null);Q=oe.nextNode();)if(kn(ee.uponSanitizeShadowNode,Q,null),Ya(Q,q),aa(Q),di(Q.content)&&la(Q.content),A(Q)===wn.element){const pe=k(Q);di(pe)&&($a(pe),la(pe))}kn(ee.afterSanitizeShadowDOM,q,null)},$a=function(q){const Q=[{node:q,shadow:null}];for(;Q.length>0;){const oe=Q.pop();if(oe.shadow){la(oe.shadow);continue}const pe=oe.node,xe=A(pe)===wn.element,Xe=S(pe);if(Xe)for(let lt=Xe.length-1;lt>=0;--lt)Q.push({node:Xe[lt],shadow:null});if(xe){const lt=N?N(pe):null;if(typeof lt=="string"&&dt(lt)==="template"){const At=pe.content;di(At)&&Q.push({node:At,shadow:null})}}if(xe){const lt=k(pe);di(lt)&&Q.push({node:null,shadow:lt},{node:lt,shadow:null})}}};return a.sanitize=function(de){let q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Q=null,oe=null,pe=null,ye=null;if(Fr=!de,Fr&&(de="<!-->"),typeof de!="string"&&!ei(de)&&(de=q1(de),typeof de!="string"))throw jr("dirty is not a string, aborting");if(!a.isSupported)return de;mn?(Ae=Xn,Me=Zn):Fn(q),(ee.uponSanitizeElement.length>0||ee.uponSanitizeAttribute.length>0)&&(Ae=Tn(Ae)),ee.uponSanitizeAttribute.length>0&&(Me=Tn(Me)),a.removed=[];const xe=Hn&&typeof de!="string"&&ei(de);if(xe){ia(de);const At=D(de);if(typeof At=="string"){const ut=dt(At);if(!Ae[ut]||Bt[ut])throw ta(de),jr("root node is forbidden and cannot be sanitized in-place")}if(Ui(de))throw ta(de),jr("root node is clobbered and cannot be sanitized in-place");try{$a(de)}catch(ut){throw ta(de),ut}}else if(ei(de))Q=Rn("<!---->"),oe=Q.ownerDocument.importNode(de,!0),oe.nodeType===wn.element&&oe.nodeName==="BODY"||oe.nodeName==="HTML"?Q=oe:Q.appendChild(oe),$a(Q);else{if(!mt&&!Wt&&!hn&&de.indexOf("<")===-1)return M&&wt?B(de):de;if(Q=Rn(de),!Q)return mt?null:wt?I:""}Q&&tn&&Yt(Q.firstChild);const Xe=xe?de:Q;try{const At=Zt(Xe);for(;pe=At.nextNode();)Ya(pe,Xe),aa(pe),di(pe.content)&&la(pe.content)}catch(At){throw xe&&(ta(de),Ir(a.removed,ut=>{ut.element&&na(ut.element)})),At}if(xe)return Ir(a.removed,At=>{At.element&&na(At.element)}),Wt&&Qa(de),de;if(mt){if(Wt&&Qa(Q),Xt)for(ye=K.call(Q.ownerDocument);Q.firstChild;)ye.appendChild(Q.firstChild);else ye=Q;return(Me.shadowroot||Me.shadowrootmode)&&(ye=ie.call(l,ye,!0)),ye}let lt=hn?Q.outerHTML:Q.innerHTML;return hn&&Ae["!doctype"]&&Q.ownerDocument&&Q.ownerDocument.doctype&&Q.ownerDocument.doctype.name&&$t(G1,Q.ownerDocument.doctype.name)&&(lt="<!DOCTYPE "+Q.ownerDocument.doctype.name+`>
59
59
  `+lt),Wt&&(lt=Sr(lt)),M&&wt?B(lt):lt},a.setConfig=function(){let de=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fn(de),mn=!0,Xn=Ae,Zn=Me},a.clearConfig=function(){ui=null,mn=!1,Xn=null,Zn=null,M=G,I=""},a.isValidAttribute=function(de,q,Q){ui||Fn({});const oe=dt(de),pe=dt(q);return Pa(oe,pe,Q)},a.addHook=function(de,q){typeof q=="function"&&fn(ee,de)&&Dl(ee[de],q)},a.removeHook=function(de,q){if(fn(ee,de)){if(q!==void 0){const Q=T1(ee[de],q);return Q===-1?void 0:A1(ee[de],Q,1)[0]}return zp(ee[de])}},a.removeHooks=function(de){fn(ee,de)&&(ee[de]=[])},a.removeAllHooks=function(){ee=Qp()},a}var ey=Wg();function _f(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var $r=_f();function ty(r){$r=r}var Vl={exec:()=>null};function Ze(r,a=""){let o=typeof r=="string"?r:r.source;const l={replace:(f,h)=>{let m=typeof h=="string"?h:h.source;return m=m.replace(Jt.caret,"$1"),o=o.replace(f,m),l},getRegex:()=>new RegExp(o,a)};return l}var Jt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i")},K1=/^(?:[ \t]*(?:\n|$))+/,J1=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,F1=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Xl=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,W1=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sf=/(?:[*+-]|\d{1,9}[.)])/,ny=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,iy=Ze(ny).replace(/bull/g,Sf).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),eS=Ze(ny).replace(/bull/g,Sf).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ef=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,tS=/^[^\n]+/,wf=/(?!\s*\])(?:\\.|[^\[\]\\])+/,nS=Ze(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",wf).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),iS=Ze(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sf).getRegex(),Ao="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Tf=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,rS=Ze("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Tf).replace("tag",Ao).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ry=Ze(Ef).replace("hr",Xl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ao).getRegex(),aS=Ze(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ry).getRegex(),Af={blockquote:aS,code:J1,def:nS,fences:F1,heading:W1,hr:Xl,html:rS,lheading:iy,list:iS,newline:K1,paragraph:ry,table:Vl,text:tS},Yp=Ze("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Xl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ao).getRegex(),lS={...Af,lheading:eS,table:Yp,paragraph:Ze(Ef).replace("hr",Xl).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Yp).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ao).getRegex()},sS={...Af,html:Ze(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Tf).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Vl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ze(Ef).replace("hr",Xl).replace("heading",` *#{1,6} *[^
60
60
  ]`).replace("lheading",iy).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},oS=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,uS=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ay=/^( {2,}|\\)\n(?!\s*$)/,cS=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,xo=/[\p{P}\p{S}]/u,xf=/[\s\p{P}\p{S}]/u,ly=/[^\s\p{P}\p{S}]/u,fS=Ze(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,xf).getRegex(),sy=/(?!~)[\p{P}\p{S}]/u,dS=/(?!~)[\s\p{P}\p{S}]/u,hS=/(?:[^\s\p{P}\p{S}]|~)/u,mS=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,oy=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,pS=Ze(oy,"u").replace(/punct/g,xo).getRegex(),gS=Ze(oy,"u").replace(/punct/g,sy).getRegex(),uy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",yS=Ze(uy,"gu").replace(/notPunctSpace/g,ly).replace(/punctSpace/g,xf).replace(/punct/g,xo).getRegex(),bS=Ze(uy,"gu").replace(/notPunctSpace/g,hS).replace(/punctSpace/g,dS).replace(/punct/g,sy).getRegex(),vS=Ze("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ly).replace(/punctSpace/g,xf).replace(/punct/g,xo).getRegex(),_S=Ze(/\\(punct)/,"gu").replace(/punct/g,xo).getRegex(),SS=Ze(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ES=Ze(Tf).replace("(?:-->|$)","-->").getRegex(),wS=Ze("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ES).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),vo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,TS=Ze(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",vo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),cy=Ze(/^!?\[(label)\]\[(ref)\]/).replace("label",vo).replace("ref",wf).getRegex(),fy=Ze(/^!?\[(ref)\](?:\[\])?/).replace("ref",wf).getRegex(),AS=Ze("reflink|nolink(?!\\()","g").replace("reflink",cy).replace("nolink",fy).getRegex(),Cf={_backpedal:Vl,anyPunctuation:_S,autolink:SS,blockSkip:mS,br:ay,code:uS,del:Vl,emStrongLDelim:pS,emStrongRDelimAst:yS,emStrongRDelimUnd:vS,escape:oS,link:TS,nolink:fy,punctuation:fS,reflink:cy,reflinkSearch:AS,tag:wS,text:cS,url:Vl},xS={...Cf,link:Ze(/^!?\[(label)\]\((.*?)\)/).replace("label",vo).getRegex(),reflink:Ze(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",vo).getRegex()},ef={...Cf,emStrongRDelimAst:bS,emStrongLDelim:gS,url:Ze(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},CS={...ef,br:Ze(ay).replace("{2,}","*").getRegex(),text:Ze(ef.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},po={normal:Af,gfm:lS,pedantic:sS},Bl={normal:Cf,gfm:ef,breaks:CS,pedantic:xS},RS={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Pp=r=>RS[r];function li(r,a){if(a){if(Jt.escapeTest.test(r))return r.replace(Jt.escapeReplace,Pp)}else if(Jt.escapeTestNoEncode.test(r))return r.replace(Jt.escapeReplaceNoEncode,Pp);return r}function $p(r){try{r=encodeURI(r).replace(Jt.percentDecode,"%")}catch{return null}return r}function Xp(r,a){var h;const o=r.replace(Jt.findPipe,(m,d,p)=>{let c=!1,g=d;for(;--g>=0&&p[g]==="\\";)c=!c;return c?"|":" |"}),l=o.split(Jt.splitPipe);let f=0;if(l[0].trim()||l.shift(),l.length>0&&!((h=l.at(-1))!=null&&h.trim())&&l.pop(),a)if(l.length>a)l.splice(a);else for(;l.length<a;)l.push("");for(;f<l.length;f++)l[f]=l[f].trim().replace(Jt.slashPipe,"|");return l}function Hl(r,a,o){const l=r.length;if(l===0)return"";let f=0;for(;f<l&&r.charAt(l-f-1)===a;)f++;return r.slice(0,l-f)}function kS(r,a){if(r.indexOf(a[1])===-1)return-1;let o=0;for(let l=0;l<r.length;l++)if(r[l]==="\\")l++;else if(r[l]===a[0])o++;else if(r[l]===a[1]&&(o--,o<0))return l;return o>0?-2:-1}function Zp(r,a,o,l,f){const h=a.href,m=a.title||null,d=r[1].replace(f.other.outputLinkReplace,"$1");l.state.inLink=!0;const p={type:r[0].charAt(0)==="!"?"image":"link",raw:o,href:h,title:m,text:d,tokens:l.inlineTokens(d)};return l.state.inLink=!1,p}function NS(r,a,o){const l=r.match(o.other.indentCodeCompensation);if(l===null)return a;const f=l[1];return a.split(`
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '2.16.0';
3
+ exports.default = '2.16.1';
@@ -1 +1 @@
1
- export default '2.16.0';
1
+ export default '2.16.1';
@@ -1,2 +1,2 @@
1
- declare const _default: "2.16.0";
1
+ declare const _default: "2.16.1";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-pia",
3
- "version": "2.16.0",
3
+ "version": "2.16.1",
4
4
  "description": "Constructor.io AI Product Insights Agent UI library for web applications",
5
5
  "author": "Constructor.io Corporation",
6
6
  "license": "MIT",
@@ -36,10 +36,12 @@
36
36
  "require": "./dist/constructorio-ui-pia-bundled.js"
37
37
  },
38
38
  ".": {
39
+ "types": "./lib/types/index.d.ts",
39
40
  "import": "./lib/mjs/index.js",
40
41
  "require": "./lib/cjs/index.js"
41
42
  },
42
43
  "./cjs": {
44
+ "types": "./lib/types/index.d.ts",
43
45
  "import": "./lib/cjs/index.js",
44
46
  "require": "./lib/cjs/index.js"
45
47
  }