@hidemikimura/chit-ui 0.1.0 → 0.2.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.
@@ -1,4 +1,4 @@
1
- const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new WeakMap;let n=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=i.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&i.set(s,t))}return t}toString(){return this.cssText}};const o=(t,...e)=>{const i=1===t.length?t[0]:e.reduce((e,s,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[i+1],t[0]);return new n(i,t,s)},r=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:a,defineProperty:h,getOwnPropertyDescriptor:l,getOwnPropertyNames:c,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,u=globalThis,m=u.trustedTypes,f=m?m.emptyScript:"",g=u.reactiveElementPolyfillSupport,b=(t,e)=>t,v={toAttribute(t,e){switch(e){case Boolean:t=t?f:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!a(t,e),$={attribute:!0,type:String,converter:v,reflect:!1,useDefault:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),u.litPropertyMetadata??=new WeakMap;let w=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&h(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(b("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b("properties"))){const t=this.properties,e=[...c(t),...d(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const s=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((s,i)=>{if(e)s.adoptedStyleSheets=i.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of i){const i=document.createElement("style"),n=t.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}})(s,this.constructor.elementStyles),s}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:v).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:v;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??y)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};w.elementStyles=[],w.shadowRootOptions={mode:"open"},w[b("elementProperties")]=new Map,w[b("finalized")]=new Map,g?.({ReactiveElement:w}),(u.reactiveElementVersions??=[]).push("2.1.2");const x=globalThis,_=t=>t,S=x.trustedTypes,A=S?S.createPolicy("lit-html",{createHTML:t=>t}):void 0,E="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,k="?"+C,T=`<${k}>`,O=document,U=()=>O.createComment(""),P=t=>null===t||"object"!=typeof t&&"function"!=typeof t,L=Array.isArray,R="[ \t\n\f\r]",z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,N=/>/g,H=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,I=/"/g,j=/^(?:script|style|textarea|title)$/i,D=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),q=D(1),F=D(2),W=Symbol.for("lit-noChange"),K=Symbol.for("lit-nothing"),G=new WeakMap,J=O.createTreeWalker(O,129);function V(t,e){if(!L(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==A?A.createHTML(e):e}class Y{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,a=this.parts,[h,l]=((t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=z;for(let e=0;e<s;e++){const s=t[e];let a,h,l=-1,c=0;for(;c<s.length&&(r.lastIndex=c,h=r.exec(s),null!==h);)c=r.lastIndex,r===z?"!--"===h[1]?r=M:void 0!==h[1]?r=N:void 0!==h[2]?(j.test(h[2])&&(n=RegExp("</"+h[2],"g")),r=H):void 0!==h[3]&&(r=H):r===H?">"===h[0]?(r=n??z,l=-1):void 0===h[1]?l=-2:(l=r.lastIndex-h[2].length,a=h[1],r=void 0===h[3]?H:'"'===h[3]?I:B):r===I||r===B?r=H:r===M||r===N?r=z:(r=H,n=void 0);const d=r===H&&t[e+1].startsWith("/>")?" ":"";o+=r===z?s+T:l>=0?(i.push(a),s.slice(0,l)+E+s.slice(l)+C+d):s+C+(-2===l?e:d)}return[V(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]})(t,e);if(this.el=Y.createElement(h,s),J.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=J.nextNode())&&a.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(E)){const e=l[o++],s=i.getAttribute(t).split(C),r=/([.?@])?(.*)/.exec(e);a.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?et:"?"===r[1]?st:"@"===r[1]?it:tt}),i.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:n}),i.removeAttribute(t));if(j.test(i.tagName)){const t=i.textContent.split(C),e=t.length-1;if(e>0){i.textContent=S?S.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],U()),J.nextNode(),a.push({type:2,index:++n});i.append(t[e],U())}}}else if(8===i.nodeType)if(i.data===k)a.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(C,t+1));)a.push({type:7,index:n}),t+=C.length-1}n++}}static createElement(t,e){const s=O.createElement("template");return s.innerHTML=t,s}}function Z(t,e,s=t,i){if(e===W)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=P(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Z(t,n._$AS(t,e.values),n,i)),e}class Q{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??O).importNode(e,!0);J.currentNode=i;let n=J.nextNode(),o=0,r=0,a=s[0];for(;void 0!==a;){if(o===a.index){let e;2===a.type?e=new X(n,n.nextSibling,this,t):1===a.type?e=new a.ctor(n,a.name,a.strings,this,t):6===a.type&&(e=new nt(n,this,t)),this._$AV.push(e),a=s[++r]}o!==a?.index&&(n=J.nextNode(),o++)}return J.currentNode=O,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=K,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),P(t)?t===K||null==t||""===t?(this._$AH!==K&&this._$AR(),this._$AH=K):t!==this._$AH&&t!==W&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>L(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==K&&P(this._$AH)?this._$AA.nextSibling.data=t:this.T(O.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Y.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new Q(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=G.get(t.strings);return void 0===e&&G.set(t.strings,e=new Y(t)),e}k(t){L(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new X(this.O(U()),this.O(U()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=_(t).nextSibling;_(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=K,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=K}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Z(this,t,e,0),o=!P(t)||t!==this._$AH&&t!==W,o&&(this._$AH=t);else{const i=t;let r,a;for(t=n[0],r=0;r<n.length-1;r++)a=Z(this,i[s+r],e,r),a===W&&(a=this._$AH[r]),o||=!P(a)||a!==this._$AH[r],a===K?t=K:t!==K&&(t+=(a??"")+n[r+1]),this._$AH[r]=a}o&&!i&&this.j(t)}j(t){t===K?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===K?void 0:t}}class st extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==K)}}class it extends tt{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??K)===W)return;const s=this._$AH,i=t===K&&s!==K||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==K&&(s===K||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}}const ot={I:X},rt=x.litHtmlPolyfillSupport;rt?.(Y,X),(x.litHtmlVersions??=[]).push("3.3.3");const at=(t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new X(e.insertBefore(U(),t),t,void 0,s??{})}return n._$AI(t),n},ht=globalThis;let lt=class extends w{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=at(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return W}};lt._$litElement$=!0,lt.finalized=!0,ht.litElementHydrateSupport?.({LitElement:lt});const ct=ht.litElementPolyfillSupport;ct?.({LitElement:lt}),(ht.litElementVersions??=[]).push("4.2.2");const dt=1,pt=2,ut=3,mt=4,ft=t=>(...e)=>({_$litDirective$:t,values:e});let gt=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}},bt=class extends gt{constructor(t){if(super(t),this.it=K,t.type!==pt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===K||null==t)return this._t=void 0,this.it=t;if(t===W)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};bt.directiveName="unsafeHTML",bt.resultType=1;const vt=ft(bt),yt=Object.freeze({SUBMIT:"chat-submit",BEFORE_OPEN:"chat-before-open",OPEN:"chat-open",BEFORE_CLOSE:"chat-before-close",CLOSE:"chat-close",HIDE:"chat-hide",SHOW:"chat-show",STATE_CHANGE:"chat-state-change",INPUT:"chat-input",MESSAGE_RENDER:"chat-message-render",MESSAGE_CLICK:"chat-message-click",SCROLL_TOP:"chat-scroll-top",BREAKPOINT_CHANGE:"chat-breakpoint-change"});function $t(t,e,s,{cancelable:i=!1}={}){return t.dispatchEvent(new CustomEvent(e,{detail:s,bubbles:!0,composed:!0,cancelable:i}))}const wt={closed:"launcher",open:"panel",hidden:null};class xt{#t;#e;#s;#i;#n="closed";#o="closed";#r=!1;#a=0;#h=null;#l=null;#c=!1;constructor(t,{animation:e,keepsLauncher:s,onOpened:i}){this.#t=t,this.#e=e,this.#s=s,this.#i=i,t.addController(this)}get renderedState(){return this.#o}get applying(){return this.#r}hostConnected(){this.#n=this.#t.state,this.#o=this.#t.state,this.#t.dataset.renderedState=this.#o}hostDisconnected(){this.#l?.(),this.#l=null,this.#h?.(!1),this.#h=null}hostUpdated(){this.#t.dataset.renderedState=this.#o}request(t,e){const s=this.#n;return t===s?Promise.resolve(!0):this.#d(s,t,e)?(this.#p(),this.#n=t,this.#u(t),$t(this.#t,yt.STATE_CHANGE,{from:s,to:t,trigger:e}),this.#m(s,t,e)):(this.#u(s),Promise.resolve(!1))}#d(t,e,s){return"open"===e?$t(this.#t,yt.BEFORE_OPEN,{from:t,trigger:s},{cancelable:!0}):"closed"!==e||"open"!==t||$t(this.#t,yt.BEFORE_CLOSE,{from:t,trigger:s},{cancelable:!0})}#p(){this.#a+=1,this.#l?.(),this.#l=null,this.#h?.(!1),this.#h=null,this.#o!==this.#n&&(this.#o=this.#n,this.#t.requestUpdate())}#m(t,e,s){const i=this.#a,n=new Promise(t=>{this.#h=t});return(async()=>{if(this.#c=this.#f(),await this.#t.updateComplete,i!==this.#a)return;const n=this.#g(t);if(n&&!this.#b(t,e)&&(await this.#v(n,"exit",this.#e(t,e,"exit")),i!==this.#a))return;if(this.#o=e,this.#t.requestUpdate(),await this.#t.updateComplete,i!==this.#a)return;const o=this.#g(e);o&&(await this.#v(o,"enter",this.#e(t,e,"enter")),i!==this.#a)||(this.#y(t,e,s),this.#$(e),this.#h?.(!0),this.#h=null)})(),n}#b(t,e){return"closed"===t&&"open"===e&&this.#s()}#y(t,e,s){"hidden"===t&&$t(this.#t,yt.SHOW,{from:t,to:e}),"hidden"!==e?"open"===e?$t(this.#t,yt.OPEN,{from:t,trigger:s}):"closed"===e&&"open"===t&&$t(this.#t,yt.CLOSE,{from:t,trigger:s}):$t(this.#t,yt.HIDE,{from:t,to:e})}#$(t){"open"!==t?("closed"===t&&this.#c&&this.#g("closed")?.focus(),this.#c=!1):this.#i()}#f(){const t=this.#t.renderRoot instanceof ShadowRoot?this.#t.renderRoot.activeElement:null,e=this.#g("open");return!(!t||!e||t!==e&&!e.contains(t))}#g(t){const e=wt[t];return e?this.#t.renderRoot.querySelector(`[part~="${e}"]`):null}#u(t){this.#t.state!==t&&(this.#r=!0,this.#t.state=t,this.#r=!1)}#v(t,e,s){const{effect:i,duration:n}=s;return"none"===i||n<=0||window.matchMedia("(prefers-reduced-motion: reduce)").matches?Promise.resolve():new Promise(s=>{let o=!1;const r=e=>{e&&e.target!==t||o||(o=!0,clearTimeout(a),t.removeEventListener("animationend",r),t.removeAttribute("data-anim"),t.style.removeProperty("--_chit-anim-duration"),this.#l===r&&(this.#l=null),s())};t.dataset.effect=i,t.dataset.anim=e,t.style.setProperty("--_chit-anim-duration",`${n}ms`),t.addEventListener("animationend",r);const a=setTimeout(r,n+50);this.#l=r})}}class _t{#t;#w=null;#x=0;#_="pc";#S=!1;constructor(t){this.#t=t,t.addController(this)}get device(){return this.#_}hostDisconnected(){this.#w?.removeEventListener("change",this.#A),this.#w=null}observe(t){t===this.#x&&this.#w||(this.#x=t,this.#w?.removeEventListener("change",this.#A),this.#w=window.matchMedia(`(max-width: ${t-1}px)`),this.#w.addEventListener("change",this.#A),this.#E(this.#w.matches?"mobile":"pc"))}#A=t=>{this.#E(t.matches?"mobile":"pc")};#E(t){t===this.#_&&this.#t.dataset.device||(this.#_=t,this.#t.dataset.device=t,this.#t.requestUpdate(),this.#S&&$t(this.#t,yt.BREAKPOINT_CHANGE,{device:t}),this.#S=!0)}}const St="#2563eb",At="#1f2328",Et="#5c6370",Ct="#ffffff",kt="#f1f3f5",Tt="#e4e4e7",Ot="#ffffff",Ut={size:60,position:"bottom-right",offset:{x:24,y:24},radius:30,image:null,label:null,component:null,props:{},colors:{background:St,text:Ot,shadow:"0 4px 12px rgba(0, 0, 0, 0.2)"},animation:{enter:"scale",exit:"scale",duration:200,idle:"none"}},Pt={size:56,offset:{x:16,y:16},radius:28},Lt={breakpoint:768,zIndex:2147483e3,font:{family:"system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif",size:14},closed:{pc:Ut,mobile:{...Ut,...Pt}},open:{width:380,height:600,position:"bottom-right",offset:{x:24,y:24},radius:16,launcher:"hidden",header:{title:null,logo:null,avatar:null},background:{image:null},colors:{background:Ct,text:At,accent:St,border:Tt,shadow:"0 8px 32px rgba(0, 0, 0, 0.24)",headerBackground:Ct,headerText:At,userBubble:St,userText:Ot,assistantBubble:kt,assistantText:At,systemText:Et,inputBackground:Ct,inputText:At,inputPlaceholder:Et},animation:{enter:"scale",exit:"fade",duration:150,scroll:"smooth"},input:{maxRows:5,placeholder:null}},hidden:{animation:{exit:"fade",duration:150}}},Rt=Pt;function zt(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Mt(t,e){if(!zt(e))return t;const s={...t};for(const[t,i]of Object.entries(e)){if(void 0===i)continue;const e=s[t];s[t]=zt(i)&&zt(e)?Mt(e,i):i}return s}function Nt(t,e){const s=t??{},i=function(t,e){const s=t??{};if(!("pc"in s)&&!("mobile"in s)){const s=t??{};return Mt(Lt.closed[e],s)}const i=Mt(Lt.closed.pc,s.pc);return"pc"===e?i:s.mobile?Mt(Lt.closed.mobile,s.mobile):Mt(i,Rt)}(s.closed,e);return{breakpoint:s.breakpoint??Lt.breakpoint,zIndex:s.zIndex??Lt.zIndex,font:Mt(Lt.font,s.font),closed:Mt(Lt.closed[e],i),open:Mt(Lt.open,s.open),hidden:Mt(Lt.hidden,s.hidden),device:e}}const Ht=t=>`${t}px`;function Bt(t){return t?`url("${t.replace(/[\\"]/g,"\\$&")}")`:"none"}function It(t){const e=Object.entries(function(t){const{closed:e,open:s}=t,i=s.colors;return{"--chit-z-index":String(t.zIndex),"--chit-font-family":t.font.family,"--chit-font-size":Ht(t.font.size),"--chit-launcher-size":"auto"===e.size?"auto":Ht(e.size),"--chit-launcher-offset-x":Ht(e.offset.x),"--chit-launcher-offset-y":Ht(e.offset.y),"--chit-launcher-radius":Ht(e.radius),"--chit-launcher-image":Bt(e.image),"--chit-launcher-bg":e.colors.background,"--chit-launcher-text":e.colors.text,"--chit-launcher-shadow":e.colors.shadow,"--chit-panel-width":Ht(s.width),"--chit-panel-height":Ht(s.height),"--chit-panel-offset-x":Ht(s.offset.x),"--chit-panel-offset-y":Ht(s.offset.y),"--chit-panel-radius":Ht(s.radius),"--chit-panel-bg-image":Bt(s.background.image),"--chit-panel-shadow":i.shadow,"--chit-color-bg":i.background,"--chit-color-text":i.text,"--chit-color-accent":i.accent,"--chit-color-border":i.border,"--chit-color-header-bg":i.headerBackground,"--chit-color-header-text":i.headerText,"--chit-color-user-bg":i.userBubble,"--chit-color-user-text":i.userText,"--chit-color-assistant-bg":i.assistantBubble,"--chit-color-assistant-text":i.assistantText,"--chit-color-system-text":i.systemText,"--chit-color-input-bg":i.inputBackground,"--chit-color-input-text":i.inputText,"--chit-color-input-placeholder":i.inputPlaceholder,"--_chit-input-max-rows":String(s.input.maxRows)}}(t)).map(([t,e])=>` ${t}: ${e};`).join("\n");return`:host {\n${e}\n}\n`}const jt="undefined"!=typeof ShadowRoot&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype;class Dt{#C=null;#k=null;#T="";#O;constructor(t){this.#O=t}attach(t){if(t instanceof ShadowRoot){if(jt)return this.#C||(this.#C=new CSSStyleSheet),void(t.adoptedStyleSheets.includes(this.#C)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,this.#C]));this.#k||(this.#k=document.createElement("style"),this.#k.setAttribute(this.#O,"")),this.#k.parentNode!==t&&t.append(this.#k)}}write(t,e){if(t!==this.#T){if(this.attach(e),this.#C)this.#C.replaceSync(t);else{if(!this.#k)return;this.#k.textContent=t}this.#T=t}}detach(){this.#k?.remove(),this.#k=null}}class qt{#t;#C=new Dt("data-chit-theme");#U;constructor(t,{device:e}){this.#t=t,this.#U=Nt(void 0,e())}get current(){return this.#U}hostConnected(){this.#P()}hostDisconnected(){this.#C.detach()}static breakpointOf(t){return function(t){return t?.breakpoint??Lt.breakpoint}(t)}apply(t,e){this.#U=Nt(t,e),this.#P()}#P(){this.#C.write(It(this.#U),this.#t.renderRoot)}}class Ft{#t;#L;#R=null;#z=null;#M=!0;#N=!1;#H=!1;#B=!0;#I=!1;#j;#D=!0;#q;#F=0;constructor(t,{behavior:e}){this.#t=t,this.#L=e,t.addController(this)}get hasUnseen(){return this.#N}get atBottom(){return this.#M}hostDisconnected(){this.#W(),clearTimeout(this.#j)}hostUpdate(){const t=this.#t.messages,e=t[t.length-1],s=t.length>this.#F,i=e?.id!==this.#q;this.#q=e?.id,this.#F=t.length,(s||i)&&(this.#M||"user"===e?.role?this.#B=!0:this.#N=!0)}hostUpdated(){const t=this.#t.renderRoot.querySelector('[part~="messages"]');if(t!==this.#R&&(this.#W(),this.#R=t,this.#K(),t&&(this.#M=!0,this.#N=!1,this.#B=!0,this.#D=!0)),this.#B){const t=this.#G;this.#B=!1,this.#J({behavior:t})}}#K(){if(!this.#R)return;this.#R.addEventListener("scroll",this.#V,{passive:!0}),this.#R.addEventListener("scrollend",this.#Y);const t=this.#R.firstElementChild;t&&"undefined"!=typeof ResizeObserver&&(this.#z=new ResizeObserver(()=>{this.#M&&this.#J({behavior:this.#I?"smooth":"instant"})}),this.#z.observe(t))}#W(){this.#R?.removeEventListener("scroll",this.#V),this.#R?.removeEventListener("scrollend",this.#Y),this.#z?.disconnect(),this.#z=null,this.#R=null}#Y=()=>{this.#Z()};#V=()=>{const t=this.#R;if(!t)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight<=24;if(this.#I)return void(e&&this.#Z());e!==this.#M&&(this.#M=e,e&&this.#N&&(this.#N=!1,this.#t.requestUpdate()));const s=t.scrollTop<=0;s&&!this.#H&&$t(this.#t,yt.SCROLL_TOP,{}),this.#H=s};scrollToBottom({smooth:t}={}){const e=void 0===t?this.#G:t?"smooth":"instant";this.#J({behavior:e}),this.#N&&(this.#N=!1,this.#t.requestUpdate())}get#G(){return this.#D||window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":this.#L()}#J({behavior:t="instant"}={}){const e=this.#R;e&&(this.#D=!1,"smooth"===t&&this.#Q(),e.scrollTo({top:e.scrollHeight,behavior:t}),this.#M=!0,this.#H=!1,this.#N=!1)}#Q(){this.#I=!0,clearTimeout(this.#j),this.#j=setTimeout(()=>this.#Z(),700)}#Z(){if(!this.#I)return;this.#I=!1,clearTimeout(this.#j);const t=this.#R;if(!t)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight;this.#M=e<=24}}const Wt="undefined"!=typeof CSS&&CSS.supports?.("field-sizing","content");class Kt{#t;#X="";#tt=!1;#et=!1;#st;constructor(t){this.#t=t,t.addController(this)}get value(){return this.#X}set value(t){this.#X=t??"";const e=this.#it;e&&e.value!==this.#X&&(e.value=this.#X),this.#nt(),this.#ot()}get composing(){return this.#tt}get length(){return Array.from(this.#X).length}get canSend(){if(this.#t.busy||this.#t.inputDisabled)return!1;if(""===this.#X.trim())return!1;const t=this.#t.maxLength;return void 0===t||this.length<=t}hostDisconnected(){clearTimeout(this.#st)}hostUpdated(){const t=this.#it;t&&t.value!==this.#X&&(t.value=this.#X),this.#nt(),this.#ot()}get#it(){return this.#t.renderRoot.querySelector('[part~="input"]')}onInput(t){this.#X=t.target.value,this.#nt(),this.#ot(),$t(this.#t,yt.INPUT,{value:this.#X})}onCompositionStart(){this.#tt=!0}onCompositionEnd(){this.#tt=!1,this.#et=!0,clearTimeout(this.#st),this.#st=setTimeout(()=>{this.#et=!1},0)}onKeydown(t){"Enter"===t.key&&this.#t.sendOnEnter&&(t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.isComposing||229===t.keyCode||this.#tt||this.#et||(t.preventDefault(),this.submit()))}submit(t){const e=t??this.#X;if(void 0===t&&!this.canSend)return!1;if(void 0!==t&&(this.#t.busy||this.#t.inputDisabled))return!1;if(""===e.trim())return!1;return!!$t(this.#t,yt.SUBMIT,{text:e},{cancelable:!0})&&(this.clear(),!0)}clear(){this.value="",this.focus()}focus(){this.#it?.focus()}#nt(){if(Wt)return;const t=this.#it;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)}#ot(){const t=this.#t.renderRoot,e=t.querySelector('[part~="send-button"]');e&&(e.disabled=!this.canSend);const s=this.#it,i=t.querySelector('[part~="counter"]'),n=this.#t.maxLength;if(void 0===n)return;const o=n-this.length,r=o<0;if(s?.setAttribute("aria-invalid",r?"true":"false"),!i)return;i.textContent=String(o),i.toggleAttribute("data-over",r);const a=this.#t.currentLabels,h=r?a.overLimit:a.charactersLeft;i.setAttribute("aria-label",h.replace("{n}",String(Math.abs(o)))),i.hidden=this.length<=.8*n}}const Gt=new WeakMap,Jt=t=>`msg:${t}`,Vt=["text","html","template","element","component"];function Yt(t){const e=Vt.filter(e=>e in t);if(1===e.length)return e[0];if(0===e.length)throw new Error(`ChitUI: message "${t.id}" has no content. Give it one of html, template, element or component.`);throw new Error(`ChitUI: message "${t.id}" has ${e.join(" and ")}. Give it exactly one.`)}function Zt(t){return t[Yt(t)]}function Qt(t,e,s,i={}){let n=Gt.get(t);n||(n=new Map,Gt.set(t,n));const o=n.get(e);if(o&&o.source===s){for(const[t,e]of Object.entries(i))Object.is(o.props[t],e)||(o.element[t]=e);return o.props={...i},o.element}const r=document.createElement(function(t){if("string"==typeof t)return t;const e=customElements,s=e.getName?.(t);if(s)return s;const i=t.tagName;if("string"==typeof i&&i)return i;throw new Error("ChitUI: component is not registered in customElements. Call customElements.define() for it, or pass its tag name as a string.")}(s));for(const[t,e]of Object.entries(i))r[t]=e;return n.set(e,{source:s,element:r,props:{...i}}),r}function Xt(t,e){return Gt.get(t)?.get(Jt(e))?.element}function te(t,e){switch(Yt(e)){case"text":return e.text;case"template":return e.template;case"element":return e.element;case"component":{const s=e;return Qt(t,Jt(e.id),s.component,s.props)}default:{const s=e.html;return vt(t.sanitize?t.sanitize(s):s)}}}function ee(t){const e=t.currentTheme.closed,s=t.currentLabels,i=e.component?Qt(t,"launcher",e.component,e.props):null;return q`
1
+ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new WeakMap;let n=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=i.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&i.set(s,t))}return t}toString(){return this.cssText}};const o=(t,...e)=>{const i=1===t.length?t[0]:e.reduce((e,s,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[i+1],t[0]);return new n(i,t,s)},r=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:a,defineProperty:h,getOwnPropertyDescriptor:l,getOwnPropertyNames:c,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,u=globalThis,m=u.trustedTypes,f=m?m.emptyScript:"",g=u.reactiveElementPolyfillSupport,b=(t,e)=>t,v={toAttribute(t,e){switch(e){case Boolean:t=t?f:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!a(t,e),w={attribute:!0,type:String,converter:v,reflect:!1,useDefault:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),u.litPropertyMetadata??=new WeakMap;let $=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&h(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(b("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(b("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(b("properties"))){const t=this.properties,e=[...c(t),...d(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const s=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((s,i)=>{if(e)s.adoptedStyleSheets=i.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const e of i){const i=document.createElement("style"),n=t.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}})(s,this.constructor.elementStyles),s}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:v).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:v;this._$Em=i;const o=n.fromAttribute(e,t.type);this[i]=o??this._$Ej?.get(i)??o,this._$Em=null}}requestUpdate(t,e,s,i=!1,n){if(void 0!==t){const o=this.constructor;if(!1===i&&(n=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??y)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};$.elementStyles=[],$.shadowRootOptions={mode:"open"},$[b("elementProperties")]=new Map,$[b("finalized")]=new Map,g?.({ReactiveElement:$}),(u.reactiveElementVersions??=[]).push("2.1.2");const x=globalThis,_=t=>t,A=x.trustedTypes,S=A?A.createPolicy("lit-html",{createHTML:t=>t}):void 0,E="$lit$",k=`lit$${Math.random().toFixed(9).slice(2)}$`,C="?"+k,T=`<${C}>`,O=document,U=()=>O.createComment(""),P=t=>null===t||"object"!=typeof t&&"function"!=typeof t,L=Array.isArray,M="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,z=/-->/g,B=/>/g,H=RegExp(`>|${M}(?:([^\\s"'>=/]+)(${M}*=${M}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),N=/'/g,I=/"/g,j=/^(?:script|style|textarea|title)$/i,D=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),q=D(1),F=D(2),W=Symbol.for("lit-noChange"),K=Symbol.for("lit-nothing"),G=new WeakMap,V=O.createTreeWalker(O,129);function J(t,e){if(!L(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}class Y{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,a=this.parts,[h,l]=((t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=R;for(let e=0;e<s;e++){const s=t[e];let a,h,l=-1,c=0;for(;c<s.length&&(r.lastIndex=c,h=r.exec(s),null!==h);)c=r.lastIndex,r===R?"!--"===h[1]?r=z:void 0!==h[1]?r=B:void 0!==h[2]?(j.test(h[2])&&(n=RegExp("</"+h[2],"g")),r=H):void 0!==h[3]&&(r=H):r===H?">"===h[0]?(r=n??R,l=-1):void 0===h[1]?l=-2:(l=r.lastIndex-h[2].length,a=h[1],r=void 0===h[3]?H:'"'===h[3]?I:N):r===I||r===N?r=H:r===z||r===B?r=R:(r=H,n=void 0);const d=r===H&&t[e+1].startsWith("/>")?" ":"";o+=r===R?s+T:l>=0?(i.push(a),s.slice(0,l)+E+s.slice(l)+k+d):s+k+(-2===l?e:d)}return[J(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]})(t,e);if(this.el=Y.createElement(h,s),V.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=V.nextNode())&&a.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(E)){const e=l[o++],s=i.getAttribute(t).split(k),r=/([.?@])?(.*)/.exec(e);a.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?et:"?"===r[1]?st:"@"===r[1]?it:tt}),i.removeAttribute(t)}else t.startsWith(k)&&(a.push({type:6,index:n}),i.removeAttribute(t));if(j.test(i.tagName)){const t=i.textContent.split(k),e=t.length-1;if(e>0){i.textContent=A?A.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],U()),V.nextNode(),a.push({type:2,index:++n});i.append(t[e],U())}}}else if(8===i.nodeType)if(i.data===C)a.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(k,t+1));)a.push({type:7,index:n}),t+=k.length-1}n++}}static createElement(t,e){const s=O.createElement("template");return s.innerHTML=t,s}}function Z(t,e,s=t,i){if(e===W)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=P(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Z(t,n._$AS(t,e.values),n,i)),e}class Q{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??O).importNode(e,!0);V.currentNode=i;let n=V.nextNode(),o=0,r=0,a=s[0];for(;void 0!==a;){if(o===a.index){let e;2===a.type?e=new X(n,n.nextSibling,this,t):1===a.type?e=new a.ctor(n,a.name,a.strings,this,t):6===a.type&&(e=new nt(n,this,t)),this._$AV.push(e),a=s[++r]}o!==a?.index&&(n=V.nextNode(),o++)}return V.currentNode=O,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=K,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),P(t)?t===K||null==t||""===t?(this._$AH!==K&&this._$AR(),this._$AH=K):t!==this._$AH&&t!==W&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>L(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==K&&P(this._$AH)?this._$AA.nextSibling.data=t:this.T(O.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Y.createElement(J(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new Q(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=G.get(t.strings);return void 0===e&&G.set(t.strings,e=new Y(t)),e}k(t){L(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new X(this.O(U()),this.O(U()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=_(t).nextSibling;_(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=K,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=K}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Z(this,t,e,0),o=!P(t)||t!==this._$AH&&t!==W,o&&(this._$AH=t);else{const i=t;let r,a;for(t=n[0],r=0;r<n.length-1;r++)a=Z(this,i[s+r],e,r),a===W&&(a=this._$AH[r]),o||=!P(a)||a!==this._$AH[r],a===K?t=K:t!==K&&(t+=(a??"")+n[r+1]),this._$AH[r]=a}o&&!i&&this.j(t)}j(t){t===K?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===K?void 0:t}}class st extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==K)}}class it extends tt{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??K)===W)return;const s=this._$AH,i=t===K&&s!==K||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==K&&(s===K||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}}const ot={I:X},rt=x.litHtmlPolyfillSupport;rt?.(Y,X),(x.litHtmlVersions??=[]).push("3.3.3");const at=(t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new X(e.insertBefore(U(),t),t,void 0,s??{})}return n._$AI(t),n},ht=globalThis;let lt=class extends ${constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=at(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return W}};lt._$litElement$=!0,lt.finalized=!0,ht.litElementHydrateSupport?.({LitElement:lt});const ct=ht.litElementPolyfillSupport;ct?.({LitElement:lt}),(ht.litElementVersions??=[]).push("4.2.2");const dt=1,pt=2,ut=3,mt=4,ft=t=>(...e)=>({_$litDirective$:t,values:e});let gt=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}},bt=class extends gt{constructor(t){if(super(t),this.it=K,t.type!==pt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===K||null==t)return this._t=void 0,this.it=t;if(t===W)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};bt.directiveName="unsafeHTML",bt.resultType=1;const vt=ft(bt),yt=Object.freeze({SUBMIT:"chat-submit",BEFORE_OPEN:"chat-before-open",OPEN:"chat-open",BEFORE_CLOSE:"chat-before-close",CLOSE:"chat-close",HIDE:"chat-hide",SHOW:"chat-show",STATE_CHANGE:"chat-state-change",INPUT:"chat-input",MESSAGE_RENDER:"chat-message-render",MESSAGE_CLICK:"chat-message-click",SCROLL_TOP:"chat-scroll-top",BREAKPOINT_CHANGE:"chat-breakpoint-change",HOME:"chat-home",ATTACH:"chat-attach"});function wt(t,e,s,{cancelable:i=!1}={}){return t.dispatchEvent(new CustomEvent(e,{detail:s,bubbles:!0,composed:!0,cancelable:i}))}const $t={closed:"launcher",open:"panel",hidden:null};class xt{#t;#e;#s;#i;#n="closed";#o="closed";#r=!1;#a=0;#h=null;#l=null;#c=!1;constructor(t,{animation:e,keepsLauncher:s,onOpened:i}){this.#t=t,this.#e=e,this.#s=s,this.#i=i,t.addController(this)}get renderedState(){return this.#o}get applying(){return this.#r}hostConnected(){this.#n=this.#t.state,this.#o=this.#t.state,this.#t.dataset.renderedState=this.#o}hostDisconnected(){this.#l?.(),this.#l=null,this.#h?.(!1),this.#h=null}hostUpdated(){this.#t.dataset.renderedState=this.#o}request(t,e){const s=this.#n;return t===s?Promise.resolve(!0):this.#d(s,t,e)?(this.#p(),this.#n=t,this.#u(t),wt(this.#t,yt.STATE_CHANGE,{from:s,to:t,trigger:e}),this.#m(s,t,e)):(this.#u(s),Promise.resolve(!1))}#d(t,e,s){return"open"===e?wt(this.#t,yt.BEFORE_OPEN,{from:t,trigger:s},{cancelable:!0}):"closed"!==e||"open"!==t||wt(this.#t,yt.BEFORE_CLOSE,{from:t,trigger:s},{cancelable:!0})}#p(){this.#a+=1,this.#l?.(),this.#l=null,this.#h?.(!1),this.#h=null,this.#o!==this.#n&&(this.#o=this.#n,this.#t.requestUpdate())}#m(t,e,s){const i=this.#a,n=new Promise(t=>{this.#h=t});return(async()=>{if(this.#c=this.#f(),await this.#t.updateComplete,i!==this.#a)return;const n=this.#g(t);if(n&&!this.#b(t,e)&&(await this.#v(n,"exit",this.#e(t,e,"exit")),i!==this.#a))return;if(this.#o=e,this.#t.requestUpdate(),await this.#t.updateComplete,i!==this.#a)return;const o=this.#g(e);o&&(await this.#v(o,"enter",this.#e(t,e,"enter")),i!==this.#a)||(this.#y(t,e,s),this.#w(e),this.#h?.(!0),this.#h=null)})(),n}#b(t,e){return"closed"===t&&"open"===e&&this.#s()}#y(t,e,s){"hidden"===t&&wt(this.#t,yt.SHOW,{from:t,to:e}),"hidden"!==e?"open"===e?wt(this.#t,yt.OPEN,{from:t,trigger:s}):"closed"===e&&"open"===t&&wt(this.#t,yt.CLOSE,{from:t,trigger:s}):wt(this.#t,yt.HIDE,{from:t,to:e})}#w(t){"open"!==t?("closed"===t&&this.#c&&this.#g("closed")?.focus(),this.#c=!1):this.#i()}#f(){const t=this.#t.renderRoot instanceof ShadowRoot?this.#t.renderRoot.activeElement:null,e=this.#g("open");return!(!t||!e||t!==e&&!e.contains(t))}#g(t){const e=$t[t];return e?this.#t.renderRoot.querySelector(`[part~="${e}"]`):null}#u(t){this.#t.state!==t&&(this.#r=!0,this.#t.state=t,this.#r=!1)}#v(t,e,s){const{effect:i,duration:n}=s;return"none"===i||n<=0||window.matchMedia("(prefers-reduced-motion: reduce)").matches?Promise.resolve():new Promise(s=>{let o=!1;const r=e=>{e&&e.target!==t||o||(o=!0,clearTimeout(a),t.removeEventListener("animationend",r),t.removeAttribute("data-anim"),t.style.removeProperty("--_chit-anim-duration"),this.#l===r&&(this.#l=null),s())};t.dataset.effect=i,t.dataset.anim=e,t.style.setProperty("--_chit-anim-duration",`${n}ms`),t.addEventListener("animationend",r);const a=setTimeout(r,n+50);this.#l=r})}}class _t{#t;#$=null;#x=0;#_="pc";#A=!1;constructor(t){this.#t=t,t.addController(this)}get device(){return this.#_}hostDisconnected(){this.#$?.removeEventListener("change",this.#S),this.#$=null}observe(t){t===this.#x&&this.#$||(this.#x=t,this.#$?.removeEventListener("change",this.#S),this.#$=window.matchMedia(`(max-width: ${t-1}px)`),this.#$.addEventListener("change",this.#S),this.#E(this.#$.matches?"mobile":"pc"))}#S=t=>{this.#E(t.matches?"mobile":"pc")};#E(t){t===this.#_&&this.#t.dataset.device||(this.#_=t,this.#t.dataset.device=t,this.#t.requestUpdate(),this.#A&&wt(this.#t,yt.BREAKPOINT_CHANGE,{device:t}),this.#A=!0)}}const At="#2563eb",St="#1f2328",Et="#5c6370",kt="#ffffff",Ct="#f1f3f5",Tt="#e4e4e7",Ot="#ffffff",Ut={size:60,position:"bottom-right",offset:{x:24,y:24},radius:30,image:null,label:null,component:null,props:{},colors:{background:At,text:Ot,shadow:"0 4px 12px rgba(0, 0, 0, 0.2)"},animation:{enter:"scale",exit:"scale",duration:200,idle:"none"}},Pt={size:56,offset:{x:16,y:16},radius:28},Lt={breakpoint:768,zIndex:2147483e3,font:{family:"system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif",size:14},closed:{pc:Ut,mobile:{...Ut,...Pt}},open:{width:380,height:600,position:"bottom-right",offset:{x:24,y:24},radius:16,launcher:"hidden",header:{visible:!0,title:null,logo:null,home:!1},background:{image:null},colors:{background:kt,text:St,accent:At,border:Tt,shadow:"0 8px 32px rgba(0, 0, 0, 0.24)",headerBackground:kt,headerText:St,userBubble:At,userText:Ot,assistantBubble:Ct,assistantText:St,systemText:Et,inputBackground:kt,inputText:St,inputPlaceholder:Et},bubble:{radius:14,tail:"none"},speaker:{assistant:{name:null,avatar:null},user:{name:null,avatar:null}},animation:{enter:"scale",exit:"fade",duration:150,scroll:"smooth"},input:{maxRows:5,placeholder:null,attach:!1,accept:"image/*,video/*",multiple:!1}},hidden:{animation:{exit:"fade",duration:150}}},Mt=Pt;function Rt(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function zt(t,e){if(!Rt(e))return t;const s={...t};for(const[t,i]of Object.entries(e)){if(void 0===i)continue;const e=s[t];s[t]=Rt(i)&&Rt(e)?zt(e,i):i}return s}function Bt(t,e){const s=t??{},i=function(t,e){const s=t??{};if(!("pc"in s)&&!("mobile"in s)){const s=t??{};return zt(Lt.closed[e],s)}const i=zt(Lt.closed.pc,s.pc);return"pc"===e?i:s.mobile?zt(Lt.closed.mobile,s.mobile):zt(i,Mt)}(s.closed,e);return{breakpoint:s.breakpoint??Lt.breakpoint,zIndex:s.zIndex??Lt.zIndex,font:zt(Lt.font,s.font),closed:zt(Lt.closed[e],i),open:zt(Lt.open,s.open),hidden:zt(Lt.hidden,s.hidden),device:e}}const Ht=t=>`${t}px`;function Nt(t){return t?`url("${t.replace(/[\\"]/g,"\\$&")}")`:"none"}function It(t){const e=Object.entries(function(t){const{closed:e,open:s}=t,i=s.colors;return{"--chit-z-index":String(t.zIndex),"--chit-font-family":t.font.family,"--chit-font-size":Ht(t.font.size),"--chit-launcher-size":"auto"===e.size?"auto":Ht(e.size),"--chit-launcher-offset-x":Ht(e.offset.x),"--chit-launcher-offset-y":Ht(e.offset.y),"--chit-launcher-radius":Ht(e.radius),"--chit-launcher-image":Nt(e.image),"--chit-launcher-bg":e.colors.background,"--chit-launcher-text":e.colors.text,"--chit-launcher-shadow":e.colors.shadow,"--chit-panel-width":Ht(s.width),"--chit-panel-height":Ht(s.height),"--chit-panel-offset-x":Ht(s.offset.x),"--chit-panel-offset-y":Ht(s.offset.y),"--chit-panel-radius":Ht(s.radius),"--chit-panel-bg-image":Nt(s.background.image),"--chit-panel-shadow":i.shadow,"--chit-color-bg":i.background,"--chit-color-text":i.text,"--chit-color-accent":i.accent,"--chit-color-border":i.border,"--chit-color-header-bg":i.headerBackground,"--chit-color-header-text":i.headerText,"--chit-color-user-bg":i.userBubble,"--chit-color-user-text":i.userText,"--chit-color-assistant-bg":i.assistantBubble,"--chit-color-assistant-text":i.assistantText,"--chit-color-system-text":i.systemText,"--chit-color-input-bg":i.inputBackground,"--chit-color-input-text":i.inputText,"--chit-color-input-placeholder":i.inputPlaceholder,"--chit-bubble-radius":Ht(s.bubble.radius),"--_chit-input-max-rows":String(s.input.maxRows),"--_chit-speaker-gutter":s.speaker.assistant.avatar?"2.5em":"0px"}}(t)).map(([t,e])=>` ${t}: ${e};`).join("\n");return`:host {\n${e}\n}\n`}const jt="undefined"!=typeof ShadowRoot&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype;class Dt{#k=null;#C=null;#T="";#O;constructor(t){this.#O=t}attach(t){if(t instanceof ShadowRoot){if(jt)return this.#k||(this.#k=new CSSStyleSheet),void(t.adoptedStyleSheets.includes(this.#k)||(t.adoptedStyleSheets=[...t.adoptedStyleSheets,this.#k]));this.#C||(this.#C=document.createElement("style"),this.#C.setAttribute(this.#O,"")),this.#C.parentNode!==t&&t.append(this.#C)}}write(t,e){if(t!==this.#T){if(this.attach(e),this.#k)this.#k.replaceSync(t);else{if(!this.#C)return;this.#C.textContent=t}this.#T=t}}detach(){this.#C?.remove(),this.#C=null}}class qt{#t;#k=new Dt("data-chit-theme");#U;constructor(t,{device:e}){this.#t=t,this.#U=Bt(void 0,e())}get current(){return this.#U}hostConnected(){this.#P()}hostDisconnected(){this.#k.detach()}static breakpointOf(t){return function(t){return t?.breakpoint??Lt.breakpoint}(t)}apply(t,e){this.#U=Bt(t,e),this.#P()}#P(){this.#k.write(It(this.#U),this.#t.renderRoot)}}class Ft{#t;#L;#M=null;#R=null;#z=!0;#B=!1;#H=!1;#N=!0;#I=!1;#j;#D=!0;#q;#F=0;constructor(t,{behavior:e}){this.#t=t,this.#L=e,t.addController(this)}get hasUnseen(){return this.#B}get atBottom(){return this.#z}hostDisconnected(){this.#W(),clearTimeout(this.#j)}hostUpdate(){const t=this.#t.messages,e=t[t.length-1],s=t.length>this.#F,i=e?.id!==this.#q;this.#q=e?.id,this.#F=t.length,(s||i)&&(this.#z||"user"===e?.role?this.#N=!0:this.#B=!0)}hostUpdated(){const t=this.#t.renderRoot.querySelector('[part~="messages"]');if(t!==this.#M&&(this.#W(),this.#M=t,this.#K(),t&&(this.#z=!0,this.#B=!1,this.#N=!0,this.#D=!0)),this.#N){const t=this.#G;this.#N=!1,this.#V({behavior:t})}}#K(){if(!this.#M)return;this.#M.addEventListener("scroll",this.#J,{passive:!0}),this.#M.addEventListener("scrollend",this.#Y);const t=this.#M.firstElementChild;t&&"undefined"!=typeof ResizeObserver&&(this.#R=new ResizeObserver(()=>{this.#z&&this.#V({behavior:this.#I?"smooth":"instant"})}),this.#R.observe(t))}#W(){this.#M?.removeEventListener("scroll",this.#J),this.#M?.removeEventListener("scrollend",this.#Y),this.#R?.disconnect(),this.#R=null,this.#M=null}#Y=()=>{this.#Z()};#J=()=>{const t=this.#M;if(!t)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight<=24;if(this.#I)return void(e&&this.#Z());e!==this.#z&&(this.#z=e,e&&this.#B&&(this.#B=!1,this.#t.requestUpdate()));const s=t.scrollTop<=0;s&&!this.#H&&wt(this.#t,yt.SCROLL_TOP,{}),this.#H=s};scrollToBottom({smooth:t}={}){const e=void 0===t?this.#G:t?"smooth":"instant";this.#V({behavior:e}),this.#B&&(this.#B=!1,this.#t.requestUpdate())}get#G(){return this.#D||window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":this.#L()}#V({behavior:t="instant"}={}){const e=this.#M;e&&(this.#D=!1,"smooth"===t&&this.#Q(),e.scrollTo({top:e.scrollHeight,behavior:t}),this.#z=!0,this.#H=!1,this.#B=!1)}#Q(){this.#I=!0,clearTimeout(this.#j),this.#j=setTimeout(()=>this.#Z(),700)}#Z(){if(!this.#I)return;this.#I=!1,clearTimeout(this.#j);const t=this.#M;if(!t)return;const e=t.scrollHeight-t.scrollTop-t.clientHeight;this.#z=e<=24}}const Wt="undefined"!=typeof CSS&&CSS.supports?.("field-sizing","content");class Kt{#t;#X="";#tt=!1;#et=!1;#st;constructor(t){this.#t=t,t.addController(this)}get value(){return this.#X}set value(t){this.#X=t??"";const e=this.#it;e&&e.value!==this.#X&&(e.value=this.#X),this.#nt(),this.#ot()}get composing(){return this.#tt}get length(){return Array.from(this.#X).length}get canSend(){if(this.#t.busy||this.#t.inputDisabled)return!1;if(""===this.#X.trim())return!1;const t=this.#t.maxLength;return void 0===t||this.length<=t}hostDisconnected(){clearTimeout(this.#st)}hostUpdated(){const t=this.#it;t&&t.value!==this.#X&&(t.value=this.#X),this.#nt(),this.#ot()}get#it(){return this.#t.renderRoot.querySelector('[part~="input"]')}onInput(t){this.#X=t.target.value,this.#nt(),this.#ot(),wt(this.#t,yt.INPUT,{value:this.#X})}onCompositionStart(){this.#tt=!0}onCompositionEnd(){this.#tt=!1,this.#et=!0,clearTimeout(this.#st),this.#st=setTimeout(()=>{this.#et=!1},0)}onKeydown(t){"Enter"===t.key&&this.#t.sendOnEnter&&(t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.isComposing||229===t.keyCode||this.#tt||this.#et||(t.preventDefault(),this.submit()))}submit(t){const e=t??this.#X;if(void 0===t&&!this.canSend)return!1;if(void 0!==t&&(this.#t.busy||this.#t.inputDisabled))return!1;if(""===e.trim())return!1;return!!wt(this.#t,yt.SUBMIT,{text:e},{cancelable:!0})&&(this.clear(),!0)}clear(){this.value="",this.focus()}focus(){this.#it?.focus()}#nt(){if(Wt)return;const t=this.#it;t&&(t.style.height="auto",t.style.height=`${t.scrollHeight}px`)}#ot(){const t=this.#t.renderRoot,e=t.querySelector('[part~="send-button"]');e&&(e.disabled=!this.canSend);const s=this.#it,i=t.querySelector('[part~="counter"]'),n=this.#t.maxLength;if(void 0===n)return;const o=n-this.length,r=o<0;if(s?.setAttribute("aria-invalid",r?"true":"false"),!i)return;i.textContent=String(o),i.toggleAttribute("data-over",r);const a=this.#t.currentLabels,h=r?a.overLimit:a.charactersLeft;i.setAttribute("aria-label",h.replace("{n}",String(Math.abs(o)))),i.hidden=this.length<=.8*n}}const Gt=new WeakMap,Vt=t=>`msg:${t}`,Jt=["text","html","template","element","component"];function Yt(t){const e=Jt.filter(e=>e in t);if(1===e.length)return e[0];if(0===e.length)throw new Error(`ChitUI: message "${t.id}" has no content. Give it one of html, template, element or component.`);throw new Error(`ChitUI: message "${t.id}" has ${e.join(" and ")}. Give it exactly one.`)}function Zt(t){return t[Yt(t)]}function Qt(t,e,s,i={}){let n=Gt.get(t);n||(n=new Map,Gt.set(t,n));const o=n.get(e);if(o&&o.source===s){for(const[t,e]of Object.entries(i))Object.is(o.props[t],e)||(o.element[t]=e);return o.props={...i},o.element}const r=document.createElement(function(t){if("string"==typeof t)return t;const e=customElements,s=e.getName?.(t);if(s)return s;const i=t.tagName;if("string"==typeof i&&i)return i;throw new Error("ChitUI: component is not registered in customElements. Call customElements.define() for it, or pass its tag name as a string.")}(s));for(const[t,e]of Object.entries(i))r[t]=e;return n.set(e,{source:s,element:r,props:{...i}}),r}function Xt(t,e){return Gt.get(t)?.get(Vt(e))?.element}function te(t,e){switch(Yt(e)){case"text":return e.text;case"template":return e.template;case"element":return e.element;case"component":{const s=e;return Qt(t,Vt(e.id),s.component,s.props)}default:{const s=e.html;return vt(t.sanitize?t.sanitize(s):s)}}}function ee(t){const e=t.currentTheme.closed,s=t.currentLabels,i=e.component?Qt(t,"launcher",e.component,e.props):null;return q`
2
2
  <button
3
3
  part="launcher"
4
4
  type="button"
@@ -21,7 +21,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
21
21
  <article part="message message-system" data-role="system" data-id=${e.id}>
22
22
  <div part="message-content" data-content=${Yt(e)}>${te(t,e)}</div>
23
23
  </article>
24
- `;const s=e.time||e.status;return q`
24
+ `;const s=e.time||e.status,i=t.currentTheme.open.speaker[e.role],n=void 0===e.avatar?i.avatar:e.avatar,o=void 0===e.name?i.name:e.name;return q`
25
25
  <article
26
26
  part="message message-${e.role}"
27
27
  data-role=${e.role}
@@ -29,9 +29,9 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
29
29
  ?data-streaming=${!!e.streaming}
30
30
  aria-busy=${e.streaming?"true":"false"}
31
31
  >
32
- ${e.avatar?q`<img part="avatar" src=${e.avatar} alt="" loading="lazy" />`:K}
32
+ ${n?q`<img part="avatar" src=${n} alt="" loading="lazy" />`:i.avatar?q`<span part="avatar" data-placeholder aria-hidden="true"></span>`:K}
33
33
  <div class="body">
34
- ${e.name?q`<span part="name">${e.name}</span>`:K}
34
+ ${o?q`<span part="name">${o}</span>`:K}
35
35
  <div part="bubble">
36
36
  <div part="message-content" data-content=${Yt(e)}>${te(t,e)}</div>
37
37
  ${e.streaming?q`<span part="cursor" aria-hidden="true"></span>`:K}
@@ -46,7 +46,76 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
46
46
  `:K}
47
47
  </div>
48
48
  </article>
49
- `}const ue=ft(class extends gt{constructor(t){if(super(t),t.type!==ut&&t.type!==dt&&t.type!==mt)throw Error("The `live` directive is not allowed on child or event bindings");if(!(t=>void 0===t.strings)(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===W||e===K)return e;const s=t.element,i=t.name;if(t.type===ut){if(e===s[i])return W}else if(t.type===mt){if(!!e===s.hasAttribute(i))return W}else if(t.type===dt&&s.getAttribute(i)===e+"")return W;return he(t),e}});function me(t){const e=t.currentTheme.open,s=t.currentLabels,i=e.header?.title??s.panel;return q`
49
+ `}const ue=ft(class extends gt{constructor(t){if(super(t),t.type!==ut&&t.type!==dt&&t.type!==mt)throw Error("The `live` directive is not allowed on child or event bindings");if(!(t=>void 0===t.strings)(t))throw Error("`live` bindings can only contain a single expression")}render(t){return t}update(t,[e]){if(e===W||e===K)return e;const s=t.element,i=t.name;if(t.type===ut){if(e===s[i])return W}else if(t.type===mt){if(!!e===s.hasAttribute(i))return W}else if(t.type===dt&&s.getAttribute(i)===e+"")return W;return he(t),e}});function me(t){if(t.inputHidden)return K;const e=t.currentLabels,s=t.currentTheme.open,i=t.busy||t.inputDisabled,n=t.placeholder??s.input.placeholder??e.input;return q`
50
+ <form
51
+ part="composer"
52
+ @submit=${e=>{e.preventDefault(),t.submit()}}
53
+ >
54
+ <slot name="composer">
55
+ ${s.input.attach?function(t,e){const s=t.currentLabels,i=t.currentTheme.open.input;return q`
56
+ <button
57
+ part="attach-button"
58
+ type="button"
59
+ aria-label=${s.attach}
60
+ title=${s.attach}
61
+ ?disabled=${e}
62
+ @click=${()=>t.openAttach()}
63
+ >
64
+ <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
65
+ <path
66
+ fill="none"
67
+ stroke="currentColor"
68
+ stroke-width="2"
69
+ stroke-linecap="round"
70
+ stroke-linejoin="round"
71
+ d="M20 11.5 12.2 19.3a4.6 4.6 0 0 1-6.5-6.5l7.8-7.8a3 3 0 0 1 4.3 4.3l-7.8 7.8a1.5 1.5 0 0 1-2.1-2.1l7.1-7.1"
72
+ />
73
+ </svg>
74
+ </button>
75
+ <input
76
+ part="attach-input"
77
+ type="file"
78
+ tabindex="-1"
79
+ aria-hidden="true"
80
+ accept=${i.accept}
81
+ ?multiple=${i.multiple}
82
+ @change=${e=>{const s=e.target,i=Array.from(s.files??[]);s.value="",i.length&&t.handleAttach(i)}}
83
+ />
84
+ `}(t,i):K}
85
+
86
+ <slot name="input-before"></slot>
87
+
88
+ <textarea
89
+ part="input"
90
+ rows="1"
91
+ .value=${ue(t.value)}
92
+ placeholder=${n}
93
+ aria-label=${e.input}
94
+ ?disabled=${i}
95
+ aria-describedby=${void 0===t.maxLength?K:"chit-counter"}
96
+ @input=${e=>t.handleInput(e)}
97
+ @keydown=${e=>t.handleKeydown(e)}
98
+ @compositionstart=${()=>t.handleComposition(!0)}
99
+ @compositionend=${()=>t.handleComposition(!1)}
100
+ ></textarea>
101
+
102
+ <slot name="input-after"></slot>
103
+
104
+ ${void 0===t.maxLength?K:q`<span part="counter" id="chit-counter" aria-live="polite" hidden></span>`}
105
+
106
+ <button
107
+ part="send-button"
108
+ type="submit"
109
+ aria-label=${e.send}
110
+ ?disabled=${!t.canSend}
111
+ >
112
+ ${t.busy?q`<span part="spinner" aria-hidden="true"></span>`:q`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
113
+ <path fill="currentColor" d="M3.4 20.4 21 12 3.4 3.6 3.39 10.2 15.6 12 3.39 13.8z" />
114
+ </svg>`}
115
+ </button>
116
+ </slot>
117
+ </form>
118
+ `}function fe(t){const e=t.currentTheme.open,s=t.currentLabels,i=e.header.title??s.panel;return q`
50
119
  <section
51
120
  part="panel"
52
121
  role="dialog"
@@ -55,18 +124,39 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
55
124
  tabindex="-1"
56
125
  @keydown=${e=>function(t,e){if("Escape"!==e.key||e.defaultPrevented)return;e.preventDefault(),t.closeFromUser()}(t,e)}
57
126
  >
127
+ ${e.header.visible?function(t,e){const s=t.currentTheme.open,i=t.currentLabels;return q`
58
128
  <header part="header">
59
129
  <slot name="header">
60
130
  <slot name="header-title">
61
- ${e.header?.logo?q`<img part="header-logo" src=${e.header.logo} alt="" />`:K}
62
- <span part="header-heading">${i}</span>
131
+ <span part="header-title">
132
+ ${s.header.logo?q`<img part="header-logo" src=${s.header.logo} alt="" />`:K}
133
+ <span part="header-heading">${e}</span>
134
+ </span>
63
135
  </slot>
64
136
  <span part="header-actions">
65
137
  <slot name="header-actions"></slot>
138
+ ${s.header.home?q`<button
139
+ part="home-button"
140
+ type="button"
141
+ aria-label=${i.home}
142
+ title=${i.home}
143
+ @click=${()=>t.home("user")}
144
+ >
145
+ <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
146
+ <path
147
+ fill="none"
148
+ stroke="currentColor"
149
+ stroke-width="2"
150
+ stroke-linejoin="round"
151
+ stroke-linecap="round"
152
+ d="M4 11.2 12 4l8 7.2M6.5 9.8V19h11V9.8M10 19v-4.6h4V19"
153
+ />
154
+ </svg>
155
+ </button>`:K}
66
156
  <button
67
157
  part="close-button"
68
158
  type="button"
69
- aria-label=${s.close}
159
+ aria-label=${i.close}
70
160
  @click=${()=>t.closeFromUser()}
71
161
  >
72
162
  <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
@@ -82,6 +172,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
82
172
  </span>
83
173
  </slot>
84
174
  </header>
175
+ `}(t,i):K}
85
176
 
86
177
  ${function(t){const e=t.currentLabels,s=t.typing,i=0===t.messages.length&&!s;return q`
87
178
  <div
@@ -112,49 +203,11 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
112
203
  ${e.toLatest}
113
204
  </button>
114
205
  `:K}
115
- `}(t)} ${function(t){if(t.inputHidden)return K;const e=t.currentLabels,s=t.currentTheme.open,i=t.busy||t.inputDisabled,n=t.placeholder??s.input.placeholder??e.input;return q`
116
- <form
117
- part="composer"
118
- @submit=${e=>{e.preventDefault(),t.submit()}}
119
- >
120
- <slot name="composer">
121
- <slot name="input-before"></slot>
122
-
123
- <textarea
124
- part="input"
125
- rows="1"
126
- .value=${ue(t.value)}
127
- placeholder=${n}
128
- aria-label=${e.input}
129
- ?disabled=${i}
130
- aria-describedby=${void 0===t.maxLength?K:"chit-counter"}
131
- @input=${e=>t.handleInput(e)}
132
- @keydown=${e=>t.handleKeydown(e)}
133
- @compositionstart=${()=>t.handleComposition(!0)}
134
- @compositionend=${()=>t.handleComposition(!1)}
135
- ></textarea>
136
-
137
- <slot name="input-after"></slot>
138
-
139
- ${void 0===t.maxLength?K:q`<span part="counter" id="chit-counter" aria-live="polite" hidden></span>`}
140
-
141
- <button
142
- part="send-button"
143
- type="submit"
144
- aria-label=${e.send}
145
- ?disabled=${!t.canSend}
146
- >
147
- ${t.busy?q`<span part="spinner" aria-hidden="true"></span>`:q`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
148
- <path fill="currentColor" d="M3.4 20.4 21 12 3.4 3.6 3.39 10.2 15.6 12 3.39 13.8z" />
149
- </svg>`}
150
- </button>
151
- </slot>
152
- </form>
153
- `}(t)}
206
+ `}(t)} ${me(t)}
154
207
 
155
208
  <slot name="footer"></slot>
156
209
  </section>
157
- `}const fe={ja:{launcher:"チャットを開く",panel:"チャット",conversation:"会話",close:"チャットを閉じる",send:"送信",input:"メッセージを入力",typing:"入力中",toLatest:"最新へ",status:{sending:"送信中",sent:"送信済み",error:"送信できませんでした"},charactersLeft:"残り {n} 文字",overLimit:"{n} 文字超過しています"},en:{launcher:"Open chat",panel:"Chat",conversation:"Conversation",close:"Close chat",send:"Send",input:"Type a message",typing:"Typing",toLatest:"Jump to latest",status:{sending:"Sending",sent:"Sent",error:"Not delivered"},charactersLeft:"{n} characters left",overLimit:"{n} characters over the limit"}};function ge(t){return t||document.documentElement.lang||void 0}const be=o`
210
+ `}const ge={ja:{launcher:"チャットを開く",panel:"チャット",conversation:"会話",close:"チャットを閉じる",home:"最初に戻る",send:"送信",attach:"画像や動画を添付",input:"メッセージを入力",typing:"入力中",toLatest:"最新へ",status:{sending:"送信中",sent:"送信済み",error:"送信できませんでした"},charactersLeft:"残り {n} 文字",overLimit:"{n} 文字超過しています"},en:{launcher:"Open chat",panel:"Chat",conversation:"Conversation",close:"Close chat",home:"Back to the start",send:"Send",attach:"Attach an image or video",input:"Type a message",typing:"Typing",toLatest:"Jump to latest",status:{sending:"Sending",sent:"Sent",error:"Not delivered"},charactersLeft:"{n} characters left",overLimit:"{n} characters over the limit"}};function be(t){return t||document.documentElement.lang||void 0}const ve=o`
158
211
  :host {
159
212
  --chit-z-index: 2147483000;
160
213
  --chit-font-family: system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
@@ -182,6 +235,8 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
182
235
  --chit-color-header-bg: #ffffff;
183
236
  --chit-color-header-text: #1f1f1f;
184
237
 
238
+ --chit-bubble-radius: 14px;
239
+
185
240
  position: fixed;
186
241
  inset: 0;
187
242
  z-index: var(--chit-z-index);
@@ -302,7 +357,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
302
357
  animation: none !important;
303
358
  }
304
359
  }
305
- `,ve=o`
360
+ `,ye=o`
306
361
  [part~='launcher'] {
307
362
  position: absolute;
308
363
  display: grid;
@@ -437,7 +492,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
437
492
  animation: none;
438
493
  }
439
494
  }
440
- `,ye=o`
495
+ `,we=o`
441
496
  [part~='panel'] {
442
497
  position: absolute;
443
498
  display: flex;
@@ -512,18 +567,33 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
512
567
  color: var(--chit-color-header-text);
513
568
  }
514
569
 
570
+ /*
571
+ * The image and the title are one flex item. A slot is display: contents,
572
+ * so without this wrapper its children become items of the header itself
573
+ * and space-between pushes the image to one edge and the title to the
574
+ * middle, away from each other.
575
+ */
576
+ [part~='header-title'] {
577
+ display: inline-flex;
578
+ min-width: 0;
579
+ align-items: center;
580
+ gap: 0.5em;
581
+ }
582
+
515
583
  [part~='header-heading'] {
584
+ overflow: hidden;
516
585
  font-size: 1.05em;
517
586
  font-weight: 600;
587
+ text-overflow: ellipsis;
588
+ white-space: nowrap;
518
589
  }
519
590
 
520
591
  [part~='header-logo'] {
592
+ flex: none;
521
593
  width: 1.75em;
522
594
  height: 1.75em;
523
- margin-inline-end: 0.5em;
524
595
  border-radius: 50%;
525
596
  object-fit: cover;
526
- vertical-align: middle;
527
597
  }
528
598
 
529
599
  [part~='header-actions'] {
@@ -532,6 +602,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
532
602
  gap: 0.25em;
533
603
  }
534
604
 
605
+ [part~='home-button'],
535
606
  [part~='close-button'] {
536
607
  display: grid;
537
608
  place-items: center;
@@ -545,21 +616,36 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
545
616
  cursor: pointer;
546
617
  }
547
618
 
619
+ [part~='home-button']:hover,
548
620
  [part~='close-button']:hover {
549
621
  background: color-mix(in srgb, currentColor 10%, transparent);
550
622
  }
551
623
 
624
+ [part~='home-button']:focus-visible,
552
625
  [part~='close-button']:focus-visible {
553
626
  outline: 2px solid var(--chit-color-accent);
554
627
  outline-offset: 1px;
555
628
  }
556
629
 
630
+ [part~='home-button'] svg,
557
631
  [part~='close-button'] svg {
558
632
  width: 1.1em;
559
633
  height: 1.1em;
560
634
  }
561
635
 
562
636
  `,$e=o`
637
+ :host {
638
+ /* Internal: the box the tail's path is drawn in. The path is written in
639
+ these units, so the two move together. */
640
+ --_chit-tail-w: 18px;
641
+ --_chit-tail-h: 20px;
642
+ /* How deep the tail's root sits inside the bubble. Less than the
643
+ bubble's own padding, so it never reaches the text. */
644
+ --_chit-tail-root: 9px;
645
+ /* Far enough down that the bubble's edge has straightened out under it. */
646
+ --_chit-tail-offset: calc(var(--chit-bubble-radius) / 4 + 1px);
647
+ }
648
+
563
649
  [part~='messages'] {
564
650
  flex: 1 1 auto;
565
651
  min-height: 0;
@@ -584,7 +670,13 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
584
670
  */
585
671
  [part~='message'] {
586
672
  display: flex;
587
- align-items: flex-end;
673
+ /*
674
+ * The icon sits level with the top of the speaker's block — beside the
675
+ * name when there is one, beside the bubble's first line otherwise. At
676
+ * the bottom it would end up next to the timestamp, away from everything
677
+ * it identifies.
678
+ */
679
+ align-items: flex-start;
588
680
  gap: 0.5em;
589
681
  width: 100%;
590
682
  max-width: 100%;
@@ -610,7 +702,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
610
702
  [part~='bubble'] {
611
703
  position: relative;
612
704
  padding: 0.6em 0.85em;
613
- border-radius: 14px;
705
+ border-radius: var(--chit-bubble-radius);
614
706
  background: var(--chit-color-assistant-bg);
615
707
  color: var(--chit-color-assistant-text);
616
708
  }
@@ -625,6 +717,90 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
625
717
  border-bottom-left-radius: 4px;
626
718
  }
627
719
 
720
+ /* --- tails -------------------------------------------------------------
721
+ *
722
+ * A tail is one pseudo-element: a box in the bubble's colour, clipped to a
723
+ * leaf whose point sits outside the bubble and whose root is buried inside
724
+ * it. Burying the root is what makes the join disappear — the bubble's own
725
+ * background covers the seam, so every corner keeps its radius and the two
726
+ * read as one shape at any radius.
727
+ *
728
+ * It hangs a little below the corner, where the bubble's edge has
729
+ * straightened out, so the root has something flat to sit against. The
730
+ * offset follows the radius for that reason.
731
+ *
732
+ * The other side and the downward version are the same path mirrored, so
733
+ * the curve is written once.
734
+ */
735
+
736
+ [part~='bubble']::after,
737
+ [part~='typing']::after {
738
+ content: '';
739
+ display: none;
740
+ position: absolute;
741
+ width: var(--_chit-tail-w);
742
+ height: var(--_chit-tail-h);
743
+ clip-path: path('M 18 0.5 Q 8 0.8 0.5 3.5 Q 0 5.2 2 7 Q 10 9.5 18 19 Z');
744
+ }
745
+
746
+ /*
747
+ * Everything below needs clip-path: path() to draw the leaf. Where that is
748
+ * missing the tail stays hidden and the bubble keeps its default shape,
749
+ * rather than a bare rectangle poking out of its side.
750
+ */
751
+ @supports (clip-path: path('M 0 0 Z')) {
752
+ :host([data-bubble-tail='top']) [part~='bubble']::after,
753
+ :host([data-bubble-tail='bottom']) [part~='bubble']::after,
754
+ :host([data-bubble-tail='top']) [part~='typing']::after,
755
+ :host([data-bubble-tail='bottom']) [part~='typing']::after {
756
+ display: block;
757
+ }
758
+
759
+ /*
760
+ * With a tail there is no need to clip the speaker's corner as well: one
761
+ * bubble carries one cue about who is talking, not two.
762
+ */
763
+ :host([data-bubble-tail='top']) [part~='bubble'],
764
+ :host([data-bubble-tail='bottom']) [part~='bubble'],
765
+ :host([data-bubble-tail='top']) [part~='typing'],
766
+ :host([data-bubble-tail='bottom']) [part~='typing'] {
767
+ border-radius: var(--chit-bubble-radius);
768
+ }
769
+
770
+ /* Their side: the leaf points left, its root inside the bubble. */
771
+ :host([data-bubble-tail]) [part~='message-assistant'] [part~='bubble']::after,
772
+ :host([data-bubble-tail]) [part~='typing']::after {
773
+ right: calc(100% - var(--_chit-tail-root));
774
+ background: var(--chit-color-assistant-bg);
775
+ }
776
+
777
+ /* Your side: the same leaf, mirrored. */
778
+ :host([data-bubble-tail]) [part~='message-user'] [part~='bubble']::after {
779
+ left: calc(100% - var(--_chit-tail-root));
780
+ background: var(--chit-color-user-bg);
781
+ transform: scaleX(-1);
782
+ }
783
+
784
+ :host([data-bubble-tail='top']) [part~='bubble']::after,
785
+ :host([data-bubble-tail='top']) [part~='typing']::after {
786
+ top: var(--_chit-tail-offset);
787
+ }
788
+
789
+ :host([data-bubble-tail='bottom']) [part~='bubble']::after,
790
+ :host([data-bubble-tail='bottom']) [part~='typing']::after {
791
+ bottom: var(--_chit-tail-offset);
792
+ }
793
+
794
+ :host([data-bubble-tail='bottom']) [part~='message-assistant'] [part~='bubble']::after,
795
+ :host([data-bubble-tail='bottom']) [part~='typing']::after {
796
+ transform: scaleY(-1);
797
+ }
798
+
799
+ :host([data-bubble-tail='bottom']) [part~='message-user'] [part~='bubble']::after {
800
+ transform: scale(-1, -1);
801
+ }
802
+ }
803
+
628
804
  [part~='avatar'] {
629
805
  flex: none;
630
806
  width: 2em;
@@ -633,6 +809,15 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
633
809
  object-fit: cover;
634
810
  }
635
811
 
812
+ /*
813
+ * A message that hides the theme's icon (avatar: null, for the second and
814
+ * later messages in a run) keeps its place in the row, so the bubbles below
815
+ * stay in line with the one that shows the face.
816
+ */
817
+ [part~='avatar'][data-placeholder] {
818
+ visibility: hidden;
819
+ }
820
+
636
821
  [part~='name'] {
637
822
  font-size: 0.8em;
638
823
  color: var(--chit-color-system-text);
@@ -676,9 +861,12 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
676
861
  }
677
862
 
678
863
  [part~='typing'] {
864
+ position: relative;
679
865
  align-self: flex-start;
866
+ /* Indented past the speaker's icon, when the theme gives them one. */
867
+ margin-inline-start: var(--_chit-speaker-gutter, 0px);
680
868
  padding: 0.7em 0.9em;
681
- border-radius: 14px;
869
+ border-radius: var(--chit-bubble-radius);
682
870
  border-bottom-left-radius: 4px;
683
871
  background: var(--chit-color-assistant-bg);
684
872
  color: var(--chit-color-assistant-text);
@@ -747,7 +935,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
747
935
  animation: none;
748
936
  }
749
937
  }
750
- `,we=o`
938
+ `,xe=o`
751
939
  [part~='message-content'] {
752
940
  min-width: 0;
753
941
  max-width: 100%;
@@ -854,7 +1042,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
854
1042
  border: 0;
855
1043
  border-top: 1px solid var(--chit-color-border);
856
1044
  }
857
- `,xe=o`
1045
+ `,_e=o`
858
1046
  [part~='composer'] {
859
1047
  display: flex;
860
1048
  flex: none;
@@ -908,6 +1096,45 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
908
1096
  font-weight: 600;
909
1097
  }
910
1098
 
1099
+ /* Out of sight, but still clickable from the button beside it. */
1100
+ [part~='attach-input'] {
1101
+ display: none;
1102
+ }
1103
+
1104
+ [part~='attach-button'] {
1105
+ display: grid;
1106
+ flex: none;
1107
+ place-items: center;
1108
+ width: 2.4em;
1109
+ height: 2.4em;
1110
+ padding: 0;
1111
+ border: 0;
1112
+ border-radius: 50%;
1113
+ background: transparent;
1114
+ color: var(--chit-color-system-text);
1115
+ cursor: pointer;
1116
+ transition: opacity 120ms ease;
1117
+ }
1118
+
1119
+ [part~='attach-button'] svg {
1120
+ width: 1.3em;
1121
+ height: 1.3em;
1122
+ }
1123
+
1124
+ [part~='attach-button']:hover:not(:disabled) {
1125
+ background: color-mix(in srgb, currentColor 10%, transparent);
1126
+ }
1127
+
1128
+ [part~='attach-button']:focus-visible {
1129
+ outline: 2px solid var(--chit-color-accent);
1130
+ outline-offset: 2px;
1131
+ }
1132
+
1133
+ [part~='attach-button']:disabled {
1134
+ opacity: 0.4;
1135
+ cursor: default;
1136
+ }
1137
+
911
1138
  [part~='send-button'] {
912
1139
  display: grid;
913
1140
  flex: none;
@@ -958,7 +1185,7 @@ const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow
958
1185
  animation-duration: 2s;
959
1186
  }
960
1187
  }
961
- `;class _e extends lt{static styles=[be,ve,ye,$e,we,xe];static properties={state:{type:String,reflect:!0,noAccessor:!0},theme:{type:Object},messages:{type:Array},typing:{type:Object},busy:{type:Boolean,reflect:!0},inputDisabled:{type:Boolean,reflect:!0,attribute:"input-disabled"},inputHidden:{type:Boolean,reflect:!0,attribute:"input-hidden"},placeholder:{type:String,reflect:!0},sendOnEnter:{type:Boolean,reflect:!0,attribute:"send-on-enter"},maxLength:{type:Number,reflect:!0,attribute:"max-length"},focusOnOpen:{type:String,reflect:!0,attribute:"focus-on-open"},locale:{type:String,reflect:!0},labels:{type:Object},messageStyles:{type:String}};#rt="closed";#at="api";#ht;#x;#lt;#ct;#dt;#pt=new Dt("data-chit-message-styles");#ut=new Map;#mt=null;constructor(){super(),this.theme={},this.messages=[],this.typing=!1,this.busy=!1,this.inputDisabled=!1,this.inputHidden=!1,this.placeholder=void 0,this.sendOnEnter=!0,this.maxLength=void 0,this.focusOnOpen="auto",this.locale=void 0,this.labels=void 0,this.messageStyles="",this.sanitize=void 0,this.formatTime=void 0,this.#ht=new xt(this,{animation:(t,e,s)=>this.#ft(t,e,s),keepsLauncher:()=>"visible"===this.currentTheme.open.launcher,onOpened:()=>this.#gt()}),this.#x=new _t(this),this.#lt=new qt(this,{device:()=>this.#x.device}),this.addController(this.#lt),this.#ct=new Ft(this,{behavior:()=>this.currentTheme.open.animation.scroll}),this.#dt=new Kt(this)}get state(){return this.#rt}set state(t){const e=this.#rt;if(t===e)return;if(this.#rt=t,this.requestUpdate("state",e),!this.#ht||this.#ht.applying)return;const s=this.#at;this.#at="api";const i=this.#ht.request(t,s);this.#mt=i,i.then(()=>{this.#mt===i&&(this.#mt=null)})}get device(){return this.#x.device}get currentTheme(){return this.#lt.current}get currentLabels(){return function(t,e){const s=(ge(t)||"en").toLowerCase(),i=fe[s]??fe[s.split("-")[0]]??fe.en;return e?{...i,...e}:i}(this.locale,this.labels)}get resolvedLocale(){return ge(this.locale)}get renderedState(){return this.#ht.renderedState}get hasUnseen(){return this.#ct.hasUnseen}get value(){return this.#dt.value}set value(t){this.#dt.value=t}get canSend(){return this.#dt.canSend}open(){return this.#bt("open","api")}close(){return this.#bt("closed","api")}hide(){return this.#bt("hidden","api")}show(){return"hidden"===this.#rt?this.#bt("closed","api"):Promise.resolve(!0)}toggle(){return this.#bt("open"===this.state?"closed":"open","api")}submit(t){return this.#dt.submit(t)}clearInput(){this.#dt.clear()}scrollToBottom(t){this.#ct.scrollToBottom(t)}getMessageElement(t){return this.renderRoot.querySelector(`[part~="message"][data-id="${CSS.escape(t)}"] [part~="message-content"]`)}focusInput(){const t=this.renderRoot.querySelector('[part~="input"]');return!!t&&(t.focus(),!0)}#gt(){if("never"===this.focusOnOpen)return;if("auto"===this.focusOnOpen&&"mobile"===this.device)return;if(this.focusInput())return;const t=this.renderRoot.querySelector('[part~="panel"]');t?.focus()}handleInput(t){this.#dt.onInput(t)}handleKeydown(t){this.#dt.onKeydown(t)}handleComposition(t){t?this.#dt.onCompositionStart():this.#dt.onCompositionEnd()}renderTypingHtml(t){return vt(this.sanitize?this.sanitize(t):t)}handleMessageClick(t){const e=t.composedPath(),s=e.find(t=>t instanceof HTMLElement&&t.getAttribute("part")?.split(/\s+/).includes("message"));if(!s)return;const i=s.dataset.id,n=this.messages.find(t=>t.id===i);if(!n)return;const o=e[0];$t(this,yt.MESSAGE_CLICK,{message:n,target:o,originalEvent:t},{cancelable:!0})||t.preventDefault()}toggleFromUser(){return this.#bt("open"===this.state?"closed":"open","user")}closeFromUser(){return this.#bt("closed","user")}#bt(t,e){return t!==this.#rt&&(this.#at=e,this.state=t),this.#mt??Promise.resolve(!0)}#ft(t,e,s){const i=this.currentTheme;if("exit"===s&&"hidden"===e)return{effect:i.hidden.animation.exit,duration:i.hidden.animation.duration};const n="open"===("exit"===s?t:e)?i.open:i.closed;return{effect:"exit"===s?n.animation.exit:n.animation.enter,duration:n.animation.duration}}willUpdate(){this.#x.observe(qt.breakpointOf(this.theme)),this.#lt.apply(this.theme,this.#x.device),this.#pt.write(this.messageStyles??"",this.renderRoot);const t=this.currentTheme;this.dataset.launcherPosition=t.closed.position,this.dataset.panelPosition=t.open.position,this.dataset.idle=t.closed.animation.idle}updated(){const t=new Set(this.messages.map(t=>t.id));!function(t,e){const s=Gt.get(t);if(s)for(const t of s.keys())t.startsWith("msg:")&&(e.has(t.slice(4))||s.delete(t))}(this,t),this.#vt(t)}#vt(t){for(const e of this.#ut.keys())t.has(e)||this.#ut.delete(e);for(const t of this.messages){const e=Zt(t);if(this.#ut.has(t.id)&&Object.is(this.#ut.get(t.id),e))continue;this.#ut.set(t.id,e);const s=this.getMessageElement(t.id);s&&$t(this,yt.MESSAGE_RENDER,{message:t,element:s,instance:Xt(this,t.id)})}}render(){const t=this.renderedState,e="closed"===t||"open"===t&&"visible"===this.currentTheme.open.launcher,s="open"===t;return q`
962
- ${e?ee(this):K} ${s?me(this):K}
963
- `}}customElements.get("chit-ui")||customElements.define("chit-ui",_e);const Se=ft(class extends gt{constructor(t){if(super(t),t.type!==dt||"class"!==t.name||t.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in e)e[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(e)}const s=t.element.classList;for(const t of this.st)t in e||(s.remove(t),this.st.delete(t));for(const t in e){const i=!!e[t];i===this.st.has(t)||this.nt?.has(t)||(i?(s.add(t),this.st.add(t)):(s.remove(t),this.st.delete(t)))}return W}}),Ae="important",Ee=" !"+Ae,Ce=ft(class extends gt{constructor(t){if(super(t),t.type!==dt||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,s)=>{const i=t[s];return null==i?e:e+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(t,[e]){const{style:s}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in e){const i=e[t];if(null!=i){this.ft.add(t);const e="string"==typeof i&&i.endsWith(Ee);t.includes("-")||e?s.setProperty(t,e?i.slice(0,-11):i,e?Ae:""):s[t]=i}}return W}});export{_e as ChitUI,yt as Events,lt as LitElement,Se as classMap,o as css,q as html,ue as live,K as nothing,at as render,de as repeat,Ce as styleMap,F as svg,vt as unsafeHTML};
1188
+ `;class Ae extends lt{static styles=[ve,ye,we,$e,xe,_e];static properties={state:{type:String,reflect:!0,noAccessor:!0},theme:{type:Object},messages:{type:Array},typing:{type:Object},busy:{type:Boolean,reflect:!0},inputDisabled:{type:Boolean,reflect:!0,attribute:"input-disabled"},inputHidden:{type:Boolean,reflect:!0,attribute:"input-hidden"},placeholder:{type:String,reflect:!0},sendOnEnter:{type:Boolean,reflect:!0,attribute:"send-on-enter"},maxLength:{type:Number,reflect:!0,attribute:"max-length"},focusOnOpen:{type:String,reflect:!0,attribute:"focus-on-open"},locale:{type:String,reflect:!0},labels:{type:Object},messageStyles:{type:String}};#rt="closed";#at="api";#ht;#x;#lt;#ct;#dt;#pt=new Dt("data-chit-message-styles");#ut=new Map;#mt=null;constructor(){super(),this.theme={},this.messages=[],this.typing=!1,this.busy=!1,this.inputDisabled=!1,this.inputHidden=!1,this.placeholder=void 0,this.sendOnEnter=!0,this.maxLength=void 0,this.focusOnOpen="auto",this.locale=void 0,this.labels=void 0,this.messageStyles="",this.sanitize=void 0,this.formatTime=void 0,this.#ht=new xt(this,{animation:(t,e,s)=>this.#ft(t,e,s),keepsLauncher:()=>"visible"===this.currentTheme.open.launcher,onOpened:()=>this.#gt()}),this.#x=new _t(this),this.#lt=new qt(this,{device:()=>this.#x.device}),this.addController(this.#lt),this.#ct=new Ft(this,{behavior:()=>this.currentTheme.open.animation.scroll}),this.#dt=new Kt(this)}get state(){return this.#rt}set state(t){const e=this.#rt;if(t===e)return;if(this.#rt=t,this.requestUpdate("state",e),!this.#ht||this.#ht.applying)return;const s=this.#at;this.#at="api";const i=this.#ht.request(t,s);this.#mt=i,i.then(()=>{this.#mt===i&&(this.#mt=null)})}get device(){return this.#x.device}get currentTheme(){return this.#lt.current}get currentLabels(){return function(t,e){const s=(be(t)||"en").toLowerCase(),i=ge[s]??ge[s.split("-")[0]]??ge.en;return e?{...i,...e}:i}(this.locale,this.labels)}get resolvedLocale(){return be(this.locale)}get renderedState(){return this.#ht.renderedState}get hasUnseen(){return this.#ct.hasUnseen}get value(){return this.#dt.value}set value(t){this.#dt.value=t}get canSend(){return this.#dt.canSend}open(){return this.#bt("open","api")}close(){return this.#bt("closed","api")}hide(){return this.#bt("hidden","api")}show(){return"hidden"===this.#rt?this.#bt("closed","api"):Promise.resolve(!0)}toggle(){return this.#bt("open"===this.state?"closed":"open","api")}submit(t){return this.#dt.submit(t)}clearInput(){this.#dt.clear()}scrollToBottom(t){this.#ct.scrollToBottom(t)}getMessageElement(t){return this.renderRoot.querySelector(`[part~="message"][data-id="${CSS.escape(t)}"] [part~="message-content"]`)}focusInput(){const t=this.renderRoot.querySelector('[part~="input"]');return!!t&&(t.focus(),!0)}#gt(){if("never"===this.focusOnOpen)return;if("auto"===this.focusOnOpen&&"mobile"===this.device)return;if(this.focusInput())return;const t=this.renderRoot.querySelector('[part~="panel"]');t?.focus()}handleInput(t){this.#dt.onInput(t)}handleKeydown(t){this.#dt.onKeydown(t)}handleComposition(t){t?this.#dt.onCompositionStart():this.#dt.onCompositionEnd()}handleAttach(t){wt(this,yt.ATTACH,{files:t})}openAttach(){const t=this.renderRoot.querySelector('[part~="attach-input"]');t?.click()}renderTypingHtml(t){return vt(this.sanitize?this.sanitize(t):t)}handleMessageClick(t){const e=t.composedPath(),s=e.find(t=>t instanceof HTMLElement&&t.getAttribute("part")?.split(/\s+/).includes("message"));if(!s)return;const i=s.dataset.id,n=this.messages.find(t=>t.id===i);if(!n)return;const o=e[0];wt(this,yt.MESSAGE_CLICK,{message:n,target:o,originalEvent:t},{cancelable:!0})||t.preventDefault()}toggleFromUser(){return this.#bt("open"===this.state?"closed":"open","user")}closeFromUser(){return this.#bt("closed","user")}home(t="api"){wt(this,yt.HOME,{trigger:t})}#bt(t,e){return t!==this.#rt&&(this.#at=e,this.state=t),this.#mt??Promise.resolve(!0)}#ft(t,e,s){const i=this.currentTheme;if("exit"===s&&"hidden"===e)return{effect:i.hidden.animation.exit,duration:i.hidden.animation.duration};const n="open"===("exit"===s?t:e)?i.open:i.closed;return{effect:"exit"===s?n.animation.exit:n.animation.enter,duration:n.animation.duration}}willUpdate(){this.#x.observe(qt.breakpointOf(this.theme)),this.#lt.apply(this.theme,this.#x.device),this.#pt.write(this.messageStyles??"",this.renderRoot);const t=this.currentTheme;this.dataset.launcherPosition=t.closed.position,this.dataset.panelPosition=t.open.position,this.dataset.idle=t.closed.animation.idle,this.dataset.bubbleTail=t.open.bubble.tail}updated(){const t=new Set(this.messages.map(t=>t.id));!function(t,e){const s=Gt.get(t);if(s)for(const t of s.keys())t.startsWith("msg:")&&(e.has(t.slice(4))||s.delete(t))}(this,t),this.#vt(t)}#vt(t){for(const e of this.#ut.keys())t.has(e)||this.#ut.delete(e);for(const t of this.messages){const e=Zt(t);if(this.#ut.has(t.id)&&Object.is(this.#ut.get(t.id),e))continue;this.#ut.set(t.id,e);const s=this.getMessageElement(t.id);s&&wt(this,yt.MESSAGE_RENDER,{message:t,element:s,instance:Xt(this,t.id)})}}render(){const t=this.renderedState,e="closed"===t||"open"===t&&"visible"===this.currentTheme.open.launcher,s="open"===t;return q`
1189
+ ${e?ee(this):K} ${s?fe(this):K}
1190
+ `}}customElements.get("chit-ui")||customElements.define("chit-ui",Ae);const Se={closed:{colors:{background:"#0a6b36",text:"#ffffff",shadow:"0 4px 12px rgba(16, 42, 26, 0.32)"}},open:{radius:12,colors:{background:"#d3ddea",text:"#16212c",accent:"#0a6b36",border:"#b6c5d6",shadow:"0 8px 32px rgba(16, 32, 48, 0.28)",headerBackground:"#ffffff",headerText:"#16212c",userBubble:"#9ce26c",userText:"#14240c",assistantBubble:"#ffffff",assistantText:"#16212c",systemText:"#37475a",inputBackground:"#ffffff",inputText:"#16212c",inputPlaceholder:"#5c6370"},bubble:{radius:18,tail:"top"}}},Ee=ft(class extends gt{constructor(t){if(super(t),t.type!==dt||"class"!==t.name||t.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter(e=>t[e]).join(" ")+" "}update(t,[e]){if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter(t=>""!==t)));for(const t in e)e[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(e)}const s=t.element.classList;for(const t of this.st)t in e||(s.remove(t),this.st.delete(t));for(const t in e){const i=!!e[t];i===this.st.has(t)||this.nt?.has(t)||(i?(s.add(t),this.st.add(t)):(s.remove(t),this.st.delete(t)))}return W}}),ke="important",Ce=" !"+ke,Te=ft(class extends gt{constructor(t){if(super(t),t.type!==dt||"style"!==t.name||t.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,s)=>{const i=t[s];return null==i?e:e+`${s=s.includes("-")?s:s.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(t,[e]){const{style:s}=t.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(e)),this.render(e);for(const t of this.ft)null==e[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in e){const i=e[t];if(null!=i){this.ft.add(t);const e="string"==typeof i&&i.endsWith(Ce);t.includes("-")||e?s.setProperty(t,e?i.slice(0,-11):i,e?ke:""):s[t]=i}}return W}});export{Ae as ChitUI,yt as Events,lt as LitElement,Ee as classMap,o as css,Se as greenTheme,q as html,ue as live,K as nothing,at as render,de as repeat,Te as styleMap,F as svg,vt as unsafeHTML};
964
1191
  //# sourceMappingURL=chit-ui.min.js.map