kenobi-js 0.1.28
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/README.md +12 -0
- package/dist/kenobi.js +2867 -0
- package/dist/kenobi.js.map +7 -0
- package/dist/kenobi.min.js +68 -0
- package/package.json +30 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Kenobi SDK v0.1.28
|
|
3
|
+
* (c) 2025 Kenobi.ai
|
|
4
|
+
*/
|
|
5
|
+
"use strict";var KenobiLib=(()=>{var me=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Ut=Object.prototype.hasOwnProperty;var zt=(e,t,r)=>t in e?me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Kt=(e,t)=>{for(var r in t)me(e,r,{get:t[r],enumerable:!0})},Vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ft(t))!Ut.call(e,i)&&i!==r&&me(e,i,{get:()=>t[i],enumerable:!(n=It(t,i))||n.enumerable});return e};var $t=e=>Vt(me({},"__esModule",{value:!0}),e);var y=(e,t,r)=>zt(e,typeof t!="symbol"?t+"":t,r);var Mr={};Kt(Mr,{CueCard:()=>Ae,Kenobi:()=>Ve,TRANSFORMATION_ACTIONS:()=>Rt});var $e=11;function jt(e,t){var r=t.attributes,n,i,o,a,c;if(!(t.nodeType===$e||e.nodeType===$e)){for(var u=r.length-1;u>=0;u--)n=r[u],i=n.name,o=n.namespaceURI,a=n.value,o?(i=n.localName||i,c=e.getAttributeNS(o,i),c!==a&&(n.prefix==="xmlns"&&(i=n.name),e.setAttributeNS(o,i,a))):(c=e.getAttribute(i),c!==a&&e.setAttribute(i,a));for(var l=e.attributes,m=l.length-1;m>=0;m--)n=l[m],i=n.name,o=n.namespaceURI,o?(i=n.localName||i,t.hasAttributeNS(o,i)||e.removeAttributeNS(o,i)):t.hasAttribute(i)||e.removeAttribute(i)}}var he,Bt="http://www.w3.org/1999/xhtml",V=typeof document>"u"?void 0:document,Wt=!!V&&"content"in V.createElement("template"),qt=!!V&&V.createRange&&"createContextualFragment"in V.createRange();function Gt(e){var t=V.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function Xt(e){he||(he=V.createRange(),he.selectNode(V.body));var t=he.createContextualFragment(e);return t.childNodes[0]}function Yt(e){var t=V.createElement("body");return t.innerHTML=e,t.childNodes[0]}function Qt(e){return e=e.trim(),Wt?Gt(e):qt?Xt(e):Yt(e)}function _e(e,t){var r=e.nodeName,n=t.nodeName,i,o;return r===n?!0:(i=r.charCodeAt(0),o=n.charCodeAt(0),i<=90&&o>=97?r===n.toUpperCase():o<=90&&i>=97?n===r.toUpperCase():!1)}function Jt(e,t){return!t||t===Bt?V.createElement(e):V.createElementNS(t,e)}function Zt(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}function Ee(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r))}var je={OPTION:function(e,t){var r=e.parentNode;if(r){var n=r.nodeName.toUpperCase();n==="OPTGROUP"&&(r=r.parentNode,n=r&&r.nodeName.toUpperCase()),n==="SELECT"&&!r.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),r.selectedIndex=-1)}Ee(e,t,"selected")},INPUT:function(e,t){Ee(e,t,"checked"),Ee(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var i=n.nodeValue;if(i==r||!r&&i==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var r=-1,n=0,i=e.firstChild,o,a;i;)if(a=i.nodeName&&i.nodeName.toUpperCase(),a==="OPTGROUP")o=i,i=o.firstChild,i||(i=o.nextSibling,o=null);else{if(a==="OPTION"){if(i.hasAttribute("selected")){r=n;break}n++}i=i.nextSibling,!i&&o&&(i=o.nextSibling,o=null)}e.selectedIndex=r}}},ae=1,Be=11,We=3,qe=8;function te(){}function er(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function tr(e){return function(r,n,i){if(i||(i={}),typeof n=="string")if(r.nodeName==="#document"||r.nodeName==="HTML"||r.nodeName==="BODY"){var o=n;n=V.createElement("html"),n.innerHTML=o}else n=Qt(n);else n.nodeType===Be&&(n=n.firstElementChild);var a=i.getNodeKey||er,c=i.onBeforeNodeAdded||te,u=i.onNodeAdded||te,l=i.onBeforeElUpdated||te,m=i.onElUpdated||te,s=i.onBeforeNodeDiscarded||te,f=i.onNodeDiscarded||te,b=i.onBeforeElChildrenUpdated||te,C=i.skipFromChildren||te,M=i.addChild||function(v,h){return v.appendChild(h)},S=i.childrenOnly===!0,p=Object.create(null),g=[];function R(v){g.push(v)}function O(v,h){if(v.nodeType===ae)for(var P=v.firstChild;P;){var k=void 0;h&&(k=a(P))?R(k):(f(P),P.firstChild&&O(P,h)),P=P.nextSibling}}function H(v,h,P){s(v)!==!1&&(h&&h.removeChild(v),f(v),O(v,P))}function w(v){if(v.nodeType===ae||v.nodeType===Be)for(var h=v.firstChild;h;){var P=a(h);P&&(p[P]=h),w(h),h=h.nextSibling}}w(r);function $(v){u(v);for(var h=v.firstChild;h;){var P=h.nextSibling,k=a(h);if(k){var T=p[k];T&&_e(h,T)?(h.parentNode.replaceChild(T,h),D(T,h)):$(h)}else $(h);h=P}}function W(v,h,P){for(;h;){var k=h.nextSibling;(P=a(h))?R(P):H(h,v,!0),h=k}}function D(v,h,P){var k=a(h);if(k&&delete p[k],!P){var T=l(v,h);if(T===!1||(T instanceof HTMLElement&&(v=T,w(v)),e(v,h),m(v),b(v,h)===!1))return}v.nodeName!=="TEXTAREA"?j(v,h):je.TEXTAREA(v,h)}function j(v,h){var P=C(v,h),k=h.firstChild,T=v.firstChild,Z,q,ee,ie,_;e:for(;k;){for(ie=k.nextSibling,Z=a(k);!P&&T;){if(ee=T.nextSibling,k.isSameNode&&k.isSameNode(T)){k=ie,T=ee;continue e}q=a(T);var A=T.nodeType,U=void 0;if(A===k.nodeType&&(A===ae?(Z?Z!==q&&((_=p[Z])?ee===_?U=!1:(v.insertBefore(_,T),q?R(q):H(T,v,!0),T=_,q=a(T)):U=!1):q&&(U=!1),U=U!==!1&&_e(T,k),U&&D(T,k)):(A===We||A==qe)&&(U=!0,T.nodeValue!==k.nodeValue&&(T.nodeValue=k.nodeValue))),U){k=ie,T=ee;continue e}q?R(q):H(T,v,!0),T=ee}if(Z&&(_=p[Z])&&_e(_,k))P||M(v,_),D(_,k);else{var K=c(k);K!==!1&&(K&&(k=K),k.actualize&&(k=k.actualize(v.ownerDocument||V)),M(v,k),$(k))}k=ie,T=ee}W(v,T,q);var G=je[v.nodeName];G&&G(v,h)}var x=r,z=x.nodeType,fe=n.nodeType;if(!S){if(z===ae)fe===ae?_e(r,n)||(f(r),x=Zt(r,Jt(n.nodeName,n.namespaceURI))):x=n;else if(z===We||z===qe){if(fe===z)return x.nodeValue!==n.nodeValue&&(x.nodeValue=n.nodeValue),x;x=n}}if(x===n)f(r);else{if(n.isSameNode&&n.isSameNode(x))return;if(D(x,n,S),g)for(var F=0,Q=g.length;F<Q;F++){var re=p[g[F]];re&&H(re,re.parentNode,!1)}}return!S&&x!==r&&r.parentNode&&(x.actualize&&(x=x.actualize(r.ownerDocument||V)),r.parentNode.replaceChild(x,r)),x}}var rr=tr(jt),ge=rr;var xe,E,Je,nr,ne,Ge,Ze,et,tt,Le,Me,Pe,ir,se={},rt=[],or=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Te=Array.isArray;function J(e,t){for(var r in t)e[r]=t[r];return e}function De(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ar(e,t,r){var n,i,o,a={};for(o in t)o=="key"?n=t[o]:o=="ref"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?xe.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return ye(e,a,n,i,null)}function ye(e,t,r,n,i){var o={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Je,__i:-1,__u:0};return i==null&&E.vnode!=null&&E.vnode(o),o}function X(e){return e.children}function ke(e,t){this.props=e,this.context=t}function oe(e,t){if(t==null)return e.__?oe(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?oe(e):null}function nt(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return nt(e)}}function Xe(e){(!e.__d&&(e.__d=!0)&&ne.push(e)&&!we.__r++||Ge!=E.debounceRendering)&&((Ge=E.debounceRendering)||Ze)(we)}function we(){for(var e,t,r,n,i,o,a,c=1;ne.length;)ne.length>c&&ne.sort(et),e=ne.shift(),c=ne.length,e.__d&&(r=void 0,n=void 0,i=(n=(t=e).__v).__e,o=[],a=[],t.__P&&((r=J({},n)).__v=n.__v+1,E.vnode&&E.vnode(r),Ne(t.__P,r,n,t.__n,t.__P.namespaceURI,32&n.__u?[i]:null,o,i??oe(n),!!(32&n.__u),a),r.__v=n.__v,r.__.__k[r.__i]=r,at(o,r,a),n.__e=n.__=null,r.__e!=i&&nt(r)));we.__r=0}function it(e,t,r,n,i,o,a,c,u,l,m){var s,f,b,C,M,S,p,g=n&&n.__k||rt,R=t.length;for(u=sr(r,t,g,u,R),s=0;s<R;s++)(b=r.__k[s])!=null&&(f=b.__i==-1?se:g[b.__i]||se,b.__i=s,S=Ne(e,b,f,i,o,a,c,u,l,m),C=b.__e,b.ref&&f.ref!=b.ref&&(f.ref&&He(f.ref,null,b),m.push(b.ref,b.__c||C,b)),M==null&&C!=null&&(M=C),(p=!!(4&b.__u))||f.__k===b.__k?u=ot(b,u,e,p):typeof b.type=="function"&&S!==void 0?u=S:C&&(u=C.nextSibling),b.__u&=-7);return r.__e=M,u}function sr(e,t,r,n,i){var o,a,c,u,l,m=r.length,s=m,f=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(u=o+f,(a=e.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?ye(null,a,null,null,null):Te(a)?ye(X,{children:a},null,null,null):a.constructor==null&&a.__b>0?ye(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,c=null,(l=a.__i=lr(a,r,u,s))!=-1&&(s--,(c=r[l])&&(c.__u|=2)),c==null||c.__v==null?(l==-1&&(i>m?f--:i<m&&f++),typeof a.type!="function"&&(a.__u|=4)):l!=u&&(l==u-1?f--:l==u+1?f++:(l>u?f--:f++,a.__u|=4))):e.__k[o]=null;if(s)for(o=0;o<m;o++)(c=r[o])!=null&&(2&c.__u)==0&&(c.__e==n&&(n=oe(c)),lt(c,c));return n}function ot(e,t,r,n){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=ot(i[o],t,r,n));return t}e.__e!=t&&(n&&(t&&e.type&&!t.parentNode&&(t=oe(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function lr(e,t,r,n){var i,o,a,c=e.key,u=e.type,l=t[r],m=l!=null&&(2&l.__u)==0;if(l===null&&e.key==null||m&&c==l.key&&u==l.type)return r;if(n>(m?1:0)){for(i=r-1,o=r+1;i>=0||o<t.length;)if((l=t[a=i>=0?i--:o++])!=null&&(2&l.__u)==0&&c==l.key&&u==l.type)return a}return-1}function Ye(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||or.test(t)?r:r+"px"}function ve(e,t,r,n,i){var o,a;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||Ye(e.style,t,"");if(r)for(t in r)n&&r[t]==n[t]||Ye(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(tt,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=r,r?n?r.u=n.u:(r.u=Le,e.addEventListener(t,o?Pe:Me,o)):e.removeEventListener(t,o?Pe:Me,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function Qe(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=Le++;else if(t.t<r.u)return;return r(E.event?E.event(t):t)}}}function Ne(e,t,r,n,i,o,a,c,u,l){var m,s,f,b,C,M,S,p,g,R,O,H,w,$,W,D,j,x=t.type;if(t.constructor!=null)return null;128&r.__u&&(u=!!(32&r.__u),o=[c=t.__e=r.__e]),(m=E.__b)&&m(t);e:if(typeof x=="function")try{if(p=t.props,g="prototype"in x&&x.prototype.render,R=(m=x.contextType)&&n[m.__c],O=m?R?R.props.value:m.__:n,r.__c?S=(s=t.__c=r.__c).__=s.__E:(g?t.__c=s=new x(p,O):(t.__c=s=new ke(p,O),s.constructor=x,s.render=ur),R&&R.sub(s),s.props=p,s.state||(s.state={}),s.context=O,s.__n=n,f=s.__d=!0,s.__h=[],s._sb=[]),g&&s.__s==null&&(s.__s=s.state),g&&x.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=J({},s.__s)),J(s.__s,x.getDerivedStateFromProps(p,s.__s))),b=s.props,C=s.state,s.__v=t,f)g&&x.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),g&&s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(g&&x.getDerivedStateFromProps==null&&p!==b&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(p,O),!s.__e&&s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(p,s.__s,O)===!1||t.__v==r.__v){for(t.__v!=r.__v&&(s.props=p,s.state=s.__s,s.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(z){z&&(z.__=t)}),H=0;H<s._sb.length;H++)s.__h.push(s._sb[H]);s._sb=[],s.__h.length&&a.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(p,s.__s,O),g&&s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(b,C,M)})}if(s.context=O,s.props=p,s.__P=e,s.__e=!1,w=E.__r,$=0,g){for(s.state=s.__s,s.__d=!1,w&&w(t),m=s.render(s.props,s.state,s.context),W=0;W<s._sb.length;W++)s.__h.push(s._sb[W]);s._sb=[]}else do s.__d=!1,w&&w(t),m=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++$<25);s.state=s.__s,s.getChildContext!=null&&(n=J(J({},n),s.getChildContext())),g&&!f&&s.getSnapshotBeforeUpdate!=null&&(M=s.getSnapshotBeforeUpdate(b,C)),D=m,m!=null&&m.type===X&&m.key==null&&(D=st(m.props.children)),c=it(e,Te(D)?D:[D],t,r,n,i,o,a,c,u,l),s.base=t.__e,t.__u&=-161,s.__h.length&&a.push(s),S&&(s.__E=s.__=null)}catch(z){if(t.__v=null,u||o!=null)if(z.then){for(t.__u|=u?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(j=o.length;j--;)De(o[j]);Re(t)}else t.__e=r.__e,t.__k=r.__k,z.then||Re(t);E.__e(z,t,r)}else o==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):c=t.__e=cr(r.__e,t,r,n,i,o,a,u,l);return(m=E.diffed)&&m(t),128&t.__u?void 0:c}function Re(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(Re)}function at(e,t,r){for(var n=0;n<r.length;n++)He(r[n],r[++n],r[++n]);E.__c&&E.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){E.__e(o,i.__v)}})}function st(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:Te(e)?e.map(st):J({},e)}function cr(e,t,r,n,i,o,a,c,u){var l,m,s,f,b,C,M,S=r.props,p=t.props,g=t.type;if(g=="svg"?i="http://www.w3.org/2000/svg":g=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(l=0;l<o.length;l++)if((b=o[l])&&"setAttribute"in b==!!g&&(g?b.localName==g:b.nodeType==3)){e=b,o[l]=null;break}}if(e==null){if(g==null)return document.createTextNode(p);e=document.createElementNS(i,g,p.is&&p),c&&(E.__m&&E.__m(t,o),c=!1),o=null}if(g==null)S===p||c&&e.data==p||(e.data=p);else{if(o=o&&xe.call(e.childNodes),S=r.props||se,!c&&o!=null)for(S={},l=0;l<e.attributes.length;l++)S[(b=e.attributes[l]).name]=b.value;for(l in S)if(b=S[l],l!="children"){if(l=="dangerouslySetInnerHTML")s=b;else if(!(l in p)){if(l=="value"&&"defaultValue"in p||l=="checked"&&"defaultChecked"in p)continue;ve(e,l,null,b,i)}}for(l in p)b=p[l],l=="children"?f=b:l=="dangerouslySetInnerHTML"?m=b:l=="value"?C=b:l=="checked"?M=b:c&&typeof b!="function"||S[l]===b||ve(e,l,b,S[l],i);if(m)c||s&&(m.__html==s.__html||m.__html==e.innerHTML)||(e.innerHTML=m.__html),t.__k=[];else if(s&&(e.innerHTML=""),it(t.type=="template"?e.content:e,Te(f)?f:[f],t,r,n,g=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:r.__k&&oe(r,0),c,u),o!=null)for(l=o.length;l--;)De(o[l]);c||(l="value",g=="progress"&&C==null?e.removeAttribute("value"):C!=null&&(C!==e[l]||g=="progress"&&!C||g=="option"&&C!=S[l])&&ve(e,l,C,S[l],i),l="checked",M!=null&&M!=e[l]&&ve(e,l,M,S[l],i))}return e}function He(e,t,r){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(i){E.__e(i,r)}}function lt(e,t,r){var n,i;if(E.unmount&&E.unmount(e),(n=e.ref)&&(n.current&&n.current!=e.__e||He(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){E.__e(o,t)}n.base=n.__P=null}if(n=e.__k)for(i=0;i<n.length;i++)n[i]&<(n[i],t,r||typeof e.type!="function");r||De(e.__e),e.__c=e.__=e.__e=void 0}function ur(e,t,r){return this.constructor(e,r)}function Oe(e,t,r){var n,i,o,a;t==document&&(t=document.documentElement),E.__&&E.__(e,t),i=(n=typeof r=="function")?null:r&&r.__k||t.__k,o=[],a=[],Ne(t,e=(!n&&r||t).__k=ar(X,null,[e]),i||se,se,t.namespaceURI,!n&&r?[r]:i?null:t.firstChild?xe.call(t.childNodes):null,o,!n&&r?r:i?i.__e:t.firstChild,n,a),at(o,e,a)}xe=rt.slice,E={__e:function(e,t,r,n){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,n||{}),a=i.__d),a)return i.__E=i}catch(c){e=c}throw e}},Je=0,nr=function(e){return e!=null&&e.constructor==null},ke.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=J({},this.state),typeof e=="function"&&(e=e(J({},r),this.props)),e&&J(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),Xe(this))},ke.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Xe(this))},ke.prototype.render=X,ne=[],Ze=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,et=function(e,t){return e.__v.__b-t.__v.__b},we.__r=0,tt=/(PointerCapture)$|Capture$/i,Le=0,Me=Qe(!1),Pe=Qe(!0),ir=0;var le,L,Ie,ct,ce=0,_t=[],N=E,ut=N.__b,dt=N.__r,ft=N.diffed,pt=N.__c,bt=N.unmount,mt=N.__;function Ue(e,t){N.__h&&N.__h(L,e,ce||t),ce=0;var r=L.__H||(L.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function Se(e){return ce=1,dr(kt,e)}function dr(e,t,r){var n=Ue(le++,2);if(n.t=e,!n.__c&&(n.__=[r?r(t):kt(void 0,t),function(c){var u=n.__N?n.__N[0]:n.__[0],l=n.t(u,c);u!==l&&(n.__N=[l,n.__[1]],n.__c.setState({}))}],n.__c=L,!L.__f)){var i=function(c,u,l){if(!n.__c.__H)return!0;var m=n.__c.__H.__.filter(function(f){return!!f.__c});if(m.every(function(f){return!f.__N}))return!o||o.call(this,c,u,l);var s=n.__c.props!==c;return m.forEach(function(f){if(f.__N){var b=f.__[0];f.__=f.__N,f.__N=void 0,b!==f.__[0]&&(s=!0)}}),o&&o.call(this,c,u,l)||s};L.__f=!0;var o=L.shouldComponentUpdate,a=L.componentWillUpdate;L.componentWillUpdate=function(c,u,l){if(this.__e){var m=o;o=void 0,i(c,u,l),o=m}a&&a.call(this,c,u,l)},L.shouldComponentUpdate=i}return n.__N||n.__}function B(e,t){var r=Ue(le++,3);!N.__s&&yt(r.__H,t)&&(r.__=e,r.u=t,L.__H.__h.push(r))}function I(e){return ce=5,gt(function(){return{current:e}},[])}function gt(e,t){var r=Ue(le++,7);return yt(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function vt(e,t){return ce=8,gt(function(){return e},t)}function fr(){for(var e;e=_t.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ce),e.__H.__h.forEach(Fe),e.__H.__h=[]}catch(t){e.__H.__h=[],N.__e(t,e.__v)}}N.__b=function(e){L=null,ut&&ut(e)},N.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),mt&&mt(e,t)},N.__r=function(e){dt&&dt(e),le=0;var t=(L=e.__c).__H;t&&(Ie===L?(t.__h=[],L.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(Ce),t.__h.forEach(Fe),t.__h=[],le=0)),Ie=L},N.diffed=function(e){ft&&ft(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(_t.push(t)!==1&&ct===N.requestAnimationFrame||((ct=N.requestAnimationFrame)||pr)(fr)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),Ie=L=null},N.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Ce),r.__h=r.__h.filter(function(n){return!n.__||Fe(n)})}catch(n){t.some(function(i){i.__h&&(i.__h=[])}),t=[],N.__e(n,r.__v)}}),pt&&pt(e,t)},N.unmount=function(e){bt&&bt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{Ce(n)}catch(i){t=i}}),r.__H=void 0,t&&N.__e(t,r.__v))};var ht=typeof requestAnimationFrame=="function";function pr(e){var t,r=function(){clearTimeout(n),ht&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(r,35);ht&&(t=requestAnimationFrame(r))}function Ce(e){var t=L,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),L=t}function Fe(e){var t=L;e.__c=e.__(),L=t}function yt(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function kt(e,t){return typeof t=="function"?t(e):t}var br=0;function d(e,t,r,n,i,o){t||(t={});var a,c,u=t;if("ref"in u)for(c in u={},t)c=="ref"?a=t[c]:u[c]=t[c];var l={type:e,props:u,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--br,__i:-1,__u:0,__source:i,__self:o};if(typeof e=="function"&&(a=e.defaultProps))for(c in a)u[c]===void 0&&(u[c]=a[c]);return E.vnode&&E.vnode(l),l}var wt=()=>d("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:d("path",{fillRule:"evenodd",d:"M16.72 7.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1 0 1.06l-3.75 3.75a.75.75 0 1 1-1.06-1.06l2.47-2.47H3a.75.75 0 0 1 0-1.5h16.19l-2.47-2.47a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})}),mr=()=>d("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:d("path",{fillRule:"evenodd",d:"M19.916 4.626a.75.75 0 0 1 .208 1.04l-9 13.5a.75.75 0 0 1-1.154.114l-6-6a.75.75 0 0 1 1.06-1.06l5.353 5.353 8.493-12.739a.75.75 0 0 1 1.04-.208Z",clipRule:"evenodd"})}),hr=()=>d("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"16",height:"16",children:d("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"})}),ze=()=>d("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:d("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),xt=()=>d("svg",{width:"32",height:"32",viewBox:"0 0 900 900",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[d("circle",{cx:"446",cy:"450",r:"424",fill:"black"}),d("circle",{cx:"450",cy:"450",r:"357",fill:"url(#paint0_linear_1_41)"}),d("ellipse",{cx:"579.85",cy:"294.451",rx:"79.778",ry:"108.483",transform:"rotate(-46.2324 579.85 294.451)",fill:"black"}),d("defs",{children:d("linearGradient",{id:"paint0_linear_1_41",x1:"807",y1:"93",x2:"93",y2:"807",gradientUnits:"userSpaceOnUse",children:[d("stop",{"stop-color":"#FAFAFA"}),d("stop",{offset:"1","stop-color":"#CACACA"})]})})]}),_r=`
|
|
6
|
+
:host { --kb-font-family: system-ui, -apple-system, sans-serif; --kb-bg-container: rgba(255, 255, 255, 0.05); --kb-border-container: rgba(255, 255, 255, 0.2); --kb-shadow-container: 0 25px 50px -12px rgba(0, 0, 0, 0.25); --kb-backdrop-blur: 16px; --kb-text-title: #ffffff; --kb-text-subtitle: rgba(255, 255, 255, 0.7); --kb-btn-dismiss-bg: rgba(0, 0, 0, 0.7); --kb-btn-dismiss-border: rgba(255, 255, 255, 0.2); --kb-btn-dismiss-text: rgba(255, 255, 255, 0.8); --kb-btn-dismiss-hover-bg: rgba(0, 0, 0, 0.9); --kb-btn-dismiss-hover-text: #ffffff; --kb-btn-trigger-bg: #ffffff; --kb-btn-trigger-text: #000000; --kb-btn-trigger-hover-bg: rgba(255, 255, 255, 0.9); --kb-progress-track: rgba(255, 255, 255, 0.2); --kb-progress-indicator: #ffffff; --kb-popover-bg: rgba(255, 255, 255, 0.05); --kb-popover-border: rgba(255, 255, 255, 0.2); --kb-popover-text: #ffffff; --kb-input-bg: transparent; --kb-input-border: rgba(255, 255, 255, 0.3); --kb-input-text: #ffffff; --kb-input-placeholder: rgba(255, 255, 255, 0.6); --kb-form-label: #ffffff; --kb-success-color: #6ee7b7; --kb-focus-blur: 10px; --kb-kbd-bg: rgba(255, 255, 255, 0.1); --kb-kbd-border: rgba(255, 255, 255, 0.2); --kb-kbd-text: rgba(255, 255, 255, 0.6); --kb-watermark-text: rgba(255, 255, 255, 0.4); font-family: var(--kb-font-family); }
|
|
7
|
+
.theme-light { --kb-bg-container: #ffffff; --kb-border-container: #e2e8f0; --kb-shadow-container: 0 20px 25px -5px rgba(0, 0, 0, 0.1); --kb-backdrop-blur: 0px; --kb-text-title: #0f172a; --kb-text-subtitle: #475569; --kb-btn-dismiss-bg: #ffffff; --kb-btn-dismiss-border: #e2e8f0; --kb-btn-dismiss-text: #64748b; --kb-btn-dismiss-hover-bg: #f1f5f9; --kb-btn-dismiss-hover-text: #0f172a; --kb-btn-trigger-bg: #0f172a; --kb-btn-trigger-text: #ffffff; --kb-btn-trigger-hover-bg: #1e293b; --kb-progress-track: #e2e8f0; --kb-progress-indicator: #0f172a; --kb-popover-bg: #ffffff; --kb-popover-border: #e2e8f0; --kb-popover-text: #0f172a; --kb-input-bg: #ffffff; --kb-input-border: #cbd5e1; --kb-input-text: #0f172a; --kb-input-placeholder: #94a3b8; --kb-form-label: #334155; --kb-success-color: #059669; --kb-kbd-bg: #f1f5f9; --kb-kbd-border: #e2e8f0; --kb-kbd-text: #64748b; --kb-watermark-text: #94a3b8; }
|
|
8
|
+
.theme-dark { --kb-bg-container: #0f172a; --kb-border-container: #334155; --kb-shadow-container: 0 25px 50px -12px rgba(0, 0, 0, 0.25); --kb-backdrop-blur: 0px; --kb-text-title: #f1f5f9; --kb-text-subtitle: #94a3b8; --kb-btn-dismiss-bg: #1e293b; --kb-btn-dismiss-border: #334155; --kb-btn-dismiss-text: #cbd5e1; --kb-btn-dismiss-hover-bg: #334155; --kb-btn-dismiss-hover-text: #ffffff; --kb-btn-trigger-bg: #ffffff; --kb-btn-trigger-text: #0f172a; --kb-btn-trigger-hover-bg: #f1f5f9; --kb-progress-track: #1e293b; --kb-progress-indicator: #ffffff; --kb-popover-bg: #0f172a; --kb-popover-border: #334155; --kb-popover-text: #f1f5f9; --kb-input-bg: #0f172a; --kb-input-border: #475569; --kb-input-text: #f1f5f9; --kb-input-placeholder: #94a3b8; --kb-form-label: #e2e8f0; --kb-success-color: #6ee7b7; --kb-kbd-bg: #1e293b; --kb-kbd-border: #334155; --kb-kbd-text: #94a3b8; --kb-watermark-text: #64748b; }
|
|
9
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
10
|
+
#cue-card-root { position: fixed; z-index: 2147483647; pointer-events: none; width: 100%; height: 0; top: 0; left: 0; isolation: isolate; }
|
|
11
|
+
.container { position: absolute; pointer-events: auto; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); border-radius: 0.25rem; border-bottom-left-radius: 0.25rem; border-bottom-right-radius: 0.25rem; padding: 1rem; width: auto; min-width: 320px; max-width: 90vw; opacity: 0; z-index: 1; font-family: var(--kb-font-family); }
|
|
12
|
+
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); transition: all 0.5s ease; z-index: 0; pointer-events: none; }
|
|
13
|
+
.backdrop.active { background: rgba(0,0,0,0.1); backdrop-filter: blur(var(--kb-focus-blur)); -webkit-backdrop-filter: blur(var(--kb-focus-blur)); }
|
|
14
|
+
.launcher { position: absolute; pointer-events: auto; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); border-radius: 9999px; padding: 0.5rem 1rem; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; transition: transform 0.2s, opacity 0.3s; opacity: 0; z-index: 1; color: var(--kb-text-title); font-weight: 500; font-size: 0.875rem; font-family: var(--kb-font-family); }
|
|
15
|
+
.launcher .kbd-hint .kbd { background: var(--kb-kbd-bg); border: 1px solid var(--kb-kbd-border); color: var(--kb-kbd-text); }
|
|
16
|
+
.launcher .kbd-hint .kbd-text { color: var(--kb-kbd-text); }
|
|
17
|
+
.launcher:hover { transform: scale(1.02); background-color: var(--kb-bg-container); }
|
|
18
|
+
.pos-top-center { left: 50%; translate: -50% 0; top: 1rem; }
|
|
19
|
+
.pos-top-right { right: 1rem; top: 1rem; left: auto; }
|
|
20
|
+
@media (max-width: 768px) { .pos-top-center, .pos-top-right { left: 0.5rem; right: 0.5rem; top: 0.5rem; translate: none; width: auto; max-width: none; } }
|
|
21
|
+
.content-wrapper { display: flex; align-items: center; gap: 1rem; }
|
|
22
|
+
.logo { width: 2.5rem; height: 2.5rem; display: none; }
|
|
23
|
+
@media (min-width: 1024px) { .logo { display: block; } }
|
|
24
|
+
.text-content { flex: 1; user-select: none; }
|
|
25
|
+
.text-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
|
|
26
|
+
.title { color: var(--kb-text-title); font-size: 1rem; font-weight: 600; line-height: 1.5; }
|
|
27
|
+
.subtitle { color: var(--kb-text-title); font-size: 0.875rem; line-height: 1.25; opacity: 0.8; }
|
|
28
|
+
.btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 0.375rem; font-weight: 500; font-size: 0.875rem; line-height: 1.25rem; padding: 0.5rem 1rem; transition: all 0.2s; cursor: pointer; border: none; outline: none; }
|
|
29
|
+
.btn-trigger { background-color: var(--kb-btn-trigger-bg); color: var(--kb-btn-trigger-text); min-width: 8rem; gap: 0.5rem; }
|
|
30
|
+
.btn-trigger:not(:disabled):hover { background-color: var(--kb-btn-trigger-hover-bg); }
|
|
31
|
+
.btn-trigger:disabled { opacity: 0.8; cursor: not-allowed; }
|
|
32
|
+
.btn-trigger.success { background-color: transparent; color: var(--kb-success-color); padding-right: 0.75rem; cursor: default; }
|
|
33
|
+
.btn-trigger.success:hover { background-color: transparent; }
|
|
34
|
+
.animate-spin { animation: spin 1s linear infinite; }
|
|
35
|
+
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
|
36
|
+
.btn-dismiss { position: absolute; top: -0.5rem; left: -0.5rem; width: 1.5rem; height: 1.5rem; padding: 0; border-radius: 9999px; display: flex; align-items: center; justify-content: center; background-color: var(--kb-btn-dismiss-bg); border: 1px solid var(--kb-btn-dismiss-border); color: var(--kb-btn-dismiss-text); cursor: pointer; transition: all 0.3s ease-out; z-index: 10; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
|
|
37
|
+
.btn-dismiss:hover { background-color: var(--kb-btn-dismiss-hover-bg); color: var(--kb-btn-dismiss-hover-text); }
|
|
38
|
+
.progress-clip { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
|
|
39
|
+
.progress-container { position: absolute; bottom: 0; left: 0; right: 0; height: 0.25rem; background-color: var(--kb-progress-track); overflow: hidden; pointer-events: none; }
|
|
40
|
+
.progress-bar { height: 100%; background-color: var(--kb-progress-indicator); width: 0%; transition: width 0.3s ease; }
|
|
41
|
+
.popover { position: absolute; top: 100%; left: 0; right: 0; margin-top: 0.375rem; background-color: var(--kb-popover-bg); border: 1px solid var(--kb-popover-border); border-radius: 0.25rem; border-top-left-radius: 0; border-top-right-radius: 0; padding: 1rem; color: var(--kb-popover-text); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); opacity: 0; transform: translateY(-10px); pointer-events: none; visibility: hidden; transition: all 0.2s ease-out; }
|
|
42
|
+
.popover.open { opacity: 1; transform: translateY(0); pointer-events: auto; visibility: visible; }
|
|
43
|
+
.form-group { margin-bottom: 1rem; }
|
|
44
|
+
.form-label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; color: var(--kb-form-label); font-weight: 500; }
|
|
45
|
+
.input-row { display: flex; gap: 0.5rem; }
|
|
46
|
+
.form-input { flex: 1; background-color: var(--kb-input-bg); border: 1px solid var(--kb-input-border); color: var(--kb-input-text); border-radius: 0.375rem; padding: 0.5rem 0.75rem; font-size: 0.875rem; outline: none; transition: border-color 0.2s; min-height: 44px; }
|
|
47
|
+
.form-input::placeholder { color: var(--kb-input-placeholder); }
|
|
48
|
+
.form-input:focus { border-color: var(--kb-progress-indicator); }
|
|
49
|
+
.btn-submit { background-color: var(--kb-btn-trigger-bg); color: var(--kb-btn-trigger-text); padding: 0.5rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
|
|
50
|
+
.btn-submit:disabled { opacity: 0.7; cursor: not-allowed; }
|
|
51
|
+
.kbd-hint { display: flex; align-items: center; gap: 0.5rem; position: absolute; top: calc(100% + 0.5rem); left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; white-space: nowrap; }
|
|
52
|
+
.kbd-hint.visible { opacity: 1; }
|
|
53
|
+
.kbd-group { display: flex; align-items: center; gap: 0.25rem; }
|
|
54
|
+
.kbd { font-family: inherit; font-size: 0.75rem; line-height: 1; padding: 0.25rem 0.375rem; border-radius: 0.25rem; background: var(--kb-kbd-bg); border: 1px solid var(--kb-kbd-border); color: var(--kb-kbd-text); font-weight: 500; min-width: 1.25rem; text-align: center; }
|
|
55
|
+
.kbd-text { font-size: 0.75rem; color: var(--kb-kbd-text); }
|
|
56
|
+
.watermark { text-align: center; font-size: 0.625rem; color: var(--kb-watermark-text); opacity: 0.8; font-weight: 500; letter-spacing: 0.025em; }
|
|
57
|
+
.watermark a { color: inherit; text-decoration: none; cursor: pointer; }
|
|
58
|
+
.watermark a:hover { text-decoration: underline; text-decoration-color: var(--kb-watermark-text); }
|
|
59
|
+
/* Launcher hint positioning */
|
|
60
|
+
.launcher .kbd-hint { position: static; transform: none; opacity: 0.6; transition: opacity 0.2s; }
|
|
61
|
+
.launcher:hover .kbd-hint { opacity: 1; }
|
|
62
|
+
.pos-top-right.launcher .kbd-hint { left: auto; right: auto; }
|
|
63
|
+
`,Tt=(e,t,r)=>{let n=I(!1);B(()=>{let i=e.current;if(!i)return;let o=r.direction==="top-to-bottom",a=o?"translateY(-60px)":"translateX(60px)",c=o?"translateY(-20px)":"translateX(20px)",u="translate(0, 0)";if(t){n.current=!0;let l=i.animate([{opacity:0,transform:a},{opacity:1,transform:u}],{duration:500,delay:r.entranceDelayMs,easing:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fill:"forwards"});l.onfinish=()=>r.onEntranceComplete?.()}else if(n.current){let l=i.animate([{opacity:1,transform:u},{opacity:0,transform:c}],{duration:350,delay:r.exitDelayMs,easing:"ease-in-out",fill:"forwards"});l.onfinish=()=>r.onExitComplete?.()}else i.style.opacity="0",i.style.transform=c},[t,r.direction])},Ct=e=>{if(!e)return{};let t={};return e.fontFamily&&(t["--kb-font-family"]=e.fontFamily),e.backgroundColor&&(t["--kb-bg-container"]=e.backgroundColor,t["--kb-popover-bg"]=e.backgroundColor),e.borderColor&&(t["--kb-border-container"]=e.borderColor,t["--kb-popover-border"]=e.borderColor),e.textColor&&(t["--kb-text-title"]=e.textColor,t["--kb-popover-text"]=e.textColor),e.subtitleColor&&(t["--kb-text-subtitle"]=e.subtitleColor),e.borderRadius&&(t["border-radius"]=e.borderRadius,t["border-bottom-left-radius"]=e.borderRadius,t["border-bottom-right-radius"]=e.borderRadius),e.primaryColor&&(t["--kb-btn-trigger-bg"]=e.primaryColor,t["--kb-progress-indicator"]=e.primaryColor,t["--kb-success-color"]=e.primaryColor),e.primaryTextColor&&(t["--kb-btn-trigger-text"]=e.primaryTextColor),t},gr=({config:e,isOpen:t,setIsOpen:r})=>{let n=I(null),i=I(null),o=I(null),a=I(null),c=I(null),[u,l]=Se("card"),m=I(!1),s=I(!1),f=I(!1),b=I(!1),C=I("card"),M=I(e.status),S=I(!!e.isVisible),p=I(null),g=I(null),R=I(!1),[O,H]=Se(!1),[w,$]=Se(0),W=I(0),D=e.enableTimer!==!1,j=Math.max(500,e.timerDurationMs??2e4),x=vt(_=>{W.current=_,$(_)},[]);B(()=>{e.isVisible&&(l("card"),m.current=!1)},[e.isVisible]),u==="card"&&C.current==="launcher"&&(f.current=!1),e.status==="success"&&M.current!=="success"?u==="card"&&(f.current=!0):e.status!=="success"&&(f.current=!1),M.current=e.status,B(()=>{let _=C.current==="launcher",A=u==="card";_&&A&&s.current&&(b.current=!0,setTimeout(()=>{b.current=!1},100)),u==="launcher"&&H(!1),_&&A&&D&&(x(0),p.current=null,R.current=!1)},[u,x,D]),B(()=>{if(e.status==="success"&&(s.current=!0,e.enableLauncher&&u==="card"&&f.current)){let _=setTimeout(()=>{l("launcher")},2e3);return()=>clearTimeout(_)}},[e.status,e.enableLauncher,u]),B(()=>{e.isVisible&&!S.current&&D&&(x(0),p.current=null,R.current=!1),S.current=!!e.isVisible},[e.isVisible,x,D]),B(()=>{C.current=u},[u]),B(()=>{if(t){s.current&&c.current&&c.current.reset();let _=setTimeout(()=>{a.current&&a.current.focus()},100);return()=>clearTimeout(_)}},[t]),Tt(n,!!e.isVisible&&u==="card",{direction:e.direction||"top-to-bottom",position:e.position||"top-center",entranceDelayMs:m.current?0:e.entranceDelayMs||0,exitDelayMs:75,onEntranceComplete:()=>{e.onEntranceComplete?.(),m.current=!0},onExitComplete:()=>{e.isVisible||e.onExitComplete?.()}}),Tt(i,!!e.isVisible&&u==="launcher",{direction:e.direction||"top-to-bottom",position:e.position||"top-center",entranceDelayMs:0,exitDelayMs:75}),B(()=>{let _=o.current;if(!_)return;let A=e.status==="success";if(e.enableFocusMode&&u==="card"&&e.isVisible&&!A){let U=setTimeout(()=>{_.classList.add("active")},e.focusDelayMs||500);return()=>clearTimeout(U)}else _.classList.remove("active")},[e.enableFocusMode,u,e.isVisible,e.focusDelayMs,e.status]),B(()=>{if(!e.isVisible)return;let _=A=>{if(A.key==="Escape"){if(t){r(!1);return}u==="card"&&(e.enableLauncher?l("launcher"):e.onDismiss?.());return}((K,G)=>{let pe=G||{key:"p",modifiers:["meta","ctrl"]};if(K.key.toLowerCase()!==pe.key.toLowerCase())return!1;let be=pe.modifiers||[];if(G){let Dt=be.includes("meta")===K.metaKey,Nt=be.includes("ctrl")===K.ctrlKey,Ht=be.includes("alt")===K.altKey,Ot=be.includes("shift")===K.shiftKey;return Dt&&Nt&&Ht&&Ot}return K.metaKey||K.ctrlKey})(A,e.keyboardShortcut)&&(A.preventDefault(),u==="launcher"?(l("card"),r(!0)):u==="card"&&(e.enableLauncher?l("launcher"):e.onDismiss?.()))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[e.isVisible,t,u,e.enableLauncher,r,e.onDismiss]);let z=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),fe=(()=>{if(e.keyboardShortcut){let _=e.keyboardShortcut.modifiers||[],A=[];return _.includes("meta")&&A.push(z?"\u2318":"Win"),_.includes("ctrl")&&A.push("Ctrl"),_.includes("alt")&&A.push(z?"Opt":"Alt"),_.includes("shift")&&A.push("Shift"),A.push(e.keyboardShortcut.key.toUpperCase()),A}return[z?"\u2318":"Ctrl","P"]})(),F=e.status==="starting",Q=e.status==="success",re=e.status==="error",v=Q&&f.current,h=e.textOverrides||{},P=Q?h.titleSuccess||"Personalization complete":F?"Starting personalization":re?h.titleError||"Let's try that again":e.hasPersonalization?"Personalization ready":h.titleResting||"Personalization available",k=Q?h.subtitleSuccess||"Take a look":F?"Hang tight...":re?h.subtitleError||"Something went wrong. Tap to retry.":h.subtitleResting||"This page can adapt to you",T=F?h.btnLoading||"Starting...":re?h.btnError||"Try again":Q&&f.current?h.btnSuccess||"Personalised":s.current?"Show me again":h.btnResting||"Show me",Z=_=>{if(_.preventDefault(),F)return;let A=new FormData(_.target),U={};A.forEach((K,G)=>{U[G]=K.toString()}),r(!1),e.onSubmitPersonalization?.(U)},q=_=>{_.stopPropagation(),!(F||Q)&&r(!t)};B(()=>{if(!D||R.current)return;if(!(e.isVisible&&u==="card"&&e.status==="resting"&&!t&&!O)){g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),p.current=null;return}let A=U=>{p.current===null&&(p.current=U-W.current/100*j);let K=U-p.current,G=Math.min(1,K/j),pe=G*100;if(x(pe),G>=1){R.current=!0,p.current=null,g.current=null,e.enableLauncher?(l("launcher"),r(!1)):e.onDismiss?.();return}g.current=requestAnimationFrame(A)};return g.current=requestAnimationFrame(A),()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null)}},[e.enableLauncher,e.isVisible,e.onDismiss,e.status,O,t,u,r,j,D,x]),B(()=>()=>{g.current!==null&&cancelAnimationFrame(g.current)},[]);let ee=Math.max(0,Math.min(100,e.progressPct??0)),ie=D?w:ee;return d(X,{children:[d("div",{ref:o,class:"backdrop"}),d("div",{ref:n,class:`container theme-${e.theme||"glass"} pos-${e.position||"top-center"}`,style:Ct(e.customTheme),onClick:()=>!t&&!F&&!Q&&r(!0),onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1),children:[d("button",{class:"btn-dismiss","aria-label":"Dismiss",onClick:_=>{_.stopPropagation(),R.current=!0,e.enableLauncher?l("launcher"):e.onDismiss?.()},children:d(hr,{})}),d("div",{class:"content-wrapper",children:[d("div",{class:"logo",children:d(xt,{})}),d("div",{class:"text-content",children:d("div",{class:"text-row",children:[d("div",{children:[d("div",{class:"title",children:P}),d("div",{class:"subtitle",children:k})]}),d("button",{class:`btn btn-trigger ${v?"success":""}`,disabled:F||v,onClick:q,children:F?d(X,{children:[d(ze,{})," ",T]}):v?d(X,{children:[d(mr,{})," ",T]}):T})]})})]}),d("div",{class:"progress-clip",children:d("div",{class:"progress-container",children:d("div",{class:"progress-bar",style:{width:`${ie}%`}})})}),d("div",{class:`popover ${t?"open":""}`,onClick:_=>_.stopPropagation(),children:[d("form",{onSubmit:Z,ref:c,children:[e.fields.map((_,A)=>d("div",{class:"form-group",children:[d("label",{class:"form-label",children:_.label}),d("div",{class:"input-row",children:[d("input",{ref:A===0?a:void 0,class:"form-input",name:_.name,type:_.type||"text",placeholder:_.placeholder,required:_.required}),e.fields.length===1&&d("button",{type:"submit",class:"btn btn-submit",disabled:F,children:F?d(ze,{}):d(wt,{})})]})]},_.name)),e.fields.length>1&&d("button",{type:"submit",class:"btn btn-submit",style:{width:"100%"},disabled:F,children:F?d(ze,{}):d(wt,{})})]}),e.showWatermark&&d("div",{class:"watermark",children:["Powered by"," ",d("a",{href:"https://kenobi.ai",target:"_blank",rel:"noopener noreferrer",children:"Kenobi"})]})]}),e.showKeyboardHints&&e.enableFocusMode&&d("div",{class:`kbd-hint ${!t&&!F&&!Q?"visible":""}`,children:[d("div",{class:"kbd-group",children:d("div",{class:"kbd",children:"Esc"})}),d("span",{class:"kbd-text",children:"to dismiss"})]})]}),d("button",{ref:i,class:`launcher theme-${e.theme||"glass"} pos-${e.position||"top-center"}`,style:Ct(e.customTheme),onClick:_=>{_.stopPropagation(),l("card"),r(!0)},children:[d("div",{style:{display:"flex",width:"20px",height:"20px",overflow:"hidden",alignItems:"center",justifyContent:"center"},children:d("div",{style:{transform:"scale(0.6)"},children:d(xt,{})})}),e.textOverrides?.launcherLabel||(s.current?"Personalize again":"Personalize"),e.showKeyboardHints&&d("div",{class:"kbd-hint visible",children:d("div",{class:"kbd-group",children:fe.map((_,A)=>d("div",{class:"kbd",children:_},A))})})]})]})},Ae=class{constructor(t){y(this,"host");y(this,"shadow");y(this,"config");y(this,"isOpen",!1);this.config={position:"top-center",direction:"top-to-bottom",theme:"glass",entranceDelayMs:0,exitDelayMs:75,hasPersonalization:!1,isVisible:!1,progressPct:0,status:"resting",enableTimer:!0,timerDurationMs:2e4,enableLauncher:!0,enableFocusMode:!1,focusBlurIntensity:"10px",focusDelayMs:500,showKeyboardHints:!1,showWatermark:!0,...t},this.host=document.createElement("div"),this.host.id="kenobi-cue-card-root",this.host.style.cssText=`
|
|
64
|
+
position: fixed !important; z-index: 2147483647 !important;
|
|
65
|
+
top: 0 !important; left: 0 !important; width: 100% !important;
|
|
66
|
+
height: 0 !important; pointer-events: none !important; isolation: isolate !important;
|
|
67
|
+
`,this.shadow=this.host.attachShadow({mode:"open"});let r=document.createElement("style");r.textContent=_r,this.shadow.appendChild(r);let n=document.createElement("div");this.shadow.appendChild(n)}mount(t=document.body){t.contains(this.host)||t.appendChild(this.host),this.render()}unmount(){Oe(null,this.shadow.lastElementChild),this.host.remove()}update(t){this.config={...this.config,...t},this.render()}setTheme(t){this.update({theme:t})}render(){let t=this.shadow.lastElementChild;Oe(d(gr,{config:this.config,isOpen:this.isOpen,setIsOpen:r=>{this.isOpen=r,this.config.onOpenChange?.(r),this.render()}}),t)}};var St="kfor",At="kenobi_visitor_key",Y="data-kenobi-transformation-identifier",ue={enabled:!1,durationMs:300,delayMs:0,easing:"ease",animateSize:!0},vr=e=>({enabled:e?.enabled??ue.enabled,durationMs:e?.durationMs??ue.durationMs,delayMs:e?.delayMs??ue.delayMs,easing:e?.easing??ue.easing,animateSize:e?.animateSize??ue.animateSize,textAnimation:e?.textAnimation,enter:e?.enter,exit:e?.exit}),yr=(e,t)=>({enabled:t?.enabled??e.enabled,durationMs:t?.durationMs??e.durationMs,delayMs:t?.delayMs??e.delayMs,easing:t?.easing??e.easing,animateSize:t?.animateSize??e.animateSize,textAnimation:t?.textAnimation??e.textAnimation,enter:t?.enter??e.enter,exit:t?.exit??e.exit}),Mt=e=>typeof e=="string",de=e=>e instanceof HTMLElement||typeof SVGElement<"u"&&e instanceof SVGElement,kr=e=>typeof e=="string",wr=e=>e==="line"||e==="word"||e==="character",Pt=e=>typeof e!="object"||e===null?!1:Array.isArray(e)?e.every(t=>typeof t=="object"&&t!==null):!0,Et=e=>{if(typeof e!="object"||e===null)return!1;let t=e,{animationName:r,keyframes:n,durationMs:i,delayMs:o}=t;return(r===void 0||Mt(r))&&(n===void 0||Pt(n))&&(i===void 0||typeof i=="number")&&(o===void 0||typeof o=="number")},xr=e=>{if(typeof e!="object"||e===null)return!1;let t=e,{by:r,staggerMs:n,animationName:i,keyframes:o,delayMs:a,durationMs:c}=t;return wr(r)&&(a===void 0||typeof a=="number")&&(n===void 0||typeof n=="number")&&(c===void 0||typeof c=="number")&&(Mt(i)||o!==void 0)&&(o===void 0||Pt(o))},Tr=e=>{if(typeof e!="object"||e===null)return!1;let t=e,{enabled:r,durationMs:n,delayMs:i,easing:o,animateSize:a,textAnimation:c,enter:u,exit:l}=t;return(r===void 0||typeof r=="boolean")&&(n===void 0||typeof n=="number")&&(i===void 0||typeof i=="number")&&(o===void 0||kr(o))&&(a===void 0||typeof a=="boolean")&&(c===void 0||xr(c))&&(u===void 0||Et(u))&&(l===void 0||Et(l))},Ke=class{constructor(){y(this,"replaceWithTransition",async(t,r,n)=>{let i=document.createElement("div");i.style.position="relative",i.style.overflow="hidden";let o=t.getBoundingClientRect(),a=window.getComputedStyle(t);i.style.display=a.display,i.style.verticalAlign=a.verticalAlign,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`,i.style.margin=a.margin;let c=t.cloneNode(!0);if(!(c instanceof Element)||!de(c))throw new Error("oldElClone is not an AnimatableElement");c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.width="100%",c.style.height="100%",c.style.margin="0",c.style.pointerEvents="none",i.appendChild(c);let u=document.createElement("div");u.innerHTML=r;let l=u.firstElementChild;if(!l||!(l instanceof HTMLElement||l instanceof SVGElement))return await this.exit(t,n).finished,t;let m=l.style.cssText,s=t.parentNode,f;if(s instanceof HTMLElement){let w=s.cloneNode(!1),$=window.getComputedStyle(s),W=$.cssText?$.cssText:Array.from($).reduce((D,j)=>`${D}${j}:${$.getPropertyValue(j)};`,"");w.style.cssText=W,w.style.position="absolute",w.style.top="-9999px",w.style.left="-9999px",w.style.visibility="hidden",w.style.pointerEvents="none",w.appendChild(l),document.body.appendChild(w),n.textAnimation&&this.applyTextAnimationToNode(l,n.textAnimation,n),f=l.getBoundingClientRect(),document.body.removeChild(w)}else{let w=document.createElement("div");w.style.position="absolute",w.style.top="-9999px",w.style.left="-9999px",w.style.visibility="hidden",w.appendChild(l),document.body.appendChild(w),n.textAnimation&&this.applyTextAnimationToNode(l,n.textAnimation,n),f=l.getBoundingClientRect(),document.body.removeChild(w)}l.style.cssText=m,l.style.visibility="",l.style.position="absolute",l.style.top="0",l.style.left="0",l.style.width=`${f.width}px`,l.style.height=`${f.height}px`,l.style.margin="0",l.style.opacity="0",i.appendChild(l),t.replaceWith(i);let b=n.exit?.delayMs??n.delayMs,C=n.exit?.durationMs??n.durationMs,M=n.enter?.delayMs??n.delayMs,S=n.enter?.durationMs??n.durationMs,p=[],g=this.resolveKeyframes(n.exit?.keyframes),R=c.animate(g,{duration:C,delay:b,easing:n.easing,fill:"forwards"});p.push(R);let O=this.resolveKeyframes(n.enter?.keyframes),H=l.animate(O,{duration:S,delay:M,easing:n.easing,fill:"forwards"});if(p.push(H),n.animateSize){let w=i.animate([{width:`${o.width}px`,height:`${o.height}px`},{width:`${f.width}px`,height:`${f.height}px`}],{duration:S,delay:M,easing:n.easing,fill:"forwards"});p.push(w)}return await Promise.all(p.map(w=>w.finished)),i.parentNode&&i.replaceWith(l),l.style.cssText=m,c.remove(),l});y(this,"enter",(t,r)=>{let n=r.enter?.delayMs??r.delayMs,i=r.enter?.durationMs??r.durationMs,o=this.resolveKeyframes(r.enter?.keyframes);return t.animate(o,{duration:i,delay:n,easing:r.easing,fill:"forwards"})});y(this,"exit",(t,r)=>{let n=r.exit?.delayMs??r.delayMs,i=r.exit?.durationMs??r.durationMs,o=this.resolveKeyframes(r.exit?.keyframes);return t.animate(o,{duration:i,delay:n,easing:r.easing,fill:"forwards"})});y(this,"resolveKeyframes",t=>t?Array.isArray(t)?t:[t]:[]);y(this,"applyTextAnimationToNode",(t,r,n)=>{let i=r.delayMs??0,o=window.getComputedStyle(t),a=o.getPropertyValue("background-clip")==="text"||o.getPropertyValue("-webkit-background-clip")==="text",c=(u,l,m)=>{if(u.nodeType===Node.TEXT_NODE){let s=u.textContent??"";if(s.trim().length===0)return l;let f;switch(r.by){case"character":f=s.split("");break;case"word":f=s.split(/(\s+)/);break;case"line":f=s.split(`
|
|
68
|
+
`);break}let b=document.createDocumentFragment(),C=l;return f.forEach(M=>{if(M.length===0)return;if(M.trim().length===0){b.appendChild(document.createTextNode(M));return}let p=document.createElement("span");p.textContent=M,p.style.display="inline-block",p.style.opacity="0",m&&(p.style.setProperty("background","inherit"),p.style.setProperty("-webkit-background-clip","text"),p.style.setProperty("background-clip","text"),p.style.setProperty("color","transparent"),p.style.setProperty("will-change","opacity, transform"));let g=this.resolveKeyframes(r.keyframes),R=r.durationMs??n.durationMs??300,O=n.easing??"ease",H=p.animate(g,{duration:R,easing:O,delay:C,fill:"forwards"});H.addEventListener("finish",()=>{H.commitStyles(),H.cancel()}),b.appendChild(p),C+=r.staggerMs??50}),u.parentNode?.replaceChild(b,u),C}if(u.nodeType===Node.ELEMENT_NODE){let s=l,f=Array.from(u.childNodes);for(let b of f)s=c(b,s,m);return s}return l};c(t,i,a)})}},Rt=new Set(["Replace","InsertBefore","InsertAfter","Delete","SetFormField"]),Lt=e=>typeof e=="string",Cr=e=>Array.isArray(e)&&e.every(t=>Lt(t)),Sr=e=>typeof e=="string"&&Rt.has(e),Ar=e=>{if(typeof e!="object"||e===null)return!1;let t=e;return Lt(t.identifier)&&typeof t.markup=="string"&&Cr(t.selectorGuesses)&&Sr(t.action)&&(t.transition===void 0||Tr(t.transition))},Er=e=>{if(typeof e!="object"||e===null)throw new Error("Invalid response: expected object with data array");let t=e.data;if(!Array.isArray(t))throw new Error("Invalid response: data must be an array");return t.forEach((r,n)=>{if(!Ar(r))throw new Error(`Invalid transformation at index ${n}`)}),t},Ve=class{constructor(t){y(this,"config");y(this,"changeStack",new Map);y(this,"visitorKey",null);y(this,"orchestrator");y(this,"currentPath");y(this,"currentUrl");y(this,"navTicking",!1);y(this,"transitionDefaults");y(this,"startAutoTransform",async()=>{try{this.syncChangeStack(),await this.waitForLoaded(),this.isFramer()&&(await this.waitForFrames(),await this.waitForIdle(),await this.waitForQuietDom(100,1e3)),await this.transform()}catch(t){this.log("error","Auto-transformation flow failed with error:",t)}});y(this,"transform",async()=>{try{let t=new Date;if(this.log("debug","Starting transform"),this.visitorKey===null){this.log("debug",`Couldn't find a visitor copy external ID with query param key "${St}"`,"Exiting...");return}let r=[];try{r=await this.getTransformations(this.currentPath,this.visitorKey)}catch(o){this.log("error_detailed","An error occurred _getting_ transformations",o)}try{await this.applyTransformations(r)}catch(o){this.log("error_detailed","An error occurred _applying_ transformations",o)}let n=new Date,i=this.getDurationInMilliseconds(t,n);this.log("debug",`Transformation complete, took ${this.formatThousands(i)} ms`)}catch(t){this.log("error","An unexpected, top-level error occurred during transformation",t)}});y(this,"log",(t,r,...n)=>{let a=`${`[Kenobi \u25D4] (v${typeof window.__KENOBI_VERSION__<"u"?window.__KENOBI_VERSION__:"dev"})`} [${t.toLocaleUpperCase()}] :: ${r}`;switch(t){case"debug":this.config.debug&&console.log(a,...n);break;case"info":console.log(a,...n);break;case"warn":console.warn(a,...n);break;case"error_detailed":console.trace(...n);case"error":console.error(a,...n);break}});y(this,"resolveTransitionConfig",t=>yr(this.transitionDefaults,t));y(this,"retrieveElement",t=>{if(!Array.isArray(t)||t.some(r=>typeof r!="string"))throw new Error(`Invalid selectorGuesses payload received: expected array of strings but got ${JSON.stringify(t)}`);for(let r of t){let n=document.querySelector(r);if(n!==null)return n}throw new Error(`Could not find an element in the document with any of these selector patterns: ${t.join(", ")}`)});y(this,"getQueryParam",t=>new URLSearchParams(window.location.search).get(t));y(this,"getCurrentPath",()=>window.location.pathname);y(this,"getCurrentUrl",()=>window.location.pathname+window.location.search+window.location.hash);y(this,"getDurationInMilliseconds",(t,r)=>+r-+t);y(this,"formatThousands",t=>new Intl.NumberFormat("en-US").format(t));y(this,"setDebug",t=>this.config.debug=t);y(this,"isInputElement",t=>!(!(t instanceof HTMLInputElement)&&!(t instanceof HTMLTextAreaElement)&&!(t instanceof HTMLSelectElement)));y(this,"waitForFrames",()=>new Promise(t=>requestAnimationFrame(()=>requestAnimationFrame(t))));y(this,"waitForIdle",(t=1e3)=>new Promise(r=>"requestIdleCallback"in window?window.requestIdleCallback(()=>r(),{timeout:t}):setTimeout(r,50)));y(this,"waitForLoaded",()=>document.readyState==="complete"?Promise.resolve():new Promise(t=>window.addEventListener("load",()=>t(),{once:!0})));y(this,"waitForQuietDom",(t,r)=>new Promise(n=>{let i=performance.now(),o=new MutationObserver(()=>{i=performance.now()});o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let a=performance.now()+t;(function c(){let u=performance.now();if(u-i>=r){o.disconnect(),n();return}if(u>=a){o.disconnect(),n();return}requestAnimationFrame(c)})()}));y(this,"isFramer",()=>{let t=Array.from(document.scripts).map(n=>n.src||"");return["__framer_events"in window,document.querySelector("[data-framer-root],[data-framer-component],[data-framer-page]"),t.some(n=>/framerusercontent\.com\/sites/i.test(n))].some(n=>!!n)});y(this,"syncVisitorKey",()=>{try{let t=this.getQueryParam(St);t?(this.log("debug",`Query param value found (${t}), pushing into session storage`),sessionStorage.setItem(At,t),this.visitorKey=t):this.visitorKey=sessionStorage.getItem(At)}catch(t){this.log("error","Failed to sync visitor key with error:",t)}});y(this,"initNavigationListener",()=>{if("__KENOBI_NAV_HOOKED__"in window)return;window.__KENOBI_NAV_HOOKED__=!0;let t=i=>{this.navTicking||(this.navTicking=!0,queueMicrotask(()=>{this.navTicking=!1;let o=this.getCurrentUrl();o!==this.currentUrl&&(this.currentUrl=o,this.currentPath=this.getCurrentPath(),this.log("debug",`URL changed (${i}) \u2192 ${location.href}`),this.config.autoTransform&&(this.undoAll(),this.startAutoTransform()))}))};if("navigation"in window){let i=window.navigation;i&&"addEventListener"in i&&typeof i.addEventListener=="function"&&(i.addEventListener("navigate",()=>t("navigation:navigate")),i.addEventListener("currententrychange",()=>t("navigation:entrychange")),i.addEventListener?.("navigatesuccess",()=>t("navigation:success")))}let r=history.pushState.bind(history),n=history.replaceState.bind(history);history.pushState=((...i)=>{let o=r(...i);return t("pushState"),o}),history.replaceState=((...i)=>{let o=n(...i);return t("replaceState"),o}),window.addEventListener("popstate",()=>t("popstate")),window.addEventListener("hashchange",()=>t("hashchange")),document.addEventListener("click",i=>{let o=i.target,a=o&&o.closest?.("a[href]");!a||a.target&&a.target!=="_self"||new URL(a.href,location.href).origin!==location.origin||setTimeout(()=>t("click"),0)},!0),setInterval(()=>{this.getCurrentUrl()!==this.currentUrl&&t("poll")},1e3)});y(this,"getTransformations",async(t,r)=>{let n=new URLSearchParams({path:t}),i=await fetch(`${this.config.apiHost}/v1/visitor-copy-transformations/${r}?${n.toString()}`),o=await i.json();if(!i.ok)throw new Error(`Network error (status ${i.status}) with json body: ${JSON.stringify(o,null,2)}`);return Er(o)});y(this,"validateTransitionPreconditions",(t,r,n)=>{if(n.enabled){let i=document.createElement("div");i.innerHTML=r;let o=i.firstElementChild;if(!o||!de(o))return this.log("warn",`Transformation "${t}" was skipped: A transition was requested, but the element is not animatable.`),!1}return!0});y(this,"applyTransformations",async(t,r)=>{this.log("debug",`Starting ${t.length} transformations`),r?.shouldConsolidate&&this.changeStack.forEach((n,i)=>{t.find(a=>a.identifier===i)&&this.undo(i)});for(let{identifier:n,...i}of t)try{if(this.changeStack.get(n))throw new Error("Transformation already exists in stack");let o=this.retrieveElement(i.selectorGuesses);switch(i.action){case"Replace":{let a=o.outerHTML,c=this.resolveTransitionConfig(i.transition);if(c.enabled&&de(o)&&"animate"in o){let u=await this.orchestrator.replaceWithTransition(o,i.markup,c);this.setOrUpdateReplaceChangeRef(n,a,u)}else ge(o,i.markup,{}),this.setOrUpdateReplaceChangeRef(n,a,o);o.nodeName==="VIDEO"&&o.play();break}case"InsertBefore":{let a=this.resolveTransitionConfig(i.transition);if(!this.validateTransitionPreconditions(n,i.markup,a))break;o.insertAdjacentHTML("beforebegin",i.markup);let c=o.previousElementSibling;if(c===null)throw new Error("Element wasn't created");if(c.setAttribute(Y,n),a.enabled&&de(c)){let u=c.style.cssText;c.style.opacity="0",this.orchestrator.enter(c,{...a,delayMs:a.enter?.delayMs??a.delayMs}).addEventListener("finish",()=>{c.style.cssText=u},{once:!0})}this.changeStack.set(n,{undoOpts:{type:"Remove",ref:c}});break}case"InsertAfter":{let a=this.resolveTransitionConfig(i.transition);if(!this.validateTransitionPreconditions(n,i.markup,a))break;o.insertAdjacentHTML("afterend",i.markup);let c=o.nextElementSibling;if(c===null)throw new Error("Element wasn't created");if(c.setAttribute(Y,n),a.enabled&&de(c)){let u=c.style.cssText;c.style.opacity="0",this.orchestrator.enter(c,{...a,delayMs:a.enter?.delayMs??a.delayMs}).addEventListener("finish",()=>{c.style.cssText=u},{once:!0})}this.changeStack.set(n,{undoOpts:{type:"Remove",ref:c}});break}case"Delete":{let a=o.outerHTML;ge(o,'<div style="display: none;" data-kenobi-delete-marker="true"></div>',{}),o.setAttribute(Y,n),this.changeStack.set(n,{undoOpts:{type:"Replace",ref:o,content:a}});break}case"SetFormField":{if(!this.isInputElement(o))throw new Error("Element targeted is not of a supported type");let a=o.value;this.setInputValue(o,i.markup),o.setAttribute(Y,n),this.changeStack.set(n,{undoOpts:{type:"SetInput",ref:o,content:a}})}}}catch(o){this.log("warn",`Unable to apply transformation with identifier "${n}"`,o)}});y(this,"setOrUpdateReplaceChangeRef",(t,r,n)=>{let i=this.changeStack.get(t);if(!i){n.setAttribute(Y,t),this.changeStack.set(t,{undoOpts:{type:"Replace",ref:n,content:r}});return}let o=i.undoOpts.ref;o&&o!==n&&o.isConnected&&o.removeAttribute(Y),n.setAttribute(Y,t),i.undoOpts.ref=n});y(this,"syncChangeStack",()=>{let t=0;for(let[r,n]of this.changeStack){let i=n.undoOpts.ref;if(!(!!i&&(i.isConnected||document.contains(i)))){this.changeStack.delete(r),t++;continue}i.getAttribute(Y)!==r&&(this.changeStack.delete(r),t++)}this.log("debug",`syncChangeStack pruned ${this.formatThousands(t)} stale entries`)});y(this,"undo",t=>{let r=this.changeStack.get(t);if(r===void 0)throw new Error(`Cannot undo stack item with identifier ${t} as it does not exist.`);let{undoOpts:n}=r;switch(n.type){case"Remove":{n.ref.remove();break}case"Replace":{ge(n.ref,n.content),n.ref.removeAttribute(Y);break}case"SetInput":{if(!this.isInputElement(n.ref))throw new Error("Element targeted is not of a supported type");this.setInputValue(n.ref,n.content),n.ref.removeAttribute(Y);break}}this.changeStack.delete(t)});y(this,"undoAll",()=>{this.changeStack.forEach((t,r)=>this.undo(r))});y(this,"setInputValue",(t,r)=>{let n=t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:t instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLSelectElement.prototype,i=Object.getOwnPropertyDescriptor(n,"value");if(!i?.set)throw new Error("No value setter found");i.set.call(t,r),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))});this.config={apiHost:"https://kenobi.ai/api",debug:!1,autoTransform:!0,...t},this.transitionDefaults=vr(this.config.transitionDefaults),this.orchestrator=new Ke,this.syncVisitorKey(),this.currentPath=this.getCurrentPath(),this.currentUrl=this.getCurrentUrl();try{this.initNavigationListener()}catch(r){this.log("error","Failed to initialize navigation listener with error:",r)}this.log("debug","Kenobi initialized"),this.config.autoTransform&&(this.log("debug","Auto-transform is requested... Starting..."),this.startAutoTransform())}};return $t(Mr);})();
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kenobi-js",
|
|
3
|
+
"version": "0.1.28",
|
|
4
|
+
"description": "Kenobi JavaScript SDK",
|
|
5
|
+
"main": "dist/kenobi.min.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/kenobi.min.js",
|
|
8
|
+
"./lib": "./src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"bump": "pnpm version patch",
|
|
15
|
+
"build": "tsx src/build.ts --prod",
|
|
16
|
+
"dev": "tsx src/build.ts --watch",
|
|
17
|
+
"tsc": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"morphdom": "^2.7.7",
|
|
24
|
+
"preact": "^10.27.2"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"esbuild": "^0.25.9",
|
|
28
|
+
"typescript": "catalog:"
|
|
29
|
+
}
|
|
30
|
+
}
|