import{useCallback}from"react";import{useSetAtom,useAtomValue}from"jotai";import{getActiveMediaType}from"../models";import{operationStore}from"../jotai/operation";import{activeMimeNameAtom}from"../jotai/app";export function useActivateExample(e){const o=useSetAtom(operationStore((null==e?void 0:e.operation.pointer)||"no_operation_pointer")),i=useAtomValue(activeMimeNameAtom),t=e?getActiveMediaType(e,i):void 0;return useCallback((e=>{var i,a,l,m,n,r,u;if(t)if(t.examples&&(null===(i=t.schema)||void 0===i?void 0:i.oneOf)&&Object.keys(t.examples).includes(e)){const i=null===(l=null===(a=t.schema)||void 0===a?void 0:a.oneOf)||void 0===l?void 0:l.findIndex((o=>o.title===e));o(-1===i?{activeExampleName:e,requestValues:{}}:{activeOneOf:{[(null===(m=t.schema)||void 0===m?void 0:m.pointer)||""]:i},activeExampleName:null===(u=null===(r=null===(n=t.schema)||void 0===n?void 0:n.oneOf)||void 0===r?void 0:r[i])||void 0===u?void 0:u.title,requestValues:{}})}else o({activeExampleName:e,requestValues:{}})}),[t,o])}
//# sourceMappingURL=useActivateExample.js.map