import{ah as y,a as f,ai as m,a6 as c,M as b,aj as S}from"./index-a6248777.js";import"./index-c34407b8.js";import{S as w}from"./index-8d4fb46c.js";let l,p=0,x=new y("GroupTypes");function j(){return(!l||p<Date.now())&&(l=m().get("/api/v1/group-types"),p=Date.now()+3e6,l.then(t=>{x.$notify("update",t)})),l}function k(){const[t,e]=f.useState([]),[r,o]=f.useState(!1);return f.useEffect(()=>{let n=!0;o(!0),j().then(u=>{n&&e(u)}).finally(()=>{n&&o(!1)});const s=x.$observe("update",u=>e(u));return()=>{s(),n=!1}},[]),[t,{loading:r}]}function V({multiple:t=!1,value:e,onChange:r}){const[o,{loading:n}]=k(),s=f.useMemo(()=>o.map(u=>({label:u.name,value:u.key})),[o]);return c.jsx(w,{loading:n,mode:t?"multiple":void 0,value:e,onChange:r,options:s,filterOption:(u,a)=>a?a.label.startsWith(u):!0})}function O(t,e){for(;t.length<e;)t="0"+t;return t}function i(t,e){var r,o,n;if(e.length===0)return t;for(r=0,n=e.length;r<n;r++)o=e.charCodeAt(r),t=(t<<5)-t+o,t|=0;return t<0?t*-2:t}function v(t,e,r){return Object.keys(e).sort().reduce(o,t);function o(n,s){return T(n,e[s],s,r)}}function T(t,e,r,o){var n=i(i(i(t,r),h(e)),typeof e);if(e===null)return i(n,"null");if(e===void 0)return i(n,"undefined");if(typeof e=="object"||typeof e=="function"){if(o.indexOf(e)!==-1)return i(n,"[Circular]"+r);o.push(e);var s=v(n,e,o);if(!("valueOf"in e)||typeof e.valueOf!="function")return s;try{return i(s,String(e.valueOf()))}catch(u){return i(s,"[valueOf exception]"+(u.stack||u.message))}}return i(n,e.toString())}function h(t){return Object.prototype.toString.call(t)}function D(t){return O(T(0,t,"",[]).toString(16),8)}var E=D;const G=b(E);var d=Object.keys,$=function(e,r){if(e===r)return!0;if(!(e instanceof Object)||!(r instanceof Object))return!1;for(var o=d(e),n=o.length,s=0;s<n;s++)if(!(o[s]in r))return!1;for(var s=0;s<n;s++)if(e[o[s]]!==r[o[s]])return!1;return n===d(r).length},C=function(t,e){return t.every(function(r,o){return $(r,e[o])})},L=function(t,e){S(t,e,C)};const q=L;let g={};function P(t){const e=G(t);let r=g[e];if(!r||r.expires<Date.now()){const o={pp:-1};t&&t.taggibles&&(o.taggible$=t.taggibles.join(",")),r={promise:m().get({path:"/api/v1/tags",query:o}).then(({items:n})=>n.map(s=>({style:s.styles,...s}))).catch(n=>(console.debug(`fetchTags ${String(n)}`),[])),expires:Date.now()+3e6,ob:new y(`Tags:${e}`)},g[e]=r,r.promise.then(n=>{r.ob.$notify("update",n)})}return r}function R(t){const[e,r]=f.useState([]),[o,n]=f.useState(!1),s=f.useRef(!0);return f.useEffect(()=>()=>{s.current=!1},[]),q(()=>{n(!0);const u=P(t);return u.promise.then(a=>{s.current&&r(a)}).finally(()=>{s.current&&n(!1)}),u.ob.$observe("update",a=>s.current&&r(a))},[t]),[e,{loading:o}]}const _="_tag-dropdown_lkxa3_1",M={tagDropdown:_};function N({tags:t,multiple:e=!1,value:r,onChange:o}){return c.jsx("div",{className:M.tagDropdown,children:t.map(n=>c.jsx("div",{className:"tag",style:n.style,onClick:s=>{s.stopPropagation(),o&&(e?r!=null&&r.includes(n.key)?o(r.filter(u=>u!==n.key)):o([...r||[],n.key]):o(n.key))},children:n.name},n.key))})}function W({multiple:t=!1,taggibles:e,value:r,onChange:o}){const[n,{loading:s}]=R({taggibles:e}),u=f.useMemo(()=>n.map(a=>({label:a.name,value:a.key})),[n]);return c.jsx(w,{loading:s,mode:t?"multiple":void 0,showSearch:!1,value:r,options:u,onChange:o,dropdownRender:()=>c.jsx(N,{multiple:t,tags:n,value:r,onChange:o})})}export{V as G,W as T};
