@nyaruka/temba-components 0.173.1 → 0.174.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,8 +4,15 @@ 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.174.0](https://github.com/nyaruka/temba-components/compare/v0.173.1...v0.174.0)
8
+
9
+ - Don't navigate the current page on meta/ctrl row click [`#1111`](https://github.com/nyaruka/temba-components/pull/1111)
10
+ - Don't fire RowClick when meta/ctrl-click opens a row in a new tab [`507d4d7`](https://github.com/nyaruka/temba-components/commit/507d4d7fd5a48a7721452dd0c6910dd78e883de0)
11
+
7
12
  #### [v0.173.1](https://github.com/nyaruka/temba-components/compare/v0.173.0...v0.173.1)
8
13
 
14
+ > 4 August 2026
15
+
9
16
  - Search the full contact history even when the chat is viewing a ticket [`#1109`](https://github.com/nyaruka/temba-components/pull/1109)
10
17
 
11
18
  #### [v0.173.0](https://github.com/nyaruka/temba-components/compare/v0.172.0...v0.173.0)
@@ -11537,7 +11537,7 @@ const{I:Uu}=lt,qu=t=>t,Wu=()=>document.createComment(""),ju=(t,e,i)=>{const o=t.
11537
11537
  background: var(--danger-bg);
11538
11538
  color: var(--danger);
11539
11539
  }
11540
- `}contentMenuEndpointWithSearch(){if(!this.contentMenuEndpoint)return this.contentMenuEndpoint;try{const t=new URL(this.contentMenuEndpoint,window.location.origin);return this.search?t.searchParams.set("search",this.search):t.searchParams.delete("search"),t.pathname+t.search}catch(t){return this.contentMenuEndpoint}}get hasCheckboxes(){return this.selectable&&this.bulkActions.length>0}constructor(){super(),this.contentMenuEndpoint="",this.columns=[],this.bulkActions=[],this.valueKey="uuid",this.pageSize=50,this.searchable=!0,this.selectable=!0,this.fixedLayout=!1,this.minTableWidth="",this.fillWindow=!1,this.urlState=!1,this.urlParamPrefix="",this.historyStateKey="",this.columnWidthSettings={},this.settingsEndpoint="",this.saveDelay=500,this.searchPlaceholder="Search",this.listTitle="",this.subtitle="",this.emptyMessage="Nothing to show",this.refreshKey="",this.actionEndpoint="",this.items=[],this.total=0,this.hasCount=!1,this.page=1,this.cursorMode=!1,this.nextCursor="",this.prevCursor="",this.currentUrl="",this.restoreUrl="",this.sort="",this.search="",this.loading=!1,this.searching=!1,this.searchError="",this.selectedIds=new Set,this.searchOpen=!1,this.searchDraft="",this.labelsByActionKey={},this.pendingLabel=null,this.bulkCollapsed=!1,this.bulkCollapseFrame=0,this.pending=null,this.previousBodyUserSelect="",this.previousBodyUserSelectDrag="",this.draggingColumnKey="",this.columnDropSlot=-1,this.columnWidths={},this.columnWidthSaveTimeout=null,this.suppressHeaderClick=!1,this.headerClickSuppressionTimeout=null,this.pinIndexByColumn=new Map,this.rightPinIndexByColumn=new Map,this.checkPinIndex=-1,this.lastPinIndex=-1,this.firstRightPinIndex=-1,this.spacerAfterIndex=-1,this.reservesIcon=!1,this.handleColumnResizeMove=t=>{if(!this.columnResize)return;t.preventDefault();const e=this.columnResize,i=e.startWidth+t.clientX-e.startX;e.nativeFloor&&(i<=e.minWidth||e.minWidth>=om.MAX_COLUMN_WIDTH)?this.restoreColumnWidth(e.key,e.initialSavedWidth):this.setColumnWidth(e.key,i,e.minWidth),e.changed=this.columnWidths[e.key]!==e.initialSavedWidth},this.stopColumnResize=t=>{if(!this.columnResize)return;const{changed:e,handle:i}=this.columnResize;i.classList.remove("resizing"),this.columnResize=void 0,document.body.style.userSelect=this.previousBodyUserSelect,this.toggleAttribute("column-resizing",!1),window.removeEventListener("pointermove",this.handleColumnResizeMove),window.removeEventListener("pointerup",this.stopColumnResize),window.removeEventListener("pointercancel",this.stopColumnResize),"pointerup"===(null==t?void 0:t.type)&&(this.suppressHeaderClick=!0,clearTimeout(this.headerClickSuppressionTimeout),this.headerClickSuppressionTimeout=setTimeout(()=>{this.suppressHeaderClick=!1,this.headerClickSuppressionTimeout=null},0)),e&&this.scheduleColumnWidthSave()},this.handleColumnDragMove=t=>{const e=this.columnDrag;if(e&&t.pointerId===e.pointerId){if(!e.started){if(Math.abs(t.clientX-e.startX)<om.DRAG_DEAD_ZONE)return;e.started=!0;try{e.header.setPointerCapture(e.pointerId)}catch(t){}e.ghost=this.createColumnDragGhost(e.header),this.draggingColumnKey=e.key,this.previousBodyUserSelectDrag=document.body.style.userSelect,document.body.style.userSelect="none",this.toggleAttribute("column-dragging",!0)}t.preventDefault(),e.ghost&&(e.ghost.style.left=t.clientX-e.grabOffsetX+"px"),this.columnDropSlot=this.computeColumnDropSlot(t.clientX)}},this.stopColumnDrag=t=>{const e=this.columnDrag;if(!e)return;if(t instanceof PointerEvent&&t.pointerId!==e.pointerId)return;const i=this.columnDropSlot;if(this.teardownColumnDrag(),!e.started)return;"pointerup"===(null==t?void 0:t.type)&&(this.suppressHeaderClick=!0,clearTimeout(this.headerClickSuppressionTimeout),this.headerClickSuppressionTimeout=setTimeout(()=>{this.suppressHeaderClick=!1,this.headerClickSuppressionTimeout=null},0));const o=this.columns.findIndex(t=>t.key===e.key);if(-1===o||i<0)return;const s=i>o?i-1:i;if(s===o)return;const n=[...this.columns],[r]=n.splice(o,1);n.splice(s,0,r),this.columns=n,this.fireCustomEvent(jo.ColumnOrderChanged,{keys:n.map(t=>t.key),from:o,to:s}),this.onColumnOrderChanged(n)},this.cancelColumnDrag=t=>{const e=this.columnDrag;e&&(t instanceof PointerEvent&&t.pointerId!==e.pointerId||this.teardownColumnDrag())}}prepareItems(t){return t}willUpdate(t){var e;if(super.willUpdate(t),t.has("columnWidthSettings")||t.has("historyStateKey")||t.has("columns")){const i=null===(e=this.columnWidthSettings)||void 0===e?void 0:e[this.historyStateKey],o={};i&&"object"==typeof i&&Object.entries(i).forEach(([t,e])=>{if("number"==typeof e&&Number.isFinite(e)){const i=this.columns.find(e=>e.key===t);o[t]=this.clampColumnWidth(e,i?this.minimumColumnWidth(i):om.MIN_COLUMN_WIDTH)}});const s=t.has("columnWidthSettings")||t.has("historyStateKey")?{}:this.columnWidths;this.columnWidths={...o,...s}}}connectedCallback(){super.connectedCallback(),this.urlState?(this.readUrlState(),this.popstateHandler=()=>{this.readUrlState(),this.fetchPage()},window.addEventListener("popstate",this.popstateHandler)):this.historyStateKey&&(this.readHistoryState(),this.popstateHandler=()=>{this.readHistoryState();const t=this.restoreUrl;this.restoreUrl="",this.fetchPage(t||void 0)},window.addEventListener("popstate",this.popstateHandler)),this.resizeHandler=()=>{this.syncScrollAffordance(),this.updateBulkCollapse()},window.addEventListener("resize",this.resizeHandler),document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.measurePinOffsets(),this.syncScrollAffordance()})}disconnectedCallback(){if(this.popstateHandler&&window.removeEventListener("popstate",this.popstateHandler),this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.stopColumnResize(),this.cancelColumnDrag(),this.columnWidthSaveTimeout&&(clearTimeout(this.columnWidthSaveTimeout),this.columnWidthSaveTimeout=null,this.saveColumnWidths()),this.headerClickSuppressionTimeout&&(clearTimeout(this.headerClickSuppressionTimeout),this.headerClickSuppressionTimeout=null),this.bulkCollapseFrame&&(cancelAnimationFrame(this.bulkCollapseFrame),this.bulkCollapseFrame=0),this.pending){const t=this.pending;this.pending=null,t.abort()}super.disconnectedCallback()}updated(t){if(super.updated(t),(t.has("endpoint")||t.has("refreshKey"))&&this.endpoint){const t=this.restoreUrl;this.restoreUrl="",this.fetchPage(t||void 0)}this.measurePinOffsets(),this.syncScrollAffordance(),this.updateBulkCollapse()}updateBulkCollapse(){this.measureBulkCollapse(),this.bulkCollapseFrame&&cancelAnimationFrame(this.bulkCollapseFrame),this.bulkCollapseFrame=requestAnimationFrame(()=>{this.bulkCollapseFrame=0,this.measureBulkCollapse()})}measureBulkCollapse(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".bulk-bar");if(!e)return;e.classList.add("measuring"),e.classList.remove("collapsed");const i=e.scrollWidth>e.clientWidth+1;e.classList.toggle("collapsed",this.bulkCollapsed),e.offsetWidth,e.classList.remove("measuring"),i!==this.bulkCollapsed&&(this.bulkCollapsed=i)}readUrlState(){const t=new URLSearchParams(window.location.search),e=t=>this.urlParamPrefix?`${this.urlParamPrefix}_${t}`:t,i=this.search;this.search=t.get(e("search"))||"",this.sort=t.get(e("sort"))||"";const o=parseInt(t.get(e("page"))||"1",10);this.page=isNaN(o)||o<1?1:o,this.search?(this.searchOpen=!0,this.searchDraft=this.search):i&&(this.searchOpen=!1,this.searchDraft="")}writeUrlState(t=!1){if(this.bubbleHistoryState(t),!this.urlState)return;const e=this.buildBrowserUrl();t?window.history.replaceState({},"",e):window.history.pushState({},"",e)}buildBrowserUrl(){const t=new URLSearchParams(window.location.search),e=t=>this.urlParamPrefix?`${this.urlParamPrefix}_${t}`:t,i=(e,i)=>{i?t.set(e,i):t.delete(e)};i(e("search"),this.search),i(e("sort"),this.sort),i(e("page"),this.page>1?String(this.page):"");const o=t.toString();return window.location.pathname+(o?"?"+o:"")}readHistoryState(){const t=this.historyStateKey;if(!t)return;const e=window.history.state||{};if(!(t in e))return this.restoreUrl="",void this.readUrlState();const i=e[t]||{},o=this.search;this.search="string"==typeof i.search?i.search:"",this.sort="string"==typeof i.sort?i.sort:"";const s=parseInt(i.page,10);this.page=isNaN(s)||s<1?1:s,this.restoreUrl="string"==typeof i.url?i.url:"",this.search?(this.searchOpen=!0,this.searchDraft=this.search):o&&(this.searchOpen=!1,this.searchDraft="")}bubbleHistoryState(t){if(!this.historyStateKey)return;const e={page:this.page,sort:this.sort,search:this.search};this.cursorMode&&this.currentUrl&&(e.url=this.currentUrl),this.fireCustomEvent(jo.HistoryChange,{key:this.historyStateKey,state:e,replace:t,url:this.buildBrowserUrl()})}buildRequestUrl(){const t=new URL(this.endpoint,window.location.origin);return this.search&&t.searchParams.set("search",this.search),this.sort&&t.searchParams.set("sort",this.sort),this.page>1&&t.searchParams.set("page",String(this.page)),50!==this.pageSize&&t.searchParams.set("page_size",String(this.pageSize)),t.pathname+t.search}detectCursorMode(t){const e=t=>{if(!t)return!1;try{return new URL(t,window.location.origin).searchParams.has("cursor")}catch(t){return!1}};return!(!e(t.next)&&!e(t.previous))||null==t.count}toRequestUrl(t){try{const e=new URL(t,window.location.origin);return e.origin!==window.location.origin?"":e.pathname+e.search}catch(t){return""}}async fetchPage(t){var e;if(!this.endpoint)return;this.pending&&this.pending.abort();const i=new AbortController;this.pending=i,this.loading=!0,this.searchError="";const o=this.searching,s=t||this.buildRequestUrl();this.currentUrl=s;try{const t=(await fe(s,i)).json||{};this.searchError="string"==typeof t.error?t.error:"",this.items=this.prepareItems(t.results||[]),this.nextCursor=t.next?this.toRequestUrl(t.next):"",this.prevCursor=t.previous?this.toRequestUrl(t.previous):"",this.cursorMode=this.detectCursorMode(t),this.hasCount=null!=t.count,this.total=null!==(e=t.count)&&void 0!==e?e:this.items.length,this.cursorMode&&!this.prevCursor&&1!==this.page&&(this.page=1,this.writeUrlState(!0));const n=new Set(this.items.map(t=>this.rowId(t))),r=new Set;this.selectedIds.forEach(t=>{n.has(t)&&r.add(t)}),this.selectedIds=r,o&&"string"==typeof t.query&&(this.search=t.query,this.searchDraft=t.query,this.writeUrlState(!0))}catch(t){"AbortError"!==(null==t?void 0:t.name)&&console.error("ContentList fetch failed",t)}finally{this.pending===i&&(this.pending=null,this.loading=!1,this.searching=!1,o&&this.searchOpen&&this.updateComplete.then(()=>this.focusSearchEnd()),this.fireCustomEvent(jo.FetchComplete))}}focusSearchEnd(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".searchbar input");if(!e)return;e.focus();const i=e.value.length;e.setSelectionRange(i,i)}refresh(){this.labelsByActionKey={},this.fetchPage(this.currentUrl||void 0)}rowId(t){const e=null==t?void 0:t[this.valueKey];return null!=e?String(e):JSON.stringify(t)}renderCell(t,e){const i=null==t?void 0:t[e.key];return null==i?"":String(i)}getRowHref(t){return null}handleSearchInput(t){this.searchDraft=t.target.value||""}handleSearchKey(t){"Enter"===t.key?(t.preventDefault(),this.commitSearch()):"Escape"===t.key&&(t.preventDefault(),this.toggleSearch())}commitSearch(){this.search!==this.searchDraft&&(this.search=this.searchDraft,this.page=1,this.searching=!0,this.fetchPage(),this.writeUrlState())}handleSortClick(t){t.sortable&&(this.sort===t.key?this.sort="-"+t.key:this.sort==="-"+t.key?this.sort="":this.sort=t.key,this.page=1,this.fetchPage(),this.writeUrlState())}handleColumnHeaderClick(t,e){if(this.suppressHeaderClick)return t.preventDefault(),t.stopPropagation(),this.suppressHeaderClick=!1,clearTimeout(this.headerClickSuppressionTimeout),void(this.headerClickSuppressionTimeout=null);this.handleSortClick(e)}handleRowClick(t,e){if(e.composedPath().some(t=>{var e,i;return null===(i=null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains)||void 0===i?void 0:i.call(e,"check-cell")}))return;this.fireCustomEvent(jo.RowClick,{item:t});const i=this.getRowHref(t);if(i&&this.isSafeHref(i)){if(e.metaKey||e.ctrlKey)return void window.open(i,"_blank");this.fireCustomEvent(jo.Redirected,{url:i})}}isSafeHref(t){if("string"!=typeof t||0===t.length)return!1;if(t.startsWith("//"))return!1;if(t.startsWith("/"))return!0;try{return new URL(t,window.location.origin).origin===window.location.origin}catch(t){return!1}}handleRowToggle(t){const e=this.rowId(t),i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.selectedIds=i,this.fireCustomEvent(jo.SelectionChange,{ids:Array.from(i)})}handleSelectAll(){const t=this.items.map(t=>this.rowId(t)),e=t.length>0&&t.every(t=>this.selectedIds.has(t));this.selectedIds=e?new Set:new Set(t),this.fireCustomEvent(jo.SelectionChange,{ids:Array.from(this.selectedIds)})}async handleBulkAction(t){if(t.confirm&&!window.confirm(t.confirm))return;const e=Array.from(this.selectedIds);if(this.actionEndpoint&&!t.clientOnly){const i=new URLSearchParams;i.append("action",t.key),e.forEach(t=>i.append("objects",t));try{await _e(this.actionEndpoint,i),await this.fetchPage(this.currentUrl||void 0),this.recheckSelection(e),this.fireCustomEvent(jo.BulkAction,{action:t.key,ids:e})}catch(t){console.error("bulk action POST failed",t)}}else this.fireCustomEvent(jo.BulkAction,{action:t.key,ids:e})}handlePage(t){if(this.cursorMode){const e=t>0?this.nextCursor:this.prevCursor;return void(e&&(this.page=Math.max(1,this.page+t),this.fetchPage(e),this.writeUrlState()))}const e=Math.max(1,Math.ceil(this.total/this.pageSize)),i=Math.min(e,Math.max(1,this.page+t));i!==this.page&&(this.page=i,this.fetchPage(),this.writeUrlState())}renderTitlebar(){const t=this.subtitle||this.querySelector('[slot="subtitle"]');return G`
11540
+ `}contentMenuEndpointWithSearch(){if(!this.contentMenuEndpoint)return this.contentMenuEndpoint;try{const t=new URL(this.contentMenuEndpoint,window.location.origin);return this.search?t.searchParams.set("search",this.search):t.searchParams.delete("search"),t.pathname+t.search}catch(t){return this.contentMenuEndpoint}}get hasCheckboxes(){return this.selectable&&this.bulkActions.length>0}constructor(){super(),this.contentMenuEndpoint="",this.columns=[],this.bulkActions=[],this.valueKey="uuid",this.pageSize=50,this.searchable=!0,this.selectable=!0,this.fixedLayout=!1,this.minTableWidth="",this.fillWindow=!1,this.urlState=!1,this.urlParamPrefix="",this.historyStateKey="",this.columnWidthSettings={},this.settingsEndpoint="",this.saveDelay=500,this.searchPlaceholder="Search",this.listTitle="",this.subtitle="",this.emptyMessage="Nothing to show",this.refreshKey="",this.actionEndpoint="",this.items=[],this.total=0,this.hasCount=!1,this.page=1,this.cursorMode=!1,this.nextCursor="",this.prevCursor="",this.currentUrl="",this.restoreUrl="",this.sort="",this.search="",this.loading=!1,this.searching=!1,this.searchError="",this.selectedIds=new Set,this.searchOpen=!1,this.searchDraft="",this.labelsByActionKey={},this.pendingLabel=null,this.bulkCollapsed=!1,this.bulkCollapseFrame=0,this.pending=null,this.previousBodyUserSelect="",this.previousBodyUserSelectDrag="",this.draggingColumnKey="",this.columnDropSlot=-1,this.columnWidths={},this.columnWidthSaveTimeout=null,this.suppressHeaderClick=!1,this.headerClickSuppressionTimeout=null,this.pinIndexByColumn=new Map,this.rightPinIndexByColumn=new Map,this.checkPinIndex=-1,this.lastPinIndex=-1,this.firstRightPinIndex=-1,this.spacerAfterIndex=-1,this.reservesIcon=!1,this.handleColumnResizeMove=t=>{if(!this.columnResize)return;t.preventDefault();const e=this.columnResize,i=e.startWidth+t.clientX-e.startX;e.nativeFloor&&(i<=e.minWidth||e.minWidth>=om.MAX_COLUMN_WIDTH)?this.restoreColumnWidth(e.key,e.initialSavedWidth):this.setColumnWidth(e.key,i,e.minWidth),e.changed=this.columnWidths[e.key]!==e.initialSavedWidth},this.stopColumnResize=t=>{if(!this.columnResize)return;const{changed:e,handle:i}=this.columnResize;i.classList.remove("resizing"),this.columnResize=void 0,document.body.style.userSelect=this.previousBodyUserSelect,this.toggleAttribute("column-resizing",!1),window.removeEventListener("pointermove",this.handleColumnResizeMove),window.removeEventListener("pointerup",this.stopColumnResize),window.removeEventListener("pointercancel",this.stopColumnResize),"pointerup"===(null==t?void 0:t.type)&&(this.suppressHeaderClick=!0,clearTimeout(this.headerClickSuppressionTimeout),this.headerClickSuppressionTimeout=setTimeout(()=>{this.suppressHeaderClick=!1,this.headerClickSuppressionTimeout=null},0)),e&&this.scheduleColumnWidthSave()},this.handleColumnDragMove=t=>{const e=this.columnDrag;if(e&&t.pointerId===e.pointerId){if(!e.started){if(Math.abs(t.clientX-e.startX)<om.DRAG_DEAD_ZONE)return;e.started=!0;try{e.header.setPointerCapture(e.pointerId)}catch(t){}e.ghost=this.createColumnDragGhost(e.header),this.draggingColumnKey=e.key,this.previousBodyUserSelectDrag=document.body.style.userSelect,document.body.style.userSelect="none",this.toggleAttribute("column-dragging",!0)}t.preventDefault(),e.ghost&&(e.ghost.style.left=t.clientX-e.grabOffsetX+"px"),this.columnDropSlot=this.computeColumnDropSlot(t.clientX)}},this.stopColumnDrag=t=>{const e=this.columnDrag;if(!e)return;if(t instanceof PointerEvent&&t.pointerId!==e.pointerId)return;const i=this.columnDropSlot;if(this.teardownColumnDrag(),!e.started)return;"pointerup"===(null==t?void 0:t.type)&&(this.suppressHeaderClick=!0,clearTimeout(this.headerClickSuppressionTimeout),this.headerClickSuppressionTimeout=setTimeout(()=>{this.suppressHeaderClick=!1,this.headerClickSuppressionTimeout=null},0));const o=this.columns.findIndex(t=>t.key===e.key);if(-1===o||i<0)return;const s=i>o?i-1:i;if(s===o)return;const n=[...this.columns],[r]=n.splice(o,1);n.splice(s,0,r),this.columns=n,this.fireCustomEvent(jo.ColumnOrderChanged,{keys:n.map(t=>t.key),from:o,to:s}),this.onColumnOrderChanged(n)},this.cancelColumnDrag=t=>{const e=this.columnDrag;e&&(t instanceof PointerEvent&&t.pointerId!==e.pointerId||this.teardownColumnDrag())}}prepareItems(t){return t}willUpdate(t){var e;if(super.willUpdate(t),t.has("columnWidthSettings")||t.has("historyStateKey")||t.has("columns")){const i=null===(e=this.columnWidthSettings)||void 0===e?void 0:e[this.historyStateKey],o={};i&&"object"==typeof i&&Object.entries(i).forEach(([t,e])=>{if("number"==typeof e&&Number.isFinite(e)){const i=this.columns.find(e=>e.key===t);o[t]=this.clampColumnWidth(e,i?this.minimumColumnWidth(i):om.MIN_COLUMN_WIDTH)}});const s=t.has("columnWidthSettings")||t.has("historyStateKey")?{}:this.columnWidths;this.columnWidths={...o,...s}}}connectedCallback(){super.connectedCallback(),this.urlState?(this.readUrlState(),this.popstateHandler=()=>{this.readUrlState(),this.fetchPage()},window.addEventListener("popstate",this.popstateHandler)):this.historyStateKey&&(this.readHistoryState(),this.popstateHandler=()=>{this.readHistoryState();const t=this.restoreUrl;this.restoreUrl="",this.fetchPage(t||void 0)},window.addEventListener("popstate",this.popstateHandler)),this.resizeHandler=()=>{this.syncScrollAffordance(),this.updateBulkCollapse()},window.addEventListener("resize",this.resizeHandler),document.fonts&&document.fonts.ready&&document.fonts.ready.then(()=>{this.measurePinOffsets(),this.syncScrollAffordance()})}disconnectedCallback(){if(this.popstateHandler&&window.removeEventListener("popstate",this.popstateHandler),this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.stopColumnResize(),this.cancelColumnDrag(),this.columnWidthSaveTimeout&&(clearTimeout(this.columnWidthSaveTimeout),this.columnWidthSaveTimeout=null,this.saveColumnWidths()),this.headerClickSuppressionTimeout&&(clearTimeout(this.headerClickSuppressionTimeout),this.headerClickSuppressionTimeout=null),this.bulkCollapseFrame&&(cancelAnimationFrame(this.bulkCollapseFrame),this.bulkCollapseFrame=0),this.pending){const t=this.pending;this.pending=null,t.abort()}super.disconnectedCallback()}updated(t){if(super.updated(t),(t.has("endpoint")||t.has("refreshKey"))&&this.endpoint){const t=this.restoreUrl;this.restoreUrl="",this.fetchPage(t||void 0)}this.measurePinOffsets(),this.syncScrollAffordance(),this.updateBulkCollapse()}updateBulkCollapse(){this.measureBulkCollapse(),this.bulkCollapseFrame&&cancelAnimationFrame(this.bulkCollapseFrame),this.bulkCollapseFrame=requestAnimationFrame(()=>{this.bulkCollapseFrame=0,this.measureBulkCollapse()})}measureBulkCollapse(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".bulk-bar");if(!e)return;e.classList.add("measuring"),e.classList.remove("collapsed");const i=e.scrollWidth>e.clientWidth+1;e.classList.toggle("collapsed",this.bulkCollapsed),e.offsetWidth,e.classList.remove("measuring"),i!==this.bulkCollapsed&&(this.bulkCollapsed=i)}readUrlState(){const t=new URLSearchParams(window.location.search),e=t=>this.urlParamPrefix?`${this.urlParamPrefix}_${t}`:t,i=this.search;this.search=t.get(e("search"))||"",this.sort=t.get(e("sort"))||"";const o=parseInt(t.get(e("page"))||"1",10);this.page=isNaN(o)||o<1?1:o,this.search?(this.searchOpen=!0,this.searchDraft=this.search):i&&(this.searchOpen=!1,this.searchDraft="")}writeUrlState(t=!1){if(this.bubbleHistoryState(t),!this.urlState)return;const e=this.buildBrowserUrl();t?window.history.replaceState({},"",e):window.history.pushState({},"",e)}buildBrowserUrl(){const t=new URLSearchParams(window.location.search),e=t=>this.urlParamPrefix?`${this.urlParamPrefix}_${t}`:t,i=(e,i)=>{i?t.set(e,i):t.delete(e)};i(e("search"),this.search),i(e("sort"),this.sort),i(e("page"),this.page>1?String(this.page):"");const o=t.toString();return window.location.pathname+(o?"?"+o:"")}readHistoryState(){const t=this.historyStateKey;if(!t)return;const e=window.history.state||{};if(!(t in e))return this.restoreUrl="",void this.readUrlState();const i=e[t]||{},o=this.search;this.search="string"==typeof i.search?i.search:"",this.sort="string"==typeof i.sort?i.sort:"";const s=parseInt(i.page,10);this.page=isNaN(s)||s<1?1:s,this.restoreUrl="string"==typeof i.url?i.url:"",this.search?(this.searchOpen=!0,this.searchDraft=this.search):o&&(this.searchOpen=!1,this.searchDraft="")}bubbleHistoryState(t){if(!this.historyStateKey)return;const e={page:this.page,sort:this.sort,search:this.search};this.cursorMode&&this.currentUrl&&(e.url=this.currentUrl),this.fireCustomEvent(jo.HistoryChange,{key:this.historyStateKey,state:e,replace:t,url:this.buildBrowserUrl()})}buildRequestUrl(){const t=new URL(this.endpoint,window.location.origin);return this.search&&t.searchParams.set("search",this.search),this.sort&&t.searchParams.set("sort",this.sort),this.page>1&&t.searchParams.set("page",String(this.page)),50!==this.pageSize&&t.searchParams.set("page_size",String(this.pageSize)),t.pathname+t.search}detectCursorMode(t){const e=t=>{if(!t)return!1;try{return new URL(t,window.location.origin).searchParams.has("cursor")}catch(t){return!1}};return!(!e(t.next)&&!e(t.previous))||null==t.count}toRequestUrl(t){try{const e=new URL(t,window.location.origin);return e.origin!==window.location.origin?"":e.pathname+e.search}catch(t){return""}}async fetchPage(t){var e;if(!this.endpoint)return;this.pending&&this.pending.abort();const i=new AbortController;this.pending=i,this.loading=!0,this.searchError="";const o=this.searching,s=t||this.buildRequestUrl();this.currentUrl=s;try{const t=(await fe(s,i)).json||{};this.searchError="string"==typeof t.error?t.error:"",this.items=this.prepareItems(t.results||[]),this.nextCursor=t.next?this.toRequestUrl(t.next):"",this.prevCursor=t.previous?this.toRequestUrl(t.previous):"",this.cursorMode=this.detectCursorMode(t),this.hasCount=null!=t.count,this.total=null!==(e=t.count)&&void 0!==e?e:this.items.length,this.cursorMode&&!this.prevCursor&&1!==this.page&&(this.page=1,this.writeUrlState(!0));const n=new Set(this.items.map(t=>this.rowId(t))),r=new Set;this.selectedIds.forEach(t=>{n.has(t)&&r.add(t)}),this.selectedIds=r,o&&"string"==typeof t.query&&(this.search=t.query,this.searchDraft=t.query,this.writeUrlState(!0))}catch(t){"AbortError"!==(null==t?void 0:t.name)&&console.error("ContentList fetch failed",t)}finally{this.pending===i&&(this.pending=null,this.loading=!1,this.searching=!1,o&&this.searchOpen&&this.updateComplete.then(()=>this.focusSearchEnd()),this.fireCustomEvent(jo.FetchComplete))}}focusSearchEnd(){var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".searchbar input");if(!e)return;e.focus();const i=e.value.length;e.setSelectionRange(i,i)}refresh(){this.labelsByActionKey={},this.fetchPage(this.currentUrl||void 0)}rowId(t){const e=null==t?void 0:t[this.valueKey];return null!=e?String(e):JSON.stringify(t)}renderCell(t,e){const i=null==t?void 0:t[e.key];return null==i?"":String(i)}getRowHref(t){return null}handleSearchInput(t){this.searchDraft=t.target.value||""}handleSearchKey(t){"Enter"===t.key?(t.preventDefault(),this.commitSearch()):"Escape"===t.key&&(t.preventDefault(),this.toggleSearch())}commitSearch(){this.search!==this.searchDraft&&(this.search=this.searchDraft,this.page=1,this.searching=!0,this.fetchPage(),this.writeUrlState())}handleSortClick(t){t.sortable&&(this.sort===t.key?this.sort="-"+t.key:this.sort==="-"+t.key?this.sort="":this.sort=t.key,this.page=1,this.fetchPage(),this.writeUrlState())}handleColumnHeaderClick(t,e){if(this.suppressHeaderClick)return t.preventDefault(),t.stopPropagation(),this.suppressHeaderClick=!1,clearTimeout(this.headerClickSuppressionTimeout),void(this.headerClickSuppressionTimeout=null);this.handleSortClick(e)}handleRowClick(t,e){if(e.composedPath().some(t=>{var e,i;return null===(i=null===(e=null==t?void 0:t.classList)||void 0===e?void 0:e.contains)||void 0===i?void 0:i.call(e,"check-cell")}))return;const i=this.getRowHref(t),o=i&&this.isSafeHref(i)?i:null;o&&(e.metaKey||e.ctrlKey)?window.open(o,"_blank"):(this.fireCustomEvent(jo.RowClick,{item:t}),o&&this.fireCustomEvent(jo.Redirected,{url:o}))}isSafeHref(t){if("string"!=typeof t||0===t.length)return!1;if(t.startsWith("//"))return!1;if(t.startsWith("/"))return!0;try{return new URL(t,window.location.origin).origin===window.location.origin}catch(t){return!1}}handleRowToggle(t){const e=this.rowId(t),i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.selectedIds=i,this.fireCustomEvent(jo.SelectionChange,{ids:Array.from(i)})}handleSelectAll(){const t=this.items.map(t=>this.rowId(t)),e=t.length>0&&t.every(t=>this.selectedIds.has(t));this.selectedIds=e?new Set:new Set(t),this.fireCustomEvent(jo.SelectionChange,{ids:Array.from(this.selectedIds)})}async handleBulkAction(t){if(t.confirm&&!window.confirm(t.confirm))return;const e=Array.from(this.selectedIds);if(this.actionEndpoint&&!t.clientOnly){const i=new URLSearchParams;i.append("action",t.key),e.forEach(t=>i.append("objects",t));try{await _e(this.actionEndpoint,i),await this.fetchPage(this.currentUrl||void 0),this.recheckSelection(e),this.fireCustomEvent(jo.BulkAction,{action:t.key,ids:e})}catch(t){console.error("bulk action POST failed",t)}}else this.fireCustomEvent(jo.BulkAction,{action:t.key,ids:e})}handlePage(t){if(this.cursorMode){const e=t>0?this.nextCursor:this.prevCursor;return void(e&&(this.page=Math.max(1,this.page+t),this.fetchPage(e),this.writeUrlState()))}const e=Math.max(1,Math.ceil(this.total/this.pageSize)),i=Math.min(e,Math.max(1,this.page+t));i!==this.page&&(this.page=i,this.fetchPage(),this.writeUrlState())}renderTitlebar(){const t=this.subtitle||this.querySelector('[slot="subtitle"]');return G`
11541
11541
  <temba-page-header
11542
11542
  content-menu-endpoint=${this.contentMenuEndpointWithSearch()}
11543
11543
  >
@@ -14539,7 +14539,7 @@ background: #ccc;
14539
14539
  ${this.renderUploader()}
14540
14540
  </div>
14541
14541
  </div>
14542
- </div>`}}i([ft({type:String,attribute:!1})],Am.prototype,"endpoint",void 0),i([ft({type:Boolean})],Am.prototype,"pendingDrop",void 0),i([ft({type:Boolean})],Am.prototype,"ignoreDrops",void 0),i([ft({type:String})],Am.prototype,"icon",void 0),i([ft({type:String})],Am.prototype,"accept",void 0),i([ft({type:Number})],Am.prototype,"max",void 0),i([ft({type:Array})],Am.prototype,"attachments",void 0),i([ft({type:Boolean,attribute:!1})],Am.prototype,"uploading",void 0);let Dm="dev";try{Dm="0.173.1"}catch(t){}const Mm=Dm,zm=[{type:"has_any_word",name:"has any of the words",operands:1},{type:"has_all_words",name:"has all of the words",operands:1},{type:"has_phrase",name:"has the phrase",operands:1},{type:"has_only_phrase",name:"has only the phrase",operands:1},{type:"has_beginning",name:"starts with",operands:1},{type:"has_text",name:"has some text",operands:0,categoryName:"Has Text"},{type:"has_number",name:"has a number",operands:0,categoryName:"Has Number"},{type:"has_number_between",name:"has a number between",operands:2},{type:"has_number_lt",name:"has a number below",operands:1},{type:"has_number_lte",name:"has a number at or below",operands:1},{type:"has_number_eq",name:"has a number equal to",operands:1},{type:"has_number_gte",name:"has a number at or above",operands:1},{type:"has_number_gt",name:"has a number above",operands:1},{type:"has_date",name:"has a date",operands:0,categoryName:"Has Date"},{type:"has_date_lt",name:"has a date before",operands:1},{type:"has_date_eq",name:"has a date equal to",operands:1},{type:"has_date_gt",name:"has a date after",operands:1},{type:"has_time",name:"has a time",operands:0,categoryName:"Has Time"},{type:"has_phone",name:"has a phone number",operands:0,categoryName:"Has Phone"},{type:"has_email",name:"has an email",operands:0,categoryName:"Has Email"},{type:"has_state",name:"has state",operands:0,categoryName:"Has State",filter:"locations"},{type:"has_district",name:"has district",operands:1,categoryName:"Has District",filter:"locations"},{type:"has_ward",name:"has ward",operands:2,categoryName:"Has Ward",filter:"locations"},{type:"has_group",name:"is in the group",operands:1,visibility:"hidden"},{type:"has_category",name:"has the category",operands:0,visibility:"hidden"},{type:"has_error",name:"has an error",operands:0,categoryName:"Has Error",visibility:"hidden"},{type:"has_value",name:"is not empty",operands:0,categoryName:"Not Empty",visibility:"hidden"},{type:"has_pattern",name:"matches regex",operands:1}],Pm=t=>zm.filter(e=>"hidden"!==e.visibility&&(!e.filter||!!t&&t.includes(e.filter))),Im=new Set(["has_beginning","has_number","has_number_between","has_number_lt","has_number_lte","has_number_eq","has_number_gte","has_number_gt","has_pattern"]),Om=t=>zm.find(e=>e.type===t),Rm=t=>t.map(t=>({value:t.type,name:t.name})),Lm={type:"text",required:!1,maxLength:64,placeholder:"(optional)",helpText:"The name to use to reference this result in the flow"},Nm={type:"checkbox",label:"Require rules to be localized",helpText:"Each language must specify its own rules for this node"},Fm={type:"checkbox",label:"Require categories to be localized",helpText:t=>{var e;const i=null===(e=t.result_name)||void 0===e?void 0:e.trim();if(i){return`Only enable if you plan to use @results.${i.toLowerCase().replace(/\s+/g,"_")}.category_localized`}return"Only enable if you plan to use category_localized in your expressions for this result"},conditions:{visible:t=>!!t.result_name}},Bm={label:"Save Result",localizable:!1,items:["result_name"],collapsed:t=>!(t._isNew&&t.result_name),getValueCount:t=>!!t.result_name},Um={type:"accordion",multi:!0,sections:[Bm,{label:"Localization",localizable:!1,items:["localizeRules","localizeCategories"],collapsed:!0,getValueCount:t=>!(!t.localizeRules&&!t.localizeCategories)}]},qm={type:"accordion",multi:!0,sections:[Bm]},Wm={type:"accordion",multi:!0,sections:[Bm,{label:"Localization",localizable:!1,items:["localizeCategories"],collapsed:!0,getValueCount:t=>!!t.localizeCategories}]};function jm(t,e){var i,o;const s=(null===(i=t.router)||void 0===i?void 0:i.categories)||[],n={};s.forEach(t=>{const i=t.uuid,o=e[i];n[i]={originalName:t.name,localizedName:o&&o.name?Array.isArray(o.name)?o.name[0]||"":o.name:""}});const r=(null===(o=t.router)||void 0===o?void 0:o.cases)||[],a={};return r.forEach(t=>{var i,o;if(!(null===(i=t.arguments)||void 0===i?void 0:i.length)||!t.arguments.some(t=>t))return;const s=e[t.uuid],n=(null===(o=Om(t.type))||void 0===o?void 0:o.name)||t.type;a[t.uuid]={operatorName:n,originalArguments:[...t.arguments],localizedArguments:(null==s?void 0:s.arguments)?[...s.arguments]:t.arguments.map(()=>"")}}),{categories:n,rules:a}}function Hm(t,e){const i={};return t.categories&&Object.keys(t.categories).forEach(e=>{var o,s;const n=t.categories[e],r=(null===(o=n.localizedName)||void 0===o?void 0:o.trim())||"",a=(null===(s=n.originalName)||void 0===s?void 0:s.trim())||"";r&&r!==a&&(i[e]={name:[r]})}),t.rules&&Object.keys(t.rules).forEach(e=>{const o=t.rules[e],s=o.localizedArguments||[],n=o.originalArguments||[],r=s.some((t,e)=>(null==t?void 0:t.trim())&&t.trim()!==(n[e]||""));r&&(i[e]={arguments:s.map(t=>(null==t?void 0:t.trim())||"")})}),i}function Vm(t,e,i,o=[]){const s=[],n=[],r=[];return t.forEach(t=>{const a=ae(e,t.name),l=a?i.find(t=>t.uuid===a.exit_uuid):null,d=(null==l?void 0:l.uuid)||Xt(),c=(null==a?void 0:a.uuid)||Xt();if(s.push({uuid:c,name:t.name,exit_uuid:d}),n.push({uuid:d,destination_uuid:(null==l?void 0:l.destination_uuid)||null}),t.case){const e=t.case.arguments[0],i=o.find(t=>{var i;return(null===(i=t.arguments)||void 0===i?void 0:i[0])===e});r.push({uuid:(null==i?void 0:i.uuid)||Xt(),type:t.case.type,arguments:t.case.arguments,category_uuid:c})}}),{categories:s,exits:n,cases:r}}function Gm(t,e,i,o,s){const n=s.some(t=>re(t,"Other"))?null:ae(i,"Other"),r=n?o.find(t=>t.uuid===n.exit_uuid):null,a=(null==r?void 0:r.uuid)||Xt(),l=(null==n?void 0:n.uuid)||Xt();return t.push({uuid:l,name:"Other",exit_uuid:a}),e.push({uuid:a,destination_uuid:(null==r?void 0:r.destination_uuid)||null}),l}function Km(t){return e=>{const i={};return t(e,i),{valid:0===Object.keys(i).length,errors:i}}}function Zm(t){const e=t.filter(t=>"contact"===t.type||!t.type&&!t.expression&&t.id),i=t.filter(t=>"group"===t.type),o=t.filter(t=>"expression"===t.type||t.expression);if(e.length>100)return"You can only add up to 100 contacts";if(i.length>100)return"You can only add up to 100 groups";if(o.length>100)return"You can only add up to 100 expressions";const s=o.some(t=>{const e=t.value||t.name||t.id||"";return"string"==typeof e&&e.length>1e3});return s?"Expressions must be no more than 1000 characters":null}function Ym(t){const e=t.some(t=>"string"==typeof t&&t.length>1e4);return e?"Template variables must be no more than 10000 characters":null}function Xm(t){return t.toLocalizationFormData?t.toLocalizationFormData:"categories"===t.localizable?jm:Array.isArray(t.localizable)?(e=t.localizable,(t,i)=>{const o={uuid:t.uuid};return e.forEach(t=>{const e=i[t];o[t]=Array.isArray(e)&&e[0]||""}),o}):void 0;var e}function Qm(t){return t.fromLocalizationFormData?t.fromLocalizationFormData:"categories"===t.localizable?Hm:Array.isArray(t.localizable)?(e=t.localizable,(t,i)=>{const o={};return e.forEach(e=>{const s=t[e];s&&""!==s.trim()&&s!==i[e]&&(o[e]=[s])}),o}):void 0;var e}const Jm="undefined"!=typeof navigator&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function tg(t){return 0!==t.button||!(!Jm||!t.ctrlKey)}function eg(t){if(t.dependency){const e=t.dependency.name||t.dependency.key;return`Cannot find a ${t.dependency.type} for ${e}`}return t.description}function ig(t){const e=20*Math.round(t/20);return Math.max(e,0)}const og="font-family:SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;font-size:0.95em",sg={[ch.ExpressionPrefix]:`color:${Dh.expression};font-weight:600;${og}`,[ch.Identifier]:`color:${Dh.expression};${og}`,[ch.FunctionName]:`color:${Dh.fn};font-weight:900;${og}`,[ch.StringLiteral]:`color:${Dh.string};${og}`,[ch.NumberLiteral]:`color:${Dh.number};${og}`,[ch.Keyword]:`color:${Dh.keyword};${og}`,[ch.Operator]:`color:${Dh.operator};${og}`,[ch.ContextRef]:`color:${Dh.expression};${og}`,[ch.Separator]:`color:${Dh.operator};${og}`,[ch.Arrow]:`color:${Dh.operator};${og}`,[ch.Bracket]:`color:${Dh.operator};${og}`,[ch.Paren]:`color:${Dh.paren};${og}`,[ch.Whitespace]:og},ng=[[/claude|anthropic/i,"anthropic"],[/gpt|openai|o1|o3|o4/i,"openai"],[/gemini|google/i,"gemini"],[/azure|microsoft/i,"azure"],[/deepseek/i,"deepseek"]],rg=(t,e=!1)=>{const i=fh(t||"",e?ih:eh),o=[];for(const t of i){const e=!!sg[t.type],i=o[o.length-1];i&&i.isExpr===e?i.tokens.push(t):o.push({isExpr:e,tokens:[t]})}const s=t=>{const e=sg[t.type];if(!e){const e=t.text.split("\n");return G`${e.map((t,e)=>G`${e>0?G`<br />`:null}${t}`)}`}const i=t.text.split("\n");return G`${i.map((t,i)=>G`${i>0?G`<br />`:null}${t?G`<span style="${e}">${t}</span>`:null}`)}`};return G`${o.map(t=>{const e=G`${t.tokens.map(s)}`;return t.isExpr?G`<span style="hyphens:none">${e}</span>`:e})}`},ag=(t,e,i=3)=>G`<div
14542
+ </div>`}}i([ft({type:String,attribute:!1})],Am.prototype,"endpoint",void 0),i([ft({type:Boolean})],Am.prototype,"pendingDrop",void 0),i([ft({type:Boolean})],Am.prototype,"ignoreDrops",void 0),i([ft({type:String})],Am.prototype,"icon",void 0),i([ft({type:String})],Am.prototype,"accept",void 0),i([ft({type:Number})],Am.prototype,"max",void 0),i([ft({type:Array})],Am.prototype,"attachments",void 0),i([ft({type:Boolean,attribute:!1})],Am.prototype,"uploading",void 0);let Dm="dev";try{Dm="0.174.0"}catch(t){}const Mm=Dm,zm=[{type:"has_any_word",name:"has any of the words",operands:1},{type:"has_all_words",name:"has all of the words",operands:1},{type:"has_phrase",name:"has the phrase",operands:1},{type:"has_only_phrase",name:"has only the phrase",operands:1},{type:"has_beginning",name:"starts with",operands:1},{type:"has_text",name:"has some text",operands:0,categoryName:"Has Text"},{type:"has_number",name:"has a number",operands:0,categoryName:"Has Number"},{type:"has_number_between",name:"has a number between",operands:2},{type:"has_number_lt",name:"has a number below",operands:1},{type:"has_number_lte",name:"has a number at or below",operands:1},{type:"has_number_eq",name:"has a number equal to",operands:1},{type:"has_number_gte",name:"has a number at or above",operands:1},{type:"has_number_gt",name:"has a number above",operands:1},{type:"has_date",name:"has a date",operands:0,categoryName:"Has Date"},{type:"has_date_lt",name:"has a date before",operands:1},{type:"has_date_eq",name:"has a date equal to",operands:1},{type:"has_date_gt",name:"has a date after",operands:1},{type:"has_time",name:"has a time",operands:0,categoryName:"Has Time"},{type:"has_phone",name:"has a phone number",operands:0,categoryName:"Has Phone"},{type:"has_email",name:"has an email",operands:0,categoryName:"Has Email"},{type:"has_state",name:"has state",operands:0,categoryName:"Has State",filter:"locations"},{type:"has_district",name:"has district",operands:1,categoryName:"Has District",filter:"locations"},{type:"has_ward",name:"has ward",operands:2,categoryName:"Has Ward",filter:"locations"},{type:"has_group",name:"is in the group",operands:1,visibility:"hidden"},{type:"has_category",name:"has the category",operands:0,visibility:"hidden"},{type:"has_error",name:"has an error",operands:0,categoryName:"Has Error",visibility:"hidden"},{type:"has_value",name:"is not empty",operands:0,categoryName:"Not Empty",visibility:"hidden"},{type:"has_pattern",name:"matches regex",operands:1}],Pm=t=>zm.filter(e=>"hidden"!==e.visibility&&(!e.filter||!!t&&t.includes(e.filter))),Im=new Set(["has_beginning","has_number","has_number_between","has_number_lt","has_number_lte","has_number_eq","has_number_gte","has_number_gt","has_pattern"]),Om=t=>zm.find(e=>e.type===t),Rm=t=>t.map(t=>({value:t.type,name:t.name})),Lm={type:"text",required:!1,maxLength:64,placeholder:"(optional)",helpText:"The name to use to reference this result in the flow"},Nm={type:"checkbox",label:"Require rules to be localized",helpText:"Each language must specify its own rules for this node"},Fm={type:"checkbox",label:"Require categories to be localized",helpText:t=>{var e;const i=null===(e=t.result_name)||void 0===e?void 0:e.trim();if(i){return`Only enable if you plan to use @results.${i.toLowerCase().replace(/\s+/g,"_")}.category_localized`}return"Only enable if you plan to use category_localized in your expressions for this result"},conditions:{visible:t=>!!t.result_name}},Bm={label:"Save Result",localizable:!1,items:["result_name"],collapsed:t=>!(t._isNew&&t.result_name),getValueCount:t=>!!t.result_name},Um={type:"accordion",multi:!0,sections:[Bm,{label:"Localization",localizable:!1,items:["localizeRules","localizeCategories"],collapsed:!0,getValueCount:t=>!(!t.localizeRules&&!t.localizeCategories)}]},qm={type:"accordion",multi:!0,sections:[Bm]},Wm={type:"accordion",multi:!0,sections:[Bm,{label:"Localization",localizable:!1,items:["localizeCategories"],collapsed:!0,getValueCount:t=>!!t.localizeCategories}]};function jm(t,e){var i,o;const s=(null===(i=t.router)||void 0===i?void 0:i.categories)||[],n={};s.forEach(t=>{const i=t.uuid,o=e[i];n[i]={originalName:t.name,localizedName:o&&o.name?Array.isArray(o.name)?o.name[0]||"":o.name:""}});const r=(null===(o=t.router)||void 0===o?void 0:o.cases)||[],a={};return r.forEach(t=>{var i,o;if(!(null===(i=t.arguments)||void 0===i?void 0:i.length)||!t.arguments.some(t=>t))return;const s=e[t.uuid],n=(null===(o=Om(t.type))||void 0===o?void 0:o.name)||t.type;a[t.uuid]={operatorName:n,originalArguments:[...t.arguments],localizedArguments:(null==s?void 0:s.arguments)?[...s.arguments]:t.arguments.map(()=>"")}}),{categories:n,rules:a}}function Hm(t,e){const i={};return t.categories&&Object.keys(t.categories).forEach(e=>{var o,s;const n=t.categories[e],r=(null===(o=n.localizedName)||void 0===o?void 0:o.trim())||"",a=(null===(s=n.originalName)||void 0===s?void 0:s.trim())||"";r&&r!==a&&(i[e]={name:[r]})}),t.rules&&Object.keys(t.rules).forEach(e=>{const o=t.rules[e],s=o.localizedArguments||[],n=o.originalArguments||[],r=s.some((t,e)=>(null==t?void 0:t.trim())&&t.trim()!==(n[e]||""));r&&(i[e]={arguments:s.map(t=>(null==t?void 0:t.trim())||"")})}),i}function Vm(t,e,i,o=[]){const s=[],n=[],r=[];return t.forEach(t=>{const a=ae(e,t.name),l=a?i.find(t=>t.uuid===a.exit_uuid):null,d=(null==l?void 0:l.uuid)||Xt(),c=(null==a?void 0:a.uuid)||Xt();if(s.push({uuid:c,name:t.name,exit_uuid:d}),n.push({uuid:d,destination_uuid:(null==l?void 0:l.destination_uuid)||null}),t.case){const e=t.case.arguments[0],i=o.find(t=>{var i;return(null===(i=t.arguments)||void 0===i?void 0:i[0])===e});r.push({uuid:(null==i?void 0:i.uuid)||Xt(),type:t.case.type,arguments:t.case.arguments,category_uuid:c})}}),{categories:s,exits:n,cases:r}}function Gm(t,e,i,o,s){const n=s.some(t=>re(t,"Other"))?null:ae(i,"Other"),r=n?o.find(t=>t.uuid===n.exit_uuid):null,a=(null==r?void 0:r.uuid)||Xt(),l=(null==n?void 0:n.uuid)||Xt();return t.push({uuid:l,name:"Other",exit_uuid:a}),e.push({uuid:a,destination_uuid:(null==r?void 0:r.destination_uuid)||null}),l}function Km(t){return e=>{const i={};return t(e,i),{valid:0===Object.keys(i).length,errors:i}}}function Zm(t){const e=t.filter(t=>"contact"===t.type||!t.type&&!t.expression&&t.id),i=t.filter(t=>"group"===t.type),o=t.filter(t=>"expression"===t.type||t.expression);if(e.length>100)return"You can only add up to 100 contacts";if(i.length>100)return"You can only add up to 100 groups";if(o.length>100)return"You can only add up to 100 expressions";const s=o.some(t=>{const e=t.value||t.name||t.id||"";return"string"==typeof e&&e.length>1e3});return s?"Expressions must be no more than 1000 characters":null}function Ym(t){const e=t.some(t=>"string"==typeof t&&t.length>1e4);return e?"Template variables must be no more than 10000 characters":null}function Xm(t){return t.toLocalizationFormData?t.toLocalizationFormData:"categories"===t.localizable?jm:Array.isArray(t.localizable)?(e=t.localizable,(t,i)=>{const o={uuid:t.uuid};return e.forEach(t=>{const e=i[t];o[t]=Array.isArray(e)&&e[0]||""}),o}):void 0;var e}function Qm(t){return t.fromLocalizationFormData?t.fromLocalizationFormData:"categories"===t.localizable?Hm:Array.isArray(t.localizable)?(e=t.localizable,(t,i)=>{const o={};return e.forEach(e=>{const s=t[e];s&&""!==s.trim()&&s!==i[e]&&(o[e]=[s])}),o}):void 0;var e}const Jm="undefined"!=typeof navigator&&/Mac|iPod|iPhone|iPad/.test(navigator.platform);function tg(t){return 0!==t.button||!(!Jm||!t.ctrlKey)}function eg(t){if(t.dependency){const e=t.dependency.name||t.dependency.key;return`Cannot find a ${t.dependency.type} for ${e}`}return t.description}function ig(t){const e=20*Math.round(t/20);return Math.max(e,0)}const og="font-family:SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;font-size:0.95em",sg={[ch.ExpressionPrefix]:`color:${Dh.expression};font-weight:600;${og}`,[ch.Identifier]:`color:${Dh.expression};${og}`,[ch.FunctionName]:`color:${Dh.fn};font-weight:900;${og}`,[ch.StringLiteral]:`color:${Dh.string};${og}`,[ch.NumberLiteral]:`color:${Dh.number};${og}`,[ch.Keyword]:`color:${Dh.keyword};${og}`,[ch.Operator]:`color:${Dh.operator};${og}`,[ch.ContextRef]:`color:${Dh.expression};${og}`,[ch.Separator]:`color:${Dh.operator};${og}`,[ch.Arrow]:`color:${Dh.operator};${og}`,[ch.Bracket]:`color:${Dh.operator};${og}`,[ch.Paren]:`color:${Dh.paren};${og}`,[ch.Whitespace]:og},ng=[[/claude|anthropic/i,"anthropic"],[/gpt|openai|o1|o3|o4/i,"openai"],[/gemini|google/i,"gemini"],[/azure|microsoft/i,"azure"],[/deepseek/i,"deepseek"]],rg=(t,e=!1)=>{const i=fh(t||"",e?ih:eh),o=[];for(const t of i){const e=!!sg[t.type],i=o[o.length-1];i&&i.isExpr===e?i.tokens.push(t):o.push({isExpr:e,tokens:[t]})}const s=t=>{const e=sg[t.type];if(!e){const e=t.text.split("\n");return G`${e.map((t,e)=>G`${e>0?G`<br />`:null}${t}`)}`}const i=t.text.split("\n");return G`${i.map((t,i)=>G`${i>0?G`<br />`:null}${t?G`<span style="${e}">${t}</span>`:null}`)}`};return G`${o.map(t=>{const e=G`${t.tokens.map(s)}`;return t.isExpr?G`<span style="hyphens:none">${e}</span>`:e})}`},ag=(t,e,i=3)=>G`<div
14543
14543
  style="display: -webkit-box; -webkit-line-clamp: ${i}; -webkit-box-orient: vertical; overflow: hidden; word-wrap: break-word; overflow-wrap: break-word; hyphens: auto;"
14544
14544
  title="${e}"
14545
14545
  >