PageSourceSearch

https://menpan.go.id/assets/MenuManager-C4W_d1ug.js

js menpan.go.id collected 2026-10-01 12:17:11 UTC 33,017 bytes, 11 lines download raw bytes

vendor: 15,658 bytes, lines 1-11
1import{j as e}from"./vendor-mui-pzAHH9Px.js";import{a as l}from"./vendor-react-khHHqPIU.js";import{u as kt,a as Ye,D as Nt,M as St,c as Ct,S as It,v as _t,b as Et,d as rt,s as Mt,K as Dt,P as Pt,e as At,C as Rt}from"./vendor-dnd-BFPnxUeJ.js";import{B as pe}from"./button-B__KXJKn.js";import{I as Ce}from"./input-Cb9axp0j.js";import{L as Z}from"./label-D7RLqSGc.js";import{S as Ie,a as _e,b as Ee,c as Me,d as ee}from"./select-BpN5RP8C.js";import{P as Tt,a as Lt,b as $t}from"./popover-DspL0vNM.js";import{R as Ot,P as Ft,O as Ut,C as Gt}from"./index-Cr7U6S9d.js";import{n as nt,_ as Q,aA as fe,O as ne,ae as Kt,aE as $,a as Vt,w as Ht,aF as Qe,aG as qt,E as Bt}from"./index-BKlU2-ad.js";import{u as de}from"./index-DvVtr4Gm.js";import{C as De,a as Pe,b as Ae,d as Re,c as Te}from"./card-itfuPoYn.js";import{S as zt,D as Jt,a as Wt,b as Xt,e as Le,d as Yt}from"./dropdown-menu-BDHULSFS.js";import{S as Qt}from"./switch-CLHbz0Ar.js";import{G as Ge}from"./grip-vertical-COeE-m3K.js";import{C as Zt}from"./check-D2IyaXV3.js";import{P as er}from"./plus-CrgguSQy.js";import{S as tr}from"./save-D7xFBIg_.js";import{E as rr}from"./external-link-CvcT_48A.js";import{A as nr,a as ar}from"./arrow-up-DR8tdrsK.js";import{A as sr}from"./arrow-left-V0gK9KL5.js";import{P as lr}from"./pencil-B-b7POsA.js";import{T as ir}from"./trash-2-KzCV3G7N.js";import"./index-DM9HOgI6.js";import"./index-D2shsKci.js";import"./chevron-up-C5jj7mp5.js";import"./index-CEyMD-YA.js";/**
2 * @license lucide-react v0.488.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const or=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],dr=nt("chevrons-up-down",or);/**
7 * @license lucide-react v0.488.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const cr=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],ur=nt("ellipsis-vertical",cr);var Ze=1,mr=.9,pr=.8,hr=.17,$e=.1,Oe=.999,fr=.9999,gr=.99,xr=/[\\\/_+.#"@\[\(\{&]/,vr=/[\\\/_+.#"@\[\(\{&]/g,br=/[\s-]/,at=/[\s-]/g;function Ke(t,s,r,c,m,o,u){if(o===s.length)return m===t.length?Ze:gr;var f=`${m},${o}`;if(u[f]!==void 0)return u[f];for(var y=c.charAt(o),d=r.indexOf(y,m),b=0,j,E,I,D;d>=0;)j=Ke(t,s,r,c,d+1,o+1,u),j>b&&(d===m?j*=Ze:xr.test(t.charAt(d-1))?(j*=pr,I=t.slice(m,d-1).match(vr),I&&m>0&&(j*=Math.pow(Oe,I.length))):br.test(t.charAt(d-1))?(j*=mr,D=t.slice(m,d-1).match(at),D&&m>0&&(j*=Math.pow(Oe,D.length))):(j*=hr,m>0&&(j*=Math.pow(Oe,d-m))),t.charAt(d)!==s.charAt(o)&&(j*=fr)),(j<$e&&r.charAt(d-1)===c.charAt(o+1)||c.charAt(o+1)===c.charAt(o)&&r.charAt(d-1)!==c.charAt(o))&&(E=Ke(t,s,r,c,d+1,o+2,u),E*$e>j&&(j=E*$e)),j>b&&(b=j),d=r.indexOf(y,d+1);return u[f]=b,b}function et(t){return t.toLowerCase().replace(at," ")}function yr(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,Ke(t,s,et(t),et(s),0,0,{})}var he='[cmdk-group=""]',Fe='[cmdk-group-items=""]',jr='[cmdk-group-heading=""]',st='[cmdk-item=""]',tt=`${st}:not([aria-disabled="true"])`,Ve="cmdk-item-select",ie="data-value",wr=(t,s,r)=>yr(t,s,r),lt=l.createContext(void 0),ge=()=>l.useContext(lt),it=l.createContext(void 0),Be=()=>l.useContext(it),ot=l.createContext(void 0),dt=l.forwardRef((t,s)=>{let r=oe(()=>{var a,h;return{search:"",value:(h=(a=t.value)!=null?a:t.defaultValue)!=null?h:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),c=oe(()=>new Set),m=oe(()=>new Map),o=oe(()=>new Map),u=oe(()=>new Set),f=ct(t),{label:y,children:d,value:b,onValueChange:j,filter:E,shouldFilter:I,loop:D,disablePointerSelection:H=!1,vimBindings:C=!0,...q}=t,M=de(),B=de(),J=de(),F=l.useRef(null),w=Ar();re(()=>{if(b!==void 0){let a=b.trim();r.current.value=a,A.emit()}},[b]),re(()=>{w(6,_)},[]);let A=l.useMemo(()=>({subscribe:a=>(u.current.add(a),()=>u.current.delete(a)),snapshot:()=>r.current,setState:(a,h,v)=>{var p,k,S,L;if(!Object.is(r.current[a],h)){if(r.current[a]=h,a==="search")W(),ce(),w(1,ue);else if(a==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let T=document.getElementById(J);T?T.focus():(p=document.getElementById(M))==null||p.focus()}if(w(7,()=>{var T;r.current.selectedItemId=(T=G())==null?void 0:T.id,A.emit()}),v||w(5,_),((k=f.current)==null?void 0:k.value)!==void 0){let T=h??"";(L=(S=f.current).onValueChange)==null||L.call(S,T);return}}A.emit()}},emit:()=>{u.current.forEach(a=>a())}}),[]),P=l.useMemo(()=>({value:(a,h,v)=>{var p;h!==((p=o.current.get(a))==null?void 0:p.value)&&(o.current.set(a,{value:h,keywords:v}),r.current.filtered.items.set(a,U(h,v)),w(2,()=>{ce(),A.emit()}))},item:(a,h)=>(c.current.add(a),h&&(m.current.has(h)?m.current.get(h).add(a):m.current.set(h,new Set([a]))),w(3,()=>{W(),ce(),r.current.value||ue(),A.emit()}),()=>{o.current.delete(a),c.current.delete(a),r.current.filtered.items.delete(a);let v=G();w(4,()=>{W(),(v==null?void 0:v.getAttribute("id"))===a&&ue(),A.emit()})}),group:a=>(m.current.has(a)||m.current.set(a,new Set),()=>{o.current.delete(a),m.current.delete(a)}),filter:()=>f.current.shouldFilter,label:y||t["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:M,inputId:J,labelId:B,listInnerRef:F}),[]);function U(a,h){var v,p;let k=(p=(v=f.current)==null?void 0:v.filter)!=null?p:wr;return a?k(a,r.current.search,h):0}function ce(){if(!r.current.search||f.current.shouldFilter===!1)return;let a=r.current.filtered.items,h=[];r.current.filtered.groups.forEach(p=>{let k=m.current.get(p),S=0;k.forEach(L=>{let T=a.get(L);S=Math.max(T,S)}),h.push([p,S])});let v=F.current;z().sort((p,k)=>{var S,L;let T=p.getAttribute("id"),se=k.getAttribute("id");return((S=a.get(se))!=null?S:0)-((L=a.get(T))!=null?L:0)}).forEach(p=>{let k=p.closest(Fe);k?k.appendChild(p.parentElement===k?p:p.closest(`${Fe} > *`)):v.appendChild(p.parentElement===v?p:p.closest(`${Fe} > *`))}),h.sort((p,k)=>k[1]-p[1]).forEach(p=>{var k;let S=(k=F.current)==null?void 0:k.querySelector(`${he}[${ie}="${encodeURIComponent(p[0])}"]`);S==null||S.parentElement.appendChild(S)})}function ue(){let a=z().find(v=>v.getAttribute("aria-disabled")!=="true"),h=a==null?void 0:a.getAttribute(ie);A.setState("value",h||void 0)}function W(){var a,h,v,p;if(!r.current.search||f.current.shouldFilter===!1){r.current.filtered.count=c.current.size;return}r.current.filtered.groups=new Set;let k=0;for(let S of c.current){let L=(h=(a=o.current.get(S))==null?void 0:a.value)!=null?h:"",T=(p=(v=o.current.get(S))==null?void 0:v.keywords)!=null?p:[],se=U(L,T);r.current.filtered.items.set(S,se),se>0&&k++}for(let[S,L]of m.current)for(let T of L)if(r.current.filtered.items.get(T)>0){r.current.filtered.groups.add(S);break}r.current.filtered.count=k}function _(){var a,h,v;let p=G();p&&(((a=p.parentElement)==null?void 0:a.firstChild)===p&&((v=(h=p.closest(he))==null?void 0:h.querySelector(jr))==null||v.scrollIntoView({block:"nearest"})),p.scrollIntoView({block:"nearest"}))}function G(){var a;return(a=F.current)==null?void 0:a.querySelector(`${st}[aria-selected="true"]`)}function z(){var a;return Array.from(((a=F.current)==null?void 0:a.querySelectorAll(tt))||[])}function X(a){let h=z()[a];h&&A.setState("value",h.getAttribute(ie))}function ae(a){var h;let v=G(),p=z(),k=p.findIndex(L=>L===v),S=p[k+a];(h=f.current)!=null&&h.loop&&(S=k+a<0?p[p.length-1]:k+a===p.length?p[0]:p[k+a]),S&&A.setState("value",S.getAttribute(ie))}function xe(a){let h=G(),v=h==null?void 0:h.closest(he),p;for(;v&&!p;)v=a>0?Dr(v,he):Pr(v,he),p=v==null?void 0:v.querySelector(tt);p?A.setState("value",p.getAttribute(ie)):ae(a)}let ve=()=>X(z().length-1),be=a=>{a.preventDefault(),a.metaKey?ve():a.altKey?xe(1):ae(1)},ye=a=>{a.preventDefault(),a.metaKey?X(0):a.altKey?xe(-1):ae(-1)};return l.createElement(Q.div,{ref:s,tabIndex:-1,...q,"cmdk-root":"",onKeyDown:a=>{var h;(h=q.onKeyDown)==null||h.call(q,a);let v=a.nativeEvent.isComposing||a.keyCode===229;if(!(a.defaultPrevented||v))switch(a.key){case"n":case"j":{C&&a.ctrlKey&&be(a);break}case"ArrowDown":{be(a);break}case"p":case"k":{C&&a.ctrlKey&&ye(a);break}case"ArrowUp":{ye(a);break}case"Home":{a.preventDefault(),X(0);break}case"End":{a.preventDefault(),ve();break}case"Enter":{a.preventDefault();let p=G();if(p){let k=new Event(Ve);p.dispatchEvent(k)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:Tr},y),ke(t,a=>l.createElement(it.Provider,{value:A},l.createElement(lt.Provider,{value:P},a))))}),kr=l.forwardRef((t,s)=>{var r,c;let m=de(),o=l.useRef(null),u=l.useContext(ot),f=ge(),y=ct(t),d=(c=(r=y.current)==null?void 0:r.forceMount)!=null?c:u==null?void 0:u.forceMount;re(()=>{if(!d)return f.item(m,u==null?void 0:u.id)},[d]);let b=ut(m,o,[t.value,t.children,o],t.keywords),j=Be(),E=Y(w=>w.value&&w.value===b.current),I=Y(w=>d||f.filter()===!1?!0:w.search?w.filtered.items.get(m)>0:!0);l.useEffect(()=>{let w=o.current;if(!(!w||t.disabled))return w.addEventListener(Ve,D),()=>w.removeEventListener(Ve,D)},[I,t.onSelect,t.disabled]);function D(){var w,A;H(),(A=(w=y.current).onSelect)==null||A.call(w,b.current)}function H(){j.setState("value",b.current,!0)}if(!I)return null;let{disabled:C,value:q,onSelect:M,forceMount:B,keywords:J,...F}=t;return l.createElement(Q.div,{ref:fe(o,s),...F,id:m,"cmdk-item":"",role:"option","aria-disabled":!!C,"aria-selected":!!E,"data-disabled":!!C,"data-selected":!!E,onPointerMove:C||f.getDisablePointerSelection()?void 0:H,onClick:C?void 0:D},t.children)}),Nr=l.forwardRef((t,s)=>{let{heading:r,children:c,forceMount:m,...o}=t,u=de(),f=l.useRef(null),y=l.useRef(null),d=de(),b=ge(),j=Y(I=>m||b.filter()===!1?!0:I.search?I.filtered.groups.has(u):!0);re(()=>b.group(u),[]),ut(u,f,[t.value,t.heading,y]);let E=l.useMemo(()=>({id:u,forceMount:m}),[m]);return l.createElement(Q.div,{ref:fe(f,s),...o,"cmdk-group":"",role:"presentation",hidden:j?void 0:!0},r&&l.createElement("div",{ref:y,"cmdk-group-heading":"","aria-hidden":!0,id:d},r),ke(t,I=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?d:void 0},l.createElement(ot.Provider,{value:E},I))))}),Sr=l.forwardRef((t,s)=>{let{alwaysRender:r,...c}=t,m=l.useRef(null),o=Y(u=>!u.search);return!r&&!o?null:l.createElement(Q.div,{ref:fe(m,s),...c,"cmdk-separator":"",role:"separator"})}),Cr=l.forwardRef((t,s)=>{let{onValueChange:r,...c}=t,m=t.value!=null,o=Be(),u=Y(d=>d.search),f=Y(d=>d.selectedItemId),y=ge();return l.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),l.createElement(Q.input,{ref:s,...c,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":y.listId,"aria-labelledby":y.labelId,"aria-activedescendant":f,id:y.inputId,type:"text",value:m?t.value:u,onChange:d=>{m||o.setState("search",d.target.value),r==null||r(d.target.value)}})}),Ir=l.forwardRef((t,s)=>{let{children:r,label:c="Suggestions",...m}=t,o=l.useRef(null),u=l.useRef(null),f=Y(d=>d.selectedItemId),y=ge();return l.useEffect(()=>{if(u.current&&o.current){let d=u.current,b=o.current,j,E=new ResizeObserver(()=>{j=requestAnimationFrame(()=>{let I=d.offsetHeight;b.style.setProperty("--cmdk-list-height",I.toFixed(1)+"px")})});return E.observe(d),()=>{cancelAnimationFrame(j),E.unobserve(d)}}},[]),l.createElement(Q.div,{ref:fe(o,s),...m,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":c,id:y.listId},ke(t,d=>l.createElement("div",{ref:fe(u,y.listInnerRef),"cmdk-list-sizer":""},d)))}),_r=l.forwardRef((t,s)=>{let{open:r,onOpenChange:c,overlayClassName:m,contentClassName:o,container:u,...f}=t;return l.createElement(Ot,{open:r,onOpenChange:c},l.createElement(Ft,{container:u},l.createElement(Ut,{"cmdk-overlay":"",className:m}),l.createElement(Gt,{"aria-label":t.label,"cmdk-dialog":"",className:o},l.createElement(dt,{ref:s,...f}))))}),Er=l.forwardRef((t,s)=>Y(r=>r.filtered.count===0)?l.createElement(Q.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),Mr=l.forwardRef((t,s)=>{let{progress:r,children:c,label:m="Loading...",...o}=t;return l.createElement(Q.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":m},ke(t,u=>l.createElement("div",{"aria-hidden":!0},u)))}),V=Object.assign(dt,{List:Ir,Item:kr,Input:Cr,Group:Nr,Separator:Sr,Dialog:_r,Empty:Er,Loading:Mr});function Dr(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function Pr(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function ct(t){let s=l.useRef(t);return re(()=>{s.current=t}),s}var re=typeof window>"u"?l.useEffect:l.useLayoutEffect;function oe(t){let s=l.useRef();return s.current===void 0&&(s.current=t()),s}function Y(t){let s=Be(),r=()=>t(s.snapshot());return l.useSyncExternalStore(s.subscribe,r,r)}function ut(t,s,r,c=[]){let m=l.useRef(),o=ge();return re(()=>{var u;let f=(()=>{var d;for(let b of r){if(typeof b=="string")return b.trim();if(typeof b=="object"&&"current"in b)return b.current?(d=b.current.textContent)==null?void 0:d.trim():m.current}})(),y=c.map(d=>d.trim());o.value(t,f,y),(u=s.current)==null||u.setAttribute(ie,f),m.current=f}),m}var Ar=()=>{let[t,s]=l.useState(),r=oe(()=>new Map);return re(()=>{r.current.forEach(c=>c()),r.current=new Map},[t]),(c,m)=>{r.current.set(c,m),s({})}};function Rr(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function ke({asChild:t,children:s},r){return t&&l.isValidElement(s)?l.cloneElement(Rr(s),{ref:s.ref},r(s.props.children)):r(s)}var Tr={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const mt=l.forwardRef(({className:t,...s},r)=>e.jsx(V,{ref:r,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));mt.displayName=V.displayName;const pt=l.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","data-cmdk-input-wrapper":"",children:[e.jsx(Kt,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(V.Input,{ref:r,className:ne("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...s})]}));pt.displayName=V.Input.displayName;const ht=l.forwardRef(({className:t,...s},r)=>e.jsx(V.List,{ref:r,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));ht.displayName=V.List.displayName;const ft=l.forwardRef((t,s)=>e.jsx(V.Empty,{ref:s,className:"py-6 text-center text-sm text-muted-foreground",...t}));ft.displayName=V.Empty.displayName;const gt=l.forwardRef(({className:t,...s},r)=>e.jsx(V.Group,{ref:r,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...s}));gt.displayName=V.Group.displayName;const xt=l.forwardRef(({className:t,...s},r)=>e.jsx(V.Item,{ref:r,className:ne("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),...s}));xt.displayName=V.Item.displayName;const te="https://menpan.go.id",je=()=>({Authorization:`Bearer ${localStorage.getItem("token")}`}
11),vt=32,we=2,He=(t,s=0)=>{let r=[];return t.forEach(c=>{r.push({...c,depth_level:s}),c.children&&c.children.length>0&&(r=[...r,...He(c.children,s+1)])}),r},bt=(t,s=null)=>t.filter(r=>(r.parent_id??null)===s).map(r=>({...r,children:bt(t,r.id)})),qe=(t,s)=>{const r=new Set([t]);return s.forEach(c=>{c.parent_id!=null&&r.has(c.parent_id)&&r.add(c.id)}),r},Lr=(t,s)=>{const r=new Set(s);return t.filter(c=>c.parent_id!=null&&r.has(c.parent_id)?(r.add(c.id),!1):!0)},Ue=(t,s)=>{const r=t.find(o=>o.id===s);if(!r)return 0;const c=qe(s,t);return t.filter(o=>c.has(o.id)).reduce((o,u)=>Math.max(o,u.depth_level),r.depth_level)-r.depth_level},$r=(t,s,r,c,m)=>{const o=t.findIndex(M=>M.id===r),u=t.findIndex(M=>M.id===s);if(o===-1||u===-1)return null;const f=t[u],y=rt(t,u,o),d=y[o-1],b=y[o+1],j=Math.max(0,we-m),E=Math.round(c/vt),I=f.depth_level+E,D=d?d.depth_level+1:0,H=b?b.depth_level:0;let C=I;return I>=D?C=D:I<H&&(C=H),C=Math.max(0,Math.min(C,j)),{depth:C,parentId:(()=>{if(C===0||!d)return null;if(C===d.depth_level)return d.parent_id??null;if(C>d.depth_level)return d.id;const M=y.slice(0,o).reverse().find(B=>B.depth_level===C);return(M==null?void 0:M.parent_id)??null})()}};function Or({item:t,depth:s,hasChildren:r,isCollapsed:c,onToggleCollapse:m,onEdit:o,onDelete:u,onToggle:f,onIndent:y,onOutdent:d,onMoveUp:b,onMoveDown:j,canIndent:E,canOutdent:I,canMoveUp:D,canMoveDown:H}){const{attributes:C,listeners:q,setNodeRef:M,transform:B,transition:J,isDragging:F}=At({id:t.id}),w={transform:Rt.Translate.toString(B),transition:J,paddingLeft:`${s*vt}px`};return e.jsx("div",{ref:M,style:w,className:ne("group relative",F&&"opacity-40"),children:e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 border border-border rounded py-2 px-3 mb-1 hover:bg-card hover:shadow-sm transition-all",children:[e.jsx("div",{...C,...q,className:"cursor-grab active:cursor-grabbing p-2 -m-1 rounded hover:bg-gray-200 touch-none",title:"Seret untuk mengurutkan. Geser ke kanan/kiri untuk mengubah level.",children:e.jsx(Ge,{className:"h-5 w-5 text-gray-400"})}),r?e.jsx("button",{type:"button",onClick:()=>m(t.id),className:"p-1 hover:bg-gray-200 rounded",title:c?"Tampilkan submenu":"Sembunyikan submenu",children:c?e.jsx(Vt,{className:"h-4 w-4 text-gray-600"}):e.jsx(Ht,{className:"h-4 w-4 text-gray-600"})}):e.jsx("span",{className:"w-6","aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:t.title}),t.target==="_blank"&&e.jsx(rr,{className:"h-3 w-3 text-gray-400"}),!t.is_active&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 bg-red-600 text-white rounded shrink-0",children:[e.jsx(Qe,{className:"h-3 w-3","aria-hidden":"true"}),"Disembunyikan"]})]}),t.url&&e.jsx("span",{className:"text-xs text-gray-500 truncate block",children:t.url})]}),e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1 bg-muted rounded",children:["L",s]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>b(t),disabled:!D,className:"p-1.5 rounded text-gray-500 hover:bg-gray-200 hover:text-gray-900 disabled:opacity-25 disabled:hover:bg-transparent disabled:hover:text-gray-500",title:"Naikkan urutan",children:e.jsx(nr,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>j(t),disabled:!H,className:"p-1.5 rounded text-gray-500 hover:bg-gray-200 hover:text-gray-900 disabled:opacity-25 disabled:hover:bg-transparent disabled:hover:text-gray-500",title:"Turunkan urutan",children:e.jsx(ar,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>d(t),disabled:!I,className:"p-1.5 rounded text-muted-foreground hover:bg-blue-100 hover:text-blue-700 dark:hover:bg-blue-500/15 dark:hover:text-blue-400 disabled:opacity-25 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",title:"Keluarkan dari submenu (naikkan level)",children:e.jsx(sr,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>y(t),disabled:!E,className:"p-1.5 rounded text-muted-foreground hover:bg-blue-100 hover:text-blue-700 dark:hover:bg-blue-500/15 dark:hover:text-blue-400 disabled:opacity-25 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",title:"Jadikan submenu dari item di atasnya (turunkan level)",children:e.jsx(qt,{className:"h-4 w-4"})}),e.jsxs(Jt,{children:[e.jsx(Wt,{asChild:!0,children:e.jsxs("button",{type:"button",className:"p-1.5 ml-1 rounded text-gray-500 hover:bg-gray-200 hover:text-gray-900 data-[state=open]:bg-gray-200",title:"Aksi lain",children:[e.jsx(ur,{className:"h-4 w-4"}),e.jsxs("span",{className:"sr-only",children:["Aksi lain untuk ",t.title]})]})}),e.jsxs(Xt,{align:"end",className:"w-48",children:[e.jsxs(Le,{onSelect:()=>o(t),children:[e.jsx(lr,{className:"h-4 w-4 mr-2"}),"Edit menu"]}),e.jsxs(Le,{onSelect:()=>f(t),children:[t.is_active?e.jsx(Qe,{className:"h-4 w-4 mr-2"}):e.jsx(Bt,{className:"h-4 w-4 mr-2"}),t.is_active?"Sembunyikan":"Tampilkan"]}),e.jsx(Yt,{}),e.jsxs(Le,{onSelect:()=>setTimeout(()=>u(t),0),className:"text-red-600 focus:text-red-600 focus:bg-red-50",children:[e.jsx(ir,{className:"h-4 w-4 mr-2"}),"Hapus menu"]})]})]})]})]})})}function pn(){var Je,We,Xe;const[t,s]=l.useState([]),[r,c]=l.useState("header"),[m,o]=l.useState(!1),[u,f]=l.useState(null),[y,d]=l.useState(null),[b,j]=l.useState(0),[E,I]=l.useState(()=>new Set),[D,H]=l.useState([]),[C,q]=l.useState(!1),[M,B]=l.useState(""),[J,F]=l.useState(!1),[w,A]=l.useState(!1),[P,U]=l.useState({title:"",url:"",icon:"",target:"_self",parent_id:null,menu_location:"header",is_active:!0}),ce=kt(Ye(Pt,{activationConstraint:{distance:8}}),Ye(Dt,{coordinateGetter:Mt}));l.useEffect(()=>{W()},[r]),l.useEffect(()=>{ue()},[]);const ue=async()=>{q(!0);try{const i=await(await fetch(`${te}/api/pages?limit=1000&page=1`)).json(),N=(Array.isArray(i==null?void 0:i.data)?i.data:[]).filter(x=>(x==null?void 0:x.status)==="published");H(N)}catch(n){$.error("Gagal mengambil data halaman"),console.error(n)}finally{q(!1)}},W=async()=>{o(!0);try{const i=await(await fetch(`${te}/api/menus?location=${r}&includeInactive=true`)).json();s(i.data||[])}catch(n){$.error("Gagal mengambil data menu"),console.error(n)}finally{o(!1)}},_=l.useMemo(()=>He(t),[t]),G=l.useMemo(()=>{const n=_.filter(i=>E.has(i.id)).map(i=>i.id);return Lr(_,u!=null?[...n,u]:n)},[_,E,u]),z=l.useMemo(()=>u!=null&&y!=null?$r(G,u,y,b,Ue(_,u)):null,[G,_,u,y,b]),X=async(n,i)=>{const g=bt(n),N=He(g),x=t;s(g);try{if(!(await fetch(`${te}/api/menus/order`,{method:"PUT",headers:{"Content-Type":"application/json",...je()},body:JSON.stringify({menus:N.map((R,Se)=>({id:R.id,order_position:Se,parent_id:R.parent_id??null,depth_level:R.depth_level}))})})).ok)throw new Error("Update failed");i&&$.success(i)}catch(K){$.error("Gagal menyimpan struktur menu"),console.error(K),s(x)}},ae=()=>{f(null),d(null),j(0),document.body.style.setProperty("cursor","")},xe=({active:n})=>{f(n.id),d(n.id),document.body.style.setProperty("cursor","grabbing")},ve=({delta:n})=>j(n.x),be=({over:n})=>d((n==null?void 0:n.id)??null),ye=()=>ae(),a=async({active:n,over:i})=>{const g=z;if(ae(),!i||!g)return;const N=_.map(R=>({...R})),x=N.findIndex(R=>R.id===n.id),K=N.findIndex(R=>R.id===i.id);x===-1||K===-1||(N[x]={...N[x],parent_id:g.parentId,depth_level:g.depth},await X(rt(N,x,K),"Struktur menu diperbarui"))},h=n=>{I(i=>{const g=new Set(i);return g.has(n)?g.delete(n):g.add(n),g})},v=async n=>{n.preventDefault();try{const i=w?`${te}/api/menus/${P.id}`:`${te}/api/menus`,N=await fetch(i,{method:w?"PUT":"POST",headers:{"Content-Type":"application/json",...je()},body:JSON.stringify({...P,menu_location:r})});if(N.ok)$.success(w?"Menu diperbarui":"Menu ditambahkan"),Ne(),W();else{const x=await N.json();$.error(x.msg||"Gagal menyimpan menu")}}catch(i){$.error("Terjadi kesalahan"),console.error(i)}},p=n=>{U({id:n.id,title:n.title,url:n.url||"",icon:n.icon||"",target:n.target||"_self",parent_id:n.parent_id,menu_location:n.menu_location,is_active:n.is_active}),A(!0)},k=async n=>{if(confirm(`Hapus menu "${n.title}"?`))try{const i=await fetch(`${te}/api/menus/${n.id}`,{method:"DELETE",headers:je()});if(i.ok)$.success("Menu dihapus"),W();else{const g=await i.json();$.error(g.msg||"Gagal menghapus menu")}}catch(i){$.error("Terjadi kesalahan"),console.error(i)}},S=async n=>{try{(await fetch(`${te}/api/menus/${n.id}/toggle`,{method:"PUT",headers:je()})).ok&&($.success(n.is_active?"Menu disembunyikan":"Menu ditampilkan"),W())}catch(i){$.error("Gagal mengubah status menu"),console.error(i)}},L=n=>_.filter(i=>(i.parent_id??null)===(n.parent_id??null)),T=async n=>{const i=L(n),g=i.findIndex(R=>R.id===n.id);if(g<=0)return;const N=i[g-1],x=N.depth_level+1;if(x+Ue(_,n.id)>we){$.error(`Menu hanya bisa sampai ${we+1} tingkat`);return}const K=_.map(R=>R.id===n.id?{...R,parent_id:N.id}:{...R});await X(K,`Dipindah ke Level ${x} (→)`)},se=async n=>{const i=_.find(x=>x.id===n.parent_id);if(!i)return;const g=_.filter(x=>
11x.id!==n.id).map(x=>({...x}));let N=g.findIndex(x=>x.id===i.id)+1;for(;N<g.length&&g[N].depth_level>i.depth_level;)N++;g.splice(N,0,{...n,parent_id:i.parent_id??null}),await X(g,`Dipindah ke Level ${i.depth_level} (←)`)},ze=async(n,i)=>{const g=L(n),N=g.findIndex(O=>O.id===n.id),x=N+i;if(N===-1||x<0||x>=g.length)return;const K=g[x],R=qe(n.id,_),Se=_.filter(O=>R.has(O.id)).map(O=>({...O})),le=_.filter(O=>!R.has(O.id)).map(O=>({...O}));let me=le.findIndex(O=>O.id===K.id);if(i>0){const O=qe(K.id,le);for(me+=1;me<le.length&&O.has(le[me].id);)me++}le.splice(me,0,...Se),await X(le,i<0?"Dipindah ke atas ↑":"Dipindah ke bawah ↓")},yt=n=>ze(n,-1),jt=n=>ze(n,1),Ne=()=>{U({title:"",url:"",icon:"",target:"_self",parent_id:null,menu_location:r,is_active:!0}),A(!1)},wt=()=>{if(!M){$.error("Pilih page terlebih dulu");return}const n=D.find(i=>(i==null?void 0:i.slug)===M);if(!n){$.error("Page tidak ditemukan");return}A(!1),U({title:n.title||"",url:`/page/${n.slug}`,icon:"",target:"_self",parent_id:null,menu_location:r,is_active:!0}),$.success("Form menu terisi dari page")};return e.jsxs("div",{className:"container mx-auto p-6 max-w-7xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Menu Manager"}),e.jsx("p",{className:"text-gray-600",children:"Manajemen menu interaktif dengan drag & drop"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(De,{children:[e.jsx(Pe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ae,{children:"Menu Items"}),e.jsx(Re,{children:"Seret ↕ untuk mengurutkan, dan geser ke kanan/kiri saat menyeret untuk menjadikannya submenu atau mengeluarkannya. Submenu ikut berpindah bersama induknya. Tombol ↑↓←→ tersedia sebagai alternatif."})]}),e.jsxs(Ie,{value:r,onValueChange:c,children:[e.jsx(_e,{className:"w-[180px]",children:e.jsx(Ee,{})}),e.jsxs(Me,{children:[e.jsx(ee,{value:"header",children:"Header Menu"}),e.jsx(ee,{value:"footer",children:"Footer Menu"}),e.jsx(ee,{value:"sidebar",children:"Sidebar Menu"})]})]})]})}),e.jsx(Te,{children:m?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500 mb-4"}),e.jsx("p",{className:"text-gray-500",children:"Loading menus..."})]}):t.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-muted rounded-full flex items-center justify-center mb-4",children:e.jsx(Ge,{className:"h-8 w-8 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No menu items yet"}),e.jsx("p",{className:"text-gray-500 mb-4",children:"Create your first menu item to get started"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Use the form on the right to add a new menu →"})]}):e.jsxs(Nt,{sensors:ce,collisionDetection:Ct,measuring:{droppable:{strategy:St.Always}},onDragStart:xe,onDragMove:ve,onDragOver:be,onDragEnd:a,onDragCancel:ye,children:[e.jsx(It,{items:G.map(n=>n.id),strategy:_t,children:e.jsx("div",{className:"space-y-1",children:G.map(n=>{const i=G.filter(x=>(x.parent_id??null)===(n.parent_id??null)),g=i.findIndex(x=>x.id===n.id),N=_.some(x=>x.parent_id===n.id);return e.jsx(Or,{item:n,depth:n.id===u&&z?z.depth:n.depth_level,hasChildren:N,isCollapsed:E.has(n.id),onToggleCollapse:h,onEdit:p,onDelete:k,onToggle:S,onIndent:T,onOutdent:se,onMoveUp:yt,onMoveDown:jt,canIndent:g>0&&n.depth_level+1+Ue(_,n.id)<=we,canOutdent:n.depth_level>0,canMoveUp:g>0,canMoveDown:g<i.length-1},n.id)})})}),e.jsx(Et,{children:u?e.jsx("div",{className:"bg-card border-2 border-primary rounded-lg p-3 shadow-lg",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:(Je=_.find(n=>n.id===u))==null?void 0:Je.title})]})}):null})]})})]})}),e.jsx("div",{className:"lg:col-span-1",children:e.jsxs("div",{className:"sticky top-6 space-y-6",children:[e.jsxs(De,{children:[e.jsxs(Pe,{children:[e.jsx(Ae,{children:"Tambah Menu dari Halaman"}),e.jsx(Re,{children:"Pilih page (published) lalu isi otomatis ke form menu."})]}),e.jsxs(Te,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{children:"Page"}),e.jsxs(Tt,{open:J,onOpenChange:F,children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(pe,{type:"button",variant:"outline",role:"combobox","aria-expanded":J,disabled:C,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:"truncate",children:C?"Memuat pages...":M?(We=D.find(n=>n.slug===M))==null?void 0:We.title:"Pilih page"}),e.jsx(dr,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx($t,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(mt,{filter:(n,i)=>{var x;const g=D.find(K=>K.slug===n);return(((x=g==null?void 0:g.title)==null?void 0:x.toLowerCase())||"").includes(i.toLowerCase())?1:0},children:[e.jsx(pt,{placeholder:"Cari judul page..."}),e.jsxs(ht,{children:[e.jsx(ft,{children:"Tidak ada page yang cocok."}),e.jsx(gt,{children:D.map(n=>e.jsxs(xt,{value:n.slug,onSelect:i=>{B(i===M?"":i),F(!1)},children:[e.jsx(Zt,{className:ne("mr-2 h-4 w-4",M===n.slug?"opacity-100":"opacity-0")}),n.title]},n.id))})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(pe,{type:"button",className:"flex-1",onClick:wt,disabled:C||D.length===0,children:[e.jsx(er,{className:"h-4 w-4 mr-2"}),"Isi ke Form"]}),e.jsx(pe,{type:"button",variant:"outline",onClick:()=>{B(""),Ne()},children:"Reset"})]})]})]}),e.jsxs(De,{children:[e.jsxs(Pe,{children:[e.jsx(Ae,{children:w?"Edit Menu Item":"Add Menu Item"}),e.jsx(Re,{children:w?"Update the menu item details":"Create a new menu item"})]}),e.jsx(Te,{children:e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"title",children:"Menu Title *"}),e.jsx(Ce,{id:"title",value:P.title,onChange:n=>U({...P,title:n.target.value}),placeholder:"e.g., About Us",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"url",children:"URL"}),e.jsx(Ce,{id:"url",value:P.url,onChange:n=>U({...P,url:n.target.value}),placeholder:"/about or https://example.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"icon",children:"Icon (Lucide)"}),e.jsx(Ce,{id:"icon",value:P.icon,onChange:n=>U({...P,icon:n.target.value}),placeholder:"Building2, Home, etc."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"parent",children:"Parent Menu"}),e.jsxs(Ie,{value:((Xe=P.parent_id)==null?void 0:Xe.toString())||"none",onValueChange:n=>U({...P,parent_id:n==="none"?null:parseInt(n)}),children:[e.jsx(_e,{id:"parent",children:e.jsx(Ee,{})}),e.jsxs(Me,{children:[e.jsx(ee,{value:"none",children:"None (Top Level)"}),_.filter(n=>n.id!==P.id).map(n=>e.jsx(ee,{value:n.id.toString(),className:n.depth_level>0?"pl-8":"",children:e.jsxs("span",{className:"flex items-center gap-2",children:[n.depth_level>0&&e.jsx("span",{className:"text-muted-foreground flex items-center",children:"└─ ".repeat(n.depth_level)}),e.jsx("span",{className:n.depth_level>0?"font-normal text-sm":"font-medium",children:n.title}),n.depth_level>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(Level ",n.depth_level,")"]})]})},n.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Z,{htmlFor:"target",children:"Link Target"}),e.jsxs(Ie,{value:P.target,onValueChange:n=>U({...P,target:n}),children:[e.jsx(_e,{id:"target",children:e.jsx(Ee,{})}),e.jsxs(Me,{children:[e.jsx(ee,{value:"_self",children:"Same Tab"}),e.jsx(ee,{value:"_blank",children:"New Tab"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx(Z,{htmlFor:"active",children:"Active"}),e.jsx(Qt,{id:"active",checked:P.is_active,onCheckedChange:n=>U({...P,is_active:n})})]}),e.jsx(zt,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(pe,{type:"submit",className:"flex-1",children:[e.jsx(tr,{className:"h-4 w-4 mr-2"}),w?"Update":"Add"," Menu"]}),w&&e.jsx(pe,{type:"button",variant:"outline",onClick:Ne,children:"Cancel"})]})]})})]})]})})]})]})}export{pn as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.