obi-sdk 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { O as ObiWidget, s as setGlobalContext, t as trackEvent, c as captureException, w as withSentryAsyncHandler, a as withSentryHandler } from "./chunks/obi-widget-c52bfca4.js";
1
+ import { O as ObiWidget, s as setGlobalContext, t as trackEvent, c as captureException, w as withSentryAsyncHandler, a as withSentryHandler } from "./chunks/obi-widget-9e8ccac7.js";
2
2
  import "./chunks/types-e0297e7b.js";
3
3
  if (!customElements.get("obi-widget")) {
4
4
  customElements.define("obi-widget", ObiWidget);
@@ -1,6 +1,6 @@
1
1
  import { S as SDKState } from "./chunks/types-e0297e7b.js";
2
- import { i, n, b as i$1, x } from "./chunks/obi-widget-c52bfca4.js";
3
- import { A, C, e, f, D, N, d, O, S } from "./chunks/obi-widget-c52bfca4.js";
2
+ import { i, n, b as i$1, x } from "./chunks/obi-widget-9e8ccac7.js";
3
+ import { A, C, e, f, D, N, d, O, S } from "./chunks/obi-widget-9e8ccac7.js";
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __decorateClass = (decorators, target, key, kind) => {
@@ -85,14 +85,14 @@ if (!customElements.get("obi-status-widget")) {
85
85
  const statusWidget = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, ObiStatusWidget }, Symbol.toStringTag, { value: "Module" }));
86
86
  function defineCustomElements() {
87
87
  Promise.resolve().then(() => statusWidget);
88
- import("./chunks/index-d50e99a5.js");
89
- import("./chunks/obi-widget-c52bfca4.js").then((n2) => n2.l);
90
- import("./chunks/obi-widget-c52bfca4.js").then((n2) => n2.m);
91
- import("./chunks/obi-widget-c52bfca4.js").then((n2) => n2.g);
92
- import("./chunks/obi-widget-c52bfca4.js").then((n2) => n2.h);
93
- import("./chunks/obi-widget-c52bfca4.js").then((n2) => n2.o);
94
- import("./chunks/obi-widget-c52bfca4.js").then((n2) => n2.j);
95
- import("./chunks/obi-widget-c52bfca4.js").then((n2) => n2.k);
88
+ import("./chunks/index-8d3d1cc8.js");
89
+ import("./chunks/obi-widget-9e8ccac7.js").then((n2) => n2.l);
90
+ import("./chunks/obi-widget-9e8ccac7.js").then((n2) => n2.m);
91
+ import("./chunks/obi-widget-9e8ccac7.js").then((n2) => n2.g);
92
+ import("./chunks/obi-widget-9e8ccac7.js").then((n2) => n2.h);
93
+ import("./chunks/obi-widget-9e8ccac7.js").then((n2) => n2.o);
94
+ import("./chunks/obi-widget-9e8ccac7.js").then((n2) => n2.j);
95
+ import("./chunks/obi-widget-9e8ccac7.js").then((n2) => n2.k);
96
96
  }
97
97
  export {
98
98
  A as AudioEqualizer,
@@ -550,7 +550,7 @@
550
550
  margin: 0;
551
551
  text-align: center;
552
552
  }
