@nyaruka/temba-components 0.130.0 → 0.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/temba-components.js +3 -3
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js +13 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +1 -0
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/form/select/Select.js +7 -1
- package/out-tsc/src/form/select/Select.js.map +1 -1
- package/package.json +1 -1
- package/src/flow/actions/add_contact_groups.ts +16 -1
- package/src/flow/actions/add_input_labels.ts +1 -0
- package/src/form/select/Select.ts +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v0.130.1](https://github.com/nyaruka/temba-components/compare/v0.130.0...v0.130.1)
|
|
8
|
+
|
|
9
|
+
- Better fallback logic for createArbitraryOption [`18f9c21`](https://github.com/nyaruka/temba-components/commit/18f9c2153403b4c358519984208fa196d26f7d37)
|
|
10
|
+
|
|
7
11
|
#### [v0.130.0](https://github.com/nyaruka/temba-components/compare/v0.129.10...v0.130.0)
|
|
8
12
|
|
|
13
|
+
> 4 September 2025
|
|
14
|
+
|
|
9
15
|
- Fix allowCreate for Select [`#684`](https://github.com/nyaruka/temba-components/pull/684)
|
|
10
16
|
- Implement split by random [`#683`](https://github.com/nyaruka/temba-components/pull/683)
|
|
11
17
|
- Implement Individual Form Configurations for Contact Update Actions [`#680`](https://github.com/nyaruka/temba-components/pull/680)
|
package/dist/temba-components.js
CHANGED
|
@@ -1243,7 +1243,7 @@ let al=Ba,ll=!1;const cl=["es","fr","pt"],hl="data:image/png;base64,iVBORw0KGgoA
|
|
|
1243
1243
|
.ghost .remove-item {
|
|
1244
1244
|
display: none !important;
|
|
1245
1245
|
}
|
|
1246
|
-
`}set values(t){this._values=Array.isArray(t)?t:[],this.requestUpdate("values")}get values(){return this._values||[]}constructor(){super(),this.hiddenInputs=[],this.inputStyle={},this.multi=!1,this.searchOnFocus=!1,this.placeholder="",this.name="",this.allowCreate=!1,this.nameKey="name",this.valueKey="value",this.maxItems=0,this.maxItemsText="Maximum items reached",this.queryParam=null,this.input="",this.visibleOptions=[],this.completionOptions=[],this.quietMillis=0,this.searchable=!1,this.cache=!0,this.cacheKey="",this.focused=!1,this.disabled=!1,this.attemptedOpen=!1,this.selectedIndex=-1,this.anchorPosition={left:0,top:0},this.tags=!1,this.emails=!1,this.flavor="default",this.infoText="",this._values=[],this.getName=t=>t[this.nameKey||"name"],this.isMatch=this.isMatchDefault,this.getValue=t=>t[this.valueKey||"value"]||t.id,this.sortFunction=null,this.renderOptionDetail=()=>H``,this.renderSelectedItem=this.renderSelectedItemDefault,this.createArbitraryOption=this.createArbitraryOptionDefault,this.getOptions=this.getOptionsDefault,this.prepareOptions=this.prepareOptionsDefault,this.isComplete=this.isCompleteDefault,this.staticOptions=[],this.allowAnchor=!0,this.alphaSort=(t,e)=>this.endpoint?this.getNameInternal(t).localeCompare(this.getNameInternal(e)):0,this.next=null,this.lruCache=Cn(20,6e4),this.getNameInternal=t=>this.getName?this.getName(t):t[this.nameKey||"name"]||"",this.renderOptionDefault=this.renderOptionDefault.bind(this),this.renderSelectedItemDefault=this.renderSelectedItemDefault.bind(this),this.prepareOptionsDefault=this.prepareOptionsDefault.bind(this),this.isMatchDefault=this.isMatchDefault.bind(this),this.handleOrderChanged=this.handleOrderChanged.bind(this),this.createArbitraryOption=(this.createArbitraryOption||this.createArbitraryOptionDefault).bind(this)}prepareOptionsDefault(t){return t}isMatchDefault(t,e){return(this.getNameInternal(t)||"").toLowerCase().indexOf(e)>-1}handleSlotChange(){if(this.staticOptions&&0===this.staticOptions.length)for(const t of this.children)if("TEMBA-OPTION"===t.tagName){const e={};for(const i of t.attributes)e[i.name]=i.value;if(e){let t=!1;void 0!==e.selected&&(delete e.selected,t=!0);const i=this.value||this.getAttribute("value");if(i){this.getValue(e)==i&&(t=!0)}this.staticOptions.push(e),t&&(this.isMultiMode?this.addValue(e):this.setValues([e]))}}this.searchable&&0===this.staticOptions.length&&(this.quietMillis=200)}checkSelectedOption(){if(this.value&&0==this.values.length&&0==this.staticOptions.length&&this.endpoint){const t=this.value;this.resolving=!0,oe(this.endpoint).then((e=>{if(e&&e.length>0){if(t){const i=e.find((e=>this.getValue(e)===t));if(i)return this.resolving=!1,this.fetching=!1,void this.setValues([i])}this.setValues([e[0]]),this.resolving=!1}}))}else this.staticOptions.length>0&&(null!==this.getAttribute("multi")?this.addValue(this.staticOptions[0]):this.getAttribute("value")?this.setSelectedValue(this.getAttribute("value")):this.setValues([this.staticOptions[0]]))}firstUpdated(t){super.firstUpdated(t),this.anchorElement=this.shadowRoot.querySelector(".select-container"),this.anchorExpressions=this.shadowRoot.querySelector("#anchor"),this.shadowRoot.addEventListener("slotchange",this.handleSlotChange.bind(this))}updated(t){super.updated(t),t.has("sorted")&&(this.sortFunction=this.sorted?this.alphaSort:null),t.has("value")&&this.value&&!this.values.length&&this.setSelectedValue(this.value),t.has("values")&&(this.updateInputs(),this.hasChanges(t.get("values"))&&this.fireEvent("change")),t.has("cacheKey")&&this.lruCache.clear(),t.has("input")&&!t.has("values")&&!t.has("options")&&this.focused&&(this.lastQuery&&window.clearTimeout(this.lastQuery),this.lastQuery=window.setTimeout((()=>{this.expressions&&this.input.indexOf("@")>-1?this.fetchExpressions():this.fetchOptions(this.input)}),this.quietMillis)),this.endpoint&&t.has("fetching")&&(this.fetching||this.isPastFetchThreshold()||this.fireCustomEvent(_n.FetchComplete)),(t.has("cursorIndex")||t.has("visibleOptions"))&&this.endpoint&&!this.fetching&&this.isPastFetchThreshold()&&(this.next?this.fetchOptions(null,null,this.next):this.fetchOptions(this.query,this.page+1)),0===this.values.length&&!this.placeholder&&this.staticOptions.length>0&&this.setValues([this.staticOptions[0]])}hasChanges(t){if(void 0===t)return!1;let e;void 0!==t&&(e=(t||[]).map((t=>this.getValue(t))).join(","));return e!==(this.values||[]).map((t=>t.arbitrary||this.getValue(t))).join(",")}setSelectedValue(t){if(this.staticOptions.length>0){const e=this.staticOptions.find((e=>this.getValue(e)===t));e&&this.setValues([e])}else this.checkSelectedOption()}updateInputs(){for(let t=null;t=this.hiddenInputs.pop();)t.remove();if(0===this.values.length)this.value=null;else{const t=this.getAttribute("name");t&&(this.isMultiMode||1!==this.values.length?this.inputRoot.parentElement&&this.values.forEach((e=>{const i=document.createElement("input");i.setAttribute("type","hidden"),i.setAttribute("name",t),i.setAttribute("value",this.serializeValue(e)),this.hiddenInputs.push(i),this.inputRoot.parentElement.appendChild(i)})):(this.selection=this.values[0],this.value=this.serializeValue(this.values[0]),this.internals&&this.internals.setFormValue(this.value)))}}setSelectedOption(t){this.isMultiMode?this.addValue(t):this.setValues([t]),this.isMultiMode&&this.searchable||(this.blur(),this.focused=!1),this.visibleOptions=[],this.attemptedOpen=!1,this.input="",this.next=null,this.complete=!0,this.selectedIndex=-1}isPastFetchThreshold(){return(this.visibleOptions.length>0||this.next)&&!this.complete&&(this.cursorIndex||0)>this.visibleOptions.length-20}handleOptionSelection(t){if(this.isMultiMode&&this.maxItems>0&&this.values.length>=this.maxItems)return void(this.infoText=this.maxItemsText);this.infoText="";const e=t.detail.selected;e.arbitrary&&this.allowCreate&&this.endpoint?(this.resolving=!0,le(this.endpoint,e).then((t=>{t.status>=200&&t.status<300?(this.setSelectedOption(t.json),this.lruCache=Cn(20,6e4),this.errors=[]):(this.setSelectedOption(e),setTimeout((()=>{this.errors=['There was an error creating "'+this.getNameInternal(e)+'"']}),0),this.blur()),this.resolving=!1}))):(this.setSelectedOption(e),this.errors=[])}handleExpressionSelection(t){const e=t.detail.selected,i=t.detail.tabbed,n=this.shadowRoot.querySelector(".searchbox");Cc(this.query,n,e),this.query="",this.completionOptions=[],i?this.fetchExpressions():-1===this.input.indexOf("(")&&this.addInputAsValue()}getOptionsDefault(t){return t.json.results}isCompleteDefault(t,e){const i=e.json;return!i.more&&!i.next}handleRemoveSelection(t){if(this.removeValue(t),this.visibleOptions=[],this.errors=[],this.allowCreate){const t=this.values.find((t=>t.arbitrary));t&&setTimeout((()=>{this.errors=['There was an error creating "'+this.getNameInternal(t)+'"']}),0)}}createArbitraryOptionDefault(t,e){return this.emails&&t&&this.isValidEmail(t)||this.tags&&t?{name:t,value:t}:null}isValidEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}get isMultiMode(){return this.multi||this.emails}open(){this.shadowRoot.querySelector(".select-container").click()}isOpen(){return this.visibleOptions.length>0||this.attemptedOpen&&this.focused}setOptions(t){this.staticOptions=t}setVisibleOptions(t){if(t=t.filter((t=>!!this.getNameInternal(t)&&(!this.shouldExclude||!this.shouldExclude(t)))),this.input){if(this.searchable&&!this.queryParam){const e=this.input.trim().toLowerCase();t=t.filter((t=>this.isMatch(t,e)))}const e=this.createArbitraryOption(this.input,t);if(e){e.arbitrary=!0;t.find((t=>this.getValue(t)===this.getValue(e)))||(t.length>0&&t[0].arbitrary?t[0]=e:t.unshift(e))}}this.values.length>0&&(this.isMultiMode?t=t.filter((t=>!this.values.find((e=>this.getValue(e)===this.getValue(t))))):(this.input?this.cursorIndex=0:this.cursorIndex=t.findIndex((t=>this.getValue(t)===this.getValue(this.values[0]))),this.requestUpdate("cursorIndex"))),this.isMultiMode&&this.maxItems>0&&this.values.length>=this.maxItems&&(t=[],this.infoText=this.maxItemsText),this.sortFunction&&t.sort(this.sortFunction),this.visibleOptions=t,this.fireCustomEvent(_n.ContentChanged,{options:this.visibleOptions})}fetchExpressions(){const t=document.querySelector("temba-store");if(this.expressions&&t){const t=this.shadowRoot.querySelector(".searchbox"),e=Sc(t,"session"===this.expressions);return this.query=e.query,this.completionOptions=e.options,this.visibleOptions=[],this.anchorPosition=e.anchorPosition,void this.fireCustomEvent(_n.FetchComplete)}}fetchOptions(t,e=0,i=null){if(this.completionOptions=[],!this.fetching){this.fetching=!0;const n=[...this.staticOptions],o=(t||"").trim().toLowerCase();if(this.tags&&o&&(n.find((t=>this.getValue(t)&&this.getValue(t).toLowerCase()===o))||n.splice(0,0,{name:t,value:t})),this.emails&&o&&this.isValidEmail(o)&&!n.find((t=>this.getValue(t)&&this.getValue(t).toLowerCase()===o))&&n.splice(0,0,{name:t,value:t}),this.endpoint){let s=this.endpoint;i?s=i:(t&&this.queryParam&&(s.indexOf("?")>-1?s+="&":s+="?",s+=this.queryParam+"="+encodeURIComponent(t)),e&&(s.indexOf("?")>-1?s+="&":s+="?",s+="page="+e));const r=this.lruCache.get(s);if(this.cache&&!this.tags&&!this.emails&&r)return 0!==e||this.next?this.setVisibleOptions([...this.visibleOptions,...r.options]):(this.cursorIndex=0,this.setVisibleOptions([...n,...r.options])),this.complete=r.complete,this.next=r.next,void(this.fetching=!1);this.searchable&&!this.queryParam?oe(s).then((t=>{t=this.prepareOptions(t),!this.cache||this.tags||this.emails||(this.lruCache.set(s,{options:t,complete:!0,next:null}),this.complete=!0,this.next=null,this.setVisibleOptions([...n,...t]),this.fetching=!1)})):ee(s).then((i=>{let r=this.getOptions(i).filter((t=>this.isMatch(t,o)));r=this.prepareOptions(r),this.next=null;const a=i.json;a.next&&(this.next=a.next),0!==e||this.next?(r.length>0&&this.setVisibleOptions([...this.visibleOptions,...r]),this.complete=this.isComplete(r,i)):(this.cursorIndex=0,this.setVisibleOptions([...n,...r]),this.query=t,this.complete=this.isComplete(this.visibleOptions,i)),!this.cache||this.tags||this.emails||this.lruCache.set(s,{options:r,complete:this.complete,next:this.next}),this.fetching=!1,this.page=e})).catch((t=>{this.fetching=!1,console.error(t)}))}else this.fetching=!1,this.setVisibleOptions(n)}}handleFocus(){this.focused||0!==this.visibleOptions.length||(this.focused=!0)}handleBlur(){this.focused=!1,this.attemptedOpen=!1,this.visibleOptions.length>0&&(this.input="",this.next=null,this.complete=!0,this.visibleOptions=[],this.cursorIndex=0),this.isMultiMode&&this.maxItems>0&&this.values.length>=this.maxItems&&(this.infoText="")}handleClick(){this.selectedIndex=-1,this.requestUpdate("input")}addInputAsValue(){const t=this.shadowRoot.querySelector(".searchbox"),e={name:t.value,value:t.value,expression:!0};this.isMultiMode?this.values.find((t=>t.expression&&t.value&&e.value&&t.value.toLowerCase().trim()==e.value.toLowerCase().trim()))||this.addValue(e):this.setValues([e]),this.input="",this.isMultiMode||this.blur()}handleKeyDown(t){if("Enter"===t.key&&this.expressions&&0===this.completionOptions.length&&this.input.indexOf("@")>-1)this.addInputAsValue();else if("Enter"===t.key&&this.emails&&this.input&&this.isValidEmail(this.input.trim())&&0===this.visibleOptions.length){t.preventDefault();const e={name:this.input.trim(),value:this.input.trim()};this.setSelectedOption(e)}else{if(("Enter"===t.key||"ArrowDown"===t.key||"n"===t.key&&t.ctrlKey)&&0===this.visibleOptions.length&&0===this.completionOptions.length&&!this.input)return this.attemptedOpen=!0,void this.requestUpdate("input");if(this.isMultiMode&&"Backspace"===t.key&&!this.input){if(this.visibleOptions.length>0)return void(this.visibleOptions=[]);-1===this.selectedIndex?(this.selectedIndex=this.values.length-1,this.visibleOptions=[]):(this.popValue(),this.selectedIndex=-1)}else this.selectedIndex=-1}}getStaticOptions(){return this.staticOptions}handleInput(t){const e=t.currentTarget;this.input=e.value}handleCancel(){this.visibleOptions=[],this.attemptedOpen=!1}handleCursorChanged(t){this.cursorIndex=t.detail.index}handleContainerClick(t){if(this.disabled)return t.stopPropagation(),void t.preventDefault();if(this.focused=!0,"INPUT"!==t.target.tagName){const t=this.shadowRoot.querySelector("input");if(t)return t.click(),void t.focus();this.isOpen()?(this.visibleOptions=[],this.attemptedOpen=!1):(this.attemptedOpen=!0,this.requestUpdate("input"),this.requestUpdate())}}getEventHandlers(){return[{event:_n.Canceled,method:this.handleCancel},{event:_n.CursorChanged,method:this.handleCursorChanged},{event:"blur",method:this.handleBlur},{event:"focus",method:this.handleFocus}]}handleArrowClick(t){this.disabled||this.isOpen()&&(t.preventDefault(),t.stopPropagation(),this.blur())}renderOptionDefault(t){if(!t)return null;const e=t.icon;return H`
|
|
1246
|
+
`}set values(t){this._values=Array.isArray(t)?t:[],this.requestUpdate("values")}get values(){return this._values||[]}constructor(){super(),this.hiddenInputs=[],this.inputStyle={},this.multi=!1,this.searchOnFocus=!1,this.placeholder="",this.name="",this.allowCreate=!1,this.nameKey="name",this.valueKey="value",this.maxItems=0,this.maxItemsText="Maximum items reached",this.queryParam=null,this.input="",this.visibleOptions=[],this.completionOptions=[],this.quietMillis=0,this.searchable=!1,this.cache=!0,this.cacheKey="",this.focused=!1,this.disabled=!1,this.attemptedOpen=!1,this.selectedIndex=-1,this.anchorPosition={left:0,top:0},this.tags=!1,this.emails=!1,this.flavor="default",this.infoText="",this._values=[],this.getName=t=>t[this.nameKey||"name"],this.isMatch=this.isMatchDefault,this.getValue=t=>t[this.valueKey||"value"]||t.id,this.sortFunction=null,this.renderOptionDetail=()=>H``,this.renderSelectedItem=this.renderSelectedItemDefault,this.createArbitraryOption=this.createArbitraryOptionDefault,this.getOptions=this.getOptionsDefault,this.prepareOptions=this.prepareOptionsDefault,this.isComplete=this.isCompleteDefault,this.staticOptions=[],this.allowAnchor=!0,this.alphaSort=(t,e)=>this.endpoint?this.getNameInternal(t).localeCompare(this.getNameInternal(e)):0,this.next=null,this.lruCache=Cn(20,6e4),this.getNameInternal=t=>this.getName?this.getName(t):t[this.nameKey||"name"]||"",this.renderOptionDefault=this.renderOptionDefault.bind(this),this.renderSelectedItemDefault=this.renderSelectedItemDefault.bind(this),this.prepareOptionsDefault=this.prepareOptionsDefault.bind(this),this.isMatchDefault=this.isMatchDefault.bind(this),this.handleOrderChanged=this.handleOrderChanged.bind(this),this.createArbitraryOption=this.createArbitraryOptionDefault.bind(this)}prepareOptionsDefault(t){return t}isMatchDefault(t,e){return(this.getNameInternal(t)||"").toLowerCase().indexOf(e)>-1}handleSlotChange(){if(this.staticOptions&&0===this.staticOptions.length)for(const t of this.children)if("TEMBA-OPTION"===t.tagName){const e={};for(const i of t.attributes)e[i.name]=i.value;if(e){let t=!1;void 0!==e.selected&&(delete e.selected,t=!0);const i=this.value||this.getAttribute("value");if(i){this.getValue(e)==i&&(t=!0)}this.staticOptions.push(e),t&&(this.isMultiMode?this.addValue(e):this.setValues([e]))}}this.searchable&&0===this.staticOptions.length&&(this.quietMillis=200)}checkSelectedOption(){if(this.value&&0==this.values.length&&0==this.staticOptions.length&&this.endpoint){const t=this.value;this.resolving=!0,oe(this.endpoint).then((e=>{if(e&&e.length>0){if(t){const i=e.find((e=>this.getValue(e)===t));if(i)return this.resolving=!1,this.fetching=!1,void this.setValues([i])}this.setValues([e[0]]),this.resolving=!1}}))}else this.staticOptions.length>0&&(null!==this.getAttribute("multi")?this.addValue(this.staticOptions[0]):this.getAttribute("value")?this.setSelectedValue(this.getAttribute("value")):this.setValues([this.staticOptions[0]]))}firstUpdated(t){super.firstUpdated(t),this.anchorElement=this.shadowRoot.querySelector(".select-container"),this.anchorExpressions=this.shadowRoot.querySelector("#anchor"),this.shadowRoot.addEventListener("slotchange",this.handleSlotChange.bind(this))}updated(t){super.updated(t),t.has("createArbitraryOption")&&(this.createArbitraryOption||(this.createArbitraryOption=this.createArbitraryOptionDefault.bind(this))),t.has("sorted")&&(this.sortFunction=this.sorted?this.alphaSort:null),t.has("value")&&this.value&&!this.values.length&&this.setSelectedValue(this.value),t.has("values")&&(this.updateInputs(),this.hasChanges(t.get("values"))&&this.fireEvent("change")),t.has("cacheKey")&&this.lruCache.clear(),t.has("input")&&!t.has("values")&&!t.has("options")&&this.focused&&(this.lastQuery&&window.clearTimeout(this.lastQuery),this.lastQuery=window.setTimeout((()=>{this.expressions&&this.input.indexOf("@")>-1?this.fetchExpressions():this.fetchOptions(this.input)}),this.quietMillis)),this.endpoint&&t.has("fetching")&&(this.fetching||this.isPastFetchThreshold()||this.fireCustomEvent(_n.FetchComplete)),(t.has("cursorIndex")||t.has("visibleOptions"))&&this.endpoint&&!this.fetching&&this.isPastFetchThreshold()&&(this.next?this.fetchOptions(null,null,this.next):this.fetchOptions(this.query,this.page+1)),0===this.values.length&&!this.placeholder&&this.staticOptions.length>0&&this.setValues([this.staticOptions[0]])}hasChanges(t){if(void 0===t)return!1;let e;void 0!==t&&(e=(t||[]).map((t=>this.getValue(t))).join(","));return e!==(this.values||[]).map((t=>t.arbitrary||this.getValue(t))).join(",")}setSelectedValue(t){if(this.staticOptions.length>0){const e=this.staticOptions.find((e=>this.getValue(e)===t));e&&this.setValues([e])}else this.checkSelectedOption()}updateInputs(){for(let t=null;t=this.hiddenInputs.pop();)t.remove();if(0===this.values.length)this.value=null;else{const t=this.getAttribute("name");t&&(this.isMultiMode||1!==this.values.length?this.inputRoot.parentElement&&this.values.forEach((e=>{const i=document.createElement("input");i.setAttribute("type","hidden"),i.setAttribute("name",t),i.setAttribute("value",this.serializeValue(e)),this.hiddenInputs.push(i),this.inputRoot.parentElement.appendChild(i)})):(this.selection=this.values[0],this.value=this.serializeValue(this.values[0]),this.internals&&this.internals.setFormValue(this.value)))}}setSelectedOption(t){this.isMultiMode?this.addValue(t):this.setValues([t]),this.isMultiMode&&this.searchable||(this.blur(),this.focused=!1),this.visibleOptions=[],this.attemptedOpen=!1,this.input="",this.next=null,this.complete=!0,this.selectedIndex=-1}isPastFetchThreshold(){return(this.visibleOptions.length>0||this.next)&&!this.complete&&(this.cursorIndex||0)>this.visibleOptions.length-20}handleOptionSelection(t){if(this.isMultiMode&&this.maxItems>0&&this.values.length>=this.maxItems)return void(this.infoText=this.maxItemsText);this.infoText="";const e=t.detail.selected;e.arbitrary&&this.allowCreate&&this.endpoint?(this.resolving=!0,le(this.endpoint,e).then((t=>{t.status>=200&&t.status<300?(this.setSelectedOption(t.json),this.lruCache=Cn(20,6e4),this.errors=[]):(this.setSelectedOption(e),setTimeout((()=>{this.errors=['There was an error creating "'+this.getNameInternal(e)+'"']}),0),this.blur()),this.resolving=!1}))):(this.setSelectedOption(e),this.errors=[])}handleExpressionSelection(t){const e=t.detail.selected,i=t.detail.tabbed,n=this.shadowRoot.querySelector(".searchbox");Cc(this.query,n,e),this.query="",this.completionOptions=[],i?this.fetchExpressions():-1===this.input.indexOf("(")&&this.addInputAsValue()}getOptionsDefault(t){return t.json.results}isCompleteDefault(t,e){const i=e.json;return!i.more&&!i.next}handleRemoveSelection(t){if(this.removeValue(t),this.visibleOptions=[],this.errors=[],this.allowCreate){const t=this.values.find((t=>t.arbitrary));t&&setTimeout((()=>{this.errors=['There was an error creating "'+this.getNameInternal(t)+'"']}),0)}}createArbitraryOptionDefault(t,e){return this.emails&&t&&this.isValidEmail(t)||this.tags&&t?{name:t,value:t}:null}isValidEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}get isMultiMode(){return this.multi||this.emails}open(){this.shadowRoot.querySelector(".select-container").click()}isOpen(){return this.visibleOptions.length>0||this.attemptedOpen&&this.focused}setOptions(t){this.staticOptions=t}setVisibleOptions(t){if(t=t.filter((t=>!!this.getNameInternal(t)&&(!this.shouldExclude||!this.shouldExclude(t)))),this.input){if(this.searchable&&!this.queryParam){const e=this.input.trim().toLowerCase();t=t.filter((t=>this.isMatch(t,e)))}const e=this.createArbitraryOption(this.input,t);if(e){e.arbitrary=!0;t.find((t=>this.getValue(t)===this.getValue(e)))||(t.length>0&&t[0].arbitrary?t[0]=e:t.unshift(e))}}this.values.length>0&&(this.isMultiMode?t=t.filter((t=>!this.values.find((e=>this.getValue(e)===this.getValue(t))))):(this.input?this.cursorIndex=0:this.cursorIndex=t.findIndex((t=>this.getValue(t)===this.getValue(this.values[0]))),this.requestUpdate("cursorIndex"))),this.isMultiMode&&this.maxItems>0&&this.values.length>=this.maxItems&&(t=[],this.infoText=this.maxItemsText),this.sortFunction&&t.sort(this.sortFunction),this.visibleOptions=t,this.fireCustomEvent(_n.ContentChanged,{options:this.visibleOptions})}fetchExpressions(){const t=document.querySelector("temba-store");if(this.expressions&&t){const t=this.shadowRoot.querySelector(".searchbox"),e=Sc(t,"session"===this.expressions);return this.query=e.query,this.completionOptions=e.options,this.visibleOptions=[],this.anchorPosition=e.anchorPosition,void this.fireCustomEvent(_n.FetchComplete)}}fetchOptions(t,e=0,i=null){if(this.completionOptions=[],!this.fetching){this.fetching=!0;const n=[...this.staticOptions],o=(t||"").trim().toLowerCase();if(this.tags&&o&&(n.find((t=>this.getValue(t)&&this.getValue(t).toLowerCase()===o))||n.splice(0,0,{name:t,value:t})),this.emails&&o&&this.isValidEmail(o)&&!n.find((t=>this.getValue(t)&&this.getValue(t).toLowerCase()===o))&&n.splice(0,0,{name:t,value:t}),this.endpoint){let s=this.endpoint;i?s=i:(t&&this.queryParam&&(s.indexOf("?")>-1?s+="&":s+="?",s+=this.queryParam+"="+encodeURIComponent(t)),e&&(s.indexOf("?")>-1?s+="&":s+="?",s+="page="+e));const r=this.lruCache.get(s);if(this.cache&&!this.tags&&!this.emails&&r)return 0!==e||this.next?this.setVisibleOptions([...this.visibleOptions,...r.options]):(this.cursorIndex=0,this.setVisibleOptions([...n,...r.options])),this.complete=r.complete,this.next=r.next,void(this.fetching=!1);this.searchable&&!this.queryParam?oe(s).then((t=>{t=this.prepareOptions(t),!this.cache||this.tags||this.emails||(this.lruCache.set(s,{options:t,complete:!0,next:null}),this.complete=!0,this.next=null,this.setVisibleOptions([...n,...t]),this.fetching=!1)})):ee(s).then((i=>{let r=this.getOptions(i).filter((t=>this.isMatch(t,o)));r=this.prepareOptions(r),this.next=null;const a=i.json;a.next&&(this.next=a.next),0!==e||this.next?(r.length>0&&this.setVisibleOptions([...this.visibleOptions,...r]),this.complete=this.isComplete(r,i)):(this.cursorIndex=0,this.setVisibleOptions([...n,...r]),this.query=t,this.complete=this.isComplete(this.visibleOptions,i)),!this.cache||this.tags||this.emails||this.lruCache.set(s,{options:r,complete:this.complete,next:this.next}),this.fetching=!1,this.page=e})).catch((t=>{this.fetching=!1,console.error(t)}))}else this.fetching=!1,this.setVisibleOptions(n)}}handleFocus(){this.focused||0!==this.visibleOptions.length||(this.focused=!0)}handleBlur(){this.focused=!1,this.attemptedOpen=!1,this.visibleOptions.length>0&&(this.input="",this.next=null,this.complete=!0,this.visibleOptions=[],this.cursorIndex=0),this.isMultiMode&&this.maxItems>0&&this.values.length>=this.maxItems&&(this.infoText="")}handleClick(){this.selectedIndex=-1,this.requestUpdate("input")}addInputAsValue(){const t=this.shadowRoot.querySelector(".searchbox"),e={name:t.value,value:t.value,expression:!0};this.isMultiMode?this.values.find((t=>t.expression&&t.value&&e.value&&t.value.toLowerCase().trim()==e.value.toLowerCase().trim()))||this.addValue(e):this.setValues([e]),this.input="",this.isMultiMode||this.blur()}handleKeyDown(t){if("Enter"===t.key&&this.expressions&&0===this.completionOptions.length&&this.input.indexOf("@")>-1)this.addInputAsValue();else if("Enter"===t.key&&this.emails&&this.input&&this.isValidEmail(this.input.trim())&&0===this.visibleOptions.length){t.preventDefault();const e={name:this.input.trim(),value:this.input.trim()};this.setSelectedOption(e)}else{if(("Enter"===t.key||"ArrowDown"===t.key||"n"===t.key&&t.ctrlKey)&&0===this.visibleOptions.length&&0===this.completionOptions.length&&!this.input)return this.attemptedOpen=!0,void this.requestUpdate("input");if(this.isMultiMode&&"Backspace"===t.key&&!this.input){if(this.visibleOptions.length>0)return void(this.visibleOptions=[]);-1===this.selectedIndex?(this.selectedIndex=this.values.length-1,this.visibleOptions=[]):(this.popValue(),this.selectedIndex=-1)}else this.selectedIndex=-1}}getStaticOptions(){return this.staticOptions}handleInput(t){const e=t.currentTarget;this.input=e.value}handleCancel(){this.visibleOptions=[],this.attemptedOpen=!1}handleCursorChanged(t){this.cursorIndex=t.detail.index}handleContainerClick(t){if(this.disabled)return t.stopPropagation(),void t.preventDefault();if(this.focused=!0,"INPUT"!==t.target.tagName){const t=this.shadowRoot.querySelector("input");if(t)return t.click(),void t.focus();this.isOpen()?(this.visibleOptions=[],this.attemptedOpen=!1):(this.attemptedOpen=!0,this.requestUpdate("input"),this.requestUpdate())}}getEventHandlers(){return[{event:_n.Canceled,method:this.handleCancel},{event:_n.CursorChanged,method:this.handleCursorChanged},{event:"blur",method:this.handleBlur},{event:"focus",method:this.handleFocus}]}handleArrowClick(t){this.disabled||this.isOpen()&&(t.preventDefault(),t.stopPropagation(),this.blur())}renderOptionDefault(t){if(!t)return null;const e=t.icon;return H`
|
|
1247
1247
|
<div
|
|
1248
1248
|
class="option-name"
|
|
1249
1249
|
style="flex: 1 1 auto;
|
|
@@ -8165,7 +8165,7 @@ const{I:bd}=at,xd=()=>document.createComment(""),_d=(t,e,i)=>{const n=t._$AA.par
|
|
|
8165
8165
|
</div>
|
|
8166
8166
|
</div>`,form:{addresses:{type:"select",label:"Recipients",options:[],multi:!0,searchable:!0,placeholder:"Search for contacts...",emails:!0},subject:{type:"text",label:"Subject",required:!0,placeholder:"Enter email subject",maxLength:255},body:{type:"textarea",required:!0,evaluated:!0,minHeight:175}},fromFormData:t=>({uuid:t.uuid,type:"send_email",addresses:t.addresses.map((t=>t.value)),subject:t.subject,body:t.body}),validate:t=>{const e={};return t.addresses&&0!==t.addresses.length||(e.addresses="At least one recipient email address is required"),{valid:0===Object.keys(e).length,errors:e}}},Ob={name:"Transfer Airtime",color:fb,render:(t,e)=>H`<div>Transfer Airtime</div>`},$b={name:"Update Name",color:gb,render:(t,e)=>H`<div>Set to <b>${e.name}</b></div>`,form:{name:{type:"text",label:"Name",placeholder:"Enter contact name...",required:!0,evaluated:!0,helpText:"The new name for the contact. You can use expressions like @contact.name"}},validate:t=>{const e={};return t.name&&""!==t.name.trim()||(e.name="Name is required"),{valid:0===Object.keys(e).length,errors:e}},sanitize:t=>{t.name&&"string"==typeof t.name&&(t.name=t.name.trim())}},Lb={name:"Remove from Group",color:gb,render:(t,e)=>e.all_groups?H`<div>Remove from all groups</div>`:H`<div>${kb(e.groups,"group")}</div>`,toFormData:t=>({uuid:t.uuid,all_groups:t.all_groups||!1,groups:t.groups||[]}),form:{groups:{type:"select",label:"Groups",helpText:"Select the groups to remove the contact from",options:[],multi:!0,searchable:!0,endpoint:"/api/v2/groups.json",valueKey:"uuid",nameKey:"name",placeholder:"Search for groups...",conditions:{visible:t=>!t.all_groups}},all_groups:{type:"checkbox",label:"Remove from All Groups",helpText:"Check this to remove the contact from all groups instead of specific ones"}},validate:t=>{const e={};return t.all_groups||t.groups&&0!==t.groups.length||(e.groups='At least one group must be selected or check "Remove from All Groups"'),{valid:0===Object.keys(e).length,errors:e}},fromFormData:t=>({uuid:t.uuid,type:"remove_contact_groups",groups:t.all_groups?[]:t.groups||[],all_groups:t.all_groups||!1})},zb={type:"split_by_random",name:"Split by Random",color:bb,form:{categories:{type:"array",label:"Buckets",helpText:"Define the buckets to randomly split contacts into",required:!0,itemLabel:"Bucket",minItems:2,maxItems:10,isEmptyItem:t=>!t.name||""===t.name.trim(),itemConfig:{name:{type:"text",placeholder:"Bucket name",required:!0}}}},layout:["categories"],validate:t=>{const e={};if(t.categories&&Array.isArray(t.categories)){const i=t.categories.filter((t=>(null==t?void 0:t.name)&&""!==t.name.trim()));i.length<2&&(e.categories="At least 2 buckets are required for random split");const n=[],o=new Map;if(i.forEach((t=>{const e=t.name.trim().toLowerCase();o.has(e)||o.set(e,[]),o.get(e).push(t.name.trim())})),o.forEach((t=>{t.length>1&&n.push(...t)})),n.length>0){const t=[...new Set(n)];e.categories=`Duplicate bucket names found: ${t.join(", ")}`}}return{valid:0===Object.keys(e).length,errors:e}},toFormData:t=>{var e,i;const n=(null===(i=null===(e=t.router)||void 0===e?void 0:e.categories)||void 0===i?void 0:i.map((t=>({name:t.name}))))||[];return{uuid:t.uuid,categories:n}},fromFormData:(t,e)=>{var i;const n=(t.categories||[]).filter((t=>{var e;return null===(e=null==t?void 0:t.name)||void 0===e?void 0:e.trim()})).map((t=>t.name.trim())),o=(null===(i=e.router)||void 0===i?void 0:i.categories)||[],s=e.exits||[],{router:r,exits:a}=((t,e=[],i=[])=>{const n=[],o=[];return t.forEach((t=>{const s=e.find((e=>e.name===t)),r=s?i.find((t=>t.uuid===s.exit_uuid)):null,a=(null==r?void 0:r.uuid)||Yt(),l=(null==s?void 0:s.uuid)||Yt();n.push({uuid:l,name:t,exit_uuid:a}),o.push({uuid:a,destination_uuid:(null==r?void 0:r.destination_uuid)||null})})),{router:{type:"random",categories:n},exits:o}})(n,o,s);return{uuid:e.uuid,actions:e.actions||[],router:r,exits:a}},router:{type:"random"}},Rb='@(json(object(\n "contact", object(\n "uuid", contact.uuid, \n "name", contact.name, \n "urn", contact.urn\n ),\n "flow", object(\n "uuid", run.flow.uuid, \n "name", run.flow.name\n ),\n "results", foreach_value(results, extract_object, "value", "category")\n)))',Nb={type:"split_by_llm_categorize",name:"Split by AI",color:vb,form:{llm:{type:"select",label:"LLM",helpText:"Select the LLM to use for categorization",required:!0,endpoint:"/test-assets/select/llms.json",valueKey:"uuid",nameKey:"name",placeholder:"Select an LLM..."},input:{type:"text",label:"Input",helpText:"The input to categorize (usually @input)",required:!0,evaluated:!0,placeholder:"@input"},categories:{type:"array",label:"Categories",helpText:"Define the categories for classification",required:!0,itemLabel:"Category",minItems:1,maxItems:10,isEmptyItem:t=>!t.name||""===t.name.trim(),itemConfig:{name:{type:"text",placeholder:"Category name",required:!0}}}},layout:["llm","input","categories"],validate:t=>{const e={};if(t.categories&&Array.isArray(t.categories)){const i=t.categories.filter((t=>(null==t?void 0:t.name)&&""!==t.name.trim())),n=[],o=new Map;if(i.forEach((t=>{const e=t.name.trim().toLowerCase();o.has(e)||o.set(e,[]),o.get(e).push(t.name.trim())})),o.forEach((t=>{t.length>1&&n.push(...t)})),n.length>0){const t=[...new Set(n)];e.categories=`Duplicate category names found: ${t.join(", ")}`}}return{valid:0===Object.keys(e).length,errors:e}},render:t=>{var e;const i=null===(e=t.actions)||void 0===e?void 0:e.find((t=>"call_llm"===t.type));return H`
|
|
8167
8167
|
<div class="body">Categorize with ${i.llm.name}</div>
|
|
8168
|
-
`},toFormData:t=>{var e,i,n;const o=null===(e=t.actions)||void 0===e?void 0:e.find((t=>"call_llm"===t.type)),s=(null===(n=null===(i=t.router)||void 0===i?void 0:i.categories)||void 0===n?void 0:n.filter((t=>"Other"!==t.name&&"Failure"!==t.name)).map((t=>({name:t.name}))))||[];return{uuid:t.uuid,llm:(null==o?void 0:o.llm)?[{value:o.llm.uuid,name:o.llm.name}]:[],input:(null==o?void 0:o.input)||"@input",categories:s}},fromFormData:(t,e)=>{var i,n,o;const s=Array.isArray(t.llm)&&t.llm.length>0?t.llm[0]:null,r=(t.categories||[]).filter((t=>{var e;return null===(e=null==t?void 0:t.name)||void 0===e?void 0:e.trim()})).map((t=>t.name.trim())),a=null===(i=e.actions)||void 0===i?void 0:i.find((t=>"call_llm"===t.type)),l={type:"call_llm",uuid:(null==a?void 0:a.uuid)||Yt(),llm:s?{uuid:s.value,name:s.name}:{uuid:"",name:""},instructions:'@(prompt("categorize", slice(node.categories, 0, -2)))',input:t.input||"@input",output_local:"_llm_output"},c=(null===(n=e.router)||void 0===n?void 0:n.categories)||[],h=e.exits||[],d=(null===(o=e.router)||void 0===o?void 0:o.cases)||[],{router:u,exits:p}=((t,e,i,n=[],o=[],s=[])=>{const r=[],a=[],l=[];e.forEach((t=>{const e=we({name:t,existingCategories:n,existingExits:o,existingCases:s,caseConfig:i(t)});r.push(e.category),a.push(e.exit),e.case&&l.push(e.case)}));const c=we({name:"Other",existingCategories:n,existingExits:o});r.push(c.category),a.push(c.exit);const h=we({name:"Failure",existingCategories:n,existingExits:o,existingCases:s,caseConfig:{type:"has_only_text",arguments:["<ERROR>"]}});return r.push(h.category),a.push(h.exit),h.case&&l.push(h.case),{router:{type:"switch",categories:r,default_category_uuid:c.category.uuid,operand:t,cases:l},exits:a}})("@locals._llm_output",r,(t=>({type:"has_only_text",arguments:[t]})),c,h,d);return{uuid:e.uuid,actions:[l],router:u,exits:p}}},jb={add_input_labels:{name:"Add Input Labels",color:yb,render:(t,e)=>H`<div>${kb(e.labels,"label")}</div>`,toFormData:t=>({labels:t.labels||[],uuid:t.uuid}),form:{labels:{type:"select",label:"Labels",helpText:"Select labels to add to the input. Type a new label name to create it.",required:!0,options:[],multi:!0,searchable:!0,endpoint:"/api/v2/labels.json",valueKey:"uuid",nameKey:"name",placeholder:"Search for labels or type to create new ones...",createArbitraryOption:(t,e)=>!e.find((e=>e.name.toLowerCase().trim()===t.toLowerCase().trim()))&&t.trim()?{name:t.trim(),arbitrary:!0}:null}},fromFormData:t=>({uuid:t.uuid,type:"add_input_labels",labels:t.labels||[]})},add_contact_urn:{name:"Add URN",color:gb,render:(t,e)=>{const i=Sb[e.scheme]||e.scheme;return H`<div
|
|
8168
|
+
`},toFormData:t=>{var e,i,n;const o=null===(e=t.actions)||void 0===e?void 0:e.find((t=>"call_llm"===t.type)),s=(null===(n=null===(i=t.router)||void 0===i?void 0:i.categories)||void 0===n?void 0:n.filter((t=>"Other"!==t.name&&"Failure"!==t.name)).map((t=>({name:t.name}))))||[];return{uuid:t.uuid,llm:(null==o?void 0:o.llm)?[{value:o.llm.uuid,name:o.llm.name}]:[],input:(null==o?void 0:o.input)||"@input",categories:s}},fromFormData:(t,e)=>{var i,n,o;const s=Array.isArray(t.llm)&&t.llm.length>0?t.llm[0]:null,r=(t.categories||[]).filter((t=>{var e;return null===(e=null==t?void 0:t.name)||void 0===e?void 0:e.trim()})).map((t=>t.name.trim())),a=null===(i=e.actions)||void 0===i?void 0:i.find((t=>"call_llm"===t.type)),l={type:"call_llm",uuid:(null==a?void 0:a.uuid)||Yt(),llm:s?{uuid:s.value,name:s.name}:{uuid:"",name:""},instructions:'@(prompt("categorize", slice(node.categories, 0, -2)))',input:t.input||"@input",output_local:"_llm_output"},c=(null===(n=e.router)||void 0===n?void 0:n.categories)||[],h=e.exits||[],d=(null===(o=e.router)||void 0===o?void 0:o.cases)||[],{router:u,exits:p}=((t,e,i,n=[],o=[],s=[])=>{const r=[],a=[],l=[];e.forEach((t=>{const e=we({name:t,existingCategories:n,existingExits:o,existingCases:s,caseConfig:i(t)});r.push(e.category),a.push(e.exit),e.case&&l.push(e.case)}));const c=we({name:"Other",existingCategories:n,existingExits:o});r.push(c.category),a.push(c.exit);const h=we({name:"Failure",existingCategories:n,existingExits:o,existingCases:s,caseConfig:{type:"has_only_text",arguments:["<ERROR>"]}});return r.push(h.category),a.push(h.exit),h.case&&l.push(h.case),{router:{type:"switch",categories:r,default_category_uuid:c.category.uuid,operand:t,cases:l},exits:a}})("@locals._llm_output",r,(t=>({type:"has_only_text",arguments:[t]})),c,h,d);return{uuid:e.uuid,actions:[l],router:u,exits:p}}},jb={add_input_labels:{name:"Add Input Labels",color:yb,render:(t,e)=>H`<div>${kb(e.labels,"label")}</div>`,toFormData:t=>({labels:t.labels||[],uuid:t.uuid}),form:{labels:{type:"select",label:"Labels",helpText:"Select labels to add to the input. Type a new label name to create it.",required:!0,options:[],multi:!0,searchable:!0,endpoint:"/api/v2/labels.json",valueKey:"uuid",nameKey:"name",placeholder:"Search for labels or type to create new ones...",allowCreate:!0,createArbitraryOption:(t,e)=>!e.find((e=>e.name.toLowerCase().trim()===t.toLowerCase().trim()))&&t.trim()?{name:t.trim(),arbitrary:!0}:null}},fromFormData:t=>({uuid:t.uuid,type:"add_input_labels",labels:t.labels||[]})},add_contact_urn:{name:"Add URN",color:gb,render:(t,e)=>{const i=Sb[e.scheme]||e.scheme;return H`<div
|
|
8169
8169
|
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
|
|
8170
8170
|
>
|
|
8171
8171
|
Add ${i} <b>${e.path}</b>
|
|
@@ -8185,7 +8185,7 @@ const{I:bd}=at,xd=()=>document.createComment(""),_d=(t,e,i)=>{const n=t._$AA.par
|
|
|
8185
8185
|
</div>
|
|
8186
8186
|
${kb(e.contacts,"contact")}
|
|
8187
8187
|
</div>`:null}
|
|
8188
|
-
</div>`}},set_run_result:Pb,send_msg:Db,send_email:Ib,start_session:{name:"Start Session",color:xb,render:(t,e)=>H`<div>Start Session</div>`},call_classifier:{name:"Call Classifier",color:vb,render:(t,e)=>H`<div>Call Classifier</div>`},call_resthook:{name:"Call Resthook",color:vb,render:(t,e)=>H`<div>Call Resthook</div>`},transfer_airtime:Ob,set_contact_name:$b,add_contact_groups:{name:"Add to Group",color:gb,render:(t,e)=>H`<div>${kb(e.groups,"group")}</div>`,toFormData:t=>({groups:t.groups||[],uuid:t.uuid}),form:{groups:{type:"select",label:"Groups",helpText:"Select the groups to add the contact to",required:!0,options:[],multi:!0,searchable:!0,endpoint:"/api/v2/groups.json",valueKey:"uuid",nameKey:"name",placeholder:"Search for groups..."}},fromFormData:t=>({uuid:t.uuid,type:"add_contact_groups",groups:t.groups||[]})},remove_contact_groups:Lb,request_optin:{name:"Request Opt-in",color:fb,render:(t,e)=>H`<div>Request Opt-in</div>`},say_msg:{name:"Say Message",color:fb,render:(t,e)=>H`<div>Say Message</div>`},play_audio:{name:"Play Audio",color:fb,render:(t,e)=>H`<div>Play Audio</div>`}},Bb={execute_actions:{type:"execute_actions"},split_by_airtime:{type:"split_by_airtime",name:"Split by Airtime Transfer",color:fb,action:Ob},split_by_contact_field:{type:"split_by_contact_field",name:"Split by <Contact Field Name>",color:bb},split_by_expression:{type:"split_by_expression",name:"Split by Expression",color:bb},split_by_groups:{type:"split_by_groups",name:"Split by Group",color:bb},split_by_llm:{type:"split_by_llm",name:"Call AI",color:vb,form:{llm:{type:"select",label:"LLM",required:!0,options:[],endpoint:"/test-assets/select/llms.json",searchable:!0,valueKey:"uuid",nameKey:"name",placeholder:"Select an LLM..."},input:{type:"text",label:"Input",helpText:"The input the AI will process",required:!0,evaluated:!0,placeholder:"@input"},instructions:{type:"textarea",label:"Instructions",helpText:"Tell the AI what to do with the input. The result can be referenced as **`@locals._llm_output`**",required:!0,evaluated:!0,placeholder:"Enter instructions for the AI model...",minHeight:130}},layout:["llm","input","instructions"],render:t=>{var e;const i=null===(e=t.actions)||void 0===e?void 0:e.find((t=>"call_llm"===t.type));return H`
|
|
8188
|
+
</div>`}},set_run_result:Pb,send_msg:Db,send_email:Ib,start_session:{name:"Start Session",color:xb,render:(t,e)=>H`<div>Start Session</div>`},call_classifier:{name:"Call Classifier",color:vb,render:(t,e)=>H`<div>Call Classifier</div>`},call_resthook:{name:"Call Resthook",color:vb,render:(t,e)=>H`<div>Call Resthook</div>`},transfer_airtime:Ob,set_contact_name:$b,add_contact_groups:{name:"Add to Group",color:gb,render:(t,e)=>H`<div>${kb(e.groups,"group")}</div>`,toFormData:t=>({groups:t.groups||[],uuid:t.uuid}),form:{groups:{type:"select",label:"Groups",helpText:"Select the groups to add the contact to",required:!0,options:[],multi:!0,searchable:!0,endpoint:"/api/v2/groups.json",valueKey:"uuid",nameKey:"name",placeholder:"Search for groups...",allowCreate:!0,createArbitraryOption:(t,e)=>!e.find((e=>e.name.toLowerCase().trim()===t.toLowerCase().trim()))&&t.trim()?{name:t.trim(),arbitrary:!0}:null}},fromFormData:t=>({uuid:t.uuid,type:"add_contact_groups",groups:t.groups||[]})},remove_contact_groups:Lb,request_optin:{name:"Request Opt-in",color:fb,render:(t,e)=>H`<div>Request Opt-in</div>`},say_msg:{name:"Say Message",color:fb,render:(t,e)=>H`<div>Say Message</div>`},play_audio:{name:"Play Audio",color:fb,render:(t,e)=>H`<div>Play Audio</div>`}},Bb={execute_actions:{type:"execute_actions"},split_by_airtime:{type:"split_by_airtime",name:"Split by Airtime Transfer",color:fb,action:Ob},split_by_contact_field:{type:"split_by_contact_field",name:"Split by <Contact Field Name>",color:bb},split_by_expression:{type:"split_by_expression",name:"Split by Expression",color:bb},split_by_groups:{type:"split_by_groups",name:"Split by Group",color:bb},split_by_llm:{type:"split_by_llm",name:"Call AI",color:vb,form:{llm:{type:"select",label:"LLM",required:!0,options:[],endpoint:"/test-assets/select/llms.json",searchable:!0,valueKey:"uuid",nameKey:"name",placeholder:"Select an LLM..."},input:{type:"text",label:"Input",helpText:"The input the AI will process",required:!0,evaluated:!0,placeholder:"@input"},instructions:{type:"textarea",label:"Instructions",helpText:"Tell the AI what to do with the input. The result can be referenced as **`@locals._llm_output`**",required:!0,evaluated:!0,placeholder:"Enter instructions for the AI model...",minHeight:130}},layout:["llm","input","instructions"],render:t=>{var e;const i=null===(e=t.actions)||void 0===e?void 0:e.find((t=>"call_llm"===t.type));return H`
|
|
8189
8189
|
<div
|
|
8190
8190
|
class="body"
|
|
8191
8191
|
style="word-wrap: break-word; overflow-wrap: break-word; hyphens: auto; max-width: 180px; max-height: 90px; margin-bottom:10px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;"
|