@nexlylab/widget 1.32.18 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/INSTALL.txt +1 -1
- package/dist/runtime/{1.32.18/chunks/ClickToLoadEmbed-BLIUFZOn-BwY-LAJ8.js → 1.33.0/chunks/ClickToLoadEmbed-DdH19Upf-CnpjmfE1.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/PanelInfoVideo-BNVzih9J-BrU-Qlul.js → 1.33.0/chunks/PanelInfoVideo-XFcVoL2c-qpxDXdLm.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/allowed-elements-BXnLJV1S-C-_lr2zm.js → 1.33.0/chunks/allowed-elements-C0OfX2zF-DIBV8lKu.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/assistant-link-components-DUrLEPUB-DKaQavIJ.js → 1.33.0/chunks/assistant-link-components-gMuMhmaU-rHpeX4O6.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/assistant-link-policy-DHB-k1Aa-Cc-yj-a-.js → 1.33.0/chunks/assistant-link-policy-DlGAtyk7-By6jpR50.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/block-rating-D7hR2gTc-CoiP5C2K.js → 1.33.0/chunks/block-rating-CAVRRYuG-CQMNokIy.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/external-url-qbs1SznX-CJQjg_od.js → 1.33.0/chunks/external-url-JbUnX7Da-rLiy7c9v.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index--xfG4CIn-DbuSZfeK.js → 1.33.0/chunks/index--H6hRpBJ-F9_TzvkO.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BIGVEl9--CSQQTbsg.js → 1.33.0/chunks/index--pcCOJWb-BzpgdoE8.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-7N5M1HdS-DAdxCQyi.js → 1.33.0/chunks/index-7yhyghzH-BlFXtfQb.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CF37rhgu-BcW8HKb8.js → 1.33.0/chunks/index-BCxeWwto-B9PuY2Gx.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BKZyJMr2-oy07dUaV.js → 1.33.0/chunks/index-BO0vI80C-qK4w7DnX.js} +4 -4
- package/dist/runtime/{1.32.18/chunks/index-99heIIoH-QeFj7CR9.js → 1.33.0/chunks/index-BP1Q45X4-f3F4IxQ5.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DAICBUgn-DBhSkJ7i.js → 1.33.0/chunks/index-BPfUysTZ-CV5ZiVsD.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-Ce9TuEzb-C3bBvEcm.js → 1.33.0/chunks/index-BWY1nqf0-DX50C5MZ.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-COfQIa8G-D6wzHiS0.js → 1.33.0/chunks/index-BblCrrAW-bh6F7tw3.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BX6ig9BJ-Dsa9X9U7.js → 1.33.0/chunks/index-Bd_8PmPr-CgO1smBF.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-D96sEJQ6-Dp5AxBD4.js → 1.33.0/chunks/index-BjHXOMPQ-Bt7j8evJ.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BKrM_uoq-CABL-0v-.js → 1.33.0/chunks/index-BwnCq3yC-LScXPMbE.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-kAGaGinD-Dm9kbc85.js → 1.33.0/chunks/index-BzVJMW3i-Bhh8_8Oh.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-B3DeMFo7-BbdAbuAw.js → 1.33.0/chunks/index-CDlumsdH-BgpZz7kC.js} +3 -3
- package/dist/runtime/{1.32.18/chunks/index-CYeJYTiB-BLxOZxZv.js → 1.33.0/chunks/index-CH-C6uk_-B-pT4hKt.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CV2tGt-4-C9wFr7fa.js → 1.33.0/chunks/index-CNP-4dFm-BlRhWcs1.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-E59S8-Gw-CovGUxIZ.js → 1.33.0/chunks/index-CNbQ508J-BPOHZMXu.js} +4 -4
- package/dist/runtime/{1.32.18/chunks/index-BtkNePSj-CiRb-0NX.js → 1.33.0/chunks/index-CPGSyaZ4-BoVmvEOm.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-Dw7QeZq3-Dr1V6OGz.js → 1.33.0/chunks/index-CVtuVQCx-Dtq7n928.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CCEWGjHV-BTsOZg4v.js → 1.33.0/chunks/index-CYP-tLa5-DLVDVk-F.js} +4 -4
- package/dist/runtime/{1.32.18/chunks/index-COTfVuju-DQBGsPwB.js → 1.33.0/chunks/index-CZCcZigQ-qH_mrcVT.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-Cd1-jHFp-Za3SKEQp.js → 1.33.0/chunks/index-CZSW9eXg-BwcGrX1b.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-OcrS6o5Y-bdo5pwX-.js → 1.33.0/chunks/index-Cfy6Ocqe-CzwqZYRk.js} +2 -2
- package/dist/runtime/1.33.0/chunks/index-Ci7P37Ya-W5nof5Mx.js +6 -0
- package/dist/runtime/{1.32.18/chunks/index-l8Oxwea3-Aqz1AnQ5.js → 1.33.0/chunks/index-CmM1q2bg-D6H0juMn.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CSRoJRaW-CoI3p0S7.js → 1.33.0/chunks/index-CnknkPUN-Yl3jEGAx.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-qN6oEHVu-C_0Ll4qr.js → 1.33.0/chunks/index-D9fi5TQ9-k8zxZkfU.js} +2 -2
- package/dist/runtime/1.33.0/chunks/index-DG6McKPZ-CqZ9_vG_.js +2 -0
- package/dist/runtime/{1.32.18/chunks/index-PxSB6BA6-DFxY6dqO.js → 1.33.0/chunks/index-DOJHU9qy-Bil-vDLm.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DiZcd1hz-H31PHMqm.js → 1.33.0/chunks/index-DTa1aDGz-Deg8QEW2.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DATkkw3P-VhJcCfAC.js → 1.33.0/chunks/index-DUV1wU5j-ErDxRmJu.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-oxM4Cgtc-R_xuAEQV.js → 1.33.0/chunks/index-DZNxd978-BmIQ-NmU.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BZO9Qaiw-DP0QKkgf.js → 1.33.0/chunks/index-DsyaMk1k-DpMzyqHN.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DuPFNKhZ-_M0CWPEY.js → 1.33.0/chunks/index-HIu_g6Cr-CEIHlemy.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-cCAzBYyN-W1lJrIDD.js → 1.33.0/chunks/index-NPLN6oCC-VW9D8cgC.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-C5RVj6y1-DUgMllqN.js → 1.33.0/chunks/index-S2W2KqpV-PMvqlUvO.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-D1YmJ3gf-3B-eE3K7.js → 1.33.0/chunks/index-SV2KdT0_-BZw4n83V.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-Bf_npmqm-C1BzRUwZ.js → 1.33.0/chunks/index-qzvjftnO-CDVtcfdt.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DaW9uf4--pkywvGDF.js → 1.33.0/chunks/index-s0zHGN1t-DWm0RYZF.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-C1Fa-E3e-ZRnEJoQe.js → 1.33.0/chunks/index-uYSCRIpT-qsVnaLmo.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BauMKr5c-BpgnWlB8.js → 1.33.0/chunks/index-v9CNsbwM-CavFmRiD.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CZ-JrY2X-TEMHje2B.js → 1.33.0/chunks/index-xQDKGkvA-pCzSL4DD.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index.modern-CioVZ357-BA5NTOmY.js → 1.33.0/chunks/index.modern-CioVZ357-nfRNslCS.js} +2 -2
- package/dist/runtime/1.33.0/nexly.js +61 -0
- package/dist/v1.js +1 -1
- package/package.json +1 -1
- package/dist/runtime/1.32.18/chunks/index-rblri-2U-I68tb-d3.js +0 -2
- package/dist/runtime/1.32.18/chunks/index-xx1GG5d1-CW29F9vY.js +0 -6
- package/dist/runtime/1.32.18/nexly.js +0 -61
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/PanelVideoOverlay-BY__oBYV-B8OPC1xh.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/_commonjsHelpers-C6fGbg64-BC8KDfbh.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/accent-legibility-BJF2VO5n-CDPQ7suO.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/block-helpers-Cg_zAqG6-DnN2COvk.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/index-BPDIV1BN-DINkyYvc.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/index-BcsmWDTX-Dw9WA5Ac.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/index-C262wwK4-DpyhuXqd.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/index-DMQkz1bV-BuMYksln.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/index-DZADUAKv-DPfvWVuj.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/inert-assistant-components-B6Cx9pG5-DWb6n3Yq.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.33.0}/chunks/use-deferred-rating-XlgCUwcY-DDVOwURi.js +0 -0
package/dist/INSTALL.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Wklej przed </body>:
|
|
2
2
|
|
|
3
|
-
<script src="https://cdn.jsdelivr.net/npm/@nexlylab/widget@1.
|
|
3
|
+
<script src="https://cdn.jsdelivr.net/npm/@nexlylab/widget@1.33.0/dist/v1.js" data-api-key="pk_live_TWOJ_KLUCZ" defer></script>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=ClickToLoadEmbed-
|
|
1
|
+
import{Z as v,r as y,j as i}from"../nexly.js";import{L as $,N as j,l as N}from"./allowed-elements-C0OfX2zF-DIBV8lKu.js";import{a as m}from"./assistant-link-policy-DlGAtyk7-By6jpR50.js";const k=["youtube.com","youtube-nocookie.com"],B=["youtu.be"],E=["vimeo.com"],f=/^[A-Za-z0-9_-]{6,32}$/,P=/^\d{6,12}$/;function S(n){return f.test(n)}const _=4;function w(n){const[t,e]=v(()=>new URL(n));return e||!t?null:t}function b(n,t){if(t){const r=n.pathname.split("/").filter(Boolean);if(r.length!==1)return null;const o=r[0];return f.test(o)?o:null}const e=n.pathname.split("/").filter(Boolean);if(e[0]==="watch"){const r=n.searchParams.get("v");return r&&f.test(r)?r:null}if(e[0]==="embed"||e[0]==="shorts"||e[0]==="v"){if(e.length!==2)return null;const r=e[1];return f.test(r)?r:null}return null}function z(n){const t=n.pathname.split("/").filter(Boolean),e=t[0]==="video"?t[1]:t[0];if(!e)return null;const r=t[0]==="video"?2:1;return t.length!==r?null:P.test(e)?e:null}function C(n){const t=w(n);if(!t||t.protocol!=="https:")return null;const e=t.hostname;if(m(e,B)){const r=b(t,!0);return r?{provider:"youtube",id:r}:null}if(m(e,k)){const r=b(t,!1);return r?{provider:"youtube",id:r}:null}if(m(e,E)){const r=z(t);return r?{provider:"vimeo",id:r}:null}return null}const F=/\.(png|jpe?g|gif|webp|avif|svg)$/i,L=/[;?#]|[\u0000-\u001F\u007F]/,R=5;function U(n){let t=n;for(let e=0;e<R;e++){if(!t.includes("%"))return t;const[r,o]=v(()=>decodeURIComponent(t));if(o||r===void 0)return null;if(r===t)return t;t=r}return null}function Z(n,t){if(t.length===0)return null;const e=w(n);if(!e||e.protocol!=="https:"||!m(e.hostname,t)||e.search)return null;const r=U(e.pathname);return r===null||L.test(r)||!F.test(r)?null:(e.username="",e.password="",e.href)}function*x(n){if(n.children)for(const t of n.children)yield t,yield*x(t)}function O(n,t={}){const e=t.allowEmbeds===!0,r=t.allowedImageHosts??[],o={embeds:[],images:[]};if(!n||!e&&r.length===0)return o;const[p,h]=v(()=>$().use(j).use(N).parse(n));if(h||!p)return o;const c=[],s=[],d=new Set,a=new Set;for(const u of x(p)){if(e&&u.type==="link"&&c.length<_){const l=u.url?C(u.url):null;if(l){const g=`${l.provider}:${l.id}`;d.has(g)||(d.add(g),c.push(l))}continue}if(u.type==="image"&&s.length<_){const l=u.url?Z(u.url,r):null;l&&!a.has(l)&&(a.add(l),s.push({src:l,alt:(u.alt??"").trim()}))}}return{embeds:c,images:s}}const H={youtube:"support_chat.media_provider_youtube",vimeo:"support_chat.media_provider_vimeo"};function I(n){return n.provider==="youtube"?S(n.id)?`https://www.youtube-nocookie.com/embed/${n.id}`:null:`https://player.vimeo.com/video/${n.id}`}function T({embed:n,t,classPrefix:e,posterUrl:r=null}){const[o,p]=y.useState(!1),[h,c]=y.useState(!1),s=t(H[n.provider]),d=I(n);if(!d)return null;if(o)return i.jsx("div",{className:`${e}__media-frame`,children:i.jsx("iframe",{src:d,title:t("support_chat.media_player_title",{provider:s}),sandbox:"allow-scripts allow-same-origin allow-presentation",referrerPolicy:"strict-origin-when-cross-origin",allow:"accelerometer; encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,loading:"lazy"})});const a=h?null:r;return i.jsxs("button",{type:"button",className:`${e}__media-tile${a?` ${e}__media-tile--poster`:""}`,onClick:()=>p(!0),"aria-label":t("support_chat.media_play_video",{provider:s}),children:[a&&i.jsx("img",{className:`${e}__media-poster`,src:a,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",onError:()=>c(!0)}),i.jsx("span",{className:`${e}__media-play`,"aria-hidden":"true",children:i.jsx("svg",{viewBox:"0 0 24 24",width:"24",height:"24",fill:"currentColor",children:i.jsx("path",{d:"M8 5v14l11-7z"})})}),i.jsx("span",{className:`${e}__media-tile-label`,children:s})]})}export{S as F,T as X,O as j};
|
|
2
|
+
//# sourceMappingURL=ClickToLoadEmbed-DdH19Upf-CnpjmfE1.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/PanelVideoOverlay-BY__oBYV-B8OPC1xh.js","nexly.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as o,j as n,_ as v,
|
|
3
|
-
//# sourceMappingURL=PanelInfoVideo-
|
|
2
|
+
import{r as o,j as n,_ as v,K as d}from"../nexly.js";function _(e,r,a){const[i,t]=o.useState(null);return o.useEffect(()=>{if(!a)return;let l=!1;async function s(){const[u,c]=await d(()=>fetch(`${r}/api/widget/panel-video?panel=${e}`,{headers:{"X-API-Key":a}}));if(l||c||!u.ok)return;const[p,f]=await d(()=>u.json());l||f||t(p)}return s(),()=>{l=!0}},[e,r,a]),i}const b=o.lazy(()=>v(()=>import("./PanelVideoOverlay-BY__oBYV-B8OPC1xh.js"),__vite__mapDeps([0,1])).then(e=>({default:e.PanelVideoOverlay})));function x({panelKey:e,baseUrl:r,apiKey:a,t:i}){const t=_(e,r,a),[l,s]=o.useState(!1);if(!t?.enabled||!t.videoUrl)return null;const u=t.videoUrl,c=t.contentType??"video/mp4";return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"es-panel-video-btn","aria-label":i("panel_video.info_button"),title:i("panel_video.info_button"),onClick:()=>s(!0),"data-testid":"panel-video-info-button",children:n.jsx("span",{"aria-hidden":"true",children:"i"})}),l&&n.jsx(o.Suspense,{fallback:null,children:n.jsx(b,{videoUrl:u,contentType:c,onClose:()=>s(!1),t:i})})]})}export{x as j};
|
|
3
|
+
//# sourceMappingURL=PanelInfoVideo-XFcVoL2c-qpxDXdLm.js.map
|
|
@@ -24,5 +24,5 @@ import{M as Le}from"../nexly.js";import{e as Ne}from"./_commonjsHelpers-C6fGbg64
|
|
|
24
24
|
`)&&c.type==="html"&&(o[o.length-1]=o[o.length-1].replace(/(\r?\n|\r)$/," "),u=" ",s=t.createTracker(n),s.move(o.join(""))),o.push(s.move(t.handle(c,e,t,{...s.current(),before:u,after:f}))),u=o[o.length-1].slice(-1)}return r.pop(),o.join("")}const ss=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Nr.peek=hs;const cs={canContainEols:["delete"],enter:{strikethrough:ps},exit:{strikethrough:ds}},fs={unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:ss}],handlers:{delete:Nr}};function ps(e){this.enter({type:"delete",children:[]},e)}function ds(e){this.exit(e)}function Nr(e,t,n,r){const i=tt(r),o=n.enter("strikethrough");let l=i.move("~~");return l+=Br(e,n,{...i.current(),before:l,after:"~"}),l+=i.move("~~"),o(),l}function hs(){return"~"}Hr.peek=gs;function Hr(e,t,n){let r=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const l=n.unsafe[o],u=Rr(l);let s;if(l.atBreak)for(;s=u.exec(r);){let c=s.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(s.index+1)}}return i+r+i}function gs(){return"`"}function ms(e){return e.length}function ys(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||ms,o=[],l=[],u=[],s=[];let c=0,f=-1;for(;++f<e.length;){const m=[],y=[];let k=-1;for(e[f].length>c&&(c=e[f].length);++k<e[f].length;){const F=ks(e[f][k]);if(n.alignDelimiters!==!1){const C=i(F);y[k]=C,(s[k]===void 0||C>s[k])&&(s[k]=C)}m.push(F)}l[f]=m,u[f]=y}let a=-1;if(typeof r=="object"&&"length"in r)for(;++a<c;)o[a]=Un(r[a]);else{const m=Un(r);for(;++a<c;)o[a]=m}a=-1;const d=[],p=[];for(;++a<c;){const m=o[a];let y="",k="";m===99?(y=":",k=":"):m===108?y=":":m===114&&(k=":");let F=n.alignDelimiters===!1?1:Math.max(1,s[a]-y.length-k.length);const C=y+"-".repeat(F)+k;n.alignDelimiters!==!1&&(F=y.length+F+k.length,F>s[a]&&(s[a]=F),p[a]=F),d[a]=C}l.splice(1,0,d),u.splice(1,0,p),f=-1;const x=[];for(;++f<l.length;){const m=l[f],y=u[f];a=-1;const k=[];for(;++a<c;){const F=m[a]||"";let C="",P="";if(n.alignDelimiters!==!1){const I=s[a]-(y[a]||0),b=o[a];b===114?C=" ".repeat(I):b===99?I%2?(C=" ".repeat(I/2+.5),P=" ".repeat(I/2-.5)):(C=" ".repeat(I/2),P=C):P=" ".repeat(I)}n.delimiterStart!==!1&&!a&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&F==="")&&(n.delimiterStart!==!1||a)&&k.push(" "),n.alignDelimiters!==!1&&k.push(C),k.push(F),n.alignDelimiters!==!1&&k.push(P),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||a!==c-1)&&k.push("|")}x.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return x.join(`
|
|
25
25
|
`)}function ks(e){return e==null?"":String(e)}function Un(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}const xs={enter:{table:bs,tableData:Vn,tableHeader:Vn,tableRow:ws},exit:{codeText:Cs,table:vs,tableData:wt,tableHeader:wt,tableRow:wt}};function bs(e){const t=e._align;this.enter({type:"table",align:t.map(n=>n==="none"?null:n),children:[]},e),this.setData("inTable",!0)}function vs(e){this.exit(e),this.setData("inTable")}function ws(e){this.enter({type:"tableRow",children:[]},e)}function wt(e){this.exit(e)}function Vn(e){this.enter({type:"tableCell",children:[]},e)}function Cs(e){let t=this.resume();this.getData("inTable")&&(t=t.replace(/\\([\\|])/g,Ss));const n=this.stack[this.stack.length-1];n.value=t,this.exit(e)}function Ss(e,t){return t==="|"?t:e}function Fs(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
26
26
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{table:l,tableRow:u,tableCell:s,inlineCode:d}};function l(p,x,m,y){return c(f(p,m,y),p.align)}function u(p,x,m,y){const k=a(p,m,y),F=c([k]);return F.slice(0,F.indexOf(`
|
|
27
|
-
`))}function s(p,x,m,y){const k=m.enter("tableCell"),F=m.enter("phrasing"),C=Br(p,m,{...y,before:o,after:o});return F(),k(),C}function c(p,x){return ys(p,{align:x,alignDelimiters:r,padding:n,stringLength:i})}function f(p,x,m){const y=p.children;let k=-1;const F=[],C=x.enter("table");for(;++k<y.length;)F[k]=a(y[k],x,m);return C(),F}function a(p,x,m){const y=p.children;let k=-1;const F=[],C=x.enter("tableRow");for(;++k<y.length;)F[k]=s(y[k],p,x,m);return C(),F}function d(p,x,m){let y=Hr(p,x,m);return m.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function As(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Es(e){const t=e.options.listItemIndent||"tab";if(t===1||t==="1")return"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ds(e,t,n,r){const i=Es(n);let o=n.bulletCurrent||As(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let l=o.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(l=Math.ceil(l/4)*4);const u=n.createTracker(r);u.move(o+" ".repeat(l-o.length)),u.shift(l);const s=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,u.current()),f);return s(),c;function f(a,d,p){return d?(p?"":" ".repeat(l))+a:(p?o:o+" ".repeat(l-o.length))+a}}const Ts={exit:{taskListCheckValueChecked:qn,taskListCheckValueUnchecked:qn,paragraph:Ls}},Os={unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Ps}};function qn(e){const t=this.stack[this.stack.length-2];t.checked=e.type==="taskListCheckValueChecked"}function Ls(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1],r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,l;for(;++o<i.length;){const u=i[o];if(u.type==="paragraph"){l=u;break}}l===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Ps(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",u=tt(r);o&&u.move(l);let s=Ds(e,t,n,{...r,...u.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),s;function c(f){return f+l}}function Is(){return[Pa,Ka(),cs,xs,Ts]}function zs(e){return{extensions:[Ia,Za(),fs,Fs(e),Os]}}function Ms(e={}){const t=this.data();n("micromarkExtensions",Ea(e)),n("fromMarkdownExtensions",Is()),n("toMarkdownExtensions",zs(e));function n(r,i){(t[r]?t[r]:t[r]=[]).push(i)}}const Bs=["p","br","strong","em","del","a","code","pre","ul","ol","li","input","h1","h2","h3","h4","h5","h6","blockquote","hr","table","thead","tbody","tr","th","td"],Ns=[Ms];export{mo as L,vl as N,_s as a,Ns as c,Ms as l,Bs as s,Xu as x};
|
|
28
|
-
//# sourceMappingURL=allowed-elements-
|
|
27
|
+
`))}function s(p,x,m,y){const k=m.enter("tableCell"),F=m.enter("phrasing"),C=Br(p,m,{...y,before:o,after:o});return F(),k(),C}function c(p,x){return ys(p,{align:x,alignDelimiters:r,padding:n,stringLength:i})}function f(p,x,m){const y=p.children;let k=-1;const F=[],C=x.enter("table");for(;++k<y.length;)F[k]=a(y[k],x,m);return C(),F}function a(p,x,m){const y=p.children;let k=-1;const F=[],C=x.enter("tableRow");for(;++k<y.length;)F[k]=s(y[k],p,x,m);return C(),F}function d(p,x,m){let y=Hr(p,x,m);return m.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function As(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Es(e){const t=e.options.listItemIndent||"tab";if(t===1||t==="1")return"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ds(e,t,n,r){const i=Es(n);let o=n.bulletCurrent||As(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let l=o.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(l=Math.ceil(l/4)*4);const u=n.createTracker(r);u.move(o+" ".repeat(l-o.length)),u.shift(l);const s=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,u.current()),f);return s(),c;function f(a,d,p){return d?(p?"":" ".repeat(l))+a:(p?o:o+" ".repeat(l-o.length))+a}}const Ts={exit:{taskListCheckValueChecked:qn,taskListCheckValueUnchecked:qn,paragraph:Ls}},Os={unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Ps}};function qn(e){const t=this.stack[this.stack.length-2];t.checked=e.type==="taskListCheckValueChecked"}function Ls(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1],r=n.children[0];if(r&&r.type==="text"){const i=t.children;let o=-1,l;for(;++o<i.length;){const u=i[o];if(u.type==="paragraph"){l=u;break}}l===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Ps(e,t,n,r){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",l="["+(e.checked?"x":" ")+"] ",u=tt(r);o&&u.move(l);let s=Ds(e,t,n,{...r,...u.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),s;function c(f){return f+l}}function Is(){return[Pa,Ka(),cs,xs,Ts]}function zs(e){return{extensions:[Ia,Za(),fs,Fs(e),Os]}}function Ms(e={}){const t=this.data();n("micromarkExtensions",Ea(e)),n("fromMarkdownExtensions",Is()),n("toMarkdownExtensions",zs(e));function n(r,i){(t[r]?t[r]:t[r]=[]).push(i)}}const Bs=["p","br","strong","em","del","a","code","pre","ul","ol","li","input","h1","h2","h3","h4","h5","h6","blockquote","hr","table","thead","tbody","tr","th","td"],Ns=[Ms],Hs=[];export{mo as L,vl as N,_s as a,Ns as c,Hs as f,Ms as l,Bs as s,Xu as x};
|
|
28
|
+
//# sourceMappingURL=allowed-elements-C0OfX2zF-DIBV8lKu.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as r}from"../nexly.js";import{u as s}from"./assistant-link-policy-
|
|
2
|
-
//# sourceMappingURL=assistant-link-components-
|
|
1
|
+
import{j as r}from"../nexly.js";import{u as s}from"./assistant-link-policy-DlGAtyk7-By6jpR50.js";function c(o={}){const n=o.allowedHosts??[];return{a:({href:e,title:l,children:t})=>{const i=r.jsx(r.Fragment,{children:t});return s(e,n)?r.jsx("a",{href:e,title:l,target:"_blank",rel:"noopener noreferrer nofollow",children:t}):i}}}export{c as f};
|
|
2
|
+
//# sourceMappingURL=assistant-link-components-gMuMhmaU-rHpeX4O6.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=assistant-link-policy-
|
|
1
|
+
import{Z as l}from"../nexly.js";function i(r){const e=r.trim().toLowerCase().replace(/^\.+|\.+$/g,"");return e==="*"?"":e}function a(r,e){const t=r.trim().toLowerCase().replace(/\.$/,"");if(!t)return!1;for(const s of e){const n=i(s);if(n&&(t===n||t.endsWith(`.${n}`)))return!0}return!1}function u(r,e){if(!r||e.length===0)return!1;const[t,s]=l(()=>new URL(r));if(s||!t)return!1;if(t.protocol==="http:"||t.protocol==="https:")return a(t.hostname,e);if(t.protocol==="mailto:"){const n=t.pathname.split(",").map(o=>o.trim()).filter(Boolean);return n.length===0?!1:n.every(o=>{const f=o.lastIndexOf("@");return f===-1?!1:a(o.slice(f+1),e)})}return!1}export{a,u};
|
|
2
|
+
//# sourceMappingURL=assistant-link-policy-DlGAtyk7-By6jpR50.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r,j as a,b as X}from"../nexly.js";const de=240,R=30,ue=n=>n<=3?"low":"high",pe=n=>`block_feedback.chip.${n}`;Object.fromEntries([{key:"numbers_wrong",labelEn:"The numbers look wrong"},{key:"too_generic",labelEn:"Too generic"},{key:"hard_to_understand",labelEn:"Hard to understand"},{key:"not_relevant",labelEn:"Not relevant to me"},{key:"accurate",labelEn:"Accurate numbers"},{key:"clear",labelEn:"Clear and easy to follow"},{key:"actionable",labelEn:"I know what to do next"},{key:"saves_time",labelEn:"Saves me time"},{key:"not_my_situation",labelEn:"Doesn't fit my situation"},{key:"where_to_start",labelEn:"Don't know where to start"},{key:"concrete_steps",labelEn:"Concrete steps"},{key:"matches_my_data",labelEn:"Matches my data"},{key:"motivating",labelEn:"Motivates me to act"},{key:"data_stale",labelEn:"Data looks outdated"},{key:"dashboard_mismatch",labelEn:"Differs from my dashboard"},{key:"threshold_unclear",labelEn:"The threshold isn't clear"},{key:"no_next_step",labelEn:"No hint what to do next"},{key:"warned_in_time",labelEn:"Warned me in time"},{key:"clear_threshold",labelEn:"Clear threshold and deadline"},{key:"branch_detail",labelEn:"Not enough branch detail"},{key:"how_to_use",labelEn:"Not sure how to use this"},{key:"comparison_weak",labelEn:"Comparison not helpful"},{key:"see_growth",labelEn:"I can see where my team grows"},{key:"recognize_team",labelEn:"Helps me recognize my team"},{key:"week_over_week",labelEn:"Useful week-over-week view"},{key:"payout_mismatch",labelEn:"Doesn't match my payout"},{key:"assumptions_unclear",labelEn:"Assumptions aren't clear"},{key:"no_what_if",labelEn:"No what-if scenarios"},{key:"currency_unclear",labelEn:"Currency or rate unclear"},{key:"matches_payout",labelEn:"Matches my payout"},{key:"helps_planning",labelEn:"Helps me plan the cycle"},{key:"too_late",labelEn:"Came too late"},{key:"no_context",labelEn:"Not enough context"},{key:"other_topics",labelEn:"I'd prefer other topics"},{key:"spot_on",labelEn:"Spot-on topic"},{key:"learned",labelEn:"I learned something"},{key:"on_time",labelEn:"Right on time"},{key:"want_to_join",labelEn:"Makes me want to join in"},{key:"needs_example",labelEn:"No example"},{key:"too_long",labelEn:"Too long"},{key:"bad_formatting",labelEn:"Badly formatted"},{key:"good_example",labelEn:"Good example"}].map(n=>[n.key,n]));const he={low:["numbers_wrong","too_generic","hard_to_understand","not_relevant"],high:["accurate","clear","actionable","saves_time"]},q={low:["payout_mismatch","assumptions_unclear","no_what_if","currency_unclear"],high:["matches_payout","helps_planning","clear","accurate"]},be={"daily-action-plan":{low:["not_my_situation","numbers_wrong","too_generic","where_to_start"],high:["concrete_steps","matches_my_data","saves_time","motivating"]},"rank-advancement-roadmap":{low:["data_stale","dashboard_mismatch","threshold_unclear","no_next_step"],high:["warned_in_time","clear_threshold","actionable","accurate"]},"network-growth":{low:["branch_detail","data_stale","how_to_use","comparison_weak"],high:["see_growth","recognize_team","week_over_week","motivating"]},"mlm-calculator":q,"commission-forecast":q,"social-insights":{low:["not_relevant","too_late","no_context","other_topics"],high:["spot_on","learned","on_time","want_to_join"]},learning:{low:["hard_to_understand","needs_example","too_long","bad_formatting"],high:["clear","good_example","learned","actionable"]}};function me(n,o){return(be[n]??he)[ue(o)]}function Q(n){const o=n.trim().match(/\S+/g);return o?o.length:0}const ye=[1,2,3,4,5],M=96,_e=20;function fe(n){let o=n.slice(0,de);if(Q(o)>R){let c=0,d=0,p=!1;for(;d<o.length;){const _=/\s/.test(o.charAt(d));if(!_&&!p&&(c++,p=!0,c>R))break;_&&(p=!1),d++}o=o.slice(0,d).trimEnd()}return o}function ge({promptLogId:n,blockSlug:o,sectionKey:c,subjectType:d,subjectId:p,ariaKey:_,onRated:Z,onFeedbackCycleDone:z,settleInPlace:v=!1,baseUrl:H,apiKey:F,jwt:K,t:l,promptKey:ee,compact:s=!1,className:te,previewMode:L=!1}){const[m,E]=r.useState(null),[ae,j]=r.useState(!1),[$,S]=r.useState(null),[f,k]=r.useState("none"),i=f==="settled",[g,A]=r.useState([]),[C,O]=r.useState(""),[oe,B]=r.useState(!1),N=r.useRef(null),T=r.useRef(z);T.current=z;const w=r.useRef(!1),P=r.useRef(!1);r.useEffect(()=>()=>{P.current&&!w.current&&(w.current=!0,T.current?.())},[]),r.useEffect(()=>{if(!(f!=="done"||v))return N.current=setTimeout(()=>{E(null),S(null),A([]),O(""),k("none"),w.current||(w.current=!0,T.current?.())},2500),()=>{N.current&&clearTimeout(N.current)}},[f,v]);const h=n?"ai":o?"block":null;if(!h||!K)return null;const ne=ee??(s?"block_rating.prompt_section":"block_rating.prompt"),u=m!==null||ae,W=m??0,re=!u&&$!==null?$:W,U=s?15:18,J=d&&p?{subjectType:d,subjectId:p}:{},Y={"Content-Type":"application/json",...F?{"X-API-Key":F}:{},Authorization:`Bearer ${K}`},le=async e=>{if(u)return;if(L){E(e),k(h==="block"?"chips":"done");return}j(!0);const t=h==="ai"?"/api/widget/ai-feedback":"/api/widget/block-feedback",b=h==="ai"?{promptLogId:n,rating:e}:{blockSlug:o,rating:e,...c?{sectionKey:c}:{},...J},[y,ce]=await X(fetch(`${H}${t}`,{method:"POST",headers:Y,body:JSON.stringify(b)}));if(ce){j(!1);return}(y.ok||y.status===409)&&(E(e),k(h==="block"&&y.ok?"chips":"done"),P.current=!0,Z?.()),j(!1)},I=()=>k(v?"settled":"done"),se=e=>A(t=>t.includes(e)?t.filter(b=>b!==e):[...t,e]),ie=e=>{O(fe(e.target.value));const t=e.target;t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,M)}px`,t.style.overflowY=t.scrollHeight>M?"auto":"hidden"},D=Q(C),x=!oe&&!i&&(g.length>0||D>0),G=async()=>{if(!x)return;if(L){I();return}B(!0);const e=C.trim(),t={blockSlug:o,...c?{sectionKey:c}:{},...J,...g.length?{categories:g}:{},...e?{feedback:e}:{}},[b,y]=await X(fetch(`${H}/api/widget/block-feedback`,{method:"PUT",headers:Y,body:JSON.stringify(t)}));if(y){B(!1);return}(b.ok||b.status===404)&&I(),B(!1)},V=(f==="chips"||i)&&h==="block"&&m!==null&&o?me(o,m):[];return a.jsxs("div",{className:["es-block__rating",s?"es-block__rating--compact":"",te].filter(Boolean).join(" "),"data-es-no-read":!0,style:{display:"flex",alignItems:"center",gap:s?6:8,flexWrap:"wrap",...s?{marginTop:10,paddingTop:8,borderTop:"1px solid var(--es-color-border, rgba(0, 0, 0, 0.1))"}:{marginBottom:12}},children:[a.jsx("span",{className:"es-block__rating-label",style:{fontSize:s?12:13,color:"var(--es-color-on-surface-muted, #4B5563)"},children:l(m?"support_chat.feedback_thanks":ne)}),a.jsx("div",{className:"es-block__rating-stars",role:"radiogroup","aria-label":l(_??"support_chat.rate_aria"),style:{display:"inline-flex",alignItems:"center",gap:4},onMouseLeave:()=>!u&&S(null),children:ye.map(e=>{const t=e<=re;return a.jsx("button",{type:"button",role:"radio","aria-checked":e===W,"aria-label":l("support_chat.rate_star",{count:e}),disabled:u,onMouseEnter:()=>!u&&S(e),onClick:()=>le(e),style:{background:"none",border:"none",padding:0,cursor:u?"default":"pointer",lineHeight:0,color:"var(--es-color-warning, #9C5300)",opacity:u&&!t?.4:1,transition:"opacity 150ms ease-out"},children:a.jsx("svg",{width:U,height:U,viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})},e)})}),V.length>0&&a.jsxs("div",{className:"es-block__rating-followup",style:{flexBasis:"100%",display:"flex",flexDirection:"column",gap:6,marginTop:2},children:[a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:V.map(e=>{const t=g.includes(e);return a.jsx("button",{type:"button","aria-pressed":t,disabled:i,onClick:()=>se(e),style:{font:"inherit",fontSize:s?11.5:12,fontWeight:t?600:400,padding:"3px 10px",borderRadius:999,cursor:i?"default":"pointer",border:t?"1px solid var(--es-color-primary, #2563EB)":"1px solid var(--es-color-control-border, #6B7280)",background:t?"var(--es-color-primary-muted, rgba(37, 99, 235, 0.08))":"var(--es-color-surface-elevated, #f5f5f5)",color:t?"var(--es-color-primary-on-muted, #1D4ED8)":"var(--es-color-on-surface-muted, #4B5563)",transition:"border-color 120ms ease, color 120ms ease"},children:l(pe(e))},e)})}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"flex-end"},children:[a.jsx("textarea",{rows:1,value:C,disabled:i,onChange:ie,onKeyDown:e=>{e.key==="Enter"&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),G())},placeholder:l("block_feedback.own_words"),"aria-label":l("block_feedback.input_aria"),style:{flex:1,resize:"none",font:"inherit",fontSize:s?12:13,lineHeight:1.45,padding:"6px 10px",borderRadius:10,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",minHeight:32,maxHeight:M,overflowY:"hidden"}}),a.jsx("button",{type:"button","aria-label":l("block_feedback.send_aria"),disabled:!x,onClick:()=>{G()},style:{border:"none",borderRadius:10,width:32,height:32,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:x?"pointer":"default",background:"var(--es-color-primary, #2563EB)",color:"var(--es-color-on-primary, #FFFFFF)",opacity:x?1:.35,transition:"opacity 150ms ease-out"},children:a.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:[a.jsx("path",{d:"M22 2 11 13"}),a.jsx("path",{d:"M22 2 15 22l-4-9-9-4 20-7z"})]})})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8},children:[a.jsx("span",{"aria-live":"polite","data-es-no-read":!0,style:{fontSize:11,fontVariantNumeric:"tabular-nums",color:"var(--es-color-on-surface-muted, #4B5563)",visibility:D>=_e?"visible":"hidden"},children:l("block_feedback.counter",{count:D,max:R})}),a.jsx("button",{type:"button",disabled:i,onClick:I,style:{background:"none",border:"none",padding:0,font:"inherit",fontSize:11,cursor:i?"default":"pointer",color:"var(--es-color-on-surface-muted, #4B5563)",visibility:i?"hidden":"visible"},children:l("block_feedback.skip")})]})]})]})}export{ge as C};
|
|
2
|
-
//# sourceMappingURL=block-rating-
|
|
1
|
+
import{r,j as a,K as X}from"../nexly.js";const de=240,R=30,ue=n=>n<=3?"low":"high",pe=n=>`block_feedback.chip.${n}`;Object.fromEntries([{key:"numbers_wrong",labelEn:"The numbers look wrong"},{key:"too_generic",labelEn:"Too generic"},{key:"hard_to_understand",labelEn:"Hard to understand"},{key:"not_relevant",labelEn:"Not relevant to me"},{key:"accurate",labelEn:"Accurate numbers"},{key:"clear",labelEn:"Clear and easy to follow"},{key:"actionable",labelEn:"I know what to do next"},{key:"saves_time",labelEn:"Saves me time"},{key:"not_my_situation",labelEn:"Doesn't fit my situation"},{key:"where_to_start",labelEn:"Don't know where to start"},{key:"concrete_steps",labelEn:"Concrete steps"},{key:"matches_my_data",labelEn:"Matches my data"},{key:"motivating",labelEn:"Motivates me to act"},{key:"data_stale",labelEn:"Data looks outdated"},{key:"dashboard_mismatch",labelEn:"Differs from my dashboard"},{key:"threshold_unclear",labelEn:"The threshold isn't clear"},{key:"no_next_step",labelEn:"No hint what to do next"},{key:"warned_in_time",labelEn:"Warned me in time"},{key:"clear_threshold",labelEn:"Clear threshold and deadline"},{key:"branch_detail",labelEn:"Not enough branch detail"},{key:"how_to_use",labelEn:"Not sure how to use this"},{key:"comparison_weak",labelEn:"Comparison not helpful"},{key:"see_growth",labelEn:"I can see where my team grows"},{key:"recognize_team",labelEn:"Helps me recognize my team"},{key:"week_over_week",labelEn:"Useful week-over-week view"},{key:"payout_mismatch",labelEn:"Doesn't match my payout"},{key:"assumptions_unclear",labelEn:"Assumptions aren't clear"},{key:"no_what_if",labelEn:"No what-if scenarios"},{key:"currency_unclear",labelEn:"Currency or rate unclear"},{key:"matches_payout",labelEn:"Matches my payout"},{key:"helps_planning",labelEn:"Helps me plan the cycle"},{key:"too_late",labelEn:"Came too late"},{key:"no_context",labelEn:"Not enough context"},{key:"other_topics",labelEn:"I'd prefer other topics"},{key:"spot_on",labelEn:"Spot-on topic"},{key:"learned",labelEn:"I learned something"},{key:"on_time",labelEn:"Right on time"},{key:"want_to_join",labelEn:"Makes me want to join in"},{key:"needs_example",labelEn:"No example"},{key:"too_long",labelEn:"Too long"},{key:"bad_formatting",labelEn:"Badly formatted"},{key:"good_example",labelEn:"Good example"}].map(n=>[n.key,n]));const he={low:["numbers_wrong","too_generic","hard_to_understand","not_relevant"],high:["accurate","clear","actionable","saves_time"]},q={low:["payout_mismatch","assumptions_unclear","no_what_if","currency_unclear"],high:["matches_payout","helps_planning","clear","accurate"]},be={"daily-action-plan":{low:["not_my_situation","numbers_wrong","too_generic","where_to_start"],high:["concrete_steps","matches_my_data","saves_time","motivating"]},"rank-advancement-roadmap":{low:["data_stale","dashboard_mismatch","threshold_unclear","no_next_step"],high:["warned_in_time","clear_threshold","actionable","accurate"]},"network-growth":{low:["branch_detail","data_stale","how_to_use","comparison_weak"],high:["see_growth","recognize_team","week_over_week","motivating"]},"mlm-calculator":q,"commission-forecast":q,"social-insights":{low:["not_relevant","too_late","no_context","other_topics"],high:["spot_on","learned","on_time","want_to_join"]},learning:{low:["hard_to_understand","needs_example","too_long","bad_formatting"],high:["clear","good_example","learned","actionable"]}};function me(n,o){return(be[n]??he)[ue(o)]}function Q(n){const o=n.trim().match(/\S+/g);return o?o.length:0}const ye=[1,2,3,4,5],M=96,_e=20;function fe(n){let o=n.slice(0,de);if(Q(o)>R){let c=0,d=0,p=!1;for(;d<o.length;){const _=/\s/.test(o.charAt(d));if(!_&&!p&&(c++,p=!0,c>R))break;_&&(p=!1),d++}o=o.slice(0,d).trimEnd()}return o}function ge({promptLogId:n,blockSlug:o,sectionKey:c,subjectType:d,subjectId:p,ariaKey:_,onRated:Z,onFeedbackCycleDone:z,settleInPlace:v=!1,baseUrl:H,apiKey:K,jwt:F,t:l,promptKey:ee,compact:s=!1,className:te,previewMode:L=!1}){const[m,E]=r.useState(null),[ae,j]=r.useState(!1),[$,S]=r.useState(null),[f,k]=r.useState("none"),i=f==="settled",[g,A]=r.useState([]),[C,O]=r.useState(""),[oe,B]=r.useState(!1),N=r.useRef(null),T=r.useRef(z);T.current=z;const w=r.useRef(!1),P=r.useRef(!1);r.useEffect(()=>()=>{P.current&&!w.current&&(w.current=!0,T.current?.())},[]),r.useEffect(()=>{if(!(f!=="done"||v))return N.current=setTimeout(()=>{E(null),S(null),A([]),O(""),k("none"),w.current||(w.current=!0,T.current?.())},2500),()=>{N.current&&clearTimeout(N.current)}},[f,v]);const h=n?"ai":o?"block":null;if(!h||!F)return null;const ne=ee??(s?"block_rating.prompt_section":"block_rating.prompt"),u=m!==null||ae,W=m??0,re=!u&&$!==null?$:W,U=s?15:18,J=d&&p?{subjectType:d,subjectId:p}:{},Y={"Content-Type":"application/json",...K?{"X-API-Key":K}:{},Authorization:`Bearer ${F}`},le=async e=>{if(u)return;if(L){E(e),k(h==="block"?"chips":"done");return}j(!0);const t=h==="ai"?"/api/widget/ai-feedback":"/api/widget/block-feedback",b=h==="ai"?{promptLogId:n,rating:e}:{blockSlug:o,rating:e,...c?{sectionKey:c}:{},...J},[y,ce]=await X(fetch(`${H}${t}`,{method:"POST",headers:Y,body:JSON.stringify(b)}));if(ce){j(!1);return}(y.ok||y.status===409)&&(E(e),k(h==="block"&&y.ok?"chips":"done"),P.current=!0,Z?.()),j(!1)},I=()=>k(v?"settled":"done"),se=e=>A(t=>t.includes(e)?t.filter(b=>b!==e):[...t,e]),ie=e=>{O(fe(e.target.value));const t=e.target;t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,M)}px`,t.style.overflowY=t.scrollHeight>M?"auto":"hidden"},D=Q(C),x=!oe&&!i&&(g.length>0||D>0),G=async()=>{if(!x)return;if(L){I();return}B(!0);const e=C.trim(),t={blockSlug:o,...c?{sectionKey:c}:{},...J,...g.length?{categories:g}:{},...e?{feedback:e}:{}},[b,y]=await X(fetch(`${H}/api/widget/block-feedback`,{method:"PUT",headers:Y,body:JSON.stringify(t)}));if(y){B(!1);return}(b.ok||b.status===404)&&I(),B(!1)},V=(f==="chips"||i)&&h==="block"&&m!==null&&o?me(o,m):[];return a.jsxs("div",{className:["es-block__rating",s?"es-block__rating--compact":"",te].filter(Boolean).join(" "),"data-es-no-read":!0,style:{display:"flex",alignItems:"center",gap:s?6:8,flexWrap:"wrap",...s?{marginTop:10,paddingTop:8,borderTop:"1px solid var(--es-color-border, rgba(0, 0, 0, 0.1))"}:{marginBottom:12}},children:[a.jsx("span",{className:"es-block__rating-label",style:{fontSize:s?12:13,color:"var(--es-color-on-surface-muted, #4B5563)"},children:l(m?"support_chat.feedback_thanks":ne)}),a.jsx("div",{className:"es-block__rating-stars",role:"radiogroup","aria-label":l(_??"support_chat.rate_aria"),style:{display:"inline-flex",alignItems:"center",gap:4},onMouseLeave:()=>!u&&S(null),children:ye.map(e=>{const t=e<=re;return a.jsx("button",{type:"button",role:"radio","aria-checked":e===W,"aria-label":l("support_chat.rate_star",{count:e}),disabled:u,onMouseEnter:()=>!u&&S(e),onClick:()=>le(e),style:{background:"none",border:"none",padding:0,cursor:u?"default":"pointer",lineHeight:0,color:"var(--es-color-warning, #9C5300)",opacity:u&&!t?.4:1,transition:"opacity 150ms ease-out"},children:a.jsx("svg",{width:U,height:U,viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})},e)})}),V.length>0&&a.jsxs("div",{className:"es-block__rating-followup",style:{flexBasis:"100%",display:"flex",flexDirection:"column",gap:6,marginTop:2},children:[a.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:V.map(e=>{const t=g.includes(e);return a.jsx("button",{type:"button","aria-pressed":t,disabled:i,onClick:()=>se(e),style:{font:"inherit",fontSize:s?11.5:12,fontWeight:t?600:400,padding:"3px 10px",borderRadius:999,cursor:i?"default":"pointer",border:t?"1px solid var(--es-color-primary, #2563EB)":"1px solid var(--es-color-control-border, #6B7280)",background:t?"var(--es-color-primary-muted, rgba(37, 99, 235, 0.08))":"var(--es-color-surface-elevated, #f5f5f5)",color:t?"var(--es-color-primary-on-muted, #1D4ED8)":"var(--es-color-on-surface-muted, #4B5563)",transition:"border-color 120ms ease, color 120ms ease"},children:l(pe(e))},e)})}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"flex-end"},children:[a.jsx("textarea",{rows:1,value:C,disabled:i,onChange:ie,onKeyDown:e=>{e.key==="Enter"&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),G())},placeholder:l("block_feedback.own_words"),"aria-label":l("block_feedback.input_aria"),style:{flex:1,resize:"none",font:"inherit",fontSize:s?12:13,lineHeight:1.45,padding:"6px 10px",borderRadius:10,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",minHeight:32,maxHeight:M,overflowY:"hidden"}}),a.jsx("button",{type:"button","aria-label":l("block_feedback.send_aria"),disabled:!x,onClick:()=>{G()},style:{border:"none",borderRadius:10,width:32,height:32,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:x?"pointer":"default",background:"var(--es-color-primary, #2563EB)",color:"var(--es-color-on-primary, #FFFFFF)",opacity:x?1:.35,transition:"opacity 150ms ease-out"},children:a.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:[a.jsx("path",{d:"M22 2 11 13"}),a.jsx("path",{d:"M22 2 15 22l-4-9-9-4 20-7z"})]})})]}),a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8},children:[a.jsx("span",{"aria-live":"polite","data-es-no-read":!0,style:{fontSize:11,fontVariantNumeric:"tabular-nums",color:"var(--es-color-on-surface-muted, #4B5563)",visibility:D>=_e?"visible":"hidden"},children:l("block_feedback.counter",{count:D,max:R})}),a.jsx("button",{type:"button",disabled:i,onClick:I,style:{background:"none",border:"none",padding:0,font:"inherit",fontSize:11,cursor:i?"default":"pointer",color:"var(--es-color-on-surface-muted, #4B5563)",visibility:i?"hidden":"visible"},children:l("block_feedback.skip")})]})]})]})}export{ge as C};
|
|
2
|
+
//# sourceMappingURL=block-rating-CAVRRYuG-CQMNokIy.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=external-url-
|
|
1
|
+
import{Z as r}from"../nexly.js";import{a as u}from"./allowed-elements-C0OfX2zF-DIBV8lKu.js";const p=["https://external-url-probe.invalid/probe","http://external-url-probe.invalid/probe"];function i(t){return t.length>0&&!/^\.+$/.test(t)}function o(t){if(typeof t!="string"||t.length===0||u(t)===null)return null;const[n]=r(()=>new URL(t));return n===null||n.protocol!=="http:"&&n.protocol!=="https:"||!p.every(l=>{const[e]=r(()=>new URL(t,l));return e!==null&&e.href===n.href})||!i(n.hostname)?null:n}function f(t){return o(t)?.href??null}function h(t){return o(t)?.host??""}export{h as c,f as p};
|
|
2
|
+
//# sourceMappingURL=external-url-JbUnX7Da-rLiy7c9v.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as n,j as s,
|
|
2
|
-
//# sourceMappingURL=index--
|
|
1
|
+
import{r as n,j as s,e as H}from"../nexly.js";const L={slug:"support-session-nav",name:"Support Session Navigator",version:"1.0.0",category:"interactive",configSchema:{},defaultConfig:{},sizing:{minWidth:200,preferredHeight:"fill",scrollable:!0},supportedPlacements:["sidebar","main"],events:{emits:[{name:"support-chat:select-session",description:"User selected a past support session"}]}};function M(a,o){const u=Date.now()-new Date(a).getTime(),r=Math.floor(u/6e4);if(r<1)return o("time.just_now");if(r<60)return o("time.minutes_ago",{count:r});const i=Math.floor(r/60);return i<24?o("time.hours_ago",{count:i}):o("time.days_ago",{count:Math.floor(i/24)})}function T({actions:a,baseUrl:o,productId:u,i18n:r,supportSessionId:i,auth:k,externalContext:g}){const t=r?.t??(e=>e),m=k?.jwt,w=g?.showTicketsTab??!1,[v,l]=n.useState(!1),[x,y]=n.useState([]),[p,b]=n.useState(!1),[f,j]=n.useState(null),[d,h]=n.useState(i??null);n.useEffect(()=>{h(i??null)},[i]);const _=n.useCallback(async()=>{b(!0),j(null);try{const e=await fetch(`${o}/api/support-chat/sessions?productId=${encodeURIComponent(u||"")}`,{headers:{...m?{Authorization:`Bearer ${m}`}:{}},credentials:"include"});if(!e.ok)throw new Error(`HTTP ${e.status}`);const c=await e.json();if(!c.success||!c.data)throw new Error("Invalid response");y(c.data.sessions)}catch{j(t("support_session_nav.load_error"))}finally{b(!1)}},[o,m,u,t]);n.useEffect(()=>a.on("support-chat:session",e=>{const{sessionId:c}=e;c&&h(c),v&&_()}),[a,_,v]),n.useEffect(()=>a.on("support-chat:showHistory",()=>{l(!0),_()}),[a,_]),n.useEffect(()=>a.on("support-chat:clearHistory",()=>{l(!1)}),[a]);const C=n.useCallback(e=>{e!==d&&(h(e),a.emit("support-chat:select-session",{sessionId:e})),l(!1)},[a,d]),N=n.useCallback(()=>{a.emit("support-chat:clearHistory",void 0),h(null),l(!1)},[a]),S=n.useCallback(()=>{l(!1)},[]),E=n.useCallback(()=>{a.emit("support-chat:showTickets",void 0),l(!1)},[a]);return v?s.jsxs(H,{blockType:"support-session-nav",children:[s.jsxs("div",{className:"es-ssn__header",children:[s.jsx("span",{className:"es-ssn__header-title",children:t("support_session_nav.title")}),s.jsxs("div",{className:"es-ssn__header-actions",children:[s.jsx("button",{type:"button",className:"es-ssn__action-btn","aria-label":t("support_chat.new_conversation_button"),title:t("support_chat.new_conversation_button"),onClick:N,children:s.jsxs("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M12 5H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})]})}),s.jsx("button",{type:"button",className:"es-ssn__action-btn es-ssn__action-btn--active","aria-label":t("support_chat.history_button"),title:t("support_chat.history_button"),"aria-pressed":"true",onClick:S,children:s.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]})}),w&&s.jsx("button",{type:"button",className:"es-ssn__action-btn","aria-label":t("support_chat.tickets_tab_button"),title:t("support_chat.tickets_tab_button"),onClick:E,children:s.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),s.jsx("path",{d:"m9 12 2 2 4-4"})]})})]})]}),s.jsx("div",{className:"es-block__body",children:s.jsxs("div",{className:"es-ssn__list",role:"list","aria-label":t("support_session_nav.list_aria"),children:[p&&s.jsx("div",{className:"es-ssn__loading",role:"status",children:t("support_session_nav.loading")}),f&&!p&&s.jsx("div",{className:"es-ssn__error",role:"alert",children:f}),!p&&!f&&x.length===0&&s.jsx("div",{className:"es-ssn__empty",children:t("support_session_nav.empty")}),!p&&x.map(e=>s.jsxs("button",{role:"listitem",type:"button",className:`es-ssn__item${e.id===d?" es-ssn__item--active":""}`,onClick:()=>C(e.id),"aria-current":e.id===d?"true":void 0,children:[s.jsx("div",{className:"es-ssn__item-preview",children:e.firstUserMessage??t("support_session_nav.no_preview")}),s.jsxs("div",{className:"es-ssn__item-meta",children:[s.jsx("span",{className:`es-ssn__item-status es-ssn__item-status--${e.status}`,"aria-label":e.status,children:e.status}),s.jsx("span",{children:M(e.updatedAt,t)}),e.messageCount>0&&s.jsx("span",{children:t("support_session_nav.message_count",{count:e.messageCount})})]})]},e.id))]})})]}):null}export{T as Component,L as manifest};
|
|
2
|
+
//# sourceMappingURL=index--H6hRpBJ-F9_TzvkO.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{w as B,p as T,f as O,x as E,A as W,S as G,O as Y}from"./accent-legibility-BJF2VO5n-CDPQ7suO.js";import{H as J,r as j,j as s,Y as K}from"../nexly.js";const Q=4.5,x="#3B6FD4",Z={"--ai-bg":"#FFFFFF","--ai-bg-elevated":"#F9FAFB","--ai-bg-card":"#F3F4F6","--ai-bg-input":"#FFFFFF","--ai-bg-footer":"#F9FAFB","--ai-fg":"#111827","--ai-fg-secondary":"#374151","--ai-muted":"#4B5563","--ai-muted-dim":"#6B7280","--ai-border":"#E5E7EB","--ai-border-subtle":"#F3F4F6","--ai-assistant-bubble":"#F3F4F6","--ai-assistant-bubble-fg":"#111827","--ai-shadow":"0 20px 60px -15px rgba(15, 23, 42, 0.25)","--ai-success":"#00672B","--ai-warning":"#9C5300","--ai-error":"#AD2C26","--ai-info":"#03669D","--es-color-surface":"#FFFFFF","--es-color-surface-elevated":"#F9FAFB","--es-color-surface-hover":"#F3F4F6","--es-color-on-surface":"#111827","--es-color-on-surface-muted":"#4B5563","--es-color-border":"#E5E7EB","--es-color-control-border":"#6B7280","--es-color-error":"#AD2C26","--es-color-success":"#00672B","--es-color-on-success":"#FFFFFF"},ee={"--ai-bg":"#0F1115","--ai-bg-elevated":"#171A20","--ai-bg-card":"#171A20","--ai-bg-input":"#0F1115","--ai-bg-footer":"#0F1115","--ai-fg":"#F3F4F6","--ai-fg-secondary":"#D1D5DB","--ai-muted":"#9CA3AF","--ai-muted-dim":"#6B7280","--ai-border":"#252A33","--ai-border-subtle":"#1B1F26","--ai-assistant-bubble":"#171A20","--ai-assistant-bubble-fg":"#F3F4F6","--ai-shadow":"0 20px 60px -15px rgba(0, 0, 0, 0.7)","--ai-success":"#4ADE80","--ai-warning":"#FACC15","--ai-error":"#F87171","--ai-info":"#38BDF8","--es-color-surface":"#0F1115","--es-color-surface-elevated":"#171A20","--es-color-surface-hover":"#252A33","--es-color-on-surface":"#F3F4F6","--es-color-on-surface-muted":"#9CA3AF","--es-color-border":"#252A33","--es-color-control-border":"#6B7280","--es-color-error":"#F87171","--es-color-success":"#4ADE80","--es-color-on-success":"#0F1115"};function X(e){const a=Y("#FFFFFF",e),r=Y("#000000",e);return a>=r?"#FFFFFF":"#000000"}function ae(e){const[a,r,o]=O(e),t=G(e)<.2?28:-28;return T([Math.max(0,Math.min(255,a+t)),Math.max(0,Math.min(255,r+t)),Math.max(0,Math.min(255,o+t))])}function L({brandColor:e,mode:a}){const r=a==="light"?Z:ee,o=e&&B(e)?e:x,t=T(O(o)),l=X(t),f={ai:["--ai-bg","--ai-bg-elevated","--ai-bg-card","--ai-bg-input","--ai-bg-sidebar","--ai-bg-footer"],es:["--es-color-surface","--es-color-surface-elevated","--es-color-surface-hover"]},w=(C,c)=>{const g=new Set([c]);for(const S of f[C]){const b=r[S];typeof b=="string"&&B(b)&&g.add(b)}return[...g]},p=E({accent:t,surface:w("ai",r["--ai-bg-card"]),backdrop:r["--ai-bg"],tintAlpha:a==="light"?.08:.12,mode:a}),m=E({accent:t,surface:w("es",r["--es-color-surface-elevated"]),backdrop:r["--es-color-surface"],tintAlpha:a==="light"?.08:.12,mode:a}),u=W(t,w("es",r["--es-color-surface"]),Q,a);return{...r,"--ai-accent":t,"--ai-accent-fg":l,"--ai-accent-hover":ae(t),"--ai-accent-subtle":p.tint,"--ai-accent-on-subtle":p.onTint,"--ai-accent-on-subtle-strong":p.onStrongTint,"--ai-accent-border":p.boundary,"--ai-user-bubble":t,"--ai-user-bubble-fg":l,"--ai-scrollbar":t,"--es-color-primary":u,"--es-color-on-primary":X(u),"--es-color-primary-muted":m.tint,"--es-color-primary-on-muted":m.onTint,"--es-color-interactive":u}}const ge=L({brandColor:x,mode:"light"}),be=L({brandColor:x,mode:"dark"}),n={shape:"--es-demo-launcher-shape",width:"--es-demo-launcher-width",height:"--es-demo-launcher-height",radius:"--es-demo-launcher-radius",background:"--es-demo-launcher-background",shadow:"--es-demo-launcher-shadow",padding:"--es-demo-launcher-padding",offsetX:"--es-demo-launcher-offset-x",offsetY:"--es-demo-launcher-offset-y"},i={width:{min:32,max:240,step:2},height:{min:32,max:240,step:2},radius:{min:0,max:64,step:1},padding:{min:0,max:32,step:1},offsetX:{min:0,max:240,step:2},offsetY:{min:0,max:240,step:2}},H=8,re=8,oe=.6,d={shape:"pill",width:56,height:56,radius:12,background:"accent",shadow:!0,padding:0,offsetX:20,offsetY:20},se=new Set(["pill","circle","square","rectangle"]),te=new Set(["accent","neutral","none"]);function ne(e){if(typeof e!="string")return;const a=/^\s*(-?\d+(?:\.\d+)?)\s*(?:px)?\s*$/i.exec(e);if(!a)return;const r=Number(a[1]);return Number.isFinite(r)?r:void 0}function F(e,a,r){const o=ne(e);return o===void 0?r:Math.min(a.max,Math.max(a.min,o))}function R(e,a,r){if(typeof e!="string")return r;const o=e.trim().toLowerCase();return a.has(o)?o:r}function ie(e,a){if(typeof e!="string")return a;const r=e.trim().toLowerCase();return r==="true"||r==="1"?!0:r==="false"||r==="0"?!1:a}function U(e){const a=e.shape==="circle"||e.shape==="square";return{width:e.width,height:a?e.width:e.height}}function le(e,a,r,o){if(e==="pill")return o;const t=Math.max(0,Math.floor((Math.min(r.width,r.height)-H)/2)),l=a==="accent"?Math.min(re,t):0;return Math.min(t,Math.max(l,o))}function ce(e){const a=e??{},r=d,o=R(a[n.shape],se,r.shape),t=R(a[n.background],te,r.background),l=F(a[n.width],i.width,r.width),f=F(a[n.height],i.height,r.height);return{shape:o,width:l,height:f,radius:F(a[n.radius],i.radius,r.radius),background:t,shadow:ie(a[n.shadow],r.shadow),padding:le(o,t,U({shape:o,width:l,height:f}),F(a[n.padding],i.padding,r.padding)),offsetX:F(a[n.offsetX],i.offsetX,r.offsetX),offsetY:F(a[n.offsetY],i.offsetY,r.offsetY)}}const N={accent:"var(--ai-accent)",neutral:"var(--ai-bg)",none:"transparent"};function de(e){const{width:a,height:r}=U(e),o=e.shape==="circle"?"50%":e.shape==="pill"?"calc(var(--es-demo-launcher-h) / 2)":`${e.radius}px`;return{"--es-demo-launcher-w":`${a}px`,"--es-demo-launcher-h":`${r}px`,"--es-demo-launcher-radius":o,"--es-demo-launcher-bg":N[e.background],"--es-demo-launcher-dot-ring":e.background==="none"?N.neutral:N[e.background],"--es-demo-launcher-shadow":e.shadow?"var(--ai-shadow)":"none","--es-demo-launcher-pad":`${e.padding}px`,"--es-demo-launcher-coin":`${oe}`,"--es-demo-launcher-mark-min":`${H}px`,"--es-demo-launcher-x":`${e.offsetX}px`,"--es-demo-launcher-y":`${e.offsetY}px`}}const Fe={slug:"demo",name:"Demo",version:"0.1.0",slots:["header","main","footer"],cssVariables:{"--ai-accent":x},structure:{header:{id:"header",label:"Header",accepts:!0},main:{id:"main",label:"Main Content",accepts:!0},footer:{id:"footer",label:"Footer",accepts:!0}},defaultViews:[],requiredServices:["support-chat"],description:"Neutral, brand-adaptive shell for demo clones. Carries no mascot and no brand of its own: the logo, name and accent colour all come from the product, and the rest of the palette is derived around them so it stays legible for any input.",author:"E-Commerce Studio",packageName:"@ecommerce-studio/theme-demo",options:[{id:"colorScheme",type:"select",label:"Appearance mode",default:"auto",group:"Appearance",options:[{label:"Auto (match visitor)",value:"auto"},{label:"Light",value:"light"},{label:"Dark",value:"dark"}]},{id:"brandColor",type:"color",label:"Brand colour",default:x,cssVariable:"--ai-accent",group:"Colors"},{id:"launcherShape",type:"select",label:"Button shape",default:d.shape,cssVariable:n.shape,group:"Launcher",options:[{label:"Pill (wordmark on a chip)",value:"pill"},{label:"Circle",value:"circle"},{label:"Square",value:"square"},{label:"Rectangle",value:"rectangle"}]},{id:"launcherWidth",type:"range",label:"Width (side for circle / square)",default:d.width,unit:"px",cssVariable:n.width,group:"Launcher",...i.width},{id:"launcherHeight",type:"range",label:"Height (pill / rectangle)",default:d.height,unit:"px",cssVariable:n.height,group:"Launcher",...i.height},{id:"launcherRadius",type:"range",label:"Corner radius (square / rectangle)",default:d.radius,unit:"px",cssVariable:n.radius,group:"Launcher",...i.radius},{id:"launcherBackground",type:"select",label:"Background",default:d.background,cssVariable:n.background,group:"Launcher",options:[{label:"Brand colour",value:"accent"},{label:"Neutral",value:"neutral"},{label:"None (transparent)",value:"none"}]},{id:"launcherShadow",type:"toggle",label:"Shadow",default:d.shadow,cssVariable:n.shadow,group:"Launcher"},{id:"launcherPadding",type:"range",label:"Logo padding",default:d.padding,unit:"px",cssVariable:n.padding,group:"Launcher",...i.padding},{id:"launcherOffsetX",type:"range",label:"Distance from side",default:d.offsetX,unit:"px",cssVariable:n.offsetX,group:"Launcher",...i.offsetX},{id:"launcherOffsetY",type:"range",label:"Distance from bottom",default:d.offsetY,unit:"px",cssVariable:n.offsetY,group:"Launcher",...i.offsetY}],supports:{customCss:!1,customJs:!1,darkMode:!0,rtl:!1,views:!0}};function ue(e){const a=[e?.["--ai-accent"],e?.["--es-color-primary"]];for(const r of a)if(typeof r=="string"&&B(r))return r;return x}function he(e){const a=(e??"").trim().split(/\s+/).filter(Boolean);return a.length===0?"":a.slice(0,2).map(r=>[...r][0]??"").join("").toLocaleUpperCase()}function xe({brandName:e="",logoUrl:a,position:r="bottom-right",sidebarPosition:o="right",initialOpen:t=!1,views:l=[],activeView:f="",onViewChange:w=()=>{},children:p=null,cssVariables:m,t:u,colorScheme:C,builderMode:c=!1,unreadCount:g=0,onSettingsClick:S,onOpenChange:b,panelReadAloudControl:q}){const A=J(C)==="light"?"light":"dark",[_,M]=j.useState(t||c),y=j.useMemo(()=>ce(m),[m]),P=j.useMemo(()=>({...L({brandColor:ue(m),mode:A}),...de(y),...c?{width:"100%",height:"100%"}:{}}),[m,y,A,c]),I=()=>M(h=>{const v=!h;return b?.(v),v}),z=()=>{M(!1),b?.(!1)},D=r==="bottom-left",V=o!=="hidden"&&l.length>1,k=he(e);return s.jsxs("div",{className:["es-demo",`es-demo--${A}`].join(" "),style:P,children:[!c&&s.jsxs("button",{type:"button",className:["es-demo__launcher",`es-demo__launcher--${y.shape}`,`es-demo__launcher--bg-${y.background}`,D&&"es-demo__launcher--left",_&&"es-demo__launcher--hidden"].filter(Boolean).join(" "),onClick:I,"aria-label":u?.("floating.open_widget")??"Open chat widget",tabIndex:_?-1:0,"aria-hidden":_,children:[a?s.jsx("img",{className:"es-demo__launcher-logo",src:a,alt:""}):s.jsx("span",{className:"es-demo__launcher-monogram","aria-hidden":"true",children:k||"•"}),g>0&&s.jsx("span",{className:"es-demo__launcher-dot","aria-label":u?.("floating.unread",{count:g})??`${g} unread`})]}),s.jsxs("div",{className:["es-demo__panel",D&&!c&&"es-demo__panel--left",(_||c)&&"es-demo__panel--open"].filter(Boolean).join(" "),role:"dialog","aria-label":u?.("chat.widget_aria")??"Chat widget","aria-hidden":c?!1:!_,children:[s.jsxs("header",{className:"es-demo__header",children:[s.jsxs("div",{className:"es-demo__brand",children:[a?s.jsx("img",{className:"es-demo__brand-logo",src:a,alt:""}):k&&s.jsx("span",{className:"es-demo__brand-monogram","aria-hidden":"true",children:k}),e&&s.jsx("h1",{className:"es-demo__brand-name",children:e})]}),s.jsxs("div",{className:"es-demo__header-actions",children:[q,!c&&s.jsx("button",{type:"button",className:"es-demo__header-btn",onClick:z,"aria-label":u?.("header.close_widget")??"Close widget",children:s.jsx(me,{})})]})]}),s.jsxs("div",{className:["es-demo__body",V&&`es-demo__body--rail-${o}`].filter(Boolean).join(" "),children:[V&&s.jsx("nav",{className:`es-demo__rail es-demo__rail--${o}`,"aria-label":u?.("nav.views")??"Views",children:l.map(h=>{const v=K(h.icon||h.slug),$=h.slug===f;return s.jsxs("button",{type:"button",className:["es-demo__rail-item",$&&"es-demo__rail-item--active"].filter(Boolean).join(" "),onClick:()=>w(h.slug),"aria-current":$?"page":void 0,title:h.label,children:[v?s.jsx(v,{size:20}):null,s.jsx("span",{className:"es-demo__rail-label",children:h.label})]},h.slug)})}),s.jsx("main",{className:"es-demo__content",style:{containerName:"es-slot",containerType:"inline-size"},children:p})]})]})]})}function me({size:e=20}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"m6 9 6 6 6-6"})})}export{x as DEFAULT_BRAND,d as LAUNCHER_DEFAULTS,i as LAUNCHER_LIMITS,n as LAUNCHER_VARS,Q as TEXT_FLOOR,xe as ThemeShell,be as darkVariables,L as deriveDemoPalette,ae as hoverStep,X as inkOn,de as launcherRootStyle,ge as lightVariables,Fe as manifest,he as monogram,ce as resolveLauncherSettings};
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{w as B,p as R,f as O,x as E,A as W,S as G,O as T}from"./accent-legibility-BJF2VO5n-CDPQ7suO.js";import{T as J,r as j,j as s,o as K}from"../nexly.js";const Q=4.5,x="#3B6FD4",Z={"--ai-bg":"#FFFFFF","--ai-bg-elevated":"#F9FAFB","--ai-bg-card":"#F3F4F6","--ai-bg-input":"#FFFFFF","--ai-bg-footer":"#F9FAFB","--ai-fg":"#111827","--ai-fg-secondary":"#374151","--ai-muted":"#4B5563","--ai-muted-dim":"#6B7280","--ai-border":"#E5E7EB","--ai-border-subtle":"#F3F4F6","--ai-assistant-bubble":"#F3F4F6","--ai-assistant-bubble-fg":"#111827","--ai-shadow":"0 20px 60px -15px rgba(15, 23, 42, 0.25)","--ai-success":"#00672B","--ai-warning":"#9C5300","--ai-error":"#AD2C26","--ai-info":"#03669D","--es-color-surface":"#FFFFFF","--es-color-surface-elevated":"#F9FAFB","--es-color-surface-hover":"#F3F4F6","--es-color-on-surface":"#111827","--es-color-on-surface-muted":"#4B5563","--es-color-border":"#E5E7EB","--es-color-control-border":"#6B7280","--es-color-error":"#AD2C26","--es-color-success":"#00672B","--es-color-on-success":"#FFFFFF"},ee={"--ai-bg":"#0F1115","--ai-bg-elevated":"#171A20","--ai-bg-card":"#171A20","--ai-bg-input":"#0F1115","--ai-bg-footer":"#0F1115","--ai-fg":"#F3F4F6","--ai-fg-secondary":"#D1D5DB","--ai-muted":"#9CA3AF","--ai-muted-dim":"#6B7280","--ai-border":"#252A33","--ai-border-subtle":"#1B1F26","--ai-assistant-bubble":"#171A20","--ai-assistant-bubble-fg":"#F3F4F6","--ai-shadow":"0 20px 60px -15px rgba(0, 0, 0, 0.7)","--ai-success":"#4ADE80","--ai-warning":"#FACC15","--ai-error":"#F87171","--ai-info":"#38BDF8","--es-color-surface":"#0F1115","--es-color-surface-elevated":"#171A20","--es-color-surface-hover":"#252A33","--es-color-on-surface":"#F3F4F6","--es-color-on-surface-muted":"#9CA3AF","--es-color-border":"#252A33","--es-color-control-border":"#6B7280","--es-color-error":"#F87171","--es-color-success":"#4ADE80","--es-color-on-success":"#0F1115"};function X(e){const a=T("#FFFFFF",e),o=T("#000000",e);return a>=o?"#FFFFFF":"#000000"}function ae(e){const[a,o,r]=O(e),t=G(e)<.2?28:-28;return R([Math.max(0,Math.min(255,a+t)),Math.max(0,Math.min(255,o+t)),Math.max(0,Math.min(255,r+t))])}function L({brandColor:e,mode:a}){const o=a==="light"?Z:ee,r=e&&B(e)?e:x,t=R(O(r)),l=X(t),f={ai:["--ai-bg","--ai-bg-elevated","--ai-bg-card","--ai-bg-input","--ai-bg-sidebar","--ai-bg-footer"],es:["--es-color-surface","--es-color-surface-elevated","--es-color-surface-hover"]},w=(C,c)=>{const g=new Set([c]);for(const S of f[C]){const b=o[S];typeof b=="string"&&B(b)&&g.add(b)}return[...g]},p=E({accent:t,surface:w("ai",o["--ai-bg-card"]),backdrop:o["--ai-bg"],tintAlpha:a==="light"?.08:.12,mode:a}),m=E({accent:t,surface:w("es",o["--es-color-surface-elevated"]),backdrop:o["--es-color-surface"],tintAlpha:a==="light"?.08:.12,mode:a}),u=W(t,w("es",o["--es-color-surface"]),Q,a);return{...o,"--ai-accent":t,"--ai-accent-fg":l,"--ai-accent-hover":ae(t),"--ai-accent-subtle":p.tint,"--ai-accent-on-subtle":p.onTint,"--ai-accent-on-subtle-strong":p.onStrongTint,"--ai-accent-border":p.boundary,"--ai-user-bubble":t,"--ai-user-bubble-fg":l,"--ai-scrollbar":t,"--es-color-primary":u,"--es-color-on-primary":X(u),"--es-color-primary-muted":m.tint,"--es-color-primary-on-muted":m.onTint,"--es-color-interactive":u}}const ge=L({brandColor:x,mode:"light"}),be=L({brandColor:x,mode:"dark"}),n={shape:"--es-demo-launcher-shape",width:"--es-demo-launcher-width",height:"--es-demo-launcher-height",radius:"--es-demo-launcher-radius",background:"--es-demo-launcher-background",shadow:"--es-demo-launcher-shadow",padding:"--es-demo-launcher-padding",offsetX:"--es-demo-launcher-offset-x",offsetY:"--es-demo-launcher-offset-y"},i={width:{min:32,max:240,step:2},height:{min:32,max:240,step:2},radius:{min:0,max:64,step:1},padding:{min:0,max:32,step:1},offsetX:{min:0,max:240,step:2},offsetY:{min:0,max:240,step:2}},U=8,oe=8,re=.6,d={shape:"pill",width:56,height:56,radius:12,background:"accent",shadow:!0,padding:0,offsetX:20,offsetY:20},se=new Set(["pill","circle","square","rectangle"]),te=new Set(["accent","neutral","none"]);function ne(e){if(typeof e!="string")return;const a=/^\s*(-?\d+(?:\.\d+)?)\s*(?:px)?\s*$/i.exec(e);if(!a)return;const o=Number(a[1]);return Number.isFinite(o)?o:void 0}function F(e,a,o){const r=ne(e);return r===void 0?o:Math.min(a.max,Math.max(a.min,r))}function Y(e,a,o){if(typeof e!="string")return o;const r=e.trim().toLowerCase();return a.has(r)?r:o}function ie(e,a){if(typeof e!="string")return a;const o=e.trim().toLowerCase();return o==="true"||o==="1"?!0:o==="false"||o==="0"?!1:a}function q(e){const a=e.shape==="circle"||e.shape==="square";return{width:e.width,height:a?e.width:e.height}}function le(e,a,o,r){if(e==="pill")return r;const t=Math.max(0,Math.floor((Math.min(o.width,o.height)-U)/2)),l=a==="accent"?Math.min(oe,t):0;return Math.min(t,Math.max(l,r))}function ce(e){const a=e??{},o=d,r=Y(a[n.shape],se,o.shape),t=Y(a[n.background],te,o.background),l=F(a[n.width],i.width,o.width),f=F(a[n.height],i.height,o.height);return{shape:r,width:l,height:f,radius:F(a[n.radius],i.radius,o.radius),background:t,shadow:ie(a[n.shadow],o.shadow),padding:le(r,t,q({shape:r,width:l,height:f}),F(a[n.padding],i.padding,o.padding)),offsetX:F(a[n.offsetX],i.offsetX,o.offsetX),offsetY:F(a[n.offsetY],i.offsetY,o.offsetY)}}const N={accent:"var(--ai-accent)",neutral:"var(--ai-bg)",none:"transparent"};function de(e){const{width:a,height:o}=q(e),r=e.shape==="circle"?"50%":e.shape==="pill"?"calc(var(--es-demo-launcher-h) / 2)":`${e.radius}px`;return{"--es-demo-launcher-w":`${a}px`,"--es-demo-launcher-h":`${o}px`,"--es-demo-launcher-radius":r,"--es-demo-launcher-bg":N[e.background],"--es-demo-launcher-dot-ring":e.background==="none"?N.neutral:N[e.background],"--es-demo-launcher-shadow":e.shadow?"var(--ai-shadow)":"none","--es-demo-launcher-pad":`${e.padding}px`,"--es-demo-launcher-coin":`${re}`,"--es-demo-launcher-mark-min":`${U}px`,"--es-demo-launcher-x":`${e.offsetX}px`,"--es-demo-launcher-y":`${e.offsetY}px`}}const Fe={slug:"demo",name:"Demo",version:"0.1.0",slots:["header","main","footer"],cssVariables:{"--ai-accent":x},structure:{header:{id:"header",label:"Header",accepts:!0},main:{id:"main",label:"Main Content",accepts:!0},footer:{id:"footer",label:"Footer",accepts:!0}},defaultViews:[],requiredServices:["support-chat"],description:"Neutral, brand-adaptive shell for demo clones. Carries no mascot and no brand of its own: the logo, name and accent colour all come from the product, and the rest of the palette is derived around them so it stays legible for any input.",author:"E-Commerce Studio",packageName:"@ecommerce-studio/theme-demo",options:[{id:"colorScheme",type:"select",label:"Appearance mode",default:"auto",group:"Appearance",options:[{label:"Auto (match visitor)",value:"auto"},{label:"Light",value:"light"},{label:"Dark",value:"dark"}]},{id:"brandColor",type:"color",label:"Brand colour",default:x,cssVariable:"--ai-accent",group:"Colors"},{id:"launcherShape",type:"select",label:"Button shape",default:d.shape,cssVariable:n.shape,group:"Launcher",options:[{label:"Pill (wordmark on a chip)",value:"pill"},{label:"Circle",value:"circle"},{label:"Square",value:"square"},{label:"Rectangle",value:"rectangle"}]},{id:"launcherWidth",type:"range",label:"Width (side for circle / square)",default:d.width,unit:"px",cssVariable:n.width,group:"Launcher",...i.width},{id:"launcherHeight",type:"range",label:"Height (pill / rectangle)",default:d.height,unit:"px",cssVariable:n.height,group:"Launcher",...i.height},{id:"launcherRadius",type:"range",label:"Corner radius (square / rectangle)",default:d.radius,unit:"px",cssVariable:n.radius,group:"Launcher",...i.radius},{id:"launcherBackground",type:"select",label:"Background",default:d.background,cssVariable:n.background,group:"Launcher",options:[{label:"Brand colour",value:"accent"},{label:"Neutral",value:"neutral"},{label:"None (transparent)",value:"none"}]},{id:"launcherShadow",type:"toggle",label:"Shadow",default:d.shadow,cssVariable:n.shadow,group:"Launcher"},{id:"launcherPadding",type:"range",label:"Logo padding",default:d.padding,unit:"px",cssVariable:n.padding,group:"Launcher",...i.padding},{id:"launcherOffsetX",type:"range",label:"Distance from side",default:d.offsetX,unit:"px",cssVariable:n.offsetX,group:"Launcher",...i.offsetX},{id:"launcherOffsetY",type:"range",label:"Distance from bottom",default:d.offsetY,unit:"px",cssVariable:n.offsetY,group:"Launcher",...i.offsetY}],supports:{customCss:!1,customJs:!1,darkMode:!0,rtl:!1,views:!0}};function ue(e){const a=[e?.["--ai-accent"],e?.["--es-color-primary"]];for(const o of a)if(typeof o=="string"&&B(o))return o;return x}function he(e){const a=(e??"").trim().split(/\s+/).filter(Boolean);return a.length===0?"":a.slice(0,2).map(o=>[...o][0]??"").join("").toLocaleUpperCase()}function xe({brandName:e="",logoUrl:a,position:o="bottom-right",sidebarPosition:r="right",initialOpen:t=!1,views:l=[],activeView:f="",onViewChange:w=()=>{},children:p=null,cssVariables:m,t:u,colorScheme:C,builderMode:c=!1,unreadCount:g=0,onSettingsClick:S,onOpenChange:b,panelReadAloudControl:H}){const A=J(C)==="light"?"light":"dark",[_,M]=j.useState(t||c),y=j.useMemo(()=>ce(m),[m]),P=j.useMemo(()=>({...L({brandColor:ue(m),mode:A}),...de(y),...c?{width:"100%",height:"100%"}:{}}),[m,y,A,c]),I=()=>M(h=>{const v=!h;return b?.(v),v}),z=()=>{M(!1),b?.(!1)},D=o==="bottom-left",V=r!=="hidden"&&l.length>1,k=he(e);return s.jsxs("div",{className:["es-demo",`es-demo--${A}`].join(" "),style:P,children:[!c&&s.jsxs("button",{type:"button",className:["es-demo__launcher",`es-demo__launcher--${y.shape}`,`es-demo__launcher--bg-${y.background}`,D&&"es-demo__launcher--left",_&&"es-demo__launcher--hidden"].filter(Boolean).join(" "),onClick:I,"aria-label":u?.("floating.open_widget")??"Open chat widget",tabIndex:_?-1:0,"aria-hidden":_,children:[a?s.jsx("img",{className:"es-demo__launcher-logo",src:a,alt:""}):s.jsx("span",{className:"es-demo__launcher-monogram","aria-hidden":"true",children:k||"•"}),g>0&&s.jsx("span",{className:"es-demo__launcher-dot","aria-label":u?.("floating.unread",{count:g})??`${g} unread`})]}),s.jsxs("div",{className:["es-demo__panel",D&&!c&&"es-demo__panel--left",(_||c)&&"es-demo__panel--open"].filter(Boolean).join(" "),role:"dialog","aria-label":u?.("chat.widget_aria")??"Chat widget","aria-hidden":c?!1:!_,children:[s.jsxs("header",{className:"es-demo__header",children:[s.jsxs("div",{className:"es-demo__brand",children:[a?s.jsx("img",{className:"es-demo__brand-logo",src:a,alt:""}):k&&s.jsx("span",{className:"es-demo__brand-monogram","aria-hidden":"true",children:k}),e&&s.jsx("h1",{className:"es-demo__brand-name",children:e})]}),s.jsxs("div",{className:"es-demo__header-actions",children:[H,!c&&s.jsx("button",{type:"button",className:"es-demo__header-btn",onClick:z,"aria-label":u?.("header.close_widget")??"Close widget",children:s.jsx(me,{})})]})]}),s.jsxs("div",{className:["es-demo__body",V&&`es-demo__body--rail-${r}`].filter(Boolean).join(" "),children:[V&&s.jsx("nav",{className:`es-demo__rail es-demo__rail--${r}`,"aria-label":u?.("nav.views")??"Views",children:l.map(h=>{const v=K(h.icon||h.slug),$=h.slug===f;return s.jsxs("button",{type:"button",className:["es-demo__rail-item",$&&"es-demo__rail-item--active"].filter(Boolean).join(" "),onClick:()=>w(h.slug),"aria-current":$?"page":void 0,title:h.label,children:[v?s.jsx(v,{size:20}):null,s.jsx("span",{className:"es-demo__rail-label",children:h.label})]},h.slug)})}),s.jsx("main",{className:"es-demo__content",style:{containerName:"es-slot",containerType:"inline-size"},children:p})]})]})]})}function me({size:e=20}){return s.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"m6 9 6 6 6-6"})})}export{x as DEFAULT_BRAND,d as LAUNCHER_DEFAULTS,i as LAUNCHER_LIMITS,n as LAUNCHER_VARS,Q as TEXT_FLOOR,xe as ThemeShell,be as darkVariables,L as deriveDemoPalette,ae as hoverStep,X as inkOn,de as launcherRootStyle,ge as lightVariables,Fe as manifest,he as monogram,ce as resolveLauncherSettings};
|
|
2
|
+
//# sourceMappingURL=index--pcCOJWb-BzpgdoE8.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{j as e,e as u}from"../nexly.js";const y={slug:"demo-shipping-returns",name:"DEMO — Contact details",version:"0.1.0",category:"content",configSchema:{properties:{rows:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},note:{type:"string"}},required:["label","value"]},default:[]}}},defaultConfig:{rows:[]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main","sidebar"]};function _(t){return Array.isArray(t)?t.flatMap(s=>{if(typeof s!="object"||s===null)return[];const n=s,d=typeof n.label=="string"?n.label.trim():"",a=typeof n.value=="string"?n.value.trim():"";if(!d||!a)return[];const c=typeof n.note=="string"?n.note.trim():"";return[{label:d,value:a,...c?{note:c}:{}}]}):[]}function i(t){if(typeof t!="string")return null;const s=t.trim();return s.length>0?s:null}function x(t){const s=i(t);if(!s||/\s/.test(s))return null;const n=s.indexOf("@");return n>0&&n<s.length-1?s:null}function j(t){const s=i(t);return!s||!/[0-9]/.test(s)?null:s}function f(t){return t.split(/\s+/).filter(s=>/[\p{L}\p{N}]/u.test(s)).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function v({data:t,config:s,i18n:n}){const d=n?.t??(o=>o),a=t?.rows?t:s??{},c=_(a.rows),m=i(a.company),p=i(a.tagline),r=x(a.email),l=j(a.phone),h=i(a.note);return!m&&!r&&!l&&c.length===0?e.jsx(u,{blockType:"demo-shipping-returns",children:e.jsx("div",{className:"es-block__body",children:e.jsx("div",{className:"es-block__empty",children:d("demoTerms.empty")})})}):e.jsx(u,{blockType:"demo-shipping-returns",children:e.jsxs("div",{className:"es-block__body es-democontact",children:[e.jsxs("div",{className:"es-democontact__card",children:[m&&e.jsxs("div",{className:"es-democontact__identity",children:[e.jsx("div",{className:"es-democontact__coin","aria-hidden":"true",children:f(m)}),e.jsxs("div",{className:"es-democontact__names",children:[e.jsx("p",{className:"es-democontact__company",children:m}),p&&e.jsx("p",{className:"es-democontact__tagline",children:p})]})]}),c.length>0&&e.jsx("dl",{className:"es-democontact__grid",children:c.map(o=>e.jsxs("div",{className:"es-democontact__cell",children:[e.jsx("dt",{className:"es-democontact__label",children:o.label}),e.jsx("dd",{className:"es-democontact__value",children:o.value}),o.note&&e.jsx("dd",{className:"es-democontact__note",children:o.note})]},o.label))}),(r||l)&&e.jsxs("div",{className:"es-democontact__actions",children:[r&&e.jsxs("a",{className:"es-democontact__action",href:`mailto:${r}`,children:[e.jsxs("svg",{className:"es-democontact__glyph",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2.5",y:"4.5",width:"19",height:"15",rx:"2.5"}),e.jsx("path",{d:"M3 7l9 6 9-6"})]}),e.jsx("span",{className:"es-democontact__action-text",children:r})]}),l&&e.jsxs("a",{className:"es-democontact__action",href:`tel:${l.replace(/\s+/g,"")}`,children:[e.jsx("svg",{className:"es-democontact__glyph",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M6.5 3.5h3l1.5 4-2 1.5a11 11 0 006 6l1.5-2 4 1.5v3a2 2 0 01-2.2 2A17 17 0 014.5 5.7 2 2 0 016.5 3.5z"})}),e.jsx("span",{className:"es-democontact__action-text",children:l})]})]})]}),h&&e.jsxs("div",{className:"es-democontact__reassurance",children:[e.jsxs("svg",{className:"es-democontact__glyph",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 3l7.5 3v5.5c0 4.6-3.1 8.4-7.5 9.5-4.4-1.1-7.5-4.9-7.5-9.5V6z"}),e.jsx("path",{d:"M9 12.2l2.2 2.2 4-4.2"})]}),e.jsx("p",{className:"es-democontact__reassurance-text",children:h})]})]})})}export{v as Component,y as manifest};
|
|
2
|
+
//# sourceMappingURL=index-7yhyghzH-BlFXtfQb.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{j as e,e as a}from"../nexly.js";const t={slug:"user-profile",name:"User Profile",version:"1.0.0",category:"content",configSchema:{},defaultConfig:{},dataContract:{serviceSlug:null,inputSchema:{type:"object",properties:{}}},fields:[],sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main"]};function c({i18n:r,auth:l}){const i=r?.t??(d=>d);if(!l?.isAuthenticated||!l.user)return e.jsx(a,{blockType:"user-profile",children:e.jsx("div",{className:"es-widget__profile",children:e.jsx("div",{className:"es-widget__profile-empty",children:e.jsx("p",{children:i("profile.not_logged_in")})})})});const{user:s}=l;return e.jsx(a,{blockType:"user-profile",children:e.jsxs("div",{className:"es-widget__profile",children:[e.jsx("div",{className:"es-widget__panel-header",children:e.jsx("div",{className:"es-widget__panel-header-left",children:e.jsx("h2",{className:"es-widget__panel-header-title",children:i("profile.title")})})}),e.jsx("div",{className:"es-widget__profile-body",children:e.jsxs("div",{className:"es-widget__profile-info",children:[s.name&&e.jsxs("div",{className:"es-widget__profile-field",children:[e.jsx("span",{className:"es-widget__profile-field-label",children:i("profile.name")}),e.jsx("span",{className:"es-widget__profile-field-value",children:s.name})]}),s.email&&e.jsxs("div",{className:"es-widget__profile-field",children:[e.jsx("span",{className:"es-widget__profile-field-label",children:i("profile.email")}),e.jsx("span",{className:"es-widget__profile-field-value",children:s.email})]})]})})]})})}export{c as Component,t as manifest};
|
|
2
|
+
//# sourceMappingURL=index-BCxeWwto-B9PuY2Gx.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r as s,j as e,
|
|
1
|
+
import{r as s,j as e,L as Re,K as te,e as it}from"../nexly.js";import{x as ze,s as Oe,c as Ue,a as We}from"./allowed-elements-C0OfX2zF-DIBV8lKu.js";import{H as ot,P as ct}from"./use-deferred-rating-XlgCUwcY-DDVOwURi.js";import{r as Fe}from"./inert-assistant-components-B6Cx9pG5-DWb6n3Yq.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";const Nt={slug:"chat",name:"Chat",version:"1.0.0",category:"interactive",requiredService:"chat-bot",configSchema:{properties:{placeholder:{type:"string",default:""},welcomeMessage:{type:"string",default:""}}},defaultConfig:{placeholder:"",welcomeMessage:""},dataContract:{serviceSlug:"chat-bot",inputSchema:{type:"object",properties:{message:{type:"string",description:"AI response text"},suggestions:{type:"array",items:{type:"string"},description:"Suggested follow-up questions"}},required:["message"]},previewDataOverride:{message:"Hello! I can help you find the perfect product. What are you looking for today?",suggestions:["Show me trending items","Compare prices for me","Find deals under $50"]}},fields:[{id:"placeholder",type:"localized-text",label:"Input placeholder",default:"",placeholder:'Leave empty to use translated default (e.g. "Type a message...")',group:"Content"},{id:"welcomeMessage",type:"localized-text",label:"Welcome message",default:"",placeholder:'Leave empty to use translated default (e.g. "Hi! How can I help you?")',group:"Content"},{id:"showSuggestions",type:"toggle",label:"Show suggestions",default:!0,group:"Behavior"}],events:{emits:[{name:"chat:messageSent",description:"User sent a message"},{name:"chat:messageReceived",description:"AI response received"}],listens:[{name:"chat:clearHistory",description:"Clear chat history"}]},sizing:{minWidth:240,preferredHeight:"fill",scrollable:!0},supportedPlacements:["main","fullscreen"]},lt=["audio/webm;codecs=opus","audio/webm","audio/mp4"];function ut(){return typeof navigator>"u"||typeof window>"u"?!1:typeof navigator.mediaDevices?.getUserMedia=="function"&&typeof window.MediaRecorder<"u"}function dt(){if(typeof window>"u"||typeof window.MediaRecorder>"u")return;const o=typeof window.MediaRecorder.isTypeSupported=="function";for(const i of lt)if(!o||window.MediaRecorder.isTypeSupported(i))return i}function ht({baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w,t:b,disabled:y=!1,streaming:j,voiceStream:g,baseText:U,onText:S}){const[r]=s.useState(ut),[u,m]=s.useState("idle"),[Z,H]=s.useState(null),[f,D]=s.useState("idle"),I=!!(j&&g&&U&&S),$=s.useRef(null),E=s.useRef(null),k=s.useRef([]),F=s.useRef(!0);s.useEffect(()=>()=>{F.current=!1},[]);const d=s.useRef({baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w});s.useEffect(()=>{d.current={baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w}},[o,i,n,p,w]);const c=s.useCallback(()=>{E.current?.getTracks().forEach(_=>_.stop()),E.current=null,$.current=null,k.current=[]},[]);s.useEffect(()=>c,[c]);const h=s.useRef(()=>{});h.current=()=>{I&&(f==="connecting"||f==="listening")&&g?.stop()},s.useEffect(()=>()=>h.current(),[]);const T=s.useCallback(async _=>{const{baseUrl:V,apiKey:C,jwt:M,language:v,onTranscript:J}=d.current,K=new FormData;K.append("audio",_,"recording.webm"),K.append("language",v);const Y={};C&&(Y["X-API-Key"]=C),M&&(Y.Authorization=`Bearer ${M}`);const ee=await fetch(`${V}/api/widget/transcribe`,{method:"POST",headers:Y,credentials:"include",body:K});if(!ee.ok){const ae=new Error(`HTTP ${ee.status}`);throw ae.status=ee.status,ae}const le=await ee.json();J(le.text??"")},[]),z=s.useCallback(async()=>{H(null);let _;try{_=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{m("error"),H("voice.permission_denied");return}const V=dt();let C;try{C=V?new MediaRecorder(_,{mimeType:V}):new MediaRecorder(_)}catch{_.getTracks().forEach(M=>M.stop()),m("error"),H("voice.error_generic");return}E.current=_,$.current=C,k.current=[],C.ondataavailable=M=>{M.data&&M.data.size>0&&k.current.push(M.data)},C.onstop=async()=>{const M=C.mimeType||V||"audio/webm",v=new Blob(k.current,{type:M});if(c(),v.size===0){m("idle");return}m("transcribing");try{if(await T(v),!F.current)return;m("idle"),H(null)}catch(J){if(!F.current)return;const K=J.status;m("error"),H(K===413?"voice.error_too_large":"voice.error_generic")}},C.start(),m("recording")},[c,T]),ce=s.useCallback(()=>{const _=$.current;_&&_.state!=="inactive"?_.stop():(c(),m("idle"))},[c]),se=s.useCallback(()=>{r&&(I?f==="connecting"||f==="listening"?(g.stop(),D("idle")):(H(null),g.start({language:p,baseText:U,onText:S,onState:_=>D(_),onError:_=>{H(_),D("error")}})):u==="recording"?ce():(u==="idle"||u==="error")&&z())},[r,I,f,u,p,U,S,g,z,ce]);if(!r)return null;const L=I?f==="connecting"||f==="listening":u==="recording",R=!I&&u==="transcribing",ge=I?f==="error":u==="error",q=b(L?"voice.stop":"voice.start"),me=Z?b(Z):R?b("voice.transcribing"):q,Q=["es-chat__mic",L&&"es-chat__mic--recording",R&&"es-chat__mic--transcribing",ge&&"es-chat__mic--error"].filter(Boolean).join(" ");return e.jsx("button",{type:"button",className:Q,onClick:se,disabled:R||y,"aria-label":q,"aria-pressed":L,title:me,children:R?e.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"es-chat__mic-spinner","aria-hidden":"true",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}):L?e.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}):e.jsxs("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),e.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})}function pt({size:o=16}){return e.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]})}function gt({size:o=18}){return e.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})]})}function mt({size:o=13}){return e.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m2 2 20 20"}),e.jsx("path",{d:"M8.5 8.5 7 10a5 5 0 0 0 7 7l1.5-1.5"}),e.jsx("path",{d:"M15.5 15.5 17 14a5 5 0 0 0-7-7l-1.5 1.5"})]})}function ft({value:o,onChange:i,disabled:n,t:p}){const[w,b]=s.useState(null),y=o??0,j=!n&&w!==null?w:y;return e.jsxs("div",{className:"es-chat__rating-group",children:[e.jsx("div",{className:"es-chat__rating",role:"radiogroup","aria-label":p("support_chat.rate_aria"),onMouseLeave:()=>!n&&b(null),children:[1,2,3,4,5].map(g=>{const U=g<=j;return e.jsx("button",{type:"button",role:"radio","aria-checked":g===y,"aria-label":p("support_chat.rate_star",{count:g}),disabled:n,onMouseEnter:()=>!n&&b(g),onFocus:()=>!n&&b(g),onBlur:()=>!n&&b(null),onClick:()=>!n&&i?.(g),className:`es-chat__rating-star${U?" es-chat__rating-star--filled":""}${n?" es-chat__rating-star--disabled":""}`,children:e.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:U?"currentColor":"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})},g)})}),e.jsx("span",{className:"es-chat__rating-label","aria-live":"polite",children:j>0?p(`support_chat.rate_label_${j}`):""})]})}function De(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}const _t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,bt=45e3,yt=/https?:\/\/\S+/i;function xt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function jt(o){let i=null;const n=[];for(const p of o.split(`
|
|
2
2
|
`))p.startsWith("event:")?i=p.slice(6).trim():p.startsWith("data:")&&n.push(p.slice(5).trimStart());return{event:i,data:n.join(`
|
|
3
|
-
`)}}function It({config:o,actions:i,baseUrl:n,i18n:p,auth:w,externalContext:b,productId:y,sessionId:j,sessionMessages:g,readOnly:U}){const S=U===!0,r=p?.t??(t=>t),u=b?.apiKey??"",m=p?.currentLanguage??"en",
|
|
3
|
+
`)}}function It({config:o,actions:i,baseUrl:n,i18n:p,auth:w,externalContext:b,productId:y,sessionId:j,sessionMessages:g,readOnly:U}){const S=U===!0,r=p?.t??(t=>t),u=b?.apiKey??"",m=p?.currentLanguage??"en",Z=Re(o.placeholder,m,{t:r,fallbackKey:"chat.input_placeholder",enDefault:"Type a message..."}),H=Re(o.welcomeMessage,m,{t:r,fallbackKey:"chat.empty_state",enDefault:["Hi! How can I help you?","Hello! How can I help you?"]}),f=typeof o._draft=="string"?o._draft:void 0,D=typeof o._draftContext=="string"?o._draftContext:void 0,I=o._autoSend===!0,$=Array.isArray(o._quickChips)?o._quickChips:[],E=JSON.stringify($),k=s.useRef(w?.jwt);s.useEffect(()=>{k.current=w?.jwt},[w?.jwt]);const F=b?.voice,d=!!F?.enabled&&(F?.languages??[]).includes(m),[c,h]=s.useState(()=>g?.map(t=>({id:t.id,role:t.role,text:t.content}))??[]),[T,z]=s.useState(""),[ce,se]=s.useState([]),[L,R]=s.useState(!1),[ge,q]=s.useState(null),[me,Q]=s.useState(!1),{containerRef:_,isPinned:V,scrollToBottom:C,stickToBottom:M}=ot(),v=s.useRef(null),J=s.useRef(null),K=s.useRef(j??De()),Y=s.useRef(g&&g.length>0?j??null:null),ee=s.useRef(null),le=s.useRef(void 0),ae=s.useRef(!1);s.useEffect(()=>{i.emit("chat:session",{sessionId:K.current})},[i]),s.useEffect(()=>{M()},[c,L,M]);const be=s.useCallback(()=>{const t=v.current;if(!t)return;const a=t.closest(".es-block")?.clientHeight??0,l=a>0?Math.round(a*.4):120;t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,l)}px`,t.style.overflowY=t.scrollHeight>l?"auto":"hidden"},[]);s.useLayoutEffect(()=>{be()},[T,be]);const re=s.useCallback(()=>{ae.current&&(ae.current=!1,i.emit("chat:draftConsumed",void 0))},[i]),ne=s.useCallback(async t=>{const a=t.trim();if(!a||L)return;re();const l=le.current;le.current=void 0,se([]),Q(!1),J.current?.abort(),J.current=new AbortController;const A=yt.test(a),B=`user-${Date.now()}`,X={id:B,role:"user",text:a,...A?{linkStatus:"reading",linkFailedCount:0}:{}};h(x=>[...x,X]);const O=()=>{A&&h(x=>x.map(W=>W.id===B&&W.linkStatus==="reading"?{...W,linkStatus:"done"}:W))};C(),z(""),R(!0),q(null),v.current&&(v.current.style.height="auto");const N=c.map(x=>({role:x.role,content:x.text})),Te=await w?.ensureValidToken?.()??k.current,st={"Content-Type":"application/json",...u?{"X-API-Key":u}:{},...Te?{Authorization:`Bearer ${Te}`}:{}},ue=`assistant-${Date.now()}`;let ie="",Le=!1,xe=!1;const Ae=()=>{xe||(xe=!0,q(ue),h(x=>[...x,{id:ue,role:"assistant",text:ie}]))},Be=K.current,Pe=_t.test(Be)?Be:void 0,He=xt(),[je,ke]=await te(fetch(`${n}/api/widget/chat-bot/stream`,{method:"POST",headers:st,body:JSON.stringify({text:a,history:N,...Pe?{sessionId:Pe}:{},...y?{productId:y}:{},...He?{timeZone:He}:{},...l?{blockContext:l}:{}}),signal:J.current.signal}));if(ke){if(ke instanceof Error&&ke.name==="AbortError"){O();return}R(!1),q(null),O(),h(x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}]);return}if(!je.ok||!je.body){R(!1),q(null),O(),h(x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}]);return}const at=je.body.getReader(),rt=new TextDecoder;let de="",_e;const Me=()=>{_e&&clearTimeout(_e),_e=void 0},Ke=()=>{Me(),_e=setTimeout(()=>{J.current?.abort(),R(!1),q(null),O()},bt)},[,ve]=await te((async()=>{for(Ke();;){const{done:x,value:W}=await at.read();if(Ke(),x)break;de+=rt.decode(W,{stream:!0});let we;for(;(we=de.indexOf(`
|
|
4
4
|
|
|
5
|
-
`))!==-1;){const nt=de.slice(0,we);de=de.slice(we+2);const{event:he,data:pe}=jt(nt);if(!(!he||!pe)){if(he==="start"){const P=JSON.parse(pe);P.sessionId&&P.sessionId!==R.current&&(R.current=P.sessionId,Q.current=P.sessionId,i.emit("chat:session",{sessionId:P.sessionId}))}else if(he==="token"){const P=JSON.parse(pe);ie+=P.value??"",Ae();const Se=ie;h(Ce=>Ce.map(Y=>Y.id===ue?{...Y,text:Se}:Y))}else if(he==="meta"){const P=JSON.parse(pe);Le=!0;const Se=P.assistantMessage?.content??ie,Ce=Array.isArray(P.pastedLinks)?P.pastedLinks.filter(Y=>Y.status&&Y.status!=="ok").length:0;Ae(),h(Y=>Y.map(oe=>oe.id===ue?{...oe,text:Se,promptLogId:P.logId}:oe.id===B&&oe.linkStatus==="reading"?{...oe,linkStatus:"done",linkFailedCount:Ce}:oe))}else if(he==="error"){const P=JSON.parse(pe);throw new Error(P.message??"Stream error")}}}}if(!Le&&!ie)throw new Error("Stream ended before completion")})());if(Me(),D(!1),q(null),O(),ve){if(ve instanceof Error&&ve.name==="AbortError"||ie)return;h(xe?x=>x.map(W=>W.id===ue?{...W,text:r("chat.error_message"),promptLogId:void 0}:W):x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}])}},[L,i,c,r,u,n,y,C,w,re]),ye=s.useCallback(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop(),ne(T)},[ne,T,b]);s.useEffect(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop()},[j]);const qe=s.useCallback(t=>{if(t.autoSend){ne(t.message);return}se([]),K(""),re(),v.current&&(v.current.style.height="auto",v.current.focus())},[ne,re]);s.useEffect(()=>{if(!(f!==void 0||$.length>0))return;const t=`${f}${z??""}${String(I)}${E}`;if(ee.current!==t){if(ee.current=t,ae.current=!0,le.current=z,I&&f!==void 0){se([]),ne(f);return}se($),f!==void 0&&(K(f),v.current&&v.current.focus())}},[f,z,I,E,ne]);const Je=s.useCallback(t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ye())},[ye]),Xe=s.useCallback(t=>{re(),K(t.target.value)},[re]),Qe=s.useCallback(t=>{const a=t.trim();a&&(K(l=>l?`${l} ${a}`:a),requestAnimationFrame(()=>{v.current?.focus()}))},[]);s.useEffect(()=>()=>J.current?.abort(),[]),s.useEffect(()=>i.on("chat:clearHistory",t=>{const a=t;h([]),Z(!1);const l=a?.sessionId??ze();R.current=l,Q.current=l,i.emit("chat:session",{sessionId:l})}),[i]);const Ye=s.useCallback(async()=>{const t=k.current,[a,l]=await te(fetch(`${n}/api/chat/sessions/new`,{method:"POST",headers:{...u?{"X-API-Key":u}:{},...t?{Authorization:`Bearer ${t}`}:{}}}));if(!l&&a.ok){const[A,B]=await te(a.json());if(!B&&A.success&&A.data?.sessionId){i.emit("chat:clearHistory",{sessionId:A.data.sessionId});return}}i.emit("chat:clearHistory",void 0)},[i,u,n]),Ge=s.useCallback(()=>{i.emit("chat:showHistory",void 0)},[i]),fe=s.useCallback(async t=>{R.current=t,i.emit("chat:session",{sessionId:t}),h([]),Z(!1),D(!0);const a=k.current,[l,A]=await te(fetch(`${n}/api/chat/sessions/${encodeURIComponent(t)}/messages?limit=50`,{headers:{...u?{"X-API-Key":u}:{},...a?{Authorization:`Bearer ${a}`}:{}}}));if(D(!1),A||!l.ok){Z(!0);return}const[B,X]=await te(l.json());if(X){Z(!0);return}const O=B.data?.messages??[];h(O.map(N=>({id:N.id,role:N.role,text:N.content,promptLogId:N.promptLogId??void 0,rating:N.userScore??null}))),Q.current=t,C("auto")},[i,u,n,C]);s.useEffect(()=>i.on("chat:select-session",t=>{const{sessionId:a}=t;!a||a===Q.current||fe(a)}),[i,fe]);const Ze=s.useCallback(()=>{fe(R.current)},[fe]),Ie=s.useRef(c);s.useEffect(()=>{Ie.current=c},[c]);const Ve=s.useCallback(({messageId:t,rating:a},{keepalive:l})=>{const A=Ie.current.find(B=>B.id===t);!A||!A.promptLogId||!k.current||(h(B=>B.map(X=>X.id===t?{...X,rating:a,ratingPending:!0}:X)),(async()=>{const[B,X]=await te(fetch(`${n}/api/widget/ai-feedback`,{method:"POST",keepalive:l,headers:{"Content-Type":"application/json",...u?{"X-API-Key":u}:{},Authorization:`Bearer ${k.current}`},body:JSON.stringify({promptLogId:A.promptLogId,rating:a})}));if(X||!(B.ok||B.status===409)){h(O=>O.map(N=>N.id===t?{...N,rating:null,ratingPending:!1}:N));return}h(O=>O.map(N=>N.id===t?{...N,rating:a,ratingPending:!1}:N))})())},[u,n]),{pending:$e,rate:Ee,undo:et}=ct({submit:Ve}),tt=s.useCallback((t,a)=>{const l=c.find(A=>A.id===t);!l||!l.promptLogId||l.ratingPending||!k.current||Ee(t,a)},[c,Ee]);return e.jsxs(it,{blockType:"chat",children:[e.jsxs("div",{className:"es-chat__header",children:[e.jsx("span",{className:"es-chat__header-title",children:r("chat.chat")}),e.jsxs("div",{className:"es-chat__header-actions",children:[e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.new_session_button"),title:r("chat.new_session_button"),onClick:Ye,children:e.jsx(gt,{size:18})}),e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.history_button"),title:r("chat.history_button"),onClick:Ge,children:e.jsx(pt,{size:16})})]})]}),e.jsxs("div",{className:"es-block__body es-chat__body",children:[e.jsxs("div",{className:"es-chat__messages",ref:_,children:[c.length===0&&!me&&!L&&e.jsx("div",{className:"es-chat__welcome",children:H}),me&&e.jsxs("div",{className:"es-chat__load-error",role:"alert",children:[e.jsx("span",{className:"es-chat__load-error-text",children:r("chat.load_session_error")}),e.jsx("button",{type:"button",className:"es-chat__load-error-retry",onClick:Ze,children:r("chat.retry")})]}),c.map(t=>e.jsxs("div",{className:`es-chat__bubble es-chat__bubble--${t.role}${t.id===ge?" es-chat__bubble--streaming":""}`,children:[t.role==="assistant"?e.jsx("div",{className:"es-chat__bubble-text es-chat__bubble-text--md",children:e.jsx(Ke,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:a=>We(a)??"",transformImageUri:()=>"",components:Fe,children:t.text})}):e.jsx("div",{className:"es-chat__bubble-text",children:t.text}),t.role==="user"&&t.linkStatus==="reading"&&e.jsxs("div",{className:"es-chat__link-status",role:"status",children:[e.jsx("span",{className:"es-chat__link-status-spinner","aria-hidden":"true"}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.reading_link")})]}),t.role==="user"&&t.linkStatus==="done"&&(t.linkFailedCount??0)>0&&e.jsxs("div",{className:"es-chat__link-status es-chat__link-status--failed",children:[e.jsx(mt,{size:13}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.link_unreadable")})]}),t.role==="assistant"&&t.promptLogId&&k.current&&(()=>{const a=$e?.messageId===t.id?$e.rating:null;return e.jsxs("div",{className:"es-chat__feedback",children:[e.jsx("span",{className:"es-chat__feedback-label",children:t.rating&&a===null?r("chat.feedback_thanks"):r("support_chat.rate_aria")}),e.jsx(ft,{value:a??t.rating??null,onChange:l=>tt(t.id,l),disabled:a===null&&(!!t.rating||t.ratingPending),t:r}),a!==null&&e.jsxs("div",{className:"es-chat__rating-undo",role:"status",children:[e.jsx("span",{className:"es-chat__rating-undo-text",children:r("support_chat.rating_undo_toast",{rating:a})}),e.jsx("button",{type:"button",className:"es-chat__rating-undo-btn",onClick:et,children:r("support_chat.rating_undo_button")})]})]})})()]},t.id)),L&&ge===null&&e.jsxs("div",{className:"es-chat__typing","aria-label":r("chat.typing_aria"),children:[e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"})]})]}),!V&&c.length>0&&e.jsxs("button",{type:"button",className:"es-chat__jump",onClick:()=>C(),"aria-label":r("chat.jump_to_latest"),title:r("chat.jump_to_latest"),children:[e.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"m19 12-7 7-7-7"})]}),e.jsx("span",{className:"es-chat__jump-label",children:r("chat.jump_to_latest")})]})]}),e.jsxs("div",{className:"es-block__footer es-chat__footer",children:[ce.length>0&&e.jsx("div",{className:"es-chat__chips",role:"group","aria-label":r("chat.quick_actions_aria"),children:ce.map((t,a)=>e.jsx("button",{type:"button",className:"es-chat__chip",onClick:()=>qe(t),disabled:L||S,children:t.labelKey?r(t.labelKey):t.label},`${t.labelKey??t.label}-${a}`))}),e.jsx("div",{className:"es-chat__disclaimer",children:r("chat.disclaimer")}),e.jsxs("div",{className:"es-chat__input-row",children:[e.jsx("textarea",{ref:v,className:"es-chat__textarea",value:T,onChange:Xe,onKeyDown:Je,placeholder:G,rows:1,maxLength:2e3,disabled:L||S,"aria-label":r("chat.input_aria")}),d&&!S&&e.jsx(ht,{baseUrl:n,apiKey:u,jwt:k.current,language:m,onTranscript:Qe,t:r,streaming:F?.streaming,voiceStream:b?.voiceStream,baseText:()=>T,onText:t=>{if(K(t.length>2e3?t.slice(0,2e3):t),t.length>=2e3){const a=b?.voiceStream;a?.getState&&a.getState()!=="idle"&&a.stop()}requestAnimationFrame(()=>{be(),v.current?.focus()})}}),e.jsx("button",{className:"es-chat__send",onClick:ye,disabled:!T.trim()||L||S,type:"button","aria-label":r("chat.send_aria"),children:L?e.jsx("span",{className:"es-chat__send-loading","aria-hidden":"true",children:"⋯"}):e.jsx("span",{"aria-hidden":"true",children:"➤"})})]})]})]})}const Ne=50;function $t({sessionId:o,baseUrl:i,jwt:n,isOpen:p,onToggle:w,i18n:b}){const y=b?.t??(d=>d),j=p!==void 0,[g,U]=s.useState(!1),S=j?p:g,[r,u]=s.useState([]),[m,G]=s.useState(null),[H,f]=s.useState(!1),[z,I]=s.useState(null),$=s.useRef(!1),E=s.useCallback(async d=>{if(n){f(!0),I(null);try{const c=`${i}/api/chat/sessions/${o}/messages?limit=${Ne}&offset=${d}`,h=await fetch(c,{headers:{Authorization:`Bearer ${n}`},credentials:"include"});if(!h.ok)throw new Error(`HTTP ${h.status}`);const T=await h.json();if(!T.success)throw new Error(y("chat_history.error"));u(K=>d===0?T.data.messages:[...T.data.messages,...K]),G(T.data.pagination)}catch(c){I(c instanceof Error?c.message:y("chat_history.error"))}finally{f(!1)}}},[i,n,o,y]),k=s.useCallback(()=>{j?w?.():U(d=>{const c=!d;return c&&!$.current&&($.current=!0,E(0)),c})},[j,w,E]),F=s.useCallback(()=>{if(!m)return;const d=Math.max(0,m.total-m.offset-Ne-Ne);E(d)},[E,m]);return s.useEffect(()=>{j&&S&&!$.current&&n&&($.current=!0,E(0))},[j,S,n,E]),s.useEffect(()=>{$.current=!1,u([]),G(null),I(null),S&&n&&($.current=!0,E(0))},[o,n]),e.jsxs("div",{className:"es-chat-history",children:[!j&&e.jsxs("button",{className:"es-chat-history__toggle",type:"button","aria-expanded":S,onClick:k,disabled:!n,children:[e.jsx("span",{className:"es-chat-history__toggle-icon",children:S?"▲":"▼"}),y("chat_history.toggle")]}),S&&e.jsxs("div",{className:"es-chat-history__panel",children:[H&&e.jsxs("div",{className:"es-chat-history__loading",role:"status","aria-label":y("chat_history.loading_aria"),children:[e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"})]}),z&&!H&&e.jsx("div",{className:"es-chat-history__error",role:"alert",children:z}),!H&&!z&&e.jsxs(e.Fragment,{children:[m?.hasMore&&e.jsx("button",{className:"es-chat-history__load-more",type:"button",onClick:F,"aria-label":y("chat_history.load_older_aria"),children:y("chat_history.load_older")}),e.jsxs("div",{className:"es-chat-history__messages",role:"log","aria-live":"polite","aria-label":y("chat_history.panel_aria"),children:[r.length===0&&e.jsx("div",{className:"es-chat-history__empty",children:y("chat_history.empty")}),r.filter(d=>d.role!=="system").map(d=>e.jsx("div",{className:`es-chat-history__bubble es-chat-history__bubble--${d.role}`,children:d.role==="assistant"?e.jsx("div",{className:"es-chat-history__bubble-md",children:e.jsx(Ke,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:c=>We(c)??"",transformImageUri:()=>"",components:Fe,children:d.content})}):d.content},d.id))]})]})]})]})}export{$t as ChatHistoryBlock,It as Component,Nt as manifest};
|
|
6
|
-
//# sourceMappingURL=index-
|
|
5
|
+
`))!==-1;){const nt=de.slice(0,we);de=de.slice(we+2);const{event:he,data:pe}=jt(nt);if(!(!he||!pe)){if(he==="start"){const P=JSON.parse(pe);P.sessionId&&P.sessionId!==K.current&&(K.current=P.sessionId,Y.current=P.sessionId,i.emit("chat:session",{sessionId:P.sessionId}))}else if(he==="token"){const P=JSON.parse(pe);ie+=P.value??"",Ae();const Se=ie;h(Ce=>Ce.map(G=>G.id===ue?{...G,text:Se}:G))}else if(he==="meta"){const P=JSON.parse(pe);Le=!0;const Se=P.assistantMessage?.content??ie,Ce=Array.isArray(P.pastedLinks)?P.pastedLinks.filter(G=>G.status&&G.status!=="ok").length:0;Ae(),h(G=>G.map(oe=>oe.id===ue?{...oe,text:Se,promptLogId:P.logId}:oe.id===B&&oe.linkStatus==="reading"?{...oe,linkStatus:"done",linkFailedCount:Ce}:oe))}else if(he==="error"){const P=JSON.parse(pe);throw new Error(P.message??"Stream error")}}}}if(!Le&&!ie)throw new Error("Stream ended before completion")})());if(Me(),R(!1),q(null),O(),ve){if(ve instanceof Error&&ve.name==="AbortError"||ie)return;h(xe?x=>x.map(W=>W.id===ue?{...W,text:r("chat.error_message"),promptLogId:void 0}:W):x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}])}},[L,i,c,r,u,n,y,C,w,re]),ye=s.useCallback(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop(),ne(T)},[ne,T,b]);s.useEffect(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop()},[j]);const qe=s.useCallback(t=>{if(t.autoSend){ne(t.message);return}se([]),z(""),re(),v.current&&(v.current.style.height="auto",v.current.focus())},[ne,re]);s.useEffect(()=>{if(!(f!==void 0||$.length>0))return;const t=`${f}${D??""}${String(I)}${E}`;if(ee.current!==t){if(ee.current=t,ae.current=!0,le.current=D,I&&f!==void 0){se([]),ne(f);return}se($),f!==void 0&&(z(f),v.current&&v.current.focus())}},[f,D,I,E,ne]);const Je=s.useCallback(t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ye())},[ye]),Xe=s.useCallback(t=>{re(),z(t.target.value)},[re]),Ye=s.useCallback(t=>{const a=t.trim();a&&(z(l=>l?`${l} ${a}`:a),requestAnimationFrame(()=>{v.current?.focus()}))},[]);s.useEffect(()=>()=>J.current?.abort(),[]),s.useEffect(()=>i.on("chat:clearHistory",t=>{const a=t;h([]),Q(!1);const l=a?.sessionId??De();K.current=l,Y.current=l,i.emit("chat:session",{sessionId:l})}),[i]);const Ge=s.useCallback(async()=>{const t=k.current,[a,l]=await te(fetch(`${n}/api/chat/sessions/new`,{method:"POST",headers:{...u?{"X-API-Key":u}:{},...t?{Authorization:`Bearer ${t}`}:{}}}));if(!l&&a.ok){const[A,B]=await te(a.json());if(!B&&A.success&&A.data?.sessionId){i.emit("chat:clearHistory",{sessionId:A.data.sessionId});return}}i.emit("chat:clearHistory",void 0)},[i,u,n]),Ze=s.useCallback(()=>{i.emit("chat:showHistory",void 0)},[i]),fe=s.useCallback(async t=>{K.current=t,i.emit("chat:session",{sessionId:t}),h([]),Q(!1),R(!0);const a=k.current,[l,A]=await te(fetch(`${n}/api/chat/sessions/${encodeURIComponent(t)}/messages?limit=50`,{headers:{...u?{"X-API-Key":u}:{},...a?{Authorization:`Bearer ${a}`}:{}}}));if(R(!1),A||!l.ok){Q(!0);return}const[B,X]=await te(l.json());if(X){Q(!0);return}const O=B.data?.messages??[];h(O.map(N=>({id:N.id,role:N.role,text:N.content,promptLogId:N.promptLogId??void 0,rating:N.userScore??null}))),Y.current=t,C("auto")},[i,u,n,C]);s.useEffect(()=>i.on("chat:select-session",t=>{const{sessionId:a}=t;!a||a===Y.current||fe(a)}),[i,fe]);const Qe=s.useCallback(()=>{fe(K.current)},[fe]),Ie=s.useRef(c);s.useEffect(()=>{Ie.current=c},[c]);const Ve=s.useCallback(({messageId:t,rating:a},{keepalive:l})=>{const A=Ie.current.find(B=>B.id===t);!A||!A.promptLogId||!k.current||(h(B=>B.map(X=>X.id===t?{...X,rating:a,ratingPending:!0}:X)),(async()=>{const[B,X]=await te(fetch(`${n}/api/widget/ai-feedback`,{method:"POST",keepalive:l,headers:{"Content-Type":"application/json",...u?{"X-API-Key":u}:{},Authorization:`Bearer ${k.current}`},body:JSON.stringify({promptLogId:A.promptLogId,rating:a})}));if(X||!(B.ok||B.status===409)){h(O=>O.map(N=>N.id===t?{...N,rating:null,ratingPending:!1}:N));return}h(O=>O.map(N=>N.id===t?{...N,rating:a,ratingPending:!1}:N))})())},[u,n]),{pending:$e,rate:Ee,undo:et}=ct({submit:Ve}),tt=s.useCallback((t,a)=>{const l=c.find(A=>A.id===t);!l||!l.promptLogId||l.ratingPending||!k.current||Ee(t,a)},[c,Ee]);return e.jsxs(it,{blockType:"chat",children:[e.jsxs("div",{className:"es-chat__header",children:[e.jsx("span",{className:"es-chat__header-title",children:r("chat.chat")}),e.jsxs("div",{className:"es-chat__header-actions",children:[e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.new_session_button"),title:r("chat.new_session_button"),onClick:Ge,children:e.jsx(gt,{size:18})}),e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.history_button"),title:r("chat.history_button"),onClick:Ze,children:e.jsx(pt,{size:16})})]})]}),e.jsxs("div",{className:"es-block__body es-chat__body",children:[e.jsxs("div",{className:"es-chat__messages",ref:_,children:[c.length===0&&!me&&!L&&e.jsx("div",{className:"es-chat__welcome",children:H}),me&&e.jsxs("div",{className:"es-chat__load-error",role:"alert",children:[e.jsx("span",{className:"es-chat__load-error-text",children:r("chat.load_session_error")}),e.jsx("button",{type:"button",className:"es-chat__load-error-retry",onClick:Qe,children:r("chat.retry")})]}),c.map(t=>e.jsxs("div",{className:`es-chat__bubble es-chat__bubble--${t.role}${t.id===ge?" es-chat__bubble--streaming":""}`,children:[t.role==="assistant"?e.jsx("div",{className:"es-chat__bubble-text es-chat__bubble-text--md",children:e.jsx(ze,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:a=>We(a)??"",transformImageUri:()=>"",components:Fe,children:t.text})}):e.jsx("div",{className:"es-chat__bubble-text",children:t.text}),t.role==="user"&&t.linkStatus==="reading"&&e.jsxs("div",{className:"es-chat__link-status",role:"status",children:[e.jsx("span",{className:"es-chat__link-status-spinner","aria-hidden":"true"}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.reading_link")})]}),t.role==="user"&&t.linkStatus==="done"&&(t.linkFailedCount??0)>0&&e.jsxs("div",{className:"es-chat__link-status es-chat__link-status--failed",children:[e.jsx(mt,{size:13}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.link_unreadable")})]}),t.role==="assistant"&&t.promptLogId&&k.current&&(()=>{const a=$e?.messageId===t.id?$e.rating:null;return e.jsxs("div",{className:"es-chat__feedback",children:[e.jsx("span",{className:"es-chat__feedback-label",children:t.rating&&a===null?r("chat.feedback_thanks"):r("support_chat.rate_aria")}),e.jsx(ft,{value:a??t.rating??null,onChange:l=>tt(t.id,l),disabled:a===null&&(!!t.rating||t.ratingPending),t:r}),a!==null&&e.jsxs("div",{className:"es-chat__rating-undo",role:"status",children:[e.jsx("span",{className:"es-chat__rating-undo-text",children:r("support_chat.rating_undo_toast",{rating:a})}),e.jsx("button",{type:"button",className:"es-chat__rating-undo-btn",onClick:et,children:r("support_chat.rating_undo_button")})]})]})})()]},t.id)),L&&ge===null&&e.jsxs("div",{className:"es-chat__typing","aria-label":r("chat.typing_aria"),children:[e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"})]})]}),!V&&c.length>0&&e.jsxs("button",{type:"button",className:"es-chat__jump",onClick:()=>C(),"aria-label":r("chat.jump_to_latest"),title:r("chat.jump_to_latest"),children:[e.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"m19 12-7 7-7-7"})]}),e.jsx("span",{className:"es-chat__jump-label",children:r("chat.jump_to_latest")})]})]}),e.jsxs("div",{className:"es-block__footer es-chat__footer",children:[ce.length>0&&e.jsx("div",{className:"es-chat__chips",role:"group","aria-label":r("chat.quick_actions_aria"),children:ce.map((t,a)=>e.jsx("button",{type:"button",className:"es-chat__chip",onClick:()=>qe(t),disabled:L||S,children:t.labelKey?r(t.labelKey):t.label},`${t.labelKey??t.label}-${a}`))}),e.jsx("div",{className:"es-chat__disclaimer",children:r("chat.disclaimer")}),e.jsxs("div",{className:"es-chat__input-row",children:[e.jsx("textarea",{ref:v,className:"es-chat__textarea",value:T,onChange:Xe,onKeyDown:Je,placeholder:Z,rows:1,maxLength:2e3,disabled:L||S,"aria-label":r("chat.input_aria")}),d&&!S&&e.jsx(ht,{baseUrl:n,apiKey:u,jwt:k.current,language:m,onTranscript:Ye,t:r,streaming:F?.streaming,voiceStream:b?.voiceStream,baseText:()=>T,onText:t=>{if(z(t.length>2e3?t.slice(0,2e3):t),t.length>=2e3){const a=b?.voiceStream;a?.getState&&a.getState()!=="idle"&&a.stop()}requestAnimationFrame(()=>{be(),v.current?.focus()})}}),e.jsx("button",{className:"es-chat__send",onClick:ye,disabled:!T.trim()||L||S,type:"button","aria-label":r("chat.send_aria"),children:L?e.jsx("span",{className:"es-chat__send-loading","aria-hidden":"true",children:"⋯"}):e.jsx("span",{"aria-hidden":"true",children:"➤"})})]})]})]})}const Ne=50;function $t({sessionId:o,baseUrl:i,jwt:n,isOpen:p,onToggle:w,i18n:b}){const y=b?.t??(d=>d),j=p!==void 0,[g,U]=s.useState(!1),S=j?p:g,[r,u]=s.useState([]),[m,Z]=s.useState(null),[H,f]=s.useState(!1),[D,I]=s.useState(null),$=s.useRef(!1),E=s.useCallback(async d=>{if(n){f(!0),I(null);try{const c=`${i}/api/chat/sessions/${o}/messages?limit=${Ne}&offset=${d}`,h=await fetch(c,{headers:{Authorization:`Bearer ${n}`},credentials:"include"});if(!h.ok)throw new Error(`HTTP ${h.status}`);const T=await h.json();if(!T.success)throw new Error(y("chat_history.error"));u(z=>d===0?T.data.messages:[...T.data.messages,...z]),Z(T.data.pagination)}catch(c){I(c instanceof Error?c.message:y("chat_history.error"))}finally{f(!1)}}},[i,n,o,y]),k=s.useCallback(()=>{j?w?.():U(d=>{const c=!d;return c&&!$.current&&($.current=!0,E(0)),c})},[j,w,E]),F=s.useCallback(()=>{if(!m)return;const d=Math.max(0,m.total-m.offset-Ne-Ne);E(d)},[E,m]);return s.useEffect(()=>{j&&S&&!$.current&&n&&($.current=!0,E(0))},[j,S,n,E]),s.useEffect(()=>{$.current=!1,u([]),Z(null),I(null),S&&n&&($.current=!0,E(0))},[o,n]),e.jsxs("div",{className:"es-chat-history",children:[!j&&e.jsxs("button",{className:"es-chat-history__toggle",type:"button","aria-expanded":S,onClick:k,disabled:!n,children:[e.jsx("span",{className:"es-chat-history__toggle-icon",children:S?"▲":"▼"}),y("chat_history.toggle")]}),S&&e.jsxs("div",{className:"es-chat-history__panel",children:[H&&e.jsxs("div",{className:"es-chat-history__loading",role:"status","aria-label":y("chat_history.loading_aria"),children:[e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"})]}),D&&!H&&e.jsx("div",{className:"es-chat-history__error",role:"alert",children:D}),!H&&!D&&e.jsxs(e.Fragment,{children:[m?.hasMore&&e.jsx("button",{className:"es-chat-history__load-more",type:"button",onClick:F,"aria-label":y("chat_history.load_older_aria"),children:y("chat_history.load_older")}),e.jsxs("div",{className:"es-chat-history__messages",role:"log","aria-live":"polite","aria-label":y("chat_history.panel_aria"),children:[r.length===0&&e.jsx("div",{className:"es-chat-history__empty",children:y("chat_history.empty")}),r.filter(d=>d.role!=="system").map(d=>e.jsx("div",{className:`es-chat-history__bubble es-chat-history__bubble--${d.role}`,children:d.role==="assistant"?e.jsx("div",{className:"es-chat-history__bubble-md",children:e.jsx(ze,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:c=>We(c)??"",transformImageUri:()=>"",components:Fe,children:d.content})}):d.content},d.id))]})]})]})]})}export{$t as ChatHistoryBlock,It as Component,Nt as manifest};
|
|
6
|
+
//# sourceMappingURL=index-BO0vI80C-qK4w7DnX.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as P,j as s,
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{r as P,j as s,e as m}from"../nexly.js";const o=28,u=2*Math.PI*o;function w({data:t,config:g,actions:h,metadata:N,i18n:_}){const i=_?.t??(e=>e),b=g.mode??t.mode??"basic",p=t.report,a=t.aiPitch,[v,x]=P.useState("idle");if(!p&&!t.error)return s.jsx(m,{blockType:"product-sales-intel",children:s.jsx("div",{className:"psi-block",children:s.jsxs("div",{className:"psi-pv-card",children:[s.jsxs("div",{className:"psi-ring-container",children:[s.jsx("svg",{className:"psi-ring-svg",width:72,height:72,viewBox:"0 0 72 72",children:s.jsx("circle",{className:"psi-ring-track",cx:36,cy:36,r:o})}),s.jsxs("div",{className:"psi-ring-label",children:[s.jsx("span",{className:"psi-ring-pct",style:{color:"var(--es-color-on-surface-muted, #4B5563)"},children:"0%"}),s.jsx("span",{className:"psi-ring-sub",children:"PV"})]})]}),s.jsxs("div",{className:"psi-pv-info",children:[s.jsx("div",{className:"psi-pv-title",children:i("product_sales_intel.personal_volume")}),s.jsx("div",{className:"psi-pv-amount",style:{color:"var(--es-color-on-surface-muted, #4B5563)"},children:"—"}),s.jsx("div",{className:"psi-pv-target",style:{color:"var(--es-color-on-surface-muted, #4B5563)"},children:N?.dataQuality==="none"?i("product_sales_intel.signin_prompt"):i("product_sales_intel.loading")})]})]})})});if(t.error||!p)return s.jsx(m,{blockType:"product-sales-intel",children:s.jsx("p",{style:{color:"var(--es-color-error, #AD2C26)",fontSize:13},children:i("product_sales_intel.load_error")})});const{pvSummary:c,products:l,topProduct:r}=p,y=u-u*c.progressPct/100,j=l[0]?.pvPoints??1,f=()=>{a&&(navigator.clipboard.writeText(a).catch(()=>{}),x("copied"),h?.emit?.("psi:pitchCopied",{pitch:a}),setTimeout(()=>x("idle"),2e3))},n=e=>{h?.emit?.("psi:productSelected",{productId:e.productId,name:e.name})};return s.jsx(m,{blockType:"product-sales-intel",children:s.jsxs("div",{className:"psi-block",children:[s.jsxs("div",{className:"psi-pv-card",children:[s.jsxs("div",{className:"psi-ring-container",children:[s.jsxs("svg",{className:"psi-ring-svg",width:72,height:72,viewBox:"0 0 72 72",children:[s.jsx("circle",{className:"psi-ring-track",cx:36,cy:36,r:o}),s.jsx("circle",{className:"psi-ring-fill",cx:36,cy:36,r:o,strokeDasharray:u,strokeDashoffset:y})]}),s.jsxs("div",{className:"psi-ring-label",children:[s.jsxs("span",{className:"psi-ring-pct",children:[c.progressPct,"%"]}),s.jsx("span",{className:"psi-ring-sub",children:"PV"})]})]}),s.jsxs("div",{className:"psi-pv-info",children:[s.jsx("div",{className:"psi-pv-title",children:i("product_sales_intel.personal_volume")}),s.jsx("div",{className:"psi-pv-amount",children:c.personalVolume.toLocaleString()}),s.jsx("div",{className:"psi-pv-target",children:i("product_sales_intel.target_label",{value:c.pvTarget.toLocaleString()})}),c.gapToPv>0&&s.jsx("div",{className:"psi-pv-gap",children:i("product_sales_intel.pv_to_go",{value:c.gapToPv.toLocaleString()})})]})]}),r&&s.jsxs("div",{className:"psi-top-product",onClick:()=>n(r),onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),n(r))},tabIndex:0,role:"button",children:[s.jsx("span",{className:"psi-top-label",children:i("product_sales_intel.top_product")}),s.jsx("span",{className:"psi-top-name",children:r.name}),s.jsxs("span",{className:"psi-top-badge",children:[r.pvPoints," PV"]})]}),b==="pro"&&l.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"psi-section-title",children:i("product_sales_intel.all_products",{count:l.length})}),s.jsx("div",{className:"psi-product-list",children:l.map(e=>{const k=j>0?Math.round(e.pvPoints/j*100):0;return s.jsxs("div",{className:"psi-product-row",onClick:()=>n(e),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),n(e))},tabIndex:0,role:"button",children:[s.jsxs("div",{className:"psi-product-header",children:[s.jsx("span",{className:"psi-product-name",children:e.name}),s.jsxs("div",{className:"psi-product-stats",children:[s.jsx("span",{className:"psi-product-stat",children:i("product_sales_intel.units_sold",{count:e.unitsSold})}),s.jsxs("span",{className:"psi-product-stat",children:["$",e.revenue.toLocaleString()]}),s.jsxs("span",{className:"psi-product-pv",children:[e.pvPoints," PV"]})]})]}),s.jsx("div",{className:"psi-product-bar-track",children:s.jsx("div",{className:"psi-product-bar-fill",style:{width:`${k}%`}})})]},e.productId)})})]}),a&&s.jsxs("div",{className:"psi-pitch-box",children:[s.jsxs("div",{className:"psi-pitch-header",children:[s.jsx("span",{className:"psi-pitch-label",children:i("product_sales_intel.ai_coach_label")}),s.jsx("button",{className:`psi-copy-btn${v==="copied"?" psi-copied":""}`,onClick:f,children:v==="copied"?`✓ ${i("common.copied")}`:i("common.copy")})]}),s.jsx("p",{className:"psi-pitch-text",children:a})]})]})})}const C={slug:"product-sales-intel",name:"Product Sales Intelligence",version:"1.0.0",category:"data",requiredService:"product-sales-intel",configSchema:{properties:{mode:{type:"string",default:"basic"}}},defaultConfig:{mode:"basic"},sizing:{minWidth:260,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],dataContract:{serviceSlug:"product-sales-intel",inputSchema:{type:"object",properties:{report:{type:"object"},aiPitch:{type:"string"},mode:{type:"string"}},required:["report","mode"]}},events:{emits:[{name:"psi:productSelected",description:"User clicked on a product in the list"},{name:"psi:pitchCopied",description:"User copied the AI product pitch"}]}};export{w as Component,w as ProductSalesIntelBlock,C as manifest};
|
|
2
|
+
//# sourceMappingURL=index-BP1Q45X4-f3F4IxQ5.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as x,j as e,
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{r as x,j as e,e as p}from"../nexly.js";const _={network:"#e0e7ff",sales:"#dcfce7",social:"#fef3c7",personal:"#f3e8ff",team:"#ffedd5"},S={network:"#4338ca",sales:"#137136",social:"#9e4908",personal:"#7129eb",team:"#ab390b"},T={high:"var(--es-color-error, #AD2C26)",medium:"var(--es-color-warning, #9C5300)",low:"var(--es-color-success, #00672B)"},C={high:3,medium:2,low:1};function R({data:c,config:j,actions:h,metadata:g,i18n:b}){const t=b?.t??(a=>a),N=j.mode??c.mode??"basic",m=c.plan,o=c.aiInsight,[v,k]=x.useState(new Set),[r,u]=x.useState(0);if(!m&&!c.error)return e.jsx(p,{blockType:"weekly-rhythm-planner",children:e.jsxs("div",{className:"wrp-block",children:[e.jsxs("div",{className:"wrp-goal",children:[e.jsx("span",{className:"wrp-goal-icon",children:"🎯"}),e.jsx("span",{className:"wrp-goal-text",style:{color:"var(--es-color-on-surface-muted, #4B5563)"},children:g?.dataQuality==="none"?t("weekly_planner.sign_in_prompt"):t("weekly_planner.preparing")})]}),e.jsxs("div",{className:"wrp-basic",children:[e.jsx("div",{className:"wrp-section-label",children:t("weekly_planner.todays_top_actions")}),[1,2,3].map(a=>e.jsxs("div",{className:"wrp-action",style:{opacity:.35},children:[e.jsx("div",{className:"wrp-action-check"}),e.jsx("div",{className:"wrp-action-body",children:e.jsx("span",{className:"wrp-action-title",style:{background:"var(--es-color-surface-elevated, #f5f5f5)",borderRadius:4,display:"block",height:14,width:`${50+a*20}%`}})})]},a))]})]})});if(c.error)return e.jsx(p,{blockType:"weekly-rhythm-planner",children:e.jsx("p",{style:{color:"var(--es-color-error, #AD2C26)",fontSize:13},children:t("weekly_planner.error_generate")})});const s=m,y=(a,i,d)=>{k(l=>{const n=new Set(l);return n.has(a)?n.delete(a):n.add(a),h?.emit?.("wrp:actionToggled",{id:a,title:d,dayIndex:i,checked:!l.has(a)}),n})},f=a=>{u(a),h?.emit?.("wrp:daySelected",{dayIndex:a,dayLabel:s.days[a]?.dayLabel})},w=(a,i)=>{const d=v.has(a.id);return e.jsxs("div",{className:`wrp-action${d?" wrp-action--done":""}`,onClick:()=>y(a.id,i,a.title),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),y(a.id,i,a.title))},tabIndex:0,role:"checkbox","aria-checked":d,children:[e.jsx("div",{className:"wrp-action-check",children:d?"✓":""}),e.jsxs("div",{className:"wrp-action-body",children:[e.jsx("span",{className:"wrp-action-title",children:a.title}),e.jsxs("div",{className:"wrp-action-meta",children:[a.time&&e.jsx("span",{className:"wrp-action-time",children:a.time}),e.jsx("span",{className:"wrp-cat-badge",style:{background:_[a.category],color:S[a.category]},children:a.category})]})]}),e.jsx("div",{className:"wrp-priority",role:"img","aria-label":a.priority,title:a.priority,children:Array.from({length:C[a.priority]},(l,n)=>e.jsx("span",{className:"wrp-priority-dot",style:{background:T[a.priority]}},n))})]},a.id)};return e.jsx(p,{blockType:"weekly-rhythm-planner",children:e.jsxs("div",{className:"wrp-block",children:[s.weeklyGoal&&e.jsxs("div",{className:"wrp-goal",children:[e.jsx("span",{className:"wrp-goal-icon",children:"🎯"}),e.jsx("span",{className:"wrp-goal-text",children:s.weeklyGoal})]}),N==="basic"?e.jsxs("div",{className:"wrp-basic",children:[e.jsx("div",{className:"wrp-section-label",children:t("weekly_planner.todays_top_actions")}),e.jsx("div",{className:"wrp-action-list",children:s.topThreeToday.map(a=>w(a,0))}),o&&e.jsxs("div",{className:"wrp-insight",children:[e.jsx("span",{className:"wrp-insight-icon",children:"💡"}),e.jsx("span",{children:o})]})]}):e.jsxs("div",{className:"wrp-pro",children:[e.jsx("div",{className:"wrp-day-tabs",children:s.days.map((a,i)=>e.jsxs("button",{className:`wrp-day-tab${r===i?" wrp-day-tab--active":""}`,onClick:()=>f(i),children:[e.jsx("span",{className:"wrp-tab-label",children:a.dayLabel.slice(0,3)}),e.jsx("span",{className:"wrp-tab-count",children:a.actions.length})]},a.date))}),s.days[r]&&e.jsxs("div",{className:"wrp-day-panel",children:[e.jsxs("div",{className:"wrp-day-header",children:[e.jsx("span",{className:"wrp-day-title",children:s.days[r].dayLabel}),e.jsx("span",{className:"wrp-day-date",children:s.days[r].date})]}),e.jsx("div",{className:"wrp-action-list",children:s.days[r].actions.map(a=>w(a,r))}),s.days[r].focusTip&&e.jsxs("div",{className:"wrp-focus-tip",children:[e.jsx("span",{children:"✨"}),e.jsx("span",{children:s.days[r].focusTip})]})]}),o&&e.jsxs("div",{className:"wrp-insight",children:[e.jsx("span",{className:"wrp-insight-icon",children:"💡"}),e.jsx("span",{children:o})]})]})]})})}const B={slug:"weekly-rhythm-planner",name:"Weekly Rhythm Planner",version:"1.0.0",category:"interactive",requiredService:"weekly-rhythm-planner",configSchema:{properties:{mode:{type:"string",default:"basic"}}},defaultConfig:{mode:"basic"},sizing:{minWidth:280,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],dataContract:{serviceSlug:"weekly-rhythm-planner",inputSchema:{type:"object",properties:{plan:{type:"object"},aiInsight:{type:"string"},mode:{type:"string"}},required:["plan","mode"]}},events:{emits:[{name:"wrp:actionToggled",description:"User toggled an action checkbox"},{name:"wrp:daySelected",description:"User selected a different day in pro mode"}]}};export{R as Component,R as WeeklyRhythmPlannerBlock,B as manifest};
|
|
2
|
+
//# sourceMappingURL=index-BPfUysTZ-CV5ZiVsD.js.map
|