@gisce/react-ooui 1.2.0-rc.89 → 1.2.0-rc.90

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.
@@ -16,7 +16,7 @@
16
16
  }
17
17
  `;var gt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bo(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}var Dr=Bo,Ho=typeof gt=="object"&&gt&&gt.Object===Object&&gt,Ko=Ho,Wo=Ko,qo=typeof self=="object"&&self&&self.Object===Object&&self,Yo=Wo||qo||Function("return this")(),Vr=Yo,Go=Vr,Uo=function(){return Go.Date.now()},jo=Uo,zo=/\s/;function Jo(t){for(var r=t.length;r--&&zo.test(t.charAt(r)););return r}var Zo=Jo,Xo=Zo,Qo=/^\s+/;function Ro(t){return t&&t.slice(0,Xo(t)+1).replace(Qo,"")}var es=Ro,ts=Vr,rs=ts.Symbol,kr=rs,Er=kr,Ir=Object.prototype,ns=Ir.hasOwnProperty,os=Ir.toString,mt=Er?Er.toStringTag:void 0;function ss(t){var r=ns.call(t,mt),n=t[mt];try{t[mt]=void 0;var s=!0}catch{}var o=os.call(t);return s&&(r?t[mt]=n:delete t[mt]),o}var is=ss,as=Object.prototype,ls=as.toString;function cs(t){return ls.call(t)}var ds=cs,Mr=kr,us=is,fs=ds,hs="[object Null]",ps="[object Undefined]",Ar=Mr?Mr.toStringTag:void 0;function gs(t){return t==null?t===void 0?ps:hs:Ar&&Ar in Object(t)?us(t):fs(t)}var ms=gs;function ys(t){return t!=null&&typeof t=="object"}var ws=ys,vs=ms,Cs=ws,bs="[object Symbol]";function Ss(t){return typeof t=="symbol"||Cs(t)&&vs(t)==bs}var xs=Ss,Ts=es,$r=Dr,Fs=xs,Lr=0/0,Os=/^[-+]0x[0-9a-f]+$/i,_s=/^0b[01]+$/i,Ds=/^0o[0-7]+$/i,Vs=parseInt;function ks(t){if(typeof t=="number")return t;if(Fs(t))return Lr;if($r(t)){var r=typeof t.valueOf=="function"?t.valueOf():t;t=$r(r)?r+"":r}if(typeof t!="string")return t===0?t:+t;t=Ts(t);var n=_s.test(t);return n||Ds.test(t)?Vs(t.slice(2),n?2:8):Os.test(t)?Lr:+t}var Es=ks,Is=Dr,Gt=jo,Nr=Es,Ms="Expected a function",As=Math.max,$s=Math.min;function Ls(t,r,n){var s,o,i,a,c,d,u=0,h=!1,p=!1,g=!0;if(typeof t!="function")throw new TypeError(Ms);r=Nr(r)||0,Is(n)&&(h=!!n.leading,p="maxWait"in n,i=p?As(Nr(n.maxWait)||0,r):i,g="trailing"in n?!!n.trailing:g);function w(D){var N=s,b=o;return s=o=void 0,u=D,a=t.apply(b,N),a}function m(D){return u=D,c=setTimeout(v,r),h?w(D):a}function y(D){var N=D-d,b=D-u,x=r-N;return p?$s(x,i-b):x}function C(D){var N=D-d,b=D-u;return d===void 0||N>=r||N<0||p&&b>=i}function v(){var D=Gt();if(C(D))return E(D);c=setTimeout(v,y(D))}function E(D){return c=void 0,g&&s?w(D):(s=o=void 0,a)}function _(){c!==void 0&&clearTimeout(c),u=0,s=d=o=c=void 0}function S(){return c===void 0?a:E(Gt())}function I(){var D=Gt(),N=C(D);if(s=arguments,o=this,d=D,N){if(c===void 0)return m(d);if(p)return clearTimeout(c),c=setTimeout(v,r),w(d)}return c===void 0&&(c=setTimeout(v,r)),a}return I.cancel=_,I.flush=S,I}var Ns=Ls;function Ps(t){const n=Buffer.from(t,"base64").length/1e3;return`${Math.round((n+Number.EPSILON)*100)/100} KB`}async function tt(t){const r=await to.fileTypeFromBuffer(Buffer.from(t,"base64"));return r||{mime:"text/plain",ext:"txt"}}const Pr=t=>new Promise((r,n)=>{const s=new FileReader;s.readAsDataURL(t),s.onload=o=>r(o.target.result.split(",")[1]),s.onerror=o=>n(o)});function Tt(t,r){for(var n=atob(t),s=new Array(n.length),o=0;o<n.length;o++)s[o]=n.charCodeAt(o);var i=new Uint8Array(s),a=new Blob([i],{type:r+";base64"}),c=URL.createObjectURL(a);window.open(c)}const Br=t=>{const{ooui:r}=t,{required:n,id:s}=r,o=qe(s);return o?e.jsx(o,{}):e.jsx(me,{required:n,...t,children:e.jsx(Bs,{ooui:r})})},Bs=t=>{const{ooui:r,value:n,onChange:s}=t,{readOnly:o}=r,i=l.useRef(null),{t:a}=l.useContext(ge),c=p=>{s==null||s(p)};async function d(){const p=await tt(n),g=`data:${p==null?void 0:p.mime};base64,${n}`,w=document.createElement("a");w.href=g,w.download=`image.${p==null?void 0:p.ext}`,w.click()}async function u(p){p.stopPropagation(),p.preventDefault();const g=p.target.files[0],w=await Pr(g);c(w)}function h(){c(void 0)}return e.jsxs(e.Fragment,{children:[e.jsxs(f.Row,{gutter:8,wrap:!1,justify:"center",children:[n&&e.jsx("img",{src:`data:image/*;base64,${n}`,style:{maxWidth:"100px"}}),e.jsx("input",{type:"file",id:"file",ref:i,accept:"image/*",style:{display:"none"},onChange:u})]}),e.jsx(f.Row,{gutter:8,wrap:!1,justify:"center",className:"pt-5",children:e.jsxs(f.Space,{children:[e.jsx(Le,{tooltip:a("uploadNewImage"),icon:e.jsx(B.FolderOpenOutlined,{}),disabled:o,onClick:()=>{i.current.click()}}),e.jsx(Le,{tooltip:a("download"),disabled:!n,onClick:d,icon:e.jsx(B.DownloadOutlined,{})}),e.jsx(Le,{tooltip:a("clear"),disabled:o||!n,onClick:h,icon:e.jsx(B.ClearOutlined,{})})]})})]})},Hs=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Ks,{})})},Ks=t=>{const{value:r,onChange:n}=t;if(!r)return null;try{JSON.parse(r)}catch(s){return console.log(s),null}return e.jsx(ro.GridUi,{inputJson:r,onChange:s=>{n&&n(s)}})},rt=t=>{const r=t.arch,n=t.fields,s=new se.Tree(n);return s.parse(r),s},Ws=(t,r,n)=>t.columns.map(o=>{const i=o.type,a=o.id,c=r==null?void 0:r[i];let d;return c&&(d=u=>c(u,a,o,n)),{key:a,dataIndex:a,title:o.label,render:d,sorter:(u,h)=>{var w,m;let p=u[a]||"",g=h[a]||"";return i==="many2one"&&(p=((w=u[a])==null?void 0:w.value)||"",g=((m=h[a])==null?void 0:m.value)||""),p<g?-1:p>g?1:0}}}),Hr=(t,r)=>r.map(s=>{const o={};return Object.keys(s).map(i=>{if(i==="id")o[i]=s[i];else{const a=t.findById(i);a instanceof se.Reference||a instanceof se.Selection?o[i]=s[i]:a instanceof se.Many2one?o[i]=s[i]&&Array.isArray(s[i])&&s[i].length===2&&{model:a.relation,id:s[i][0],value:s[i][1]}:a instanceof se.Boolean?o[i]=s[i]:a?o[i]=s[i]===!1?"":s[i]:o[i]=s[i]}}),o});function Ft(t){if(!t)return;const r={};return t.forEach(n=>{r[n.id]=n.colors}),r}function nt({resultsToSort:t,sorter:r,fields:n}){if(!r)return t;const{id:s,desc:o}=r,i=o===!1?"ascend":"descend",a=n[s].type,c=(d,u)=>{var g,w;let h=d[s]||"",p=u[s]||"";return a==="many2one"&&(h=((g=d[s])==null?void 0:g[1])||"",p=((w=u[s])==null?void 0:w[1])||""),h===p?0:i==="ascend"?h>p?1:-1:h<p?1:-1};return t.sort(c)}const Ut=async t=>{var m;const{items:r,model:n,formView:s,treeView:o,context:i,currentView:a={}}=t,c=r.filter(y=>y.operation!=="original"),d=r.filter(y=>y.operation==="original").map(y=>y.id),u={form:s.fields,tree:o.fields};let h=[],p;if(a==="tree"&&(o==null?void 0:o.arch)){const y=(m=rt(o))==null?void 0:m.colors,C=await W.getHandler().readEvalUiObjects({model:n,ids:d,arch:o==null?void 0:o.arch,fields:o.fields,context:i,attrs:y&&{colors:y}});h=C[0],p=Ft(C[1])}else h=await W.getHandler().readObjects({model:n,ids:d,fields:u[a],context:i});const g=h.map(y=>{const C={};return Object.keys(y).forEach(v=>{(u[a].hasOwnProperty(v)||v==="id")&&(C[v]=y[v])}),C});return[r.map(y=>{const C=g.find(E=>E.id===y.id),v={...y};return a==="form"?v.values=C:a==="tree"&&(v.treeValues=C),v}).concat(c),p]},qs=t=>{const r=t.filter(n=>n.id&&n.id<0).map(n=>n.id);return r.length===0?-1:Math.min(...r)-1},Ys=(t,r)=>{const n={};return Object.keys(t).forEach(s=>{var o;r.hasOwnProperty(s)&&(r[s].type==="one2many"||r[s].type==="many2many")&&t[s]&&((o=t[s])==null?void 0:o.items)?n[s]=t[s].items.filter(i=>i.operation!=="pendingRemove"):n[s]=t[s]}),n},Gs=t=>{const{ooui:r}=t,{relation:n,context:s,views:o}=r,[i,a]=l.useState(!0),[c,d]=l.useState(),[u,h]=l.useState(new Map),p=l.useContext(_e),{getContext:g}=p||{};Qe.default(()=>{m()},[r]);const w=async y=>o&&o[y]?o[y]:await W.getHandler().getView({model:n,type:y,context:{...g==null?void 0:g(),...s}}),m=async()=>{a(!0),d(void 0);try{const y=await w("form"),C=await w("tree");u.set("form",y),u.set("tree",C),h(u)}catch(y){d(y)}finally{a(!1)}};return i?e.jsx(f.Spin,{}):c?e.jsx(f.Alert,{className:"mt-10",message:c,type:"error",banner:!0}):e.jsx(me,{type:"array",...t,children:e.jsx(Us,{ooui:r,views:u})})},Us=t=>{const{value:r,views:n,ooui:s,onChange:o}=t,{items:i=[]}=r||{},[a,c]=l.useState(!1),[d,u]=l.useState(),[h,p]=l.useState(!1),[g,w]=l.useState(),{relation:m,context:y,readOnly:C,summaryField:v,titleField:E}=s,_=i.filter(b=>b.values),S=l.useContext(_e),{getContext:I}=S||{};Qe.default(()=>{N()},[i]);const D=b=>{o==null||o({items:b})};async function N(){c(!0),u(void 0);try{const[b]=await Ut({treeView:{fields:n.get("tree").fields,arch:n.get("tree").arch},formView:{fields:n.get("form").fields},model:m,items:i,context:{...I==null?void 0:I(),...y},currentView:"form"});D(b)}catch(b){u(b)}finally{c(!1)}}return d?e.jsx(f.Alert,{className:"mt-10",message:d,type:"error",banner:!0}):a?e.jsx(f.Spin,{}):e.jsxs(e.Fragment,{children:[e.jsx(f.Timeline,{style:{padding:"1rem"},children:_.map((b,x)=>{var O,T;return e.jsx("div",{children:e.jsxs(f.Timeline.Item,{children:[e.jsx("div",{style:{display:"inline-block",cursor:"pointer"},onClick:()=>{w(_.find(H=>b.id===H.id)),p(!0)},children:e.jsx("strong",{children:(O=b.values)==null?void 0:O[E]})}),e.jsx("br",{}),e.jsx("div",{style:{display:"inline-block",cursor:"pointer"},onClick:()=>{w(_.find(H=>b.id===H.id)),p(!0)},children:(T=b.values)==null?void 0:T[v]})]},x)},x)})}),e.jsx(lt,{formView:n.get("form"),model:m,id:g==null?void 0:g.id,values:g==null?void 0:g.values,defaultValues:g==null?void 0:g.defaultValues,visible:h,onSubmitSucceed:()=>{p(!1)},parentContext:{...I==null?void 0:I(),...y},onCancel:()=>{p(!1)},readOnly:C,postSaveAction:N})]})},{useToken:js}=f.theme,zs=t=>{const{ooui:r}=t;return e.jsx(me,{ooui:r,children:e.jsx(Js,{ooui:r})})},Js=t=>{const{token:r}=js(),{ooui:n,value:s}=t,o=e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[n.label," "]}),n.tooltip&&e.jsx(f.Tooltip,{title:n.tooltip,children:e.jsx(B.QuestionCircleOutlined,{className:"pr-1 text-xs",style:{color:r.colorPrimaryBg}})})]}),i=qe(n.icon);let a=s;n.selectionValues.size?a=n.selectionValues.get(s):Array.isArray(s)&&(a=s[1]);const c=e.jsx(f.Statistic,{title:o,prefix:i&&e.jsx(i,{}),suffix:n.suffix,value:a});return n.card?e.jsx(f.Card,{children:c}):c},Zs=(t,r)=>{if(!r)return t;const n={};return Object.keys(t).forEach(s=>{if(r[s]===void 0)n[s]=t[s];else if(!(t[s]===!1&&r[s].type!=="boolean"))if(r[s].type==="boolean"){const o=t[s];o===0?n[s]=!1:o===1?n[s]=!0:n[s]=t[s]}else n[s]=t[s]}),n},ot=(t,r)=>Zs(t,r),jt=({source:t,target:r,fields:n})=>{const s={};return Object.keys(r).forEach(o=>{var a,c;if(n[o]?n[o].type==="one2many"||n[o].type==="many2many":!1){const d=JSON.stringify(t[o]),u=JSON.stringify(r[o]);if(d===u)return;(((c=(a=r[o])==null?void 0:a.items)==null?void 0:c.filter(p=>p.operation!=="original"))||[]).length>0&&(s[o]=r[o])}else if(Array.isArray(r[o]))if(t[o]===void 0)s[o]=r[o];else if(n[o].type==="many2one")if(Array.isArray(t[o])){const d=JSON.stringify(t[o]),u=JSON.stringify(r[o]);d!==u&&(s[o]=r[o])}else{const d=t[o],[u]=r[o];d!==u&&(s[o]=r[o])}else{const d=JSON.stringify(t[o]),u=JSON.stringify(r[o]);d!==u&&(s[o]=r[o])}else t[o]!==r[o]&&(r[o]===void 0?s[o]=null:s[o]=r[o])}),s},Xs=({changedFields:t,formOoui:r,types:n})=>t.map(o=>{var a;const i=(a=r==null?void 0:r.findById(o))==null?void 0:a.type;return n.includes(i)}).some(o=>o===!0),Qs=({fieldsDomain:t,fields:r})=>{const n={};return Object.keys(r).forEach(s=>{n[s]=r[s],t[s]&&(n[s].domain=t[s])}),n},Rs=t=>{const r={};return!t||!Array.isArray(t)||(t==null?void 0:t.length)===0?{}:(t.forEach(n=>{(n==null?void 0:n[1])==="="&&(r[n[0]]=n[2])}),r)},ei=({onChangeFieldActionArgs:t,values:r,parentValues:n={}})=>{const s={};return t.forEach(o=>{const i=o.split("");if(o==="True")s[o]=!0;else if(o==="False")s[o]=!1;else if(r[o])s[o]=r[o];else if(i[0]==="'"&&i[i.length-1]==="'"&&i.filter(a=>a==="'").length===2)s[o]=o.replace(/'/g,"");else if(i.includes("'"))s[o]=o;else if(o.indexOf("parent.")!==-1){const a=o.replace("parent.","");s[o]=n[a]||!1}else s[o]=!1}),s},Kr=t=>{const r={primary:[],secondary:[]};return t.forEach(n=>{!n||(r.primary=r.primary.concat(n.primary),r.secondary=r.secondary.concat(n.secondary))}),{primary:r.primary.filter(Wr),secondary:r.secondary.filter(Wr)}};function Wr(t,r,n){return n.indexOf(t)===r}const st=({values:t,fields:r})=>{let n={};return Object.keys(t).forEach(s=>{const o=t[s];r[s]&&r[s].type==="many2one"&&o&&Array.isArray(o)&&o.length===2?n[s]=o[0]:n[s]=o}),n},qr=t=>{let r=0;for(let o=0;o<t.length;o++)r=t.charCodeAt(o)+((r<<5)-r);let n="#";for(let o=0;o<3;o++){var s=r>>o*8&255;n+=("00"+s.toString(16)).slice(-2)}return n},Yr=t=>{const{ooui:r}=t;return e.jsx(me,{type:"array",...t,children:e.jsx(ti,{ooui:r})})},ti=t=>{const{value:r,ooui:n,onChange:s}=t,{items:o=[]}=r||{},i=o.filter(D=>D.operation!=="pendingRemove").map(D=>D.id),[a,c]=l.useState([]),[d,u]=l.useState(),[h,p]=l.useState(!1),{relation:g,context:w,readOnly:m,field:y}=n,C=l.useContext(_e),{getContext:v}=C||{};Qe.default(()=>{_()},[o]);const E=D=>{s==null||s({items:D})};async function _(){p(!0);let D=[];try{if(m&&(D=[["id","in",i]]),n.domain){const x=await W.getHandler().evalDomain({domain:n.domain,values:st({fields:C==null?void 0:C.getFields(),values:C.getPlainValues()}),fields:C==null?void 0:C.getFields(),context:C.getContext()});D=[...D,...x]}const b=(await W.getHandler().search({model:g,params:D,fields:[y],context:{...v==null?void 0:v(),...w}})).map(x=>{const O=x[y];let T=O;return Array.isArray(O)&&(T=O[1]),{label:T,value:x.id}});c(b)}catch(N){u(N)}finally{p(!1)}}const S=D=>{const N=o.map(x=>D.includes(x.id)?x.operation=="pendingRemove"?{...x,operation:"pendingLink"}:x:{id:x.id,operation:"pendingRemove"}),b=N.map(x=>x.id);D.filter(x=>!b.includes(x)).map(x=>{N.push({id:x,operation:"pendingLink"})}),E(N)},I=D=>{const{label:N,closable:b,onClose:x}=D,O=T=>{T.preventDefault(),T.stopPropagation()};return e.jsx(f.Tag,{color:qr(N),onMouseDown:O,style:{margin:"5px"},closable:b,onClose:x,children:N})};return d?e.jsx(f.Alert,{className:"mt-10",message:d,type:"error",banner:!0}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-row",children:e.jsx(f.Select,{mode:"multiple",value:a.length?i:[],tagRender:I,bordered:!m,disabled:m,options:a,onChange:S,loading:h})})})},ri=t=>{switch(t){case"form":return at;case"tree":return Ct;case"notebook":return yn;case"group":return tr;case"label":return pt;case"char":return qt;case"text":return wn;case"button":return Wt;case"buttonGroup":return br;case"selection":return Yt;case"many2one":return ln;case"boolean":return _r;case"integer":return vt;case"float":return Jt;case"progressbar":return Rr;case"date":return xn;case"datetime":return Tn;case"one2many":case"one2many_list":case"many2many":return gn;case"separator":return vn;case"reference":return Fn;case"binary":return On;case"image":return Br;case"url":return In;case"email":return Mn;case"float_time":return mn;case"fiber_grid":return Hs;case"timeline":return Gs;case"indicator":return zs;case"tags":return Yr;case"tag":return Hn;case"multicheckbox":return Kn;case"markdown":return Wn;case"radio":return qn;case"switch":return Yn;case"steps":return Gn;case"codeeditor":return Un;default:return}},ni=t=>{const{ooui:r}=t,{type:n}=r,s=ri(n);return s?Pe.default.createElement(s,t):null},oi=({item:t,responsiveBehaviour:r})=>({gridColumnStart:"span "+(r?1:t.colspan)}),si=({row:t,mustFillWithEmpties:r,numberOfColumns:n})=>{const s=[];let o=0;const i=a=>a+1===t.length&&o<n&&!r;return t.map((a,c)=>{if(o+=a.colspan,i(c)){const d=n-o;a.colspan=a.colspan+d,o+=d}if(s.push(a),i(c)){const d=n-o;for(let u=0;u<d;u+=1)s.push(new se.Label({string:""}))}}),s},ii=({row:t,numberOfColumns:r})=>t.map(n=>(n._mustExpand&&(n.colspan=r),n)),ai=(t,r)=>{const n=t.map(s=>s instanceof se.Label&&s.fieldForLabel||s instanceof se.Container?"auto":"1fr");if(n.length<r){const s=r-n.length;for(let o=0;o<s;o++)n.push("1fr")}return n.join(" ")},li=(t,r)=>{const n=r?"1fr":"auto",s="auto";let o="";for(let i=0;i<t;i++)o+=i%2?n:s,i+1<t&&(o+=" ");return o},ci=t=>t.map(n=>n.reduce((s,o)=>s+o.colspan,0)).reduce((n,s)=>Math.max(n,s)),zt=t=>{const{container:r,responsiveBehaviour:n}=t,{rows:s}=r;let{columns:o}=r;const i=ci(s);i<o&&(o=i);let a=!1,c=[];const d=s.map((p,g)=>{const w=p.filter(C=>!C.invisible),m=ii({row:w,numberOfColumns:o});let y=m;return(g===0||!(p.length===1&&p.some(C=>C.type==="group")))&&(y=si({row:m,numberOfColumns:o,mustFillWithEmpties:n}),c=c.concat(y)),y.map(C=>(C instanceof se.Label&&C.fieldForLabel&&(a=!0),e.jsx("div",{style:{...oi({item:C,responsiveBehaviour:n}),minWidth:0},children:ni({ooui:C,responsiveBehaviour:n})},C.key)))}),u=s.length===1?ai(c,o):li(o,a),h={display:"grid",gridTemplateColumns:n?"auto":u,gap:"1rem",minHeight:0,minWidth:0};return e.jsx("div",{style:h,children:d})},{confirm:di}=f.Modal,yt=({onOk:t,onCancel:r,lang:n})=>{di({title:Se("unsavedChanges",n),icon:e.jsx(B.ExclamationCircleOutlined,{}),centered:!0,content:Se("confirmCloseWithoutSave",n),okText:Se("closeWithoutSaving",n),onOk:t,onCancel:r,cancelText:Se("cancel",n)})},{error:ui}=f.Modal,Gr=t=>{ui({title:Se("formHasErrors",t),icon:e.jsx(B.ExclamationCircleOutlined,{}),centered:!0,content:Se("fillRequiredFields",t)})},{warning:fi}=f.Modal,hi=(t,r,n)=>{fi({title:t,icon:e.jsx(B.WarningOutlined,{}),centered:!0,content:r,onOk:n})},Ur=Pe.default.createContext(null),pi=t=>{const{children:r,setTitle:n}=t;return e.jsx(Ur.Provider,{value:{setTitle:n},children:r})},jr=t=>typeof t=="string"&&t==="true"||t==="false"?t==="true":t,gi=(t,r)=>{const n=bi(t),s=vi(n),o=Ci(s,r);return[...Object.keys(o).map(c=>mi(c,o[c],r))].reduce((c,d)=>Array.isArray(d[0])?c.concat(d):[...c,d],[])},mi=(t,r,n)=>{var i;const s=t.split("#")[0],o=(i=n.findById(s))==null?void 0:i.type;if(o==="char"||o==="text"||o==="many2one"||o==="many2many"||o==="one2many")return[t,"ilike",r];if(o==="float"||o==="integer"||o==="float_time"||o==="progressbar"){const a=t.indexOf("#from")!==-1?">=":"<=";return[s,a,r]}else if(o==="date"){const a=t.indexOf("#from")!==-1?">=":"<=";return[s,a,r.format("YYYY-MM-DD")]}else if(o==="datetime"){const a=[];return r[0]&&a.push([s,">=",r[0]]),r[1]&&a.push([s,"<=",r[1]]),a}else return o==="selection"?[t,"in",r.map(a=>jr(a))]:[t,"=",jr(r)]},yi=t=>Object.keys(t).filter(r=>r.indexOf("#date")!==-1),wi=t=>{const r={...t};return Object.keys(r).forEach(n=>(n.indexOf("#time")!==-1||n.indexOf("#date")!==-1)&&delete r[n]),r},vi=t=>{const r={...wi(t)};return yi(t).forEach(s=>{const o=t[s],i=s.split("#")[0],a=i+"#time",c=t[a];let d,u;if(o[0]!==null&&(d=o[0].format("YYYY-MM-DD"),c&&c[0]!==null)){const p=c[0].format("HH:mm:ss");d=d+" "+p}if(o[1]!==null&&(u=o[1].format("YYYY-MM-DD"),c&&c[1]!==null)){const p=c[1].format("HH:mm:ss");u=u+" "+p}r[i+"#datetime"]=[d,u]}),r},Ci=(t,r)=>{const n=Object.keys(t).filter(o=>{const i=r.findById(o);return i&&i.type==="date"});let s={...t};return n.forEach(o=>{delete s[o],t[o][0]!==null&&(s[o+"#from"]=t[o][0]),t[o][1]!==null&&(s[o+"#to"]=t[o][1])}),s},bi=t=>{const r={...t};return Object.keys(r).forEach(n=>(r[n]===void 0||r[n]===null||r[n]==="")&&delete r[n]),r},Si=t=>{const r={};return t.forEach(n=>{Array.isArray(n)&&n[0]?r[n[0]]=!0:r[n]=!0}),Object.keys(r)},Ot=(t,r)=>{const n=[...t],s=Si(t);return r.forEach(o=>{Array.isArray(o)&&o[0]?s.includes(o[0])||n.push(o):s.includes(o)||n.push(o)}),n},wt=80,zr=t=>{const{model:r,setSearchTreeNameSearch:n,setSelectedRowItems:s,setSearchParams:o,setSearchVisible:i,setTreeIsLoading:a,nameSearch:c,searchNameGetDoneRef:d,context:u,setActionViewTotalItems:h,treeView:p,formView:g,sorter:w,setSorter:m,setCurrentItemIndex:y,setResultsActionView:C,resultsActionView:v,domain:E,currentId:_,limit:S,setLimit:I,searchParams:D=[],setSearchValues:N}=t,[b,x]=l.useState(!1),[O,T]=l.useState(!1),[H,F]=l.useState(),[A,k]=l.useState(1),[L,V]=l.useState(0),[M,K]=l.useState(),[q,z]=l.useState([]),[Y,Z]=l.useState(void 0),J=l.useRef(S||wt),$=l.useRef([]),P=l.useCallback(oe=>{C==null||C([...oe]),z([...oe])},[]),ee=l.useCallback(()=>v||q,[v,q]),le=l.useCallback(async()=>{const oe=await W.getHandler().nameSearch({model:r,payload:c,limit:J.current,attrs:E,context:u});if(K(oe.length),h==null||h(oe.length),oe.length>0){const be=oe.map(Ie=>Ie==null?void 0:Ie[0]),{colors:ye}=rt(p),xe=await W.getHandler().readEvalUiObjects({model:r,ids:be,arch:p==null?void 0:p.arch,fields:p.field_parent?{...p.fields,[p.field_parent]:{}}:p.fields,context:u,attrs:ye&&{colors:ye}}),Ee=xe[0];$.current=[...Ee],Z(Ft(xe[1]));const Ve=Ee.map(Ie=>Ie.id),He=w!==void 0?nt({resultsToSort:Ee,sorter:w,fields:{...p.fields,...g.fields}}):[...$.current];P(He),Ve.length>0?y==null||y(0):y==null||y(void 0)}else P([]),y==null||y(void 0);d.current=!0},[P,d,c,r,u,E,p,g,w,y,h]),ce=l.useCallback(async oe=>{const{params:be,newOffset:ye}=oe||{},xe=Ot(be||D,E),{colors:Ee}=rt(p),{totalItems:Ve,results:He,attrsEvaluated:Ie}=await W.getHandler().searchForTree({params:xe,limit:J.current,offset:ye||L,model:r,fields:p.field_parent?{...p.fields,[p.field_parent]:{}}:p.fields,context:u,attrs:Ee&&{colors:Ee}});Z(Ft(Ie)),$.current=[...He];const R=w!==void 0?nt({resultsToSort:He,sorter:w,fields:{...p.fields,...g.fields}}):[...$.current];if(P(R),v&&R.length>0){const he=R.findIndex(Oe=>_===Oe.id);he===-1?y==null||y(0):y==null||y(he)}else y==null||y(void 0);const ae=await Ve;K(ae),h==null||h(ae)},[y,v,P,_,r,u,E,p,g,w,h,S,L,D]),re=l.useCallback(async oe=>{try{x(!0),a==null||a(!0),c&&!d.current?await le():await ce(oe)}catch(be){F(be.message)}finally{x(!1),T(!1),a==null||a(!1)}},[u,_,E,g,S,r,c,L,v,d,h,y,P,F,T,x,a,w,p]),X=l.useCallback(oe=>{m==null||m(oe);const be=oe!==void 0?nt({resultsToSort:ee(),sorter:oe,fields:{...p.fields,...g.fields}}):[...$.current];P(be)},[m,ee,p,g,P]),we=l.useCallback(oe=>{const{params:be,searchValues:ye,limit:xe,offset:Ee}=oe;b||(n==null||n(void 0),s==null||s([]),N==null||N(ye),o==null||o(be),i==null||i(!1),T(!0),F(void 0),k(1),xe&&(J.current=xe,I==null||I(xe)),Ee&&V(Ee),re({params:be,newOffset:Ee}))},[b,n,s,o,i,T,F,k,I,V,re]),Ce=l.useCallback(oe=>{x(!0),k(oe),V((oe-1)*S)},[x,S,V,k]),ke=l.useCallback(()=>{b||(n==null||n(void 0),o==null||o([]),N==null||N({}),F(void 0),V(0),k(1),I==null||I(S||wt))},[b,n,o,F,V,k,I,S]),fe=l.useCallback(async oe=>{const be=oe[(p==null?void 0:p.field_parent)||"child_id"],ye=await W.getHandler().readObjects({model:r,ids:be,fields:p.field_parent?{...p.fields,[p.field_parent]:{}}:p.fields,context:u});return P([...ee(),...ye]),Hr(rt(p),ye)},[p,r,u,ee,P]);return{submit:we,clear:ke,fetchResults:re,tableRefreshing:b,searchFilterLoading:O,searchError:H,page:A,offset:L,limit:S,getResults:ee,requestPageChange:Ce,changeSort:X,fetchChildrenForRecord:fe,colorsForResults:Y,totalItems:M}},Be=Pe.default.createContext(null),xi=t=>{const{children:r,currentView:n,title:s,setCurrentView:o,availableViews:i,formRef:a,searchTreeRef:c,onNewClicked:d,currentId:u,setCurrentId:h,setResults:p,results:g,currentItemIndex:w,setCurrentItemIndex:m,currentModel:y,sorter:C,setSorter:v,totalItems:E,setTotalItems:_,setSelectedRowItems:S,selectedRowItems:I,searchTreeNameSearch:D,setSearchTreeNameSearch:N,goToResourceId:b,limit:x}=t,[O,T]=l.useState(!1),[H,F]=l.useState(!1),[A,k]=l.useState(!1),[L,V]=l.useState(!0),[M,K]=l.useState(!0),[q,z]=l.useState([]),[Y,Z]=l.useState(!1),[J,$]=l.useState([]),[P,ee]=l.useState(!1),[le,ce]=l.useState(!0),[re,X]=l.useState(),[we,Ce]=l.useState({}),[ke,fe]=l.useState(x!==void 0?x:wt),[oe,be]=l.useState(s);l.useEffect(()=>{g&&g.length>0&&!w&&(m==null||m(0),h==null||h(g[0].id))},[g]),l.useEffect(()=>{fe(x!==void 0?x:wt)},[x]),l.useEffect(()=>{i.length===1?X(i[0]):i.length>1&&X(i.filter(xe=>xe.view_id!==n.view_id)[0])},[i]),l.useEffect(()=>{(re==null?void 0:re.view_id)===n.view_id&&i.length>1&&X(i.filter(xe=>xe.view_id!==n.view_id)[0])},[n]);const ye=async()=>{var xe;return await((xe=a.current)==null?void 0:xe.submitForm())};return e.jsx(Be.Provider,{value:{title:oe,currentView:n,setCurrentView:o,availableViews:i,formIsSaving:O,setFormIsSaving:T,formHasChanges:H,setFormHasChanges:F,formRef:a,searchTreeRef:c,onFormSave:ye,onNewClicked:d,currentId:u,setCurrentId:h,currentItemIndex:w,setCurrentItemIndex:m,results:g,setResults:p,currentModel:y,removingItem:A,setRemovingItem:k,formIsLoading:L,setFormIsLoading:V,treeIsLoading:M,setTreeIsLoading:K,attachments:q,setAttachments:z,selectedRowItems:I,setSelectedRowItems:S,duplicatingItem:Y,setDuplicatingItem:Z,setSearchParams:$,searchParams:J,searchVisible:P,setSearchVisible:ee,sorter:C,setSorter:v,totalItems:E,setTotalItems:_,searchTreeNameSearch:D,setSearchTreeNameSearch:N,setGraphIsLoading:ce,graphIsLoading:le,previousView:re,setPreviousView:X,goToResourceId:b,searchValues:we,setSearchValues:Ce,limit:ke,setLimit:fe,setTitle:be},children:r})},Ye=Pe.default.createContext(null),Ti=t=>{const{children:r,openAction:n,openRelate:s,openDefaultActionForModel:o,openShortcut:i,activeKey:a,onChangeTab:c,onRemoveTab:d,tabs:u}=t,[h,p]=l.useState(),[g,w]=l.useState();return e.jsx(Ye.Provider,{value:{openAction:n,openRelate:s,openDefaultActionForModel:o,activeKey:a,openShortcut:i,onChangeTab:c,onRemoveTab:d,tabs:u,currentId:g,currentView:h,setCurrentId:w,setCurrentView:p},children:r})},it=Pe.default.createContext(null),Jr=async t=>{var r;for(let n=0;n<t.length;n++)await((r=t==null?void 0:t[n])==null?void 0:r.call(t))},Fi=(t,r)=>{const{children:n,globalValues:s={}}=t,o=l.useRef(),i=l.useRef(),[a,c]=l.useState(!1),d=l.useContext(Ye),{openAction:u}=d||{},h=l.useRef([]),{t:p}=l.useContext(ge);l.useImperativeHandle(r,()=>({openActionModal:S}));const[g,w]=l.useState(!1),[m,y]=l.useState({context:{}});async function C(N){const{reportData:b,fields:x,values:O,context:T={}}=N,{context:H,model:F,datas:A={},report_name:k,type:L}=b;if(L!=="ir.actions.report.xml"){Me(`${L} action not supported`);return}const{ids:V}=A||{};let M=V||[];const K=typeof H=="string"?se.parseContext({context:H,fields:x,values:O}):H;try{const q=await W.getHandler().createReport({model:F,name:k,datas:A,ids:M,context:{...T,...K}});c(!0),i.current=!0,o.current=setInterval(()=>{v(q)},1e3)}catch(q){i.current=!1,clearInterval(o.current),Me(q),c(!1)}}async function v(N){let b;try{if(b=await W.getHandler().getReport({id:N}),b.state&&i.current===!0){i.current=!1,clearInterval(o.current),c(!1);const x=await tt(b.result);Tt(b.result,x.mime)}}catch(x){i.current=!1,clearInterval(o.current),c(!1),Me(x.exception||x)}}async function E({actionData:N,fields:b,values:x,context:O,onRefreshParentValues:T}){const{type:H}=N;return h.current.push(T),H==="ir.actions.report.xml"?await C({reportData:N,fields:b,values:x,context:O}):H==="ir.actions.act_window"?await _({actionData:N,fields:b,values:x,context:O}):(Me(`${H} action not supported`),{})}async function _({actionData:N,fields:b={},values:x={},context:O={}}){var k;let T=N;N.res_model||(T=(await W.getHandler().readObjects({model:"ir.actions.act_window",ids:[parseInt(N.id)],context:O}))[0]);const F={...typeof(T==null?void 0:T.context)=="string"?se.parseContext({context:T.context,fields:b,values:{...x,...s}}):T.context,...O};let A=[];if(T.domain&&(A=await W.getHandler().evalDomain({domain:T.domain,values:st({fields:b,values:{...x,...s}}),fields:b,context:F})),T.target==="new"){const L=await W.getHandler().getView({model:T.res_model,type:"form",id:((k=T==null?void 0:T.view_id)==null?void 0:k[0])||void 0,context:F});return S({domain:A,model:T.res_model,formView:L,context:F}),{}}else{const{initialView:L,views:V}=await Oi({model:T.res_model,context:F,view_mode:T.view_mode,views:T.views});return u==null||u({target:"current",context:F,domain:A,model:T.res_model,views:V,title:T.name,initialView:L,action_id:T.id,action_type:T.type}),{closeParent:!0}}}function S({domain:N,model:b,formView:x,context:O,actionData:T}){g?I({domain:N,model:b,formView:x,context:O,actionData:T}):(y({domain:N,model:b,context:O,formView:x,actionData:T}),w(!0))}async function I({domain:N,model:b,formView:x,context:O,actionData:T}){y({domain:void 0,model:void 0,context:{},formView:void 0,actionData:void 0}),w(!1),await new Promise(H=>setTimeout(H,300)),y({domain:N,model:b,context:O,formView:x,actionData:T}),w(!0)}async function D(){Jr(h.current),h.current=[],w(!1),y({domain:void 0,model:void 0,context:{},formView:void 0,actionData:void 0})}return e.jsx(e.Fragment,{children:e.jsx(it.Provider,{value:{processAction:E,globalValues:s},children:e.jsxs(e.Fragment,{children:[n,e.jsx(f.Modal,{title:p("generatingReport"),open:a,footer:null,closable:!1,centered:!0,maskClosable:!1,children:e.jsx(f.Spin,{})}),e.jsx(lt,{buttonModal:!0,parentContext:m.context,model:m.model,formView:m.formView,visible:g,onSubmitSucceed:D,onCancel:()=>{Jr(h.current),h.current=[],w(!1),y({domain:void 0,model:void 0,context:{},formView:void 0,actionData:void 0})},showFooter:!1,actionDomain:m.domain,isMenuAction:(m==null?void 0:m.actionData)!==void 0,actionData:m==null?void 0:m.actionData})]})})})};async function Oi({views:t,view_mode:r,model:n,context:s,view_id:o}){const i=[];let a;if(t)for(const c of t){const d=await W.getHandler().getView({model:n,type:c[1],id:c[0],context:s});i.push([d.view_id,c[1]])}else{const c=r.split(",");for(const d of c){const u=await W.getHandler().getView({model:n,type:d,context:s});i.push([u.view_id,d])}}if(t&&t.length>0){const[c,d]=t[0];a={id:c,type:d}}else if(o)a={id:o,type:r.split(",")[0]};else{const c=r.split(",")[0],[d]=i.find(([u,h])=>h===c);a={id:d,type:c}}return{views:i,initialView:a}}const Zr=l.forwardRef(Fi),_i=({error:t,className:r})=>{let n,s="error";if(typeof t=="string"&&t.indexOf(" -- ")!==-1&&t.indexOf(`
18
18
 
19
- `)!==-1){const{message:o,type:i,title:a}=xr(t);n=e.jsx(Pt.Interweave,{content:`${a}<br />${o}`}),s=i}else n=t.message?JSON.stringify(t.message):JSON.stringify(t);return e.jsx(f.Alert,{className:r,message:n,type:s,banner:!0})},Di=800;function Vi(t,r){const{model:n,id:s,onCancel:o,onSubmitSucceed:i,showFooter:a=!1,getDataFromAction:c=!1,onFieldsChange:d,onSubmitError:u,readOnly:h=!1,mustClearAfterSave:p=!1,submitMode:g="api",values:w,formView:m,postSaveAction:y,insideButtonModal:C=!1,parentContext:v={},actionDomain:E,visible:_=!0,rootForm:S=!1,defaultValues:I,forcedValues:D={}}=t,{t:N,lang:b}=l.useContext(ge),[x,O]=l.useState(!1),[T,H]=l.useState(),[F,A]=l.useState(),[k]=f.Form.useForm(),[L,V]=l.useState(),[M,K]=l.useState(),q=l.useContext(Ur),[z,Y]=l.useState(),[Z,J]=l.useState(!1),$=l.useRef(),P=l.useRef({}),ee=l.useRef({}),le=l.useRef(!1),ce=l.useRef(!1),re=z<Di,X=l.useContext(_e),{activeId:we,getPlainValues:Ce}=X||{},ke=l.useContext(Be),{setFormIsSaving:fe=void 0,setFormHasChanges:oe=void 0,setCurrentId:be=void 0,setFormIsLoading:ye=void 0,setAttachments:xe=void 0,title:Ee=void 0,setTitle:Ve=void 0}=(S?ke:{})||{},He=l.useContext(it),{processAction:Ie,globalValues:R}=He||{};l.useImperativeHandle(r,()=>({submitForm:Lt,getFields:Ae,getValues:De,getPlainValues:Ze,getContext:Ge,fetchValues:je,cancelUnsavedChanges:Xe,clearAndReload:()=>{$.current=void 0,A(void 0),Ue()}})),l.useEffect(()=>{if(H(void 0),!(!n&&!m)){if(!_){$.current=void 0,A(void 0);return}(s===void 0&&M||s!==void 0&&M&&s<0)&&($.current=void 0,A(void 0)),Ue()}},[s,n,w,m,_]),l.useEffect(()=>{Z&&(cr({elementHasLostFocus:!0}),J(!1))},[Z]);const ae=(j,U,te)=>{oe==null||oe(!1),fe==null||fe(!1),i==null||i(j,U,te),be==null||be(j)},he=()=>{fe==null||fe(!1),o==null||o()},Oe=j=>{fe==null||fe(!1),u==null||u(j)};function ue(){return s||$.current}function Ae(){return M}function De(){const j={...ie(M),...Q()};for(const U in j)j[U]===void 0&&delete j[U];return j}function Ze(){const j=De(),U=Ae();let te={};return Object.keys(j).forEach(ne=>{const Fe=j[ne];U[ne]&&U[ne].type==="many2one"&&Fe&&Array.isArray(Fe)&&Fe.length===2?te[ne]=Fe[0]:U[ne]&&(U[ne].type==="one2many"||U[ne].type==="many2many")&&Fe&&Fe.items?te[ne]=Fe.items.filter(Re=>Re.operation!=="pendingRemove").map(Re=>Re.id):te[ne]=Fe}),te}function Ke(){const j={...ie(M)};for(const U in j)j[U]===void 0&&delete j[U];return j}function Ge(){return{...v,...F==null?void 0:F.context}}function Q(){return{id:ue(),active_id:ue(),active_ids:[ue()],parent_id:we,...R}}const de=async j=>{const U=ue()?F==null?void 0:F.context:{};return await W.getHandler().defaultGet({model:n,fields:j,context:{...v,...U},extraValues:I})},Te=()=>Object.keys(jt({source:P.current,target:ie(M),fields:M})).length!==0,ie=j=>{const U=k.getFieldsValue(!0);return ot(U,j)},ve=(j,U)=>{$t({values:{...ot(k.getFieldsValue(!0),M),[j]:U},fields:M,reset:!1})},pe=j=>k.getFieldsValue(!0)[j];async function $e(){try{return await k.validateFields(),!1}catch{return f.message.error(N("fillRequiredFields")),!0}}const Ue=async()=>{H(void 0),ye==null||ye(!0);let j;try{m?j={arch:m.arch,fields:m.fields}:j=await Zl();const{fields:U,arch:te}=j;K(U),V(te),await je({fields:U,arch:te})}catch(U){H(U!=null&&U.message?U.message+U.stack:U),ye==null||ye(!1)}},je=async j=>{let U,te,ne,Fe;ye==null||ye(!0),H(void 0),j?(te=j.fields,ne=j.arch):(te=M,ne=L),w?U=w:{values:U,defaultGetCalled:Fe}=await Xl({fields:te,arch:ne}),E&&(U={...Rs(E),...U}),P.current=ot(U,te),$t({values:U,fields:te,reset:!0,isDefaultGet:Fe}),Nt({fields:te,arch:ne,values:U}),ye==null||ye(!1),oe==null||oe(!1),Fe&&J(!0)},Xe=async()=>new Promise(async j=>{Te()?yt({lang:b,onOk:()=>{he==null||he(),j(!0)},onCancel:()=>{j(!1)}}):(he==null||he(),j(!0))}),Zl=async()=>{if(c){const j=await W.getHandler().getActionStringForModel(n);return(await W.getHandler().getViewsForAction({action:j,context:v})).views.get("form")}return await W.getHandler().getView({model:n,type:"form",context:v})},$t=({values:j,fields:U,reset:te,isDefaultGet:ne=!1})=>{const Re={...te?{}:k.getFieldsValue(!0),...j},dr=ot(Re,U),dc=Object.keys(U).map(ur=>{const uc=dr[ur]!==void 0?dr[ur]:void 0;return{name:ur,touched:!1,value:uc}});ne||(ee.current=dr),k.setFields(dc)},Xl=async({fields:j,arch:U})=>{let te={},ne=!1;if(ue()){te=(await W.getHandler().readObjects({model:n,ids:[ue()],fields:j,context:v}))[0];const Fe=await W.getHandler().search({params:[["res_model","=",n],["res_id","=",ue()]],fields:["id","name"],context:Ge(),model:"ir.attachment"});xe==null||xe(Fe)}else xe==null||xe([]),te=await de(j),ne=!0;return{values:te,defaultGetCalled:ne}},Ql=async j=>{const{callOnSubmitSucceed:U=!0}=j||{};if(ue()){const te=jt({source:P.current,target:ie(M),fields:M});await W.getHandler().update({model:n,id:ue(),values:{...te,...D},fields:M,context:{...v,...F==null?void 0:F.context}}),P.current=ie(M)}else{const te=ie(M),ne=await W.getHandler().create({model:n,values:{...te,...D},fields:M,context:{...v,...F==null?void 0:F.context}});$.current=ne,P.current=te}y&&await y([ue()]),!C&&U&&(ae==null||ae(ue(),De(),Ke()))},Rl=async j=>{const{callOnSubmitSucceed:U=!0}=j||{};!C&&U&&(ae==null||ae(ue(),De(),Ke()))},Lt=async j=>{let U=!1;const{callOnSubmitSucceed:te=!0}=j||{};if(ce.current=!0,H(void 0),!Te()&&ue()&&te)return ce.current=!1,oe==null||oe(!1),he==null||he(),{succeed:!0,id:ue()};if(await $e())return ce.current=!1,Gr(b),{succeed:!1,id:ue()};O(!0),fe==null||fe(!0);try{g==="api"?await Ql(j):await Rl(j),p&&($.current=void 0,$t({values:{},fields:M,reset:!0})),await je(),U=!0,f.message.success(N("savedRegisters"))}catch(ne){ce.current=!1,O(!1),fe==null||fe(!1),Oe==null||Oe(ne),f.message.error(N("errorWhileSavingForm")),H(ne!=null&&ne.message?ne.message:ne)}finally{ce.current=!1,fe==null||fe(!1),O(!1)}return{succeed:U,id:ue()}},Nt=({fields:j,arch:U,values:te})=>{var Fe;const ne=new se.Form(j);ne.parse(U,{readOnly:h,values:Ys({...te,...Q()},j)}),A(ne),ne.string&&ne.string!==Ee&&(Ve==null||Ve(ne.string)),q&&ne.string&&((Fe=q.setTitle)==null||Fe.call(q,ne.string))},cr=async({elementHasLostFocus:j=!1})=>{if(ce.current)return;const U=jt({source:ee.current,target:ie(M),fields:M}),te=Object.keys(U);if(te.length!==0){if(Xs({changedFields:te,formOoui:F,types:["text","codeeditor","email","url","char","float","float_time","integer","many2one"]})&&j!==!0)return;{const ne=ot(k.getFieldsValue(!0),M);ee.current=ne,d==null||d(ne),oe==null||oe(!0),tc(te)}}},ec=Ns(cr,100),tc=async j=>{try{for(let U=0;U<j.length;U+=1){const te=j[U];await rc(te)}}catch(U){Me(U)}},rc=async j=>{const U=F==null?void 0:F.onChangeFields[j];if(!U){Nt({fields:M,arch:L,values:ie(M)});return}const te=ei({values:{...ie(M),context:{...v,...F==null?void 0:F.context}},parentValues:Ce==null?void 0:Ce(),onChangeFieldActionArgs:U.args}),ne=await W.getHandler().executeOnChange({model:n,action:U.method,ids:ue()?[ue()]:[],payload:te,fields:M});if(ne.value){const Fe={...ie(M),...ne.value};Nt({fields:M,arch:L,values:Fe}),$t({values:Fe,fields:M,reset:!1})}if(ne.warning&&ne.warning.title&&ne.warning.message&&!le.current){const{title:Fe,message:Re}=ne.warning;le.current=!0,hi(Fe,Re,()=>{le.current=!1})}if(ne.domain&&Object.keys(ne.domain).length>0){const Fe=Qs({fieldsDomain:ne.domain,fields:M});Nt({fields:Fe,arch:L,values:ie(Fe)}),K(Fe)}};async function nc({action:j,context:U}){const te=await W.getHandler().execute({model:n,action:j,payload:[ue()],context:{...U,...F==null?void 0:F.context,...v}});if(typeof te=="object"&&te!==null&&Object.keys(te).length===0&&C)ae==null||ae(ue(),De(),Ke());else if(te.type&&te.type==="ir.actions.act_window_close")ae==null||ae(ue(),De(),Ke());else if(te.type){let ne={};te.context&&(ne=se.parseContext({context:te.context,fields:M,values:De()})),await jn({actionData:te,context:{...U,...ne}})}else await je()}async function oc({action:j}){const U=await W.getHandler().executeWorkflow({model:n,action:j,payload:ue()});U.type&&U.type==="ir.actions.act_window_close"?ae==null||ae(ue(),De(),Ke()):await je()}async function sc({action:j,context:U}){const te=(await W.getHandler().readObjects({model:"ir.actions.actions",ids:[parseInt(j)],context:v}))[0];await jn({actionData:te,context:U})}async function jn({actionData:j,context:U}){const{closeParent:te}=await(Ie==null?void 0:Ie({actionData:j,fields:M,values:De(),context:{...v,...F==null?void 0:F.context,...U},onRefreshParentValues:()=>{je()}}))||{};!S&&te&&(ae==null||ae(ue(),De(),Ke()))}function ic(){cr({elementHasLostFocus:!0})}async function ac({type:j,action:U,context:te}){if(j==="cancel"){he==null||he();return}if(await $e()){Gr(b);return}try{(Te()||ue()===void 0)&&await Lt({callOnSubmitSucceed:!1}),j==="object"?await nc({action:U,context:te}):j==="workflow"?await oc({action:U}):j==="action"&&await sc({action:U,context:te})}catch(ne){Me(ne)}}const lc=()=>!F&&!T?e.jsx(f.Spin,{}):!n&&!m||!_?null:e.jsx(e.Fragment,{children:e.jsx(bo,{getValues:De,getPlainValues:Ze,getFields:Ae,domain:E,activeId:s,activeModel:n,setFieldValue:ve,getFieldValue:pe,executeButtonAction:ac,getContext:Ge,submitForm:Lt,fetchValues:je,formHasChanges:Te,elementHasLostFocus:ic,children:e.jsx(f.Form,{form:k,onFieldsChange:()=>{ec({elementHasLostFocus:!1})},component:!1,children:F&&e.jsx(zt,{container:F.container,responsiveBehaviour:re})})})}),cc=()=>e.jsxs(e.Fragment,{children:[e.jsx(f.Divider,{}),e.jsx(f.Row,{justify:"end",children:e.jsxs(f.Space,{children:[e.jsx(f.Button,{icon:e.jsx(B.CloseOutlined,{}),disabled:x,onClick:async()=>{await Xe()},children:"Cancel"}),e.jsx(f.Button,{disabled:x||h,loading:x,icon:e.jsx(B.CheckOutlined,{}),onClick:async()=>{await Lt()},type:"primary",children:"OK"})]})})]});return _?e.jsx(Ht.default,{bounds:!0,onResize:j=>{var U;Y((U=j.bounds)==null?void 0:U.width)},children:({measureRef:j})=>e.jsxs("div",{className:"pb-2",ref:j,children:[T&&e.jsx(_i,{className:"mt-10 mb-20",error:T}),lc(),a&&cc()]})}):null}const at=l.forwardRef(Vi),lt=t=>{const{visible:r,id:n,title:s,buttonModal:o=!1,onCancel:i,isMenuAction:a=!1,actionData:c,...d}=t,{modalWidth:u}=xt(),[h,p]=l.useState(s),[g,w]=l.useState(!1),[m,y]=l.useState();l.useEffect(()=>{a&&C()},[c,a]);async function C(){const{action_id:_,res_id:S,action_type:I,view_id:D}=c,N=await W.getHandler().isShortcutFavorite({action_id:_,action_type:I,view_id:D,res_id:S||!1});w(N!==!1),N!==!1&&y(N)}async function v(){if(g&&m)await W.getHandler().removeFavourite({shortcut_id:m});else{const{action_id:_,res_id:S,action_type:I,view_id:D}=c;await W.getHandler().addFavourite({action_id:_,action_type:I,view_id:D,res_id:S||!1})}w(!g)}function E(){return e.jsxs(f.Row,{align:"middle",children:[e.jsx(f.Col,{children:e.jsx(f.Button,{type:g?"primary":"default",icon:g?e.jsx(B.StarFilled,{style:{color:"white"}}):e.jsx(B.StarOutlined,{}),style:{width:30},onClick:v})}),e.jsx(f.Col,{style:{paddingLeft:10},children:h})]})}return e.jsx(pi,{setTitle:p,children:e.jsx(f.Modal,{title:a?E():h,centered:!0,width:u,open:r,footer:null,destroyOnClose:!0,onCancel:i,maskClosable:!1,children:e.jsx(at,{id:n,showFooter:!0,insideButtonModal:o,onCancel:i,...d})})})},ki=t=>e.jsx(me,{...t,layout:"vertical",children:e.jsx(f.DatePicker.RangePicker,{allowEmpty:[!0,!0],format:"DD/MM/YYYY"})}),Ei=t=>{const{ooui:r,showLabel:n=!1}=t,{label:s,id:o}=r,i=[new se.Field({name:o+"#date",label:""}),new se.Field({name:o+"#time",label:""})];return e.jsxs(e.Fragment,{children:[n&&e.jsx(pt,{ooui:new se.Label({name:o+"_label",string:s,help:r.tooltip,fieldForLabel:o}),align:"left"}),e.jsxs(f.Row,{align:"bottom",className:"p-0",children:[e.jsx(f.Col,{className:"mr-2",children:e.jsx(me,{...t,ooui:i[0],showLabel:!1,children:e.jsx(f.DatePicker.RangePicker,{className:"w-60",allowEmpty:[!0,!0],format:"DD/MM/YYYY"})})}),e.jsx(f.Col,{children:e.jsx(me,{...t,ooui:i[1],showLabel:!1,children:e.jsx(f.TimePicker.RangePicker,{className:"w-60",allowEmpty:[!0,!0],format:"HH:mm"})})})]})]})},{useToken:Ii}=f.theme,Jt=t=>{const{ooui:r}=t,{id:n,decimalDigits:s,readOnly:o,required:i}=r,{token:a}=Ii(),c=i&&!o?{backgroundColor:a.colorPrimaryBg}:void 0,d=l.useContext(_e),{elementHasLostFocus:u}=d||{};return e.jsx(me,{required:i,type:"number",...t,children:e.jsx(f.InputNumber,{disabled:o,className:"w-full",style:c,id:n,precision:s,formatter:h=>`${h}`.replace(/[^0-9\.\-]+/g,""),defaultValue:0,decimalSeparator:".",onBlur:u})})},{useToken:Mi}=f.theme,vt=t=>{const{ooui:r,onChange:n}=t,{id:s,readOnly:o,required:i}=r,{token:a}=Mi(),c=i&&!o?{backgroundColor:a.colorPrimaryBg}:void 0,d=l.useContext(_e),{elementHasLostFocus:u}=d||{};return e.jsx(me,{required:i,type:"number",...t,children:e.jsx(f.InputNumber,{id:s,className:"w-full ",disabled:o,formatter:h=>`${h}`.replace(/[^0-9\-]+/g,""),onChange:h=>{const p=h;n==null||n(p)},defaultValue:0,onBlur:u,precision:0,style:c})})};function Ai(t){const{ooui:r,showLabel:n}=t,{id:s,label:o,tooltip:i}=r,a=r instanceof se.Integer?vt:Jt,c=d=>e.jsx(a,{ooui:{...r,id:s+d,label:"",tooltip:void 0},layout:"vertical"});return e.jsxs(e.Fragment,{children:[n&&e.jsx(pt,{ooui:new se.Label({name:s+"_label",string:o,help:i,fieldForLabel:s}),align:"left"}),e.jsxs(f.Row,{align:"bottom",className:"mt-0",wrap:!1,children:[e.jsx(f.Col,{children:c("#from")}),e.jsx(f.Col,{className:"pb-1",children:e.jsx("span",{className:"pl-2 pr-2 h-full",children:" - "})}),e.jsx(f.Col,{children:c("#to")})]})]})}const{defaultAlgorithm:$i,defaultSeed:Li}=f.theme,Ni=$i(Li),{Option:Pi}=f.Select,Bi=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,type:"any",...t,children:e.jsx(Hi,{...t})})},Hi=t=>{const{ooui:r,onChange:n,value:s}=t,{selectionValues:o,readOnly:i,required:a}=r,c=Array.from(o.entries()),d=c&&c.length&&c.filter(p=>{const[g]=p;return s?!s.includes(g):!0}).map(p=>{const[g,w]=p;return e.jsx(Pi,{value:w,children:w},g)}),u=a&&!i?Ki:f.Select;function h(p){const g=p.map(w=>{const m=c.find(([y,C])=>w===C);return m&&m[0]});if(g.length===0){n==null||n(void 0);return}n==null||n(g)}return e.jsx(u,{disabled:i,onChange:h,value:s==null?void 0:s.map(p=>o.get(p)),mode:"multiple",showArrow:!0,children:d})},Ki=ht.default(f.Select)`
19
+ `)!==-1){const{message:o,type:i,title:a}=xr(t);n=e.jsx(Pt.Interweave,{content:`${a}<br />${o}`}),s=i}else n=t.message?JSON.stringify(t.message):JSON.stringify(t);return e.jsx(f.Alert,{className:r,message:n,type:s,banner:!0})},Di=800;function Vi(t,r){const{model:n,id:s,onCancel:o,onSubmitSucceed:i,showFooter:a=!1,getDataFromAction:c=!1,onFieldsChange:d,onSubmitError:u,readOnly:h=!1,mustClearAfterSave:p=!1,submitMode:g="api",values:w,formView:m,postSaveAction:y,insideButtonModal:C=!1,parentContext:v={},actionDomain:E,visible:_=!0,rootForm:S=!1,defaultValues:I,forcedValues:D={}}=t,{t:N,lang:b}=l.useContext(ge),[x,O]=l.useState(!1),[T,H]=l.useState(),[F,A]=l.useState(),[k]=f.Form.useForm(),[L,V]=l.useState(),[M,K]=l.useState(),q=l.useContext(Ur),[z,Y]=l.useState(),[Z,J]=l.useState(!1),$=l.useRef(),P=l.useRef({}),ee=l.useRef({}),le=l.useRef(!1),ce=l.useRef(!1),re=z<Di,X=l.useContext(_e),{activeId:we,getPlainValues:Ce}=X||{},ke=l.useContext(Be),{setFormIsSaving:fe=void 0,setFormHasChanges:oe=void 0,setCurrentId:be=void 0,setFormIsLoading:ye=void 0,setAttachments:xe=void 0,title:Ee=void 0,setTitle:Ve=void 0}=(S?ke:{})||{},He=l.useContext(it),{processAction:Ie,globalValues:R}=He||{};l.useImperativeHandle(r,()=>({submitForm:Lt,getFields:Ae,getValues:De,getPlainValues:Ze,getContext:Ge,fetchValues:je,cancelUnsavedChanges:Xe,clearAndReload:()=>{$.current=void 0,A(void 0),Ue()}})),l.useEffect(()=>{if(H(void 0),!(!n&&!m)){if(!_){$.current=void 0,A(void 0);return}(s===void 0&&M||s!==void 0&&M&&s<0)&&($.current=void 0,A(void 0)),Ue()}},[s,n,w,m,_]),l.useEffect(()=>{Z&&(cr({elementHasLostFocus:!0}),J(!1))},[Z]);const ae=(j,U,te)=>{oe==null||oe(!1),fe==null||fe(!1),i==null||i(j,U,te),be==null||be(j)},he=()=>{fe==null||fe(!1),o==null||o()},Oe=j=>{fe==null||fe(!1),u==null||u(j)};function ue(){return s||$.current}function Ae(){return M}function De(){const j={...ie(M),...Q()};for(const U in j)j[U]===void 0&&delete j[U];return j}function Ze(){const j=De(),U=Ae();let te={};return Object.keys(j).forEach(ne=>{const Fe=j[ne];U[ne]&&U[ne].type==="many2one"&&Fe&&Array.isArray(Fe)&&Fe.length===2?te[ne]=Fe[0]:U[ne]&&(U[ne].type==="one2many"||U[ne].type==="many2many")&&Fe&&Fe.items?te[ne]=Fe.items.filter(Re=>Re.operation!=="pendingRemove").map(Re=>Re.id):te[ne]=Fe}),te}function Ke(){const j={...ie(M)};for(const U in j)j[U]===void 0&&delete j[U];return j}function Ge(){return{...v,...F==null?void 0:F.context}}function Q(){return{id:ue(),active_id:ue(),active_ids:[ue()],parent_id:we,...R}}const de=async j=>{const U=ue()?F==null?void 0:F.context:{};return await W.getHandler().defaultGet({model:n,fields:j,context:{...v,...U},extraValues:I})},Te=()=>Object.keys(jt({source:P.current,target:ie(M),fields:M})).length!==0,ie=j=>{const U=k.getFieldsValue(!0);return ot(U,j)},ve=(j,U)=>{$t({values:{...ot(k.getFieldsValue(!0),M),[j]:U},fields:M,reset:!1})},pe=j=>k.getFieldsValue(!0)[j];async function $e(){try{return await k.validateFields(),!1}catch{return f.message.error(N("fillRequiredFields")),!0}}const Ue=async()=>{H(void 0),ye==null||ye(!0);let j;try{m?j={arch:m.arch,fields:m.fields}:j=await Zl();const{fields:U,arch:te}=j;K(U),V(te),await je({fields:U,arch:te})}catch(U){H(U!=null&&U.message?U.message+U.stack:U),ye==null||ye(!1)}},je=async j=>{let U,te,ne,Fe;ye==null||ye(!0),H(void 0),j?(te=j.fields,ne=j.arch):(te=M,ne=L),w?U=w:{values:U,defaultGetCalled:Fe}=await Xl({fields:te,arch:ne}),E&&(U={...Rs(E),...U}),P.current=ot(U,te),$t({values:U,fields:te,reset:!0,isDefaultGet:Fe}),Nt({fields:te,arch:ne,values:U}),ye==null||ye(!1),oe==null||oe(!1),Fe&&J(!0)},Xe=async()=>new Promise(async j=>{Te()?yt({lang:b,onOk:()=>{he==null||he(),j(!0)},onCancel:()=>{j(!1)}}):(he==null||he(),j(!0))}),Zl=async()=>{if(c){const j=await W.getHandler().getActionStringForModel(n);return(await W.getHandler().getViewsForAction({action:j,context:v})).views.get("form")}return await W.getHandler().getView({model:n,type:"form",context:v})},$t=({values:j,fields:U,reset:te,isDefaultGet:ne=!1})=>{const Re={...te?{}:k.getFieldsValue(!0),...j},dr=ot(Re,U),dc=Object.keys(U).map(ur=>{const uc=dr[ur]!==void 0?dr[ur]:void 0;return{name:ur,touched:!1,value:uc}});ne||(ee.current=dr),k.setFields(dc)},Xl=async({fields:j,arch:U})=>{let te={},ne=!1;if(ue()){te=(await W.getHandler().readObjects({model:n,ids:[ue()],fields:j,context:v}))[0];const Fe=await W.getHandler().search({params:[["res_model","=",n],["res_id","=",ue()]],fields:["id","name"],context:Ge(),model:"ir.attachment"});xe==null||xe(Fe)}else xe==null||xe([]),te=await de(j),ne=!0;return{values:te,defaultGetCalled:ne}},Ql=async j=>{const{callOnSubmitSucceed:U=!0}=j||{};if(ue()){const te=jt({source:P.current,target:ie(M),fields:M});await W.getHandler().update({model:n,id:ue(),values:{...te,...D},fields:M,context:{...v,...F==null?void 0:F.context}}),P.current=ie(M)}else{const te=ie(M),ne=await W.getHandler().create({model:n,values:{...te,...D},fields:M,context:{...v,...F==null?void 0:F.context}});$.current=ne,P.current=te}y&&await y([ue()]),!C&&U&&(ae==null||ae(ue(),De(),Ke()))},Rl=async j=>{const{callOnSubmitSucceed:U=!0}=j||{};!C&&U&&(ae==null||ae(ue(),De(),Ke()))},Lt=async j=>{let U=!1;const{callOnSubmitSucceed:te=!0}=j||{};if(ce.current=!0,H(void 0),!Te()&&ue()&&te)return ce.current=!1,oe==null||oe(!1),he==null||he(),{succeed:!0,id:ue()};if(await $e())return ce.current=!1,Gr(b),{succeed:!1,id:ue()};O(!0),fe==null||fe(!0);try{g==="api"?await Ql(j):await Rl(j),p&&($.current=void 0,$t({values:{},fields:M,reset:!0})),await je(),U=!0,f.message.success(N("savedRegisters"))}catch(ne){ce.current=!1,O(!1),fe==null||fe(!1),Oe==null||Oe(ne),f.message.error(N("errorWhileSavingForm")),H(ne!=null&&ne.message?ne.message:ne)}finally{ce.current=!1,fe==null||fe(!1),O(!1)}return{succeed:U,id:ue()}},Nt=({fields:j,arch:U,values:te})=>{var Fe;const ne=new se.Form(j);ne.parse(U,{readOnly:h,values:Ys({...te,...Q()},j)}),A(ne),ne.string&&ne.string!==Ee&&(Ve==null||Ve(ne.string)),q&&ne.string&&((Fe=q.setTitle)==null||Fe.call(q,ne.string))},cr=async({elementHasLostFocus:j=!1})=>{if(ce.current)return;const U=jt({source:ee.current,target:ie(M),fields:M}),te=Object.keys(U);if(te.length!==0){if(Xs({changedFields:te,formOoui:F,types:["text","codeeditor","email","url","char","float","float_time","integer","many2one"]})&&j!==!0)return;{const ne=ot(k.getFieldsValue(!0),M);ee.current=ne,d==null||d(ne),oe==null||oe(!0),tc(te)}}},ec=Ns(cr,100),tc=async j=>{try{for(let U=0;U<j.length;U+=1){const te=j[U];await rc(te)}}catch(U){Me(U)}},rc=async j=>{const U=F==null?void 0:F.onChangeFields[j];if(!U){Nt({fields:M,arch:L,values:ie(M)});return}const te=ei({values:{...ie(M),context:{...v,...F==null?void 0:F.context}},parentValues:Ce==null?void 0:Ce(),onChangeFieldActionArgs:U.args}),ne=await W.getHandler().executeOnChange({model:n,action:U.method,ids:ue()?[ue()]:[],payload:te,fields:M});if(ne.value){const Fe={...ie(M),...ne.value};Nt({fields:M,arch:L,values:Fe}),$t({values:Fe,fields:M,reset:!1})}if(ne.warning&&ne.warning.title&&ne.warning.message&&!le.current){const{title:Fe,message:Re}=ne.warning;le.current=!0,hi(Fe,Re,()=>{le.current=!1})}if(ne.domain&&Object.keys(ne.domain).length>0){const Fe=Qs({fieldsDomain:ne.domain,fields:M});Nt({fields:Fe,arch:L,values:ie(Fe)}),K(Fe)}};async function nc({action:j,context:U}){const te=await W.getHandler().execute({model:n,action:j,payload:[ue()],context:{...U,...F==null?void 0:F.context,...v}});if(typeof te=="object"&&te!==null&&Object.keys(te).length===0&&C)ae==null||ae(ue(),De(),Ke());else if(te.type&&te.type==="ir.actions.act_window_close")ae==null||ae(ue(),De(),Ke());else if(te.type){let ne={};te.context&&(ne=se.parseContext({context:te.context,fields:M,values:De()})),await jn({actionData:te,context:{...U,...ne}})}else await je()}async function oc({action:j}){const U=await W.getHandler().executeWorkflow({model:n,action:j,payload:ue()});U.type&&U.type==="ir.actions.act_window_close"?ae==null||ae(ue(),De(),Ke()):await je()}async function sc({action:j,context:U}){const te=(await W.getHandler().readObjects({model:"ir.actions.actions",ids:[parseInt(j)],context:v}))[0];await jn({actionData:te,context:U})}async function jn({actionData:j,context:U}){const{closeParent:te}=await(Ie==null?void 0:Ie({actionData:j,fields:M,values:De(),context:{...v,...F==null?void 0:F.context,...U},onRefreshParentValues:()=>{je()}}))||{};!S&&te&&(ae==null||ae(ue(),De(),Ke()))}function ic(){cr({elementHasLostFocus:!0})}async function ac({type:j,action:U,context:te}){if(j==="cancel"){he==null||he();return}if(await $e()){Gr(b);return}try{(Te()||ue()===void 0)&&await Lt({callOnSubmitSucceed:!1}),j==="object"?await nc({action:U,context:te}):j==="workflow"?await oc({action:U}):j==="action"&&await sc({action:U,context:te})}catch(ne){Me(ne)}}const lc=()=>!F&&!T?e.jsx(f.Spin,{}):!n&&!m||!_?null:e.jsx(e.Fragment,{children:e.jsx(bo,{getValues:De,getPlainValues:Ze,getFields:Ae,domain:E,activeId:s,activeModel:n,setFieldValue:ve,getFieldValue:pe,executeButtonAction:ac,getContext:Ge,submitForm:Lt,fetchValues:je,formHasChanges:Te,elementHasLostFocus:ic,children:e.jsx(f.Form,{form:k,onFieldsChange:()=>{ec({elementHasLostFocus:!1})},component:!1,children:F&&e.jsx(zt,{container:F.container,responsiveBehaviour:re})})})}),cc=()=>e.jsxs(e.Fragment,{children:[e.jsx(f.Divider,{}),e.jsx(f.Row,{justify:"end",children:e.jsxs(f.Space,{children:[e.jsx(f.Button,{icon:e.jsx(B.CloseOutlined,{}),disabled:x,onClick:async()=>{await Xe()},children:"Cancel"}),e.jsx(f.Button,{disabled:x||h,loading:x,icon:e.jsx(B.CheckOutlined,{}),onClick:async()=>{await Lt()},type:"primary",children:"OK"})]})})]});return _?e.jsx(Ht.default,{bounds:!0,onResize:j=>{var U;Y((U=j.bounds)==null?void 0:U.width)},children:({measureRef:j})=>e.jsxs("div",{className:"pb-2",ref:j,children:[T&&e.jsx(_i,{className:"mt-5 mb-10",error:T}),lc(),a&&cc()]})}):null}const at=l.forwardRef(Vi),lt=t=>{const{visible:r,id:n,title:s,buttonModal:o=!1,onCancel:i,isMenuAction:a=!1,actionData:c,...d}=t,{modalWidth:u}=xt(),[h,p]=l.useState(s),[g,w]=l.useState(!1),[m,y]=l.useState();l.useEffect(()=>{a&&C()},[c,a]);async function C(){const{action_id:_,res_id:S,action_type:I,view_id:D}=c,N=await W.getHandler().isShortcutFavorite({action_id:_,action_type:I,view_id:D,res_id:S||!1});w(N!==!1),N!==!1&&y(N)}async function v(){if(g&&m)await W.getHandler().removeFavourite({shortcut_id:m});else{const{action_id:_,res_id:S,action_type:I,view_id:D}=c;await W.getHandler().addFavourite({action_id:_,action_type:I,view_id:D,res_id:S||!1})}w(!g)}function E(){return e.jsxs(f.Row,{align:"middle",children:[e.jsx(f.Col,{children:e.jsx(f.Button,{type:g?"primary":"default",icon:g?e.jsx(B.StarFilled,{style:{color:"white"}}):e.jsx(B.StarOutlined,{}),style:{width:30},onClick:v})}),e.jsx(f.Col,{style:{paddingLeft:10},children:h})]})}return e.jsx(pi,{setTitle:p,children:e.jsx(f.Modal,{title:a?E():h,centered:!0,width:u,open:r,footer:null,destroyOnClose:!0,onCancel:i,maskClosable:!1,children:e.jsx(at,{id:n,showFooter:!0,insideButtonModal:o,onCancel:i,...d})})})},ki=t=>e.jsx(me,{...t,layout:"vertical",children:e.jsx(f.DatePicker.RangePicker,{allowEmpty:[!0,!0],format:"DD/MM/YYYY"})}),Ei=t=>{const{ooui:r,showLabel:n=!1}=t,{label:s,id:o}=r,i=[new se.Field({name:o+"#date",label:""}),new se.Field({name:o+"#time",label:""})];return e.jsxs(e.Fragment,{children:[n&&e.jsx(pt,{ooui:new se.Label({name:o+"_label",string:s,help:r.tooltip,fieldForLabel:o}),align:"left"}),e.jsxs(f.Row,{align:"bottom",className:"p-0",children:[e.jsx(f.Col,{className:"mr-2",children:e.jsx(me,{...t,ooui:i[0],showLabel:!1,children:e.jsx(f.DatePicker.RangePicker,{className:"w-60",allowEmpty:[!0,!0],format:"DD/MM/YYYY"})})}),e.jsx(f.Col,{children:e.jsx(me,{...t,ooui:i[1],showLabel:!1,children:e.jsx(f.TimePicker.RangePicker,{className:"w-60",allowEmpty:[!0,!0],format:"HH:mm"})})})]})]})},{useToken:Ii}=f.theme,Jt=t=>{const{ooui:r}=t,{id:n,decimalDigits:s,readOnly:o,required:i}=r,{token:a}=Ii(),c=i&&!o?{backgroundColor:a.colorPrimaryBg}:void 0,d=l.useContext(_e),{elementHasLostFocus:u}=d||{};return e.jsx(me,{required:i,type:"number",...t,children:e.jsx(f.InputNumber,{disabled:o,className:"w-full",style:c,id:n,precision:s,formatter:h=>`${h}`.replace(/[^0-9\.\-]+/g,""),defaultValue:0,decimalSeparator:".",onBlur:u})})},{useToken:Mi}=f.theme,vt=t=>{const{ooui:r,onChange:n}=t,{id:s,readOnly:o,required:i}=r,{token:a}=Mi(),c=i&&!o?{backgroundColor:a.colorPrimaryBg}:void 0,d=l.useContext(_e),{elementHasLostFocus:u}=d||{};return e.jsx(me,{required:i,type:"number",...t,children:e.jsx(f.InputNumber,{id:s,className:"w-full ",disabled:o,formatter:h=>`${h}`.replace(/[^0-9\-]+/g,""),onChange:h=>{const p=h;n==null||n(p)},defaultValue:0,onBlur:u,precision:0,style:c})})};function Ai(t){const{ooui:r,showLabel:n}=t,{id:s,label:o,tooltip:i}=r,a=r instanceof se.Integer?vt:Jt,c=d=>e.jsx(a,{ooui:{...r,id:s+d,label:"",tooltip:void 0},layout:"vertical"});return e.jsxs(e.Fragment,{children:[n&&e.jsx(pt,{ooui:new se.Label({name:s+"_label",string:o,help:i,fieldForLabel:s}),align:"left"}),e.jsxs(f.Row,{align:"bottom",className:"mt-0",wrap:!1,children:[e.jsx(f.Col,{children:c("#from")}),e.jsx(f.Col,{className:"pb-1",children:e.jsx("span",{className:"pl-2 pr-2 h-full",children:" - "})}),e.jsx(f.Col,{children:c("#to")})]})]})}const{defaultAlgorithm:$i,defaultSeed:Li}=f.theme,Ni=$i(Li),{Option:Pi}=f.Select,Bi=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,type:"any",...t,children:e.jsx(Hi,{...t})})},Hi=t=>{const{ooui:r,onChange:n,value:s}=t,{selectionValues:o,readOnly:i,required:a}=r,c=Array.from(o.entries()),d=c&&c.length&&c.filter(p=>{const[g]=p;return s?!s.includes(g):!0}).map(p=>{const[g,w]=p;return e.jsx(Pi,{value:w,children:w},g)}),u=a&&!i?Ki:f.Select;function h(p){const g=p.map(w=>{const m=c.find(([y,C])=>w===C);return m&&m[0]});if(g.length===0){n==null||n(void 0);return}n==null||n(g)}return e.jsx(u,{disabled:i,onChange:h,value:s==null?void 0:s.map(p=>o.get(p)),mode:"multiple",showArrow:!0,children:d})},Ki=ht.default(f.Select)`
20
20
  &.ant-select:not(.ant-select-customize-input) .ant-select-selector {
21
21
  background-color: ${Ni.colorPrimaryBg};
22
22
  }