import{I}from"./IdnodeGrid-U6EqXqja.js";import{d as V,u as F,c as R,o as L,e as N,f as l,g as p,i as D,t as O,h as e,I as U,F as z,r as f,L as M,_ as G}from"./index-D92x6h1h.js";import{A as J}from"./ActionMenu-B3aKIJFu.js";import{B as m}from"./BooleanCell-BFiLlZVv.js";import{u as P}from"./useEditorMode-DvyB-mon.js";import{u as j}from"./useBulkAction-UV8yZtrd.js";import{b as H}from"./dvrToolbarHelpers-C5M0Cokf.js";import"./DataGrid-CbtTsx8d.js";import"./index-BG9mM10J.js";import"./index-7HNOjfAo.js";import"./localDay-CoEbUe3O.js";import"./SearchInput-DBHWpJgW.js";import"./useGridLayout-DCIiMD42.js";import"./CollapsibleSection.vue_vue_type_style_index_0_lang-Cq2AVc9p.js";import"./sliders-horizontal-Am8f4Xsv.js";import"./useStaleDataRecovery-BuNK-94T.js";const K={class:"bouquets__empty"},Q=V({__name:"BouquetsView",setup(W){const{t}=F(),b=[{field:"enabled",sortable:!0,filterType:"boolean",width:90,minVisible:"phone",phoneOrder:1,cellComponent:m,editable:!0},{field:"name",sortable:!0,filterType:"string",width:240,minVisible:"phone",phoneRole:"primary",editable:!0},{field:"maptoch",sortable:!0,filterType:"boolean",width:130,cellComponent:m,editable:!0},{field:"lcn_off",sortable:!0,filterType:"numeric",width:130,editable:!0},{field:"mapopt",sortable:!0,filterType:"string",width:220,editable:!0},{field:"chtag",sortable:!0,filterType:"string",width:220,editable:!0},{field:"source",sortable:!0,filterType:"string",width:240,editable:!0},{field:"services_count",sortable:!0,filterType:"numeric",width:110,minVisible:"phone",phoneOrder:2,editable:!0},{field:"services_seen",sortable:!0,filterType:"numeric",width:130,editable:!0},{field:"comment",sortable:!0,filterType:"string",width:240,editable:!0}],g=f(""),{editingUuid:a,editingUuids:h,creatingBase:y,creatingSubclass:_,gridRef:q,editorLevel:w,editorList:v,openEditor:d,openCreate:T,closeEditor:A,flipToEdit:B}=P({createBase:"bouquet",editList:g,urlSync:!0}),C=j({endpoint:"idnode/delete",confirmText:t("Do you really want to delete the selected bouquets?"),confirmSeverity:"danger",failPrefix:t("Failed to delete")}),n=f(!1),u=R();async function S(s,r){const o=s.map(i=>i.uuid).filter(i=>!!i);if(o.length!==0){n.value=!0;try{await M("bouquet/scan",{uuid:JSON.stringify(o)}),u.success(o.length===1?t("Bouquet scan triggered."):t("Scan triggered for {0} bouquets.",o.length)),r()}catch(i){u.error(t("Failed to trigger scan: {0}",i instanceof Error?i.message:String(i)))}finally{n.value=!1}}}function E(s,r){const o=H({selection:s,clearSelection:r,remove:C,onAdd:()=>T(),onEdit:d,addTooltip:t("Add a new bouquet")}),i=o.findIndex(x=>x.id==="delete"),c=i===-1?o.length:i,k={id:"force-scan",label:n.value?t("Scanning…"):t("Force Scan"),tooltip:t("Re-fetch and re-apply mapping for the selected bouquets"),disabled:s.length===0||n.value,onClick:()=>S(s,r)};return[...o.slice(0,c),k,...o.slice(c)]}return(s,r)=>(L(),N(z,null,[l(I,{ref_key:"gridRef",ref:q,endpoint:"bouquet/grid","help-page":"class/bouquet","entity-class":"bouquet",columns:b,"store-key":"config-channel-bouquets","default-sort":{key:"name",dir:"ASC"},"virtual-scroller-options":{itemSize:36,lazy:!1},"count-label":e(t)("bouquets"),"edit-mode":"cell",class:"bouquets__grid",onRowDblclick:r[0]||(r[0]=o=>e(d)([o]))},{empty:p(()=>[D("p",K,O(e(t)("No bouquets defined. Add one (or import via an external URL) to map a network's services into channels en masse.")),1)]),toolbarActions:p(({selection:o,clearSelection:i})=>[l(J,{actions:E(o,i)},null,8,["actions"])]),_:1},8,["count-label"]),l(U,{uuid:e(a),uuids:e(h),"create-base":e(y),subclass:e(_),level:e(w),list:e(v),title:e(a)?e(t)("Edit Bouquet"):e(t)("Add Bouquet"),onClose:e(A),onCreated:e(B)},null,8,["uuid","uuids","create-base","subclass","level","list","title","onClose","onCreated"])],64))}}),pe=G(Q,[["__scopeId","data-v-c5dbc6cf"]]);export{pe as default};