553
- `,XU([np({type:Array})],YU.prototype,"courses",2),XU([np({type:Boolean})],YU.prototype,"loading",2),XU([np({type:String})],YU.prototype,"error",2),XU([np({type:String})],YU.prototype,"apiKey",2),XU([np({type:Function})],YU.prototype,"onClose",2),XU([rp()],YU.prototype,"apiBaseUrl",2),XU([rp()],YU.prototype,"selectedCourse",2),customElements.get("obi-course-modal")||customElements.define("obi-course-modal",YU);class $U{constructor(A){}get Ut(){return this.Qt.Ut}dt(A,t,e){this.Ye=A,this.Qt=t,this.$e=e}Bt(A,t){return this.update(A,t)}update(A,t){return this.render(...t)}}const WU=(A,t)=>{const e=A.wt;if(void 0===e)return!1;for(const i of e)i.ut?.(t,!1),WU(i,t);return!0},ZU=A=>{let t,e;do{if(void 0===(t=A.Qt))break;e=t.wt,e.delete(A),A=t}while(0===e?.size)},qU=A=>{for(let t;t=A.Qt;A=t){let e=t.wt;if(void 0===e)t.wt=e=new Set;else if(e.has(A))break;e.add(A),tC(t)}};function zU(A){void 0!==this.wt?(ZU(this),this.Qt=A,qU(this)):this.Qt=A}function AC(A,t=!1,e=0){const i=this.yt,n=this.wt;if(void 0!==n&&0!==n.size)if(t)if(Array.isArray(i))for(let r=e;r<i.length;r++)WU(i[r],!1),ZU(i[r]);else null!=i&&(WU(i,!1),ZU(i));else WU(this,A)}const tC=A=>{2==A.type&&(A.kt??(A.kt=AC),A.We??(A.We=zU))};class eC extends $U{constructor(){super(...arguments),this.wt=void 0}dt(A,t,e){super.dt(A,t,e),qU(this),this.isConnected=A.Ut}ut(A,t=!0){A!==this.isConnected&&(this.isConnected=A,A?this.reconnected?.():this.disconnected?.()),t&&(WU(this,A),ZU(this))}setValue(A){if(void 0===this.Ye.strings)this.Ye.Ct(A,this);else{const t=[...this.Ye.yt];t[this.$e]=A,this.Ye.Ct(t,this,0)}}disconnected(){}reconnected(){}}class iC{}const nC=new WeakMap,rC=(sC=class extends eC{render(A){return _g}update(A,[t]){const e=t!==this.G;return e&&void 0!==this.G&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=A.options?.host,this.rt(this.ct=A.element)),_g}rt(A){if(this.isConnected||(A=void 0),"function"==typeof this.G){const t=this.ht??globalThis;let e=nC.get(t);void 0===e&&(e=new WeakMap,nC.set(t,e)),void 0!==e.get(this.G)&&this.G.call(this.ht,void 0),e.set(this.G,A),void 0!==A&&this.G.call(this.ht,A)}else this.G.value=A}get lt(){return"function"==typeof this.G?nC.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}},(...A)=>({ot:sC,values:A}));var sC,oC=Object.defineProperty,aC=Object.getOwnPropertyDescriptor,cC=(A,t,e,i)=>{for(var n,r=i>1?void 0:i?aC(t,e):t,s=A.length-1;s>=0;s--)(n=A[s])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&oC(t,e,r),r};class uC extends Ap{constructor(){super(...arguments),this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.canvasRef=new iC,this.barCount=8,this.animationFrame=null,this.primaryColor=Pa}connectedCallback(){super.connectedCallback(),this.primaryColor=getComputedStyle(this).getPropertyValue("--obi-primary").trim()||Pa,this.startAnimation()}disconnectedCallback(){super.disconnectedCallback(),this.stopAnimation()}startAnimation(){const A=()=>{this.drawEqualizer(),this.animationFrame=requestAnimationFrame(A)};this.animationFrame=requestAnimationFrame(A)}stopAnimation(){this.animationFrame&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=null)}drawEqualizer(){const A=this.canvasRef.value;if(!A)return;const t=A.getContext("2d");if(!t)return;const e=window.devicePixelRatio||1,i=A.clientWidth,n=A.clientHeight;A.width=Math.round(i*e),A.height=Math.round(n*e),t.scale(e,e),t.imageSmoothingEnabled=!1,t.clearRect(0,0,i,n);const r=Math.max(1,(i-3*(this.barCount-1))/this.barCount),s=n/2,o=(this.volume.speaker,this.volume.volume),a=(this.volume.speaker,this.volume.spectrum);if(0===o)return;let c=[];if(a&&a.length>0){const A=a.length,t=Math.ceil(A/10);let e=[];for(let c=0;c<10;c++){const i=c*t,n=Math.min((c+1)*t,A);let r=0;for(let A=i;A<n;A++)r+=a[A]||0;e.push({region:c,startIdx:i,endIdx:n,energy:r})}e.sort(((A,t)=>t.energy-A.energy));const i=e.slice(0,3),n=Math.min(...i.map((A=>A.startIdx))),r=Math.max(...i.map((A=>A.endIdx)));if(r>n)for(let u=0;u<this.barCount;u++){const t=n+u/(this.barCount-1)*(r-n),e=Math.min(A-1,Math.floor(t));c[u]=a[e]||0}else for(let u=0;u<this.barCount;u++){const t=u/(this.barCount-1)*(A/2),e=Math.min(A-1,Math.floor(t));c[u]=a[e]||0}const s=Math.max(...c,1),o="USER"===this.volume.speaker?.7:.6;c=c.map(((A,t)=>{const e=A/s,i=o+t/(this.barCount-1)*.3;return Math.min(1,e*i)}))}else if("USER"!==this.volume.speaker)for(let u=0;u<this.barCount;u++){const A=.002*Date.now(),t=.3+.2*Math.sin(A+.7*u);c[u]=t}for(let u=0;u<this.barCount;u++){const A=c.length>0&&void 0!==c[u]?c[u]:o;if("USER"===this.volume.speaker){const e=Math.floor(255*(.5*A+.5)).toString(16).padStart(2,"0");t.fillStyle=`${this.primaryColor}${e}`}else{const e=Math.floor(255*(.5*A+.5)).toString(16).padStart(2,"0");t.fillStyle=`#FFFFFF${e}`}const e=Math.max(2,.8*A*s),a=i-(this.barCount-u)*(r+3),h=r/2;t.beginPath(),t.moveTo(a+h,n/2-e),t.lineTo(a+r-h,n/2-e),t.quadraticCurveTo(a+r,n/2-e,a+r,n/2-e+h),t.lineTo(a+r,n/2),t.lineTo(a,n/2),t.lineTo(a,n/2-e+h),t.quadraticCurveTo(a,n/2-e,a+h,n/2-e),t.fill(),t.beginPath(),t.moveTo(a,n/2),t.lineTo(a+r,n/2),t.lineTo(a+r,n/2+e-h),t.quadraticCurveTo(a+r,n/2+e,a+r-h,n/2+e),t.lineTo(a+h,n/2+e),t.quadraticCurveTo(a,n/2+e,a,n/2+e-h),t.lineTo(a,n/2),t.fill()}}render(){return Mg` <canvas ${rC(this.canvasRef)} width="40" height="40"></canvas> `}}uC.styles=zw`
553
+ `,XU([np({type:Array})],YU.prototype,"courses",2),XU([np({type:Boolean})],YU.prototype,"loading",2),XU([np({type:String})],YU.prototype,"error",2),XU([np({type:String})],YU.prototype,"apiKey",2),XU([np({type:Function})],YU.prototype,"onClose",2),XU([rp()],YU.prototype,"apiBaseUrl",2),XU([rp()],YU.prototype,"selectedCourse",2),customElements.get("obi-course-modal")||customElements.define("obi-course-modal",YU);class $U{constructor(A){}get Ut(){return this.Qt.Ut}dt(A,t,e){this.Ye=A,this.Qt=t,this.$e=e}Bt(A,t){return this.update(A,t)}update(A,t){return this.render(...t)}}const WU=(A,t)=>{const e=A.wt;if(void 0===e)return!1;for(const i of e)i.ut?.(t,!1),WU(i,t);return!0},ZU=A=>{let t,e;do{if(void 0===(t=A.Qt))break;e=t.wt,e.delete(A),A=t}while(0===e?.size)},qU=A=>{for(let t;t=A.Qt;A=t){let e=t.wt;if(void 0===e)t.wt=e=new Set;else if(e.has(A))break;e.add(A),tC(t)}};function zU(A){void 0!==this.wt?(ZU(this),this.Qt=A,qU(this)):this.Qt=A}function AC(A,t=!1,e=0){const i=this.yt,n=this.wt;if(void 0!==n&&0!==n.size)if(t)if(Array.isArray(i))for(let r=e;r<i.length;r++)WU(i[r],!1),ZU(i[r]);else null!=i&&(WU(i,!1),ZU(i));else WU(this,A)}const tC=A=>{2==A.type&&(A.kt??(A.kt=AC),A.We??(A.We=zU))};class eC extends $U{constructor(){super(...arguments),this.wt=void 0}dt(A,t,e){super.dt(A,t,e),qU(this),this.isConnected=A.Ut}ut(A,t=!0){A!==this.isConnected&&(this.isConnected=A,A?this.reconnected?.():this.disconnected?.()),t&&(WU(this,A),ZU(this))}setValue(A){if(void 0===this.Ye.strings)this.Ye.Ct(A,this);else{const t=[...this.Ye.yt];t[this.$e]=A,this.Ye.Ct(t,this,0)}}disconnected(){}reconnected(){}}class iC{}const nC=new WeakMap,rC=(sC=class extends eC{render(A){return _g}update(A,[t]){const e=t!==this.G;return e&&void 0!==this.G&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=A.options?.host,this.rt(this.ct=A.element)),_g}rt(A){if(this.isConnected||(A=void 0),"function"==typeof this.G){const t=this.ht??globalThis;let e=nC.get(t);void 0===e&&(e=new WeakMap,nC.set(t,e)),void 0!==e.get(this.G)&&this.G.call(this.ht,void 0),e.set(this.G,A),void 0!==A&&this.G.call(this.ht,A)}else this.G.value=A}get lt(){return"function"==typeof this.G?nC.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}},(...A)=>({ot:sC,values:A}));var sC,oC=Object.defineProperty,aC=Object.getOwnPropertyDescriptor,cC=(A,t,e,i)=>{for(var n,r=i>1?void 0:i?aC(t,e):t,s=A.length-1;s>=0;s--)(n=A[s])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&oC(t,e,r),r};class uC extends Ap{constructor(){super(...arguments),this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.canvasRef=new iC,this.barCount=8,this.animationFrame=null,this.primaryColor=Pa}connectedCallback(){super.connectedCallback(),this.primaryColor=getComputedStyle(this).getPropertyValue("--obi-primary").trim()||Pa,this.startAnimation()}disconnectedCallback(){super.disconnectedCallback(),this.stopAnimation()}startAnimation(){const A=()=>{this.drawEqualizer(),this.animationFrame=requestAnimationFrame(A)};this.animationFrame=requestAnimationFrame(A)}stopAnimation(){this.animationFrame&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=null)}drawEqualizer(){const A=this.canvasRef.value;if(!A)return;const t=A.getContext("2d");if(!t)return;const e=window.devicePixelRatio||1,i=A.clientWidth,n=A.clientHeight;A.width=Math.round(i*e),A.height=Math.round(n*e),t.scale(e,e),t.imageSmoothingEnabled=!1,t.clearRect(0,0,i,n);const r=Math.max(1,(i-3*(this.barCount-1))/this.barCount),s=n/2,o=(this.volume.speaker,this.volume.volume),a=(this.volume.speaker,this.volume.spectrum);if(0===o)return;let c=[];if(a&&a.length>0){const A=a.length,t=Math.ceil(A/10);let e=[];for(let c=0;c<10;c++){const i=c*t,n=Math.min((c+1)*t,A);let r=0;for(let A=i;A<n;A++)r+=a[A]||0;e.push({region:c,startIdx:i,endIdx:n,energy:r})}e.sort(((A,t)=>t.energy-A.energy));const i=e.slice(0,3),n=Math.min(...i.map((A=>A.startIdx))),r=Math.max(...i.map((A=>A.endIdx)));if(r>n)for(let u=0;u<this.barCount;u++){const t=n+u/(this.barCount-1)*(r-n),e=Math.min(A-1,Math.floor(t));c[u]=a[e]||0}else for(let u=0;u<this.barCount;u++){const t=u/(this.barCount-1)*(A/2),e=Math.min(A-1,Math.floor(t));c[u]=a[e]||0}const s=Math.max(...c,1),o="USER"===this.volume.speaker?.7:.6;c=c.map(((A,t)=>{const e=A/s,i=o+t/(this.barCount-1)*.3;return Math.min(1,e*i)}))}else if("USER"!==this.volume.speaker)for(let u=0;u<this.barCount;u++){const A=.002*Date.now(),t=.3+.2*Math.sin(A+.7*u);c[u]=t}for(let u=0;u<this.barCount;u++){const A=c.length>0&&void 0!==c[u]?c[u]:o;"USER"===this.volume.speaker?t.fillStyle=`${this.primaryColor}`:t.fillStyle="#FFFFFF";const e=Math.max(2,.8*A*s),a=i-(this.barCount-u)*(r+3),h=r/2;t.beginPath(),t.moveTo(a+h,n/2-e),t.lineTo(a+r-h,n/2-e),t.quadraticCurveTo(a+r,n/2-e,a+r,n/2-e+h),t.lineTo(a+r,n/2),t.lineTo(a,n/2),t.lineTo(a,n/2-e+h),t.quadraticCurveTo(a,n/2-e,a+h,n/2-e),t.fill(),t.beginPath(),t.moveTo(a,n/2),t.lineTo(a+r,n/2),t.lineTo(a+r,n/2+e-h),t.quadraticCurveTo(a+r,n/2+e,a+r-h,n/2+e),t.lineTo(a+h,n/2+e),t.quadraticCurveTo(a,n/2+e,a,n/2+e-h),t.lineTo(a,n/2),t.fill()}}render(){return Mg` <canvas ${rC(this.canvasRef)} width="40" height="40"></canvas> `}}uC.styles=zw`
554
554
  :host {
555
555
  display: block;
556
556
  width: 40px;