@gisce/react-ooui 1.2.0-rc.3 → 1.2.0-rc.4
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/dist/actionbar/TreeActionBar.d.ts.map +1 -1
- package/dist/react-ooui.es.js +41 -8
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +1 -1
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actionbar/TreeActionBar.tsx +42 -8
- package/src/types/index.ts +1 -0
- package/src/views/actionViews/TreeActionView.tsx +1 -1
package/dist/react-ooui.umd.js
CHANGED
|
@@ -281,5 +281,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
281
281
|
.ant-transfer-list-body-customize-wrapper {
|
|
282
282
|
min-height: ${300}px;
|
|
283
283
|
}
|
|
284
|
-
`,cn=({targetKeys:e,locale:o,onGetFields:r,onGetFieldChilds:a,onChange:s,...c})=>{const[l,d]=React.useState(),[u,f]=React.useState(!0),[p,m]=React.useState(),[I,h]=React.useState();React.useEffect(()=>{v()},[]);const v=React.useCallback(async()=>{f(!0);try{const g=await r();d(g)}catch(g){console.error(g),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(g,null,2)})})}f(!1)},[]),C=React.useCallback(async({key:g})=>{try{const O=Z(l).find(F=>F.key===g),w=await a({key:g,title:O.title}),_=Ht(l,g,w);d(_)}catch(O){console.error(O),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}},[l]),b=React.useCallback((g,O)=>{g==="left"?m(O.trim()===""?void 0:O.trim()):h(O.trim()===""?void 0:O.trim())},[]),y=React.useCallback(({checkedKeys:g,onItemSelect:O})=>(w,{node:{key:_}})=>{var F;O(_,(F=_,!g.includes(F)))},[]);return jsxRuntime.jsx(sn,{...c,showSearch:!0,targetKeys:e,dataSource:Z(l),className:"tree-transfer",render:g=>g.title,onChange:s,showSelectAll:!0,locale:{itemUnit:S("exportModalItemsUnit",o),itemsUnit:S("exportModalItemsUnit",o),notFoundContent:S("notFoundContent",o),searchPlaceholder:S("searchPlaceholder",o)},filterOption:Le,onSearch:b,titles:[S("availableFields",o),S("fieldsToExport",o)],children:({direction:g,onItemSelect:O,selectedKeys:w})=>{if(u)return jsxRuntime.jsx("div",{style:{display:"flex",paddingTop:"2em",justifyContent:"center"},children:jsxRuntime.jsx(antd.Spin,{})});if(g==="left"){const _=[...e,...w];return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:_,loadData:C,treeData:Pt({treeNodes:l,checkedKeys:e,searchText:p}),onCheck:y({checkedKeys:_,onItemSelect:O}),onSelect:y({checkedKeys:_,onItemSelect:O}),titleRender:F=>jsxRuntime.jsx(Xe,{node:F})})}return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:w,onCheck:y({checkedKeys:w,onItemSelect:O}),onSelect:y({checkedKeys:w,onItemSelect:O}),treeData:Ie({treeNodes:l,checkedKeys:e,searchText:I}),titleRender:_=>jsxRuntime.jsx(Xe,{node:_})})}})},et=()=>jsxRuntime.jsx("div",{style:{padding:"0.5em"}}),{error:dn}=antd.Modal,Yn=e=>{const{visible:o,locale:r,onCancel:a,onSucceed:s,totalRegisters:c,selectedRegistersToExport:l,selectedKeys:d}=e,{modalWidth:u}=jt(),[f,p]=React.useState(!1),[m,I]=React.useState("csv"),[h,v]=React.useState("all"),[C,b]=React.useState(d);React.useEffect(()=>{o||(b(void 0),I("csv"),v(l?"selected":"all"))},[o]),React.useEffect(()=>{v(l?"selected":"all")},[l]),React.useEffect(()=>{d===void 0||C||b(d)},[d,C]);const y=React.useCallback(O=>{b(O)},[]),g=React.useCallback(async()=>{p(!0);try{await s({exportType:m,selectedKeys:C,registersAmount:h})}catch(O){console.error(O),dn({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}p(!1)},[m,C,h]);return jsxRuntime.jsxs(antd.Modal,{title:S("export",r),centered:!0,width:u,visible:o,closable:!f,onCancel:a,footer:null,destroyOnClose:!0,children:[jsxRuntime.jsx(cn,{targetKeys:C,onChange:y,locale:r,onGetFieldChilds:e.onGetFieldChilds,onGetFields:e.onGetFields}),jsxRuntime.jsx(et,{}),jsxRuntime.jsx(an,{locale:r,value:m,onChange:I}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(et,{}),jsxRuntime.jsx(on,{locale:r,totalRegisters:c,selectedRegistersToExport:l,value:h,onChange:v})]}),jsxRuntime.jsx(antd.Divider,{}),jsxRuntime.jsx(qt,{locale:r,onClose:a,onConfirm:g,loading:f,left:S("exportRegisters",r).replace("{total}",h==="selected"?l==null?void 0:l.toString():c.toString())})]})},ExportModal=e=>{const{visible:o,locale:r,onClose:a,model:s,context:c,treeFields:l,selectedRegistersToExport:d,totalRegisters:u,domain:f,limit:p}=e,m=React.useRef({}),I=React.useCallback(async C=>{if(C.selectedKeys.length===0){showDialog$7(tForLang("selectAtLeastOneField",r));return}const{datas:b}=await ConnectionProvider.getHandler().exportData({model:s,fields:C.selectedKeys,domain:C.registersAmount==="all"?[]:f,limit:C.registersAmount==="all"?void 0:p,context:c,format:C.exportType});a(),await new Promise(g=>setTimeout(g,200));const y=await getMimeType(b);openBase64InNewTab(b,y.mime)},[r,s,f,p,c,a]),h=React.useCallback(async()=>{const C=await ConnectionProvider.getHandler().getFields({model:s,context:c,fields:[]});return m.current["/"]=C,convertToExportField({fields:C})},[s,c,m]),v=React.useCallback(async({key:C,title:b})=>{let y;C.indexOf("/")===-1?y=m.current["/"]:y=m.current[getParentKey(C)];const O=y[getChildKey(C)].relation,w=await ConnectionProvider.getHandler().getFields({model:O,context:c,fields:[]});return m.current[C]=w,convertToExportField({fields:w,parentTitle:b,parentKey:C})},[m,s,c]);return jsxRuntime.jsx(Yn,{visible:o,locale:r,onSucceed:I,onCancel:a,selectedRegistersToExport:d,totalRegisters:u,onGetFieldChilds:v,onGetFields:h,selectedKeys:l?Object.keys(l):void 0})},convertToExportField=({fields:e,parentKey:o,parentTitle:r})=>{const a=[];for(const s of Object.keys(e)){const c=e[s],l=c.type==="many2one"||c.type==="one2many"||c.type==="many2many";a.push({key:`${o?o+"/":""}${s}`,title:`${r?r+"/":""}${c.string}`,tooltip:c.help,required:c.required,isLeaf:!l})}return a},getParentKey=e=>e.indexOf("/")===-1?e:e.split("/").slice(0,-1).join("/"),getChildKey=e=>{if(e.indexOf("/")===-1)return e;const o=e.split("/");return o[o.length-1]},DatePickerConfig={date:{placeholder:"__/__/____",dateDisplayFormat:"YYYY-MM-DD",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"YYYY-MM-DD HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},DatePicker=e=>{const{ooui:o,showTime:r=!1}=e,{required:a}=o;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(DatePickerInput,{ooui:o,showTime:r})})},DatePickerInput=e=>{const{value:o,onChange:r,ooui:a,showTime:s}=e,{id:c,readOnly:l,required:d}=a,u=d&&!l?Config.requiredClass:void 0,f=s?"time":"date",p=v=>{r==null||r(v)},m=v=>{if(v===null){p(void 0);return}p(v.format(DatePickerConfig[f].dateInternalFormat))},I=s?{defaultValue:hooks("00:00:00","HH:mm:ss")}:void 0,h=o?hooks(o,DatePickerConfig[f].dateInternalFormat):void 0;return jsxRuntime.jsx(antd.DatePicker,{style:{width:"100%"},placeholder:s?DatePickerConfig.time.placeholder:DatePickerConfig.date.placeholder,disabled:l,id:c,showTime:I,className:u,format:DatePickerConfig[f].dateDisplayFormat,value:h,onChange:m})},Date$1=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o})},DateTime=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o,showTime:!0})},Reference=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(ReferenceInput,{ooui:o})})},ReferenceInput=e=>{const{value:o,onChange:r,ooui:a}=e,{required:s,selectionValues:c,readOnly:l}=a,d=o==null?void 0:o.split(","),[u,f]=React.useState([]),[p,m]=React.useState();return React.useEffect(()=>{if(!o)return;const I=o&&d&&d[0],h=o&&d&&d[1]&&parseInt(d[1]);f([h,void 0]),m(I)},[o]),jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"1",children:jsxRuntime.jsx(SelectionInput$1,{ooui:new ooui.Selection({name:"model_selection",selection:c,readOnly:l,required:s}),onChange:I=>{m(I),f([]),r==null||r(void 0)},value:p})}),jsxRuntime.jsx(antd.Col,{flex:"3",children:jsxRuntime.jsx(Many2oneInput,{ooui:new ooui.Many2one({name:"object_value",relation:p,readOnly:l,required:s}),value:u,onChange:I=>{f(I);const h=`${p},${I[0]}`;h!==o&&(r==null||r(h))}})})]})},Binary=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(BinaryInput,{ooui:o})})},BinaryInput=e=>{const{ooui:o,value:r,onChange:a}=e,{readOnly:s,required:c,filenameField:l}=o,d=c&&!s?Config.requiredClass:void 0,u=React.useRef(null),{setFieldValue:f,getFieldValue:p}=React.useContext(FormContext$1)||{},{t:m}=React.useContext(LocaleContext),I=r?getFilesize(r):"",h=g=>{a==null||a(g)};async function v(){const g=await getMimeType(r),O=`data:${g==null?void 0:g.mime};base64,${r}`,w=document.createElement("a"),_=p(l),F=p("name");w.href=O,w.download=_||F,w.click()}async function C(){const g=await getMimeType(r);openBase64InNewTab(r,g.mime)}async function b(g){g.stopPropagation(),g.preventDefault();const O=g.target.files[0],w=await toBase64(O);h(w),l&&f(l,O.name)}function y(){f(l,void 0),h(void 0)}return jsxRuntime.jsxs(antd.Row,{gutter:8,children:[jsxRuntime.jsxs(antd.Col,{style:{paddingBottom:5},children:[jsxRuntime.jsx("input",{type:"file",id:"file",ref:u,style:{display:"none"},onChange:b}),jsxRuntime.jsx(antd.Input,{type:"text",disabled:!0,className:d,value:I})]}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.FolderOpenOutlined,{}),disabled:s,onClick:()=>{u.current.click()},children:"Select"}),jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EyeOutlined,{}),disabled:!r,onClick:C,children:m("open")}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("download"),disabled:!r,onClick:v,icon:jsxRuntime.jsx(Icon.DownloadOutlined,{})}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("clear"),disabled:s||!r,onClick:y,icon:jsxRuntime.jsx(Icon.ClearOutlined,{})})]})})]})},iconsForViewTypes={tree:jsxRuntime.jsx(Icon.TableOutlined,{}),form:jsxRuntime.jsx(Icon.FormOutlined,{}),graph:jsxRuntime.jsx(Icon.AreaChartOutlined,{}),calendar:jsxRuntime.jsx(Icon.CalendarOutlined,{})};function getIconForView(e){return e?(iconsForViewTypes==null?void 0:iconsForViewTypes[e.type])||jsxRuntime.jsx(Icon.FormOutlined,{}):jsxRuntime.jsx(Icon.FormOutlined,{})}function ChangeViewButton(e){const{currentView:o,availableViews:r,onChangeView:a,disabled:s=!1,formHasChanges:c=!1,previousView:l}=e,{t:d,lang:u}=React.useContext(LocaleContext);function f(){const I=r.map((h,v)=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:getIconForView(h)}),jsxRuntime.jsx(antd.Col,{flex:"auto",style:{paddingRight:20},children:h.type==="graph"?h.name:h.type.charAt(0).toUpperCase()+h.type.slice(1)}),jsxRuntime.jsx(antd.Col,{flex:"none",children:jsxRuntime.jsx(Icon.CheckOutlined,{style:{opacity:o.view_id===h.view_id?1:0}})})]})},h.view_id||v));return jsxRuntime.jsx(antd.Menu,{onClick:m,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:d("viewAs"),children:I})})}function p(I){if(c){showDialog$6({lang:u,onOk:()=>{I()}});return}I()}function m(I){p(()=>{const h=r.find(v=>v.view_id===parseInt(I.key));a(h)})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ButtonWithTooltip,{tooltip:l?d("viewAs")+" "+d(l.type):"",icon:getIconForView(l),style:{width:50},onClick:()=>{m({key:l==null?void 0:l.view_id})},disabled:s||r.length===1}),jsxRuntime.jsx(antd.Dropdown,{overlay:f(),disabled:s||r.length===1,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:I=>I.preventDefault()})})]})}function DropdownButton(e){const{icon:o,tooltip:r,items:a=[],onItemClick:s,label:c,disabled:l=!1}=e;function d(){const f=a==null?void 0:a.map((p,m)=>p.name==="divider"?jsxRuntime.jsx(antd.Menu.Divider,{},"divider"+m):jsxRuntime.jsx(antd.Menu.Item,{children:p.name},p.id));return jsxRuntime.jsx(antd.Menu,{onClick:u,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:r,children:f})})}function u(f){const p=a.find(m=>isNaN(f.key)?m.id===f.key:m.id===parseInt(f.key));s(p)}return jsxRuntime.jsx(antd.Dropdown,{overlay:d(),disabled:l||!a||a.length===0,children:jsxRuntime.jsxs(antd.Button,{children:[o," ",c," ",jsxRuntime.jsx(Icon.DownOutlined,{})]})})}function ActionButton(e){const{onClick:o,disabled:r=!1,loading:a=!1,tooltip:s,icon:c,label:l,type:d="default"}=e,u=a?jsxRuntime.jsx(Icon.LoadingOutlined,{}):c;return jsxRuntime.jsxs(ButtonWithTooltip,{type:d,tooltip:s,onClick:o,disabled:r,children:[u,l]})}function NewButton(e){const{disabled:o=!1}=e,{formHasChanges:r,onNewClicked:a}=React.useContext(ActionViewContext),{t:s,lang:c}=React.useContext(LocaleContext),l=()=>{if(r){showDialog$6({lang:c,onOk:()=>{a()}});return}a()};return jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.FileAddOutlined,{}),tooltip:s("new"),onClick:l,disabled:o})}const{confirm}=antd.Modal,showDialog=({onOk:e,onCancel:o,lang:r})=>{confirm({title:tForLang("unsavedChanges",r),icon:jsxRuntime.jsx(Icon.ExclamationCircleOutlined,{}),centered:!0,content:tForLang("confirmRefreshWithoutSave",r),okText:tForLang("discardAndRefresh",r),cancelText:tForLang("cancel",r),onOk:e,onCancel:o})};async function showLogInfo(e,o,r){const a=(await ConnectionProvider.getHandler().getLogInfo({model:e,ids:[o]}))[0],{create_date:s,create_uid:c,id:l,write_date:d,write_uid:u}=a;showDialog$7(jsxRuntime.jsxs("div",{children:["ID: "+l," ",jsxRuntime.jsx("br",{}),r("createdBy")+": "+c[1]," ",jsxRuntime.jsx("br",{}),r("creationDate")+": "+s," ",jsxRuntime.jsx("br",{}),r("lastUpdatedBy")+": "+u[1]," ",jsxRuntime.jsx("br",{}),r("lastUpdatedDate")+": "+d]}))}const AttachmentsButtonWrapper=e=>{const{numberOfAttachments:o,disabled:r}=e,{t:a}=React.useContext(LocaleContext),[s,c]=React.useState(!1),l=jsxRuntime.jsxs(antd.Button,{disabled:r,children:[jsxRuntime.jsx(Icon.LinkOutlined,{}),`(${o})`,jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:12}})]});return r?l:jsxRuntime.jsx(antd.Popover,{onVisibleChange:d=>c(d),visible:s,placement:"bottom",content:Content$1(e,c),title:a("attachments"),arrowContent:null,children:l})},Content$1=(e,o)=>{const{attachments:r=[],loading:a,onAddNewAttachment:s,onopenAttachmentLink:c,onOpenAttachmentDetail:l,onListAllAttachments:d}=e,{t:u}=React.useContext(LocaleContext);return a?jsxRuntime.jsx(antd.Spin,{style:{padding:20}}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{o(!1),d()},children:[jsxRuntime.jsx(Icon.TableOutlined,{})," ",u("listAllAttachments")]}),jsxRuntime.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{o(!1),s()},children:[jsxRuntime.jsx(Icon.FileAddOutlined,{})," ",u("addNewAttachment")]}),r.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("li",{className:" ant-dropdown-menu-item-divider"}),r.map(f=>{const p=f.link?Icon.LinkOutlined:Icon.DownloadOutlined;return jsxRuntime.jsxs(antd.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[jsxRuntime.jsx(antd.Col,{flex:"auto",children:f.name}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:(f.datas_fname||f.link)&&jsxRuntime.jsx(antd.Tooltip,{title:f.link?u("openAttachmentLink"):u("download"),children:jsxRuntime.jsx(p,{style:{cursor:"pointer"},onClick:()=>{o(!1),c(f)}})})}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:jsxRuntime.jsx(antd.Tooltip,{title:u("openAttachment"),children:jsxRuntime.jsx(Icon.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{o(!1),l(f)}})})})]},f.id)})]})]})};function AttachmentsButton(e){const{attachments:o,disabled:r=!1,onAddNewAttachment:a,onListAllAttachments:s,onViewAttachmentDetails:c}=e,{formRef:l}=React.useContext(ActionViewContext),[d,u]=React.useState(!1),[f,p]=React.useState([]),[m,I]=React.useState(!1),{t:h}=React.useContext(LocaleContext),v=React.useCallback(async()=>{u(!0);try{const y=await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:o.map(g=>g.id),fieldsToRetrieve:["name","datas_fname","link"],context:l.current.getContext()});p(y.map(g=>({id:g.id,name:g.name,datas_fname:g.datas_fname,link:g.link})))}catch(y){showDialog$8(y)}u(!1)},o),C=React.useCallback(async y=>{if(y.link){window.open(y.link);return}I(!0);let g;try{g=(await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:[y.id],context:l.current.getContext()}))[0]}catch(O){showDialog$8(O)}if(I(!1),!!g)if(g.datas){const O=await getMimeType(g.datas);openBase64InNewTab(g.datas,O.mime)}else c(g)},[]),b=React.useCallback(async y=>{c(y)},[]);return React.useEffect(()=>{v()},[v]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AttachmentsButtonWrapper,{numberOfAttachments:o.length,attachments:f,disabled:r,loading:d,onAddNewAttachment:a,onListAllAttachments:s,onopenAttachmentLink:C,onOpenAttachmentDetail:b}),jsxRuntime.jsx(antd.Modal,{title:h("downloadingAttachment"),visible:m,footer:null,closable:!1,centered:!0,maskClosable:!1,children:jsxRuntime.jsx(antd.Spin,{})})]})}function FormActionBar({toolbar:e}){const{availableViews:o,currentView:r,setCurrentView:a,onFormSave:s,formHasChanges:c,formIsSaving:l,currentId:d,results:u,setCurrentItemIndex:f,currentItemIndex:p,setCurrentId:m,currentModel:I,setRemovingItem:h,removingItem:v,duplicatingItem:C,setDuplicatingItem:b,setResults:y,formIsLoading:g,attachments:O,formRef:w,setFormHasChanges:_,searchTreeRef:F,previousView:L,setPreviousView:E,goToResourceId:P}=React.useContext(ActionViewContext),{t:A,lang:W}=React.useContext(LocaleContext),J=React.useContext(ContentRootContext),{processAction:Y}=J||{},z=React.useContext(TabManagerContext),{openRelate:Q,openDefaultActionForModel:oe}=z||{};function te(N){if(c){showDialog({lang:W,onOk:()=>{N()}});return}N()}function X(N){if(c){showDialog$6({lang:W,onOk:()=>{N()}});return}N()}function ce(){u&&u.length>p+1?(f==null||f(p+1),m==null||m(u[p+1].id)):u&&p+1===u.length&&(f==null||f(0),m==null||m(u[0].id))}function Re(){u&&p>0?(f==null||f(p-1),m==null||m(u[p-1].id)):u&&p===0&&(f==null||f(u.length-1),m==null||m(u[u.length-1].id))}function xe(){showDialog$9({confirmMessage:A("confirmRemoveItem"),lang:W,onOk:()=>{de()}})}async function de(){try{h==null||h(!0),await ConnectionProvider.getHandler().delete({model:I,ids:[d]});const N=u==null?void 0:u.filter(re=>re.id!==d);y==null||y(N);let U=0;p>0&&p<=u.length-1&&(U=p-1),N!=null&&N[U]?(m==null||m(N==null?void 0:N[U].id),f==null||f(U)):(m==null||m(void 0),f==null||f(void 0))}catch(N){showDialog$3(JSON.stringify(N))}finally{h==null||h(!1)}}async function Ce(){try{b==null||b(!0);const N=await ConnectionProvider.getHandler().duplicate({id:d,model:I,context:w.current.getContext()});N&&await(P==null?void 0:P(N))}catch(N){showDialog$3(JSON.stringify(N))}finally{b==null||b(!1)}}const ee=l||v||g||C;function ue(N){Y==null||Y({actionData:N,values:w.current.getValues(),fields:w.current.getFields(),context:w.current.getContext(),onRefreshParentValues:()=>{w.current.fetchValues()}})}return r?jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[g&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Spin,{}),separator$2(),separator$2()]}),jsxRuntime.jsx(NewButton,{disabled:l||g||v||C}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SaveOutlined,{}),tooltip:A("save"),disabled:!c||ee,loading:l,onClick:s}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:A("duplicate"),disabled:c||l||d===void 0||C||g,loading:C,onClick:Ce}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:A("delete"),disabled:l||d===void 0||v||C||g,loading:v,onClick:xe}),separator$2(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:A("showLogs"),disabled:l||d===void 0||v||C||g,loading:!1,onClick:()=>{showLogInfo(I,d,A)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:A("refresh"),disabled:l||d===void 0||v||C||g,loading:!1,onClick:()=>{te(()=>{w.current.fetchValues()})}}),separator$2(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,previousView:L,availableViews:o,onChangeView:N=>{E==null||E(r),_==null||_(!1),a==null||a(N)},disabled:ee,formHasChanges:c}),separator$2(),jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.LeftOutlined,{}),tooltip:A("previous"),disabled:ee,loading:!1,onClick:()=>{X(Re)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.RightOutlined,{}),tooltip:A("next"),disabled:ee,loading:!1,onClick:()=>{X(ce)}})]}),separator$2(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:ee,tooltip:A("actions"),items:e==null?void 0:e.action,onItemClick:N=>{!N||ue(N)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:ee,tooltip:A("reports"),items:e==null?void 0:e.print,onItemClick:N=>{!N||ue({...N,datas:{...N.datas||{},ids:[d]}})}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.EnterOutlined,{}),disabled:ee,tooltip:A("related"),items:e==null?void 0:e.relate,onItemClick:async N=>{!N||Q({relateData:N,values:w.current.getValues(),fields:w.current.getFields(),action_id:N.id,action_type:N.type})}}),jsxRuntime.jsx(AttachmentsButton,{disabled:ee,attachments:O,onAddNewAttachment:()=>{const N=d,U=I;oe({model:"ir.attachment",values:{selection_associated_object:`${U},${N}`},forced_values:{res_model:U,res_id:N},initialViewType:"form"})},onListAllAttachments:()=>{const N=d;oe({model:"ir.attachment",domain:[["res_model","=",`${I}`],["res_id","=",`${N}`]],initialViewType:"tree"})},onViewAttachmentDetails:N=>{oe({model:"ir.attachment",res_id:N.id,initialViewType:"form"})}})]}):null}function separator$2(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const LinkInput=e=>{const{ooui:o,value:r,onChange:a,valueValidator:s,linkPrefix:c=""}=e,{id:l,readOnly:d,required:u}=o,f=u&&!d?Config.requiredClass:void 0,p=React.useContext(FormContext$1),{elementHasLostFocus:m}=p||{},[I,h]=React.useState(!1),[v,C]=React.useState(!1);React.useEffect(()=>{d&&!I&&C(!1),!r&&!d&&(h(!0),C(!0))},[I,d]);const b=y=>{a==null||a(y.target.value)};return jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,align:"middle",children:[d?null:jsxRuntime.jsx(antd.Col,{flex:"32px",children:I?jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),onClick:()=>{s(r)&&(h(!1),C(!1))},tabIndex:-1}):jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EditOutlined,{}),onClick:()=>{h(!0),C(!0)},tabIndex:-1})}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:v?jsxRuntime.jsx(antd.Input,{id:l,onChange:b,className:f,value:r,onBlur:()=>{s(r)&&(h(!1),C(!1),m==null||m())}}):jsxRuntime.jsx("a",{href:`${c}${r}`,style:{color:"#1890ff",paddingRight:15},target:"_blank",children:r})})]})},Url=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,valueValidator:a=>a?isURL(a):!1})})},Email=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,linkPrefix:"mailto:",valueValidator:a=>a?isEmail(a):!1})})},GoToResourceModal=e=>{const{visible:o,onIdSubmitted:r,onCancel:a,isSearching:s}=e,{t:c}=React.useContext(LocaleContext);function l(d){r(d.id)}return jsxRuntime.jsx(antd.Modal,{title:c("goToResourceId"),centered:!0,visible:o,footer:null,destroyOnClose:!0,onCancel:a,maskClosable:!1,children:jsxRuntime.jsxs(antd.Form,{layout:"vertical",onFinish:l,autoComplete:"off",children:[jsxRuntime.jsx(antd.Form.Item,{name:"id",label:c("searchId"),rules:[{required:!0,type:"number"}],children:jsxRuntime.jsx(antd.InputNumber,{style:{width:"100%"},autoFocus:!0})}),jsxRuntime.jsx(antd.Row,{align:"middle",justify:"end",children:jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CloseOutlined,{}),htmlType:"button",onClick:a,disabled:s,children:c("cancel")}),jsxRuntime.jsx(antd.Button,{loading:s,style:{marginLeft:15},icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:s,children:c("ok")})]})})})]})})};function ButtonWithBadge(e){const{badgeNumber:o=0,...r}=e;return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:jsxRuntime.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:"#1890FF",color:"#fefefe"},children:o})}),jsxRuntime.jsx(ButtonWithTooltip,{...r,style:{width:46,zIndex:0}})]})}function GraphActionBar({refreshGraph:e}){const{t:o}=React.useContext(LocaleContext),{availableViews:r,currentView:a,setCurrentView:s,searchParams:c,searchVisible:l,setSearchVisible:d,graphIsLoading:u,previousView:f,setPreviousView:p}=React.useContext(ActionViewContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:l?"white":void 0}}),tooltip:o("advanced_search"),type:l?"primary":"default",onClick:()=>{d==null||d(!l)},disabled:u,badgeNumber:c==null?void 0:c.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:o("refresh"),disabled:u,loading:!1,onClick:()=>{e()}}),jsxRuntime.jsx(ChangeViewButton,{currentView:a,availableViews:r,onChangeView:m=>{p==null||p(a),s==null||s(m)},disabled:!1,previousView:f})]})}const{Title:Title$1,Text:Text$1}=antd.Typography;function TitleHeader(e){const{title:o,children:r}=e,{title:a,currentView:s,currentId:c,currentItemIndex:l,results:d,totalItems:u,selectedRowItems:f}=React.useContext(ActionViewContext),{t:p}=React.useContext(LocaleContext);function m(){if((s==null?void 0:s.type)==="form")return c?u===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("editingDocument")," (id: ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("register")," ",l===void 0?1:l+1," /"," ",d.length," ",p("of")," ",u," - ",p("editingDocument")," (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):"";if((s==null?void 0:s.type)==="tree"&&f){if(f.length===1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["1 ",p("selectedRegisters")," - (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:f[0].id}),")"]});if(f.length>1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f.length," ",p("selectedRegisters"),jsxRuntime.jsx(Text$1,{copyable:{text:f.map(I=>I.id).join(", ")}})]})}return null}return jsxRuntime.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[jsxRuntime.jsxs(antd.Row,{className:"rounded shadow-md bg-blueGray-100",style:{padding:"1em"},align:"middle",children:[jsxRuntime.jsxs(antd.Col,{flex:2,children:[jsxRuntime.jsx(Title$1,{level:3,style:{marginBottom:0},children:o||a}),m()]}),jsxRuntime.jsx(antd.Col,{flex:3,children:jsxRuntime.jsx(antd.Row,{justify:"end",children:r})})]}),jsxRuntime.jsx("div",{className:"pb-5"})]})}const GraphActionView=e=>{const{viewData:o,visible:r,model:a,context:s,domain:c,formView:l,treeView:d}=e,u=React.useRef(),f=React.useContext(ActionViewContext),{setResults:p=void 0,setCurrentItemIndex:m=void 0,currentId:I=void 0,results:h=void 0,setSelectedRowItems:v=void 0,setSearchParams:C=void 0,searchVisible:b=!0,setSearchVisible:y=void 0,sorter:g=void 0,setSorter:O=void 0,setTotalItems:w=void 0,setSearchTreeNameSearch:_=void 0,setTreeIsLoading:F=void 0,limit:L,setLimit:E,searchParams:P,searchValues:A,setSearchValues:W,currentView:J}=f||{},[Y,z]=React.useState(!0);React.useEffect(()=>{var Re;(Re=u.current)==null||Re.refresh()},[P]),React.useEffect(()=>{o.view_id!==J.view_id&&z(!0)},[J]);const{clear:Q,searchFilterLoading:oe,searchError:te,offset:X,tableRefreshing:ce}=useSearch({model:a,setSearchTreeNameSearch:_,setSelectedRowItems:v,searchParams:P,setSearchValues:W,setSearchParams:C,setSearchVisible:y,setTreeIsLoading:F,context:s,formView:l,treeView:d,sorter:g,setSorter:O,setCurrentItemIndex:m,setResultsActionView:p,resultsActionView:h,domain:c,currentId:I,setActionViewTotalItems:w,limit:L,setLimit:E});return!r||!o?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{title:o.name,children:jsxRuntime.jsx(GraphActionBar,{refreshGraph:()=>{u.current.refresh()}})}),jsxRuntime.jsx(SearchFilter,{fields:{...d.fields,...l.fields},searchFields:mergeSearchFields([l.search_fields,d.search_fields]),limit:L,onClear:Q,offset:X,isSearching:oe,onSubmit:Re=>{z(!1),C==null||C(Re.params),y==null||y(!1)},searchError:te,searchVisible:b,searchValues:A,showLimitOptions:!1}),ce?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Graph,{ref:u,view_id:o.view_id,model:a,context:s,domain:mergeParams(P||[],c),limit:Y?L:void 0,manualIds:Y?h==null?void 0:h.map(Re=>Re.id):void 0})]})},FormActionView=e=>{const{visible:o,formRef:r,model:a,currentId:s,domain:c,formView:l,context:d,defaultValues:u,forcedValues:f,results:p,setResults:m,setCurrentItemIndex:I}=e;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(FormActionBar,{toolbar:l==null?void 0:l.toolbar})}),jsxRuntime.jsx(Form$1,{rootForm:!0,ref:r,model:a,defaultValues:u,forcedValues:f,formView:l,actionDomain:c,id:s,parentContext:d,onSubmitSucceed:(h,v)=>{p.findIndex(b=>b.id===h)===-1&&(p.push(v),m(p),I(p.length-1))}})]}):null};function SearchBar(e){const{onSearch:o,disabled:r=!1,searchText:a}=e,{t:s}=React.useContext(LocaleContext),[c]=antd.Form.useForm(),[l,d]=React.useState(!1);function u(p){o(p.search)}React.useEffect(()=>{c.setFieldsValue({search:a})},[a]);function f(){d(!1),c.setFieldsValue({search:void 0}),o(void 0)}return jsxRuntime.jsx(antd.Form,{form:c,onFinish:u,autoComplete:"off",children:jsxRuntime.jsxs(antd.Row,{align:"middle",justify:"end",children:[jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Form.Item,{name:"search",noStyle:!0,children:jsxRuntime.jsx(antd.Input,{autoFocus:!0,disabled:r,onChange:p=>{d(p.target.value.length>0)},suffix:(l||a&&a.length>0)&&jsxRuntime.jsx(antd.Tooltip,{title:s("clear"),children:jsxRuntime.jsx(Icon.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:f})})})})}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Button,{htmlType:"submit",disabled:r,children:s("search")})})]})})}function TreeActionBar(e){var xe,de;const{availableViews:o,currentView:r,setCurrentView:a,selectedRowItems:s,setRemovingItem:c,removingItem:l,duplicatingItem:d,setDuplicatingItem:u,currentModel:f,searchTreeRef:p,setCurrentId:m,setCurrentItemIndex:I,searchParams:h,searchVisible:v,setSearchVisible:C,setSearchTreeNameSearch:b,searchTreeNameSearch:y,treeIsLoading:g,setPreviousView:O,previousView:w,results:_,limit:F,totalItems:L}=React.useContext(ActionViewContext),{parentContext:E={},treeExpandable:P,toolbar:A}=e,{t:W,lang:J}=React.useContext(LocaleContext),Y=React.useContext(ContentRootContext),{processAction:z}=Y||{},[Q,oe]=React.useState(!1);function te(){showDialog$9({confirmMessage:W("confirmRemove"),lang:J,onOk:()=>{X()}})}async function X(){var Ce;try{c==null||c(!0),await ConnectionProvider.getHandler().delete({model:f,ids:s.map(ee=>ee.id)}),m==null||m(void 0),I==null||I(void 0),(Ce=p==null?void 0:p.current)==null||Ce.refreshResults()}catch(ee){showDialog$8(ee)}finally{c==null||c(!1)}}async function ce(){var Ce;try{u==null||u(!0);const ee=s[0].id;await ConnectionProvider.getHandler().duplicate({id:ee,model:f,context:{...E}})&&((Ce=p==null?void 0:p.current)==null||Ce.refreshResults())}catch(ee){showDialog$8(ee)}finally{u==null||u(!1)}}function Re(Ce){z==null||z({actionData:Ce,values:{active_id:s==null?void 0:s.map(ee=>ee.id)[0],active_ids:s==null?void 0:s.map(ee=>ee.id)},fields:{},context:{...E,active_id:s==null?void 0:s.map(ee=>ee.id)[0],active_ids:s==null?void 0:s.map(ee=>ee.id)},onRefreshParentValues:()=>{var ee;(ee=p==null?void 0:p.current)==null||ee.refreshResults()}})}return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[P?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SearchBar,{disabled:d||l||g,searchText:y,onSearch:Ce=>{Ce&&Ce.trim().length>0?b==null||b(Ce):b==null||b(void 0)}}),separator$1(),jsxRuntime.jsx(NewButton,{disabled:g}),separator$1(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:W("duplicate"),disabled:!s||(s==null?void 0:s.length)!==1||d||g,loading:d,onClick:ce}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:W("delete"),disabled:!(s&&(s==null?void 0:s.length)>0)||g,loading:l,onClick:te}),separator$1()]}),!P&&jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:v?"white":void 0}}),tooltip:W("advanced_search"),type:v?"primary":"default",onClick:()=>{C==null||C(!v)},disabled:d||l||g,badgeNumber:h==null?void 0:h.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:W("showLogs"),disabled:!(s&&(s==null?void 0:s.length)>0)||g,loading:!1,onClick:()=>{showLogInfo(f,s[0].id,W)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:W("refresh"),disabled:d||l||g,loading:!1,onClick:()=>{var Ce;(Ce=p==null?void 0:p.current)==null||Ce.refreshResults()}}),!P&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[separator$1(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,availableViews:o,onChangeView:Ce=>{O==null||O(r),a==null||a(Ce)},previousView:w,disabled:g})]}),separator$1(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ExportOutlined,{}),tooltip:W("export"),disabled:d||l||g,loading:!1,onClick:()=>{oe(!0)}}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||g,tooltip:W("actions"),items:A==null?void 0:A.action,onItemClick:Ce=>{!Ce||Re(Ce)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||g,tooltip:W("reports"),items:A==null?void 0:A.print,onItemClick:Ce=>{!Ce||Re({...Ce,datas:{...Ce.datas||{},ids:s.map(ee=>ee.id)}})}}),jsxRuntime.jsx(ExportModal,{visible:Q,locale:J,onClose:()=>oe(!1),model:f,treeFields:(xe=p==null?void 0:p.current)==null?void 0:xe.getFields(),domain:mergeParams(((de=p==null?void 0:p.current)==null?void 0:de.getDomain())||[],h||[]),limit:F,totalRegisters:L,selectedRegistersToExport:_&&_.length&&_.length>0?_.length:void 0,context:E})]})}function separator$1(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const TreeActionView=e=>{const{visible:o,searchTreeRef:r,model:a,context:s,formView:c,treeView:l,domain:d,setCurrentItemIndex:u,results:f,setCurrentId:p,setCurrentView:m,availableViews:I,searchTreeNameSearch:h}=e;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(TreeActionBar,{toolbar:c==null?void 0:c.toolbar,parentContext:s,treeExpandable:(l==null?void 0:l.isExpandable)||!1})}),jsxRuntime.jsx(SearchTree$1,{ref:r,rootTree:!0,model:a,parentContext:s,nameSearch:h,formView:c,treeView:l,domain:d,onRowClicked:v=>{const{id:C}=v;p(C);const b=f.findIndex(g=>g.id===C);u(b);const y=I.find(g=>g.type==="form");m(y)}})]}):null},DashboardActionContext=React__default.default.createContext(null),DashboardActionProvider=e=>{const[o,r]=React.useState(!1),[a,s]=React.useState(!1),{children:c,dashboardRef:l,openAction:d}=e;return jsxRuntime.jsx(DashboardActionContext.Provider,{value:{isLoading:o,setIsLoading:r,dashboardRef:l,openAction:d,moveItemsEnabled:a,setMoveItemsEnabled:s},children:c})};function DashboardActionBar(){const{isLoading:e,dashboardRef:o,moveItemsEnabled:r,setMoveItemsEnabled:a}=React.useContext(DashboardActionContext),{t:s}=React.useContext(LocaleContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.BorderOuterOutlined,{style:{color:r?"white":void 0}}),type:r?"primary":"default",tooltip:s("moveDashboard"),disabled:e,loading:!1,onClick:()=>{a(!r)}}),separator(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SettingOutlined,{}),tooltip:s("configDashboard"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.configDashboard()}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:s("refresh"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.refresh()}})]})}function separator(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const DashboardActionView=e=>{const{dashboardData:o}=e,r=React.useRef(),a=React.useContext(TabManagerContext),{openShortcut:s}=a||{};return o?jsxRuntime.jsxs(DashboardActionProvider,{dashboardRef:r,openAction:c=>{s(c)},children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(DashboardActionBar,{})}),jsxRuntime.jsx(Dashboard$1,{ref:r,model:o.model,id:o.id,context:o==null?void 0:o.context,configAction:o==null?void 0:o.configAction})]}):null};function ActionView(e,o){const{domain:r,model:a,context:s,views:c,title:l,setCanWeClose:d,tabKey:u,initialView:f,formDefaultValues:p,formForcedValues:m={},res_id:I=!1,action_id:h,action_type:v,treeExpandable:C=!1,limit:b}=e,[y,g]=React.useState(),[O,w]=React.useState([]),[_,F]=React.useState(!0),L=I||void 0,[E,P]=React.useState(L),[A,W]=React.useState([]),[J,Y]=React.useState(),[z,Q]=React.useState([]),[oe,te]=React.useState(),[X,ce]=React.useState(0),[Re,xe]=React.useState(!1),[de,Ce]=React.useState(!1),[ee,ue]=React.useState(),{t:N}=React.useContext(LocaleContext),U=React.useRef(),re=React.useRef(),Te=React.useContext(TabManagerContext),{setCurrentView:Fe,setCurrentId:M,tabs:j,activeKey:we,openAction:je}=Te||{};reactHotkeysHook.useHotkeys("ctrl+g,command+g",Ct=>{Ct.preventDefault(),Tt()},[we,j,y,J,z]);function tt(Ct){P(Ct),M==null||M(Ct)}function Ne(Ct){g(Ct),Fe==null||Fe(Ct)}React.useImperativeHandle(o,()=>({canWeClose:yt}));const Ge=async()=>{F(!0);const Ct=[];for(const Ft of c){const[Ut,Gt]=Ft;let Qt;try{Gt!=="dashboard"&&(Qt=await ConnectionProvider.getHandler().getView({model:a,type:Gt,id:Ut,context:s}))}catch(Wt){console.error(`${a} - ${Gt}\xA0- ${JSON.stringify(Wt,null,2)}`);continue}switch(Gt){case"dashboard":{const Wt=c.find(un=>{const[,_t]=un;return _t==="form"});let fn;Wt&&(fn={action_id:h,action_type:v,name:l,res_id:s.active_id,res_model:a,view_id:Wt[0],view_type:Wt[1]}),Ct.push({type:"dashboard",id:s.active_id,model:a,context:s,configAction:fn});break}case"form":{Ct.push({...Qt});break}case"tree":{Ct.push({...Qt,isExpandable:C});break}case"graph":{Ct.push({...Qt});break}}}if(!f&&Ct.find(Ft=>Ft.type==="tree")){const Ft=Ct.find(Ut=>Ut.type==="tree");Ne(Ft)}else if(f){const Ft=Ct.find(Ut=>f.id?Ut.type===f.type&&Ut.view_id===f.id:Ut.type===f.type);Ne(Ft)}else{const Ft=Ct.find(Ut=>Ut.type==="form");Ne(Ft)}w(Ct),F(!1)};d({tabKey:u,canWeClose:yt}),React.useEffect(()=>{const Ct=O.find(Ut=>Ut.type==="tree"),Ft=O.find(Ut=>f.id?Ut.type===f.type&&Ut.view_id===f.id:Ut.type===f.type);Ne(Ft||Ct),I?M==null||M(L):(tt(void 0),Y(void 0)),Ge()},[a,c,I]),React.useEffect(()=>{we===u&&(M==null||M(E),Fe==null||Fe(y))},[j,we]);async function yt(){return y.type==="form"?await U.current.cancelUnsavedChanges():!0}async function Tt(){we===u&&(y.type==="form"&&!await U.current.cancelUnsavedChanges()||xe(!0))}async function Ot(Ct){var Qt;Ce(!0);const Ft=z.findIndex(Wt=>Wt.id===Ct);let Ut;if(Ft===-1){try{Ut=(Qt=await ConnectionProvider.getHandler().readObjects({model:a,ids:[Ct],context:s}))==null?void 0:Qt[0]}catch{}if(!Ut){Ce(!1),xe(!1),showDialog$7(N("idNotFound"));return}}else Ut=z[Ft];Ce(!1),xe(!1);const Gt=c.find(Wt=>Wt[1]==="form");je({domain:[],context:s,model:a,views:c,title:l,target:"current",initialView:{id:Gt==null?void 0:Gt[0],type:"form"},action_id:h,action_type:v,res_id:Ct})}function $t(){return O.map(Ct=>{switch(Ct.type){case"form":return jsxRuntime.jsx(FormActionView,{formRef:U,currentId:E,visible:y.type===Ct.type&&y.view_id===Ct.view_id,formView:Ct,model:a,context:s,domain:r,defaultValues:p,forcedValues:m,results:z,setResults:Q,setCurrentItemIndex:Y},`${Ct.type}-${Ct.view_id}`);case"tree":return jsxRuntime.jsx(TreeActionView,{visible:y.type===Ct.type&&y.view_id===Ct.view_id,limit:b,model:a,context:s,domain:r,formView:O.find(Ft=>Ft.type==="form"),treeView:Ct,searchTreeRef:re,searchTreeNameSearch:ee,availableViews:O,results:z,setCurrentItemIndex:Y,setCurrentId:tt,setCurrentView:Ne},`${Ct.type}-${Ct.view_id}`);case"graph":return jsxRuntime.jsx(GraphActionView,{visible:y.type===Ct.type&&y.view_id===Ct.view_id,viewData:Ct,model:a,context:s,domain:r,treeView:O.find(Ft=>Ft.type==="tree"),formView:O.find(Ft=>Ft.type==="form")},`${Ct.type}-${Ct.view_id}`);case"dashboard":return jsxRuntime.jsx(DashboardActionView,{dashboardData:Ct},`${Ct.type}-${Ct.view_id}`)}})}function Vt(){if(E===void 0&&y.type==="form")U.current.clearAndReload();else{tt(void 0);const Ct=O.find(Ft=>Ft.type==="form");Ne(Ct)}}return _?jsxRuntime.jsx(antd.Spin,{}):y?jsxRuntime.jsxs(ActionViewProvider,{title:l,currentView:y,setCurrentView:Ne,availableViews:O,formRef:U,searchTreeRef:re,onNewClicked:Vt,currentId:E,setCurrentId:tt,setCurrentItemIndex:Y,currentItemIndex:J,results:z,setResults:Q,currentModel:a,sorter:oe,setSorter:te,totalItems:X,setTotalItems:ce,selectedRowItems:A,setSelectedRowItems:W,setSearchTreeNameSearch:ue,searchTreeNameSearch:ee,goToResourceId:Ot,limit:b,children:[$t(),jsxRuntime.jsx(GoToResourceModal,{visible:Re,onIdSubmitted:Ot,isSearching:de,onCancel:()=>{xe(!1)}})]}):null}const ActionView$1=React.forwardRef(ActionView);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return typeof e=="string"&®EX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(byteToHex[e[o+0]]+byteToHex[e[o+1]]+byteToHex[e[o+2]]+byteToHex[e[o+3]]+"-"+byteToHex[e[o+4]]+byteToHex[e[o+5]]+"-"+byteToHex[e[o+6]]+byteToHex[e[o+7]]+"-"+byteToHex[e[o+8]]+byteToHex[e[o+9]]+"-"+byteToHex[e[o+10]]+byteToHex[e[o+11]]+byteToHex[e[o+12]]+byteToHex[e[o+13]]+byteToHex[e[o+14]]+byteToHex[e[o+15]]).toLowerCase();if(!validate(r))throw TypeError("Stringified UUID is invalid");return r}function v4(e,o,r){e=e||{};var a=e.random||(e.rng||rng)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,o){r=r||0;for(var s=0;s<16;++s)o[r+s]=a[s];return o}return stringify(a)}async function fetchAction({actionId:e,rootContext:o={},globalValues:r={}}){const a="ir.actions.act_window",s=`${a},${e}`,c=await ConnectionProvider.getHandler().getActionData({action:s,context:o}),l=ooui.parseContext({context:c.context,values:r,fields:{}}),d=c.domain?await ConnectionProvider.getHandler().evalDomain({domain:c.domain,values:r,context:{...o,...l}}):[],{res_model:u,views:f,name:p,limit:m,view_type:I}=c,h=I==="tree",v=[];for(const g of f){const[O,w]=g;if(O)v.push(g);else{const{view_id:_}=await ConnectionProvider.getHandler().getView({model:u,type:w,id:O,context:{...o,...l}});v.push([_,w])}}const[C,b]=v[0],y={id:C,type:b};return{title:p,actionId:e,actionType:a,key:v4(),views:f,model:u,context:{...o,...l},domain:d,initialView:y,limit:m,treeExpandable:h}}const styles$1="",styles="",ResponsiveReactGridLayout=reactGridLayout.WidthProvider(reactGridLayout.Responsive),DashboardGrid=e=>{const{children:o=[],onPositionItemsChanged:r}=e,a=React__default.default.Children.map(o,s=>{const{parms:c,id:l}=s.props;return jsxRuntime.jsx("div",{"data-grid":c,children:s},l)});return jsxRuntime.jsx(ResponsiveReactGridLayout,{className:"layout",cols:{lg:12,md:10,sm:6,xs:4,xxs:2},draggableHandle:".draggable-head",rowHeight:30,onLayoutChange:s=>{r==null||r(s.map(c=>({id:parseInt(c.i.replace(".$",""),10),x:c.x,y:c.y,w:c.w,h:c.h})))},children:a})},{Text}=antd.Typography,DashboardGridItem=e=>{const{id:o,title:r,children:a,action:s,openAction:c}=e;return jsxRuntime.jsxs("div",{className:"shadow-md rounded",style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #eee",backgroundColor:"white"},children:[jsxRuntime.jsxs(antd.Row,{className:"bg-blueGray-100",align:"middle",style:{borderBottom:"1px solid #ddd"},wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"auto",className:"draggable-head",style:{fontWeight:"bold",padding:"0.5rem",cursor:"grab",overflow:"hidden"},children:jsxRuntime.jsx(Text,{ellipsis:!0,children:r})}),s&&jsxRuntime.jsx(antd.Col,{flex:"25px",style:{padding:"0.5rem"},children:jsxRuntime.jsx(antd.Row,{justify:"end",align:"middle",children:jsxRuntime.jsx(Icon.ExportOutlined,{style:{cursor:"pointer"},onClick:()=>{c==null||c(s)}})})})]}),a]})},DEFAULT_SEARCH_LIMIT=80;function DashboardTree(e){const{action:o,model:r,view_id:a,onRowClicked:s,domain:c=[],visible:l=!0,parentContext:d={}}=e,[u,f]=React.useState(!1),[p,m]=React.useState(!1),[I,h]=React.useState(),[v,C]=React.useState(),[b,y]=React.useState(),[g,O]=React.useState(1),[w,_]=React.useState(0),F=React.useRef(DEFAULT_SEARCH_LIMIT),L=React.useRef([]),[E,P]=React.useState(0),[A,W]=React.useState([]),[J,Y]=React.useState(void 0),[z,Q]=React.useState(),[oe,te]=React.useState(),[X,ce]=React.useState(),[Re,xe]=React.useState(!1),de=React.useRef([]),Ce=M=>{xe(!0),O(M),_((M-1)*F.current)},ee=async()=>{const M=de.current.length>0?de.current:c,j=mergeParams(L.current,M),{colors:we}=getTree(v),{totalItems:je,results:tt,attrsEvaluated:Ne}=await ConnectionProvider.getHandler().searchForTree({params:j,limit:F.current,offset:w,model:I,fields:v.fields,context:d,attrs:we&&{colors:we}}),Ge=await je;P(Ge),Y(getColorMap(Ne));const yt=sortResults({resultsToSort:tt,sorter:z,fields:{...v.fields,...b.fields}});W(yt)},ue=async()=>{try{xe(!0),await ee()}catch(M){te(JSON.stringify(M))}finally{xe(!1)}};React.useEffect(()=>{!p||l&&ue()},[g,w,p,l]);const N=async M=>{m(!1),f(!0),ce(void 0);try{M==="action"?await U():await re(),m(!0)}catch(j){ce(j)}finally{f(!1)}},U=async()=>{const M=await ConnectionProvider.getHandler().getViewsForAction({action:o,context:d});de.current=M.domain,y(M.views.get("form")),C(M.views.get("tree")),h(M.model),F.current=M.limit},re=async()=>{h(r);const M=await ConnectionProvider.getHandler().getView({model:r,type:"form",context:d});y(M);const j=await ConnectionProvider.getHandler().getView({model:r,type:"tree",id:a,context:d});C(j)};React.useEffect(()=>{o?N("action"):r&&N("model")},[o,r]);const Te=M=>{const{id:j}=M;s({id:j,model:I,treeView:v})},Fe=()=>!v||!b?null:jsxRuntime.jsxs("div",{style:{overflowY:"scroll"},children:[oe&&jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:oe,type:"error",banner:!0}),jsxRuntime.jsx(Tree,{showPagination:!1,total:E,limit:F.current,page:g,treeView:v,results:A,onRequestPageChange:Ce,loading:Re,onRowClicked:Te,colorsForResults:J,sorter:z,onChangeSort:M=>{Q==null||Q(M);const j=sortResults({resultsToSort:A,sorter:M,fields:{...v.fields,...b.fields}});W(j)}})]});return X?jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:X,type:"error",banner:!0}):u?jsxRuntime.jsx(antd.Spin,{style:{padding:"2rem"}}):Fe()}const DashboardForm=e=>{const{model:o}=e,[r,a]=React.useState();React.useEffect(()=>{s()},[o]);async function s(){const c=await ConnectionProvider.getHandler().search({params:[],model:o,limit:1});c.length>0&&a(c[0].id)}return jsxRuntime.jsx("div",{style:{padding:"0.5rem",overflowY:"scroll"},children:jsxRuntime.jsx(Form$1,{...e,model:o,id:r,readOnly:!0})})},itemsField="line_ids";function Dashboard(e,o){const{model:r,context:a={},id:s,configAction:c}=e,[l,d]=React.useState([]),[u,f]=React.useState(!1),[p,m]=React.useState(),{setIsLoading:I,openAction:h,moveItemsEnabled:v}=React.useContext(DashboardActionContext),C=React.useRef(),b=React.useRef();React.useEffect(()=>{y()},[r,s,a]),React.useImperativeHandle(o,()=>({refresh:()=>{y()},configDashboard:L}));async function y(){f(!0),I(!0),m(void 0);try{const E=await g(),P=await w(E),A=E.fields[itemsField].relation,W=P[itemsField].items;b.current=E.fields;const J=await O({items:W,model:A,context:a}),Y=await _(J);d(Y),f(!1),I(!1)}catch(E){m(JSON.stringify(E))}}async function g(){return await ConnectionProvider.getHandler().getView({model:r,type:"form",context:a})}async function O({items:E,model:P,context:A}){return C.current=(await ConnectionProvider.getHandler().getView({model:P,type:"form",context:A})).fields,await readObjectValues({treeFields:C.current,formFields:C.current,model:P,items:E,context:A})}async function w(E){return(await ConnectionProvider.getHandler().readObjects({model:r,ids:[s],fields:E.fields,context:a}))[0]}async function _(E){const P=[];for(const A of E){const{values:W}=A;if(W.action_id&&W.action_id.length>0){const J=parseInt(W.action_id[0],10),Y=await fetchAction({actionId:J,rootContext:a});P.push({...A,actionData:Y})}}return P}async function F(E){if(!v)return;const P=E.filter(Y=>{const z=l.find(oe=>oe.id===Y.id);if(!z)return!1;if(!z.position)return!0;const Q={...JSON.parse(z.position.replace(/'/g,'"')),id:z.id};return JSON.stringify(Y)!==JSON.stringify(Q)});if(P.length===0)return;const W=l.filter(Y=>P.map(z=>z.id).includes(Y.id)).map(Y=>{const z={...P.find(Q=>Q.id===Y.id)};return delete z.id,{...Y},{...Y,operation:"pendingUpdate",values:{...Y.values,position:JSON.stringify(z).replace(/"/g,"'")}}}),J={fields:C.current,items:W};await ConnectionProvider.getHandler().update({model:r,id:s,values:{[itemsField]:J},fields:b.current,context:a})}async function L(){h(c)}return p?jsxRuntime.jsx(antd.Alert,{className:"mt-10 mb-20",message:p,type:"error",banner:!0}):u?jsxRuntime.jsx(Icon.LoadingOutlined,{}):jsxRuntime.jsx(DashboardGrid,{onPositionItemsChanged:F,children:l.map((E,P)=>{const{actionData:A,values:W}=E,{position:J,id:Y}=W,{actionId:z,actionType:Q,key:oe,title:te,views:X,model:ce,context:Re,domain:xe,initialView:de,limit:Ce}=A;let ee={};try{ee=JSON.parse(J.replace(/'/g,'"'))}catch{ee={x:P*2,y:0,w:2,h:3}}let ue=null;(de==null?void 0:de.type)==="graph"?ue=jsxRuntime.jsx(Graph,{view_id:X.filter(re=>re[1]==="graph")[0][0],model:ce,context:Re,domain:xe,limit:Ce}):(de==null?void 0:de.type)==="form"?ue=jsxRuntime.jsx(DashboardForm,{model:ce,actionDomain:xe}):(de==null?void 0:de.type)==="tree"?ue=jsxRuntime.jsx(DashboardTree,{model:ce,domain:xe,view_id:X.filter(re=>re[1]==="tree")[0][0],onRowClicked:re=>{const Te=X.find(Fe=>{const[,M]=Fe;return M==="form"});if(Te){const[Fe,M]=Te,{actionId:j,actionType:we,title:je,model:tt}=A,Ne={action_id:j,action_type:we,name:je,res_id:re.id,res_model:tt,view_id:Fe,view_type:M};h(Ne)}}}):de!==void 0&&(ue=jsxRuntime.jsx(ActionView$1,{action_id:z,action_type:Q,tabKey:oe,title:te,views:X,model:ce,context:Re,domain:xe,setCanWeClose:()=>{},initialView:de,limit:Ce}));let N;const U=X.find(re=>{const[,Te]=re;return Te==="tree"});if(U){const[re,Te]=U,{actionId:Fe,actionType:M,title:j,model:we}=A;N={action_id:Fe,action_type:M,name:j,res_id:!1,res_model:we,view_id:re,view_type:Te}}return jsxRuntime.jsx(DashboardGridItem,{id:Y,title:te,parms:ee,action:N,openAction:h,children:ue},Y)})})}const Dashboard$1=React.forwardRef(Dashboard),MultiCheckbox=e=>{const{ooui:o}=e;return jsxRuntime.jsx(Field$1,{type:"array",...e,children:jsxRuntime.jsx(MultiCheckboxInput,{ooui:o})})},MultiCheckboxInput=e=>{const{value:o,ooui:r,onChange:a}=e,{items:s=[]}=o||{},c=s.filter(E=>E.operation!=="pendingRemove").map(E=>E.id),[l,d]=React.useState([]),[u,f]=React.useState(),[p,m]=React.useState(!1),{relation:I,context:h,readOnly:v,field:C,columns:b}=r,y=React.useContext(FormContext$1),{getContext:g}=y||{};useDeepCompareEffect__default.default(()=>{w()},[s]);const O=E=>{a==null||a({items:E})};async function w(){m(!0);let E=[];if(r.domain){const P=await ConnectionProvider.getHandler().evalDomain({domain:r.domain,values:transformPlainMany2Ones({fields:y==null?void 0:y.getFields(),values:y.getPlainValues()}),context:y.getContext()});E=[...E,...P]}try{const A=(await ConnectionProvider.getHandler().search({model:I,params:E,fields:[C],context:{...g==null?void 0:g(),...h}})).map(W=>{const J=W[C];let Y=J;return Array.isArray(J)&&(Y=J[1]),{label:Y,value:W.id}});d(A)}catch(P){f(P)}finally{m(!1)}if(u)return jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:u,type:"error",banner:!0})}const _=()=>{L(l.map(E=>E.value))},F=()=>{L([])},L=E=>{const P=s.map(W=>E.includes(W.id)?W.operation=="pendingRemove"?{...W,operation:"original"}:W:{id:W.id,operation:"pendingRemove"}),A=P.map(W=>W.id);E.filter(W=>!A.includes(W)).map(W=>{P.push({id:W,operation:"pendingLink"})}),O(P)};return p&&l.length===0?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsx(antd.Checkbox.Group,{value:l.length?c:[],disabled:v,onChange:L,style:{width:"100%"},children:jsxRuntime.jsx(antd.Row,{children:l.map(E=>jsxRuntime.jsx(antd.Col,{span:Math.floor(24/b),children:jsxRuntime.jsx(antd.Checkbox,{value:E.value,children:E.label})}))})}),!v&&jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{onClick:_,disabled:c.length==l.length,children:"Check all"}),jsxRuntime.jsx(antd.Button,{onClick:F,disabled:c.length===0,children:"Uncheck all"})]})]})})},Radio=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,type:"any",...e,children:jsxRuntime.jsx(SelectionInput,{...e})})},SelectionInput=e=>{const{ooui:o,onChange:r,value:a}=e,{selectionValues:s,readOnly:c,direction:l}=o,d=Array.from(s.entries()),u=d&&d.length&&d.map(f=>{const[p,m]=f;return jsxRuntime.jsx(antd.Radio,{value:p,children:m},p)});return jsxRuntime.jsx(antd.Radio.Group,{disabled:c,onChange:r,value:a,children:jsxRuntime.jsx(antd.Space,{direction:l,children:u})})},Switch=e=>{const{ooui:o}=e,{id:r,readOnly:a,required:s}=o;return jsxRuntime.jsx(Field$1,{...e,valuePropName:"checked",children:jsxRuntime.jsx(SwitchInput,{id:r,readOnly:a,required:s})})},SwitchInput=e=>{const{required:o,readOnly:r,...a}=e;return jsxRuntime.jsx("div",{className:"flex flex-row",children:jsxRuntime.jsx(antd.Switch,{disabled:r,...a})})},Steps=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,type:"any",...e,children:jsxRuntime.jsx(StepsInput,{...e})})},StepsInput=e=>{const{ooui:o,value:r}=e,{selectionValues:a,errorField:s}=o,c=React.useContext(FormContext$1),l=Array.from(a.entries()),d=l.map(p=>p[0]).indexOf(r);let u="process",f="";return s&&(f=c.getFieldValue(s),f&&(u="error")),jsxRuntime.jsx(antd.Steps,{current:d,status:u,children:l.map((p,m)=>jsxRuntime.jsx(antd.Steps.Step,{title:p[1],description:m===d&&u==="error"?f:null}))})},CodeEditor=e=>{const{ooui:o}=e,{lang:r,height:a}=o,s=React.useContext(FormContext$1),{elementHasLostFocus:c}=s||{},l=d=>{d.onDidBlurEditorWidget(c)};return jsxRuntime.jsx(Field$1,{...e,children:jsxRuntime.jsx(Editor__default.default,{defaultLanguage:r||"",height:a||300,onMount:l})})},{Content}=antd.Layout,{Title}=antd.Typography;function Welcome(){const{t:e}=React.useContext(LocaleContext);return jsxRuntime.jsx(Content,{className:"m-5 select-none",children:jsxRuntime.jsx(Title,{level:5,children:e("welcome")})})}function RootView(e,o){const{children:r,globalValues:a={},rootContext:s={},lang:c}=e,[l,d]=React.useState("welcome"),[u,f]=React.useState([{title:tForLang("welcome",c),key:"welcome",closable:!0,content:jsxRuntime.jsx(Welcome,{})}]),p=React.useRef(new Map),m=React.useRef();React.useImperativeHandle(o,()=>({retrieveAndOpenAction:v,openShortcut:y}));function I(w){if(w===l){const _=u.findIndex(F=>F.key===w);u[_-1]&&d(u[_-1].key),u[_+1]&&d(u[_+1].key)}f(u.filter(_=>_.key!==w)),p.current.delete(w)}function h({tabKey:w,canWeClose:_}){p.current.set(w,_)}async function v({action:w,values:_,forced_values:F,initialViewType:L,res_id:E,domain:P=[]}){const A=await ConnectionProvider.getHandler().getActionData({action:w,context:s});if(A.type==="ir.actions.wizard"){showDialog$8("Action type not supported");return}const[W,J]=w.split(","),Y=parseInt(J),z=ooui.parseContext({context:A.context,values:a,fields:{}}),Q=A.domain?await ConnectionProvider.getHandler().evalDomain({domain:A.domain,values:a,context:{...s,...z}}):[],{res_model:oe,views:te,name:X,target:ce,view_type:Re,limit:xe}=A,de=Re==="tree",Ce=[];for(const ue of te){const[N,U]=ue;if(N)Ce.push(ue);else if(U==="dashboard")Ce.push([void 0,"dashboard"]);else{const{view_id:re}=await ConnectionProvider.getHandler().getView({model:oe,type:U,id:N,context:{...s,...z}});Ce.push([re,U])}}let ee;if(L){const[ue,N]=Ce.find(([U,re])=>re===L);ee={id:ue,type:N}}else{const[ue,N]=Ce[0];ee={id:ue,type:N}}O({domain:[...Q,...P],context:{...s,...z},model:oe,views:Ce,title:X,target:ce,initialView:ee,action_type:W,action_id:Y,values:_,forced_values:F,res_id:E,treeExpandable:de,limit:xe})}function C({title:w,content:_,key:F,action:L}){let E=[...u];u.length===1&&u[0].key==="welcome"&&(E=[...u.filter(P=>P.key!=="welcome")]),f([...E,{title:w,key:F,closable:!0,content:_,action:L}]),d(F)}async function b({relateData:w,fields:_,values:F,action_id:L,action_type:E}){const{res_model:P,context:A,domain:W,views:J,target:Y,string:z,limit:Q}=w,[oe,te]=J[0],X={id:oe,type:te},ce=ooui.parseContext({context:A,values:{...F,...a},fields:_}),Re=W?await ConnectionProvider.getHandler().evalDomain({domain:W,values:transformPlainMany2Ones({fields:_,values:{...F,...a}}),context:{...s,...ce}}):[];O({model:P,target:Y,views:J,context:{...s,...ce},domain:Re,title:z,initialView:X,action_id:L,action_type:E,limit:Q})}async function y(w){const{action_id:_,action_type:F,res_id:L,view_id:E}=w,P=`${F},${_}`,A=await ConnectionProvider.getHandler().getActionData({action:P,context:s}),W=ooui.parseContext({context:A.context,values:a,fields:{}}),J=A.domain?await ConnectionProvider.getHandler().evalDomain({domain:A.domain,values:a,context:{...s,...W}}):[],{res_model:Y,views:z,name:Q,target:oe,view_type:te,limit:X}=A,ce=te==="tree",Re=[];for(const ee of z){const[ue,N]=ee;if(ue)Re.push(ee);else if(N==="dashboard")Re.push([void 0,"dashboard"]);else{const{view_id:U}=await ConnectionProvider.getHandler().getView({model:Y,type:N,id:ue,context:{...s,...W}});Re.push([U,N])}}let xe,de;if(E==null){const ee=Re.find(ue=>ue[0]===void 0);xe=void 0,de=ee[1]}else[xe,de]=Re.find(ee=>ee[0]===void 0?!1:ee[0]===E);const Ce={id:xe,type:de};O({domain:J,context:{...s,...W},model:Y,views:Re,title:Q,target:oe,initialView:Ce,action_id:_,action_type:F,res_id:L,treeExpandable:ce,limit:X})}async function g({model:w,values:_,forced_values:F,initialViewType:L,res_id:E,domain:P}){const A=await ConnectionProvider.getHandler().getActionStringForModel(w);await v({action:A,values:_,forced_values:F,initialViewType:L,res_id:E,domain:P})}async function O({domain:w,context:_,model:F,views:L,title:E,target:P,initialView:A,action_id:W,action_type:J,res_id:Y,values:z,forced_values:Q,treeExpandable:oe=!1,limit:te}){const X=v4();if(P!=="current"){const ce=await ConnectionProvider.getHandler().getView({model:F,type:"form",id:A.type==="form"?A.id:void 0,context:{...s,..._}});m.current.openActionModal({domain:w,model:F,formView:ce,context:{...s,..._},actionData:{action_id:W,action_type:J,res_id:Y,view_id:ce.view_id}})}else C({title:E,action:{id:W,type:J},content:jsxRuntime.jsx(ActionView$1,{action_id:W,action_type:J,tabKey:X,title:E,views:L,model:F,context:{...s,..._},domain:w,setCanWeClose:h,initialView:A,res_id:Y,formDefaultValues:z,formForcedValues:Q,treeExpandable:oe,limit:te}),key:X})}return jsxRuntime.jsx(LocaleContextProvider,{lang:c,children:jsxRuntime.jsx(TabManagerProvider,{openShortcut:y,openAction:O,openRelate:b,openDefaultActionForModel:g,tabs:u,activeKey:l,onRemoveTab:async w=>{const _=p.current.get(w);(await(_==null?void 0:_())||l==="welcome")&&I(w)},onChangeTab:w=>{d(w)},children:jsxRuntime.jsx(ContentRootProvider$1,{ref:m,globalValues:a,children:r})})})}const RootView$1=React.forwardRef(RootView);function Tab(e){const{label:o,onClose:r,tabKey:a,isActive:s,onSelected:c}=e,l=s?"#ffffff":"#F1F5F9";return jsxRuntime.jsxs("div",{onClick:()=>{!s&&c(a)},style:{cursor:"pointer",height:40,paddingTop:7,paddingBottom:5,paddingLeft:10,paddingRight:10,backgroundColor:l,display:"inline-flex",flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",borderTopLeftRadius:8,borderTopRightRadius:8,marginLeft:2},children:[jsxRuntime.jsx("div",{style:{color:s?"#001529":"#ADB0B3",userSelect:"none",height:40,display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:5,paddingRight:5,marginBottom:2},children:o}),jsxRuntime.jsx("div",{style:{paddingLeft:5,height:40,display:"flex",justifyContent:"center",alignItems:"center"},children:jsxRuntime.jsx(Icon.CloseOutlined,{style:{color:s?"#001529":"#ADB0B3"},onClick:d=>{d.stopPropagation(),r(a)}})})]})}function TabSelector(){const e=React.useContext(TabManagerContext),{activeKey:o,tabs:r,onRemoveTab:a,onChangeTab:s}=e||{};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r.map(c=>jsxRuntime.jsx(Tab,{tabKey:c.key,label:c.title,onClose:a,isActive:o===c.key,onSelected:s},c.key))})}function TabContent(e){const{tab:o}=e,r=React.useContext(TabManagerContext),{activeKey:a}=r||{},s={display:"none"};return jsxRuntime.jsx("div",{style:o.key!==a?s:void 0,children:o.content})}const TabContent$1=React__default.default.memo(TabContent,()=>!0);function CurrentTabContent(){const e=React.useContext(TabManagerContext),{tabs:o}=e||{},r=(o==null?void 0:o.map(a=>jsxRuntime.jsx(TabContent$1,{tab:a},a.key)))||null;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r})}const FavouriteButton=e=>{const{onRetrieveShortcuts:o,onCheckIsFavourite:r,onAddFavourite:a,onRemoveFavourite:s}=e,[c,l]=React.useState(!1),[d,u]=React.useState(!1),[f,p]=React.useState([]),[m,I]=React.useState(!0),[h,v]=React.useState(),{t:C}=React.useContext(LocaleContext),b=React.useContext(TabManagerContext),{openShortcut:y,tabs:g,activeKey:O,currentView:w,currentId:_,openDefaultActionForModel:F}=b||{};React.useEffect(()=>{L()},[]),React.useEffect(()=>{A()},[g,O,w,_]);async function L(){try{I(!0);const Q=await o();p(Q)}catch(Q){showDialog$8(Q)}finally{I(!1)}}function E(Q){const{key:oe}=Q,te=f.find(X=>X.id===Number(oe));(te==null?void 0:te.action_type)!=="ir.actions.wizard"&&(te&&y(te),u(!1))}function P(Q){Q&&L(),u(Q)}async function A(){if(!w)return;const Q=g.find(xe=>xe.key===O),{id:oe,type:te}=(Q==null?void 0:Q.action)||{};if(!oe||!te){l(!1);return}const X=w.view_id;let ce=!1;w.type==="form"&&(ce=_||!1);const Re=await r({action_id:oe,action_type:te,view_id:X,res_id:ce});Re!==!1&&v(Re),l(Re!==!1)}async function W(){u(!1),F==null||F({model:"ir.ui.view_sc"})}const J=jsxRuntime.jsxs(antd.Menu,{onClick:E,children:[jsxRuntime.jsxs("div",{style:{width:300,padding:5,display:"flex"},children:[jsxRuntime.jsx("div",{style:{paddingLeft:15,color:"#ccc"},children:C("favorites").toUpperCase()}),jsxRuntime.jsx("div",{style:{flexGrow:1,paddingLeft:10},children:jsxRuntime.jsx(antd.Tooltip,{title:C("edit_favorites"),children:jsxRuntime.jsx(Icon.EditOutlined,{style:{color:"#1890FF",cursor:"pointer"},onClick:W})})})]}),jsxRuntime.jsx(antd.Menu.Divider,{}),m?jsxRuntime.jsx(antd.Spin,{style:{padding:"1rem"}}):f.length>0?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f.map(Q=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsx(Y,{title:Q.name,type:Q.view_type})},Q.id))}):jsxRuntime.jsx("div",{style:{width:300,padding:5,paddingLeft:15},children:C("no_favorites")})]});function Y({title:Q,type:oe}){const te=oe==="tree"?jsxRuntime.jsx(Icon.TableOutlined,{}):jsxRuntime.jsx(Icon.FormOutlined,{});return jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:te}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:Q})]})}async function z(){if(c&&h)await s(h);else{if(!w)return;const Q=g.find(Re=>Re.key===O),{id:oe,type:te}=(Q==null?void 0:Q.action)||{},X=w.view_id;let ce=!1;if(!oe||!te){l(!1);return}w.type==="form"&&(ce=_||!1),await a({action_id:oe,action_type:te,view_id:X,res_id:ce})}await L(),l(!c)}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Button,{type:c?"primary":"default",icon:c?jsxRuntime.jsx(Icon.StarFilled,{style:{color:"white"}}):jsxRuntime.jsx(Icon.StarOutlined,{}),style:{width:50},onClick:z}),jsxRuntime.jsx(antd.Dropdown,{overlay:J,onVisibleChange:P,visible:d,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:Q=>Q.preventDefault()})})]})};exports.ActionBar=FormActionBar,exports.Binary=Binary,exports.Boolean=Boolean$1,exports.Button=Button,exports.ButtonGroup=ButtonGroup,exports.Char=Char,exports.CodeEditor=CodeEditor,exports.ConnectionProvider=ConnectionProvider,exports.ContentRootProvider=ContentRootProvider$1,exports.CurrentTabContent=CurrentTabContent,exports.Dashboard=Dashboard$1,exports.DashboardGrid=DashboardGrid,exports.DashboardGridItem=DashboardGridItem,exports.Date=Date$1,exports.DateTime=DateTime,exports.Email=Email,exports.ExportModal=ExportModal,exports.FavouriteButton=FavouriteButton,exports.Float=Float,exports.FloatTime=FloatTime,exports.Form=Form$1,exports.FormModal=FormModal,exports.GraphIndicator=GraphIndicator,exports.Group=Group,exports.Image=Image,exports.Integer=Integer,exports.Label=Label,exports.Many2one=Many2one,exports.MultiCheckbox=MultiCheckbox,exports.Notebook=Notebook,exports.One2many=One2many,exports.ProgressBar=ProgressBar,exports.Radio=Radio,exports.Reference=Reference,exports.RootView=RootView$1,exports.SearchFilter=SearchFilter,exports.SearchModal=SearchModal,exports.SearchTree=SearchTree$1,exports.Selection=Selection,exports.Separator=Separator,exports.Steps=Steps,exports.Switch=Switch,exports.TabSelector=TabSelector,exports.Tags=Tags,exports.Text=Text$2,exports.Tree=Tree,exports.Url=Url,exports.iconMapper=iconMapper,exports.showConfirmDialog=showDialog$9,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
284
|
+
`,cn=({targetKeys:e,locale:o,onGetFields:r,onGetFieldChilds:a,onChange:s,...c})=>{const[l,d]=React.useState(),[u,f]=React.useState(!0),[p,m]=React.useState(),[I,h]=React.useState();React.useEffect(()=>{v()},[]);const v=React.useCallback(async()=>{f(!0);try{const g=await r();d(g)}catch(g){console.error(g),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(g,null,2)})})}f(!1)},[]),C=React.useCallback(async({key:g})=>{try{const O=Z(l).find(F=>F.key===g),w=await a({key:g,title:O.title}),_=Ht(l,g,w);d(_)}catch(O){console.error(O),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}},[l]),b=React.useCallback((g,O)=>{g==="left"?m(O.trim()===""?void 0:O.trim()):h(O.trim()===""?void 0:O.trim())},[]),y=React.useCallback(({checkedKeys:g,onItemSelect:O})=>(w,{node:{key:_}})=>{var F;O(_,(F=_,!g.includes(F)))},[]);return jsxRuntime.jsx(sn,{...c,showSearch:!0,targetKeys:e,dataSource:Z(l),className:"tree-transfer",render:g=>g.title,onChange:s,showSelectAll:!0,locale:{itemUnit:S("exportModalItemsUnit",o),itemsUnit:S("exportModalItemsUnit",o),notFoundContent:S("notFoundContent",o),searchPlaceholder:S("searchPlaceholder",o)},filterOption:Le,onSearch:b,titles:[S("availableFields",o),S("fieldsToExport",o)],children:({direction:g,onItemSelect:O,selectedKeys:w})=>{if(u)return jsxRuntime.jsx("div",{style:{display:"flex",paddingTop:"2em",justifyContent:"center"},children:jsxRuntime.jsx(antd.Spin,{})});if(g==="left"){const _=[...e,...w];return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:_,loadData:C,treeData:Pt({treeNodes:l,checkedKeys:e,searchText:p}),onCheck:y({checkedKeys:_,onItemSelect:O}),onSelect:y({checkedKeys:_,onItemSelect:O}),titleRender:F=>jsxRuntime.jsx(Xe,{node:F})})}return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:w,onCheck:y({checkedKeys:w,onItemSelect:O}),onSelect:y({checkedKeys:w,onItemSelect:O}),treeData:Ie({treeNodes:l,checkedKeys:e,searchText:I}),titleRender:_=>jsxRuntime.jsx(Xe,{node:_})})}})},et=()=>jsxRuntime.jsx("div",{style:{padding:"0.5em"}}),{error:dn}=antd.Modal,Yn=e=>{const{visible:o,locale:r,onCancel:a,onSucceed:s,totalRegisters:c,selectedRegistersToExport:l,selectedKeys:d}=e,{modalWidth:u}=jt(),[f,p]=React.useState(!1),[m,I]=React.useState("csv"),[h,v]=React.useState("all"),[C,b]=React.useState(d);React.useEffect(()=>{o||(b(void 0),I("csv"),v(l?"selected":"all"))},[o]),React.useEffect(()=>{v(l?"selected":"all")},[l]),React.useEffect(()=>{d===void 0||C||b(d)},[d,C]);const y=React.useCallback(O=>{b(O)},[]),g=React.useCallback(async()=>{p(!0);try{await s({exportType:m,selectedKeys:C,registersAmount:h})}catch(O){console.error(O),dn({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}p(!1)},[m,C,h]);return jsxRuntime.jsxs(antd.Modal,{title:S("export",r),centered:!0,width:u,visible:o,closable:!f,onCancel:a,footer:null,destroyOnClose:!0,children:[jsxRuntime.jsx(cn,{targetKeys:C,onChange:y,locale:r,onGetFieldChilds:e.onGetFieldChilds,onGetFields:e.onGetFields}),jsxRuntime.jsx(et,{}),jsxRuntime.jsx(an,{locale:r,value:m,onChange:I}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(et,{}),jsxRuntime.jsx(on,{locale:r,totalRegisters:c,selectedRegistersToExport:l,value:h,onChange:v})]}),jsxRuntime.jsx(antd.Divider,{}),jsxRuntime.jsx(qt,{locale:r,onClose:a,onConfirm:g,loading:f,left:S("exportRegisters",r).replace("{total}",h==="selected"?l==null?void 0:l.toString():c.toString())})]})},ExportModal=e=>{const{visible:o,locale:r,onClose:a,model:s,context:c,treeFields:l,selectedRegistersToExport:d,totalRegisters:u,domain:f,limit:p}=e,m=React.useRef({}),I=React.useCallback(async C=>{if(C.selectedKeys.length===0){showDialog$7(tForLang("selectAtLeastOneField",r));return}const{datas:b}=await ConnectionProvider.getHandler().exportData({model:s,fields:C.selectedKeys,domain:C.registersAmount==="all"?[]:f,limit:C.registersAmount==="all"?void 0:p,context:c,format:C.exportType});a(),await new Promise(g=>setTimeout(g,200));const y=await getMimeType(b);openBase64InNewTab(b,y.mime)},[r,s,f,p,c,a]),h=React.useCallback(async()=>{const C=await ConnectionProvider.getHandler().getFields({model:s,context:c,fields:[]});return m.current["/"]=C,convertToExportField({fields:C})},[s,c,m]),v=React.useCallback(async({key:C,title:b})=>{let y;C.indexOf("/")===-1?y=m.current["/"]:y=m.current[getParentKey(C)];const O=y[getChildKey(C)].relation,w=await ConnectionProvider.getHandler().getFields({model:O,context:c,fields:[]});return m.current[C]=w,convertToExportField({fields:w,parentTitle:b,parentKey:C})},[m,s,c]);return jsxRuntime.jsx(Yn,{visible:o,locale:r,onSucceed:I,onCancel:a,selectedRegistersToExport:d,totalRegisters:u,onGetFieldChilds:v,onGetFields:h,selectedKeys:l?Object.keys(l):void 0})},convertToExportField=({fields:e,parentKey:o,parentTitle:r})=>{const a=[];for(const s of Object.keys(e)){const c=e[s],l=c.type==="many2one"||c.type==="one2many"||c.type==="many2many";a.push({key:`${o?o+"/":""}${s}`,title:`${r?r+"/":""}${c.string}`,tooltip:c.help,required:c.required,isLeaf:!l})}return a},getParentKey=e=>e.indexOf("/")===-1?e:e.split("/").slice(0,-1).join("/"),getChildKey=e=>{if(e.indexOf("/")===-1)return e;const o=e.split("/");return o[o.length-1]},DatePickerConfig={date:{placeholder:"__/__/____",dateDisplayFormat:"YYYY-MM-DD",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"YYYY-MM-DD HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},DatePicker=e=>{const{ooui:o,showTime:r=!1}=e,{required:a}=o;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(DatePickerInput,{ooui:o,showTime:r})})},DatePickerInput=e=>{const{value:o,onChange:r,ooui:a,showTime:s}=e,{id:c,readOnly:l,required:d}=a,u=d&&!l?Config.requiredClass:void 0,f=s?"time":"date",p=v=>{r==null||r(v)},m=v=>{if(v===null){p(void 0);return}p(v.format(DatePickerConfig[f].dateInternalFormat))},I=s?{defaultValue:hooks("00:00:00","HH:mm:ss")}:void 0,h=o?hooks(o,DatePickerConfig[f].dateInternalFormat):void 0;return jsxRuntime.jsx(antd.DatePicker,{style:{width:"100%"},placeholder:s?DatePickerConfig.time.placeholder:DatePickerConfig.date.placeholder,disabled:l,id:c,showTime:I,className:u,format:DatePickerConfig[f].dateDisplayFormat,value:h,onChange:m})},Date$1=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o})},DateTime=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o,showTime:!0})},Reference=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(ReferenceInput,{ooui:o})})},ReferenceInput=e=>{const{value:o,onChange:r,ooui:a}=e,{required:s,selectionValues:c,readOnly:l}=a,d=o==null?void 0:o.split(","),[u,f]=React.useState([]),[p,m]=React.useState();return React.useEffect(()=>{if(!o)return;const I=o&&d&&d[0],h=o&&d&&d[1]&&parseInt(d[1]);f([h,void 0]),m(I)},[o]),jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"1",children:jsxRuntime.jsx(SelectionInput$1,{ooui:new ooui.Selection({name:"model_selection",selection:c,readOnly:l,required:s}),onChange:I=>{m(I),f([]),r==null||r(void 0)},value:p})}),jsxRuntime.jsx(antd.Col,{flex:"3",children:jsxRuntime.jsx(Many2oneInput,{ooui:new ooui.Many2one({name:"object_value",relation:p,readOnly:l,required:s}),value:u,onChange:I=>{f(I);const h=`${p},${I[0]}`;h!==o&&(r==null||r(h))}})})]})},Binary=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(BinaryInput,{ooui:o})})},BinaryInput=e=>{const{ooui:o,value:r,onChange:a}=e,{readOnly:s,required:c,filenameField:l}=o,d=c&&!s?Config.requiredClass:void 0,u=React.useRef(null),{setFieldValue:f,getFieldValue:p}=React.useContext(FormContext$1)||{},{t:m}=React.useContext(LocaleContext),I=r?getFilesize(r):"",h=g=>{a==null||a(g)};async function v(){const g=await getMimeType(r),O=`data:${g==null?void 0:g.mime};base64,${r}`,w=document.createElement("a"),_=p(l),F=p("name");w.href=O,w.download=_||F,w.click()}async function C(){const g=await getMimeType(r);openBase64InNewTab(r,g.mime)}async function b(g){g.stopPropagation(),g.preventDefault();const O=g.target.files[0],w=await toBase64(O);h(w),l&&f(l,O.name)}function y(){f(l,void 0),h(void 0)}return jsxRuntime.jsxs(antd.Row,{gutter:8,children:[jsxRuntime.jsxs(antd.Col,{style:{paddingBottom:5},children:[jsxRuntime.jsx("input",{type:"file",id:"file",ref:u,style:{display:"none"},onChange:b}),jsxRuntime.jsx(antd.Input,{type:"text",disabled:!0,className:d,value:I})]}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.FolderOpenOutlined,{}),disabled:s,onClick:()=>{u.current.click()},children:"Select"}),jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EyeOutlined,{}),disabled:!r,onClick:C,children:m("open")}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("download"),disabled:!r,onClick:v,icon:jsxRuntime.jsx(Icon.DownloadOutlined,{})}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("clear"),disabled:s||!r,onClick:y,icon:jsxRuntime.jsx(Icon.ClearOutlined,{})})]})})]})},iconsForViewTypes={tree:jsxRuntime.jsx(Icon.TableOutlined,{}),form:jsxRuntime.jsx(Icon.FormOutlined,{}),graph:jsxRuntime.jsx(Icon.AreaChartOutlined,{}),calendar:jsxRuntime.jsx(Icon.CalendarOutlined,{})};function getIconForView(e){return e?(iconsForViewTypes==null?void 0:iconsForViewTypes[e.type])||jsxRuntime.jsx(Icon.FormOutlined,{}):jsxRuntime.jsx(Icon.FormOutlined,{})}function ChangeViewButton(e){const{currentView:o,availableViews:r,onChangeView:a,disabled:s=!1,formHasChanges:c=!1,previousView:l}=e,{t:d,lang:u}=React.useContext(LocaleContext);function f(){const I=r.map((h,v)=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:getIconForView(h)}),jsxRuntime.jsx(antd.Col,{flex:"auto",style:{paddingRight:20},children:h.type==="graph"?h.name:h.type.charAt(0).toUpperCase()+h.type.slice(1)}),jsxRuntime.jsx(antd.Col,{flex:"none",children:jsxRuntime.jsx(Icon.CheckOutlined,{style:{opacity:o.view_id===h.view_id?1:0}})})]})},h.view_id||v));return jsxRuntime.jsx(antd.Menu,{onClick:m,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:d("viewAs"),children:I})})}function p(I){if(c){showDialog$6({lang:u,onOk:()=>{I()}});return}I()}function m(I){p(()=>{const h=r.find(v=>v.view_id===parseInt(I.key));a(h)})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ButtonWithTooltip,{tooltip:l?d("viewAs")+" "+d(l.type):"",icon:getIconForView(l),style:{width:50},onClick:()=>{m({key:l==null?void 0:l.view_id})},disabled:s||r.length===1}),jsxRuntime.jsx(antd.Dropdown,{overlay:f(),disabled:s||r.length===1,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:I=>I.preventDefault()})})]})}function DropdownButton(e){const{icon:o,tooltip:r,items:a=[],onItemClick:s,label:c,disabled:l=!1}=e;function d(){const f=a==null?void 0:a.map((p,m)=>p.name==="divider"?jsxRuntime.jsx(antd.Menu.Divider,{},"divider"+m):jsxRuntime.jsx(antd.Menu.Item,{children:p.name},p.id));return jsxRuntime.jsx(antd.Menu,{onClick:u,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:r,children:f})})}function u(f){const p=a.find(m=>isNaN(f.key)?m.id===f.key:m.id===parseInt(f.key));s(p)}return jsxRuntime.jsx(antd.Dropdown,{overlay:d(),disabled:l||!a||a.length===0,children:jsxRuntime.jsxs(antd.Button,{children:[o," ",c," ",jsxRuntime.jsx(Icon.DownOutlined,{})]})})}function ActionButton(e){const{onClick:o,disabled:r=!1,loading:a=!1,tooltip:s,icon:c,label:l,type:d="default"}=e,u=a?jsxRuntime.jsx(Icon.LoadingOutlined,{}):c;return jsxRuntime.jsxs(ButtonWithTooltip,{type:d,tooltip:s,onClick:o,disabled:r,children:[u,l]})}function NewButton(e){const{disabled:o=!1}=e,{formHasChanges:r,onNewClicked:a}=React.useContext(ActionViewContext),{t:s,lang:c}=React.useContext(LocaleContext),l=()=>{if(r){showDialog$6({lang:c,onOk:()=>{a()}});return}a()};return jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.FileAddOutlined,{}),tooltip:s("new"),onClick:l,disabled:o})}const{confirm}=antd.Modal,showDialog=({onOk:e,onCancel:o,lang:r})=>{confirm({title:tForLang("unsavedChanges",r),icon:jsxRuntime.jsx(Icon.ExclamationCircleOutlined,{}),centered:!0,content:tForLang("confirmRefreshWithoutSave",r),okText:tForLang("discardAndRefresh",r),cancelText:tForLang("cancel",r),onOk:e,onCancel:o})};async function showLogInfo(e,o,r){const a=(await ConnectionProvider.getHandler().getLogInfo({model:e,ids:[o]}))[0],{create_date:s,create_uid:c,id:l,write_date:d,write_uid:u}=a;showDialog$7(jsxRuntime.jsxs("div",{children:["ID: "+l," ",jsxRuntime.jsx("br",{}),r("createdBy")+": "+c[1]," ",jsxRuntime.jsx("br",{}),r("creationDate")+": "+s," ",jsxRuntime.jsx("br",{}),r("lastUpdatedBy")+": "+u[1]," ",jsxRuntime.jsx("br",{}),r("lastUpdatedDate")+": "+d]}))}const AttachmentsButtonWrapper=e=>{const{numberOfAttachments:o,disabled:r}=e,{t:a}=React.useContext(LocaleContext),[s,c]=React.useState(!1),l=jsxRuntime.jsxs(antd.Button,{disabled:r,children:[jsxRuntime.jsx(Icon.LinkOutlined,{}),`(${o})`,jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:12}})]});return r?l:jsxRuntime.jsx(antd.Popover,{onVisibleChange:d=>c(d),visible:s,placement:"bottom",content:Content$1(e,c),title:a("attachments"),arrowContent:null,children:l})},Content$1=(e,o)=>{const{attachments:r=[],loading:a,onAddNewAttachment:s,onopenAttachmentLink:c,onOpenAttachmentDetail:l,onListAllAttachments:d}=e,{t:u}=React.useContext(LocaleContext);return a?jsxRuntime.jsx(antd.Spin,{style:{padding:20}}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{o(!1),d()},children:[jsxRuntime.jsx(Icon.TableOutlined,{})," ",u("listAllAttachments")]}),jsxRuntime.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{o(!1),s()},children:[jsxRuntime.jsx(Icon.FileAddOutlined,{})," ",u("addNewAttachment")]}),r.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("li",{className:" ant-dropdown-menu-item-divider"}),r.map(f=>{const p=f.link?Icon.LinkOutlined:Icon.DownloadOutlined;return jsxRuntime.jsxs(antd.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[jsxRuntime.jsx(antd.Col,{flex:"auto",children:f.name}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:(f.datas_fname||f.link)&&jsxRuntime.jsx(antd.Tooltip,{title:f.link?u("openAttachmentLink"):u("download"),children:jsxRuntime.jsx(p,{style:{cursor:"pointer"},onClick:()=>{o(!1),c(f)}})})}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:jsxRuntime.jsx(antd.Tooltip,{title:u("openAttachment"),children:jsxRuntime.jsx(Icon.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{o(!1),l(f)}})})})]},f.id)})]})]})};function AttachmentsButton(e){const{attachments:o,disabled:r=!1,onAddNewAttachment:a,onListAllAttachments:s,onViewAttachmentDetails:c}=e,{formRef:l}=React.useContext(ActionViewContext),[d,u]=React.useState(!1),[f,p]=React.useState([]),[m,I]=React.useState(!1),{t:h}=React.useContext(LocaleContext),v=React.useCallback(async()=>{u(!0);try{const y=await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:o.map(g=>g.id),fieldsToRetrieve:["name","datas_fname","link"],context:l.current.getContext()});p(y.map(g=>({id:g.id,name:g.name,datas_fname:g.datas_fname,link:g.link})))}catch(y){showDialog$8(y)}u(!1)},o),C=React.useCallback(async y=>{if(y.link){window.open(y.link);return}I(!0);let g;try{g=(await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:[y.id],context:l.current.getContext()}))[0]}catch(O){showDialog$8(O)}if(I(!1),!!g)if(g.datas){const O=await getMimeType(g.datas);openBase64InNewTab(g.datas,O.mime)}else c(g)},[]),b=React.useCallback(async y=>{c(y)},[]);return React.useEffect(()=>{v()},[v]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AttachmentsButtonWrapper,{numberOfAttachments:o.length,attachments:f,disabled:r,loading:d,onAddNewAttachment:a,onListAllAttachments:s,onopenAttachmentLink:C,onOpenAttachmentDetail:b}),jsxRuntime.jsx(antd.Modal,{title:h("downloadingAttachment"),visible:m,footer:null,closable:!1,centered:!0,maskClosable:!1,children:jsxRuntime.jsx(antd.Spin,{})})]})}function FormActionBar({toolbar:e}){const{availableViews:o,currentView:r,setCurrentView:a,onFormSave:s,formHasChanges:c,formIsSaving:l,currentId:d,results:u,setCurrentItemIndex:f,currentItemIndex:p,setCurrentId:m,currentModel:I,setRemovingItem:h,removingItem:v,duplicatingItem:C,setDuplicatingItem:b,setResults:y,formIsLoading:g,attachments:O,formRef:w,setFormHasChanges:_,searchTreeRef:F,previousView:L,setPreviousView:E,goToResourceId:P}=React.useContext(ActionViewContext),{t:A,lang:W}=React.useContext(LocaleContext),J=React.useContext(ContentRootContext),{processAction:Y}=J||{},z=React.useContext(TabManagerContext),{openRelate:Q,openDefaultActionForModel:oe}=z||{};function te(N){if(c){showDialog({lang:W,onOk:()=>{N()}});return}N()}function X(N){if(c){showDialog$6({lang:W,onOk:()=>{N()}});return}N()}function ce(){u&&u.length>p+1?(f==null||f(p+1),m==null||m(u[p+1].id)):u&&p+1===u.length&&(f==null||f(0),m==null||m(u[0].id))}function Re(){u&&p>0?(f==null||f(p-1),m==null||m(u[p-1].id)):u&&p===0&&(f==null||f(u.length-1),m==null||m(u[u.length-1].id))}function xe(){showDialog$9({confirmMessage:A("confirmRemoveItem"),lang:W,onOk:()=>{de()}})}async function de(){try{h==null||h(!0),await ConnectionProvider.getHandler().delete({model:I,ids:[d]});const N=u==null?void 0:u.filter(re=>re.id!==d);y==null||y(N);let U=0;p>0&&p<=u.length-1&&(U=p-1),N!=null&&N[U]?(m==null||m(N==null?void 0:N[U].id),f==null||f(U)):(m==null||m(void 0),f==null||f(void 0))}catch(N){showDialog$3(JSON.stringify(N))}finally{h==null||h(!1)}}async function Ce(){try{b==null||b(!0);const N=await ConnectionProvider.getHandler().duplicate({id:d,model:I,context:w.current.getContext()});N&&await(P==null?void 0:P(N))}catch(N){showDialog$3(JSON.stringify(N))}finally{b==null||b(!1)}}const ee=l||v||g||C;function ue(N){Y==null||Y({actionData:N,values:w.current.getValues(),fields:w.current.getFields(),context:w.current.getContext(),onRefreshParentValues:()=>{w.current.fetchValues()}})}return r?jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[g&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Spin,{}),separator$2(),separator$2()]}),jsxRuntime.jsx(NewButton,{disabled:l||g||v||C}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SaveOutlined,{}),tooltip:A("save"),disabled:!c||ee,loading:l,onClick:s}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:A("duplicate"),disabled:c||l||d===void 0||C||g,loading:C,onClick:Ce}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:A("delete"),disabled:l||d===void 0||v||C||g,loading:v,onClick:xe}),separator$2(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:A("showLogs"),disabled:l||d===void 0||v||C||g,loading:!1,onClick:()=>{showLogInfo(I,d,A)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:A("refresh"),disabled:l||d===void 0||v||C||g,loading:!1,onClick:()=>{te(()=>{w.current.fetchValues()})}}),separator$2(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,previousView:L,availableViews:o,onChangeView:N=>{E==null||E(r),_==null||_(!1),a==null||a(N)},disabled:ee,formHasChanges:c}),separator$2(),jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.LeftOutlined,{}),tooltip:A("previous"),disabled:ee,loading:!1,onClick:()=>{X(Re)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.RightOutlined,{}),tooltip:A("next"),disabled:ee,loading:!1,onClick:()=>{X(ce)}})]}),separator$2(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:ee,tooltip:A("actions"),items:e==null?void 0:e.action,onItemClick:N=>{!N||ue(N)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:ee,tooltip:A("reports"),items:e==null?void 0:e.print,onItemClick:N=>{!N||ue({...N,datas:{...N.datas||{},ids:[d]}})}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.EnterOutlined,{}),disabled:ee,tooltip:A("related"),items:e==null?void 0:e.relate,onItemClick:async N=>{!N||Q({relateData:N,values:w.current.getValues(),fields:w.current.getFields(),action_id:N.id,action_type:N.type})}}),jsxRuntime.jsx(AttachmentsButton,{disabled:ee,attachments:O,onAddNewAttachment:()=>{const N=d,U=I;oe({model:"ir.attachment",values:{selection_associated_object:`${U},${N}`},forced_values:{res_model:U,res_id:N},initialViewType:"form"})},onListAllAttachments:()=>{const N=d;oe({model:"ir.attachment",domain:[["res_model","=",`${I}`],["res_id","=",`${N}`]],initialViewType:"tree"})},onViewAttachmentDetails:N=>{oe({model:"ir.attachment",res_id:N.id,initialViewType:"form"})}})]}):null}function separator$2(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const LinkInput=e=>{const{ooui:o,value:r,onChange:a,valueValidator:s,linkPrefix:c=""}=e,{id:l,readOnly:d,required:u}=o,f=u&&!d?Config.requiredClass:void 0,p=React.useContext(FormContext$1),{elementHasLostFocus:m}=p||{},[I,h]=React.useState(!1),[v,C]=React.useState(!1);React.useEffect(()=>{d&&!I&&C(!1),!r&&!d&&(h(!0),C(!0))},[I,d]);const b=y=>{a==null||a(y.target.value)};return jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,align:"middle",children:[d?null:jsxRuntime.jsx(antd.Col,{flex:"32px",children:I?jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),onClick:()=>{s(r)&&(h(!1),C(!1))},tabIndex:-1}):jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EditOutlined,{}),onClick:()=>{h(!0),C(!0)},tabIndex:-1})}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:v?jsxRuntime.jsx(antd.Input,{id:l,onChange:b,className:f,value:r,onBlur:()=>{s(r)&&(h(!1),C(!1),m==null||m())}}):jsxRuntime.jsx("a",{href:`${c}${r}`,style:{color:"#1890ff",paddingRight:15},target:"_blank",children:r})})]})},Url=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,valueValidator:a=>a?isURL(a):!1})})},Email=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,linkPrefix:"mailto:",valueValidator:a=>a?isEmail(a):!1})})},GoToResourceModal=e=>{const{visible:o,onIdSubmitted:r,onCancel:a,isSearching:s}=e,{t:c}=React.useContext(LocaleContext);function l(d){r(d.id)}return jsxRuntime.jsx(antd.Modal,{title:c("goToResourceId"),centered:!0,visible:o,footer:null,destroyOnClose:!0,onCancel:a,maskClosable:!1,children:jsxRuntime.jsxs(antd.Form,{layout:"vertical",onFinish:l,autoComplete:"off",children:[jsxRuntime.jsx(antd.Form.Item,{name:"id",label:c("searchId"),rules:[{required:!0,type:"number"}],children:jsxRuntime.jsx(antd.InputNumber,{style:{width:"100%"},autoFocus:!0})}),jsxRuntime.jsx(antd.Row,{align:"middle",justify:"end",children:jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CloseOutlined,{}),htmlType:"button",onClick:a,disabled:s,children:c("cancel")}),jsxRuntime.jsx(antd.Button,{loading:s,style:{marginLeft:15},icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:s,children:c("ok")})]})})})]})})};function ButtonWithBadge(e){const{badgeNumber:o=0,...r}=e;return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:jsxRuntime.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:"#1890FF",color:"#fefefe"},children:o})}),jsxRuntime.jsx(ButtonWithTooltip,{...r,style:{width:46,zIndex:0}})]})}function GraphActionBar({refreshGraph:e}){const{t:o}=React.useContext(LocaleContext),{availableViews:r,currentView:a,setCurrentView:s,searchParams:c,searchVisible:l,setSearchVisible:d,graphIsLoading:u,previousView:f,setPreviousView:p}=React.useContext(ActionViewContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:l?"white":void 0}}),tooltip:o("advanced_search"),type:l?"primary":"default",onClick:()=>{d==null||d(!l)},disabled:u,badgeNumber:c==null?void 0:c.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:o("refresh"),disabled:u,loading:!1,onClick:()=>{e()}}),jsxRuntime.jsx(ChangeViewButton,{currentView:a,availableViews:r,onChangeView:m=>{p==null||p(a),s==null||s(m)},disabled:!1,previousView:f})]})}const{Title:Title$1,Text:Text$1}=antd.Typography;function TitleHeader(e){const{title:o,children:r}=e,{title:a,currentView:s,currentId:c,currentItemIndex:l,results:d,totalItems:u,selectedRowItems:f}=React.useContext(ActionViewContext),{t:p}=React.useContext(LocaleContext);function m(){if((s==null?void 0:s.type)==="form")return c?u===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("editingDocument")," (id: ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("register")," ",l===void 0?1:l+1," /"," ",d.length," ",p("of")," ",u," - ",p("editingDocument")," (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):"";if((s==null?void 0:s.type)==="tree"&&f){if(f.length===1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["1 ",p("selectedRegisters")," - (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:f[0].id}),")"]});if(f.length>1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f.length," ",p("selectedRegisters"),jsxRuntime.jsx(Text$1,{copyable:{text:f.map(I=>I.id).join(", ")}})]})}return null}return jsxRuntime.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[jsxRuntime.jsxs(antd.Row,{className:"rounded shadow-md bg-blueGray-100",style:{padding:"1em"},align:"middle",children:[jsxRuntime.jsxs(antd.Col,{flex:2,children:[jsxRuntime.jsx(Title$1,{level:3,style:{marginBottom:0},children:o||a}),m()]}),jsxRuntime.jsx(antd.Col,{flex:3,children:jsxRuntime.jsx(antd.Row,{justify:"end",children:r})})]}),jsxRuntime.jsx("div",{className:"pb-5"})]})}const GraphActionView=e=>{const{viewData:o,visible:r,model:a,context:s,domain:c,formView:l,treeView:d}=e,u=React.useRef(),f=React.useContext(ActionViewContext),{setResults:p=void 0,setCurrentItemIndex:m=void 0,currentId:I=void 0,results:h=void 0,setSelectedRowItems:v=void 0,setSearchParams:C=void 0,searchVisible:b=!0,setSearchVisible:y=void 0,sorter:g=void 0,setSorter:O=void 0,setTotalItems:w=void 0,setSearchTreeNameSearch:_=void 0,setTreeIsLoading:F=void 0,limit:L,setLimit:E,searchParams:P,searchValues:A,setSearchValues:W,currentView:J}=f||{},[Y,z]=React.useState(!0);React.useEffect(()=>{var Re;(Re=u.current)==null||Re.refresh()},[P]),React.useEffect(()=>{o.view_id!==J.view_id&&z(!0)},[J]);const{clear:Q,searchFilterLoading:oe,searchError:te,offset:X,tableRefreshing:ce}=useSearch({model:a,setSearchTreeNameSearch:_,setSelectedRowItems:v,searchParams:P,setSearchValues:W,setSearchParams:C,setSearchVisible:y,setTreeIsLoading:F,context:s,formView:l,treeView:d,sorter:g,setSorter:O,setCurrentItemIndex:m,setResultsActionView:p,resultsActionView:h,domain:c,currentId:I,setActionViewTotalItems:w,limit:L,setLimit:E});return!r||!o?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{title:o.name,children:jsxRuntime.jsx(GraphActionBar,{refreshGraph:()=>{u.current.refresh()}})}),jsxRuntime.jsx(SearchFilter,{fields:{...d.fields,...l.fields},searchFields:mergeSearchFields([l.search_fields,d.search_fields]),limit:L,onClear:Q,offset:X,isSearching:oe,onSubmit:Re=>{z(!1),C==null||C(Re.params),y==null||y(!1)},searchError:te,searchVisible:b,searchValues:A,showLimitOptions:!1}),ce?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Graph,{ref:u,view_id:o.view_id,model:a,context:s,domain:mergeParams(P||[],c),limit:Y?L:void 0,manualIds:Y?h==null?void 0:h.map(Re=>Re.id):void 0})]})},FormActionView=e=>{const{visible:o,formRef:r,model:a,currentId:s,domain:c,formView:l,context:d,defaultValues:u,forcedValues:f,results:p,setResults:m,setCurrentItemIndex:I}=e;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(FormActionBar,{toolbar:l==null?void 0:l.toolbar})}),jsxRuntime.jsx(Form$1,{rootForm:!0,ref:r,model:a,defaultValues:u,forcedValues:f,formView:l,actionDomain:c,id:s,parentContext:d,onSubmitSucceed:(h,v)=>{p.findIndex(b=>b.id===h)===-1&&(p.push(v),m(p),I(p.length-1))}})]}):null};function SearchBar(e){const{onSearch:o,disabled:r=!1,searchText:a}=e,{t:s}=React.useContext(LocaleContext),[c]=antd.Form.useForm(),[l,d]=React.useState(!1);function u(p){o(p.search)}React.useEffect(()=>{c.setFieldsValue({search:a})},[a]);function f(){d(!1),c.setFieldsValue({search:void 0}),o(void 0)}return jsxRuntime.jsx(antd.Form,{form:c,onFinish:u,autoComplete:"off",children:jsxRuntime.jsxs(antd.Row,{align:"middle",justify:"end",children:[jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Form.Item,{name:"search",noStyle:!0,children:jsxRuntime.jsx(antd.Input,{autoFocus:!0,disabled:r,onChange:p=>{d(p.target.value.length>0)},suffix:(l||a&&a.length>0)&&jsxRuntime.jsx(antd.Tooltip,{title:s("clear"),children:jsxRuntime.jsx(Icon.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:f})})})})}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Button,{htmlType:"submit",disabled:r,children:s("search")})})]})})}function TreeActionBar(e){var xe,de;const{availableViews:o,currentView:r,setCurrentView:a,selectedRowItems:s,setRemovingItem:c,removingItem:l,duplicatingItem:d,setDuplicatingItem:u,currentModel:f,searchTreeRef:p,setCurrentId:m,setCurrentItemIndex:I,searchParams:h,searchVisible:v,setSearchVisible:C,setSearchTreeNameSearch:b,searchTreeNameSearch:y,treeIsLoading:g,setPreviousView:O,previousView:w,results:_,limit:F,totalItems:L}=React.useContext(ActionViewContext),{parentContext:E={},treeExpandable:P,toolbar:A}=e,{t:W,lang:J}=React.useContext(LocaleContext),Y=React.useContext(ContentRootContext),{processAction:z}=Y||{},[Q,oe]=React.useState(!1);function te(){showDialog$9({confirmMessage:W("confirmRemove"),lang:J,onOk:()=>{X()}})}async function X(){var Ce;try{c==null||c(!0),await ConnectionProvider.getHandler().delete({model:f,ids:s.map(ee=>ee.id)}),m==null||m(void 0),I==null||I(void 0),(Ce=p==null?void 0:p.current)==null||Ce.refreshResults()}catch(ee){showDialog$8(ee)}finally{c==null||c(!1)}}async function ce(){var Ce;try{u==null||u(!0);const ee=s[0].id;await ConnectionProvider.getHandler().duplicate({id:ee,model:f,context:{...E}})&&((Ce=p==null?void 0:p.current)==null||Ce.refreshResults())}catch(ee){showDialog$8(ee)}finally{u==null||u(!1)}}function Re(Ce){z==null||z({actionData:Ce,values:{active_id:s==null?void 0:s.map(ee=>ee.id)[0],active_ids:s==null?void 0:s.map(ee=>ee.id)},fields:{},context:{...E,active_id:s==null?void 0:s.map(ee=>ee.id)[0],active_ids:s==null?void 0:s.map(ee=>ee.id)},onRefreshParentValues:()=>{var ee;(ee=p==null?void 0:p.current)==null||ee.refreshResults()}})}return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[P?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SearchBar,{disabled:d||l||g,searchText:y,onSearch:Ce=>{Ce&&Ce.trim().length>0?b==null||b(Ce):b==null||b(void 0)}}),separator$1(),jsxRuntime.jsx(NewButton,{disabled:g}),separator$1(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:W("duplicate"),disabled:!s||(s==null?void 0:s.length)!==1||d||g,loading:d,onClick:ce}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:W("delete"),disabled:!(s&&(s==null?void 0:s.length)>0)||g,loading:l,onClick:te}),separator$1()]}),!P&&jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:v?"white":void 0}}),tooltip:W("advanced_search"),type:v?"primary":"default",onClick:()=>{C==null||C(!v)},disabled:d||l||g,badgeNumber:h==null?void 0:h.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:W("showLogs"),disabled:!(s&&(s==null?void 0:s.length)>0)||g,loading:!1,onClick:()=>{showLogInfo(f,s[0].id,W)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:W("refresh"),disabled:d||l||g,loading:!1,onClick:()=>{var Ce;(Ce=p==null?void 0:p.current)==null||Ce.refreshResults()}}),!P&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[separator$1(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,availableViews:o,onChangeView:Ce=>{O==null||O(r),a==null||a(Ce)},previousView:w,disabled:g})]}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon__default.default,{component:()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-export",width:"18",height:"18",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"#2c3e50",fill:"none","stroke-linecap":"round","stroke-linejoin":"round",children:[jsxRuntime.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"6",rx:"8",ry:"3"}),jsxRuntime.jsx("path",{d:"M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6"}),jsxRuntime.jsx("path",{d:"M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3"})]})}),tooltip:W("export"),items:[{id:"print_screen",name:"Imprimir pantalla"},{id:"export",name:"Exportaci\xF3n avanzada"}],onItemClick:Ce=>{!Ce||Re(Ce)},disabled:d||l||g}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||g,tooltip:W("actions"),items:A==null?void 0:A.action,onItemClick:Ce=>{!Ce||Re(Ce)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||g,tooltip:W("reports"),items:A==null?void 0:A.print,onItemClick:Ce=>{!Ce||Re({...Ce,datas:{...Ce.datas||{},ids:s.map(ee=>ee.id)}})}}),jsxRuntime.jsx(ExportModal,{visible:Q,locale:J,onClose:()=>oe(!1),model:f,treeFields:(xe=p==null?void 0:p.current)==null?void 0:xe.getFields(),domain:mergeParams(((de=p==null?void 0:p.current)==null?void 0:de.getDomain())||[],h||[]),limit:F,totalRegisters:L,selectedRegistersToExport:_&&_.length&&_.length>0?_.length:void 0,context:E})]})}function separator$1(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const TreeActionView=e=>{const{visible:o,searchTreeRef:r,model:a,context:s,formView:c,treeView:l,domain:d,setCurrentItemIndex:u,results:f,setCurrentId:p,setCurrentView:m,availableViews:I,searchTreeNameSearch:h}=e;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(TreeActionBar,{toolbar:l==null?void 0:l.toolbar,parentContext:s,treeExpandable:(l==null?void 0:l.isExpandable)||!1})}),jsxRuntime.jsx(SearchTree$1,{ref:r,rootTree:!0,model:a,parentContext:s,nameSearch:h,formView:c,treeView:l,domain:d,onRowClicked:v=>{const{id:C}=v;p(C);const b=f.findIndex(g=>g.id===C);u(b);const y=I.find(g=>g.type==="form");m(y)}})]}):null},DashboardActionContext=React__default.default.createContext(null),DashboardActionProvider=e=>{const[o,r]=React.useState(!1),[a,s]=React.useState(!1),{children:c,dashboardRef:l,openAction:d}=e;return jsxRuntime.jsx(DashboardActionContext.Provider,{value:{isLoading:o,setIsLoading:r,dashboardRef:l,openAction:d,moveItemsEnabled:a,setMoveItemsEnabled:s},children:c})};function DashboardActionBar(){const{isLoading:e,dashboardRef:o,moveItemsEnabled:r,setMoveItemsEnabled:a}=React.useContext(DashboardActionContext),{t:s}=React.useContext(LocaleContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.BorderOuterOutlined,{style:{color:r?"white":void 0}}),type:r?"primary":"default",tooltip:s("moveDashboard"),disabled:e,loading:!1,onClick:()=>{a(!r)}}),separator(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SettingOutlined,{}),tooltip:s("configDashboard"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.configDashboard()}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:s("refresh"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.refresh()}})]})}function separator(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const DashboardActionView=e=>{const{dashboardData:o}=e,r=React.useRef(),a=React.useContext(TabManagerContext),{openShortcut:s}=a||{};return o?jsxRuntime.jsxs(DashboardActionProvider,{dashboardRef:r,openAction:c=>{s(c)},children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(DashboardActionBar,{})}),jsxRuntime.jsx(Dashboard$1,{ref:r,model:o.model,id:o.id,context:o==null?void 0:o.context,configAction:o==null?void 0:o.configAction})]}):null};function ActionView(e,o){const{domain:r,model:a,context:s,views:c,title:l,setCanWeClose:d,tabKey:u,initialView:f,formDefaultValues:p,formForcedValues:m={},res_id:I=!1,action_id:h,action_type:v,treeExpandable:C=!1,limit:b}=e,[y,g]=React.useState(),[O,w]=React.useState([]),[_,F]=React.useState(!0),L=I||void 0,[E,P]=React.useState(L),[A,W]=React.useState([]),[J,Y]=React.useState(),[z,Q]=React.useState([]),[oe,te]=React.useState(),[X,ce]=React.useState(0),[Re,xe]=React.useState(!1),[de,Ce]=React.useState(!1),[ee,ue]=React.useState(),{t:N}=React.useContext(LocaleContext),U=React.useRef(),re=React.useRef(),Te=React.useContext(TabManagerContext),{setCurrentView:Fe,setCurrentId:M,tabs:j,activeKey:we,openAction:je}=Te||{};reactHotkeysHook.useHotkeys("ctrl+g,command+g",Ct=>{Ct.preventDefault(),Tt()},[we,j,y,J,z]);function tt(Ct){P(Ct),M==null||M(Ct)}function Ne(Ct){g(Ct),Fe==null||Fe(Ct)}React.useImperativeHandle(o,()=>({canWeClose:yt}));const Ge=async()=>{F(!0);const Ct=[];for(const Ft of c){const[Ut,Gt]=Ft;let Qt;try{Gt!=="dashboard"&&(Qt=await ConnectionProvider.getHandler().getView({model:a,type:Gt,id:Ut,context:s}))}catch(Wt){console.error(`${a} - ${Gt}\xA0- ${JSON.stringify(Wt,null,2)}`);continue}switch(Gt){case"dashboard":{const Wt=c.find(un=>{const[,_t]=un;return _t==="form"});let fn;Wt&&(fn={action_id:h,action_type:v,name:l,res_id:s.active_id,res_model:a,view_id:Wt[0],view_type:Wt[1]}),Ct.push({type:"dashboard",id:s.active_id,model:a,context:s,configAction:fn});break}case"form":{Ct.push({...Qt});break}case"tree":{Ct.push({...Qt,isExpandable:C});break}case"graph":{Ct.push({...Qt});break}}}if(!f&&Ct.find(Ft=>Ft.type==="tree")){const Ft=Ct.find(Ut=>Ut.type==="tree");Ne(Ft)}else if(f){const Ft=Ct.find(Ut=>f.id?Ut.type===f.type&&Ut.view_id===f.id:Ut.type===f.type);Ne(Ft)}else{const Ft=Ct.find(Ut=>Ut.type==="form");Ne(Ft)}w(Ct),F(!1)};d({tabKey:u,canWeClose:yt}),React.useEffect(()=>{const Ct=O.find(Ut=>Ut.type==="tree"),Ft=O.find(Ut=>f.id?Ut.type===f.type&&Ut.view_id===f.id:Ut.type===f.type);Ne(Ft||Ct),I?M==null||M(L):(tt(void 0),Y(void 0)),Ge()},[a,c,I]),React.useEffect(()=>{we===u&&(M==null||M(E),Fe==null||Fe(y))},[j,we]);async function yt(){return y.type==="form"?await U.current.cancelUnsavedChanges():!0}async function Tt(){we===u&&(y.type==="form"&&!await U.current.cancelUnsavedChanges()||xe(!0))}async function Ot(Ct){var Qt;Ce(!0);const Ft=z.findIndex(Wt=>Wt.id===Ct);let Ut;if(Ft===-1){try{Ut=(Qt=await ConnectionProvider.getHandler().readObjects({model:a,ids:[Ct],context:s}))==null?void 0:Qt[0]}catch{}if(!Ut){Ce(!1),xe(!1),showDialog$7(N("idNotFound"));return}}else Ut=z[Ft];Ce(!1),xe(!1);const Gt=c.find(Wt=>Wt[1]==="form");je({domain:[],context:s,model:a,views:c,title:l,target:"current",initialView:{id:Gt==null?void 0:Gt[0],type:"form"},action_id:h,action_type:v,res_id:Ct})}function $t(){return O.map(Ct=>{switch(Ct.type){case"form":return jsxRuntime.jsx(FormActionView,{formRef:U,currentId:E,visible:y.type===Ct.type&&y.view_id===Ct.view_id,formView:Ct,model:a,context:s,domain:r,defaultValues:p,forcedValues:m,results:z,setResults:Q,setCurrentItemIndex:Y},`${Ct.type}-${Ct.view_id}`);case"tree":return jsxRuntime.jsx(TreeActionView,{visible:y.type===Ct.type&&y.view_id===Ct.view_id,limit:b,model:a,context:s,domain:r,formView:O.find(Ft=>Ft.type==="form"),treeView:Ct,searchTreeRef:re,searchTreeNameSearch:ee,availableViews:O,results:z,setCurrentItemIndex:Y,setCurrentId:tt,setCurrentView:Ne},`${Ct.type}-${Ct.view_id}`);case"graph":return jsxRuntime.jsx(GraphActionView,{visible:y.type===Ct.type&&y.view_id===Ct.view_id,viewData:Ct,model:a,context:s,domain:r,treeView:O.find(Ft=>Ft.type==="tree"),formView:O.find(Ft=>Ft.type==="form")},`${Ct.type}-${Ct.view_id}`);case"dashboard":return jsxRuntime.jsx(DashboardActionView,{dashboardData:Ct},`${Ct.type}-${Ct.view_id}`)}})}function Vt(){if(E===void 0&&y.type==="form")U.current.clearAndReload();else{tt(void 0);const Ct=O.find(Ft=>Ft.type==="form");Ne(Ct)}}return _?jsxRuntime.jsx(antd.Spin,{}):y?jsxRuntime.jsxs(ActionViewProvider,{title:l,currentView:y,setCurrentView:Ne,availableViews:O,formRef:U,searchTreeRef:re,onNewClicked:Vt,currentId:E,setCurrentId:tt,setCurrentItemIndex:Y,currentItemIndex:J,results:z,setResults:Q,currentModel:a,sorter:oe,setSorter:te,totalItems:X,setTotalItems:ce,selectedRowItems:A,setSelectedRowItems:W,setSearchTreeNameSearch:ue,searchTreeNameSearch:ee,goToResourceId:Ot,limit:b,children:[$t(),jsxRuntime.jsx(GoToResourceModal,{visible:Re,onIdSubmitted:Ot,isSearching:de,onCancel:()=>{xe(!1)}})]}):null}const ActionView$1=React.forwardRef(ActionView);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return typeof e=="string"&®EX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(byteToHex[e[o+0]]+byteToHex[e[o+1]]+byteToHex[e[o+2]]+byteToHex[e[o+3]]+"-"+byteToHex[e[o+4]]+byteToHex[e[o+5]]+"-"+byteToHex[e[o+6]]+byteToHex[e[o+7]]+"-"+byteToHex[e[o+8]]+byteToHex[e[o+9]]+"-"+byteToHex[e[o+10]]+byteToHex[e[o+11]]+byteToHex[e[o+12]]+byteToHex[e[o+13]]+byteToHex[e[o+14]]+byteToHex[e[o+15]]).toLowerCase();if(!validate(r))throw TypeError("Stringified UUID is invalid");return r}function v4(e,o,r){e=e||{};var a=e.random||(e.rng||rng)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,o){r=r||0;for(var s=0;s<16;++s)o[r+s]=a[s];return o}return stringify(a)}async function fetchAction({actionId:e,rootContext:o={},globalValues:r={}}){const a="ir.actions.act_window",s=`${a},${e}`,c=await ConnectionProvider.getHandler().getActionData({action:s,context:o}),l=ooui.parseContext({context:c.context,values:r,fields:{}}),d=c.domain?await ConnectionProvider.getHandler().evalDomain({domain:c.domain,values:r,context:{...o,...l}}):[],{res_model:u,views:f,name:p,limit:m,view_type:I}=c,h=I==="tree",v=[];for(const g of f){const[O,w]=g;if(O)v.push(g);else{const{view_id:_}=await ConnectionProvider.getHandler().getView({model:u,type:w,id:O,context:{...o,...l}});v.push([_,w])}}const[C,b]=v[0],y={id:C,type:b};return{title:p,actionId:e,actionType:a,key:v4(),views:f,model:u,context:{...o,...l},domain:d,initialView:y,limit:m,treeExpandable:h}}const styles$1="",styles="",ResponsiveReactGridLayout=reactGridLayout.WidthProvider(reactGridLayout.Responsive),DashboardGrid=e=>{const{children:o=[],onPositionItemsChanged:r}=e,a=React__default.default.Children.map(o,s=>{const{parms:c,id:l}=s.props;return jsxRuntime.jsx("div",{"data-grid":c,children:s},l)});return jsxRuntime.jsx(ResponsiveReactGridLayout,{className:"layout",cols:{lg:12,md:10,sm:6,xs:4,xxs:2},draggableHandle:".draggable-head",rowHeight:30,onLayoutChange:s=>{r==null||r(s.map(c=>({id:parseInt(c.i.replace(".$",""),10),x:c.x,y:c.y,w:c.w,h:c.h})))},children:a})},{Text}=antd.Typography,DashboardGridItem=e=>{const{id:o,title:r,children:a,action:s,openAction:c}=e;return jsxRuntime.jsxs("div",{className:"shadow-md rounded",style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #eee",backgroundColor:"white"},children:[jsxRuntime.jsxs(antd.Row,{className:"bg-blueGray-100",align:"middle",style:{borderBottom:"1px solid #ddd"},wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"auto",className:"draggable-head",style:{fontWeight:"bold",padding:"0.5rem",cursor:"grab",overflow:"hidden"},children:jsxRuntime.jsx(Text,{ellipsis:!0,children:r})}),s&&jsxRuntime.jsx(antd.Col,{flex:"25px",style:{padding:"0.5rem"},children:jsxRuntime.jsx(antd.Row,{justify:"end",align:"middle",children:jsxRuntime.jsx(Icon.ExportOutlined,{style:{cursor:"pointer"},onClick:()=>{c==null||c(s)}})})})]}),a]})},DEFAULT_SEARCH_LIMIT=80;function DashboardTree(e){const{action:o,model:r,view_id:a,onRowClicked:s,domain:c=[],visible:l=!0,parentContext:d={}}=e,[u,f]=React.useState(!1),[p,m]=React.useState(!1),[I,h]=React.useState(),[v,C]=React.useState(),[b,y]=React.useState(),[g,O]=React.useState(1),[w,_]=React.useState(0),F=React.useRef(DEFAULT_SEARCH_LIMIT),L=React.useRef([]),[E,P]=React.useState(0),[A,W]=React.useState([]),[J,Y]=React.useState(void 0),[z,Q]=React.useState(),[oe,te]=React.useState(),[X,ce]=React.useState(),[Re,xe]=React.useState(!1),de=React.useRef([]),Ce=M=>{xe(!0),O(M),_((M-1)*F.current)},ee=async()=>{const M=de.current.length>0?de.current:c,j=mergeParams(L.current,M),{colors:we}=getTree(v),{totalItems:je,results:tt,attrsEvaluated:Ne}=await ConnectionProvider.getHandler().searchForTree({params:j,limit:F.current,offset:w,model:I,fields:v.fields,context:d,attrs:we&&{colors:we}}),Ge=await je;P(Ge),Y(getColorMap(Ne));const yt=sortResults({resultsToSort:tt,sorter:z,fields:{...v.fields,...b.fields}});W(yt)},ue=async()=>{try{xe(!0),await ee()}catch(M){te(JSON.stringify(M))}finally{xe(!1)}};React.useEffect(()=>{!p||l&&ue()},[g,w,p,l]);const N=async M=>{m(!1),f(!0),ce(void 0);try{M==="action"?await U():await re(),m(!0)}catch(j){ce(j)}finally{f(!1)}},U=async()=>{const M=await ConnectionProvider.getHandler().getViewsForAction({action:o,context:d});de.current=M.domain,y(M.views.get("form")),C(M.views.get("tree")),h(M.model),F.current=M.limit},re=async()=>{h(r);const M=await ConnectionProvider.getHandler().getView({model:r,type:"form",context:d});y(M);const j=await ConnectionProvider.getHandler().getView({model:r,type:"tree",id:a,context:d});C(j)};React.useEffect(()=>{o?N("action"):r&&N("model")},[o,r]);const Te=M=>{const{id:j}=M;s({id:j,model:I,treeView:v})},Fe=()=>!v||!b?null:jsxRuntime.jsxs("div",{style:{overflowY:"scroll"},children:[oe&&jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:oe,type:"error",banner:!0}),jsxRuntime.jsx(Tree,{showPagination:!1,total:E,limit:F.current,page:g,treeView:v,results:A,onRequestPageChange:Ce,loading:Re,onRowClicked:Te,colorsForResults:J,sorter:z,onChangeSort:M=>{Q==null||Q(M);const j=sortResults({resultsToSort:A,sorter:M,fields:{...v.fields,...b.fields}});W(j)}})]});return X?jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:X,type:"error",banner:!0}):u?jsxRuntime.jsx(antd.Spin,{style:{padding:"2rem"}}):Fe()}const DashboardForm=e=>{const{model:o}=e,[r,a]=React.useState();React.useEffect(()=>{s()},[o]);async function s(){const c=await ConnectionProvider.getHandler().search({params:[],model:o,limit:1});c.length>0&&a(c[0].id)}return jsxRuntime.jsx("div",{style:{padding:"0.5rem",overflowY:"scroll"},children:jsxRuntime.jsx(Form$1,{...e,model:o,id:r,readOnly:!0})})},itemsField="line_ids";function Dashboard(e,o){const{model:r,context:a={},id:s,configAction:c}=e,[l,d]=React.useState([]),[u,f]=React.useState(!1),[p,m]=React.useState(),{setIsLoading:I,openAction:h,moveItemsEnabled:v}=React.useContext(DashboardActionContext),C=React.useRef(),b=React.useRef();React.useEffect(()=>{y()},[r,s,a]),React.useImperativeHandle(o,()=>({refresh:()=>{y()},configDashboard:L}));async function y(){f(!0),I(!0),m(void 0);try{const E=await g(),P=await w(E),A=E.fields[itemsField].relation,W=P[itemsField].items;b.current=E.fields;const J=await O({items:W,model:A,context:a}),Y=await _(J);d(Y),f(!1),I(!1)}catch(E){m(JSON.stringify(E))}}async function g(){return await ConnectionProvider.getHandler().getView({model:r,type:"form",context:a})}async function O({items:E,model:P,context:A}){return C.current=(await ConnectionProvider.getHandler().getView({model:P,type:"form",context:A})).fields,await readObjectValues({treeFields:C.current,formFields:C.current,model:P,items:E,context:A})}async function w(E){return(await ConnectionProvider.getHandler().readObjects({model:r,ids:[s],fields:E.fields,context:a}))[0]}async function _(E){const P=[];for(const A of E){const{values:W}=A;if(W.action_id&&W.action_id.length>0){const J=parseInt(W.action_id[0],10),Y=await fetchAction({actionId:J,rootContext:a});P.push({...A,actionData:Y})}}return P}async function F(E){if(!v)return;const P=E.filter(Y=>{const z=l.find(oe=>oe.id===Y.id);if(!z)return!1;if(!z.position)return!0;const Q={...JSON.parse(z.position.replace(/'/g,'"')),id:z.id};return JSON.stringify(Y)!==JSON.stringify(Q)});if(P.length===0)return;const W=l.filter(Y=>P.map(z=>z.id).includes(Y.id)).map(Y=>{const z={...P.find(Q=>Q.id===Y.id)};return delete z.id,{...Y},{...Y,operation:"pendingUpdate",values:{...Y.values,position:JSON.stringify(z).replace(/"/g,"'")}}}),J={fields:C.current,items:W};await ConnectionProvider.getHandler().update({model:r,id:s,values:{[itemsField]:J},fields:b.current,context:a})}async function L(){h(c)}return p?jsxRuntime.jsx(antd.Alert,{className:"mt-10 mb-20",message:p,type:"error",banner:!0}):u?jsxRuntime.jsx(Icon.LoadingOutlined,{}):jsxRuntime.jsx(DashboardGrid,{onPositionItemsChanged:F,children:l.map((E,P)=>{const{actionData:A,values:W}=E,{position:J,id:Y}=W,{actionId:z,actionType:Q,key:oe,title:te,views:X,model:ce,context:Re,domain:xe,initialView:de,limit:Ce}=A;let ee={};try{ee=JSON.parse(J.replace(/'/g,'"'))}catch{ee={x:P*2,y:0,w:2,h:3}}let ue=null;(de==null?void 0:de.type)==="graph"?ue=jsxRuntime.jsx(Graph,{view_id:X.filter(re=>re[1]==="graph")[0][0],model:ce,context:Re,domain:xe,limit:Ce}):(de==null?void 0:de.type)==="form"?ue=jsxRuntime.jsx(DashboardForm,{model:ce,actionDomain:xe}):(de==null?void 0:de.type)==="tree"?ue=jsxRuntime.jsx(DashboardTree,{model:ce,domain:xe,view_id:X.filter(re=>re[1]==="tree")[0][0],onRowClicked:re=>{const Te=X.find(Fe=>{const[,M]=Fe;return M==="form"});if(Te){const[Fe,M]=Te,{actionId:j,actionType:we,title:je,model:tt}=A,Ne={action_id:j,action_type:we,name:je,res_id:re.id,res_model:tt,view_id:Fe,view_type:M};h(Ne)}}}):de!==void 0&&(ue=jsxRuntime.jsx(ActionView$1,{action_id:z,action_type:Q,tabKey:oe,title:te,views:X,model:ce,context:Re,domain:xe,setCanWeClose:()=>{},initialView:de,limit:Ce}));let N;const U=X.find(re=>{const[,Te]=re;return Te==="tree"});if(U){const[re,Te]=U,{actionId:Fe,actionType:M,title:j,model:we}=A;N={action_id:Fe,action_type:M,name:j,res_id:!1,res_model:we,view_id:re,view_type:Te}}return jsxRuntime.jsx(DashboardGridItem,{id:Y,title:te,parms:ee,action:N,openAction:h,children:ue},Y)})})}const Dashboard$1=React.forwardRef(Dashboard),MultiCheckbox=e=>{const{ooui:o}=e;return jsxRuntime.jsx(Field$1,{type:"array",...e,children:jsxRuntime.jsx(MultiCheckboxInput,{ooui:o})})},MultiCheckboxInput=e=>{const{value:o,ooui:r,onChange:a}=e,{items:s=[]}=o||{},c=s.filter(E=>E.operation!=="pendingRemove").map(E=>E.id),[l,d]=React.useState([]),[u,f]=React.useState(),[p,m]=React.useState(!1),{relation:I,context:h,readOnly:v,field:C,columns:b}=r,y=React.useContext(FormContext$1),{getContext:g}=y||{};useDeepCompareEffect__default.default(()=>{w()},[s]);const O=E=>{a==null||a({items:E})};async function w(){m(!0);let E=[];if(r.domain){const P=await ConnectionProvider.getHandler().evalDomain({domain:r.domain,values:transformPlainMany2Ones({fields:y==null?void 0:y.getFields(),values:y.getPlainValues()}),context:y.getContext()});E=[...E,...P]}try{const A=(await ConnectionProvider.getHandler().search({model:I,params:E,fields:[C],context:{...g==null?void 0:g(),...h}})).map(W=>{const J=W[C];let Y=J;return Array.isArray(J)&&(Y=J[1]),{label:Y,value:W.id}});d(A)}catch(P){f(P)}finally{m(!1)}if(u)return jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:u,type:"error",banner:!0})}const _=()=>{L(l.map(E=>E.value))},F=()=>{L([])},L=E=>{const P=s.map(W=>E.includes(W.id)?W.operation=="pendingRemove"?{...W,operation:"original"}:W:{id:W.id,operation:"pendingRemove"}),A=P.map(W=>W.id);E.filter(W=>!A.includes(W)).map(W=>{P.push({id:W,operation:"pendingLink"})}),O(P)};return p&&l.length===0?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsx(antd.Checkbox.Group,{value:l.length?c:[],disabled:v,onChange:L,style:{width:"100%"},children:jsxRuntime.jsx(antd.Row,{children:l.map(E=>jsxRuntime.jsx(antd.Col,{span:Math.floor(24/b),children:jsxRuntime.jsx(antd.Checkbox,{value:E.value,children:E.label})}))})}),!v&&jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{onClick:_,disabled:c.length==l.length,children:"Check all"}),jsxRuntime.jsx(antd.Button,{onClick:F,disabled:c.length===0,children:"Uncheck all"})]})]})})},Radio=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,type:"any",...e,children:jsxRuntime.jsx(SelectionInput,{...e})})},SelectionInput=e=>{const{ooui:o,onChange:r,value:a}=e,{selectionValues:s,readOnly:c,direction:l}=o,d=Array.from(s.entries()),u=d&&d.length&&d.map(f=>{const[p,m]=f;return jsxRuntime.jsx(antd.Radio,{value:p,children:m},p)});return jsxRuntime.jsx(antd.Radio.Group,{disabled:c,onChange:r,value:a,children:jsxRuntime.jsx(antd.Space,{direction:l,children:u})})},Switch=e=>{const{ooui:o}=e,{id:r,readOnly:a,required:s}=o;return jsxRuntime.jsx(Field$1,{...e,valuePropName:"checked",children:jsxRuntime.jsx(SwitchInput,{id:r,readOnly:a,required:s})})},SwitchInput=e=>{const{required:o,readOnly:r,...a}=e;return jsxRuntime.jsx("div",{className:"flex flex-row",children:jsxRuntime.jsx(antd.Switch,{disabled:r,...a})})},Steps=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,type:"any",...e,children:jsxRuntime.jsx(StepsInput,{...e})})},StepsInput=e=>{const{ooui:o,value:r}=e,{selectionValues:a,errorField:s}=o,c=React.useContext(FormContext$1),l=Array.from(a.entries()),d=l.map(p=>p[0]).indexOf(r);let u="process",f="";return s&&(f=c.getFieldValue(s),f&&(u="error")),jsxRuntime.jsx(antd.Steps,{current:d,status:u,children:l.map((p,m)=>jsxRuntime.jsx(antd.Steps.Step,{title:p[1],description:m===d&&u==="error"?f:null}))})},CodeEditor=e=>{const{ooui:o}=e,{lang:r,height:a}=o,s=React.useContext(FormContext$1),{elementHasLostFocus:c}=s||{},l=d=>{d.onDidBlurEditorWidget(c)};return jsxRuntime.jsx(Field$1,{...e,children:jsxRuntime.jsx(Editor__default.default,{defaultLanguage:r||"",height:a||300,onMount:l})})},{Content}=antd.Layout,{Title}=antd.Typography;function Welcome(){const{t:e}=React.useContext(LocaleContext);return jsxRuntime.jsx(Content,{className:"m-5 select-none",children:jsxRuntime.jsx(Title,{level:5,children:e("welcome")})})}function RootView(e,o){const{children:r,globalValues:a={},rootContext:s={},lang:c}=e,[l,d]=React.useState("welcome"),[u,f]=React.useState([{title:tForLang("welcome",c),key:"welcome",closable:!0,content:jsxRuntime.jsx(Welcome,{})}]),p=React.useRef(new Map),m=React.useRef();React.useImperativeHandle(o,()=>({retrieveAndOpenAction:v,openShortcut:y}));function I(w){if(w===l){const _=u.findIndex(F=>F.key===w);u[_-1]&&d(u[_-1].key),u[_+1]&&d(u[_+1].key)}f(u.filter(_=>_.key!==w)),p.current.delete(w)}function h({tabKey:w,canWeClose:_}){p.current.set(w,_)}async function v({action:w,values:_,forced_values:F,initialViewType:L,res_id:E,domain:P=[]}){const A=await ConnectionProvider.getHandler().getActionData({action:w,context:s});if(A.type==="ir.actions.wizard"){showDialog$8("Action type not supported");return}const[W,J]=w.split(","),Y=parseInt(J),z=ooui.parseContext({context:A.context,values:a,fields:{}}),Q=A.domain?await ConnectionProvider.getHandler().evalDomain({domain:A.domain,values:a,context:{...s,...z}}):[],{res_model:oe,views:te,name:X,target:ce,view_type:Re,limit:xe}=A,de=Re==="tree",Ce=[];for(const ue of te){const[N,U]=ue;if(N)Ce.push(ue);else if(U==="dashboard")Ce.push([void 0,"dashboard"]);else{const{view_id:re}=await ConnectionProvider.getHandler().getView({model:oe,type:U,id:N,context:{...s,...z}});Ce.push([re,U])}}let ee;if(L){const[ue,N]=Ce.find(([U,re])=>re===L);ee={id:ue,type:N}}else{const[ue,N]=Ce[0];ee={id:ue,type:N}}O({domain:[...Q,...P],context:{...s,...z},model:oe,views:Ce,title:X,target:ce,initialView:ee,action_type:W,action_id:Y,values:_,forced_values:F,res_id:E,treeExpandable:de,limit:xe})}function C({title:w,content:_,key:F,action:L}){let E=[...u];u.length===1&&u[0].key==="welcome"&&(E=[...u.filter(P=>P.key!=="welcome")]),f([...E,{title:w,key:F,closable:!0,content:_,action:L}]),d(F)}async function b({relateData:w,fields:_,values:F,action_id:L,action_type:E}){const{res_model:P,context:A,domain:W,views:J,target:Y,string:z,limit:Q}=w,[oe,te]=J[0],X={id:oe,type:te},ce=ooui.parseContext({context:A,values:{...F,...a},fields:_}),Re=W?await ConnectionProvider.getHandler().evalDomain({domain:W,values:transformPlainMany2Ones({fields:_,values:{...F,...a}}),context:{...s,...ce}}):[];O({model:P,target:Y,views:J,context:{...s,...ce},domain:Re,title:z,initialView:X,action_id:L,action_type:E,limit:Q})}async function y(w){const{action_id:_,action_type:F,res_id:L,view_id:E}=w,P=`${F},${_}`,A=await ConnectionProvider.getHandler().getActionData({action:P,context:s}),W=ooui.parseContext({context:A.context,values:a,fields:{}}),J=A.domain?await ConnectionProvider.getHandler().evalDomain({domain:A.domain,values:a,context:{...s,...W}}):[],{res_model:Y,views:z,name:Q,target:oe,view_type:te,limit:X}=A,ce=te==="tree",Re=[];for(const ee of z){const[ue,N]=ee;if(ue)Re.push(ee);else if(N==="dashboard")Re.push([void 0,"dashboard"]);else{const{view_id:U}=await ConnectionProvider.getHandler().getView({model:Y,type:N,id:ue,context:{...s,...W}});Re.push([U,N])}}let xe,de;if(E==null){const ee=Re.find(ue=>ue[0]===void 0);xe=void 0,de=ee[1]}else[xe,de]=Re.find(ee=>ee[0]===void 0?!1:ee[0]===E);const Ce={id:xe,type:de};O({domain:J,context:{...s,...W},model:Y,views:Re,title:Q,target:oe,initialView:Ce,action_id:_,action_type:F,res_id:L,treeExpandable:ce,limit:X})}async function g({model:w,values:_,forced_values:F,initialViewType:L,res_id:E,domain:P}){const A=await ConnectionProvider.getHandler().getActionStringForModel(w);await v({action:A,values:_,forced_values:F,initialViewType:L,res_id:E,domain:P})}async function O({domain:w,context:_,model:F,views:L,title:E,target:P,initialView:A,action_id:W,action_type:J,res_id:Y,values:z,forced_values:Q,treeExpandable:oe=!1,limit:te}){const X=v4();if(P!=="current"){const ce=await ConnectionProvider.getHandler().getView({model:F,type:"form",id:A.type==="form"?A.id:void 0,context:{...s,..._}});m.current.openActionModal({domain:w,model:F,formView:ce,context:{...s,..._},actionData:{action_id:W,action_type:J,res_id:Y,view_id:ce.view_id}})}else C({title:E,action:{id:W,type:J},content:jsxRuntime.jsx(ActionView$1,{action_id:W,action_type:J,tabKey:X,title:E,views:L,model:F,context:{...s,..._},domain:w,setCanWeClose:h,initialView:A,res_id:Y,formDefaultValues:z,formForcedValues:Q,treeExpandable:oe,limit:te}),key:X})}return jsxRuntime.jsx(LocaleContextProvider,{lang:c,children:jsxRuntime.jsx(TabManagerProvider,{openShortcut:y,openAction:O,openRelate:b,openDefaultActionForModel:g,tabs:u,activeKey:l,onRemoveTab:async w=>{const _=p.current.get(w);(await(_==null?void 0:_())||l==="welcome")&&I(w)},onChangeTab:w=>{d(w)},children:jsxRuntime.jsx(ContentRootProvider$1,{ref:m,globalValues:a,children:r})})})}const RootView$1=React.forwardRef(RootView);function Tab(e){const{label:o,onClose:r,tabKey:a,isActive:s,onSelected:c}=e,l=s?"#ffffff":"#F1F5F9";return jsxRuntime.jsxs("div",{onClick:()=>{!s&&c(a)},style:{cursor:"pointer",height:40,paddingTop:7,paddingBottom:5,paddingLeft:10,paddingRight:10,backgroundColor:l,display:"inline-flex",flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",borderTopLeftRadius:8,borderTopRightRadius:8,marginLeft:2},children:[jsxRuntime.jsx("div",{style:{color:s?"#001529":"#ADB0B3",userSelect:"none",height:40,display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:5,paddingRight:5,marginBottom:2},children:o}),jsxRuntime.jsx("div",{style:{paddingLeft:5,height:40,display:"flex",justifyContent:"center",alignItems:"center"},children:jsxRuntime.jsx(Icon.CloseOutlined,{style:{color:s?"#001529":"#ADB0B3"},onClick:d=>{d.stopPropagation(),r(a)}})})]})}function TabSelector(){const e=React.useContext(TabManagerContext),{activeKey:o,tabs:r,onRemoveTab:a,onChangeTab:s}=e||{};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r.map(c=>jsxRuntime.jsx(Tab,{tabKey:c.key,label:c.title,onClose:a,isActive:o===c.key,onSelected:s},c.key))})}function TabContent(e){const{tab:o}=e,r=React.useContext(TabManagerContext),{activeKey:a}=r||{},s={display:"none"};return jsxRuntime.jsx("div",{style:o.key!==a?s:void 0,children:o.content})}const TabContent$1=React__default.default.memo(TabContent,()=>!0);function CurrentTabContent(){const e=React.useContext(TabManagerContext),{tabs:o}=e||{},r=(o==null?void 0:o.map(a=>jsxRuntime.jsx(TabContent$1,{tab:a},a.key)))||null;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r})}const FavouriteButton=e=>{const{onRetrieveShortcuts:o,onCheckIsFavourite:r,onAddFavourite:a,onRemoveFavourite:s}=e,[c,l]=React.useState(!1),[d,u]=React.useState(!1),[f,p]=React.useState([]),[m,I]=React.useState(!0),[h,v]=React.useState(),{t:C}=React.useContext(LocaleContext),b=React.useContext(TabManagerContext),{openShortcut:y,tabs:g,activeKey:O,currentView:w,currentId:_,openDefaultActionForModel:F}=b||{};React.useEffect(()=>{L()},[]),React.useEffect(()=>{A()},[g,O,w,_]);async function L(){try{I(!0);const Q=await o();p(Q)}catch(Q){showDialog$8(Q)}finally{I(!1)}}function E(Q){const{key:oe}=Q,te=f.find(X=>X.id===Number(oe));(te==null?void 0:te.action_type)!=="ir.actions.wizard"&&(te&&y(te),u(!1))}function P(Q){Q&&L(),u(Q)}async function A(){if(!w)return;const Q=g.find(xe=>xe.key===O),{id:oe,type:te}=(Q==null?void 0:Q.action)||{};if(!oe||!te){l(!1);return}const X=w.view_id;let ce=!1;w.type==="form"&&(ce=_||!1);const Re=await r({action_id:oe,action_type:te,view_id:X,res_id:ce});Re!==!1&&v(Re),l(Re!==!1)}async function W(){u(!1),F==null||F({model:"ir.ui.view_sc"})}const J=jsxRuntime.jsxs(antd.Menu,{onClick:E,children:[jsxRuntime.jsxs("div",{style:{width:300,padding:5,display:"flex"},children:[jsxRuntime.jsx("div",{style:{paddingLeft:15,color:"#ccc"},children:C("favorites").toUpperCase()}),jsxRuntime.jsx("div",{style:{flexGrow:1,paddingLeft:10},children:jsxRuntime.jsx(antd.Tooltip,{title:C("edit_favorites"),children:jsxRuntime.jsx(Icon.EditOutlined,{style:{color:"#1890FF",cursor:"pointer"},onClick:W})})})]}),jsxRuntime.jsx(antd.Menu.Divider,{}),m?jsxRuntime.jsx(antd.Spin,{style:{padding:"1rem"}}):f.length>0?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f.map(Q=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsx(Y,{title:Q.name,type:Q.view_type})},Q.id))}):jsxRuntime.jsx("div",{style:{width:300,padding:5,paddingLeft:15},children:C("no_favorites")})]});function Y({title:Q,type:oe}){const te=oe==="tree"?jsxRuntime.jsx(Icon.TableOutlined,{}):jsxRuntime.jsx(Icon.FormOutlined,{});return jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:te}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:Q})]})}async function z(){if(c&&h)await s(h);else{if(!w)return;const Q=g.find(Re=>Re.key===O),{id:oe,type:te}=(Q==null?void 0:Q.action)||{},X=w.view_id;let ce=!1;if(!oe||!te){l(!1);return}w.type==="form"&&(ce=_||!1),await a({action_id:oe,action_type:te,view_id:X,res_id:ce})}await L(),l(!c)}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Button,{type:c?"primary":"default",icon:c?jsxRuntime.jsx(Icon.StarFilled,{style:{color:"white"}}):jsxRuntime.jsx(Icon.StarOutlined,{}),style:{width:50},onClick:z}),jsxRuntime.jsx(antd.Dropdown,{overlay:J,onVisibleChange:P,visible:d,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:Q=>Q.preventDefault()})})]})};exports.ActionBar=FormActionBar,exports.Binary=Binary,exports.Boolean=Boolean$1,exports.Button=Button,exports.ButtonGroup=ButtonGroup,exports.Char=Char,exports.CodeEditor=CodeEditor,exports.ConnectionProvider=ConnectionProvider,exports.ContentRootProvider=ContentRootProvider$1,exports.CurrentTabContent=CurrentTabContent,exports.Dashboard=Dashboard$1,exports.DashboardGrid=DashboardGrid,exports.DashboardGridItem=DashboardGridItem,exports.Date=Date$1,exports.DateTime=DateTime,exports.Email=Email,exports.ExportModal=ExportModal,exports.FavouriteButton=FavouriteButton,exports.Float=Float,exports.FloatTime=FloatTime,exports.Form=Form$1,exports.FormModal=FormModal,exports.GraphIndicator=GraphIndicator,exports.Group=Group,exports.Image=Image,exports.Integer=Integer,exports.Label=Label,exports.Many2one=Many2one,exports.MultiCheckbox=MultiCheckbox,exports.Notebook=Notebook,exports.One2many=One2many,exports.ProgressBar=ProgressBar,exports.Radio=Radio,exports.Reference=Reference,exports.RootView=RootView$1,exports.SearchFilter=SearchFilter,exports.SearchModal=SearchModal,exports.SearchTree=SearchTree$1,exports.Selection=Selection,exports.Separator=Separator,exports.Steps=Steps,exports.Switch=Switch,exports.TabSelector=TabSelector,exports.Tags=Tags,exports.Text=Text$2,exports.Tree=Tree,exports.Url=Url,exports.iconMapper=iconMapper,exports.showConfirmDialog=showDialog$9,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
285
285
|
//# sourceMappingURL=react-ooui.umd.js.map
|